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