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
23#ifndef STANDARD_ATAPI
24#define STANDARD_ATAPI 0
25#endif
26
27
28/* Turning this on will disable the door-locking functionality.
29   This is apparently needed for supermount. */
30
31#ifndef NO_DOOR_LOCKING
32#define NO_DOOR_LOCKING 0
33#endif
34
35/*
36 * typical timeout for packet command
37 */
38#define ATAPI_WAIT_PC		(60 * HZ)
39#define ATAPI_WAIT_WRITE_BUSY	(10 * HZ)
40
41/************************************************************************/
42
43#define SECTOR_BITS 		9
44#ifndef SECTOR_SIZE
45#define SECTOR_SIZE		(1 << SECTOR_BITS)
46#endif
47#define SECTORS_PER_FRAME	(CD_FRAMESIZE >> SECTOR_BITS)
48#define SECTOR_BUFFER_SIZE	(CD_FRAMESIZE * 32)
49#define SECTORS_BUFFER		(SECTOR_BUFFER_SIZE >> SECTOR_BITS)
50#define SECTORS_MAX		(131072 >> SECTOR_BITS)
51
52#define BLOCKS_PER_FRAME	(CD_FRAMESIZE / BLOCK_SIZE)
53
54/* special command codes for strategy routine. */
55#define PACKET_COMMAND        4315
56#define REQUEST_SENSE_COMMAND 4316
57#define RESET_DRIVE_COMMAND   4317
58
59
60/* Configuration flags.  These describe the capabilities of the drive.
61   They generally do not change after initialization, unless we learn
62   more about the drive from stuff failing. */
63struct ide_cd_config_flags {
64	__u8 drq_interrupt	: 1; /* Device sends an interrupt when ready
65					for a packet command. */
66	__u8 no_doorlock	: 1; /* Drive cannot lock the door. */
67	__u8 no_eject		: 1; /* Drive cannot eject the disc. */
68	__u8 nec260		: 1; /* Drive is a pre-1.2 NEC 260 drive. */
69	__u8 playmsf_as_bcd	: 1; /* PLAYMSF command takes BCD args. */
70	__u8 tocaddr_as_bcd	: 1; /* TOC addresses are in BCD. */
71	__u8 toctracks_as_bcd	: 1; /* TOC track numbers are in BCD. */
72	__u8 subchan_as_bcd	: 1; /* Subchannel info is in BCD. */
73	__u8 is_changer		: 1; /* Drive is a changer. */
74	__u8 cd_r		: 1; /* Drive can write to CD-R media . */
75	__u8 cd_rw		: 1; /* Drive can write to CD-R/W media . */
76	__u8 dvd		: 1; /* Drive is a DVD-ROM */
77	__u8 dvd_r		: 1; /* Drive can write DVD-R */
78	__u8 dvd_ram		: 1; /* Drive can write DVD-RAM */
79	__u8 ram		: 1; /* generic WRITE (dvd-ram/mrw) */
80	__u8 test_write		: 1; /* Drive can fake writes */
81	__u8 supp_disc_present	: 1; /* Changer can report exact contents
82					of slots. */
83	__u8 limit_nframes	: 1; /* Drive does not provide data in
84					multiples of SECTOR_SIZE when more
85					than one interrupt is needed. */
86	__u8 seeking		: 1; /* Seeking in progress */
87	__u8 audio_play		: 1; /* can do audio related commands */
88	__u8 close_tray		: 1; /* can close the tray */
89	__u8 writing		: 1; /* pseudo write in progress */
90	__u8 mo_drive		: 1; /* drive is an MO device */
91	__u8 reserved		: 2;
92	byte max_speed;		     /* Max speed of the drive */
93};
94#define CDROM_CONFIG_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->config_flags))
95
96
97/* State flags.  These give information about the current state of the
98   drive, and will change during normal operation. */
99struct ide_cd_state_flags {
100	__u8 media_changed : 1; /* Driver has noticed a media change. */
101	__u8 toc_valid     : 1; /* Saved TOC information is current. */
102	__u8 door_locked   : 1; /* We think that the drive door is locked. */
103	__u8 writing       : 1; /* the drive is currently writing */
104	__u8 reserved      : 4;
105	byte current_speed;	/* Current speed of the drive */
106};
107
108#define CDROM_STATE_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->state_flags))
109
110/* Structure of a MSF cdrom address. */
111struct atapi_msf {
112	byte reserved;
113	byte minute;
114	byte second;
115	byte frame;
116};
117
118/* Space to hold the disk TOC. */
119#define MAX_TRACKS 99
120struct atapi_toc_header {
121	unsigned short toc_length;
122	byte first_track;
123	byte last_track;
124};
125
126struct atapi_toc_entry {
127	byte reserved1;
128#if defined(__BIG_ENDIAN_BITFIELD)
129	__u8 adr     : 4;
130	__u8 control : 4;
131#elif defined(__LITTLE_ENDIAN_BITFIELD)
132	__u8 control : 4;
133	__u8 adr     : 4;
134#else
135#error "Please fix <asm/byteorder.h>"
136#endif
137	byte track;
138	byte reserved2;
139	union {
140		unsigned lba;
141		struct atapi_msf msf;
142	} addr;
143};
144
145struct atapi_toc {
146	int    last_session_lba;
147	int    xa_flag;
148	unsigned long capacity;
149	struct atapi_toc_header hdr;
150	struct atapi_toc_entry  ent[MAX_TRACKS+1];
151	  /* One extra for the leadout. */
152};
153
154
155/* This structure is annoyingly close to, but not identical with,
156   the cdrom_subchnl structure from cdrom.h. */
157struct atapi_cdrom_subchnl {
158 	u_char  acdsc_reserved;
159 	u_char  acdsc_audiostatus;
160 	u_short acdsc_length;
161	u_char  acdsc_format;
162
163#if defined(__BIG_ENDIAN_BITFIELD)
164	u_char  acdsc_ctrl:     4;
165	u_char  acdsc_adr:      4;
166#elif defined(__LITTLE_ENDIAN_BITFIELD)
167	u_char  acdsc_adr:	4;
168	u_char  acdsc_ctrl:	4;
169#else
170#error "Please fix <asm/byteorder.h>"
171#endif
172	u_char  acdsc_trk;
173	u_char  acdsc_ind;
174	union {
175		struct atapi_msf msf;
176		int	lba;
177	} acdsc_absaddr;
178	union {
179		struct atapi_msf msf;
180		int	lba;
181	} acdsc_reladdr;
182};
183
184
185
186/* This should probably go into cdrom.h along with the other
187 * generic stuff now in the Mt. Fuji spec.
188 */
189struct atapi_capabilities_page {
190	struct mode_page_header header;
191#if defined(__BIG_ENDIAN_BITFIELD)
192	__u8 parameters_saveable : 1;
193	__u8 reserved1           : 1;
194	__u8 page_code           : 6;
195#elif defined(__LITTLE_ENDIAN_BITFIELD)
196	__u8 page_code           : 6;
197	__u8 reserved1           : 1;
198	__u8 parameters_saveable : 1;
199#else
200#error "Please fix <asm/byteorder.h>"
201#endif
202
203	byte     page_length;
204
205#if defined(__BIG_ENDIAN_BITFIELD)
206	__u8 reserved2           : 2;
207	/* Drive supports reading of DVD-RAM discs */
208	__u8 dvd_ram_read        : 1;
209	/* Drive supports reading of DVD-R discs */
210	__u8 dvd_r_read          : 1;
211	/* Drive supports reading of DVD-ROM discs */
212	__u8 dvd_rom             : 1;
213	/* Drive supports reading CD-R discs with addressing method 2 */
214	__u8 method2             : 1; /* reserved in 1.2 */
215	/* Drive can read from CD-R/W (CD-E) discs (orange book, part III) */
216	__u8 cd_rw_read		 : 1; /* reserved in 1.2 */
217	/* Drive supports read from CD-R discs (orange book, part II) */
218	__u8 cd_r_read           : 1; /* reserved in 1.2 */
219#elif defined(__LITTLE_ENDIAN_BITFIELD)
220	/* Drive supports read from CD-R discs (orange book, part II) */
221	__u8 cd_r_read           : 1; /* reserved in 1.2 */
222	/* Drive can read from CD-R/W (CD-E) discs (orange book, part III) */
223	__u8 cd_rw_read          : 1; /* reserved in 1.2 */
224	/* Drive supports reading CD-R discs with addressing method 2 */
225	__u8 method2             : 1;
226	/* Drive supports reading of DVD-ROM discs */
227	__u8 dvd_rom             : 1;
228	/* Drive supports reading of DVD-R discs */
229	__u8 dvd_r_read          : 1;
230	/* Drive supports reading of DVD-RAM discs */
231	__u8 dvd_ram_read        : 1;
232	__u8 reserved2		 : 2;
233#else
234#error "Please fix <asm/byteorder.h>"
235#endif
236
237#if defined(__BIG_ENDIAN_BITFIELD)
238	__u8 reserved3           : 2;
239	/* Drive can write DVD-RAM discs */
240	__u8 dvd_ram_write       : 1;
241	/* Drive can write DVD-R discs */
242	__u8 dvd_r_write         : 1;
243	__u8 reserved3a          : 1;
244	/* Drive can fake writes */
245	__u8 test_write          : 1;
246	/* Drive can write to CD-R/W (CD-E) discs (orange book, part III) */
247	__u8 cd_rw_write	 : 1; /* reserved in 1.2 */
248	/* Drive supports write to CD-R discs (orange book, part II) */
249	__u8 cd_r_write          : 1; /* reserved in 1.2 */
250#elif defined(__LITTLE_ENDIAN_BITFIELD)
251	/* Drive can write to CD-R discs (orange book, part II) */
252	__u8 cd_r_write          : 1; /* reserved in 1.2 */
253	/* Drive can write to CD-R/W (CD-E) discs (orange book, part III) */
254	__u8 cd_rw_write	 : 1; /* reserved in 1.2 */
255	/* Drive can fake writes */
256	__u8 test_write          : 1;
257	__u8 reserved3a          : 1;
258	/* Drive can write DVD-R discs */
259	__u8 dvd_r_write         : 1;
260	/* Drive can write DVD-RAM discs */
261	__u8 dvd_ram_write       : 1;
262	__u8 reserved3           : 2;
263#else
264#error "Please fix <asm/byteorder.h>"
265#endif
266
267#if defined(__BIG_ENDIAN_BITFIELD)
268	__u8 reserved4           : 1;
269	/* Drive can read multisession discs. */
270	__u8 multisession        : 1;
271	/* Drive can read mode 2, form 2 data. */
272	__u8 mode2_form2         : 1;
273	/* Drive can read mode 2, form 1 (XA) data. */
274	__u8 mode2_form1         : 1;
275	/* Drive supports digital output on port 2. */
276	__u8 digport2            : 1;
277	/* Drive supports digital output on port 1. */
278	__u8 digport1            : 1;
279	/* Drive can deliver a composite audio/video data stream. */
280	__u8 composite           : 1;
281	/* Drive supports audio play operations. */
282	__u8 audio_play          : 1;
283#elif defined(__LITTLE_ENDIAN_BITFIELD)
284	/* Drive supports audio play operations. */
285	__u8 audio_play          : 1;
286	/* Drive can deliver a composite audio/video data stream. */
287	__u8 composite           : 1;
288	/* Drive supports digital output on port 1. */
289	__u8 digport1            : 1;
290	/* Drive supports digital output on port 2. */
291	__u8 digport2            : 1;
292	/* Drive can read mode 2, form 1 (XA) data. */
293	__u8 mode2_form1         : 1;
294	/* Drive can read mode 2, form 2 data. */
295	__u8 mode2_form2         : 1;
296	/* Drive can read multisession discs. */
297	__u8 multisession        : 1;
298	__u8 reserved4           : 1;
299#else
300#error "Please fix <asm/byteorder.h>"
301#endif
302
303#if defined(__BIG_ENDIAN_BITFIELD)
304	__u8 reserved5           : 1;
305	/* Drive can return Media Catalog Number (UPC) info. */
306	__u8 upc                 : 1;
307	/* Drive can return International Standard Recording Code info. */
308	__u8 isrc                : 1;
309	/* Drive supports C2 error pointers. */
310	__u8 c2_pointers         : 1;
311	/* R-W data will be returned deinterleaved and error corrected. */
312	__u8 rw_corr             : 1;
313	/* Subchannel reads can return combined R-W information. */
314	__u8 rw_supported        : 1;
315	/* Drive can continue a read cdda operation from a loss of streaming.*/
316	__u8 cdda_accurate       : 1;
317	/* Drive can read Red Book audio data. */
318	__u8 cdda                : 1;
319#elif defined(__LITTLE_ENDIAN_BITFIELD)
320	/* Drive can read Red Book audio data. */
321	__u8 cdda                : 1;
322	/* Drive can continue a read cdda operation from a loss of streaming.*/
323	__u8 cdda_accurate       : 1;
324	/* Subchannel reads can return combined R-W information. */
325	__u8 rw_supported        : 1;
326	/* R-W data will be returned deinterleaved and error corrected. */
327	__u8 rw_corr             : 1;
328	/* Drive supports C2 error pointers. */
329	__u8 c2_pointers         : 1;
330	/* Drive can return International Standard Recording Code info. */
331	__u8 isrc                : 1;
332	/* Drive can return Media Catalog Number (UPC) info. */
333	__u8 upc                 : 1;
334	__u8 reserved5           : 1;
335#else
336#error "Please fix <asm/byteorder.h>"
337#endif
338
339#if defined(__BIG_ENDIAN_BITFIELD)
340	/* Drive mechanism types. */
341	mechtype_t mechtype	 : 3;
342	__u8 reserved6           : 1;
343	/* Drive can eject a disc or changer cartridge. */
344	__u8 eject               : 1;
345	/* State of prevent/allow jumper. */
346	__u8 prevent_jumper      : 1;
347	/* Present state of door lock. */
348	__u8 lock_state          : 1;
349	/* Drive can lock the door. */
350	__u8 lock                : 1;
351#elif defined(__LITTLE_ENDIAN_BITFIELD)
352
353	/* Drive can lock the door. */
354	__u8 lock                : 1;
355	/* Present state of door lock. */
356	__u8 lock_state          : 1;
357	/* State of prevent/allow jumper. */
358	__u8 prevent_jumper      : 1;
359	/* Drive can eject a disc or changer cartridge. */
360	__u8 eject               : 1;
361	__u8 reserved6           : 1;
362	/* Drive mechanism types. */
363	mechtype_t mechtype	 : 3;
364#else
365#error "Please fix <asm/byteorder.h>"
366#endif
367
368#if defined(__BIG_ENDIAN_BITFIELD)
369	__u8 reserved7           : 4;
370	/* Drive supports software slot selection. */
371	__u8 sss                 : 1;  /* reserved in 1.2 */
372	/* Changer can report exact contents of slots. */
373	__u8 disc_present        : 1;  /* reserved in 1.2 */
374	/* Audio for each channel can be muted independently. */
375	__u8 separate_mute       : 1;
376	/* Audio level for each channel can be controlled independently. */
377	__u8 separate_volume     : 1;
378#elif defined(__LITTLE_ENDIAN_BITFIELD)
379
380	/* Audio level for each channel can be controlled independently. */
381	__u8 separate_volume     : 1;
382	/* Audio for each channel can be muted independently. */
383	__u8 separate_mute       : 1;
384	/* Changer can report exact contents of slots. */
385	__u8 disc_present        : 1;  /* reserved in 1.2 */
386	/* Drive supports software slot selection. */
387	__u8 sss                 : 1;  /* reserved in 1.2 */
388	__u8 reserved7           : 4;
389#else
390#error "Please fix <asm/byteorder.h>"
391#endif
392
393	/* Note: the following four fields are returned in big-endian form. */
394	/* Maximum speed (in kB/s). */
395	unsigned short maxspeed;
396	/* Number of discrete volume levels. */
397	unsigned short n_vol_levels;
398	/* Size of cache in drive, in kB. */
399	unsigned short buffer_size;
400	/* Current speed (in kB/s). */
401	unsigned short curspeed;
402	char pad[4];
403};
404
405
406struct atapi_mechstat_header {
407#if defined(__BIG_ENDIAN_BITFIELD)
408	__u8 fault         : 1;
409	__u8 changer_state : 2;
410	__u8 curslot       : 5;
411#elif defined(__LITTLE_ENDIAN_BITFIELD)
412	__u8 curslot       : 5;
413	__u8 changer_state : 2;
414	__u8 fault         : 1;
415#else
416#error "Please fix <asm/byteorder.h>"
417#endif
418
419#if defined(__BIG_ENDIAN_BITFIELD)
420	__u8 mech_state    : 3;
421	__u8 door_open     : 1;
422	__u8 reserved1     : 4;
423#elif defined(__LITTLE_ENDIAN_BITFIELD)
424	__u8 reserved1     : 4;
425	__u8 door_open     : 1;
426	__u8 mech_state    : 3;
427#else
428#error "Please fix <asm/byteorder.h>"
429#endif
430
431	byte     curlba[3];
432	byte     nslots;
433	__u16	 slot_tablelen;
434};
435
436
437struct atapi_slot {
438#if defined(__BIG_ENDIAN_BITFIELD)
439	__u8 disc_present : 1;
440	__u8 reserved1    : 6;
441	__u8 change       : 1;
442#elif defined(__LITTLE_ENDIAN_BITFIELD)
443	__u8 change       : 1;
444	__u8 reserved1    : 6;
445	__u8 disc_present : 1;
446#else
447#error "Please fix <asm/byteorder.h>"
448#endif
449
450	byte reserved2[3];
451};
452
453struct atapi_changer_info {
454	struct atapi_mechstat_header hdr;
455	struct atapi_slot slots[0];
456};
457
458/* Extra per-device info for cdrom drives. */
459struct cdrom_info {
460	ide_drive_t	*drive;
461	ide_driver_t	*driver;
462	struct gendisk	*disk;
463	struct kref	kref;
464
465	/* Buffer for table of contents.  NULL if we haven't allocated
466	   a TOC buffer for this device yet. */
467
468	struct atapi_toc *toc;
469
470	unsigned long	sector_buffered;
471	unsigned long	nsectors_buffered;
472	unsigned char	*buffer;
473
474	/* The result of the last successful request sense command
475	   on this device. */
476	struct request_sense sense_data;
477
478	struct request request_sense_request;
479	int dma;
480	unsigned long last_block;
481	unsigned long start_seek;
482	/* Buffer to hold mechanism status and changer slot table. */
483	struct atapi_changer_info *changer_info;
484
485	struct ide_cd_config_flags	config_flags;
486	struct ide_cd_state_flags	state_flags;
487
488        /* Per-device info needed by cdrom.c generic driver. */
489        struct cdrom_device_info devinfo;
490
491	unsigned long write_timeout;
492};
493
494/****************************************************************************
495 * Descriptions of ATAPI error codes.
496 */
497
498#define ARY_LEN(a) ((sizeof(a) / sizeof(a[0])))
499
500/* This stuff should be in cdrom.h, since it is now generic... */
501
502/* ATAPI sense keys (from table 140 of ATAPI 2.6) */
503#define NO_SENSE                0x00
504#define RECOVERED_ERROR         0x01
505#define NOT_READY               0x02
506#define MEDIUM_ERROR            0x03
507#define HARDWARE_ERROR          0x04
508#define ILLEGAL_REQUEST         0x05
509#define UNIT_ATTENTION          0x06
510#define DATA_PROTECT            0x07
511#define BLANK_CHECK             0x08
512#define ABORTED_COMMAND         0x0b
513#define MISCOMPARE              0x0e
514
515
516
517/* This stuff should be in cdrom.h, since it is now generic... */
518#if VERBOSE_IDE_CD_ERRORS
519
520 /* The generic packet command opcodes for CD/DVD Logical Units,
521 * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
522static const struct {
523	unsigned short packet_command;
524	const char * const text;
525} packet_command_texts[] = {
526	{ GPCMD_TEST_UNIT_READY, "Test Unit Ready" },
527	{ GPCMD_REQUEST_SENSE, "Request Sense" },
528	{ GPCMD_FORMAT_UNIT, "Format Unit" },
529	{ GPCMD_INQUIRY, "Inquiry" },
530	{ GPCMD_START_STOP_UNIT, "Start/Stop Unit" },
531	{ GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL, "Prevent/Allow Medium Removal" },
532	{ GPCMD_READ_FORMAT_CAPACITIES, "Read Format Capacities" },
533	{ GPCMD_READ_CDVD_CAPACITY, "Read Cd/Dvd Capacity" },
534	{ GPCMD_READ_10, "Read 10" },
535	{ GPCMD_WRITE_10, "Write 10" },
536	{ GPCMD_SEEK, "Seek" },
537	{ GPCMD_WRITE_AND_VERIFY_10, "Write and Verify 10" },
538	{ GPCMD_VERIFY_10, "Verify 10" },
539	{ GPCMD_FLUSH_CACHE, "Flush Cache" },
540	{ GPCMD_READ_SUBCHANNEL, "Read Subchannel" },
541	{ GPCMD_READ_TOC_PMA_ATIP, "Read Table of Contents" },
542	{ GPCMD_READ_HEADER, "Read Header" },
543	{ GPCMD_PLAY_AUDIO_10, "Play Audio 10" },
544	{ GPCMD_GET_CONFIGURATION, "Get Configuration" },
545	{ GPCMD_PLAY_AUDIO_MSF, "Play Audio MSF" },
546	{ GPCMD_PLAYAUDIO_TI, "Play Audio TrackIndex" },
547	{ GPCMD_GET_EVENT_STATUS_NOTIFICATION, "Get Event Status Notification" },
548	{ GPCMD_PAUSE_RESUME, "Pause/Resume" },
549	{ GPCMD_STOP_PLAY_SCAN, "Stop Play/Scan" },
550	{ GPCMD_READ_DISC_INFO, "Read Disc Info" },
551	{ GPCMD_READ_TRACK_RZONE_INFO, "Read Track Rzone Info" },
552	{ GPCMD_RESERVE_RZONE_TRACK, "Reserve Rzone Track" },
553	{ GPCMD_SEND_OPC, "Send OPC" },
554	{ GPCMD_MODE_SELECT_10, "Mode Select 10" },
555	{ GPCMD_REPAIR_RZONE_TRACK, "Repair Rzone Track" },
556	{ GPCMD_MODE_SENSE_10, "Mode Sense 10" },
557	{ GPCMD_CLOSE_TRACK, "Close Track" },
558	{ GPCMD_BLANK, "Blank" },
559	{ GPCMD_SEND_EVENT, "Send Event" },
560	{ GPCMD_SEND_KEY, "Send Key" },
561	{ GPCMD_REPORT_KEY, "Report Key" },
562	{ GPCMD_LOAD_UNLOAD, "Load/Unload" },
563	{ GPCMD_SET_READ_AHEAD, "Set Read-ahead" },
564	{ GPCMD_READ_12, "Read 12" },
565	{ GPCMD_GET_PERFORMANCE, "Get Performance" },
566	{ GPCMD_SEND_DVD_STRUCTURE, "Send DVD Structure" },
567	{ GPCMD_READ_DVD_STRUCTURE, "Read DVD Structure" },
568	{ GPCMD_SET_STREAMING, "Set Streaming" },
569	{ GPCMD_READ_CD_MSF, "Read CD MSF" },
570	{ GPCMD_SCAN, "Scan" },
571	{ GPCMD_SET_SPEED, "Set Speed" },
572	{ GPCMD_PLAY_CD, "Play CD" },
573	{ GPCMD_MECHANISM_STATUS, "Mechanism Status" },
574	{ GPCMD_READ_CD, "Read CD" },
575};
576
577
578
579/* From Table 303 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
580static const char * const sense_key_texts[16] = {
581	"No sense data",
582	"Recovered error",
583	"Not ready",
584	"Medium error",
585	"Hardware error",
586	"Illegal request",
587	"Unit attention",
588	"Data protect",
589	"Blank check",
590	"(reserved)",
591	"(reserved)",
592	"Aborted command",
593	"(reserved)",
594	"(reserved)",
595	"Miscompare",
596	"(reserved)",
597};
598
599/* From Table 304 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
600static const struct {
601	unsigned long asc_ascq;
602	const char * const text;
603} sense_data_texts[] = {
604	{ 0x000000, "No additional sense information" },
605	{ 0x000011, "Play operation in progress" },
606	{ 0x000012, "Play operation paused" },
607	{ 0x000013, "Play operation successfully completed" },
608	{ 0x000014, "Play operation stopped due to error" },
609	{ 0x000015, "No current audio status to return" },
610	{ 0x010c0a, "Write error - padding blocks added" },
611	{ 0x011700, "Recovered data with no error correction applied" },
612	{ 0x011701, "Recovered data with retries" },
613	{ 0x011702, "Recovered data with positive head offset" },
614	{ 0x011703, "Recovered data with negative head offset" },
615	{ 0x011704, "Recovered data with retries and/or CIRC applied" },
616	{ 0x011705, "Recovered data using previous sector ID" },
617	{ 0x011800, "Recovered data with error correction applied" },
618	{ 0x011801, "Recovered data with error correction and retries applied"},
619	{ 0x011802, "Recovered data - the data was auto-reallocated" },
620	{ 0x011803, "Recovered data with CIRC" },
621	{ 0x011804, "Recovered data with L-EC" },
622	{ 0x015d00,
623	    "Failure prediction threshold exceeded - Predicted logical unit failure" },
624	{ 0x015d01,
625	    "Failure prediction threshold exceeded - Predicted media failure" },
626	{ 0x015dff, "Failure prediction threshold exceeded - False" },
627	{ 0x017301, "Power calibration area almost full" },
628	{ 0x020400, "Logical unit not ready - cause not reportable" },
629	/* Following is misspelled in ATAPI 2.6, _and_ in Mt. Fuji */
630	{ 0x020401,
631	  "Logical unit not ready - in progress [sic] of becoming ready" },
632	{ 0x020402, "Logical unit not ready - initializing command required" },
633	{ 0x020403, "Logical unit not ready - manual intervention required" },
634	{ 0x020404, "Logical unit not ready - format in progress" },
635	{ 0x020407, "Logical unit not ready - operation in progress" },
636	{ 0x020408, "Logical unit not ready - long write in progress" },
637	{ 0x020600, "No reference position found (media may be upside down)" },
638	{ 0x023000, "Incompatible medium installed" },
639	{ 0x023a00, "Medium not present" },
640	{ 0x025300, "Media load or eject failed" },
641	{ 0x025700, "Unable to recover table of contents" },
642	{ 0x030300, "Peripheral device write fault" },
643	{ 0x030301, "No write current" },
644	{ 0x030302, "Excessive write errors" },
645	{ 0x030c00, "Write error" },
646	{ 0x030c01, "Write error - Recovered with auto reallocation" },
647	{ 0x030c02, "Write error - auto reallocation failed" },
648	{ 0x030c03, "Write error - recommend reassignment" },
649	{ 0x030c04, "Compression check miscompare error" },
650	{ 0x030c05, "Data expansion occurred during compress" },
651	{ 0x030c06, "Block not compressible" },
652	{ 0x030c07, "Write error - recovery needed" },
653	{ 0x030c08, "Write error - recovery failed" },
654	{ 0x030c09, "Write error - loss of streaming" },
655	{ 0x031100, "Unrecovered read error" },
656	{ 0x031106, "CIRC unrecovered error" },
657	{ 0x033101, "Format command failed" },
658	{ 0x033200, "No defect spare location available" },
659	{ 0x033201, "Defect list update failure" },
660	{ 0x035100, "Erase failure" },
661	{ 0x037200, "Session fixation error" },
662	{ 0x037201, "Session fixation error writin lead-in" },
663	{ 0x037202, "Session fixation error writin lead-out" },
664	{ 0x037300, "CD control error" },
665	{ 0x037302, "Power calibration area is full" },
666	{ 0x037303, "Power calibration area error" },
667	{ 0x037304, "Program memory area / RMA update failure" },
668	{ 0x037305, "Program memory area / RMA is full" },
669	{ 0x037306, "Program memory area / RMA is (almost) full" },
670
671	{ 0x040200, "No seek complete" },
672	{ 0x040300, "Write fault" },
673	{ 0x040900, "Track following error" },
674	{ 0x040901, "Tracking servo failure" },
675	{ 0x040902, "Focus servo failure" },
676	{ 0x040903, "Spindle servo failure" },
677	{ 0x041500, "Random positioning error" },
678	{ 0x041501, "Mechanical positioning or changer error" },
679	{ 0x041502, "Positioning error detected by read of medium" },
680	{ 0x043c00, "Mechanical positioning or changer error" },
681	{ 0x044000, "Diagnostic failure on component (ASCQ)" },
682	{ 0x044400, "Internal CD/DVD logical unit failure" },
683	{ 0x04b600, "Media load mechanism failed" },
684	{ 0x051a00, "Parameter list length error" },
685	{ 0x052000, "Invalid command operation code" },
686	{ 0x052100, "Logical block address out of range" },
687	{ 0x052102, "Invalid address for write" },
688	{ 0x052400, "Invalid field in command packet" },
689	{ 0x052600, "Invalid field in parameter list" },
690	{ 0x052601, "Parameter not supported" },
691	{ 0x052602, "Parameter value invalid" },
692	{ 0x052700, "Write protected media" },
693	{ 0x052c00, "Command sequence error" },
694	{ 0x052c03, "Current program area is not empty" },
695	{ 0x052c04, "Current program area is empty" },
696	{ 0x053001, "Cannot read medium - unknown format" },
697	{ 0x053002, "Cannot read medium - incompatible format" },
698	{ 0x053900, "Saving parameters not supported" },
699	{ 0x054e00, "Overlapped commands attempted" },
700	{ 0x055302, "Medium removal prevented" },
701	{ 0x055500, "System resource failure" },
702	{ 0x056300, "End of user area encountered on this track" },
703	{ 0x056400, "Illegal mode for this track or incompatible medium" },
704	{ 0x056f00, "Copy protection key exchange failure - Authentication failure" },
705	{ 0x056f01, "Copy protection key exchange failure - Key not present" },
706	{ 0x056f02, "Copy protection key exchange failure - Key not established" },
707	{ 0x056f03, "Read of scrambled sector without authentication" },
708	{ 0x056f04, "Media region code is mismatched to logical unit" },
709	{ 0x056f05,  "Drive region must be permanent / region reset count error" },
710	{ 0x057203, "Session fixation error - incomplete track in session" },
711	{ 0x057204, "Empty or partially written reserved track" },
712	{ 0x057205, "No more RZONE reservations are allowed" },
713	{ 0x05bf00, "Loss of streaming" },
714	{ 0x062800, "Not ready to ready transition, medium may have changed" },
715	{ 0x062900, "Power on, reset or hardware reset occurred" },
716	{ 0x062a00, "Parameters changed" },
717	{ 0x062a01, "Mode parameters changed" },
718	{ 0x062e00, "Insufficient time for operation" },
719	{ 0x063f00, "Logical unit operating conditions have changed" },
720	{ 0x063f01, "Microcode has been changed" },
721	{ 0x065a00, "Operator request or state change input (unspecified)" },
722	{ 0x065a01, "Operator medium removal request" },
723	{ 0x0bb900, "Play operation aborted" },
724
725	/* Here we use 0xff for the key (not a valid key) to signify
726	 * that these can have _any_ key value associated with them... */
727	{ 0xff0401, "Logical unit is in process of becoming ready" },
728	{ 0xff0400, "Logical unit not ready, cause not reportable" },
729	{ 0xff0402, "Logical unit not ready, initializing command required" },
730	{ 0xff0403, "Logical unit not ready, manual intervention required" },
731	{ 0xff0500, "Logical unit does not respond to selection" },
732	{ 0xff0800, "Logical unit communication failure" },
733	{ 0xff0802, "Logical unit communication parity error" },
734	{ 0xff0801, "Logical unit communication time-out" },
735	{ 0xff2500, "Logical unit not supported" },
736	{ 0xff4c00, "Logical unit failed self-configuration" },
737	{ 0xff3e00, "Logical unit has not self-configured yet" },
738};
739#endif
740
741
742#endif /* _IDE_CD_H */
743