ide-cd: move the remaining cdrom.c ioctl handling code to ide-cd_ioctl.c
[linux-2.6/cjktty.git] / drivers / ide / ide-cd.h
blob58ae663425a8b4aeaf02c35628cf0141fd30b76c
1 /*
2 * linux/drivers/ide/ide_cd.h
4 * Copyright (C) 1996-98 Erik Andersen
5 * Copyright (C) 1998-2000 Jens Axboe
6 */
7 #ifndef _IDE_CD_H
8 #define _IDE_CD_H
10 #include <linux/cdrom.h>
11 #include <asm/byteorder.h>
14 * typical timeout for packet command
16 #define ATAPI_WAIT_PC (60 * HZ)
17 #define ATAPI_WAIT_WRITE_BUSY (10 * HZ)
19 /************************************************************************/
21 #define SECTOR_BITS 9
22 #ifndef SECTOR_SIZE
23 #define SECTOR_SIZE (1 << SECTOR_BITS)
24 #endif
25 #define SECTORS_PER_FRAME (CD_FRAMESIZE >> SECTOR_BITS)
26 #define SECTOR_BUFFER_SIZE (CD_FRAMESIZE * 32)
28 /* Capabilities Page size including 8 bytes of Mode Page Header */
29 #define ATAPI_CAPABILITIES_PAGE_SIZE (8 + 20)
30 #define ATAPI_CAPABILITIES_PAGE_PAD_SIZE 4
32 enum {
33 /* Device sends an interrupt when ready for a packet command. */
34 IDE_CD_FLAG_DRQ_INTERRUPT = (1 << 0),
35 /* Drive cannot lock the door. */
36 IDE_CD_FLAG_NO_DOORLOCK = (1 << 1),
37 /* Drive cannot eject the disc. */
38 IDE_CD_FLAG_NO_EJECT = (1 << 2),
39 /* Drive is a pre ATAPI 1.2 drive. */
40 IDE_CD_FLAG_PRE_ATAPI12 = (1 << 3),
41 /* TOC addresses are in BCD. */
42 IDE_CD_FLAG_TOCADDR_AS_BCD = (1 << 4),
43 /* TOC track numbers are in BCD. */
44 IDE_CD_FLAG_TOCTRACKS_AS_BCD = (1 << 5),
46 * Drive does not provide data in multiples of SECTOR_SIZE
47 * when more than one interrupt is needed.
49 IDE_CD_FLAG_LIMIT_NFRAMES = (1 << 6),
50 /* Seeking in progress. */
51 IDE_CD_FLAG_SEEKING = (1 << 7),
52 /* Driver has noticed a media change. */
53 IDE_CD_FLAG_MEDIA_CHANGED = (1 << 8),
54 /* Saved TOC information is current. */
55 IDE_CD_FLAG_TOC_VALID = (1 << 9),
56 /* We think that the drive door is locked. */
57 IDE_CD_FLAG_DOOR_LOCKED = (1 << 10),
58 /* SET_CD_SPEED command is unsupported. */
59 IDE_CD_FLAG_NO_SPEED_SELECT = (1 << 11),
60 IDE_CD_FLAG_VERTOS_300_SSD = (1 << 12),
61 IDE_CD_FLAG_VERTOS_600_ESD = (1 << 13),
62 IDE_CD_FLAG_SANYO_3CD = (1 << 14),
63 IDE_CD_FLAG_FULL_CAPS_PAGE = (1 << 15),
64 IDE_CD_FLAG_PLAY_AUDIO_OK = (1 << 16),
65 IDE_CD_FLAG_LE_SPEED_FIELDS = (1 << 17),
68 /* Structure of a MSF cdrom address. */
69 struct atapi_msf {
70 byte reserved;
71 byte minute;
72 byte second;
73 byte frame;
76 /* Space to hold the disk TOC. */
77 #define MAX_TRACKS 99
78 struct atapi_toc_header {
79 unsigned short toc_length;
80 byte first_track;
81 byte last_track;
84 struct atapi_toc_entry {
85 byte reserved1;
86 #if defined(__BIG_ENDIAN_BITFIELD)
87 __u8 adr : 4;
88 __u8 control : 4;
89 #elif defined(__LITTLE_ENDIAN_BITFIELD)
90 __u8 control : 4;
91 __u8 adr : 4;
92 #else
93 #error "Please fix <asm/byteorder.h>"
94 #endif
95 byte track;
96 byte reserved2;
97 union {
98 unsigned lba;
99 struct atapi_msf msf;
100 } addr;
103 struct atapi_toc {
104 int last_session_lba;
105 int xa_flag;
106 unsigned long capacity;
107 struct atapi_toc_header hdr;
108 struct atapi_toc_entry ent[MAX_TRACKS+1];
109 /* One extra for the leadout. */
112 /* Extra per-device info for cdrom drives. */
113 struct cdrom_info {
114 ide_drive_t *drive;
115 ide_driver_t *driver;
116 struct gendisk *disk;
117 struct kref kref;
119 /* Buffer for table of contents. NULL if we haven't allocated
120 a TOC buffer for this device yet. */
122 struct atapi_toc *toc;
124 unsigned long sector_buffered;
125 unsigned long nsectors_buffered;
126 unsigned char *buffer;
128 /* The result of the last successful request sense command
129 on this device. */
130 struct request_sense sense_data;
132 struct request request_sense_request;
133 int dma;
134 unsigned long last_block;
135 unsigned long start_seek;
137 unsigned int cd_flags;
139 u8 max_speed; /* Max speed of the drive. */
140 u8 current_speed; /* Current speed of the drive. */
142 /* Per-device info needed by cdrom.c generic driver. */
143 struct cdrom_device_info devinfo;
145 unsigned long write_timeout;
148 /* ide-cd_verbose.c */
149 void ide_cd_log_error(const char *, struct request *, struct request_sense *);
151 /* ide-cd.c functions used by ide-cd_ioctl.c */
152 void ide_cd_init_rq(ide_drive_t *, struct request *);
153 int ide_cd_queue_pc(ide_drive_t *, struct request *);
154 int ide_cd_read_toc(ide_drive_t *, struct request_sense *);
155 int ide_cdrom_get_capabilities(ide_drive_t *, u8 *);
156 void ide_cdrom_update_speed(ide_drive_t *, u8 *);
157 int cdrom_check_status(ide_drive_t *, struct request_sense *);
159 /* ide-cd_ioctl.c */
160 int ide_cdrom_open_real(struct cdrom_device_info *, int);
161 void ide_cdrom_release_real(struct cdrom_device_info *);
162 int ide_cdrom_drive_status(struct cdrom_device_info *, int);
163 int ide_cdrom_check_media_change_real(struct cdrom_device_info *, int);
164 int ide_cdrom_tray_move(struct cdrom_device_info *, int);
165 int ide_cdrom_lock_door(struct cdrom_device_info *, int);
166 int ide_cdrom_select_speed(struct cdrom_device_info *, int);
167 int ide_cdrom_get_last_session(struct cdrom_device_info *,
168 struct cdrom_multisession *);
169 int ide_cdrom_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *);
170 int ide_cdrom_reset(struct cdrom_device_info *cdi);
171 int ide_cdrom_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
172 int ide_cdrom_packet(struct cdrom_device_info *, struct packet_command *);
174 #endif /* _IDE_CD_H */