1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * -- <linux/cdrom.h> 4 * General header file for linux CD-ROM drivers 5 * Copyright (C) 1992 David Giller, rafetmad@oxy.edu 6 * 1994, 1995 Eberhard Mönkeberg, emoenke@gwdg.de 7 * 1996 David van Leeuwen, david@tm.tno.nl 8 * 1997, 1998 Erik Andersen, andersee@debian.org 9 * 1998-2002 Jens Axboe, axboe@suse.de 10 */ 11 12 #ifndef _UAPI_LINUX_CDROM_H 13 #define _UAPI_LINUX_CDROM_H 14 15 #include <linux/types.h> 16 #include <asm/byteorder.h> 17 18 /******************************************************* 19 * As of Linux 2.1.x, all Linux CD-ROM application programs will use this 20 * (and only this) include file. It is my hope to provide Linux with 21 * a uniform interface between software accessing CD-ROMs and the various 22 * device drivers that actually talk to the drives. There may still be 23 * 23 different kinds of strange CD-ROM drives, but at least there will 24 * now be one, and only one, Linux CD-ROM interface. 25 * 26 * Additionally, as of Linux 2.1.x, all Linux application programs 27 * should use the O_NONBLOCK option when opening a CD-ROM device 28 * for subsequent ioctl commands. This allows for neat system errors 29 * like "No medium found" or "Wrong medium type" upon attempting to 30 * mount or play an empty slot, mount an audio disc, or play a data disc. 31 * Generally, changing an application program to support O_NONBLOCK 32 * is as easy as the following: 33 * - drive = open("/dev/cdrom", O_RDONLY); 34 * + drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK); 35 * It is worth the small change. 36 * 37 * Patches for many common CD programs (provided by David A. van Leeuwen) 38 * can be found at: ftp://ftp.gwdg.de/pub/linux/cdrom/drivers/cm206/ 39 * 40 *******************************************************/ 41 42 /* When a driver supports a certain function, but the cdrom drive we are 43 * using doesn't, we will return the error EDRIVE_CANT_DO_THIS. We will 44 * borrow the "Operation not supported" error from the network folks to 45 * accomplish this. Maybe someday we will get a more targeted error code, 46 * but this will do for now... */ 47 #define EDRIVE_CANT_DO_THIS EOPNOTSUPP 48 49 /******************************************************* 50 * The CD-ROM IOCTL commands -- these should be supported by 51 * all the various cdrom drivers. For the CD-ROM ioctls, we 52 * will commandeer byte 0x53, or 'S'. 53 *******************************************************/ 54 #define CDROMPAUSE 0x5301 /* Pause Audio Operation */ 55 #define CDROMRESUME 0x5302 /* Resume paused Audio Operation */ 56 #define CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */ 57 #define CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index 58 (struct cdrom_ti) */ 59 #define CDROMREADTOCHDR 0x5305 /* Read TOC header 60 (struct cdrom_tochdr) */ 61 #define CDROMREADTOCENTRY 0x5306 /* Read TOC entry 62 (struct cdrom_tocentry) */ 63 #define CDROMSTOP 0x5307 /* Stop the cdrom drive */ 64 #define CDROMSTART 0x5308 /* Start the cdrom drive */ 65 #define CDROMEJECT 0x5309 /* Ejects the cdrom media */ 66 #define CDROMVOLCTRL 0x530a /* Control output volume 67 (struct cdrom_volctrl) */ 68 #define CDROMSUBCHNL 0x530b /* Read subchannel data 69 (struct cdrom_subchnl) */ 70 #define CDROMREADMODE2 0x530c /* Read CDROM mode 2 data (2336 Bytes) 71 (struct cdrom_read) */ 72 #define CDROMREADMODE1 0x530d /* Read CDROM mode 1 data (2048 Bytes) 73 (struct cdrom_read) */ 74 #define CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */ 75 #define CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */ 76 #define CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session 77 address of multi session disks 78 (struct cdrom_multisession) */ 79 #define CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code" 80 if available (struct cdrom_mcn) */ 81 #define CDROM_GET_UPC CDROM_GET_MCN /* This one is deprecated, 82 but here anyway for compatibility */ 83 #define CDROMRESET 0x5312 /* hard-reset the drive */ 84 #define CDROMVOLREAD 0x5313 /* Get the drive's volume setting 85 (struct cdrom_volctrl) */ 86 #define CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes) 87 (struct cdrom_read) */ 88 /* 89 * These ioctls are used only used in aztcd.c and optcd.c 90 */ 91 #define CDROMREADCOOKED 0x5315 /* read data in cooked mode */ 92 #define CDROMSEEK 0x5316 /* seek msf address */ 93 94 /* 95 * This ioctl is only used by the scsi-cd driver. 96 It is for playing audio in logical block addressing mode. 97 */ 98 #define CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */ 99 100 /* 101 * These ioctls are only used in optcd.c 102 */ 103 #define CDROMREADALL 0x5318 /* read all 2646 bytes */ 104 105 /* 106 * These ioctls were only in (now removed) ide-cd.c for controlling 107 * drive spindown time. They should be implemented in the 108 * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10, 109 * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE... 110 * -Erik 111 */ 112 #define CDROMGETSPINDOWN 0x531d 113 #define CDROMSETSPINDOWN 0x531e 114 115 /* 116 * These ioctls are implemented through the uniform CD-ROM driver 117 * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM 118 * drivers are eventually ported to the uniform CD-ROM driver interface. 119 */ 120 #define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */ 121 #define CDROM_SET_OPTIONS 0x5320 /* Set behavior options */ 122 #define CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */ 123 #define CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */ 124 #define CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */ 125 #define CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */ 126 #define CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */ 127 #define CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */ 128 #define CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */ 129 #define CDROM_LOCKDOOR 0x5329 /* lock or unlock door */ 130 #define CDROM_DEBUG 0x5330 /* Turn debug messages on/off */ 131 #define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */ 132 133 /* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386. 134 * Future CDROM ioctls should be kept below 0x537F 135 */ 136 137 /* This ioctl is only used by sbpcd at the moment */ 138 #define CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */ 139 /* conflict with SCSI_IOCTL_GET_IDLUN */ 140 141 /* DVD-ROM Specific ioctls */ 142 #define DVD_READ_STRUCT 0x5390 /* Read structure */ 143 #define DVD_WRITE_STRUCT 0x5391 /* Write structure */ 144 #define DVD_AUTH 0x5392 /* Authentication */ 145 146 #define CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */ 147 #define CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */ 148 #define CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */ 149 150 #define CDROM_TIMED_MEDIA_CHANGE 0x5396 /* get the timestamp of the last media change */ 151 152 /******************************************************* 153 * CDROM IOCTL structures 154 *******************************************************/ 155 156 /* Address in MSF format */ 157 struct cdrom_msf0 158 { 159 __u8 minute; 160 __u8 second; 161 __u8 frame; 162 }; 163 164 /* Address in either MSF or logical format */ 165 union cdrom_addr 166 { 167 struct cdrom_msf0 msf; 168 int lba; 169 }; 170 171 /* This struct is used by the CDROMPLAYMSF ioctl */ 172 struct cdrom_msf 173 { 174 __u8 cdmsf_min0; /* start minute */ 175 __u8 cdmsf_sec0; /* start second */ 176 __u8 cdmsf_frame0; /* start frame */ 177 __u8 cdmsf_min1; /* end minute */ 178 __u8 cdmsf_sec1; /* end second */ 179 __u8 cdmsf_frame1; /* end frame */ 180 }; 181 182 /* This struct is used by the CDROMPLAYTRKIND ioctl */ 183 struct cdrom_ti 184 { 185 __u8 cdti_trk0; /* start track */ 186 __u8 cdti_ind0; /* start index */ 187 __u8 cdti_trk1; /* end track */ 188 __u8 cdti_ind1; /* end index */ 189 }; 190 191 /* This struct is used by the CDROMREADTOCHDR ioctl */ 192 struct cdrom_tochdr 193 { 194 __u8 cdth_trk0; /* start track */ 195 __u8 cdth_trk1; /* end track */ 196 }; 197 198 /* This struct is used by the CDROMVOLCTRL and CDROMVOLREAD ioctls */ 199 struct cdrom_volctrl 200 { 201 __u8 channel0; 202 __u8 channel1; 203 __u8 channel2; 204 __u8 channel3; 205 }; 206 207 /* This struct is used by the CDROMSUBCHNL ioctl */ 208 struct cdrom_subchnl 209 { 210 __u8 cdsc_format; 211 __u8 cdsc_audiostatus; 212 __u8 cdsc_adr: 4; 213 __u8 cdsc_ctrl: 4; 214 __u8 cdsc_trk; 215 __u8 cdsc_ind; 216 union cdrom_addr cdsc_absaddr; 217 union cdrom_addr cdsc_reladdr; 218 }; 219 220 221 /* This struct is used by the CDROMREADTOCENTRY ioctl */ 222 struct cdrom_tocentry 223 { 224 __u8 cdte_track; 225 __u8 cdte_adr :4; 226 __u8 cdte_ctrl :4; 227 __u8 cdte_format; 228 union cdrom_addr cdte_addr; 229 __u8 cdte_datamode; 230 }; 231 232 /* This struct is used by the CDROMREADMODE1, and CDROMREADMODE2 ioctls */ 233 struct cdrom_read 234 { 235 int cdread_lba; 236 char *cdread_bufaddr; 237 int cdread_buflen; 238 }; 239 240 /* This struct is used by the CDROMREADAUDIO ioctl */ 241 struct cdrom_read_audio 242 { 243 union cdrom_addr addr; /* frame address */ 244 __u8 addr_format; /* CDROM_LBA or CDROM_MSF */ 245 int nframes; /* number of 2352-byte-frames to read at once */ 246 __u8 __user *buf; /* frame buffer (size: nframes*2352 bytes) */ 247 }; 248 249 /* This struct is used with the CDROMMULTISESSION ioctl */ 250 struct cdrom_multisession 251 { 252 union cdrom_addr addr; /* frame address: start-of-last-session 253 (not the new "frame 16"!). Only valid 254 if the "xa_flag" is true. */ 255 __u8 xa_flag; /* 1: "is XA disk" */ 256 __u8 addr_format; /* CDROM_LBA or CDROM_MSF */ 257 }; 258 259 /* This struct is used with the CDROM_GET_MCN ioctl. 260 * Very few audio discs actually have Universal Product Code information, 261 * which should just be the Medium Catalog Number on the box. Also note 262 * that the way the codeis written on CD is _not_ uniform across all discs! 263 */ 264 struct cdrom_mcn 265 { 266 __u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */ 267 }; 268 269 /* This is used by the CDROMPLAYBLK ioctl */ 270 struct cdrom_blk 271 { 272 unsigned from; 273 unsigned short len; 274 }; 275 276 #define CDROM_PACKET_SIZE 12 277 278 #define CGC_DATA_UNKNOWN 0 279 #define CGC_DATA_WRITE 1 280 #define CGC_DATA_READ 2 281 #define CGC_DATA_NONE 3 282 283 /* for CDROM_PACKET_COMMAND ioctl */ 284 struct cdrom_generic_command 285 { 286 unsigned char cmd[CDROM_PACKET_SIZE]; 287 unsigned char __user *buffer; 288 unsigned int buflen; 289 int stat; 290 struct request_sense __user *sense; 291 unsigned char data_direction; 292 int quiet; 293 int timeout; 294 union { 295 void __user *reserved[1]; /* unused, actually */ 296 void __user *unused; 297 }; 298 }; 299 300 /* This struct is used by CDROM_TIMED_MEDIA_CHANGE */ 301 struct cdrom_timed_media_change_info { 302 __s64 last_media_change; /* Timestamp of the last detected media 303 * change in ms. May be set by caller, 304 * updated upon successful return of 305 * ioctl. 306 */ 307 __u64 media_flags; /* Flags returned by ioctl to indicate 308 * media status. 309 */ 310 }; 311 #define MEDIA_CHANGED_FLAG 0x1 /* Last detected media change was more 312 * recent than last_media_change set by 313 * caller. 314 */ 315 /* other bits of media_flags available for future use */ 316 317 /* 318 * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336, 319 * 2340, or 2352 bytes long. 320 321 * Sector types of the standard CD-ROM data formats: 322 * 323 * format sector type user data size (bytes) 324 * ----------------------------------------------------------------------------- 325 * 1 (Red Book) CD-DA 2352 (CD_FRAMESIZE_RAW) 326 * 2 (Yellow Book) Mode1 Form1 2048 (CD_FRAMESIZE) 327 * 3 (Yellow Book) Mode1 Form2 2336 (CD_FRAMESIZE_RAW0) 328 * 4 (Green Book) Mode2 Form1 2048 (CD_FRAMESIZE) 329 * 5 (Green Book) Mode2 Form2 2328 (2324+4 spare bytes) 330 * 331 * 332 * The layout of the standard CD-ROM data formats: 333 * ----------------------------------------------------------------------------- 334 * - audio (red): | audio_sample_bytes | 335 * | 2352 | 336 * 337 * - data (yellow, mode1): | sync - head - data - EDC - zero - ECC | 338 * | 12 - 4 - 2048 - 4 - 8 - 276 | 339 * 340 * - data (yellow, mode2): | sync - head - data | 341 * | 12 - 4 - 2336 | 342 * 343 * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC | 344 * | 12 - 4 - 8 - 2048 - 4 - 276 | 345 * 346 * - XA data (green, mode2 form2): | sync - head - sub - data - Spare | 347 * | 12 - 4 - 8 - 2324 - 4 | 348 * 349 */ 350 351 /* Some generally useful CD-ROM information -- mostly based on the above */ 352 #define CD_MINS 74 /* max. minutes per CD, not really a limit */ 353 #define CD_SECS 60 /* seconds per minute */ 354 #define CD_FRAMES 75 /* frames per second */ 355 #define CD_SYNC_SIZE 12 /* 12 sync bytes per raw data frame */ 356 #define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */ 357 #define CD_CHUNK_SIZE 24 /* lowest-level "data bytes piece" */ 358 #define CD_NUM_OF_CHUNKS 98 /* chunks per frame */ 359 #define CD_FRAMESIZE_SUB 96 /* subchannel data "frame" size */ 360 #define CD_HEAD_SIZE 4 /* header (address) bytes per raw data frame */ 361 #define CD_SUBHEAD_SIZE 8 /* subheader bytes per raw XA data frame */ 362 #define CD_EDC_SIZE 4 /* bytes EDC per most raw data frame types */ 363 #define CD_ZERO_SIZE 8 /* bytes zero per yellow book mode 1 frame */ 364 #define CD_ECC_SIZE 276 /* bytes ECC per most raw data frame types */ 365 #define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */ 366 #define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */ 367 #define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */ 368 /* most drives don't deliver everything: */ 369 #define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/ 370 #define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/ 371 372 #define CD_XA_HEAD (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */ 373 #define CD_XA_TAIL (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */ 374 #define CD_XA_SYNC_HEAD (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */ 375 376 /* CD-ROM address types (cdrom_tocentry.cdte_format) */ 377 #define CDROM_LBA 0x01 /* "logical block": first frame is #0 */ 378 #define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */ 379 380 /* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */ 381 #define CDROM_DATA_TRACK 0x04 382 383 /* The leadout track is always 0xAA, regardless of # of tracks on disc */ 384 #define CDROM_LEADOUT 0xAA 385 386 /* audio states (from SCSI-2, but seen with other drives, too) */ 387 #define CDROM_AUDIO_INVALID 0x00 /* audio status not supported */ 388 #define CDROM_AUDIO_PLAY 0x11 /* audio play operation in progress */ 389 #define CDROM_AUDIO_PAUSED 0x12 /* audio play operation paused */ 390 #define CDROM_AUDIO_COMPLETED 0x13 /* audio play successfully completed */ 391 #define CDROM_AUDIO_ERROR 0x14 /* audio play stopped due to error */ 392 #define CDROM_AUDIO_NO_STATUS 0x15 /* no current audio status to return */ 393 394 /* capability flags used with the uniform CD-ROM driver */ 395 #define CDC_CLOSE_TRAY 0x1 /* caddy systems _can't_ close */ 396 #define CDC_OPEN_TRAY 0x2 /* but _can_ eject. */ 397 #define CDC_LOCK 0x4 /* disable manual eject */ 398 #define CDC_SELECT_SPEED 0x8 /* programmable speed */ 399 #define CDC_SELECT_DISC 0x10 /* select disc from juke-box */ 400 #define CDC_MULTI_SESSION 0x20 /* read sessions>1 */ 401 #define CDC_MCN 0x40 /* Medium Catalog Number */ 402 #define CDC_MEDIA_CHANGED 0x80 /* media changed */ 403 #define CDC_PLAY_AUDIO 0x100 /* audio functions */ 404 #define CDC_RESET 0x200 /* hard reset device */ 405 #define CDC_DRIVE_STATUS 0x800 /* driver implements drive status */ 406 #define CDC_GENERIC_PACKET 0x1000 /* driver implements generic packets */ 407 #define CDC_CD_R 0x2000 /* drive is a CD-R */ 408 #define CDC_CD_RW 0x4000 /* drive is a CD-RW */ 409 #define CDC_DVD 0x8000 /* drive is a DVD */ 410 #define CDC_DVD_R 0x10000 /* drive can write DVD-R */ 411 #define CDC_DVD_RAM 0x20000 /* drive can write DVD-RAM */ 412 #define CDC_MO_DRIVE 0x40000 /* drive is an MO device */ 413 #define CDC_MRW 0x80000 /* drive can read MRW */ 414 #define CDC_MRW_W 0x100000 /* drive can write MRW */ 415 #define CDC_RAM 0x200000 /* ok to open for WRITE */ 416 417 /* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */ 418 #define CDS_NO_INFO 0 /* if not implemented */ 419 #define CDS_NO_DISC 1 420 #define CDS_TRAY_OPEN 2 421 #define CDS_DRIVE_NOT_READY 3 422 #define CDS_DISC_OK 4 423 424 /* return values for the CDROM_DISC_STATUS ioctl */ 425 /* can also return CDS_NO_[INFO|DISC], from above */ 426 #define CDS_AUDIO 100 427 #define CDS_DATA_1 101 428 #define CDS_DATA_2 102 429 #define CDS_XA_2_1 103 430 #define CDS_XA_2_2 104 431 #define CDS_MIXED 105 432 433 /* User-configurable behavior options for the uniform CD-ROM driver */ 434 #define CDO_AUTO_CLOSE 0x1 /* close tray on first open() */ 435 #define CDO_AUTO_EJECT 0x2 /* open tray on last release() */ 436 #define CDO_USE_FFLAGS 0x4 /* use O_NONBLOCK information on open */ 437 #define CDO_LOCK 0x8 /* lock tray on open files */ 438 #define CDO_CHECK_TYPE 0x10 /* check type on open for data */ 439 440 /* Special codes used when specifying changer slots. */ 441 #define CDSL_NONE (INT_MAX-1) 442 #define CDSL_CURRENT INT_MAX 443 444 /* For partition based multisession access. IDE can handle 64 partitions 445 * per drive - SCSI CD-ROM's use minors to differentiate between the 446 * various drives, so we can't do multisessions the same way there. 447 * Use the -o session=x option to mount on them. 448 */ 449 #define CD_PART_MAX 64 450 #define CD_PART_MASK (CD_PART_MAX - 1) 451 452 /********************************************************************* 453 * Generic Packet commands, MMC commands, and such 454 *********************************************************************/ 455 456 /* The generic packet command opcodes for CD/DVD Logical Units, 457 * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ 458 #define GPCMD_BLANK 0xa1 459 #define GPCMD_CLOSE_TRACK 0x5b 460 #define GPCMD_FLUSH_CACHE 0x35 461 #define GPCMD_FORMAT_UNIT 0x04 462 #define GPCMD_GET_CONFIGURATION 0x46 463 #define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a 464 #define GPCMD_GET_PERFORMANCE 0xac 465 #define GPCMD_INQUIRY 0x12 466 #define GPCMD_LOAD_UNLOAD 0xa6 467 #define GPCMD_MECHANISM_STATUS 0xbd 468 #define GPCMD_MODE_SELECT_10 0x55 469 #define GPCMD_MODE_SENSE_10 0x5a 470 #define GPCMD_PAUSE_RESUME 0x4b 471 #define GPCMD_PLAY_AUDIO_10 0x45 472 #define GPCMD_PLAY_AUDIO_MSF 0x47 473 #define GPCMD_PLAY_AUDIO_TI 0x48 474 #define GPCMD_PLAY_CD 0xbc 475 #define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e 476 #define GPCMD_READ_10 0x28 477 #define GPCMD_READ_12 0xa8 478 #define GPCMD_READ_BUFFER 0x3c 479 #define GPCMD_READ_BUFFER_CAPACITY 0x5c 480 #define GPCMD_READ_CDVD_CAPACITY 0x25 481 #define GPCMD_READ_CD 0xbe 482 #define GPCMD_READ_CD_MSF 0xb9 483 #define GPCMD_READ_DISC_INFO 0x51 484 #define GPCMD_READ_DVD_STRUCTURE 0xad 485 #define GPCMD_READ_FORMAT_CAPACITIES 0x23 486 #define GPCMD_READ_HEADER 0x44 487 #define GPCMD_READ_TRACK_RZONE_INFO 0x52 488 #define GPCMD_READ_SUBCHANNEL 0x42 489 #define GPCMD_READ_TOC_PMA_ATIP 0x43 490 #define GPCMD_REPAIR_RZONE_TRACK 0x58 491 #define GPCMD_REPORT_KEY 0xa4 492 #define GPCMD_REQUEST_SENSE 0x03 493 #define GPCMD_RESERVE_RZONE_TRACK 0x53 494 #define GPCMD_SEND_CUE_SHEET 0x5d 495 #define GPCMD_SCAN 0xba 496 #define GPCMD_SEEK 0x2b 497 #define GPCMD_SEND_DVD_STRUCTURE 0xbf 498 #define GPCMD_SEND_EVENT 0xa2 499 #define GPCMD_SEND_KEY 0xa3 500 #define GPCMD_SEND_OPC 0x54 501 #define GPCMD_SET_READ_AHEAD 0xa7 502 #define GPCMD_SET_STREAMING 0xb6 503 #define GPCMD_START_STOP_UNIT 0x1b 504 #define GPCMD_STOP_PLAY_SCAN 0x4e 505 #define GPCMD_TEST_UNIT_READY 0x00 506 #define GPCMD_VERIFY_10 0x2f 507 #define GPCMD_WRITE_10 0x2a 508 #define GPCMD_WRITE_12 0xaa 509 #define GPCMD_WRITE_AND_VERIFY_10 0x2e 510 #define GPCMD_WRITE_BUFFER 0x3b 511 /* This is listed as optional in ATAPI 2.6, but is (curiously) 512 * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji 513 * Table 377 as an MMC command for SCSi devices though... Most ATAPI 514 * drives support it. */ 515 #define GPCMD_SET_SPEED 0xbb 516 /* This seems to be a SCSI specific CD-ROM opcode 517 * to play data at track/index */ 518 #define GPCMD_PLAYAUDIO_TI 0x48 519 /* 520 * From MS Media Status Notification Support Specification. For 521 * older drives only. 522 */ 523 #define GPCMD_GET_MEDIA_STATUS 0xda 524 525 /* Mode page codes for mode sense/set */ 526 #define GPMODE_VENDOR_PAGE 0x00 527 #define GPMODE_R_W_ERROR_PAGE 0x01 528 #define GPMODE_WRITE_PARMS_PAGE 0x05 529 #define GPMODE_WCACHING_PAGE 0x08 530 #define GPMODE_AUDIO_CTL_PAGE 0x0e 531 #define GPMODE_POWER_PAGE 0x1a 532 #define GPMODE_FAULT_FAIL_PAGE 0x1c 533 #define GPMODE_TO_PROTECT_PAGE 0x1d 534 #define GPMODE_CAPABILITIES_PAGE 0x2a 535 #define GPMODE_ALL_PAGES 0x3f 536 /* Not in Mt. Fuji, but in ATAPI 2.6 -- deprecated now in favor 537 * of MODE_SENSE_POWER_PAGE */ 538 #define GPMODE_CDROM_PAGE 0x0d 539 540 541 542 /* DVD struct types */ 543 #define DVD_STRUCT_PHYSICAL 0x00 544 #define DVD_STRUCT_COPYRIGHT 0x01 545 #define DVD_STRUCT_DISCKEY 0x02 546 #define DVD_STRUCT_BCA 0x03 547 #define DVD_STRUCT_MANUFACT 0x04 548 549 struct dvd_layer { 550 __u8 book_version : 4; 551 __u8 book_type : 4; 552 __u8 min_rate : 4; 553 __u8 disc_size : 4; 554 __u8 layer_type : 4; 555 __u8 track_path : 1; 556 __u8 nlayers : 2; 557 __u8 track_density : 4; 558 __u8 linear_density : 4; 559 __u8 bca : 1; 560 __u32 start_sector; 561 __u32 end_sector; 562 __u32 end_sector_l0; 563 }; 564 565 #define DVD_LAYERS 4 566 567 struct dvd_physical { 568 __u8 type; 569 __u8 layer_num; 570 struct dvd_layer layer[DVD_LAYERS]; 571 }; 572 573 struct dvd_copyright { 574 __u8 type; 575 576 __u8 layer_num; 577 __u8 cpst; 578 __u8 rmi; 579 }; 580 581 struct dvd_disckey { 582 __u8 type; 583 584 unsigned agid : 2; 585 __u8 value[2048]; 586 }; 587 588 struct dvd_bca { 589 __u8 type; 590 591 int len; 592 __u8 value[188]; 593 }; 594 595 struct dvd_manufact { 596 __u8 type; 597 598 __u8 layer_num; 599 int len; 600 __u8 value[2048]; 601 }; 602 603 typedef union { 604 __u8 type; 605 606 struct dvd_physical physical; 607 struct dvd_copyright copyright; 608 struct dvd_disckey disckey; 609 struct dvd_bca bca; 610 struct dvd_manufact manufact; 611 } dvd_struct; 612 613 /* 614 * DVD authentication ioctl 615 */ 616 617 /* Authentication states */ 618 #define DVD_LU_SEND_AGID 0 619 #define DVD_HOST_SEND_CHALLENGE 1 620 #define DVD_LU_SEND_KEY1 2 621 #define DVD_LU_SEND_CHALLENGE 3 622 #define DVD_HOST_SEND_KEY2 4 623 624 /* Termination states */ 625 #define DVD_AUTH_ESTABLISHED 5 626 #define DVD_AUTH_FAILURE 6 627 628 /* Other functions */ 629 #define DVD_LU_SEND_TITLE_KEY 7 630 #define DVD_LU_SEND_ASF 8 631 #define DVD_INVALIDATE_AGID 9 632 #define DVD_LU_SEND_RPC_STATE 10 633 #define DVD_HOST_SEND_RPC_STATE 11 634 635 /* State data */ 636 typedef __u8 dvd_key[5]; /* 40-bit value, MSB is first elem. */ 637 typedef __u8 dvd_challenge[10]; /* 80-bit value, MSB is first elem. */ 638 639 struct dvd_lu_send_agid { 640 __u8 type; 641 unsigned agid : 2; 642 }; 643 644 struct dvd_host_send_challenge { 645 __u8 type; 646 unsigned agid : 2; 647 648 dvd_challenge chal; 649 }; 650 651 struct dvd_send_key { 652 __u8 type; 653 unsigned agid : 2; 654 655 dvd_key key; 656 }; 657 658 struct dvd_lu_send_challenge { 659 __u8 type; 660 unsigned agid : 2; 661 662 dvd_challenge chal; 663 }; 664 665 #define DVD_CPM_NO_COPYRIGHT 0 666 #define DVD_CPM_COPYRIGHTED 1 667 668 #define DVD_CP_SEC_NONE 0 669 #define DVD_CP_SEC_EXIST 1 670 671 #define DVD_CGMS_UNRESTRICTED 0 672 #define DVD_CGMS_SINGLE 2 673 #define DVD_CGMS_RESTRICTED 3 674 675 struct dvd_lu_send_title_key { 676 __u8 type; 677 unsigned agid : 2; 678 679 dvd_key title_key; 680 int lba; 681 unsigned cpm : 1; 682 unsigned cp_sec : 1; 683 unsigned cgms : 2; 684 }; 685 686 struct dvd_lu_send_asf { 687 __u8 type; 688 unsigned agid : 2; 689 690 unsigned asf : 1; 691 }; 692 693 struct dvd_host_send_rpcstate { 694 __u8 type; 695 __u8 pdrc; 696 }; 697 698 struct dvd_lu_send_rpcstate { 699 __u8 type : 2; 700 __u8 vra : 3; 701 __u8 ucca : 3; 702 __u8 region_mask; 703 __u8 rpc_scheme; 704 }; 705 706 typedef union { 707 __u8 type; 708 709 struct dvd_lu_send_agid lsa; 710 struct dvd_host_send_challenge hsc; 711 struct dvd_send_key lsk; 712 struct dvd_lu_send_challenge lsc; 713 struct dvd_send_key hsk; 714 struct dvd_lu_send_title_key lstk; 715 struct dvd_lu_send_asf lsasf; 716 struct dvd_host_send_rpcstate hrpcs; 717 struct dvd_lu_send_rpcstate lrpcs; 718 } dvd_authinfo; 719 720 struct request_sense { 721 #if defined(__BIG_ENDIAN_BITFIELD) 722 __u8 valid : 1; 723 __u8 error_code : 7; 724 #elif defined(__LITTLE_ENDIAN_BITFIELD) 725 __u8 error_code : 7; 726 __u8 valid : 1; 727 #endif 728 __u8 segment_number; 729 #if defined(__BIG_ENDIAN_BITFIELD) 730 __u8 reserved1 : 2; 731 __u8 ili : 1; 732 __u8 reserved2 : 1; 733 __u8 sense_key : 4; 734 #elif defined(__LITTLE_ENDIAN_BITFIELD) 735 __u8 sense_key : 4; 736 __u8 reserved2 : 1; 737 __u8 ili : 1; 738 __u8 reserved1 : 2; 739 #endif 740 __u8 information[4]; 741 __u8 add_sense_len; 742 __u8 command_info[4]; 743 __u8 asc; 744 __u8 ascq; 745 __u8 fruc; 746 __u8 sks[3]; 747 __u8 asb[46]; 748 }; 749 750 /* 751 * feature profile 752 */ 753 #define CDF_RWRT 0x0020 /* "Random Writable" */ 754 #define CDF_HWDM 0x0024 /* "Hardware Defect Management" */ 755 #define CDF_MRW 0x0028 756 757 /* 758 * media status bits 759 */ 760 #define CDM_MRW_NOTMRW 0 761 #define CDM_MRW_BGFORMAT_INACTIVE 1 762 #define CDM_MRW_BGFORMAT_ACTIVE 2 763 #define CDM_MRW_BGFORMAT_COMPLETE 3 764 765 /* 766 * mrw address spaces 767 */ 768 #define MRW_LBA_DMA 0 769 #define MRW_LBA_GAA 1 770 771 /* 772 * mrw mode pages (first is deprecated) -- probed at init time and 773 * cdi->mrw_mode_page is set 774 */ 775 #define MRW_MODE_PC_PRE1 0x2c 776 #define MRW_MODE_PC 0x03 777 778 struct mrw_feature_desc { 779 __be16 feature_code; 780 #if defined(__BIG_ENDIAN_BITFIELD) 781 __u8 reserved1 : 2; 782 __u8 feature_version : 4; 783 __u8 persistent : 1; 784 __u8 curr : 1; 785 #elif defined(__LITTLE_ENDIAN_BITFIELD) 786 __u8 curr : 1; 787 __u8 persistent : 1; 788 __u8 feature_version : 4; 789 __u8 reserved1 : 2; 790 #endif 791 __u8 add_len; 792 #if defined(__BIG_ENDIAN_BITFIELD) 793 __u8 reserved2 : 7; 794 __u8 write : 1; 795 #elif defined(__LITTLE_ENDIAN_BITFIELD) 796 __u8 write : 1; 797 __u8 reserved2 : 7; 798 #endif 799 __u8 reserved3; 800 __u8 reserved4; 801 __u8 reserved5; 802 }; 803 804 /* cf. mmc4r02g.pdf 5.3.10 Random Writable Feature (0020h) pg 197 of 635 */ 805 struct rwrt_feature_desc { 806 __be16 feature_code; 807 #if defined(__BIG_ENDIAN_BITFIELD) 808 __u8 reserved1 : 2; 809 __u8 feature_version : 4; 810 __u8 persistent : 1; 811 __u8 curr : 1; 812 #elif defined(__LITTLE_ENDIAN_BITFIELD) 813 __u8 curr : 1; 814 __u8 persistent : 1; 815 __u8 feature_version : 4; 816 __u8 reserved1 : 2; 817 #endif 818 __u8 add_len; 819 __u32 last_lba; 820 __u32 block_size; 821 __u16 blocking; 822 #if defined(__BIG_ENDIAN_BITFIELD) 823 __u8 reserved2 : 7; 824 __u8 page_present : 1; 825 #elif defined(__LITTLE_ENDIAN_BITFIELD) 826 __u8 page_present : 1; 827 __u8 reserved2 : 7; 828 #endif 829 __u8 reserved3; 830 }; 831 832 typedef struct { 833 __be16 disc_information_length; 834 #if defined(__BIG_ENDIAN_BITFIELD) 835 __u8 reserved1 : 3; 836 __u8 erasable : 1; 837 __u8 border_status : 2; 838 __u8 disc_status : 2; 839 #elif defined(__LITTLE_ENDIAN_BITFIELD) 840 __u8 disc_status : 2; 841 __u8 border_status : 2; 842 __u8 erasable : 1; 843 __u8 reserved1 : 3; 844 #else 845 #error "Please fix <asm/byteorder.h>" 846 #endif 847 __u8 n_first_track; 848 __u8 n_sessions_lsb; 849 __u8 first_track_lsb; 850 __u8 last_track_lsb; 851 #if defined(__BIG_ENDIAN_BITFIELD) 852 __u8 did_v : 1; 853 __u8 dbc_v : 1; 854 __u8 uru : 1; 855 __u8 reserved2 : 2; 856 __u8 dbit : 1; 857 __u8 mrw_status : 2; 858 #elif defined(__LITTLE_ENDIAN_BITFIELD) 859 __u8 mrw_status : 2; 860 __u8 dbit : 1; 861 __u8 reserved2 : 2; 862 __u8 uru : 1; 863 __u8 dbc_v : 1; 864 __u8 did_v : 1; 865 #endif 866 __u8 disc_type; 867 __u8 n_sessions_msb; 868 __u8 first_track_msb; 869 __u8 last_track_msb; 870 __u32 disc_id; 871 __u32 lead_in; 872 __u32 lead_out; 873 __u8 disc_bar_code[8]; 874 __u8 reserved3; 875 __u8 n_opc; 876 } disc_information; 877 878 typedef struct { 879 __be16 track_information_length; 880 __u8 track_lsb; 881 __u8 session_lsb; 882 __u8 reserved1; 883 #if defined(__BIG_ENDIAN_BITFIELD) 884 __u8 reserved2 : 2; 885 __u8 damage : 1; 886 __u8 copy : 1; 887 __u8 track_mode : 4; 888 __u8 rt : 1; 889 __u8 blank : 1; 890 __u8 packet : 1; 891 __u8 fp : 1; 892 __u8 data_mode : 4; 893 __u8 reserved3 : 6; 894 __u8 lra_v : 1; 895 __u8 nwa_v : 1; 896 #elif defined(__LITTLE_ENDIAN_BITFIELD) 897 __u8 track_mode : 4; 898 __u8 copy : 1; 899 __u8 damage : 1; 900 __u8 reserved2 : 2; 901 __u8 data_mode : 4; 902 __u8 fp : 1; 903 __u8 packet : 1; 904 __u8 blank : 1; 905 __u8 rt : 1; 906 __u8 nwa_v : 1; 907 __u8 lra_v : 1; 908 __u8 reserved3 : 6; 909 #endif 910 __be32 track_start; 911 __be32 next_writable; 912 __be32 free_blocks; 913 __be32 fixed_packet_size; 914 __be32 track_size; 915 __be32 last_rec_address; 916 } track_information; 917 918 struct feature_header { 919 __u32 data_len; 920 __u8 reserved1; 921 __u8 reserved2; 922 __u16 curr_profile; 923 }; 924 925 struct mode_page_header { 926 __be16 mode_data_length; 927 __u8 medium_type; 928 __u8 reserved1; 929 __u8 reserved2; 930 __u8 reserved3; 931 __be16 desc_length; 932 }; 933 934 /* removable medium feature descriptor */ 935 struct rm_feature_desc { 936 __be16 feature_code; 937 #if defined(__BIG_ENDIAN_BITFIELD) 938 __u8 reserved1:2; 939 __u8 feature_version:4; 940 __u8 persistent:1; 941 __u8 curr:1; 942 #elif defined(__LITTLE_ENDIAN_BITFIELD) 943 __u8 curr:1; 944 __u8 persistent:1; 945 __u8 feature_version:4; 946 __u8 reserved1:2; 947 #endif 948 __u8 add_len; 949 #if defined(__BIG_ENDIAN_BITFIELD) 950 __u8 mech_type:3; 951 __u8 load:1; 952 __u8 eject:1; 953 __u8 pvnt_jmpr:1; 954 __u8 dbml:1; 955 __u8 lock:1; 956 #elif defined(__LITTLE_ENDIAN_BITFIELD) 957 __u8 lock:1; 958 __u8 dbml:1; 959 __u8 pvnt_jmpr:1; 960 __u8 eject:1; 961 __u8 load:1; 962 __u8 mech_type:3; 963 #endif 964 __u8 reserved2; 965 __u8 reserved3; 966 __u8 reserved4; 967 }; 968 969 #endif /* _UAPI_LINUX_CDROM_H */ 970