CDIO(4I) | Ioctl Requests | CDIO(4I) |
cdio
— CD-ROM
control operations
#include
<sys/cdio.h>
The set of ioctl(2) commands
described below are used to perform audio and CD-ROM
specific operations. Basic to these
cdio ioctl
requests are the definitions in
<sys/cdio.h>
.
Several CD-ROM specific commands can report addresses either in LBA (Logical Block Address) format or in MSF (Minute, Second, Frame) format. The READ HEADER, BREAD SUBCHANNEL, and BREAD TABLE OF CONTENTS commands have this feature.
LBA format represents the logical block address for the CD-ROM absolute address field or for the offset from the beginning of the current track expressed as a number of logical blocks in a CD-ROM track relative address field. MSF format represents the physical address written on CD-ROM discs, expressed as a sector count relative to either the beginning of the medium or the beginning of the current track.
The following I/O controls do not have any additional data passed into or received from them.
CDROMSTART
CDROMSTOP
CDROMPAUSE
CDROMRESUME
CDROMEJECT
CDROMCLOSETRAY
The following I/O controls require a pointer to the structure for that ioctl(2), with data being passed into the ioctl(2).
CDROMPLAYMSF
/* * definition of play audio msf structure */ struct cdrom_msf { /* starting minute */ unsigned char cdmsf_min0; /* starting second */ unsigned char cdmsf_sec0; /* starting frame */ unsigned char cdmsf_frame0; /* ending minute */ unsigned char cdmsf_min1; /* ending second */ unsigned char cdmsf_sec1; /* ending frame */ unsigned char cdmsf_frame1; };
The CDROMREADTOCENTRY
ioctl request
may be used to obtain the start time for a track. An approximation of
the finish time can be obtained by using the
CDROMREADTOCENTRY
ioctl request to retrieve the
start time of the track following the current track.
The leadout track is the next consecutive track after the last audio track. Hence, the start time of the leadout track may be used as the effective finish time of the last audio track.
CDROMPLAYTRKIND
CDROMPLAYMSF
. The starting and ending address is
in track/index format. The third argument of the
ioctl(2) call is a pointer to the
type struct cdrom_ti.
/* * definition of play audio track/index structure */ struct cdrom_ti { /* starting track */ unsigned char cdti_trk0; /* starting index */ unsigned char cdti_ind0; /* ending track */ unsigned char cdti_trk1; /* ending index */ unsigned char cdti_ind1; };
CDROMVOLCTRL
/* * definition of audio volume control structure */ struct cdrom_volctrl { unsigned char channel0; unsigned char channel1; unsigned char channel2; unsigned char channel3; };
The following I/O controls take a pointer that will have data returned to the user program from the CD-ROM driver.
CDROMREADTOCHDR
/* * definition of read toc header structure */ struct cdrom_tochdr { unsigned char cdth_trk0; /* starting track */ unsigned char cdth_trk1; /* ending track */ };
CDROMREADTOCENTRY
/* * definition of read toc entry structure */ struct cdrom_tocentry { unsigned char cdte_track; unsigned char cdte_adr :4; unsigned char cdte_ctrl :4; unsigned char cdte_format; union { struct { unsigned char minute; unsigned char second; unsigned char frame; } msf; int lba; } cdte_addr; unsigned char cdte_datamode; };
To get the information from the leadout track, the following value is appropriate for the cdte_track field:
CDROM_LEADOUT
To get the information from the data track, the following value is appropriate for the cdte_ctrl field:
CDROM_DATA_TRACK
The following values are appropriate for the cdte_format field:
CDROMSUBCHNL
struct cdrom_subchnl { unsigned char cdsc_format; unsigned char cdsc_audiostatus; unsigned char cdsc_adr :4; unsigned char cdsc_ctrl :4; unsigned char cdsc_trk; unsigned char cdsc_ind; union { struct { unsigned char minute; unsigned char second; unsigned char frame; } msf; int lba; } cdsc_absaddr; union { struct { unsigned char minute; unsigned char second; unsigned char frame; } msf; int lba; } cdsc_reladdr; };
The following values are valid for the audio status field returned from READ SUBCHANNEL command:
CDROM_AUDIO_INVALID
CDROM_AUDIO_PLAY
CDROM_AUDIO_PAUSED
CDROM_AUDIO_COMPLETED
CDROM_AUDIO_ERROR
CDROM_AUDIO_NO_STATUS
CDROMREADOFFSET
CDROMCDDA
CDROMREADTOCENTRY
ioctl(2) to find out which tracks
contain CD-DA data before issuing this
ioctl(2).
/* * Definition of CD-DA structure */ struct cdrom_cdda { unsigned int cdda_addr; unsigned int cdda_length; caddr_t cdda_data; unsigned char cdda_subcode; };
cdda_addr signifies the starting logical block address. cdda_length signifies the transfer length in blocks. The length of the block depends on the cdda_subcode selection, which is explained below. To get the subcode information related to CD-DA data, the following values are appropriate for the cdda_subcode field:
To allocate the memory related to CD-DA and/or subcode data, the following values are appropriate for each data block transferred:
CDROMCDXA
/* * Definition of CD-ROM XA structure */ struct cdrom_cdxa { unsigned int cdxa_addr; unsigned int cdxa_length; caddr_t cdxa_data; unsigned char cdxa_format; };
To get the proper CD-ROM XA data, the following values are appropriate for the cdxa_format field:
CDROM_XA_DATA
CDROM_XA_SECTOR_DATA
CDROM_XA_DATA_W_ERROR
To allocate the memory related to CD-ROM XA format, the following values are appropriate for each data block transferred:
CDROMSUBCODE
/* * Definition of subcode structure */ struct cdrom_subcode { unsigned int cdsc_length; caddr_t cdsc_addr; };
The next group of I/O controls get and set various CD-ROM drive parameters.
CDROMGBLKMODE
CDROMSBLKMODE
CDROM_BLK_512
CDROM_BLK_1024
CDROM_BLK_2048
CDROM_BLK_2056
CDROM_BLK_2336
CDROM_BLK_2340
CDROM_BLK_2352
CDROM_BLK_2368
CDROM_BLK_2448
CDROM_BLK_2646
CDROM_BLK_2647
CDROMGDRVSPEED
CDROMSDRVSPEED
CDROM_NORMAL_SPEED
CDROM_DOUBLE_SPEED
CDROM_QUAD_SPEED
CDROM_MAXIMUM_SPEED
600k/second (4x drive)
Note that these numbers are only accurate when reading 2048 byte blocks. The CD-ROM drive will automatically switch to normal speed when playing audio tracks and will switch back to the speed setting when accessing data.
All
Uncommitted
ioctl(2), read(2), attributes(7)
System Description Compact Disc Digital Audio, N. V. Phillips, Sony Corporation, ("Red Book").
System Description of Compact Disc Read Only Memory, N. V. Phillips, Sony Corporation, ("Yellow Book").
System Description CD-ROM XA, N. V. Phillips, Microsoft, Sony Corporation, 1991.
Volume and File Structure of CD-ROM for Information Interchange, ISO 9660:1988(E).
SCSI-2 Standard, document X3T9.2/86-109.
SCSI Multimedia Commands, Version 2 (MMC-2).
The CDROMCDDA
,
CDROMCDXA
, CDROMSUBCODE
,
CDROMGDRVSPEED
,
CDROMSDRVSPEED
, and some of the block sizes in
CDROMSBLKMODE
are designed for new Sun-supported
CD-ROM drives and might not work on some of the older
CD-ROM drives.
CDROMCDDA
,
CDROMCDXA
, and CDROMSUBCODE
will return error if the transfer length exceeds valid limits as determined
appropriate. Example: for MMC-2 drives, length can not exceed 3 bytes (i.e.
0xffffff). The same restriction is enforced for older, pre-MMC-2 drives, as
no limit was published for these older drives (and 3 bytes is reasonable for
all media). Note that enforcing this limit does not imply that values passed
in below this limit will actually be applicable for each and every piece of
media.
The interface to this device is preliminary and subject to change in future releases. Programs should be written in a modular fashion so that future changes can be easily incorporated.
October 22, 2017 | OmniOS |