16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2607ca46eSDavid Howells /* 3607ca46eSDavid Howells * -- <linux/cdrom.h> 4607ca46eSDavid Howells * General header file for linux CD-ROM drivers 5607ca46eSDavid Howells * Copyright (C) 1992 David Giller, rafetmad@oxy.edu 6607ca46eSDavid Howells * 1994, 1995 Eberhard Mönkeberg, emoenke@gwdg.de 7607ca46eSDavid Howells * 1996 David van Leeuwen, david@tm.tno.nl 8607ca46eSDavid Howells * 1997, 1998 Erik Andersen, andersee@debian.org 9607ca46eSDavid Howells * 1998-2002 Jens Axboe, axboe@suse.de 10607ca46eSDavid Howells */ 11607ca46eSDavid Howells 12607ca46eSDavid Howells #ifndef _UAPI_LINUX_CDROM_H 13607ca46eSDavid Howells #define _UAPI_LINUX_CDROM_H 14607ca46eSDavid Howells 15607ca46eSDavid Howells #include <linux/types.h> 16607ca46eSDavid Howells #include <asm/byteorder.h> 17607ca46eSDavid Howells 18607ca46eSDavid Howells /******************************************************* 19607ca46eSDavid Howells * As of Linux 2.1.x, all Linux CD-ROM application programs will use this 20607ca46eSDavid Howells * (and only this) include file. It is my hope to provide Linux with 21607ca46eSDavid Howells * a uniform interface between software accessing CD-ROMs and the various 22607ca46eSDavid Howells * device drivers that actually talk to the drives. There may still be 23607ca46eSDavid Howells * 23 different kinds of strange CD-ROM drives, but at least there will 24607ca46eSDavid Howells * now be one, and only one, Linux CD-ROM interface. 25607ca46eSDavid Howells * 26607ca46eSDavid Howells * Additionally, as of Linux 2.1.x, all Linux application programs 27607ca46eSDavid Howells * should use the O_NONBLOCK option when opening a CD-ROM device 28607ca46eSDavid Howells * for subsequent ioctl commands. This allows for neat system errors 29607ca46eSDavid Howells * like "No medium found" or "Wrong medium type" upon attempting to 30607ca46eSDavid Howells * mount or play an empty slot, mount an audio disc, or play a data disc. 31607ca46eSDavid Howells * Generally, changing an application program to support O_NONBLOCK 32607ca46eSDavid Howells * is as easy as the following: 33607ca46eSDavid Howells * - drive = open("/dev/cdrom", O_RDONLY); 34607ca46eSDavid Howells * + drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK); 35607ca46eSDavid Howells * It is worth the small change. 36607ca46eSDavid Howells * 37607ca46eSDavid Howells * Patches for many common CD programs (provided by David A. van Leeuwen) 38607ca46eSDavid Howells * can be found at: ftp://ftp.gwdg.de/pub/linux/cdrom/drivers/cm206/ 39607ca46eSDavid Howells * 40607ca46eSDavid Howells *******************************************************/ 41607ca46eSDavid Howells 42607ca46eSDavid Howells /* When a driver supports a certain function, but the cdrom drive we are 43607ca46eSDavid Howells * using doesn't, we will return the error EDRIVE_CANT_DO_THIS. We will 44607ca46eSDavid Howells * borrow the "Operation not supported" error from the network folks to 45607ca46eSDavid Howells * accomplish this. Maybe someday we will get a more targeted error code, 46607ca46eSDavid Howells * but this will do for now... */ 47607ca46eSDavid Howells #define EDRIVE_CANT_DO_THIS EOPNOTSUPP 48607ca46eSDavid Howells 49607ca46eSDavid Howells /******************************************************* 50607ca46eSDavid Howells * The CD-ROM IOCTL commands -- these should be supported by 51607ca46eSDavid Howells * all the various cdrom drivers. For the CD-ROM ioctls, we 52607ca46eSDavid Howells * will commandeer byte 0x53, or 'S'. 53607ca46eSDavid Howells *******************************************************/ 54607ca46eSDavid Howells #define CDROMPAUSE 0x5301 /* Pause Audio Operation */ 55607ca46eSDavid Howells #define CDROMRESUME 0x5302 /* Resume paused Audio Operation */ 56607ca46eSDavid Howells #define CDROMPLAYMSF 0x5303 /* Play Audio MSF (struct cdrom_msf) */ 57607ca46eSDavid Howells #define CDROMPLAYTRKIND 0x5304 /* Play Audio Track/index 58607ca46eSDavid Howells (struct cdrom_ti) */ 59607ca46eSDavid Howells #define CDROMREADTOCHDR 0x5305 /* Read TOC header 60607ca46eSDavid Howells (struct cdrom_tochdr) */ 61607ca46eSDavid Howells #define CDROMREADTOCENTRY 0x5306 /* Read TOC entry 62607ca46eSDavid Howells (struct cdrom_tocentry) */ 63607ca46eSDavid Howells #define CDROMSTOP 0x5307 /* Stop the cdrom drive */ 64607ca46eSDavid Howells #define CDROMSTART 0x5308 /* Start the cdrom drive */ 65607ca46eSDavid Howells #define CDROMEJECT 0x5309 /* Ejects the cdrom media */ 66607ca46eSDavid Howells #define CDROMVOLCTRL 0x530a /* Control output volume 67607ca46eSDavid Howells (struct cdrom_volctrl) */ 68607ca46eSDavid Howells #define CDROMSUBCHNL 0x530b /* Read subchannel data 69607ca46eSDavid Howells (struct cdrom_subchnl) */ 70607ca46eSDavid Howells #define CDROMREADMODE2 0x530c /* Read CDROM mode 2 data (2336 Bytes) 71607ca46eSDavid Howells (struct cdrom_read) */ 72607ca46eSDavid Howells #define CDROMREADMODE1 0x530d /* Read CDROM mode 1 data (2048 Bytes) 73607ca46eSDavid Howells (struct cdrom_read) */ 74607ca46eSDavid Howells #define CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */ 75607ca46eSDavid Howells #define CDROMEJECT_SW 0x530f /* enable(1)/disable(0) auto-ejecting */ 76607ca46eSDavid Howells #define CDROMMULTISESSION 0x5310 /* Obtain the start-of-last-session 77607ca46eSDavid Howells address of multi session disks 78607ca46eSDavid Howells (struct cdrom_multisession) */ 79607ca46eSDavid Howells #define CDROM_GET_MCN 0x5311 /* Obtain the "Universal Product Code" 80607ca46eSDavid Howells if available (struct cdrom_mcn) */ 81607ca46eSDavid Howells #define CDROM_GET_UPC CDROM_GET_MCN /* This one is deprecated, 82607ca46eSDavid Howells but here anyway for compatibility */ 83607ca46eSDavid Howells #define CDROMRESET 0x5312 /* hard-reset the drive */ 84607ca46eSDavid Howells #define CDROMVOLREAD 0x5313 /* Get the drive's volume setting 85607ca46eSDavid Howells (struct cdrom_volctrl) */ 86607ca46eSDavid Howells #define CDROMREADRAW 0x5314 /* read data in raw mode (2352 Bytes) 87607ca46eSDavid Howells (struct cdrom_read) */ 88607ca46eSDavid Howells /* 89607ca46eSDavid Howells * These ioctls are used only used in aztcd.c and optcd.c 90607ca46eSDavid Howells */ 91607ca46eSDavid Howells #define CDROMREADCOOKED 0x5315 /* read data in cooked mode */ 92607ca46eSDavid Howells #define CDROMSEEK 0x5316 /* seek msf address */ 93607ca46eSDavid Howells 94607ca46eSDavid Howells /* 95607ca46eSDavid Howells * This ioctl is only used by the scsi-cd driver. 96607ca46eSDavid Howells It is for playing audio in logical block addressing mode. 97607ca46eSDavid Howells */ 98607ca46eSDavid Howells #define CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */ 99607ca46eSDavid Howells 100607ca46eSDavid Howells /* 101607ca46eSDavid Howells * These ioctls are only used in optcd.c 102607ca46eSDavid Howells */ 103607ca46eSDavid Howells #define CDROMREADALL 0x5318 /* read all 2646 bytes */ 104607ca46eSDavid Howells 105607ca46eSDavid Howells /* 106*8fa10ee1SPaul Gortmaker * These ioctls were only in (now removed) ide-cd.c for controlling 107607ca46eSDavid Howells * drive spindown time. They should be implemented in the 108607ca46eSDavid Howells * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10, 109607ca46eSDavid Howells * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE... 110607ca46eSDavid Howells * -Erik 111607ca46eSDavid Howells */ 112607ca46eSDavid Howells #define CDROMGETSPINDOWN 0x531d 113607ca46eSDavid Howells #define CDROMSETSPINDOWN 0x531e 114607ca46eSDavid Howells 115607ca46eSDavid Howells /* 116607ca46eSDavid Howells * These ioctls are implemented through the uniform CD-ROM driver 117607ca46eSDavid Howells * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM 118607ca46eSDavid Howells * drivers are eventually ported to the uniform CD-ROM driver interface. 119607ca46eSDavid Howells */ 120607ca46eSDavid Howells #define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */ 121607ca46eSDavid Howells #define CDROM_SET_OPTIONS 0x5320 /* Set behavior options */ 122607ca46eSDavid Howells #define CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */ 123607ca46eSDavid Howells #define CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */ 124607ca46eSDavid Howells #define CDROM_SELECT_DISC 0x5323 /* Select disc (for juke-boxes) */ 125607ca46eSDavid Howells #define CDROM_MEDIA_CHANGED 0x5325 /* Check is media changed */ 126607ca46eSDavid Howells #define CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */ 127607ca46eSDavid Howells #define CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */ 128607ca46eSDavid Howells #define CDROM_CHANGER_NSLOTS 0x5328 /* Get number of slots */ 129607ca46eSDavid Howells #define CDROM_LOCKDOOR 0x5329 /* lock or unlock door */ 130607ca46eSDavid Howells #define CDROM_DEBUG 0x5330 /* Turn debug messages on/off */ 131607ca46eSDavid Howells #define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */ 132607ca46eSDavid Howells 133607ca46eSDavid Howells /* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386. 134607ca46eSDavid Howells * Future CDROM ioctls should be kept below 0x537F 135607ca46eSDavid Howells */ 136607ca46eSDavid Howells 137607ca46eSDavid Howells /* This ioctl is only used by sbpcd at the moment */ 138607ca46eSDavid Howells #define CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */ 139607ca46eSDavid Howells /* conflict with SCSI_IOCTL_GET_IDLUN */ 140607ca46eSDavid Howells 141607ca46eSDavid Howells /* DVD-ROM Specific ioctls */ 142607ca46eSDavid Howells #define DVD_READ_STRUCT 0x5390 /* Read structure */ 143607ca46eSDavid Howells #define DVD_WRITE_STRUCT 0x5391 /* Write structure */ 144607ca46eSDavid Howells #define DVD_AUTH 0x5392 /* Authentication */ 145607ca46eSDavid Howells 146607ca46eSDavid Howells #define CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */ 147607ca46eSDavid Howells #define CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */ 148607ca46eSDavid Howells #define CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */ 149607ca46eSDavid Howells 15067f1e027SLukas Prediger #define CDROM_TIMED_MEDIA_CHANGE 0x5396 /* get the timestamp of the last media change */ 15167f1e027SLukas Prediger 152607ca46eSDavid Howells /******************************************************* 153607ca46eSDavid Howells * CDROM IOCTL structures 154607ca46eSDavid Howells *******************************************************/ 155607ca46eSDavid Howells 156607ca46eSDavid Howells /* Address in MSF format */ 157607ca46eSDavid Howells struct cdrom_msf0 158607ca46eSDavid Howells { 159607ca46eSDavid Howells __u8 minute; 160607ca46eSDavid Howells __u8 second; 161607ca46eSDavid Howells __u8 frame; 162607ca46eSDavid Howells }; 163607ca46eSDavid Howells 164607ca46eSDavid Howells /* Address in either MSF or logical format */ 165607ca46eSDavid Howells union cdrom_addr 166607ca46eSDavid Howells { 167607ca46eSDavid Howells struct cdrom_msf0 msf; 168607ca46eSDavid Howells int lba; 169607ca46eSDavid Howells }; 170607ca46eSDavid Howells 171607ca46eSDavid Howells /* This struct is used by the CDROMPLAYMSF ioctl */ 172607ca46eSDavid Howells struct cdrom_msf 173607ca46eSDavid Howells { 174607ca46eSDavid Howells __u8 cdmsf_min0; /* start minute */ 175607ca46eSDavid Howells __u8 cdmsf_sec0; /* start second */ 176607ca46eSDavid Howells __u8 cdmsf_frame0; /* start frame */ 177607ca46eSDavid Howells __u8 cdmsf_min1; /* end minute */ 178607ca46eSDavid Howells __u8 cdmsf_sec1; /* end second */ 179607ca46eSDavid Howells __u8 cdmsf_frame1; /* end frame */ 180607ca46eSDavid Howells }; 181607ca46eSDavid Howells 182607ca46eSDavid Howells /* This struct is used by the CDROMPLAYTRKIND ioctl */ 183607ca46eSDavid Howells struct cdrom_ti 184607ca46eSDavid Howells { 185607ca46eSDavid Howells __u8 cdti_trk0; /* start track */ 186607ca46eSDavid Howells __u8 cdti_ind0; /* start index */ 187607ca46eSDavid Howells __u8 cdti_trk1; /* end track */ 188607ca46eSDavid Howells __u8 cdti_ind1; /* end index */ 189607ca46eSDavid Howells }; 190607ca46eSDavid Howells 191607ca46eSDavid Howells /* This struct is used by the CDROMREADTOCHDR ioctl */ 192607ca46eSDavid Howells struct cdrom_tochdr 193607ca46eSDavid Howells { 194607ca46eSDavid Howells __u8 cdth_trk0; /* start track */ 195607ca46eSDavid Howells __u8 cdth_trk1; /* end track */ 196607ca46eSDavid Howells }; 197607ca46eSDavid Howells 198607ca46eSDavid Howells /* This struct is used by the CDROMVOLCTRL and CDROMVOLREAD ioctls */ 199607ca46eSDavid Howells struct cdrom_volctrl 200607ca46eSDavid Howells { 201607ca46eSDavid Howells __u8 channel0; 202607ca46eSDavid Howells __u8 channel1; 203607ca46eSDavid Howells __u8 channel2; 204607ca46eSDavid Howells __u8 channel3; 205607ca46eSDavid Howells }; 206607ca46eSDavid Howells 207607ca46eSDavid Howells /* This struct is used by the CDROMSUBCHNL ioctl */ 208607ca46eSDavid Howells struct cdrom_subchnl 209607ca46eSDavid Howells { 210607ca46eSDavid Howells __u8 cdsc_format; 211607ca46eSDavid Howells __u8 cdsc_audiostatus; 212607ca46eSDavid Howells __u8 cdsc_adr: 4; 213607ca46eSDavid Howells __u8 cdsc_ctrl: 4; 214607ca46eSDavid Howells __u8 cdsc_trk; 215607ca46eSDavid Howells __u8 cdsc_ind; 216607ca46eSDavid Howells union cdrom_addr cdsc_absaddr; 217607ca46eSDavid Howells union cdrom_addr cdsc_reladdr; 218607ca46eSDavid Howells }; 219607ca46eSDavid Howells 220607ca46eSDavid Howells 221607ca46eSDavid Howells /* This struct is used by the CDROMREADTOCENTRY ioctl */ 222607ca46eSDavid Howells struct cdrom_tocentry 223607ca46eSDavid Howells { 224607ca46eSDavid Howells __u8 cdte_track; 225607ca46eSDavid Howells __u8 cdte_adr :4; 226607ca46eSDavid Howells __u8 cdte_ctrl :4; 227607ca46eSDavid Howells __u8 cdte_format; 228607ca46eSDavid Howells union cdrom_addr cdte_addr; 229607ca46eSDavid Howells __u8 cdte_datamode; 230607ca46eSDavid Howells }; 231607ca46eSDavid Howells 232607ca46eSDavid Howells /* This struct is used by the CDROMREADMODE1, and CDROMREADMODE2 ioctls */ 233607ca46eSDavid Howells struct cdrom_read 234607ca46eSDavid Howells { 235607ca46eSDavid Howells int cdread_lba; 236607ca46eSDavid Howells char *cdread_bufaddr; 237607ca46eSDavid Howells int cdread_buflen; 238607ca46eSDavid Howells }; 239607ca46eSDavid Howells 240607ca46eSDavid Howells /* This struct is used by the CDROMREADAUDIO ioctl */ 241607ca46eSDavid Howells struct cdrom_read_audio 242607ca46eSDavid Howells { 243607ca46eSDavid Howells union cdrom_addr addr; /* frame address */ 244607ca46eSDavid Howells __u8 addr_format; /* CDROM_LBA or CDROM_MSF */ 245607ca46eSDavid Howells int nframes; /* number of 2352-byte-frames to read at once */ 246607ca46eSDavid Howells __u8 __user *buf; /* frame buffer (size: nframes*2352 bytes) */ 247607ca46eSDavid Howells }; 248607ca46eSDavid Howells 249607ca46eSDavid Howells /* This struct is used with the CDROMMULTISESSION ioctl */ 250607ca46eSDavid Howells struct cdrom_multisession 251607ca46eSDavid Howells { 252607ca46eSDavid Howells union cdrom_addr addr; /* frame address: start-of-last-session 253607ca46eSDavid Howells (not the new "frame 16"!). Only valid 254607ca46eSDavid Howells if the "xa_flag" is true. */ 255607ca46eSDavid Howells __u8 xa_flag; /* 1: "is XA disk" */ 256607ca46eSDavid Howells __u8 addr_format; /* CDROM_LBA or CDROM_MSF */ 257607ca46eSDavid Howells }; 258607ca46eSDavid Howells 259607ca46eSDavid Howells /* This struct is used with the CDROM_GET_MCN ioctl. 260607ca46eSDavid Howells * Very few audio discs actually have Universal Product Code information, 261607ca46eSDavid Howells * which should just be the Medium Catalog Number on the box. Also note 262607ca46eSDavid Howells * that the way the codeis written on CD is _not_ uniform across all discs! 263607ca46eSDavid Howells */ 264607ca46eSDavid Howells struct cdrom_mcn 265607ca46eSDavid Howells { 266607ca46eSDavid Howells __u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */ 267607ca46eSDavid Howells }; 268607ca46eSDavid Howells 269607ca46eSDavid Howells /* This is used by the CDROMPLAYBLK ioctl */ 270607ca46eSDavid Howells struct cdrom_blk 271607ca46eSDavid Howells { 272607ca46eSDavid Howells unsigned from; 273607ca46eSDavid Howells unsigned short len; 274607ca46eSDavid Howells }; 275607ca46eSDavid Howells 276607ca46eSDavid Howells #define CDROM_PACKET_SIZE 12 277607ca46eSDavid Howells 278607ca46eSDavid Howells #define CGC_DATA_UNKNOWN 0 279607ca46eSDavid Howells #define CGC_DATA_WRITE 1 280607ca46eSDavid Howells #define CGC_DATA_READ 2 281607ca46eSDavid Howells #define CGC_DATA_NONE 3 282607ca46eSDavid Howells 283607ca46eSDavid Howells /* for CDROM_PACKET_COMMAND ioctl */ 284607ca46eSDavid Howells struct cdrom_generic_command 285607ca46eSDavid Howells { 286607ca46eSDavid Howells unsigned char cmd[CDROM_PACKET_SIZE]; 287607ca46eSDavid Howells unsigned char __user *buffer; 288607ca46eSDavid Howells unsigned int buflen; 289607ca46eSDavid Howells int stat; 290607ca46eSDavid Howells struct request_sense __user *sense; 291607ca46eSDavid Howells unsigned char data_direction; 292607ca46eSDavid Howells int quiet; 293607ca46eSDavid Howells int timeout; 294f5ace5efSGustavo A. R. Silva union { 295607ca46eSDavid Howells void __user *reserved[1]; /* unused, actually */ 296f5ace5efSGustavo A. R. Silva void __user *unused; 297f5ace5efSGustavo A. R. Silva }; 298607ca46eSDavid Howells }; 299607ca46eSDavid Howells 30067f1e027SLukas Prediger /* This struct is used by CDROM_TIMED_MEDIA_CHANGE */ 30167f1e027SLukas Prediger struct cdrom_timed_media_change_info { 30267f1e027SLukas Prediger __s64 last_media_change; /* Timestamp of the last detected media 30367f1e027SLukas Prediger * change in ms. May be set by caller, 30467f1e027SLukas Prediger * updated upon successful return of 30567f1e027SLukas Prediger * ioctl. 30667f1e027SLukas Prediger */ 30767f1e027SLukas Prediger __u64 media_flags; /* Flags returned by ioctl to indicate 30867f1e027SLukas Prediger * media status. 30967f1e027SLukas Prediger */ 31067f1e027SLukas Prediger }; 31167f1e027SLukas Prediger #define MEDIA_CHANGED_FLAG 0x1 /* Last detected media change was more 31267f1e027SLukas Prediger * recent than last_media_change set by 31367f1e027SLukas Prediger * caller. 31467f1e027SLukas Prediger */ 31567f1e027SLukas Prediger /* other bits of media_flags available for future use */ 31667f1e027SLukas Prediger 317607ca46eSDavid Howells /* 318607ca46eSDavid Howells * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336, 319607ca46eSDavid Howells * 2340, or 2352 bytes long. 320607ca46eSDavid Howells 321607ca46eSDavid Howells * Sector types of the standard CD-ROM data formats: 322607ca46eSDavid Howells * 323607ca46eSDavid Howells * format sector type user data size (bytes) 324607ca46eSDavid Howells * ----------------------------------------------------------------------------- 325607ca46eSDavid Howells * 1 (Red Book) CD-DA 2352 (CD_FRAMESIZE_RAW) 326607ca46eSDavid Howells * 2 (Yellow Book) Mode1 Form1 2048 (CD_FRAMESIZE) 327607ca46eSDavid Howells * 3 (Yellow Book) Mode1 Form2 2336 (CD_FRAMESIZE_RAW0) 328607ca46eSDavid Howells * 4 (Green Book) Mode2 Form1 2048 (CD_FRAMESIZE) 329607ca46eSDavid Howells * 5 (Green Book) Mode2 Form2 2328 (2324+4 spare bytes) 330607ca46eSDavid Howells * 331607ca46eSDavid Howells * 332607ca46eSDavid Howells * The layout of the standard CD-ROM data formats: 333607ca46eSDavid Howells * ----------------------------------------------------------------------------- 334607ca46eSDavid Howells * - audio (red): | audio_sample_bytes | 335607ca46eSDavid Howells * | 2352 | 336607ca46eSDavid Howells * 337607ca46eSDavid Howells * - data (yellow, mode1): | sync - head - data - EDC - zero - ECC | 338607ca46eSDavid Howells * | 12 - 4 - 2048 - 4 - 8 - 276 | 339607ca46eSDavid Howells * 340607ca46eSDavid Howells * - data (yellow, mode2): | sync - head - data | 341607ca46eSDavid Howells * | 12 - 4 - 2336 | 342607ca46eSDavid Howells * 343607ca46eSDavid Howells * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC | 344607ca46eSDavid Howells * | 12 - 4 - 8 - 2048 - 4 - 276 | 345607ca46eSDavid Howells * 346607ca46eSDavid Howells * - XA data (green, mode2 form2): | sync - head - sub - data - Spare | 347607ca46eSDavid Howells * | 12 - 4 - 8 - 2324 - 4 | 348607ca46eSDavid Howells * 349607ca46eSDavid Howells */ 350607ca46eSDavid Howells 351607ca46eSDavid Howells /* Some generally useful CD-ROM information -- mostly based on the above */ 352607ca46eSDavid Howells #define CD_MINS 74 /* max. minutes per CD, not really a limit */ 353607ca46eSDavid Howells #define CD_SECS 60 /* seconds per minute */ 354607ca46eSDavid Howells #define CD_FRAMES 75 /* frames per second */ 355607ca46eSDavid Howells #define CD_SYNC_SIZE 12 /* 12 sync bytes per raw data frame */ 356607ca46eSDavid Howells #define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */ 357607ca46eSDavid Howells #define CD_CHUNK_SIZE 24 /* lowest-level "data bytes piece" */ 358607ca46eSDavid Howells #define CD_NUM_OF_CHUNKS 98 /* chunks per frame */ 359607ca46eSDavid Howells #define CD_FRAMESIZE_SUB 96 /* subchannel data "frame" size */ 360607ca46eSDavid Howells #define CD_HEAD_SIZE 4 /* header (address) bytes per raw data frame */ 361607ca46eSDavid Howells #define CD_SUBHEAD_SIZE 8 /* subheader bytes per raw XA data frame */ 362607ca46eSDavid Howells #define CD_EDC_SIZE 4 /* bytes EDC per most raw data frame types */ 363607ca46eSDavid Howells #define CD_ZERO_SIZE 8 /* bytes zero per yellow book mode 1 frame */ 364607ca46eSDavid Howells #define CD_ECC_SIZE 276 /* bytes ECC per most raw data frame types */ 365607ca46eSDavid Howells #define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */ 366607ca46eSDavid Howells #define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */ 367607ca46eSDavid Howells #define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */ 368607ca46eSDavid Howells /* most drives don't deliver everything: */ 369607ca46eSDavid Howells #define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/ 370607ca46eSDavid Howells #define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/ 371607ca46eSDavid Howells 372607ca46eSDavid Howells #define CD_XA_HEAD (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */ 373607ca46eSDavid Howells #define CD_XA_TAIL (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */ 374607ca46eSDavid Howells #define CD_XA_SYNC_HEAD (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */ 375607ca46eSDavid Howells 376607ca46eSDavid Howells /* CD-ROM address types (cdrom_tocentry.cdte_format) */ 377607ca46eSDavid Howells #define CDROM_LBA 0x01 /* "logical block": first frame is #0 */ 378607ca46eSDavid Howells #define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */ 379607ca46eSDavid Howells 380607ca46eSDavid Howells /* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */ 381607ca46eSDavid Howells #define CDROM_DATA_TRACK 0x04 382607ca46eSDavid Howells 383607ca46eSDavid Howells /* The leadout track is always 0xAA, regardless of # of tracks on disc */ 384607ca46eSDavid Howells #define CDROM_LEADOUT 0xAA 385607ca46eSDavid Howells 386607ca46eSDavid Howells /* audio states (from SCSI-2, but seen with other drives, too) */ 387607ca46eSDavid Howells #define CDROM_AUDIO_INVALID 0x00 /* audio status not supported */ 388607ca46eSDavid Howells #define CDROM_AUDIO_PLAY 0x11 /* audio play operation in progress */ 389607ca46eSDavid Howells #define CDROM_AUDIO_PAUSED 0x12 /* audio play operation paused */ 390607ca46eSDavid Howells #define CDROM_AUDIO_COMPLETED 0x13 /* audio play successfully completed */ 391607ca46eSDavid Howells #define CDROM_AUDIO_ERROR 0x14 /* audio play stopped due to error */ 392607ca46eSDavid Howells #define CDROM_AUDIO_NO_STATUS 0x15 /* no current audio status to return */ 393607ca46eSDavid Howells 394607ca46eSDavid Howells /* capability flags used with the uniform CD-ROM driver */ 395607ca46eSDavid Howells #define CDC_CLOSE_TRAY 0x1 /* caddy systems _can't_ close */ 396607ca46eSDavid Howells #define CDC_OPEN_TRAY 0x2 /* but _can_ eject. */ 397607ca46eSDavid Howells #define CDC_LOCK 0x4 /* disable manual eject */ 398607ca46eSDavid Howells #define CDC_SELECT_SPEED 0x8 /* programmable speed */ 399607ca46eSDavid Howells #define CDC_SELECT_DISC 0x10 /* select disc from juke-box */ 400607ca46eSDavid Howells #define CDC_MULTI_SESSION 0x20 /* read sessions>1 */ 401607ca46eSDavid Howells #define CDC_MCN 0x40 /* Medium Catalog Number */ 402607ca46eSDavid Howells #define CDC_MEDIA_CHANGED 0x80 /* media changed */ 403607ca46eSDavid Howells #define CDC_PLAY_AUDIO 0x100 /* audio functions */ 404607ca46eSDavid Howells #define CDC_RESET 0x200 /* hard reset device */ 405607ca46eSDavid Howells #define CDC_DRIVE_STATUS 0x800 /* driver implements drive status */ 406607ca46eSDavid Howells #define CDC_GENERIC_PACKET 0x1000 /* driver implements generic packets */ 407607ca46eSDavid Howells #define CDC_CD_R 0x2000 /* drive is a CD-R */ 408607ca46eSDavid Howells #define CDC_CD_RW 0x4000 /* drive is a CD-RW */ 409607ca46eSDavid Howells #define CDC_DVD 0x8000 /* drive is a DVD */ 410607ca46eSDavid Howells #define CDC_DVD_R 0x10000 /* drive can write DVD-R */ 411607ca46eSDavid Howells #define CDC_DVD_RAM 0x20000 /* drive can write DVD-RAM */ 412607ca46eSDavid Howells #define CDC_MO_DRIVE 0x40000 /* drive is an MO device */ 413607ca46eSDavid Howells #define CDC_MRW 0x80000 /* drive can read MRW */ 414607ca46eSDavid Howells #define CDC_MRW_W 0x100000 /* drive can write MRW */ 415607ca46eSDavid Howells #define CDC_RAM 0x200000 /* ok to open for WRITE */ 416607ca46eSDavid Howells 417607ca46eSDavid Howells /* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */ 418607ca46eSDavid Howells #define CDS_NO_INFO 0 /* if not implemented */ 419607ca46eSDavid Howells #define CDS_NO_DISC 1 420607ca46eSDavid Howells #define CDS_TRAY_OPEN 2 421607ca46eSDavid Howells #define CDS_DRIVE_NOT_READY 3 422607ca46eSDavid Howells #define CDS_DISC_OK 4 423607ca46eSDavid Howells 424607ca46eSDavid Howells /* return values for the CDROM_DISC_STATUS ioctl */ 425607ca46eSDavid Howells /* can also return CDS_NO_[INFO|DISC], from above */ 426607ca46eSDavid Howells #define CDS_AUDIO 100 427607ca46eSDavid Howells #define CDS_DATA_1 101 428607ca46eSDavid Howells #define CDS_DATA_2 102 429607ca46eSDavid Howells #define CDS_XA_2_1 103 430607ca46eSDavid Howells #define CDS_XA_2_2 104 431607ca46eSDavid Howells #define CDS_MIXED 105 432607ca46eSDavid Howells 433607ca46eSDavid Howells /* User-configurable behavior options for the uniform CD-ROM driver */ 434607ca46eSDavid Howells #define CDO_AUTO_CLOSE 0x1 /* close tray on first open() */ 435607ca46eSDavid Howells #define CDO_AUTO_EJECT 0x2 /* open tray on last release() */ 436607ca46eSDavid Howells #define CDO_USE_FFLAGS 0x4 /* use O_NONBLOCK information on open */ 437607ca46eSDavid Howells #define CDO_LOCK 0x8 /* lock tray on open files */ 438607ca46eSDavid Howells #define CDO_CHECK_TYPE 0x10 /* check type on open for data */ 439607ca46eSDavid Howells 440607ca46eSDavid Howells /* Special codes used when specifying changer slots. */ 441607ca46eSDavid Howells #define CDSL_NONE (INT_MAX-1) 442607ca46eSDavid Howells #define CDSL_CURRENT INT_MAX 443607ca46eSDavid Howells 444607ca46eSDavid Howells /* For partition based multisession access. IDE can handle 64 partitions 445607ca46eSDavid Howells * per drive - SCSI CD-ROM's use minors to differentiate between the 446607ca46eSDavid Howells * various drives, so we can't do multisessions the same way there. 447607ca46eSDavid Howells * Use the -o session=x option to mount on them. 448607ca46eSDavid Howells */ 449607ca46eSDavid Howells #define CD_PART_MAX 64 450607ca46eSDavid Howells #define CD_PART_MASK (CD_PART_MAX - 1) 451607ca46eSDavid Howells 452607ca46eSDavid Howells /********************************************************************* 453607ca46eSDavid Howells * Generic Packet commands, MMC commands, and such 454607ca46eSDavid Howells *********************************************************************/ 455607ca46eSDavid Howells 456607ca46eSDavid Howells /* The generic packet command opcodes for CD/DVD Logical Units, 457607ca46eSDavid Howells * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ 458607ca46eSDavid Howells #define GPCMD_BLANK 0xa1 459607ca46eSDavid Howells #define GPCMD_CLOSE_TRACK 0x5b 460607ca46eSDavid Howells #define GPCMD_FLUSH_CACHE 0x35 461607ca46eSDavid Howells #define GPCMD_FORMAT_UNIT 0x04 462607ca46eSDavid Howells #define GPCMD_GET_CONFIGURATION 0x46 463607ca46eSDavid Howells #define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a 464607ca46eSDavid Howells #define GPCMD_GET_PERFORMANCE 0xac 465607ca46eSDavid Howells #define GPCMD_INQUIRY 0x12 466607ca46eSDavid Howells #define GPCMD_LOAD_UNLOAD 0xa6 467607ca46eSDavid Howells #define GPCMD_MECHANISM_STATUS 0xbd 468607ca46eSDavid Howells #define GPCMD_MODE_SELECT_10 0x55 469607ca46eSDavid Howells #define GPCMD_MODE_SENSE_10 0x5a 470607ca46eSDavid Howells #define GPCMD_PAUSE_RESUME 0x4b 471607ca46eSDavid Howells #define GPCMD_PLAY_AUDIO_10 0x45 472607ca46eSDavid Howells #define GPCMD_PLAY_AUDIO_MSF 0x47 473607ca46eSDavid Howells #define GPCMD_PLAY_AUDIO_TI 0x48 474607ca46eSDavid Howells #define GPCMD_PLAY_CD 0xbc 475607ca46eSDavid Howells #define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e 476607ca46eSDavid Howells #define GPCMD_READ_10 0x28 477607ca46eSDavid Howells #define GPCMD_READ_12 0xa8 478607ca46eSDavid Howells #define GPCMD_READ_BUFFER 0x3c 479607ca46eSDavid Howells #define GPCMD_READ_BUFFER_CAPACITY 0x5c 480607ca46eSDavid Howells #define GPCMD_READ_CDVD_CAPACITY 0x25 481607ca46eSDavid Howells #define GPCMD_READ_CD 0xbe 482607ca46eSDavid Howells #define GPCMD_READ_CD_MSF 0xb9 483607ca46eSDavid Howells #define GPCMD_READ_DISC_INFO 0x51 484607ca46eSDavid Howells #define GPCMD_READ_DVD_STRUCTURE 0xad 485607ca46eSDavid Howells #define GPCMD_READ_FORMAT_CAPACITIES 0x23 486607ca46eSDavid Howells #define GPCMD_READ_HEADER 0x44 487607ca46eSDavid Howells #define GPCMD_READ_TRACK_RZONE_INFO 0x52 488607ca46eSDavid Howells #define GPCMD_READ_SUBCHANNEL 0x42 489607ca46eSDavid Howells #define GPCMD_READ_TOC_PMA_ATIP 0x43 490607ca46eSDavid Howells #define GPCMD_REPAIR_RZONE_TRACK 0x58 491607ca46eSDavid Howells #define GPCMD_REPORT_KEY 0xa4 492607ca46eSDavid Howells #define GPCMD_REQUEST_SENSE 0x03 493607ca46eSDavid Howells #define GPCMD_RESERVE_RZONE_TRACK 0x53 494607ca46eSDavid Howells #define GPCMD_SEND_CUE_SHEET 0x5d 495607ca46eSDavid Howells #define GPCMD_SCAN 0xba 496607ca46eSDavid Howells #define GPCMD_SEEK 0x2b 497607ca46eSDavid Howells #define GPCMD_SEND_DVD_STRUCTURE 0xbf 498607ca46eSDavid Howells #define GPCMD_SEND_EVENT 0xa2 499607ca46eSDavid Howells #define GPCMD_SEND_KEY 0xa3 500607ca46eSDavid Howells #define GPCMD_SEND_OPC 0x54 501607ca46eSDavid Howells #define GPCMD_SET_READ_AHEAD 0xa7 502607ca46eSDavid Howells #define GPCMD_SET_STREAMING 0xb6 503607ca46eSDavid Howells #define GPCMD_START_STOP_UNIT 0x1b 504607ca46eSDavid Howells #define GPCMD_STOP_PLAY_SCAN 0x4e 505607ca46eSDavid Howells #define GPCMD_TEST_UNIT_READY 0x00 506607ca46eSDavid Howells #define GPCMD_VERIFY_10 0x2f 507607ca46eSDavid Howells #define GPCMD_WRITE_10 0x2a 508607ca46eSDavid Howells #define GPCMD_WRITE_12 0xaa 509607ca46eSDavid Howells #define GPCMD_WRITE_AND_VERIFY_10 0x2e 510607ca46eSDavid Howells #define GPCMD_WRITE_BUFFER 0x3b 511607ca46eSDavid Howells /* This is listed as optional in ATAPI 2.6, but is (curiously) 512607ca46eSDavid Howells * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji 513607ca46eSDavid Howells * Table 377 as an MMC command for SCSi devices though... Most ATAPI 514607ca46eSDavid Howells * drives support it. */ 515607ca46eSDavid Howells #define GPCMD_SET_SPEED 0xbb 516607ca46eSDavid Howells /* This seems to be a SCSI specific CD-ROM opcode 517607ca46eSDavid Howells * to play data at track/index */ 518607ca46eSDavid Howells #define GPCMD_PLAYAUDIO_TI 0x48 519607ca46eSDavid Howells /* 520607ca46eSDavid Howells * From MS Media Status Notification Support Specification. For 521607ca46eSDavid Howells * older drives only. 522607ca46eSDavid Howells */ 523607ca46eSDavid Howells #define GPCMD_GET_MEDIA_STATUS 0xda 524607ca46eSDavid Howells 525607ca46eSDavid Howells /* Mode page codes for mode sense/set */ 526607ca46eSDavid Howells #define GPMODE_VENDOR_PAGE 0x00 527607ca46eSDavid Howells #define GPMODE_R_W_ERROR_PAGE 0x01 528607ca46eSDavid Howells #define GPMODE_WRITE_PARMS_PAGE 0x05 529607ca46eSDavid Howells #define GPMODE_WCACHING_PAGE 0x08 530607ca46eSDavid Howells #define GPMODE_AUDIO_CTL_PAGE 0x0e 531607ca46eSDavid Howells #define GPMODE_POWER_PAGE 0x1a 532607ca46eSDavid Howells #define GPMODE_FAULT_FAIL_PAGE 0x1c 533607ca46eSDavid Howells #define GPMODE_TO_PROTECT_PAGE 0x1d 534607ca46eSDavid Howells #define GPMODE_CAPABILITIES_PAGE 0x2a 535607ca46eSDavid Howells #define GPMODE_ALL_PAGES 0x3f 536607ca46eSDavid Howells /* Not in Mt. Fuji, but in ATAPI 2.6 -- deprecated now in favor 537607ca46eSDavid Howells * of MODE_SENSE_POWER_PAGE */ 538607ca46eSDavid Howells #define GPMODE_CDROM_PAGE 0x0d 539607ca46eSDavid Howells 540607ca46eSDavid Howells 541607ca46eSDavid Howells 542607ca46eSDavid Howells /* DVD struct types */ 543607ca46eSDavid Howells #define DVD_STRUCT_PHYSICAL 0x00 544607ca46eSDavid Howells #define DVD_STRUCT_COPYRIGHT 0x01 545607ca46eSDavid Howells #define DVD_STRUCT_DISCKEY 0x02 546607ca46eSDavid Howells #define DVD_STRUCT_BCA 0x03 547607ca46eSDavid Howells #define DVD_STRUCT_MANUFACT 0x04 548607ca46eSDavid Howells 549607ca46eSDavid Howells struct dvd_layer { 550607ca46eSDavid Howells __u8 book_version : 4; 551607ca46eSDavid Howells __u8 book_type : 4; 552607ca46eSDavid Howells __u8 min_rate : 4; 553607ca46eSDavid Howells __u8 disc_size : 4; 554607ca46eSDavid Howells __u8 layer_type : 4; 555607ca46eSDavid Howells __u8 track_path : 1; 556607ca46eSDavid Howells __u8 nlayers : 2; 557607ca46eSDavid Howells __u8 track_density : 4; 558607ca46eSDavid Howells __u8 linear_density : 4; 559607ca46eSDavid Howells __u8 bca : 1; 560607ca46eSDavid Howells __u32 start_sector; 561607ca46eSDavid Howells __u32 end_sector; 562607ca46eSDavid Howells __u32 end_sector_l0; 563607ca46eSDavid Howells }; 564607ca46eSDavid Howells 565607ca46eSDavid Howells #define DVD_LAYERS 4 566607ca46eSDavid Howells 567607ca46eSDavid Howells struct dvd_physical { 568607ca46eSDavid Howells __u8 type; 569607ca46eSDavid Howells __u8 layer_num; 570607ca46eSDavid Howells struct dvd_layer layer[DVD_LAYERS]; 571607ca46eSDavid Howells }; 572607ca46eSDavid Howells 573607ca46eSDavid Howells struct dvd_copyright { 574607ca46eSDavid Howells __u8 type; 575607ca46eSDavid Howells 576607ca46eSDavid Howells __u8 layer_num; 577607ca46eSDavid Howells __u8 cpst; 578607ca46eSDavid Howells __u8 rmi; 579607ca46eSDavid Howells }; 580607ca46eSDavid Howells 581607ca46eSDavid Howells struct dvd_disckey { 582607ca46eSDavid Howells __u8 type; 583607ca46eSDavid Howells 584607ca46eSDavid Howells unsigned agid : 2; 585607ca46eSDavid Howells __u8 value[2048]; 586607ca46eSDavid Howells }; 587607ca46eSDavid Howells 588607ca46eSDavid Howells struct dvd_bca { 589607ca46eSDavid Howells __u8 type; 590607ca46eSDavid Howells 591607ca46eSDavid Howells int len; 592607ca46eSDavid Howells __u8 value[188]; 593607ca46eSDavid Howells }; 594607ca46eSDavid Howells 595607ca46eSDavid Howells struct dvd_manufact { 596607ca46eSDavid Howells __u8 type; 597607ca46eSDavid Howells 598607ca46eSDavid Howells __u8 layer_num; 599607ca46eSDavid Howells int len; 600607ca46eSDavid Howells __u8 value[2048]; 601607ca46eSDavid Howells }; 602607ca46eSDavid Howells 603607ca46eSDavid Howells typedef union { 604607ca46eSDavid Howells __u8 type; 605607ca46eSDavid Howells 606607ca46eSDavid Howells struct dvd_physical physical; 607607ca46eSDavid Howells struct dvd_copyright copyright; 608607ca46eSDavid Howells struct dvd_disckey disckey; 609607ca46eSDavid Howells struct dvd_bca bca; 610607ca46eSDavid Howells struct dvd_manufact manufact; 611607ca46eSDavid Howells } dvd_struct; 612607ca46eSDavid Howells 613607ca46eSDavid Howells /* 614607ca46eSDavid Howells * DVD authentication ioctl 615607ca46eSDavid Howells */ 616607ca46eSDavid Howells 617607ca46eSDavid Howells /* Authentication states */ 618607ca46eSDavid Howells #define DVD_LU_SEND_AGID 0 619607ca46eSDavid Howells #define DVD_HOST_SEND_CHALLENGE 1 620607ca46eSDavid Howells #define DVD_LU_SEND_KEY1 2 621607ca46eSDavid Howells #define DVD_LU_SEND_CHALLENGE 3 622607ca46eSDavid Howells #define DVD_HOST_SEND_KEY2 4 623607ca46eSDavid Howells 624607ca46eSDavid Howells /* Termination states */ 625607ca46eSDavid Howells #define DVD_AUTH_ESTABLISHED 5 626607ca46eSDavid Howells #define DVD_AUTH_FAILURE 6 627607ca46eSDavid Howells 628607ca46eSDavid Howells /* Other functions */ 629607ca46eSDavid Howells #define DVD_LU_SEND_TITLE_KEY 7 630607ca46eSDavid Howells #define DVD_LU_SEND_ASF 8 631607ca46eSDavid Howells #define DVD_INVALIDATE_AGID 9 632607ca46eSDavid Howells #define DVD_LU_SEND_RPC_STATE 10 633607ca46eSDavid Howells #define DVD_HOST_SEND_RPC_STATE 11 634607ca46eSDavid Howells 635607ca46eSDavid Howells /* State data */ 636607ca46eSDavid Howells typedef __u8 dvd_key[5]; /* 40-bit value, MSB is first elem. */ 637607ca46eSDavid Howells typedef __u8 dvd_challenge[10]; /* 80-bit value, MSB is first elem. */ 638607ca46eSDavid Howells 639607ca46eSDavid Howells struct dvd_lu_send_agid { 640607ca46eSDavid Howells __u8 type; 641607ca46eSDavid Howells unsigned agid : 2; 642607ca46eSDavid Howells }; 643607ca46eSDavid Howells 644607ca46eSDavid Howells struct dvd_host_send_challenge { 645607ca46eSDavid Howells __u8 type; 646607ca46eSDavid Howells unsigned agid : 2; 647607ca46eSDavid Howells 648607ca46eSDavid Howells dvd_challenge chal; 649607ca46eSDavid Howells }; 650607ca46eSDavid Howells 651607ca46eSDavid Howells struct dvd_send_key { 652607ca46eSDavid Howells __u8 type; 653607ca46eSDavid Howells unsigned agid : 2; 654607ca46eSDavid Howells 655607ca46eSDavid Howells dvd_key key; 656607ca46eSDavid Howells }; 657607ca46eSDavid Howells 658607ca46eSDavid Howells struct dvd_lu_send_challenge { 659607ca46eSDavid Howells __u8 type; 660607ca46eSDavid Howells unsigned agid : 2; 661607ca46eSDavid Howells 662607ca46eSDavid Howells dvd_challenge chal; 663607ca46eSDavid Howells }; 664607ca46eSDavid Howells 665607ca46eSDavid Howells #define DVD_CPM_NO_COPYRIGHT 0 666607ca46eSDavid Howells #define DVD_CPM_COPYRIGHTED 1 667607ca46eSDavid Howells 668607ca46eSDavid Howells #define DVD_CP_SEC_NONE 0 669607ca46eSDavid Howells #define DVD_CP_SEC_EXIST 1 670607ca46eSDavid Howells 671607ca46eSDavid Howells #define DVD_CGMS_UNRESTRICTED 0 672607ca46eSDavid Howells #define DVD_CGMS_SINGLE 2 673607ca46eSDavid Howells #define DVD_CGMS_RESTRICTED 3 674607ca46eSDavid Howells 675607ca46eSDavid Howells struct dvd_lu_send_title_key { 676607ca46eSDavid Howells __u8 type; 677607ca46eSDavid Howells unsigned agid : 2; 678607ca46eSDavid Howells 679607ca46eSDavid Howells dvd_key title_key; 680607ca46eSDavid Howells int lba; 681607ca46eSDavid Howells unsigned cpm : 1; 682607ca46eSDavid Howells unsigned cp_sec : 1; 683607ca46eSDavid Howells unsigned cgms : 2; 684607ca46eSDavid Howells }; 685607ca46eSDavid Howells 686607ca46eSDavid Howells struct dvd_lu_send_asf { 687607ca46eSDavid Howells __u8 type; 688607ca46eSDavid Howells unsigned agid : 2; 689607ca46eSDavid Howells 690607ca46eSDavid Howells unsigned asf : 1; 691607ca46eSDavid Howells }; 692607ca46eSDavid Howells 693607ca46eSDavid Howells struct dvd_host_send_rpcstate { 694607ca46eSDavid Howells __u8 type; 695607ca46eSDavid Howells __u8 pdrc; 696607ca46eSDavid Howells }; 697607ca46eSDavid Howells 698607ca46eSDavid Howells struct dvd_lu_send_rpcstate { 699607ca46eSDavid Howells __u8 type : 2; 700607ca46eSDavid Howells __u8 vra : 3; 701607ca46eSDavid Howells __u8 ucca : 3; 702607ca46eSDavid Howells __u8 region_mask; 703607ca46eSDavid Howells __u8 rpc_scheme; 704607ca46eSDavid Howells }; 705607ca46eSDavid Howells 706607ca46eSDavid Howells typedef union { 707607ca46eSDavid Howells __u8 type; 708607ca46eSDavid Howells 709607ca46eSDavid Howells struct dvd_lu_send_agid lsa; 710607ca46eSDavid Howells struct dvd_host_send_challenge hsc; 711607ca46eSDavid Howells struct dvd_send_key lsk; 712607ca46eSDavid Howells struct dvd_lu_send_challenge lsc; 713607ca46eSDavid Howells struct dvd_send_key hsk; 714607ca46eSDavid Howells struct dvd_lu_send_title_key lstk; 715607ca46eSDavid Howells struct dvd_lu_send_asf lsasf; 716607ca46eSDavid Howells struct dvd_host_send_rpcstate hrpcs; 717607ca46eSDavid Howells struct dvd_lu_send_rpcstate lrpcs; 718607ca46eSDavid Howells } dvd_authinfo; 719607ca46eSDavid Howells 720607ca46eSDavid Howells struct request_sense { 721607ca46eSDavid Howells #if defined(__BIG_ENDIAN_BITFIELD) 722607ca46eSDavid Howells __u8 valid : 1; 723607ca46eSDavid Howells __u8 error_code : 7; 724607ca46eSDavid Howells #elif defined(__LITTLE_ENDIAN_BITFIELD) 725607ca46eSDavid Howells __u8 error_code : 7; 726607ca46eSDavid Howells __u8 valid : 1; 727607ca46eSDavid Howells #endif 728607ca46eSDavid Howells __u8 segment_number; 729607ca46eSDavid Howells #if defined(__BIG_ENDIAN_BITFIELD) 730607ca46eSDavid Howells __u8 reserved1 : 2; 731607ca46eSDavid Howells __u8 ili : 1; 732607ca46eSDavid Howells __u8 reserved2 : 1; 733607ca46eSDavid Howells __u8 sense_key : 4; 734607ca46eSDavid Howells #elif defined(__LITTLE_ENDIAN_BITFIELD) 735607ca46eSDavid Howells __u8 sense_key : 4; 736607ca46eSDavid Howells __u8 reserved2 : 1; 737607ca46eSDavid Howells __u8 ili : 1; 738607ca46eSDavid Howells __u8 reserved1 : 2; 739607ca46eSDavid Howells #endif 740607ca46eSDavid Howells __u8 information[4]; 741607ca46eSDavid Howells __u8 add_sense_len; 742607ca46eSDavid Howells __u8 command_info[4]; 743607ca46eSDavid Howells __u8 asc; 744607ca46eSDavid Howells __u8 ascq; 745607ca46eSDavid Howells __u8 fruc; 746607ca46eSDavid Howells __u8 sks[3]; 747607ca46eSDavid Howells __u8 asb[46]; 748607ca46eSDavid Howells }; 749607ca46eSDavid Howells 750607ca46eSDavid Howells /* 751607ca46eSDavid Howells * feature profile 752607ca46eSDavid Howells */ 753607ca46eSDavid Howells #define CDF_RWRT 0x0020 /* "Random Writable" */ 754607ca46eSDavid Howells #define CDF_HWDM 0x0024 /* "Hardware Defect Management" */ 755607ca46eSDavid Howells #define CDF_MRW 0x0028 756607ca46eSDavid Howells 757607ca46eSDavid Howells /* 758607ca46eSDavid Howells * media status bits 759607ca46eSDavid Howells */ 760607ca46eSDavid Howells #define CDM_MRW_NOTMRW 0 761607ca46eSDavid Howells #define CDM_MRW_BGFORMAT_INACTIVE 1 762607ca46eSDavid Howells #define CDM_MRW_BGFORMAT_ACTIVE 2 763607ca46eSDavid Howells #define CDM_MRW_BGFORMAT_COMPLETE 3 764607ca46eSDavid Howells 765607ca46eSDavid Howells /* 766607ca46eSDavid Howells * mrw address spaces 767607ca46eSDavid Howells */ 768607ca46eSDavid Howells #define MRW_LBA_DMA 0 769607ca46eSDavid Howells #define MRW_LBA_GAA 1 770607ca46eSDavid Howells 771607ca46eSDavid Howells /* 772607ca46eSDavid Howells * mrw mode pages (first is deprecated) -- probed at init time and 773607ca46eSDavid Howells * cdi->mrw_mode_page is set 774607ca46eSDavid Howells */ 775607ca46eSDavid Howells #define MRW_MODE_PC_PRE1 0x2c 776607ca46eSDavid Howells #define MRW_MODE_PC 0x03 777607ca46eSDavid Howells 778607ca46eSDavid Howells struct mrw_feature_desc { 779607ca46eSDavid Howells __be16 feature_code; 780607ca46eSDavid Howells #if defined(__BIG_ENDIAN_BITFIELD) 781607ca46eSDavid Howells __u8 reserved1 : 2; 782607ca46eSDavid Howells __u8 feature_version : 4; 783607ca46eSDavid Howells __u8 persistent : 1; 784607ca46eSDavid Howells __u8 curr : 1; 785607ca46eSDavid Howells #elif defined(__LITTLE_ENDIAN_BITFIELD) 786607ca46eSDavid Howells __u8 curr : 1; 787607ca46eSDavid Howells __u8 persistent : 1; 788607ca46eSDavid Howells __u8 feature_version : 4; 789607ca46eSDavid Howells __u8 reserved1 : 2; 790607ca46eSDavid Howells #endif 791607ca46eSDavid Howells __u8 add_len; 792607ca46eSDavid Howells #if defined(__BIG_ENDIAN_BITFIELD) 793607ca46eSDavid Howells __u8 reserved2 : 7; 794607ca46eSDavid Howells __u8 write : 1; 795607ca46eSDavid Howells #elif defined(__LITTLE_ENDIAN_BITFIELD) 796607ca46eSDavid Howells __u8 write : 1; 797607ca46eSDavid Howells __u8 reserved2 : 7; 798607ca46eSDavid Howells #endif 799607ca46eSDavid Howells __u8 reserved3; 800607ca46eSDavid Howells __u8 reserved4; 801607ca46eSDavid Howells __u8 reserved5; 802607ca46eSDavid Howells }; 803607ca46eSDavid Howells 804607ca46eSDavid Howells /* cf. mmc4r02g.pdf 5.3.10 Random Writable Feature (0020h) pg 197 of 635 */ 805607ca46eSDavid Howells struct rwrt_feature_desc { 806607ca46eSDavid Howells __be16 feature_code; 807607ca46eSDavid Howells #if defined(__BIG_ENDIAN_BITFIELD) 808607ca46eSDavid Howells __u8 reserved1 : 2; 809607ca46eSDavid Howells __u8 feature_version : 4; 810607ca46eSDavid Howells __u8 persistent : 1; 811607ca46eSDavid Howells __u8 curr : 1; 812607ca46eSDavid Howells #elif defined(__LITTLE_ENDIAN_BITFIELD) 813607ca46eSDavid Howells __u8 curr : 1; 814607ca46eSDavid Howells __u8 persistent : 1; 815607ca46eSDavid Howells __u8 feature_version : 4; 816607ca46eSDavid Howells __u8 reserved1 : 2; 817607ca46eSDavid Howells #endif 818607ca46eSDavid Howells __u8 add_len; 819607ca46eSDavid Howells __u32 last_lba; 820607ca46eSDavid Howells __u32 block_size; 821607ca46eSDavid Howells __u16 blocking; 822607ca46eSDavid Howells #if defined(__BIG_ENDIAN_BITFIELD) 823607ca46eSDavid Howells __u8 reserved2 : 7; 824607ca46eSDavid Howells __u8 page_present : 1; 825607ca46eSDavid Howells #elif defined(__LITTLE_ENDIAN_BITFIELD) 826607ca46eSDavid Howells __u8 page_present : 1; 827607ca46eSDavid Howells __u8 reserved2 : 7; 828607ca46eSDavid Howells #endif 829607ca46eSDavid Howells __u8 reserved3; 830607ca46eSDavid Howells }; 831607ca46eSDavid Howells 832607ca46eSDavid Howells typedef struct { 833607ca46eSDavid Howells __be16 disc_information_length; 834607ca46eSDavid Howells #if defined(__BIG_ENDIAN_BITFIELD) 835607ca46eSDavid Howells __u8 reserved1 : 3; 836607ca46eSDavid Howells __u8 erasable : 1; 837607ca46eSDavid Howells __u8 border_status : 2; 838607ca46eSDavid Howells __u8 disc_status : 2; 839607ca46eSDavid Howells #elif defined(__LITTLE_ENDIAN_BITFIELD) 840607ca46eSDavid Howells __u8 disc_status : 2; 841607ca46eSDavid Howells __u8 border_status : 2; 842607ca46eSDavid Howells __u8 erasable : 1; 843607ca46eSDavid Howells __u8 reserved1 : 3; 844607ca46eSDavid Howells #else 845607ca46eSDavid Howells #error "Please fix <asm/byteorder.h>" 846607ca46eSDavid Howells #endif 847607ca46eSDavid Howells __u8 n_first_track; 848607ca46eSDavid Howells __u8 n_sessions_lsb; 849607ca46eSDavid Howells __u8 first_track_lsb; 850607ca46eSDavid Howells __u8 last_track_lsb; 851607ca46eSDavid Howells #if defined(__BIG_ENDIAN_BITFIELD) 852607ca46eSDavid Howells __u8 did_v : 1; 853607ca46eSDavid Howells __u8 dbc_v : 1; 854607ca46eSDavid Howells __u8 uru : 1; 855607ca46eSDavid Howells __u8 reserved2 : 2; 856607ca46eSDavid Howells __u8 dbit : 1; 857607ca46eSDavid Howells __u8 mrw_status : 2; 858607ca46eSDavid Howells #elif defined(__LITTLE_ENDIAN_BITFIELD) 859607ca46eSDavid Howells __u8 mrw_status : 2; 860607ca46eSDavid Howells __u8 dbit : 1; 861607ca46eSDavid Howells __u8 reserved2 : 2; 862607ca46eSDavid Howells __u8 uru : 1; 863607ca46eSDavid Howells __u8 dbc_v : 1; 864607ca46eSDavid Howells __u8 did_v : 1; 865607ca46eSDavid Howells #endif 866607ca46eSDavid Howells __u8 disc_type; 867607ca46eSDavid Howells __u8 n_sessions_msb; 868607ca46eSDavid Howells __u8 first_track_msb; 869607ca46eSDavid Howells __u8 last_track_msb; 870607ca46eSDavid Howells __u32 disc_id; 871607ca46eSDavid Howells __u32 lead_in; 872607ca46eSDavid Howells __u32 lead_out; 873607ca46eSDavid Howells __u8 disc_bar_code[8]; 874607ca46eSDavid Howells __u8 reserved3; 875607ca46eSDavid Howells __u8 n_opc; 876607ca46eSDavid Howells } disc_information; 877607ca46eSDavid Howells 878607ca46eSDavid Howells typedef struct { 879607ca46eSDavid Howells __be16 track_information_length; 880607ca46eSDavid Howells __u8 track_lsb; 881607ca46eSDavid Howells __u8 session_lsb; 882607ca46eSDavid Howells __u8 reserved1; 883607ca46eSDavid Howells #if defined(__BIG_ENDIAN_BITFIELD) 884607ca46eSDavid Howells __u8 reserved2 : 2; 885607ca46eSDavid Howells __u8 damage : 1; 886607ca46eSDavid Howells __u8 copy : 1; 887607ca46eSDavid Howells __u8 track_mode : 4; 888607ca46eSDavid Howells __u8 rt : 1; 889607ca46eSDavid Howells __u8 blank : 1; 890607ca46eSDavid Howells __u8 packet : 1; 891607ca46eSDavid Howells __u8 fp : 1; 892607ca46eSDavid Howells __u8 data_mode : 4; 893607ca46eSDavid Howells __u8 reserved3 : 6; 894607ca46eSDavid Howells __u8 lra_v : 1; 895607ca46eSDavid Howells __u8 nwa_v : 1; 896607ca46eSDavid Howells #elif defined(__LITTLE_ENDIAN_BITFIELD) 897607ca46eSDavid Howells __u8 track_mode : 4; 898607ca46eSDavid Howells __u8 copy : 1; 899607ca46eSDavid Howells __u8 damage : 1; 900607ca46eSDavid Howells __u8 reserved2 : 2; 901607ca46eSDavid Howells __u8 data_mode : 4; 902607ca46eSDavid Howells __u8 fp : 1; 903607ca46eSDavid Howells __u8 packet : 1; 904607ca46eSDavid Howells __u8 blank : 1; 905607ca46eSDavid Howells __u8 rt : 1; 906607ca46eSDavid Howells __u8 nwa_v : 1; 907607ca46eSDavid Howells __u8 lra_v : 1; 908607ca46eSDavid Howells __u8 reserved3 : 6; 909607ca46eSDavid Howells #endif 910607ca46eSDavid Howells __be32 track_start; 911607ca46eSDavid Howells __be32 next_writable; 912607ca46eSDavid Howells __be32 free_blocks; 913607ca46eSDavid Howells __be32 fixed_packet_size; 914607ca46eSDavid Howells __be32 track_size; 915607ca46eSDavid Howells __be32 last_rec_address; 916607ca46eSDavid Howells } track_information; 917607ca46eSDavid Howells 918607ca46eSDavid Howells struct feature_header { 919607ca46eSDavid Howells __u32 data_len; 920607ca46eSDavid Howells __u8 reserved1; 921607ca46eSDavid Howells __u8 reserved2; 922607ca46eSDavid Howells __u16 curr_profile; 923607ca46eSDavid Howells }; 924607ca46eSDavid Howells 925607ca46eSDavid Howells struct mode_page_header { 926607ca46eSDavid Howells __be16 mode_data_length; 927607ca46eSDavid Howells __u8 medium_type; 928607ca46eSDavid Howells __u8 reserved1; 929607ca46eSDavid Howells __u8 reserved2; 930607ca46eSDavid Howells __u8 reserved3; 931607ca46eSDavid Howells __be16 desc_length; 932607ca46eSDavid Howells }; 933607ca46eSDavid Howells 934afe75951SAaron Lu /* removable medium feature descriptor */ 935afe75951SAaron Lu struct rm_feature_desc { 936afe75951SAaron Lu __be16 feature_code; 937afe75951SAaron Lu #if defined(__BIG_ENDIAN_BITFIELD) 938afe75951SAaron Lu __u8 reserved1:2; 939afe75951SAaron Lu __u8 feature_version:4; 940afe75951SAaron Lu __u8 persistent:1; 941afe75951SAaron Lu __u8 curr:1; 942afe75951SAaron Lu #elif defined(__LITTLE_ENDIAN_BITFIELD) 943afe75951SAaron Lu __u8 curr:1; 944afe75951SAaron Lu __u8 persistent:1; 945afe75951SAaron Lu __u8 feature_version:4; 946afe75951SAaron Lu __u8 reserved1:2; 947afe75951SAaron Lu #endif 948afe75951SAaron Lu __u8 add_len; 949afe75951SAaron Lu #if defined(__BIG_ENDIAN_BITFIELD) 950afe75951SAaron Lu __u8 mech_type:3; 951afe75951SAaron Lu __u8 load:1; 952afe75951SAaron Lu __u8 eject:1; 953afe75951SAaron Lu __u8 pvnt_jmpr:1; 954afe75951SAaron Lu __u8 dbml:1; 955afe75951SAaron Lu __u8 lock:1; 956afe75951SAaron Lu #elif defined(__LITTLE_ENDIAN_BITFIELD) 957afe75951SAaron Lu __u8 lock:1; 958afe75951SAaron Lu __u8 dbml:1; 959afe75951SAaron Lu __u8 pvnt_jmpr:1; 960afe75951SAaron Lu __u8 eject:1; 961afe75951SAaron Lu __u8 load:1; 962afe75951SAaron Lu __u8 mech_type:3; 963afe75951SAaron Lu #endif 964afe75951SAaron Lu __u8 reserved2; 965afe75951SAaron Lu __u8 reserved3; 966afe75951SAaron Lu __u8 reserved4; 967afe75951SAaron Lu }; 968607ca46eSDavid Howells 969607ca46eSDavid Howells #endif /* _UAPI_LINUX_CDROM_H */ 970