Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  * -- <linux/cdrom.h>
0004  * General header file for linux CD-ROM drivers 
0005  * Copyright (C) 1992         David Giller, rafetmad@oxy.edu
0006  *               1994, 1995   Eberhard Mönkeberg, emoenke@gwdg.de
0007  *               1996         David van Leeuwen, david@tm.tno.nl
0008  *               1997, 1998   Erik Andersen, andersee@debian.org
0009  *               1998-2002    Jens Axboe, axboe@suse.de
0010  */
0011  
0012 #ifndef _UAPI_LINUX_CDROM_H
0013 #define _UAPI_LINUX_CDROM_H
0014 
0015 #include <linux/types.h>
0016 #include <asm/byteorder.h>
0017 
0018 /*******************************************************
0019  * As of Linux 2.1.x, all Linux CD-ROM application programs will use this 
0020  * (and only this) include file.  It is my hope to provide Linux with
0021  * a uniform interface between software accessing CD-ROMs and the various 
0022  * device drivers that actually talk to the drives.  There may still be
0023  * 23 different kinds of strange CD-ROM drives, but at least there will 
0024  * now be one, and only one, Linux CD-ROM interface.
0025  *
0026  * Additionally, as of Linux 2.1.x, all Linux application programs 
0027  * should use the O_NONBLOCK option when opening a CD-ROM device 
0028  * for subsequent ioctl commands.  This allows for neat system errors 
0029  * like "No medium found" or "Wrong medium type" upon attempting to 
0030  * mount or play an empty slot, mount an audio disc, or play a data disc.
0031  * Generally, changing an application program to support O_NONBLOCK
0032  * is as easy as the following:
0033  *       -    drive = open("/dev/cdrom", O_RDONLY);
0034  *       +    drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK);
0035  * It is worth the small change.
0036  *
0037  *  Patches for many common CD programs (provided by David A. van Leeuwen)
0038  *  can be found at:  ftp://ftp.gwdg.de/pub/linux/cdrom/drivers/cm206/
0039  * 
0040  *******************************************************/
0041 
0042 /* When a driver supports a certain function, but the cdrom drive we are 
0043  * using doesn't, we will return the error EDRIVE_CANT_DO_THIS.  We will 
0044  * borrow the "Operation not supported" error from the network folks to 
0045  * accomplish this.  Maybe someday we will get a more targeted error code, 
0046  * but this will do for now... */
0047 #define EDRIVE_CANT_DO_THIS  EOPNOTSUPP
0048 
0049 /*******************************************************
0050  * The CD-ROM IOCTL commands  -- these should be supported by 
0051  * all the various cdrom drivers.  For the CD-ROM ioctls, we 
0052  * will commandeer byte 0x53, or 'S'.
0053  *******************************************************/
0054 #define CDROMPAUSE      0x5301 /* Pause Audio Operation */ 
0055 #define CDROMRESUME     0x5302 /* Resume paused Audio Operation */
0056 #define CDROMPLAYMSF        0x5303 /* Play Audio MSF (struct cdrom_msf) */
0057 #define CDROMPLAYTRKIND     0x5304 /* Play Audio Track/index 
0058                                            (struct cdrom_ti) */
0059 #define CDROMREADTOCHDR     0x5305 /* Read TOC header 
0060                                            (struct cdrom_tochdr) */
0061 #define CDROMREADTOCENTRY   0x5306 /* Read TOC entry 
0062                                            (struct cdrom_tocentry) */
0063 #define CDROMSTOP       0x5307 /* Stop the cdrom drive */
0064 #define CDROMSTART      0x5308 /* Start the cdrom drive */
0065 #define CDROMEJECT      0x5309 /* Ejects the cdrom media */
0066 #define CDROMVOLCTRL        0x530a /* Control output volume 
0067                                            (struct cdrom_volctrl) */
0068 #define CDROMSUBCHNL        0x530b /* Read subchannel data 
0069                                            (struct cdrom_subchnl) */
0070 #define CDROMREADMODE2      0x530c /* Read CDROM mode 2 data (2336 Bytes) 
0071                                            (struct cdrom_read) */
0072 #define CDROMREADMODE1      0x530d /* Read CDROM mode 1 data (2048 Bytes)
0073                                            (struct cdrom_read) */
0074 #define CDROMREADAUDIO      0x530e /* (struct cdrom_read_audio) */
0075 #define CDROMEJECT_SW       0x530f /* enable(1)/disable(0) auto-ejecting */
0076 #define CDROMMULTISESSION   0x5310 /* Obtain the start-of-last-session 
0077                                            address of multi session disks 
0078                                            (struct cdrom_multisession) */
0079 #define CDROM_GET_MCN       0x5311 /* Obtain the "Universal Product Code" 
0080                                            if available (struct cdrom_mcn) */
0081 #define CDROM_GET_UPC       CDROM_GET_MCN  /* This one is deprecated, 
0082                                           but here anyway for compatibility */
0083 #define CDROMRESET      0x5312 /* hard-reset the drive */
0084 #define CDROMVOLREAD        0x5313 /* Get the drive's volume setting 
0085                                           (struct cdrom_volctrl) */
0086 #define CDROMREADRAW        0x5314  /* read data in raw mode (2352 Bytes)
0087                                            (struct cdrom_read) */
0088 /* 
0089  * These ioctls are used only used in aztcd.c and optcd.c
0090  */
0091 #define CDROMREADCOOKED     0x5315  /* read data in cooked mode */
0092 #define CDROMSEEK       0x5316  /* seek msf address */
0093   
0094 /*
0095  * This ioctl is only used by the scsi-cd driver.  
0096    It is for playing audio in logical block addressing mode.
0097  */
0098 #define CDROMPLAYBLK        0x5317  /* (struct cdrom_blk) */
0099 
0100 /* 
0101  * These ioctls are only used in optcd.c
0102  */
0103 #define CDROMREADALL        0x5318  /* read all 2646 bytes */
0104 
0105 /* 
0106  * These ioctls were only in (now removed) ide-cd.c for controlling
0107  * drive spindown time.  They should be implemented in the
0108  * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
0109  * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
0110  *  -Erik
0111  */
0112 #define CDROMGETSPINDOWN        0x531d
0113 #define CDROMSETSPINDOWN        0x531e
0114 
0115 /* 
0116  * These ioctls are implemented through the uniform CD-ROM driver
0117  * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
0118  * drivers are eventually ported to the uniform CD-ROM driver interface.
0119  */
0120 #define CDROMCLOSETRAY      0x5319  /* pendant of CDROMEJECT */
0121 #define CDROM_SET_OPTIONS   0x5320  /* Set behavior options */
0122 #define CDROM_CLEAR_OPTIONS 0x5321  /* Clear behavior options */
0123 #define CDROM_SELECT_SPEED  0x5322  /* Set the CD-ROM speed */
0124 #define CDROM_SELECT_DISC   0x5323  /* Select disc (for juke-boxes) */
0125 #define CDROM_MEDIA_CHANGED 0x5325  /* Check is media changed  */
0126 #define CDROM_DRIVE_STATUS  0x5326  /* Get tray position, etc. */
0127 #define CDROM_DISC_STATUS   0x5327  /* Get disc type, etc. */
0128 #define CDROM_CHANGER_NSLOTS    0x5328  /* Get number of slots */
0129 #define CDROM_LOCKDOOR      0x5329  /* lock or unlock door */
0130 #define CDROM_DEBUG     0x5330  /* Turn debug messages on/off */
0131 #define CDROM_GET_CAPABILITY    0x5331  /* get capabilities */
0132 
0133 /* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
0134  * Future CDROM ioctls should be kept below 0x537F
0135  */
0136 
0137 /* This ioctl is only used by sbpcd at the moment */
0138 #define CDROMAUDIOBUFSIZ        0x5382  /* set the audio buffer size */
0139                     /* conflict with SCSI_IOCTL_GET_IDLUN */
0140 
0141 /* DVD-ROM Specific ioctls */
0142 #define DVD_READ_STRUCT     0x5390  /* Read structure */
0143 #define DVD_WRITE_STRUCT    0x5391  /* Write structure */
0144 #define DVD_AUTH        0x5392  /* Authentication */
0145 
0146 #define CDROM_SEND_PACKET   0x5393  /* send a packet to the drive */
0147 #define CDROM_NEXT_WRITABLE 0x5394  /* get next writable block */
0148 #define CDROM_LAST_WRITTEN  0x5395  /* get last block written on disc */
0149 
0150 #define CDROM_TIMED_MEDIA_CHANGE   0x5396  /* get the timestamp of the last media change */
0151 
0152 /*******************************************************
0153  * CDROM IOCTL structures
0154  *******************************************************/
0155 
0156 /* Address in MSF format */
0157 struct cdrom_msf0       
0158 {
0159     __u8    minute;
0160     __u8    second;
0161     __u8    frame;
0162 };
0163 
0164 /* Address in either MSF or logical format */
0165 union cdrom_addr        
0166 {
0167     struct cdrom_msf0   msf;
0168     int         lba;
0169 };
0170 
0171 /* This struct is used by the CDROMPLAYMSF ioctl */ 
0172 struct cdrom_msf 
0173 {
0174     __u8    cdmsf_min0; /* start minute */
0175     __u8    cdmsf_sec0; /* start second */
0176     __u8    cdmsf_frame0;   /* start frame */
0177     __u8    cdmsf_min1; /* end minute */
0178     __u8    cdmsf_sec1; /* end second */
0179     __u8    cdmsf_frame1;   /* end frame */
0180 };
0181 
0182 /* This struct is used by the CDROMPLAYTRKIND ioctl */
0183 struct cdrom_ti 
0184 {
0185     __u8    cdti_trk0;  /* start track */
0186     __u8    cdti_ind0;  /* start index */
0187     __u8    cdti_trk1;  /* end track */
0188     __u8    cdti_ind1;  /* end index */
0189 };
0190 
0191 /* This struct is used by the CDROMREADTOCHDR ioctl */
0192 struct cdrom_tochdr     
0193 {
0194     __u8    cdth_trk0;  /* start track */
0195     __u8    cdth_trk1;  /* end track */
0196 };
0197 
0198 /* This struct is used by the CDROMVOLCTRL and CDROMVOLREAD ioctls */
0199 struct cdrom_volctrl
0200 {
0201     __u8    channel0;
0202     __u8    channel1;
0203     __u8    channel2;
0204     __u8    channel3;
0205 };
0206 
0207 /* This struct is used by the CDROMSUBCHNL ioctl */
0208 struct cdrom_subchnl 
0209 {
0210     __u8    cdsc_format;
0211     __u8    cdsc_audiostatus;
0212     __u8    cdsc_adr:   4;
0213     __u8    cdsc_ctrl:  4;
0214     __u8    cdsc_trk;
0215     __u8    cdsc_ind;
0216     union cdrom_addr cdsc_absaddr;
0217     union cdrom_addr cdsc_reladdr;
0218 };
0219 
0220 
0221 /* This struct is used by the CDROMREADTOCENTRY ioctl */
0222 struct cdrom_tocentry 
0223 {
0224     __u8    cdte_track;
0225     __u8    cdte_adr    :4;
0226     __u8    cdte_ctrl   :4;
0227     __u8    cdte_format;
0228     union cdrom_addr cdte_addr;
0229     __u8    cdte_datamode;
0230 };
0231 
0232 /* This struct is used by the CDROMREADMODE1, and CDROMREADMODE2 ioctls */
0233 struct cdrom_read      
0234 {
0235     int cdread_lba;
0236     char    *cdread_bufaddr;
0237     int cdread_buflen;
0238 };
0239 
0240 /* This struct is used by the CDROMREADAUDIO ioctl */
0241 struct cdrom_read_audio
0242 {
0243     union cdrom_addr addr; /* frame address */
0244     __u8 addr_format;      /* CDROM_LBA or CDROM_MSF */
0245     int nframes;           /* number of 2352-byte-frames to read at once */
0246     __u8 __user *buf;      /* frame buffer (size: nframes*2352 bytes) */
0247 };
0248 
0249 /* This struct is used with the CDROMMULTISESSION ioctl */
0250 struct cdrom_multisession
0251 {
0252     union cdrom_addr addr; /* frame address: start-of-last-session 
0253                                (not the new "frame 16"!).  Only valid
0254                                if the "xa_flag" is true. */
0255     __u8 xa_flag;        /* 1: "is XA disk" */
0256     __u8 addr_format;    /* CDROM_LBA or CDROM_MSF */
0257 };
0258 
0259 /* This struct is used with the CDROM_GET_MCN ioctl.  
0260  * Very few audio discs actually have Universal Product Code information, 
0261  * which should just be the Medium Catalog Number on the box.  Also note 
0262  * that the way the codeis written on CD is _not_ uniform across all discs!
0263  */  
0264 struct cdrom_mcn 
0265 {
0266   __u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */
0267 };
0268 
0269 /* This is used by the CDROMPLAYBLK ioctl */
0270 struct cdrom_blk 
0271 {
0272     unsigned from;
0273     unsigned short len;
0274 };
0275 
0276 #define CDROM_PACKET_SIZE   12
0277 
0278 #define CGC_DATA_UNKNOWN    0
0279 #define CGC_DATA_WRITE      1
0280 #define CGC_DATA_READ       2
0281 #define CGC_DATA_NONE       3
0282 
0283 /* for CDROM_PACKET_COMMAND ioctl */
0284 struct cdrom_generic_command
0285 {
0286     unsigned char       cmd[CDROM_PACKET_SIZE];
0287     unsigned char       __user *buffer;
0288     unsigned int        buflen;
0289     int         stat;
0290     struct request_sense    __user *sense;
0291     unsigned char       data_direction;
0292     int         quiet;
0293     int         timeout;
0294     union {
0295         void        __user *reserved[1];    /* unused, actually */
0296         void            __user *unused;
0297     };
0298 };
0299 
0300 /* This struct is used by CDROM_TIMED_MEDIA_CHANGE */
0301 struct cdrom_timed_media_change_info {
0302     __s64   last_media_change;  /* Timestamp of the last detected media
0303                      * change in ms. May be set by caller,
0304                      * updated upon successful return of
0305                      * ioctl.
0306                      */
0307     __u64   media_flags;        /* Flags returned by ioctl to indicate
0308                      * media status.
0309                      */
0310 };
0311 #define MEDIA_CHANGED_FLAG  0x1 /* Last detected media change was more
0312                      * recent than last_media_change set by
0313                      * caller.
0314                      */
0315 /* other bits of media_flags available for future use */
0316 
0317 /*
0318  * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336, 
0319  * 2340, or 2352 bytes long.  
0320 
0321 *         Sector types of the standard CD-ROM data formats:
0322  *
0323  * format   sector type               user data size (bytes)
0324  * -----------------------------------------------------------------------------
0325  *   1     (Red Book)    CD-DA          2352    (CD_FRAMESIZE_RAW)
0326  *   2     (Yellow Book) Mode1 Form1    2048    (CD_FRAMESIZE)
0327  *   3     (Yellow Book) Mode1 Form2    2336    (CD_FRAMESIZE_RAW0)
0328  *   4     (Green Book)  Mode2 Form1    2048    (CD_FRAMESIZE)
0329  *   5     (Green Book)  Mode2 Form2    2328    (2324+4 spare bytes)
0330  *
0331  *
0332  *       The layout of the standard CD-ROM data formats:
0333  * -----------------------------------------------------------------------------
0334  * - audio (red):                  | audio_sample_bytes |
0335  *                                 |        2352        |
0336  *
0337  * - data (yellow, mode1):         | sync - head - data - EDC - zero - ECC |
0338  *                                 |  12  -   4  - 2048 -  4  -   8  - 276 |
0339  *
0340  * - data (yellow, mode2):         | sync - head - data |
0341  *                                 |  12  -   4  - 2336 |
0342  *
0343  * - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC |
0344  *                                 |  12  -   4  -  8  - 2048 -  4  - 276 |
0345  *
0346  * - XA data (green, mode2 form2): | sync - head - sub - data - Spare |
0347  *                                 |  12  -   4  -  8  - 2324 -  4    |
0348  *
0349  */
0350 
0351 /* Some generally useful CD-ROM information -- mostly based on the above */
0352 #define CD_MINS              74 /* max. minutes per CD, not really a limit */
0353 #define CD_SECS              60 /* seconds per minute */
0354 #define CD_FRAMES            75 /* frames per second */
0355 #define CD_SYNC_SIZE         12 /* 12 sync bytes per raw data frame */
0356 #define CD_MSF_OFFSET       150 /* MSF numbering offset of first frame */
0357 #define CD_CHUNK_SIZE        24 /* lowest-level "data bytes piece" */
0358 #define CD_NUM_OF_CHUNKS     98 /* chunks per frame */
0359 #define CD_FRAMESIZE_SUB     96 /* subchannel data "frame" size */
0360 #define CD_HEAD_SIZE          4 /* header (address) bytes per raw data frame */
0361 #define CD_SUBHEAD_SIZE       8 /* subheader bytes per raw XA data frame */
0362 #define CD_EDC_SIZE           4 /* bytes EDC per most raw data frame types */
0363 #define CD_ZERO_SIZE          8 /* bytes zero per yellow book mode 1 frame */
0364 #define CD_ECC_SIZE         276 /* bytes ECC per most raw data frame types */
0365 #define CD_FRAMESIZE       2048 /* bytes per frame, "cooked" mode */
0366 #define CD_FRAMESIZE_RAW   2352 /* bytes per frame, "raw" mode */
0367 #define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */ 
0368 /* most drives don't deliver everything: */
0369 #define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/
0370 #define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/
0371 
0372 #define CD_XA_HEAD        (CD_HEAD_SIZE+CD_SUBHEAD_SIZE) /* "before data" part of raw XA frame */
0373 #define CD_XA_TAIL        (CD_EDC_SIZE+CD_ECC_SIZE) /* "after data" part of raw XA frame */
0374 #define CD_XA_SYNC_HEAD   (CD_SYNC_SIZE+CD_XA_HEAD) /* sync bytes + header of XA frame */
0375 
0376 /* CD-ROM address types (cdrom_tocentry.cdte_format) */
0377 #define CDROM_LBA 0x01 /* "logical block": first frame is #0 */
0378 #define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */
0379 
0380 /* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */
0381 #define CDROM_DATA_TRACK    0x04
0382 
0383 /* The leadout track is always 0xAA, regardless of # of tracks on disc */
0384 #define CDROM_LEADOUT       0xAA
0385 
0386 /* audio states (from SCSI-2, but seen with other drives, too) */
0387 #define CDROM_AUDIO_INVALID 0x00    /* audio status not supported */
0388 #define CDROM_AUDIO_PLAY    0x11    /* audio play operation in progress */
0389 #define CDROM_AUDIO_PAUSED  0x12    /* audio play operation paused */
0390 #define CDROM_AUDIO_COMPLETED   0x13    /* audio play successfully completed */
0391 #define CDROM_AUDIO_ERROR   0x14    /* audio play stopped due to error */
0392 #define CDROM_AUDIO_NO_STATUS   0x15    /* no current audio status to return */
0393 
0394 /* capability flags used with the uniform CD-ROM driver */ 
0395 #define CDC_CLOSE_TRAY      0x1     /* caddy systems _can't_ close */
0396 #define CDC_OPEN_TRAY       0x2     /* but _can_ eject.  */
0397 #define CDC_LOCK        0x4     /* disable manual eject */
0398 #define CDC_SELECT_SPEED    0x8     /* programmable speed */
0399 #define CDC_SELECT_DISC     0x10    /* select disc from juke-box */
0400 #define CDC_MULTI_SESSION   0x20    /* read sessions>1 */
0401 #define CDC_MCN         0x40    /* Medium Catalog Number */
0402 #define CDC_MEDIA_CHANGED   0x80    /* media changed */
0403 #define CDC_PLAY_AUDIO      0x100   /* audio functions */
0404 #define CDC_RESET               0x200   /* hard reset device */
0405 #define CDC_DRIVE_STATUS        0x800   /* driver implements drive status */
0406 #define CDC_GENERIC_PACKET  0x1000  /* driver implements generic packets */
0407 #define CDC_CD_R        0x2000  /* drive is a CD-R */
0408 #define CDC_CD_RW       0x4000  /* drive is a CD-RW */
0409 #define CDC_DVD         0x8000  /* drive is a DVD */
0410 #define CDC_DVD_R       0x10000 /* drive can write DVD-R */
0411 #define CDC_DVD_RAM     0x20000 /* drive can write DVD-RAM */
0412 #define CDC_MO_DRIVE        0x40000 /* drive is an MO device */
0413 #define CDC_MRW         0x80000 /* drive can read MRW */
0414 #define CDC_MRW_W       0x100000 /* drive can write MRW */
0415 #define CDC_RAM         0x200000 /* ok to open for WRITE */
0416 
0417 /* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */
0418 #define CDS_NO_INFO     0   /* if not implemented */
0419 #define CDS_NO_DISC     1
0420 #define CDS_TRAY_OPEN       2
0421 #define CDS_DRIVE_NOT_READY 3
0422 #define CDS_DISC_OK     4
0423 
0424 /* return values for the CDROM_DISC_STATUS ioctl */
0425 /* can also return CDS_NO_[INFO|DISC], from above */
0426 #define CDS_AUDIO       100
0427 #define CDS_DATA_1      101
0428 #define CDS_DATA_2      102
0429 #define CDS_XA_2_1      103
0430 #define CDS_XA_2_2      104
0431 #define CDS_MIXED       105
0432 
0433 /* User-configurable behavior options for the uniform CD-ROM driver */
0434 #define CDO_AUTO_CLOSE      0x1     /* close tray on first open() */
0435 #define CDO_AUTO_EJECT      0x2     /* open tray on last release() */
0436 #define CDO_USE_FFLAGS      0x4     /* use O_NONBLOCK information on open */
0437 #define CDO_LOCK        0x8     /* lock tray on open files */
0438 #define CDO_CHECK_TYPE      0x10    /* check type on open for data */
0439 
0440 /* Special codes used when specifying changer slots. */
0441 #define CDSL_NONE           (INT_MAX-1)
0442 #define CDSL_CURRENT        INT_MAX
0443 
0444 /* For partition based multisession access. IDE can handle 64 partitions
0445  * per drive - SCSI CD-ROM's use minors to differentiate between the
0446  * various drives, so we can't do multisessions the same way there.
0447  * Use the -o session=x option to mount on them.
0448  */
0449 #define CD_PART_MAX     64
0450 #define CD_PART_MASK        (CD_PART_MAX - 1)
0451 
0452 /*********************************************************************
0453  * Generic Packet commands, MMC commands, and such
0454  *********************************************************************/
0455 
0456  /* The generic packet command opcodes for CD/DVD Logical Units,
0457  * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
0458 #define GPCMD_BLANK             0xa1
0459 #define GPCMD_CLOSE_TRACK           0x5b
0460 #define GPCMD_FLUSH_CACHE           0x35
0461 #define GPCMD_FORMAT_UNIT           0x04
0462 #define GPCMD_GET_CONFIGURATION         0x46
0463 #define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a
0464 #define GPCMD_GET_PERFORMANCE           0xac
0465 #define GPCMD_INQUIRY               0x12
0466 #define GPCMD_LOAD_UNLOAD           0xa6
0467 #define GPCMD_MECHANISM_STATUS          0xbd
0468 #define GPCMD_MODE_SELECT_10            0x55
0469 #define GPCMD_MODE_SENSE_10         0x5a
0470 #define GPCMD_PAUSE_RESUME          0x4b
0471 #define GPCMD_PLAY_AUDIO_10         0x45
0472 #define GPCMD_PLAY_AUDIO_MSF            0x47
0473 #define GPCMD_PLAY_AUDIO_TI         0x48
0474 #define GPCMD_PLAY_CD               0xbc
0475 #define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL  0x1e
0476 #define GPCMD_READ_10               0x28
0477 #define GPCMD_READ_12               0xa8
0478 #define GPCMD_READ_BUFFER           0x3c
0479 #define GPCMD_READ_BUFFER_CAPACITY      0x5c
0480 #define GPCMD_READ_CDVD_CAPACITY        0x25
0481 #define GPCMD_READ_CD               0xbe
0482 #define GPCMD_READ_CD_MSF           0xb9
0483 #define GPCMD_READ_DISC_INFO            0x51
0484 #define GPCMD_READ_DVD_STRUCTURE        0xad
0485 #define GPCMD_READ_FORMAT_CAPACITIES        0x23
0486 #define GPCMD_READ_HEADER           0x44
0487 #define GPCMD_READ_TRACK_RZONE_INFO     0x52
0488 #define GPCMD_READ_SUBCHANNEL           0x42
0489 #define GPCMD_READ_TOC_PMA_ATIP         0x43
0490 #define GPCMD_REPAIR_RZONE_TRACK        0x58
0491 #define GPCMD_REPORT_KEY            0xa4
0492 #define GPCMD_REQUEST_SENSE         0x03
0493 #define GPCMD_RESERVE_RZONE_TRACK       0x53
0494 #define GPCMD_SEND_CUE_SHEET            0x5d
0495 #define GPCMD_SCAN              0xba
0496 #define GPCMD_SEEK              0x2b
0497 #define GPCMD_SEND_DVD_STRUCTURE        0xbf
0498 #define GPCMD_SEND_EVENT            0xa2
0499 #define GPCMD_SEND_KEY              0xa3
0500 #define GPCMD_SEND_OPC              0x54
0501 #define GPCMD_SET_READ_AHEAD            0xa7
0502 #define GPCMD_SET_STREAMING         0xb6
0503 #define GPCMD_START_STOP_UNIT           0x1b
0504 #define GPCMD_STOP_PLAY_SCAN            0x4e
0505 #define GPCMD_TEST_UNIT_READY           0x00
0506 #define GPCMD_VERIFY_10             0x2f
0507 #define GPCMD_WRITE_10              0x2a
0508 #define GPCMD_WRITE_12              0xaa
0509 #define GPCMD_WRITE_AND_VERIFY_10       0x2e
0510 #define GPCMD_WRITE_BUFFER          0x3b
0511 /* This is listed as optional in ATAPI 2.6, but is (curiously) 
0512  * missing from Mt. Fuji, Table 57.  It _is_ mentioned in Mt. Fuji
0513  * Table 377 as an MMC command for SCSi devices though...  Most ATAPI
0514  * drives support it. */
0515 #define GPCMD_SET_SPEED             0xbb
0516 /* This seems to be a SCSI specific CD-ROM opcode 
0517  * to play data at track/index */
0518 #define GPCMD_PLAYAUDIO_TI          0x48
0519 /*
0520  * From MS Media Status Notification Support Specification. For
0521  * older drives only.
0522  */
0523 #define GPCMD_GET_MEDIA_STATUS          0xda
0524 
0525 /* Mode page codes for mode sense/set */
0526 #define GPMODE_VENDOR_PAGE      0x00
0527 #define GPMODE_R_W_ERROR_PAGE       0x01
0528 #define GPMODE_WRITE_PARMS_PAGE     0x05
0529 #define GPMODE_WCACHING_PAGE        0x08
0530 #define GPMODE_AUDIO_CTL_PAGE       0x0e
0531 #define GPMODE_POWER_PAGE       0x1a
0532 #define GPMODE_FAULT_FAIL_PAGE      0x1c
0533 #define GPMODE_TO_PROTECT_PAGE      0x1d
0534 #define GPMODE_CAPABILITIES_PAGE    0x2a
0535 #define GPMODE_ALL_PAGES        0x3f
0536 /* Not in Mt. Fuji, but in ATAPI 2.6 -- deprecated now in favor
0537  * of MODE_SENSE_POWER_PAGE */
0538 #define GPMODE_CDROM_PAGE       0x0d
0539 
0540 
0541 
0542 /* DVD struct types */
0543 #define DVD_STRUCT_PHYSICAL 0x00
0544 #define DVD_STRUCT_COPYRIGHT    0x01
0545 #define DVD_STRUCT_DISCKEY  0x02
0546 #define DVD_STRUCT_BCA      0x03
0547 #define DVD_STRUCT_MANUFACT 0x04
0548 
0549 struct dvd_layer {
0550     __u8 book_version   : 4;
0551     __u8 book_type      : 4;
0552     __u8 min_rate       : 4;
0553     __u8 disc_size      : 4;
0554     __u8 layer_type     : 4;
0555     __u8 track_path     : 1;
0556     __u8 nlayers        : 2;
0557     __u8 track_density  : 4;
0558     __u8 linear_density : 4;
0559     __u8 bca        : 1;
0560     __u32 start_sector;
0561     __u32 end_sector;
0562     __u32 end_sector_l0;
0563 };
0564 
0565 #define DVD_LAYERS  4
0566 
0567 struct dvd_physical {
0568     __u8 type;
0569     __u8 layer_num;
0570     struct dvd_layer layer[DVD_LAYERS];
0571 };
0572 
0573 struct dvd_copyright {
0574     __u8 type;
0575 
0576     __u8 layer_num;
0577     __u8 cpst;
0578     __u8 rmi;
0579 };
0580 
0581 struct dvd_disckey {
0582     __u8 type;
0583 
0584     unsigned agid       : 2;
0585     __u8 value[2048];
0586 };
0587 
0588 struct dvd_bca {
0589     __u8 type;
0590 
0591     int len;
0592     __u8 value[188];
0593 };
0594 
0595 struct dvd_manufact {
0596     __u8 type;
0597 
0598     __u8 layer_num;
0599     int len;
0600     __u8 value[2048];
0601 };
0602 
0603 typedef union {
0604     __u8 type;
0605 
0606     struct dvd_physical physical;
0607     struct dvd_copyright    copyright;
0608     struct dvd_disckey  disckey;
0609     struct dvd_bca      bca;
0610     struct dvd_manufact manufact;
0611 } dvd_struct;
0612 
0613 /*
0614  * DVD authentication ioctl
0615  */
0616 
0617 /* Authentication states */
0618 #define DVD_LU_SEND_AGID    0
0619 #define DVD_HOST_SEND_CHALLENGE 1
0620 #define DVD_LU_SEND_KEY1    2
0621 #define DVD_LU_SEND_CHALLENGE   3
0622 #define DVD_HOST_SEND_KEY2  4
0623 
0624 /* Termination states */
0625 #define DVD_AUTH_ESTABLISHED    5
0626 #define DVD_AUTH_FAILURE    6
0627 
0628 /* Other functions */
0629 #define DVD_LU_SEND_TITLE_KEY   7
0630 #define DVD_LU_SEND_ASF     8
0631 #define DVD_INVALIDATE_AGID 9
0632 #define DVD_LU_SEND_RPC_STATE   10
0633 #define DVD_HOST_SEND_RPC_STATE 11
0634 
0635 /* State data */
0636 typedef __u8 dvd_key[5];        /* 40-bit value, MSB is first elem. */
0637 typedef __u8 dvd_challenge[10]; /* 80-bit value, MSB is first elem. */
0638 
0639 struct dvd_lu_send_agid {
0640     __u8 type;
0641     unsigned agid       : 2;
0642 };
0643 
0644 struct dvd_host_send_challenge {
0645     __u8 type;
0646     unsigned agid       : 2;
0647 
0648     dvd_challenge chal;
0649 };
0650 
0651 struct dvd_send_key {
0652     __u8 type;
0653     unsigned agid       : 2;
0654 
0655     dvd_key key;
0656 };
0657 
0658 struct dvd_lu_send_challenge {
0659     __u8 type;
0660     unsigned agid       : 2;
0661 
0662     dvd_challenge chal;
0663 };
0664 
0665 #define DVD_CPM_NO_COPYRIGHT    0
0666 #define DVD_CPM_COPYRIGHTED 1
0667 
0668 #define DVD_CP_SEC_NONE     0
0669 #define DVD_CP_SEC_EXIST    1
0670 
0671 #define DVD_CGMS_UNRESTRICTED   0
0672 #define DVD_CGMS_SINGLE     2
0673 #define DVD_CGMS_RESTRICTED 3
0674 
0675 struct dvd_lu_send_title_key {
0676     __u8 type;
0677     unsigned agid       : 2;
0678 
0679     dvd_key title_key;
0680     int lba;
0681     unsigned cpm        : 1;
0682     unsigned cp_sec     : 1;
0683     unsigned cgms       : 2;
0684 };
0685 
0686 struct dvd_lu_send_asf {
0687     __u8 type;
0688     unsigned agid       : 2;
0689 
0690     unsigned asf        : 1;
0691 };
0692 
0693 struct dvd_host_send_rpcstate {
0694     __u8 type;
0695     __u8 pdrc;
0696 };
0697 
0698 struct dvd_lu_send_rpcstate {
0699     __u8 type       : 2;
0700     __u8 vra        : 3;
0701     __u8 ucca       : 3;
0702     __u8 region_mask;
0703     __u8 rpc_scheme;
0704 };
0705 
0706 typedef union {
0707     __u8 type;
0708 
0709     struct dvd_lu_send_agid     lsa;
0710     struct dvd_host_send_challenge  hsc;
0711     struct dvd_send_key     lsk;
0712     struct dvd_lu_send_challenge    lsc;
0713     struct dvd_send_key     hsk;
0714     struct dvd_lu_send_title_key    lstk;
0715     struct dvd_lu_send_asf      lsasf;
0716     struct dvd_host_send_rpcstate   hrpcs;
0717     struct dvd_lu_send_rpcstate lrpcs;
0718 } dvd_authinfo;
0719 
0720 struct request_sense {
0721 #if defined(__BIG_ENDIAN_BITFIELD)
0722     __u8 valid      : 1;
0723     __u8 error_code     : 7;
0724 #elif defined(__LITTLE_ENDIAN_BITFIELD)
0725     __u8 error_code     : 7;
0726     __u8 valid      : 1;
0727 #endif
0728     __u8 segment_number;
0729 #if defined(__BIG_ENDIAN_BITFIELD)
0730     __u8 reserved1      : 2;
0731     __u8 ili        : 1;
0732     __u8 reserved2      : 1;
0733     __u8 sense_key      : 4;
0734 #elif defined(__LITTLE_ENDIAN_BITFIELD)
0735     __u8 sense_key      : 4;
0736     __u8 reserved2      : 1;
0737     __u8 ili        : 1;
0738     __u8 reserved1      : 2;
0739 #endif
0740     __u8 information[4];
0741     __u8 add_sense_len;
0742     __u8 command_info[4];
0743     __u8 asc;
0744     __u8 ascq;
0745     __u8 fruc;
0746     __u8 sks[3];
0747     __u8 asb[46];
0748 };
0749 
0750 /*
0751  * feature profile
0752  */
0753 #define CDF_RWRT    0x0020  /* "Random Writable" */
0754 #define CDF_HWDM    0x0024  /* "Hardware Defect Management" */
0755 #define CDF_MRW     0x0028
0756 
0757 /*
0758  * media status bits
0759  */
0760 #define CDM_MRW_NOTMRW          0
0761 #define CDM_MRW_BGFORMAT_INACTIVE   1
0762 #define CDM_MRW_BGFORMAT_ACTIVE     2
0763 #define CDM_MRW_BGFORMAT_COMPLETE   3
0764 
0765 /*
0766  * mrw address spaces
0767  */
0768 #define MRW_LBA_DMA         0
0769 #define MRW_LBA_GAA         1
0770 
0771 /*
0772  * mrw mode pages (first is deprecated) -- probed at init time and
0773  * cdi->mrw_mode_page is set
0774  */
0775 #define MRW_MODE_PC_PRE1        0x2c
0776 #define MRW_MODE_PC         0x03
0777 
0778 struct mrw_feature_desc {
0779     __be16 feature_code;
0780 #if defined(__BIG_ENDIAN_BITFIELD)
0781     __u8 reserved1      : 2;
0782     __u8 feature_version    : 4;
0783     __u8 persistent     : 1;
0784     __u8 curr       : 1;
0785 #elif defined(__LITTLE_ENDIAN_BITFIELD)
0786     __u8 curr       : 1;
0787     __u8 persistent     : 1;
0788     __u8 feature_version    : 4;
0789     __u8 reserved1      : 2;
0790 #endif
0791     __u8 add_len;
0792 #if defined(__BIG_ENDIAN_BITFIELD)
0793     __u8 reserved2      : 7;
0794     __u8 write      : 1;
0795 #elif defined(__LITTLE_ENDIAN_BITFIELD)
0796     __u8 write      : 1;
0797     __u8 reserved2      : 7;
0798 #endif
0799     __u8 reserved3;
0800     __u8 reserved4;
0801     __u8 reserved5;
0802 };
0803 
0804 /* cf. mmc4r02g.pdf 5.3.10 Random Writable Feature (0020h) pg 197 of 635 */
0805 struct rwrt_feature_desc {
0806     __be16 feature_code;
0807 #if defined(__BIG_ENDIAN_BITFIELD)
0808     __u8 reserved1      : 2;
0809     __u8 feature_version    : 4;
0810     __u8 persistent     : 1;
0811     __u8 curr       : 1;
0812 #elif defined(__LITTLE_ENDIAN_BITFIELD)
0813     __u8 curr       : 1;
0814     __u8 persistent     : 1;
0815     __u8 feature_version    : 4;
0816     __u8 reserved1      : 2;
0817 #endif
0818     __u8 add_len;
0819     __u32 last_lba;
0820     __u32 block_size;
0821     __u16 blocking;
0822 #if defined(__BIG_ENDIAN_BITFIELD)
0823     __u8 reserved2      : 7;
0824     __u8 page_present   : 1;
0825 #elif defined(__LITTLE_ENDIAN_BITFIELD)
0826     __u8 page_present   : 1;
0827     __u8 reserved2      : 7;
0828 #endif
0829     __u8 reserved3;
0830 };
0831 
0832 typedef struct {
0833     __be16 disc_information_length;
0834 #if defined(__BIG_ENDIAN_BITFIELD)
0835     __u8 reserved1          : 3;
0836         __u8 erasable           : 1;
0837         __u8 border_status      : 2;
0838         __u8 disc_status        : 2;
0839 #elif defined(__LITTLE_ENDIAN_BITFIELD)
0840         __u8 disc_status        : 2;
0841         __u8 border_status      : 2;
0842         __u8 erasable           : 1;
0843     __u8 reserved1          : 3;
0844 #else
0845 #error "Please fix <asm/byteorder.h>"
0846 #endif
0847     __u8 n_first_track;
0848     __u8 n_sessions_lsb;
0849     __u8 first_track_lsb;
0850     __u8 last_track_lsb;
0851 #if defined(__BIG_ENDIAN_BITFIELD)
0852     __u8 did_v          : 1;
0853         __u8 dbc_v          : 1;
0854         __u8 uru            : 1;
0855         __u8 reserved2          : 2;
0856     __u8 dbit           : 1;
0857     __u8 mrw_status         : 2;
0858 #elif defined(__LITTLE_ENDIAN_BITFIELD)
0859     __u8 mrw_status         : 2;
0860     __u8 dbit           : 1;
0861         __u8 reserved2          : 2;
0862         __u8 uru            : 1;
0863         __u8 dbc_v          : 1;
0864     __u8 did_v          : 1;
0865 #endif
0866     __u8 disc_type;
0867     __u8 n_sessions_msb;
0868     __u8 first_track_msb;
0869     __u8 last_track_msb;
0870     __u32 disc_id;
0871     __u32 lead_in;
0872     __u32 lead_out;
0873     __u8 disc_bar_code[8];
0874     __u8 reserved3;
0875     __u8 n_opc;
0876 } disc_information;
0877 
0878 typedef struct {
0879     __be16 track_information_length;
0880     __u8 track_lsb;
0881     __u8 session_lsb;
0882     __u8 reserved1;
0883 #if defined(__BIG_ENDIAN_BITFIELD)
0884     __u8 reserved2          : 2;
0885         __u8 damage         : 1;
0886         __u8 copy           : 1;
0887         __u8 track_mode         : 4;
0888     __u8 rt             : 1;
0889     __u8 blank          : 1;
0890     __u8 packet         : 1;
0891     __u8 fp             : 1;
0892     __u8 data_mode          : 4;
0893     __u8 reserved3          : 6;
0894     __u8 lra_v          : 1;
0895     __u8 nwa_v          : 1;
0896 #elif defined(__LITTLE_ENDIAN_BITFIELD)
0897         __u8 track_mode         : 4;
0898         __u8 copy           : 1;
0899         __u8 damage         : 1;
0900     __u8 reserved2          : 2;
0901     __u8 data_mode          : 4;
0902     __u8 fp             : 1;
0903     __u8 packet         : 1;
0904     __u8 blank          : 1;
0905     __u8 rt             : 1;
0906     __u8 nwa_v          : 1;
0907     __u8 lra_v          : 1;
0908     __u8 reserved3          : 6;
0909 #endif
0910     __be32 track_start;
0911     __be32 next_writable;
0912     __be32 free_blocks;
0913     __be32 fixed_packet_size;
0914     __be32 track_size;
0915     __be32 last_rec_address;
0916 } track_information;
0917 
0918 struct feature_header {
0919     __u32 data_len;
0920     __u8 reserved1;
0921     __u8 reserved2;
0922     __u16 curr_profile;
0923 };
0924 
0925 struct mode_page_header {
0926     __be16 mode_data_length;
0927     __u8 medium_type;
0928     __u8 reserved1;
0929     __u8 reserved2;
0930     __u8 reserved3;
0931     __be16 desc_length;
0932 };
0933 
0934 /* removable medium feature descriptor */
0935 struct rm_feature_desc {
0936     __be16 feature_code;
0937 #if defined(__BIG_ENDIAN_BITFIELD)
0938     __u8 reserved1:2;
0939     __u8 feature_version:4;
0940     __u8 persistent:1;
0941     __u8 curr:1;
0942 #elif defined(__LITTLE_ENDIAN_BITFIELD)
0943     __u8 curr:1;
0944     __u8 persistent:1;
0945     __u8 feature_version:4;
0946     __u8 reserved1:2;
0947 #endif
0948     __u8 add_len;
0949 #if defined(__BIG_ENDIAN_BITFIELD)
0950     __u8 mech_type:3;
0951     __u8 load:1;
0952     __u8 eject:1;
0953     __u8 pvnt_jmpr:1;
0954     __u8 dbml:1;
0955     __u8 lock:1;
0956 #elif defined(__LITTLE_ENDIAN_BITFIELD)
0957     __u8 lock:1;
0958     __u8 dbml:1;
0959     __u8 pvnt_jmpr:1;
0960     __u8 eject:1;
0961     __u8 load:1;
0962     __u8 mech_type:3;
0963 #endif
0964     __u8 reserved2;
0965     __u8 reserved3;
0966     __u8 reserved4;
0967 };
0968 
0969 #endif /* _UAPI_LINUX_CDROM_H */