ide-cd: remove duplicate sense keys definitions from ide-cd.h
[safe/jmp/linux-2.6] / drivers / ide / ide-cd.h
1 /*
2  *  linux/drivers/ide/ide_cd.h
3  *
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
9
10 #include <linux/cdrom.h>
11 #include <asm/byteorder.h>
12
13 /* Turn this on to have the driver print out the meanings of the
14    ATAPI error codes.  This will use up additional kernel-space
15    memory, though. */
16
17 #ifndef VERBOSE_IDE_CD_ERRORS
18 #define VERBOSE_IDE_CD_ERRORS 1
19 #endif
20
21 /*
22  * typical timeout for packet command
23  */
24 #define ATAPI_WAIT_PC           (60 * HZ)
25 #define ATAPI_WAIT_WRITE_BUSY   (10 * HZ)
26
27 /************************************************************************/
28
29 #define SECTOR_BITS             9
30 #ifndef SECTOR_SIZE
31 #define SECTOR_SIZE             (1 << SECTOR_BITS)
32 #endif
33 #define SECTORS_PER_FRAME       (CD_FRAMESIZE >> SECTOR_BITS)
34 #define SECTOR_BUFFER_SIZE      (CD_FRAMESIZE * 32)
35
36 /* Capabilities Page size including 8 bytes of Mode Page Header */
37 #define ATAPI_CAPABILITIES_PAGE_SIZE            (8 + 20)
38 #define ATAPI_CAPABILITIES_PAGE_PAD_SIZE        4
39
40 enum {
41         /* Device sends an interrupt when ready for a packet command. */
42         IDE_CD_FLAG_DRQ_INTERRUPT       = (1 << 0),
43         /* Drive cannot lock the door. */
44         IDE_CD_FLAG_NO_DOORLOCK         = (1 << 1),
45         /* Drive cannot eject the disc. */
46         IDE_CD_FLAG_NO_EJECT            = (1 << 2),
47         /* Drive is a pre ATAPI 1.2 drive. */
48         IDE_CD_FLAG_PRE_ATAPI12         = (1 << 3),
49         /* TOC addresses are in BCD. */
50         IDE_CD_FLAG_TOCADDR_AS_BCD      = (1 << 4),
51         /* TOC track numbers are in BCD. */
52         IDE_CD_FLAG_TOCTRACKS_AS_BCD    = (1 << 5),
53         /*
54          * Drive does not provide data in multiples of SECTOR_SIZE
55          * when more than one interrupt is needed.
56          */
57         IDE_CD_FLAG_LIMIT_NFRAMES       = (1 << 6),
58         /* Seeking in progress. */
59         IDE_CD_FLAG_SEEKING             = (1 << 7),
60         /* Driver has noticed a media change. */
61         IDE_CD_FLAG_MEDIA_CHANGED       = (1 << 8),
62         /* Saved TOC information is current. */
63         IDE_CD_FLAG_TOC_VALID           = (1 << 9),
64         /* We think that the drive door is locked. */
65         IDE_CD_FLAG_DOOR_LOCKED         = (1 << 10),
66         /* SET_CD_SPEED command is unsupported. */
67         IDE_CD_FLAG_NO_SPEED_SELECT     = (1 << 11),
68         IDE_CD_FLAG_VERTOS_300_SSD      = (1 << 12),
69         IDE_CD_FLAG_VERTOS_600_ESD      = (1 << 13),
70         IDE_CD_FLAG_SANYO_3CD           = (1 << 14),
71         IDE_CD_FLAG_FULL_CAPS_PAGE      = (1 << 15),
72         IDE_CD_FLAG_PLAY_AUDIO_OK       = (1 << 16),
73         IDE_CD_FLAG_LE_SPEED_FIELDS     = (1 << 17),
74 };
75
76 /* Structure of a MSF cdrom address. */
77 struct atapi_msf {
78         byte reserved;
79         byte minute;
80         byte second;
81         byte frame;
82 };
83
84 /* Space to hold the disk TOC. */
85 #define MAX_TRACKS 99
86 struct atapi_toc_header {
87         unsigned short toc_length;
88         byte first_track;
89         byte last_track;
90 };
91
92 struct atapi_toc_entry {
93         byte reserved1;
94 #if defined(__BIG_ENDIAN_BITFIELD)
95         __u8 adr     : 4;
96         __u8 control : 4;
97 #elif defined(__LITTLE_ENDIAN_BITFIELD)
98         __u8 control : 4;
99         __u8 adr     : 4;
100 #else
101 #error "Please fix <asm/byteorder.h>"
102 #endif
103         byte track;
104         byte reserved2;
105         union {
106                 unsigned lba;
107                 struct atapi_msf msf;
108         } addr;
109 };
110
111 struct atapi_toc {
112         int    last_session_lba;
113         int    xa_flag;
114         unsigned long capacity;
115         struct atapi_toc_header hdr;
116         struct atapi_toc_entry  ent[MAX_TRACKS+1];
117           /* One extra for the leadout. */
118 };
119
120 /* Extra per-device info for cdrom drives. */
121 struct cdrom_info {
122         ide_drive_t     *drive;
123         ide_driver_t    *driver;
124         struct gendisk  *disk;
125         struct kref     kref;
126
127         /* Buffer for table of contents.  NULL if we haven't allocated
128            a TOC buffer for this device yet. */
129
130         struct atapi_toc *toc;
131
132         unsigned long   sector_buffered;
133         unsigned long   nsectors_buffered;
134         unsigned char   *buffer;
135
136         /* The result of the last successful request sense command
137            on this device. */
138         struct request_sense sense_data;
139
140         struct request request_sense_request;
141         int dma;
142         unsigned long last_block;
143         unsigned long start_seek;
144
145         unsigned int cd_flags;
146
147         u8 max_speed;           /* Max speed of the drive. */
148         u8 current_speed;       /* Current speed of the drive. */
149
150         /* Per-device info needed by cdrom.c generic driver. */
151         struct cdrom_device_info devinfo;
152
153         unsigned long write_timeout;
154 };
155
156 /****************************************************************************
157  * Descriptions of ATAPI error codes.
158  */
159
160 /* This stuff should be in cdrom.h, since it is now generic... */
161 #if VERBOSE_IDE_CD_ERRORS
162
163  /* The generic packet command opcodes for CD/DVD Logical Units,
164  * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ 
165 static const struct {
166         unsigned short packet_command;
167         const char * const text;
168 } packet_command_texts[] = {
169         { GPCMD_TEST_UNIT_READY, "Test Unit Ready" },
170         { GPCMD_REQUEST_SENSE, "Request Sense" },
171         { GPCMD_FORMAT_UNIT, "Format Unit" },
172         { GPCMD_INQUIRY, "Inquiry" },
173         { GPCMD_START_STOP_UNIT, "Start/Stop Unit" },
174         { GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL, "Prevent/Allow Medium Removal" },
175         { GPCMD_READ_FORMAT_CAPACITIES, "Read Format Capacities" },
176         { GPCMD_READ_CDVD_CAPACITY, "Read Cd/Dvd Capacity" },
177         { GPCMD_READ_10, "Read 10" },
178         { GPCMD_WRITE_10, "Write 10" },
179         { GPCMD_SEEK, "Seek" },
180         { GPCMD_WRITE_AND_VERIFY_10, "Write and Verify 10" },
181         { GPCMD_VERIFY_10, "Verify 10" },
182         { GPCMD_FLUSH_CACHE, "Flush Cache" },
183         { GPCMD_READ_SUBCHANNEL, "Read Subchannel" },
184         { GPCMD_READ_TOC_PMA_ATIP, "Read Table of Contents" },
185         { GPCMD_READ_HEADER, "Read Header" },
186         { GPCMD_PLAY_AUDIO_10, "Play Audio 10" },
187         { GPCMD_GET_CONFIGURATION, "Get Configuration" },
188         { GPCMD_PLAY_AUDIO_MSF, "Play Audio MSF" },
189         { GPCMD_PLAYAUDIO_TI, "Play Audio TrackIndex" },
190         { GPCMD_GET_EVENT_STATUS_NOTIFICATION, "Get Event Status Notification" },
191         { GPCMD_PAUSE_RESUME, "Pause/Resume" },
192         { GPCMD_STOP_PLAY_SCAN, "Stop Play/Scan" },
193         { GPCMD_READ_DISC_INFO, "Read Disc Info" },
194         { GPCMD_READ_TRACK_RZONE_INFO, "Read Track Rzone Info" },
195         { GPCMD_RESERVE_RZONE_TRACK, "Reserve Rzone Track" },
196         { GPCMD_SEND_OPC, "Send OPC" },
197         { GPCMD_MODE_SELECT_10, "Mode Select 10" },
198         { GPCMD_REPAIR_RZONE_TRACK, "Repair Rzone Track" },
199         { GPCMD_MODE_SENSE_10, "Mode Sense 10" },
200         { GPCMD_CLOSE_TRACK, "Close Track" },
201         { GPCMD_BLANK, "Blank" },
202         { GPCMD_SEND_EVENT, "Send Event" },
203         { GPCMD_SEND_KEY, "Send Key" },
204         { GPCMD_REPORT_KEY, "Report Key" },
205         { GPCMD_LOAD_UNLOAD, "Load/Unload" },
206         { GPCMD_SET_READ_AHEAD, "Set Read-ahead" },
207         { GPCMD_READ_12, "Read 12" },
208         { GPCMD_GET_PERFORMANCE, "Get Performance" },
209         { GPCMD_SEND_DVD_STRUCTURE, "Send DVD Structure" },
210         { GPCMD_READ_DVD_STRUCTURE, "Read DVD Structure" },
211         { GPCMD_SET_STREAMING, "Set Streaming" },
212         { GPCMD_READ_CD_MSF, "Read CD MSF" },
213         { GPCMD_SCAN, "Scan" },
214         { GPCMD_SET_SPEED, "Set Speed" },
215         { GPCMD_PLAY_CD, "Play CD" },
216         { GPCMD_MECHANISM_STATUS, "Mechanism Status" },
217         { GPCMD_READ_CD, "Read CD" },
218 };
219
220
221
222 /* From Table 303 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
223 static const char * const sense_key_texts[16] = {
224         "No sense data",
225         "Recovered error",
226         "Not ready",
227         "Medium error",
228         "Hardware error",
229         "Illegal request",
230         "Unit attention",
231         "Data protect",
232         "Blank check",
233         "(reserved)",
234         "(reserved)",
235         "Aborted command",
236         "(reserved)",
237         "(reserved)",
238         "Miscompare",
239         "(reserved)",
240 };
241
242 /* From Table 304 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
243 static const struct {
244         unsigned long asc_ascq;
245         const char * const text;
246 } sense_data_texts[] = {
247         { 0x000000, "No additional sense information" },
248         { 0x000011, "Play operation in progress" },
249         { 0x000012, "Play operation paused" },
250         { 0x000013, "Play operation successfully completed" },
251         { 0x000014, "Play operation stopped due to error" },
252         { 0x000015, "No current audio status to return" },
253         { 0x010c0a, "Write error - padding blocks added" },
254         { 0x011700, "Recovered data with no error correction applied" },
255         { 0x011701, "Recovered data with retries" },
256         { 0x011702, "Recovered data with positive head offset" },
257         { 0x011703, "Recovered data with negative head offset" },
258         { 0x011704, "Recovered data with retries and/or CIRC applied" },
259         { 0x011705, "Recovered data using previous sector ID" },
260         { 0x011800, "Recovered data with error correction applied" },
261         { 0x011801, "Recovered data with error correction and retries applied"},
262         { 0x011802, "Recovered data - the data was auto-reallocated" },
263         { 0x011803, "Recovered data with CIRC" },
264         { 0x011804, "Recovered data with L-EC" },
265         { 0x015d00, 
266             "Failure prediction threshold exceeded - Predicted logical unit failure" },
267         { 0x015d01, 
268             "Failure prediction threshold exceeded - Predicted media failure" },
269         { 0x015dff, "Failure prediction threshold exceeded - False" },
270         { 0x017301, "Power calibration area almost full" },
271         { 0x020400, "Logical unit not ready - cause not reportable" },
272         /* Following is misspelled in ATAPI 2.6, _and_ in Mt. Fuji */
273         { 0x020401,
274           "Logical unit not ready - in progress [sic] of becoming ready" },
275         { 0x020402, "Logical unit not ready - initializing command required" },
276         { 0x020403, "Logical unit not ready - manual intervention required" },
277         { 0x020404, "Logical unit not ready - format in progress" },
278         { 0x020407, "Logical unit not ready - operation in progress" },
279         { 0x020408, "Logical unit not ready - long write in progress" },
280         { 0x020600, "No reference position found (media may be upside down)" },
281         { 0x023000, "Incompatible medium installed" },
282         { 0x023a00, "Medium not present" },
283         { 0x025300, "Media load or eject failed" },
284         { 0x025700, "Unable to recover table of contents" },
285         { 0x030300, "Peripheral device write fault" },
286         { 0x030301, "No write current" },
287         { 0x030302, "Excessive write errors" },
288         { 0x030c00, "Write error" },
289         { 0x030c01, "Write error - Recovered with auto reallocation" },
290         { 0x030c02, "Write error - auto reallocation failed" },
291         { 0x030c03, "Write error - recommend reassignment" },
292         { 0x030c04, "Compression check miscompare error" },
293         { 0x030c05, "Data expansion occurred during compress" },
294         { 0x030c06, "Block not compressible" },
295         { 0x030c07, "Write error - recovery needed" },
296         { 0x030c08, "Write error - recovery failed" },
297         { 0x030c09, "Write error - loss of streaming" },
298         { 0x031100, "Unrecovered read error" },
299         { 0x031106, "CIRC unrecovered error" },
300         { 0x033101, "Format command failed" },
301         { 0x033200, "No defect spare location available" },
302         { 0x033201, "Defect list update failure" },
303         { 0x035100, "Erase failure" },
304         { 0x037200, "Session fixation error" },
305         { 0x037201, "Session fixation error writin lead-in" },
306         { 0x037202, "Session fixation error writin lead-out" },
307         { 0x037300, "CD control error" },
308         { 0x037302, "Power calibration area is full" },
309         { 0x037303, "Power calibration area error" },
310         { 0x037304, "Program memory area / RMA update failure" },
311         { 0x037305, "Program memory area / RMA is full" },
312         { 0x037306, "Program memory area / RMA is (almost) full" },
313
314         { 0x040200, "No seek complete" },
315         { 0x040300, "Write fault" },
316         { 0x040900, "Track following error" },
317         { 0x040901, "Tracking servo failure" },
318         { 0x040902, "Focus servo failure" },
319         { 0x040903, "Spindle servo failure" },
320         { 0x041500, "Random positioning error" },
321         { 0x041501, "Mechanical positioning or changer error" },
322         { 0x041502, "Positioning error detected by read of medium" },
323         { 0x043c00, "Mechanical positioning or changer error" },
324         { 0x044000, "Diagnostic failure on component (ASCQ)" },
325         { 0x044400, "Internal CD/DVD logical unit failure" },
326         { 0x04b600, "Media load mechanism failed" },
327         { 0x051a00, "Parameter list length error" },
328         { 0x052000, "Invalid command operation code" },
329         { 0x052100, "Logical block address out of range" },
330         { 0x052102, "Invalid address for write" },
331         { 0x052400, "Invalid field in command packet" },
332         { 0x052600, "Invalid field in parameter list" },
333         { 0x052601, "Parameter not supported" },
334         { 0x052602, "Parameter value invalid" },
335         { 0x052700, "Write protected media" },
336         { 0x052c00, "Command sequence error" },
337         { 0x052c03, "Current program area is not empty" },
338         { 0x052c04, "Current program area is empty" },
339         { 0x053001, "Cannot read medium - unknown format" },
340         { 0x053002, "Cannot read medium - incompatible format" },
341         { 0x053900, "Saving parameters not supported" },
342         { 0x054e00, "Overlapped commands attempted" },
343         { 0x055302, "Medium removal prevented" },
344         { 0x055500, "System resource failure" },
345         { 0x056300, "End of user area encountered on this track" },
346         { 0x056400, "Illegal mode for this track or incompatible medium" },
347         { 0x056f00, "Copy protection key exchange failure - Authentication failure" },
348         { 0x056f01, "Copy protection key exchange failure - Key not present" },
349         { 0x056f02, "Copy protection key exchange failure - Key not established" },
350         { 0x056f03, "Read of scrambled sector without authentication" },
351         { 0x056f04, "Media region code is mismatched to logical unit" },
352         { 0x056f05,  "Drive region must be permanent / region reset count error" },
353         { 0x057203, "Session fixation error - incomplete track in session" },
354         { 0x057204, "Empty or partially written reserved track" },
355         { 0x057205, "No more RZONE reservations are allowed" },
356         { 0x05bf00, "Loss of streaming" },
357         { 0x062800, "Not ready to ready transition, medium may have changed" },
358         { 0x062900, "Power on, reset or hardware reset occurred" },
359         { 0x062a00, "Parameters changed" },
360         { 0x062a01, "Mode parameters changed" },
361         { 0x062e00, "Insufficient time for operation" },
362         { 0x063f00, "Logical unit operating conditions have changed" },
363         { 0x063f01, "Microcode has been changed" },
364         { 0x065a00, "Operator request or state change input (unspecified)" },
365         { 0x065a01, "Operator medium removal request" },
366         { 0x0bb900, "Play operation aborted" },
367
368         /* Here we use 0xff for the key (not a valid key) to signify
369          * that these can have _any_ key value associated with them... */
370         { 0xff0401, "Logical unit is in process of becoming ready" },
371         { 0xff0400, "Logical unit not ready, cause not reportable" },
372         { 0xff0402, "Logical unit not ready, initializing command required" },
373         { 0xff0403, "Logical unit not ready, manual intervention required" },
374         { 0xff0500, "Logical unit does not respond to selection" },
375         { 0xff0800, "Logical unit communication failure" },
376         { 0xff0802, "Logical unit communication parity error" },
377         { 0xff0801, "Logical unit communication time-out" },
378         { 0xff2500, "Logical unit not supported" },
379         { 0xff4c00, "Logical unit failed self-configuration" },
380         { 0xff3e00, "Logical unit has not self-configured yet" },
381 };
382 #endif
383
384
385 #endif /* _IDE_CD_H */