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, READ SUBCHANNEL, and READ 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(), with data being passed into the ioctl().
CDROMPLAYMSF
/* * definition of play audio msf structure */ struct cdrom_msf { unsigned char cdmsf_min0; /* starting minute*/ unsigned char cdmsf_sec0; /* starting second*/ unsigned char cdmsf_frame0; /*starting frame*/ unsigned char cdmsf_min1; /* ending minute */ unsigned char cdmsf_sec1; /* ending second */ unsigned char cdmsf_frame1; /* ending frame */ };
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
/* * definition of play audio track/index structure */ struct cdrom_ti { unsigned char cdti_trk0; /* starting track*/ unsigned char cdti_ind0; /* starting index*/ unsigned char cdti_trk1; /* ending track */ unsigned char cdti_ind1; /* ending index */ };
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:
CDROM_LBA
CDROM_MSF
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
/* * 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:
CDROM_DA_NO_SUBCODE
CDROM_DA_SUBQ
CDROM_DA_ALL_SUBCODE
CDROM_DA_SUBCODE_ONLY
To allocate the memory related to CD-DA and/or subcode data, the following values are appropriate for each data block transferred:
CD-DA data with no subcode
CD-DA data with sub Q code
CD-DA data with all subcode
All subcode only
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:
CD-ROM XA data only
CD-ROM XA all sector data
CD-ROM XA data with error flags data
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
This ioctl() command operates in exclusive-use mode only. The caller must ensure that no other processes can operate on the same CD-ROM device before issuing this ioctl(). read(2) behavior subsequent to this ioctl() remains the same: the caller is still constrained to read the raw device on block boundaries and in block multiples.
To set the proper block size, the following values are appropriate:
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
To set the CD-ROM drive to the proper speed, the following values are appropriate:
CDROM_NORMAL_SPEED
CDROM_DOUBLE_SPEED
CDROM_QUAD_SPEED
CDROM_MAXIMUM_SPEED
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.
N. V. Phillips and Sony Corporation, System Description Compact Disc Digital Audio, ("Red Book").
N. V. Phillips and Sony Corporation, System Description of Compact Disc Read Only Memory, ("Yellow Book").
N. V. Phillips, Microsoft, and Sony Corporation, System Description CD-ROM XA, 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.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |