CD-ROM/DVD-ROM  [include/linux/cdrom.h]

CDROMPAUSE Pause audio operation. edx is ignored. In case of success return value is 0, otherwise return value is -ENOSYS meaning that the cd drive is not audio-capable.
CDROMRESUME Pause paused audio operation. edx is ignored. In case of success return value is 0, otherwise return value is -ENOSYS meaning that the cd drive is not audio-capable.
CDROMPLAYMSF Play audio MSF (minutes:seconds:frames {frame is 1/75 of second}). edx should point to a properly initialized cdrom_msf structure describing the segment of music to play:

struc cdrom_msf
{
.cdmsf_min0   rb 1 ; start minute
.cdmsf_sec0   rb 1 ; start second
.cdmsf_frame0 rb 1 ; start frame
.cdmsf_min1   rb 1 ; end minute
.cdmsf_sec1   rb 1 ; end second
.cdmsf_frame1 rb 1 ; end frame
}

In case of success return value is 0, otherwise return value is -ENOSYS meaning that the cd drive is not audio-capable.
CDROMPLAYTRKIND Play audio track/index. edx should point to a properly initialized cdrom_ti structure describing the segment of music to play:

struc cdrom_ti
{
.cdti_trk0 rb 1 ; start track
.cdti_ind0 rb 1 ; start index
.cdti_trk1 rb 1 ; end track
.cdti_ind1 rb 1 ; end index
}

In case of success return value is 0, otherwise return value is -ENOSYS meaning that the cd drive is not audio-capable.
CDROMREADTOCHDR Read TOC header. edx should point to a cdrom_tochdr structure which will receive the information:

struc cdrom_tochdr
{
.cdth_trk0 rb 1 ; start track
.cdth_trk1 rb 1 ; end track
}

In case of success return value is 0, otherwise return value is -ENOSYS meaning that the cd drive is not audio-capable.
CDROMREADTOCENTRY Read TOC entry. edx should point to a cdrom_tocentry structure which will receive the information:

struc cdrom_tocentry
{
.cdte_track    rb 1
.cdte_adr      rb 1
.cdte_ctrl     rb 1
.cdte_format   rb 1
.cdte_addr     cd_addr
.cdte_datamode rb 1
}


struc cd_addr
{
msf: ;cdrom_msf0
lba  rd 1
}

cdrom_tocentry members:

cdte_format

Specifies the addressing mode. It should be one of the following values: CDROM_MSF or CDROM_LBA specifying MSF and LBA (Logical Block Address) modes respectively. To describe MSF cdrom_msf0 structure is used:

struc cdrom_msf0
{
.minute rb 1
.second rb 1
.frame  rb 1
}

