Import 2.3.25pre1
[davej-history.git] / include / linux / cdrom.h
blobbfcce8e718fb4d6d352bcde76d711203b7bf2985
1 /*
2 * -- <linux/cdrom.h>
3 * General header file for linux CD-ROM drivers
4 * Copyright (C) 1992 David Giller, rafetmad@oxy.edu
5 * 1994, 1995 Eberhard Moenkeberg, emoenke@gwdg.de
6 * 1996 David van Leeuwen, david@tm.tno.nl
7 * 1997, 1998 Erik Andersen, andersee@debian.org
8 * 1998, 1999 Jens Axboe, axboe@image.dk
9 */
11 #ifndef _LINUX_CDROM_H
12 #define _LINUX_CDROM_H
14 #include <linux/types.h>
16 /*******************************************************
17 * As of Linux 2.1.x, all Linux CD-ROM application programs will use this
18 * (and only this) include file. It is my hope to provide Linux with
19 * a uniform interface between software accessing CD-ROMs and the various
20 * device drivers that actually talk to the drives. There may still be
21 * 23 different kinds of strange CD-ROM drives, but at least there will
22 * now be one, and only one, Linux CD-ROM interface.
24 * Additionally, as of Linux 2.1.x, all Linux application programs
25 * should use the O_NONBLOCK option when opening a CD-ROM device
26 * for subsequent ioctl commands. This allows for neat system errors
27 * like "No medium found" or "Wrong medium type" upon attempting to
28 * mount or play an empty slot, mount an audio disc, or play a data disc.
29 * Generally, changing an application program to support O_NONBLOCK
30 * is as easy as the following:
31 * - drive = open("/dev/cdrom", O_RDONLY);
32 * + drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK);
33 * It is worth the small change.
35 * Patches for many common CD programs (provided by David A. van Leeuwen)
36 * can be found at: ftp://ftp.gwdg.de/pub/linux/cdrom/drivers/cm206/
38 *******************************************************/
40 /* When a driver supports a certain function, but the cdrom drive we are
41 * using doesn't, we will return the error EDRIVE_CANT_DO_THIS. We will
42 * borrow the "Operation not supported" error from the network folks to
43 * accomplish this. Maybe someday we will get a more targeted error code,
44 * but this will do for now... */
45 #define EDRIVE_CANT_DO_THIS EOPNOTSUPP
47 /*******************************************************
48 * The CD-ROM IOCTL commands -- these should be supported by
49 * all the various cdrom drivers. For the CD-ROM ioctls, we
50 * will commandeer byte 0x53, or 'S'.
51 *******************************************************/
52 #define CDROMPAUSE 0x5301 /* Pause Audio Operation */
53 #define CDROMRESUME 0x5302 /* Resume paused Audio Operation */
54 #define CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */
55 #define CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index
56 (struct cdrom_ti) */
57 #define CDROMREADTOCHDR 0x5305 /* Read TOC header
58 (struct cdrom_tochdr) */
59 #define CDROMREADTOCENTRY 0x5306 /* Read TOC entry
60 (struct cdrom_tocentry) */
61 #define CDROMSTOP 0x5307 /* Stop the cdrom drive */
62 #define CDROMSTART 0x5308 /* Start the cdrom drive */
63 #define CDROMEJECT 0x5309 /* Ejects the cdrom media */
64 #define CDROMVOLCTRL 0x530a /* Control output volume
65 (struct cdrom_volctrl) */
66 #define CDROMSUBCHNL 0x530b /* Read subchannel data
67 (struct cdrom_subchnl) */
68 #define CDROMREADMODE2 0x530c /* Read CDROM mode 2 data (2336 Bytes)
69 (struct cdrom_read) */
70 #define CDROMREADMODE1 0x530d /* Read CDROM mode 1 data (2048 Bytes)
71 (struct cdrom_read) */
72 #define CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */
73 #define CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */
74 #define CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session
75 address of multi session disks
76 (struct cdrom_multisession) */
77 #define CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code"
78 if available (struct cdrom_mcn) */
79 #define CDROM_GET_UPC CDROM_GET_MCN /* This one is depricated,
80 but here anyway for compatability */
81 #define CDROMRESET 0x5312 /* hard-reset the drive */
82 #define CDROMVOLREAD 0x5313 /* Get the drive's volume setting
83 (struct cdrom_volctrl) */
84 #define CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes)
85 (struct cdrom_read) */
86 /*
87 * These ioctls are used only used in aztcd.c and optcd.c
89 #define CDROMREADCOOKED 0x5315 /* read data in cooked mode */
90 #define CDROMSEEK 0x5316 /* seek msf address */
93 * This ioctl is only used by the scsi-cd driver.
94 It is for playing audio in logical block addressing mode.
96 #define CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */
98 /*
99 * These ioctls are only used in optcd.c
101 #define CDROMREADALL 0x5318 /* read all 2646 bytes */
104 * These ioctls are (now) only in ide-cd.c for controlling
105 * drive spindown time. They should be implemented in the
106 * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
107 * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
108 * -Erik
110 #define CDROMGETSPINDOWN 0x531d
111 #define CDROMSETSPINDOWN 0x531e
114 * These ioctls are implemented through the uniform CD-ROM driver
115 * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
116 * drivers are eventually ported to the uniform CD-ROM driver interface.
118 #define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
119 #define CDROM_SET_OPTIONS 0x5320 /* Set behavior options */
120 #define CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */
121 #define CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */
122 #define CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */
123 #define CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */
124 #define CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */
125 #define CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */
126 #define CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */
127 #define CDROM_LOCKDOOR 0x5329 /* lock or unlock door */
128 #define CDROM_DEBUG 0x5330 /* Turn debug messages on/off */
129 #define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */
131 /* This ioctl is only used by sbpcd at the moment */
132 #define CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */
134 /* DVD-ROM Specific ioctls */
135 #define DVD_READ_STRUCT 0x5390 /* Read structure */
136 #define DVD_WRITE_STRUCT 0x5391 /* Write structure */
137 #define DVD_AUTH 0x5392 /* Authentication */
139 #define CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */
140 #define CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */
141 #define CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */
143 /*******************************************************
144 * CDROM IOCTL structures
145 *******************************************************/
147 /* Address in MSF format */
148 struct cdrom_msf0
150 __u8 minute;
151 __u8 second;
152 __u8 frame;
155 /* Address in either MSF or logical format */
156 union cdrom_addr
158 struct cdrom_msf0 msf;
159 int lba;
162 /* This struct is used by the CDROMPLAYMSF ioctl */
163 struct cdrom_msf
165 __u8 cdmsf_min0; /* start minute */
166 __u8 cdmsf_sec0; /* start second */
167 __u8 cdmsf_frame0; /* start frame */
168 __u8 cdmsf_min1; /* end minute */
169 __u8 cdmsf_sec1; /* end second */
170 __u8 cdmsf_frame1; /* end frame */
173 /* This struct is used by the CDROMPLAYTRKIND ioctl */
174 struct cdrom_ti
176 __u8 cdti_trk0; /* start track */
177 __u8 cdti_ind0; /* start index */
178 __u8 cdti_trk1; /* end track */
179 __u8 cdti_ind1; /* end index */
182 /* This struct is used by the CDROMREADTOCHDR ioctl */
183 struct cdrom_tochdr
185 __u8 cdth_trk0; /* start track */
186 __u8 cdth_trk1; /* end track */
189 /* This struct is used by the CDROMVOLCTRL and CDROMVOLREAD ioctls */
190 struct cdrom_volctrl
192 __u8 channel0;
193 __u8 channel1;
194 __u8 channel2;
195 __u8 channel3;
198 /* This struct is used by the CDROMSUBCHNL ioctl */
199 struct cdrom_subchnl
201 __u8 cdsc_format;
202 __u8 cdsc_audiostatus;
203 __u8 cdsc_adr: 4;
204 __u8 cdsc_ctrl: 4;
205 __u8 cdsc_trk;
206 __u8 cdsc_ind;
207 union cdrom_addr cdsc_absaddr;
208 union cdrom_addr cdsc_reladdr;
212 /* This struct is used by the CDROMREADTOCENTRY ioctl */
213 struct cdrom_tocentry
215 __u8 cdte_track;
216 __u8 cdte_adr :4;
217 __u8 cdte_ctrl :4;
218 __u8 cdte_format;
219 union cdrom_addr cdte_addr;
220 __u8 cdte_datamode;
223 /* This struct is used by the CDROMREADMODE1, and CDROMREADMODE2 ioctls */
224 struct cdrom_read
226 int cdread_lba;
227 caddr_t cdread_bufaddr;
228 int cdread_buflen;
231 /* This struct is used by the CDROMREADAUDIO ioctl */
232 struct cdrom_read_audio
234 union cdrom_addr addr; /* frame address */
235 __u8 addr_format; /* CDROM_LBA or CDROM_MSF */
236 int nframes; /* number of 2352-byte-frames to read at once */
237 __u8 *buf; /* frame buffer (size: nframes*2352 bytes) */
240 /* This struct is used with the CDROMMULTISESSION ioctl */
241 struct cdrom_multisession
243 union cdrom_addr addr; /* frame address: start-of-last-session
244 (not the new "frame 16"!). Only valid
245 if the "xa_flag" is true. */
246 __u8 xa_flag; /* 1: "is XA disk" */
247 __u8 addr_format; /* CDROM_LBA or CDROM_MSF */
250 /* This struct is used with the CDROM_GET_MCN ioctl.
251 * Very few audio discs actually have Universal Product Code information,
252 * which should just be the Medium Catalog Number on the box. Also note
253 * that the way the codeis written on CD is _not_ uniform across all discs!
255 struct cdrom_mcn
257 __u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */
260 /* This is used by the CDROMPLAYBLK ioctl */
261 struct cdrom_blk
263 unsigned from;
264 unsigned short len;
267 #define CDROM_PACKET_SIZE 12
269 /* for CDROM_PACKET_COMMAND ioctl */
270 struct cdrom_generic_command
272 unsigned char cmd[CDROM_PACKET_SIZE];
273 unsigned char *buffer;
274 unsigned int buflen;
275 int stat;
276 void *reserved[4];
281 * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336,
282 * 2340, or 2352 bytes long.
284 * Sector types of the standard CD-ROM data formats:
286 * format sector type user data size (bytes)
287 * -----------------------------------------------------------------------------
288 * 1 (Red Book) CD-DA 2352 (CD_FRAMESIZE_RAW)
289 * 2 (Yellow Book) Mode1 Form1 2048 (CD_FRAMESIZE)
290 * 3 (Yellow Book) Mode1 Form2 2336 (CD_FRAMESIZE_RAW0)
291 * 4 (Green Book) Mode2 Form1 2048 (CD_FRAMESIZE)
292 * 5 (Green Book) Mode2 Form2 2328 (2324+4 spare bytes)
295 * The layout of the standard CD-ROM data formats:
296 * -----------------------------------------------------------------------------
297 * - audio (red): | audio_sample_bytes |
298 * | 2352 |
300 * - data (yellow, mode1): | sync - head - data - EDC - zero - ECC |
301 * | 12 - 4 - 2048 - 4 - 8 - 276 |
303 * - data (yellow, mode2): | sync - head - data |
304 * | 12 - 4 - 2336 |
306 * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC |
307 * | 12 - 4 - 8 - 2048 - 4 - 276 |
309 * - XA data (green, mode2 form2): | sync - head - sub - data - Spare |
310 * | 12 - 4 - 8 - 2324 - 4 |
314 /* Some generally useful CD-ROM information -- mostly based on the above */
315 #define CD_MINS 74 /* max. minutes per CD, not really a limit */
316 #define CD_SECS 60 /* seconds per minute */
317 #define CD_FRAMES 75 /* frames per second */
318 #define CD_SYNC_SIZE 12 /* 12 sync bytes per raw data frame */
319 #define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */
320 #define CD_CHUNK_SIZE 24 /* lowest-level "data bytes piece" */
321 #define CD_NUM_OF_CHUNKS 98 /* chunks per frame */
322 #define CD_FRAMESIZE_SUB 96 /* subchannel data "frame" size */
323 #define CD_HEAD_SIZE 4 /* header (address) bytes per raw data frame */
324 #define CD_SUBHEAD_SIZE 8 /* subheader bytes per raw XA data frame */
325 #define CD_EDC_SIZE 4 /* bytes EDC per most raw data frame types */
326 #define CD_ZERO_SIZE 8 /* bytes zero per yellow book mode 1 frame */
327 #define CD_ECC_SIZE 276 /* bytes ECC per most raw data frame types */
328 #define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */
329 #define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */
330 #define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */
331 /* most drives don't deliver everything: */
332 #define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/
333 #define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/
335 #define CD_XA_HEAD (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */
336 #define CD_XA_TAIL (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */
337 #define CD_XA_SYNC_HEAD (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */
339 /* CD-ROM address types (cdrom_tocentry.cdte_format) */
340 #define CDROM_LBA 0x01 /* "logical block": first frame is #0 */
341 #define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */
343 /* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */
344 #define CDROM_DATA_TRACK 0x04
346 /* The leadout track is always 0xAA, regardless of # of tracks on disc */
347 #define CDROM_LEADOUT 0xAA
349 /* audio states (from SCSI-2, but seen with other drives, too) */
350 #define CDROM_AUDIO_INVALID 0x00 /* audio status not supported */
351 #define CDROM_AUDIO_PLAY 0x11 /* audio play operation in progress */
352 #define CDROM_AUDIO_PAUSED 0x12 /* audio play operation paused */
353 #define CDROM_AUDIO_COMPLETED 0x13 /* audio play successfully completed */
354 #define CDROM_AUDIO_ERROR 0x14 /* audio play stopped due to error */
355 #define CDROM_AUDIO_NO_STATUS 0x15 /* no current audio status to return */
357 /* capability flags used with the uniform CD-ROM driver */
358 #define CDC_CLOSE_TRAY 0x1 /* caddy systems _can't_ close */
359 #define CDC_OPEN_TRAY 0x2 /* but _can_ eject. */
360 #define CDC_LOCK 0x4 /* disable manual eject */
361 #define CDC_SELECT_SPEED 0x8 /* programmable speed */
362 #define CDC_SELECT_DISC 0x10 /* select disc from juke-box */
363 #define CDC_MULTI_SESSION 0x20 /* read sessions>1 */
364 #define CDC_MCN 0x40 /* Medium Catalog Number */
365 #define CDC_MEDIA_CHANGED 0x80 /* media changed */
366 #define CDC_PLAY_AUDIO 0x100 /* audio functions */
367 #define CDC_RESET 0x200 /* hard reset device */
368 #define CDC_IOCTLS 0x400 /* driver has non-standard ioctls */
369 #define CDC_DRIVE_STATUS 0x800 /* driver implements drive status */
370 #define CDC_GENERIC_PACKET 0x1000 /* driver implements generic packets */
371 #define CDC_CD_R 0x2000 /* drive is a CD-R */
372 #define CDC_CD_RW 0x4000 /* drive is a CD-RW */
373 #define CDC_DVD 0x8000 /* drive is a DVD */
374 #define CDC_DVD_R 0x10000 /* drive can write DVD-R */
375 #define CDC_DVD_RAM 0x20000 /* drive can write DVD-RAM */
377 /* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */
378 #define CDS_NO_INFO 0 /* if not implemented */
379 #define CDS_NO_DISC 1
380 #define CDS_TRAY_OPEN 2
381 #define CDS_DRIVE_NOT_READY 3
382 #define CDS_DISC_OK 4
384 /* return values for the CDROM_DISC_STATUS ioctl */
385 /* can also return CDS_NO_[INFO|DISC], from above */
386 #define CDS_AUDIO 100
387 #define CDS_DATA_1 101
388 #define CDS_DATA_2 102
389 #define CDS_XA_2_1 103
390 #define CDS_XA_2_2 104
391 #define CDS_MIXED 105
393 /* User-configurable behavior options for the uniform CD-ROM driver */
394 #define CDO_AUTO_CLOSE 0x1 /* close tray on first open() */
395 #define CDO_AUTO_EJECT 0x2 /* open tray on last release() */
396 #define CDO_USE_FFLAGS 0x4 /* use O_NONBLOCK information on open */
397 #define CDO_LOCK 0x8 /* lock tray on open files */
398 #define CDO_CHECK_TYPE 0x10 /* check type on open for data */
400 /* Special codes used when specifying changer slots. */
401 #define CDSL_NONE ((int) (~0U>>1)-1)
402 #define CDSL_CURRENT ((int) (~0U>>1))
404 /* For partition based multisession access. IDE can handle 64 partitions
405 * per drive - SCSI CD-ROM's use minors to differentiate between the
406 * various drives, so we can't do multisessions the same way there.
407 * Use the -o session=x option to mount on them.
409 #define CD_PART_MAX 64
410 #define CD_PART_MASK (CD_PART_MAX - 1)
412 /*********************************************************************
413 * Generic Packet commands, MMC commands, and such
414 *********************************************************************/
416 /* The generic packet command opcodes for CD/DVD Logical Units,
417 * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
418 #define GPCMD_BLANK 0xa1
419 #define GPCMD_CLOSE_TRACK 0x5b
420 #define GPCMD_FLUSH_CACHE 0x35
421 #define GPCMD_FORMAT_UNIT 0x04
422 #define GPCMD_GET_CONFIGURATION 0x46
423 #define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a
424 #define GPCMD_GET_PERFORMANCE 0xac
425 #define GPCMD_INQUIRY 0x12
426 #define GPCMD_LOAD_UNLOAD 0xa6
427 #define GPCMD_MECHANISM_STATUS 0xbd
428 #define GPCMD_MODE_SELECT_10 0x55
429 #define GPCMD_MODE_SENSE_10 0x5a
430 #define GPCMD_PAUSE_RESUME 0x4b
431 #define GPCMD_PLAY_AUDIO_10 0x45
432 #define GPCMD_PLAY_AUDIO_MSF 0x47
433 #define GPCMD_PLAY_CD 0xbc
434 #define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
435 #define GPCMD_READ_10 0x28
436 #define GPCMD_READ_12 0xa8
437 #define GPCMD_READ_CDVD_CAPACITY 0x25
438 #define GPCMD_READ_CD 0xbe
439 #define GPCMD_READ_CD_MSF 0xb9
440 #define GPCMD_READ_DISC_INFO 0x51
441 #define GPCMD_READ_DVD_STRUCTURE 0xad
442 #define GPCMD_READ_FORMAT_CAPACITIES 0x23
443 #define GPCMD_READ_HEADER 0x44
444 #define GPCMD_READ_TRACK_RZONE_INFO 0x52
445 #define GPCMD_READ_SUBCHANNEL 0x42
446 #define GPCMD_READ_TOC_PMA_ATIP 0x43
447 #define GPCMD_REPAIR_RZONE_TRACK 0x58
448 #define GPCMD_REPORT_KEY 0xa4
449 #define GPCMD_REQUEST_SENSE 0x03
450 #define GPCMD_RESERVE_RZONE_TRACK 0x53
451 #define GPCMD_SCAN 0xba
452 #define GPCMD_SEEK 0x2b
453 #define GPCMD_SEND_DVD_STRUCTURE 0xad
454 #define GPCMD_SEND_EVENT 0xa2
455 #define GPCMD_SEND_KEY 0xa3
456 #define GPCMD_SEND_OPC 0x54
457 #define GPCMD_SET_READ_AHEAD 0xa7
458 #define GPCMD_SET_STREAMING 0xb6
459 #define GPCMD_START_STOP_UNIT 0x1b
460 #define GPCMD_STOP_PLAY_SCAN 0x4e
461 #define GPCMD_TEST_UNIT_READY 0x00
462 #define GPCMD_VERIFY_10 0x2f
463 #define GPCMD_WRITE_10 0x2a
464 #define GPCMD_WRITE_AND_VERIFY_10 0x2e
465 /* This is listed as optional in ATAPI 2.6, but is (curiously)
466 * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji
467 * Table 377 as an MMC command for SCSi devices though... Most ATAPI
468 * drives support it. */
469 #define GPCMD_SET_SPEED 0xbb
470 /* This seems to be a SCSI specific CD-ROM opcode
471 * to play data at track/index */
472 #define GPCMD_PLAYAUDIO_TI 0x48
474 /* Is this really used by anything? I couldn't find these...*/
475 #if 0
476 /* MMC2/MTFuji Opcodes */
477 #define ERASE 0x2c
478 #define READ_BUFFER 0x3c
479 #endif
484 /* Mode page codes for mode sense/set */
485 #define GPMODE_R_W_ERROR_PAGE 0x1
486 #define GPMODE_WRITE_PARMS_PAGE 0x5
487 #define GPMODE_AUDIO_CTL_PAGE 0xe
488 #define GPMODE_POWER_PAGE 0x1a
489 #define GPMODE_FAULT_FAIL_PAGE 0x1c
490 #define GPMODE_TO_PROTECT_PAGE 0x1d
491 #define GPMODE_CAPABILITIES_PAGE 0x2a
492 #define GPMODE_ALL_PAGES 0x3f
493 /* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor
494 * of MODE_SENSE_POWER_PAGE */
495 #define GPMODE_CDROM_PAGE 0x0d
499 /* DVD struct types */
500 #define DVD_STRUCT_PHYSICAL 0x00
501 #define DVD_STRUCT_COPYRIGHT 0x01
502 #define DVD_STRUCT_DISCKEY 0x02
503 #define DVD_STRUCT_BCA 0x03
504 #define DVD_STRUCT_MANUFACT 0x04
506 struct dvd_layer {
507 __u8 book_version : 4;
508 __u8 book_type : 4;
509 __u8 min_rate : 4;
510 __u8 disc_size : 4;
511 __u8 layer_type : 4;
512 __u8 track_path : 1;
513 __u8 nlayers : 2;
514 __u8 track_density : 4;
515 __u8 linear_density : 4;
516 __u8 bca : 1;
517 __u8 start_sector;
518 __u8 end_sector;
519 __u8 end_sector_l0;
522 struct dvd_physical {
523 __u8 type;
524 __u8 layer_num;
525 struct dvd_layer layer[4];
528 struct dvd_copyright {
529 __u8 type;
531 __u8 layer_num;
532 __u8 cpst;
533 __u8 rmi;
536 struct dvd_disckey {
537 __u8 type;
539 unsigned agid : 2;
540 __u8 value[2048];
543 struct dvd_bca {
544 __u8 type;
546 int len;
547 __u8 value[188];
550 struct dvd_manufact {
551 __u8 type;
553 __u8 layer_num;
554 int len;
555 __u8 value[2048];
558 typedef union {
559 __u8 type;
561 struct dvd_physical physical;
562 struct dvd_copyright copyright;
563 struct dvd_disckey disckey;
564 struct dvd_bca bca;
565 struct dvd_manufact manufact;
566 } dvd_struct;
569 * DVD authentication ioctl
572 /* Authentication states */
573 #define DVD_LU_SEND_AGID 0
574 #define DVD_HOST_SEND_CHALLENGE 1
575 #define DVD_LU_SEND_KEY1 2
576 #define DVD_LU_SEND_CHALLENGE 3
577 #define DVD_HOST_SEND_KEY2 4
579 /* Termination states */
580 #define DVD_AUTH_ESTABLISHED 5
581 #define DVD_AUTH_FAILURE 6
583 /* Other functions */
584 #define DVD_LU_SEND_TITLE_KEY 7
585 #define DVD_LU_SEND_ASF 8
586 #define DVD_INVALIDATE_AGID 9
588 /* State data */
589 typedef __u8 dvd_key[5]; /* 40-bit value, MSB is first elem. */
590 typedef __u8 dvd_challenge[10]; /* 80-bit value, MSB is first elem. */
592 struct dvd_lu_send_agid {
593 __u8 type;
594 unsigned agid : 2;
597 struct dvd_host_send_challenge {
598 __u8 type;
599 unsigned agid : 2;
601 dvd_challenge chal;
604 struct dvd_send_key {
605 __u8 type;
606 unsigned agid : 2;
608 dvd_key key;
611 struct dvd_lu_send_challenge {
612 __u8 type;
613 unsigned agid : 2;
615 dvd_challenge chal;
618 #define DVD_CPM_NO_COPYRIGHT 0
619 #define DVD_CPM_COPYRIGHTED 1
621 #define DVD_CP_SEC_NONE 0
622 #define DVD_CP_SEC_EXIST 1
624 #define DVD_CGMS_UNRESTRICTED 0
625 #define DVD_CGMS_SINGLE 2
626 #define DVD_CGMS_RESTRICTED 3
628 struct dvd_lu_send_title_key {
629 __u8 type;
630 unsigned agid : 2;
632 dvd_key title_key;
633 int lba;
634 unsigned cpm : 1;
635 unsigned cp_sec : 1;
636 unsigned cgms : 2;
639 struct dvd_lu_send_asf {
640 __u8 type;
641 unsigned agid : 2;
643 unsigned asf : 1;
646 typedef union {
647 __u8 type;
649 struct dvd_lu_send_agid lsa;
650 struct dvd_host_send_challenge hsc;
651 struct dvd_send_key lsk;
652 struct dvd_lu_send_challenge lsc;
653 struct dvd_send_key hsk;
654 struct dvd_lu_send_title_key lstk;
655 struct dvd_lu_send_asf lsasf;
656 } dvd_authinfo;
658 #ifdef __KERNEL__
660 struct cdrom_write_settings {
661 unsigned char fpacket; /* fixed/variable packets */
662 unsigned long packet_size; /* write out this number of packets */
663 unsigned long nwa; /* next writeable address */
664 unsigned char writeable; /* cdrom is writeable */
667 /* Uniform cdrom data structures for cdrom.c */
668 struct cdrom_device_info {
669 struct cdrom_device_ops *ops; /* link to device_ops */
670 struct cdrom_device_info *next; /* next device_info for this major */
671 void *handle; /* driver-dependent data */
672 /* specifications */
673 kdev_t dev; /* device number */
674 int mask; /* mask of capability: disables them */
675 int speed; /* maximum speed for reading data */
676 int capacity; /* number of discs in jukebox */
677 /* device-related storage */
678 int options : 30; /* options flags */
679 unsigned mc_flags : 2; /* media change buffer flags */
680 int use_count; /* number of times device opened */
681 char name[20]; /* name of the device type */
682 /* per-device flags */
683 __u8 sanyo_slot : 2; /* Sanyo 3 CD changer support */
684 __u8 reserved : 6; /* not used yet */
685 struct cdrom_write_settings write;
688 struct cdrom_device_ops {
689 /* routines */
690 int (*open) (struct cdrom_device_info *, int);
691 void (*release) (struct cdrom_device_info *);
692 int (*drive_status) (struct cdrom_device_info *, int);
693 int (*media_changed) (struct cdrom_device_info *, int);
694 int (*tray_move) (struct cdrom_device_info *, int);
695 int (*lock_door) (struct cdrom_device_info *, int);
696 int (*select_speed) (struct cdrom_device_info *, int);
697 int (*select_disc) (struct cdrom_device_info *, int);
698 int (*get_last_session) (struct cdrom_device_info *,
699 struct cdrom_multisession *);
700 int (*get_mcn) (struct cdrom_device_info *,
701 struct cdrom_mcn *);
702 /* hard reset device */
703 int (*reset) (struct cdrom_device_info *);
704 /* play stuff */
705 int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *);
706 /* dev-specific */
707 int (*dev_ioctl) (struct cdrom_device_info *,
708 unsigned int, unsigned long);
709 /* driver specifications */
710 const int capability; /* capability flags */
711 int n_minors; /* number of active minor devices */
712 /* handle uniform packets for scsi type devices (scsi,atapi) */
713 int (*generic_packet) (struct cdrom_device_info *,
714 struct cdrom_generic_command *);
717 /* the general file operations structure: */
718 extern struct file_operations cdrom_fops;
720 extern int register_cdrom(struct cdrom_device_info *cdi);
721 extern int unregister_cdrom(struct cdrom_device_info *cdi);
723 typedef struct {
724 int data;
725 int audio;
726 int cdi;
727 int xa;
728 long error;
729 } tracktype;
731 extern void cdrom_count_tracks(struct cdrom_device_info *cdi,tracktype* tracks);
732 extern int cdrom_get_next_writable(kdev_t dev, long *next_writable);
733 extern int cdrom_get_last_written(kdev_t dev, long *last_written);
734 extern int cdrom_number_of_slots(struct cdrom_device_info *cdi);
735 extern int cdrom_select_disc(struct cdrom_device_info *cdi, int slot);
736 extern int cdrom_mode_select(struct cdrom_device_info *cdi,
737 struct cdrom_generic_command *cgc);
738 extern int cdrom_mode_sense(struct cdrom_device_info *cdi,
739 struct cdrom_generic_command *cgc,
740 int page_code, int page_control);
741 extern void init_cdrom_command(struct cdrom_generic_command *cgc,
742 void *buffer, int len);
744 typedef struct {
745 __u16 disc_information_length;
746 #if defined(__BIG_ENDIAN_BITFIELD)
747 __u8 reserved1 : 3;
748 __u8 erasable : 1;
749 __u8 border_status : 2;
750 __u8 disc_border : 2;
751 #elif defined(__LITTLE_ENDIAN_BITFIELD)
752 __u8 disc_border : 2;
753 __u8 border_status : 2;
754 __u8 erasable : 1;
755 __u8 reserved1 : 3;
756 #else
757 #error "Please fix <asm/byteorder.h>"
758 #endif
759 __u8 n_first_track;
760 __u8 n_sessions_lsb;
761 __u8 first_track_lsb;
762 __u8 last_track_lsb;
763 #if defined(__BIG_ENDIAN_BITFIELD)
764 __u8 did_v : 1;
765 __u8 dbc_v : 1;
766 __u8 uru : 1;
767 __u8 reserved2 : 5;
768 #elif defined(__LITTLE_ENDIAN_BITFIELD)
769 __u8 reserved2 : 5;
770 __u8 uru : 1;
771 __u8 dbc_v : 1;
772 __u8 did_v : 1;
773 #endif
774 __u8 disc_type;
775 __u8 n_sessions_msb;
776 __u8 first_track_msb;
777 __u8 last_track_msb;
778 __u32 disc_id;
779 __u32 lead_in;
780 __u32 lead_out;
781 __u8 disc_bar_code[8];
782 __u8 reserved3;
783 __u8 n_opc;
784 } disc_information;
786 typedef struct {
787 __u16 track_information_length;
788 __u8 track_lsb;
789 __u8 session_lsb;
790 __u8 reserved1;
791 #if defined(__BIG_ENDIAN_BITFIELD)
792 __u8 reserved2 : 2;
793 __u8 damage : 1;
794 __u8 copy : 1;
795 __u8 track_mode : 4;
796 __u8 rt : 1;
797 __u8 blank : 1;
798 __u8 packet : 1;
799 __u8 fp : 1;
800 __u8 data_mode : 4;
801 __u8 reserved3 : 6;
802 __u8 lra_v : 1;
803 __u8 nwa_v : 1;
804 #elif defined(__LITTLE_ENDIAN_BITFIELD)
805 __u8 track_mode : 4;
806 __u8 copy : 1;
807 __u8 damage : 1;
808 __u8 reserved2 : 2;
809 __u8 data_mode : 4;
810 __u8 fp : 1;
811 __u8 packet : 1;
812 __u8 blank : 1;
813 __u8 rt : 1;
814 __u8 nwa_v : 1;
815 __u8 lra_v : 1;
816 __u8 reserved3 : 6;
817 #endif
818 __u32 track_start;
819 __u32 next_writable;
820 __u32 free_blocks;
821 __u32 fixed_packet_size;
822 __u32 track_size;
823 __u32 last_rec_address;
824 } track_information;
826 /* The SCSI spec says there could be 256 slots. */
827 #define CDROM_MAX_SLOTS 256
829 struct cdrom_mechstat_header {
830 #if defined(__BIG_ENDIAN_BITFIELD)
831 __u8 fault : 1;
832 __u8 changer_state : 2;
833 __u8 curslot : 5;
834 __u8 mech_state : 3;
835 __u8 door_open : 1;
836 __u8 reserved1 : 4;
837 #elif defined(__LITTLE_ENDIAN_BITFIELD)
838 __u8 curslot : 5;
839 __u8 changer_state : 2;
840 __u8 fault : 1;
841 __u8 reserved1 : 4;
842 __u8 door_open : 1;
843 __u8 mech_state : 3;
844 #endif
845 __u8 curlba[3];
846 __u8 nslots;
847 __u8 short slot_tablelen;
850 struct cdrom_slot {
851 #if defined(__BIG_ENDIAN_BITFIELD)
852 __u8 disc_present : 1;
853 __u8 reserved1 : 6;
854 __u8 change : 1;
855 #elif defined(__LITTLE_ENDIAN_BITFIELD)
856 __u8 change : 1;
857 __u8 reserved1 : 6;
858 __u8 disc_present : 1;
859 #endif
860 __u8 reserved2[3];
863 struct cdrom_changer_info {
864 struct cdrom_mechstat_header hdr;
865 struct cdrom_slot slots[CDROM_MAX_SLOTS];
868 typedef enum {
869 mechtype_caddy = 0,
870 mechtype_tray = 1,
871 mechtype_popup = 2,
872 mechtype_individual_changer = 4,
873 mechtype_cartridge_changer = 5
874 } mechtype_t;
876 struct mode_page_header {
877 __u16 mode_data_length;
878 __u8 medium_type;
879 __u8 reserved1;
880 __u8 reserved2;
881 __u8 reserved3;
882 __u16 desc_length;
885 typedef struct {
886 struct mode_page_header header;
887 #if defined(__BIG_ENDIAN_BITFIELD)
888 __u8 ps : 1;
889 __u8 reserved1 : 1;
890 __u8 page_code : 6;
891 __u8 page_length;
892 __u8 reserved2 : 1;
893 __u8 bufe : 1;
894 __u8 ls_v : 1;
895 __u8 test_write : 1;
896 __u8 write_type : 4;
897 __u8 multi_session : 2; /* or border, DVD */
898 __u8 fp : 1;
899 __u8 copy : 1;
900 __u8 track_mode : 4;
901 __u8 reserved3 : 4;
902 __u8 data_block_type : 4;
903 #elif defined(__LITTLE_ENDIAN_BITFIELD)
904 __u8 page_code : 6;
905 __u8 reserved1 : 1;
906 __u8 ps : 1;
907 __u8 page_length;
908 __u8 write_type : 4;
909 __u8 test_write : 1;
910 __u8 ls_v : 1;
911 __u8 bufe : 1;
912 __u8 reserved2 : 1;
913 __u8 track_mode : 4;
914 __u8 copy : 1;
915 __u8 fp : 1;
916 __u8 multi_session : 2; /* or border, DVD */
917 __u8 data_block_type : 4;
918 __u8 reserved3 : 4;
919 #endif
920 __u8 link_size;
921 __u8 reserved4;
922 #if defined(__BIG_ENDIAN_BITFIELD)
923 __u8 reserved5 : 2;
924 __u8 app_code : 6;
925 #elif defined(__LITTLE_ENDIAN_BITFIELD)
926 __u8 app_code : 6;
927 __u8 reserved5 : 2;
928 #endif
929 __u8 session_format;
930 __u8 reserved6;
931 __u32 packet_size;
932 __u16 audio_pause;
933 __u8 mcn[16];
934 __u8 isrc[16];
935 __u8 subhdr0;
936 __u8 subhdr1;
937 __u8 subhdr2;
938 __u8 subhdr3;
939 } write_param_page __attribute__((packed));
941 #endif /* End of kernel only stuff */
943 #endif /* _LINUX_CDROM_H */