blob: a69dc7f61c4d57bd64bbbecad280ef1f2e626b1f [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Copyright (C) 1996-98 Erik Andersen
4 * Copyright (C) 1998-2000 Jens Axboe
5 */
6#ifndef _IDE_CD_H
7#define _IDE_CD_H
8
9#include <linux/cdrom.h>
10#include <asm/byteorder.h>
11
Borislav Petkov0f38aaa2009-01-02 16:12:50 +010012#define IDECD_DEBUG_LOG 0
13
14#if IDECD_DEBUG_LOG
Borislav Petkov088b1b82009-01-02 13:34:47 +010015#define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args)
Borislav Petkov0f38aaa2009-01-02 16:12:50 +010016#else
17#define ide_debug_log(lvl, fmt, args...) do {} while (0)
18#endif
19
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#define ATAPI_WAIT_WRITE_BUSY (10 * HZ)
21
22/************************************************************************/
23
Bart Van Assche233bde22018-03-14 15:48:06 -070024#define SECTORS_PER_FRAME (CD_FRAMESIZE >> SECTOR_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#define SECTOR_BUFFER_SIZE (CD_FRAMESIZE * 32)
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Bartlomiej Zolnierkiewicz455d80a2008-02-01 23:09:21 +010027/* Capabilities Page size including 8 bytes of Mode Page Header */
28#define ATAPI_CAPABILITIES_PAGE_SIZE (8 + 20)
29#define ATAPI_CAPABILITIES_PAGE_PAD_SIZE 4
30
Linus Torvalds1da177e2005-04-16 15:20:36 -070031/* Structure of a MSF cdrom address. */
32struct atapi_msf {
Bartlomiej Zolnierkiewicz9892ec52009-01-06 17:20:53 +010033 u8 reserved;
34 u8 minute;
35 u8 second;
36 u8 frame;
Linus Torvalds1da177e2005-04-16 15:20:36 -070037};
38
39/* Space to hold the disk TOC. */
40#define MAX_TRACKS 99
41struct atapi_toc_header {
42 unsigned short toc_length;
Bartlomiej Zolnierkiewicz9892ec52009-01-06 17:20:53 +010043 u8 first_track;
44 u8 last_track;
Linus Torvalds1da177e2005-04-16 15:20:36 -070045};
46
47struct atapi_toc_entry {
Bartlomiej Zolnierkiewicz9892ec52009-01-06 17:20:53 +010048 u8 reserved1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#if defined(__BIG_ENDIAN_BITFIELD)
Bartlomiej Zolnierkiewicz9892ec52009-01-06 17:20:53 +010050 u8 adr : 4;
51 u8 control : 4;
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#elif defined(__LITTLE_ENDIAN_BITFIELD)
Bartlomiej Zolnierkiewicz9892ec52009-01-06 17:20:53 +010053 u8 control : 4;
54 u8 adr : 4;
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#else
56#error "Please fix <asm/byteorder.h>"
57#endif
Bartlomiej Zolnierkiewicz9892ec52009-01-06 17:20:53 +010058 u8 track;
59 u8 reserved2;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 union {
61 unsigned lba;
62 struct atapi_msf msf;
63 } addr;
64};
65
66struct atapi_toc {
67 int last_session_lba;
68 int xa_flag;
69 unsigned long capacity;
70 struct atapi_toc_header hdr;
71 struct atapi_toc_entry ent[MAX_TRACKS+1];
72 /* One extra for the leadout. */
73};
74
Linus Torvalds1da177e2005-04-16 15:20:36 -070075/* Extra per-device info for cdrom drives. */
76struct cdrom_info {
Bartlomiej Zolnierkiewicz7f3c8682009-01-06 17:20:53 +010077 ide_drive_t *drive;
78 struct ide_driver *driver;
79 struct gendisk *disk;
Bartlomiej Zolnierkiewicz8fed4362009-02-25 20:28:24 +010080 struct device dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
82 /* Buffer for table of contents. NULL if we haven't allocated
83 a TOC buffer for this device yet. */
84
85 struct atapi_toc *toc;
86
Bartlomiej Zolnierkiewicz2bc4cf22008-02-01 23:09:22 +010087 u8 max_speed; /* Max speed of the drive. */
88 u8 current_speed; /* Current speed of the drive. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
90 /* Per-device info needed by cdrom.c generic driver. */
91 struct cdrom_device_info devinfo;
92
93 unsigned long write_timeout;
94};
95
Bartlomiej Zolnierkiewicz972560f2008-02-01 23:09:23 +010096/* ide-cd_verbose.c */
97void ide_cd_log_error(const char *, struct request *, struct request_sense *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
Bartlomiej Zolnierkiewicz17802992008-02-01 23:09:25 +010099/* ide-cd.c functions used by ide-cd_ioctl.c */
FUJITA Tomonori5f828542008-07-15 21:21:42 +0200100int ide_cd_queue_pc(ide_drive_t *, const unsigned char *, int, void *,
Kees Cooke7d07482018-08-02 15:22:13 -0600101 unsigned *, struct scsi_sense_hdr *, int, req_flags_t);
Kees Cook54f8a7a2018-07-31 12:51:46 -0700102int ide_cd_read_toc(ide_drive_t *);
Bartlomiej Zolnierkiewicz17802992008-02-01 23:09:25 +0100103int ide_cdrom_get_capabilities(ide_drive_t *, u8 *);
104void ide_cdrom_update_speed(ide_drive_t *, u8 *);
Kees Cooke7d07482018-08-02 15:22:13 -0600105int cdrom_check_status(ide_drive_t *, struct scsi_sense_hdr *);
Bartlomiej Zolnierkiewicz17802992008-02-01 23:09:25 +0100106
107/* ide-cd_ioctl.c */
Borislav Petkovf9afd182008-02-01 23:09:29 +0100108int ide_cdrom_open_real(struct cdrom_device_info *, int);
109void ide_cdrom_release_real(struct cdrom_device_info *);
110int ide_cdrom_drive_status(struct cdrom_device_info *, int);
Tejun Heo5b03a1b2011-03-09 19:54:27 +0100111unsigned int ide_cdrom_check_events_real(struct cdrom_device_info *,
112 unsigned int clearing, int slot_nr);
Borislav Petkovf9afd182008-02-01 23:09:29 +0100113int ide_cdrom_tray_move(struct cdrom_device_info *, int);
Bartlomiej Zolnierkiewicz17802992008-02-01 23:09:25 +0100114int ide_cdrom_lock_door(struct cdrom_device_info *, int);
115int ide_cdrom_select_speed(struct cdrom_device_info *, int);
116int ide_cdrom_get_last_session(struct cdrom_device_info *,
117 struct cdrom_multisession *);
118int ide_cdrom_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *);
119int ide_cdrom_reset(struct cdrom_device_info *cdi);
120int ide_cdrom_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
Borislav Petkovf9afd182008-02-01 23:09:29 +0100121int ide_cdrom_packet(struct cdrom_device_info *, struct packet_command *);
Bartlomiej Zolnierkiewicz17802992008-02-01 23:09:25 +0100122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123#endif /* _IDE_CD_H */