MSF values can be converted to LBA values via this formula:
LBA = (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET;

In case of success return value is 0, otherwise return value is one of the following errno values:
-ENOSYS Cd drive not audio-capable.
-EINVAL entry.cdte_format not CDROM_MSF or CDROM_LBA.
-EINVAL Requested track out of bounds.
-EIO I/O error reading TOC.
CDROMSTOP Stop the CDROM drive. edx is ignored. In case of success return value is 0, otherwise return value is -ENOSYS meaning that the cd drive is not audio-capable.
Exact interpretation of this IOCTL depends on the device, but most seem to spin the drive down.
CDROMSTART Start the CDROM drive. edx is ignored. In case of success return value is 0, otherwise return value is -ENOSYS meaning that the cd drive is not audio-capable.
Exact interpretation of this IOCTL depends on the device, but most seem to spin the drive up and/or close the tray. Other devices ignore the IOCTL completely.
CDROMEJECT Eject the CDROM media. edx is ignored. In case of success return value is 0, otherwise return value is one of the following errno values:
-ENOSYS Cd drive not capable of ejecting.
-EBUSY Other processes are accessing drive, or door is locked.

See also CDROM_LOCKDOOR, below.
CDROMVOLCTRL Control output volume. edx should point to a properly initialized cdrom_volctrl structure:

struc cdrom_volctrl
{
.channel0 rb 1
.channel1 rb 1
.channel2 rb 1
.channel3 rb 1
}

In case of success return value is 0, otherwise return value is -ENOSYS meaning that the cd drive is not audio-capable.
CDROMSUBCHNL Read subchannel data. edx should point to a cdrom_subchnl structure which will receive the information:

struc cdrom_subchnl
{
.cdsc_format  rb 1
.cdsc_audiostatus rb 1
.cdsc_adr     rb 1
.cdsc_ctrl    rb 1
.cdsc_trk     rb 1
.cdsc_ind     rb 1
.cdsc_absaddr cd_addr
.cdsc_reladdr cd_addr
}

cdrom_subchnl members:

cdsc_format

Specifies the addressing mode. It should be one of the following values: CDROM_MSF or CDROM_LBA specifying MSF and LBA (Logical Block Address) modes respectively. To describe MSF cdrom_msf0 structure is used (See CDROMREADTOCENTRY for cdrom_msf0 structure definition).

In case of success return value is 0, otherwise return value is one of the following errno values:
-ENOSYS Cd drive not capable of ejecting.
-EINVAL format not CDROM_MSF or CDROM_LBA.
CDROMREADMODE2 Read CDROM mode 2 data (2336 Bytes). edx should point to a properly initialized cdrom_msf structure (only the start values are significant) which on return will be overwritten with the read data:

union
msf    cdrom_msf
buffer rb CD_FRAMESIZE_RAW0
ends

This IOCTL is identical to CDROMREADRAW except that block size is CD_FRAMESIZE_RAW0 (2336) bytes.

In case of success return value is 0, otherwise return value is one of the following errno values:
-EINVAL Address less than 0, or msf less than 0:2:0.
-ENOMEM Out of memory.
CDROMREADMODE1 Read CDROM mode 1 data (2048 Bytes). edx should point to a properly initialized cdrom_msf structure (only the start values are significant) which on return will be overwriten with the read data:

union
msf    cdrom_msf
buffer rb CD_FRAMESIZE
ends

This IOCTL is identical to CDROMREADRAW except that block size is CD_FRAMESIZE (2048) bytes.

In case of success return value is 0, otherwise return value is one of the following errno values:
-EINVAL Address less than 0, or msf less than 0:2:0.
-ENOMEM Out of memory.
CDROMREADAUDIO Read audio data. edx should point to a properly initialized cdrom_read_audio structure containing read start
point and length:

struc cdrom_read_audio
{
.msf:        ;cdrom_msf0
.lba         rd 1
.addr_format rb 1
.nframes     rd 1
.buf         rd 1
}

In case of success return value is 0, otherwise return value is one of the following errno values:
-EINVAL format not CDROM_MSF or CDROM_LBA
-EINVAL nframes not in range [1 75].
-ENXIO Drive has no queue (probably means invalid fd).
-ENOMEM Out of memory.
CDROMEJECT_SW Enable/disable auto ejecting. edx should be set to either 0 (disable) or 1 (enable).

In case of success return value is 0, otherwise return value is one of the following errno values:
-ENOSYS Drive is not capable of ejecting.
-EBUSY Door is locked.
CDROMMULTISESSION Obtain the start-of-last-session address of multi session disks. edx should point to a properly initialized cdrom_multisession structure containing desired format, on return it will be filled with last_session information.

struc cdrom_multisession
{
.addr        cdrom_addr
.xa_flag     rb 1 ; 1: "is XA disk"
.addr_format rb 1 ; CDROM_LBA or CDROM_MSF
}

cdrom_multisession members:

_addr

Frame address: start-of-last-session (not the new "frame 16"!). Only valid if the "xa_flag" is true.

In case of success return value is 0, otherwise return value is -EINVAL meaning that format is not CDROM_MSF or CDROM_LBA.
CDROM_GET_MCN Obtain the "Universal Product Code" if available. edx should point to a cdrom_mcn structure which will receive the information:

struct cdrom_mcn
medium_catalog_number db 14 dup(?) ; 13 ASCII digits, null-terminated
ends

In case of success return value is 0, otherwise return value is -ENOSYS meaning that the drive is not capable of reading MCN data.

*The following function is implemented, although very few audio discs give Universal Product Code information, which should just be the Medium Catalog Number on the box. Note, that the way the code is written on the CD is /not/ uniform across all discs!
CDROM_GET_UPC This IOCTL is deprecated, for compatibility reasons it's set to be identical to CDROM_GET_MCN.
CDROMRESET Hard-reset the drive. edx is ignored.

In case of success return value is 0, otherwise return value is one of the following errno values:
-EACCES Access denied: requires CAP_SYS_ADMIN.
-ENOSYS Drive is not capable of resetting.
CDROMVOLREAD Get the drive's volume setting. edx should point to a cdrom_volctrl structure which will receive the information (See CDROMVOLCTRL for the cdrom_volctrl structure definition).

In case of success return value is 0, otherwise return value is -ENOSYS meaning that the cd drive is not audio-capable.
CDROMREADRAW Read CDROM mode 1 data (2352 Bytes). edx should point to a properly initialized cdrom_msf structure (only the start values are significant) which on return will be overwritten with the read data:

union
msf    cdrom_msf
buffer rb CD_FRAMESIZE_RAW
ends

In case of success return value is 0, otherwise return value is one of the following errno values:
-EINVAL address less than 0, or msf less than 0:2:0
-ENOMEM out of memory
CDROMREADCOOKED Read data in cooked mode. edx should point to a 2048 (CD_FRAMESIZE) bytes long buffer which will receive the data.
*Not implemented on all drives.
CDROMSEEK Seek MSF address. edx should point to a cdrom_msf structure containing the address to seek to.
CDROMPLAYBLK Play CD data. edx should point to a properly initialized cdrom_blk structure specifying the region to play:

struc cdrom_blk
{
.from rd 1
.len  rw 1
}

*SCSI-CD only.
CDROMREADALL Same as CDROMREADCOOKED, but reads 2646 bytes.
CDROMGETSPINDOWN Get current 4-bit spindown value. edx should point to one byte long location which will receive the return value.
CDROMSETSPINDOWN Set 4-bit spindown value. edx should point to a properly initialized one byte long location containing the 4-bit spindown value to be set.
CDROMCLOSETRAY Pendant of CDROMEJECT. edx is ignored.

In case of success return value is 0, otherwise return value is one of the following errno values:
-ENOSYS Cd drive not capable of ejecting
-EBUSY Other processes are accessing drive, or door is locked.

See CDROM_LOCKDOOR.
CDROM_SET_OPTIONS Set behavior options. edx should contain one or result of logical-or operation of a number of the following values:

CDO_AUTO_CLOSE - close tray on first open operation
CDO_AUTO_EJECT - open tray on last release
CDO_USE_FFLAGS - use O_NONBLOCK information on open
CDO_LOCK       - lock tray on open files
CDO_CHECK_TYPE - check type on open for data

In case of success the return value is resulting options settings, otherwise the return value is -ENOSYS meaning that the selected option(s) not supported by drive.
CDROM_CLEAR_OPTIONS Clear behavior options. Same as CDROM_SET_OPTIONS, except that selected options are turned off.
CDROM_SELECT_SPEED Set the CD-ROM speed. edx should contain a value specifying new drive speed.
In case of success return value is 0, otherwise return value is -ENOSYS meaning that the speed selection is not supported by the drive.
CDROM_SELECT_DISC Select disc (for juke-boxes). edx should specify number of disk to load.
In case of success return value is 0, otherwise return value is -EINVAL meaning that the disk number is beyond capacity of the drive.
CDROM_MEDIA_CHANGED Check if media has been changed. edx should specify slot number to be tested, always zero except for juke-boxes. May also be special values CDSL_NONE or CDSL_CURRENT.

In case of success return value is either 0 or 1 depending whether the media has been changed, otherwise it is one of the following errno values:
-ENOSYS Drive can't detect media change.
-EINVAL Slot number beyond capacity of drive.
-ENOMEM Out of memory.
CDROM_DRIVE_STATUS Get drive status information. edx should specify slot number to be tested, always zero except for juke-boxes. May also be special values CDSL_NONE or CDSL_CURRENT.

In case of success return value is one of the following:
CDS_NO_INFO         - Information not available.
CDS_NO_DISC         - No disk present.
CDS_TRAY_OPEN       - Tray is open.
CDS_DRIVE_NOT_READY - Drive is busy.
CDS_DISC_OK         - Drive is ready.

In case of error return value is one of the following errno values:
-ENOSYS Drive can't detect drive status
-EINVAL Slot number beyond capacity of drive.
-ENOMEM Out of memory.
CDROM_DISC_STATUS Get disk status information. edx is ignored.

Return value is one of the following: CDS_NO_INFO, CDS_AUDIO, CDS_DATA_1, CDS_DATA_2, CDS_XA_2_1, CDS_XA_2_2 or CDS_MIXED.
CDROM_CHANGER_NSLOTS Get number of CD changer slots. edx is ignored.

The return value will be the number of slots in a CD changer. Typically 1 for non-multi-disk devices.
CDROM_LOCKDOOR Lock or unlock door. edx should specify the operation to perform: 1 (lock) or 0 (unlock).

In case of success return value is 0, otherwise return value is one of the following errno values:
-EDRIVE_CANT_DO_THIS Door lock function not supported.
-EBUSY Attempt to unlock when multiple users have the drive open and not CAP_SYS_ADMIN.

As of 2.6.8.1, the lock flag is a global lock, meaning that all CD drives will be locked or unlocked together. This is probably a bug.
CDROM_DEBUG Turn debug messages on/off. edx should specify the operation to perform: 1 (on) or 0 (off).

In case of success return value is the new debug flag, otherwise return value is -EACCES meaning that the access denied (requires CAP_SYS_ADMIN).
CDROM_GET_CAPABILITY Get capabilities. edx is ignored.
The return value is the current device capability flags. See CDC_CLOSE_TRAY, CDC_OPEN_TRAY, etc.
CDROMAUDIOBUFSIZ Set the audio buffer size. edx should specify new audio buffer size.

In case of success return value is the audio buffer size, otherwise return value is -ENOSYS meaning that the operation is not supported by this driver.
DVD_READ_STRUCT Read structure. edx should point to a dvd_struct [input/output] union with type member specifying the desired information: DVD_STRUCT_PHYSICAL, DVD_STRUCT_COPYRIGHT, DVD_STRUCT_DISCKEY, DVD_STRUCT_BCA, DVD_STRUCT_MANUFACT.

struc dvd_struct
{
.type:      ;rb ?
.physical:  ;dvd_physical
.copyright: ;dvd_copyright
.disckey:   ;dvd_disckey
.bca:       ;dvd_bca
.manufact   dvd_manufact
}

If DVD_STRUCT_PHYSICAL is set - physical.layer_num should be set as well (layers are indexed from 0).
If DVD_STRUCT_COPYRIGHT is set - copyright.layer_num should be set as well (layers are indexed from 0).

In case of success return value is 0, otherwise return value is one of the following errno values:
-EINVAL physical.layer_num exceeds number of layers.
-EIO Received invalid response from drive
DVD_WRITE_STRUCT Not implemented, as of 2.6.17.7
DVD_AUTH Authentication. edx should point to a dvd_authinfo [input/output] union with type member specifying the desired operation: DVD_LU_SEND_AGID, DVD_HOST_SEND_CHALLENGE, DVD_LU_SEND_KEY1, DVD_LU_SEND_CHALLENGE, DVD_HOST_SEND_KEY2, DVD_AUTH_ESTABLISHED, DVD_AUTH_FAILURE, DVD_LU_SEND_TITLE_KEY, DVD_LU_SEND_ASF, DVD_INVALIDATE_AGID, DVD_LU_SEND_RPC_STATE, DVD_HOST_SEND_RPC_STATE.

struc dvd_authinfo
{
.type:  rb 1
.lsa:   dvd_lu_send_agid
.hsc:   dvd_host_send_challenge
.lsk:   dvd_send_key
.lsc:   dvd_lu_send_challenge
.hsk:   dvd_send_key
.lsasf: dvd_lu_send_asf
.hrpcs: dvd_host_send_rpcstate
.lrpcs: sdvd_lu_send_rpcstate
.lstk   dvd_lu_send_title_key
}

In case of success return value is 0, otherwise return value is -ENOTTY meaning that the ai.type is not recognized.
CDROM_SEND_PACKET Send a packet to the drive. edx should point to a properly initialized cdrom_generic_command [input/output] structure containing the packet to send:

struc cdrom_generic_command
{
.cmd            rb CDROM_PACKET_SIZE
.buffer         rd 1
.buflen         rd 1
.stat           rd 1
.sense          rd 1
.data_direction rb 1
.quiet          rd 1
.timeout        rd 1
.reserved       rd 1
}

In case of success return value is 0, otherwise return value is one of the following errno values:
-EINVAL cgc.data_direction not set
-EIO Command failed.
-EPERM Operation not permitted, either because a write command was attempted on a drive which is opened read-only, or because the command requires CAP_SYS_RAWIO
CDROM_NEXT_WRITABLE Get next writable block. edx should point to an integer value which will receive the information.
In case of success return value is 0, otherwise if the device does not support this IOCTL directly, the IOCTL will return CDROM_LAST_WRITTEN+7.
CDROM_LAST_WRITTEN Get last block written on disc. edx should point to an integer value which will receive the information.
In case of success return value is 0, otherwise if the device does not support this IOCTL directly, the result is derived from the disc's table of contents. If the
table of contents can't be read, this IOCTL returns a negative errno value.