2 .\" Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH CDIO 7I "Oct 4, 2001"
8 cdio \- CD-ROM control operations
12 \fB#include <sys/cdio.h>\fR
18 The set of \fBioctl\fR(2) commands described below are used to perform audio
19 and \fBCD-ROM\fR specific operations. Basic to these \fBcdio\fR ioctl requests
20 are the definitions in \fB<sys/cdio.h>\fR\&.
23 Several \fBCD-ROM\fR specific commands can report addresses either in \fBLBA\fR
24 (Logical Block Address) format or in \fBMSF\fR (Minute, Second, Frame) format.
25 The \fBREAD HEADER\fR, \fBREAD SUBCHANNEL\fR, and \fBREAD TABLE OF CONTENTS\fR
26 commands have this feature.
29 \fBLBA\fR format represents the logical block address for the \fBCD-ROM\fR
30 absolute address field or for the offset from the beginning of the current
31 track expressed as a number of logical blocks in a \fBCD-ROM\fR track relative
32 address field. \fBMSF\fR format represents the physical address written on
33 \fBCD-ROM\fR discs, expressed as a sector count relative to either the
34 beginning of the medium or the beginning of the current track.
38 The following \fBI/O\fR controls do not have any additional data passed into or
43 \fB\fBCDROMSTART\fR\fR
46 This \fBioctl()\fR spins up the disc and seeks to the last address requested.
55 This \fBioctl()\fR spins down the disc.
61 \fB\fBCDROMPAUSE\fR\fR
64 This \fBioctl()\fR pauses the current audio play operation.
70 \fB\fBCDROMRESUME\fR\fR
73 This \fBioctl()\fR resumes the paused audio play operation.
79 \fB\fBCDROMEJECT\fR\fR
82 This \fBioctl()\fR ejects the caddy with the disc.
88 \fB\fBCDROMCLOSETRAY\fR\fR
91 This \fBioctl()\fR closes the caddy with the disc.
96 The following \fBI/O\fR controls require a pointer to the structure for that
97 \fBioctl()\fR, with data being passed into the \fBioctl()\fR.
101 \fB\fBCDROMPLAYMSF\fR\fR
104 This \fBioctl()\fR command requests the drive to output the audio signals at
105 the specified starting address and continue the audio play until the specified
106 ending address is detected. The address is in \fBMSF\fR format. The third
107 argument of this \fBioctl()\fR call is a pointer to the type \fBstruct
113 * definition of play audio msf structure
116 unsigned char cdmsf_min0; /* starting minute*/
117 unsigned char cdmsf_sec0; /* starting second*/
118 unsigned char cdmsf_frame0; /*starting frame*/
119 unsigned char cdmsf_min1; /* ending minute */
120 unsigned char cdmsf_sec1; /* ending second */
121 unsigned char cdmsf_frame1; /* ending frame */
126 The \fBCDROMREADTOCENTRY\fR ioctl request may be used to obtain the start time
127 for a track. An approximation of the finish time can be obtained by using the
128 \fBCDROMREADTOCENTRY\fR ioctl request to retrieve the start time of the track
129 following the current track.
131 The leadout track is the next consecutive track after the last audio track.
132 Hence, the start time of the leadout track may be used as the effective finish
133 time of the last audio track.
139 \fB\fBCDROMPLAYTRKIND\fR\fR
142 This \fBioctl()\fR command is similar to \fBCDROMPLAYMSF\fR. The starting and
143 ending address is in track/index format. The third argument of the
144 \fBioctl()\fR call is a pointer to the type \fBstruct cdrom_ti\fR.
149 * definition of play audio track/index structure
152 unsigned char cdti_trk0; /* starting track*/
153 unsigned char cdti_ind0; /* starting index*/
154 unsigned char cdti_trk1; /* ending track */
155 unsigned char cdti_ind1; /* ending index */
165 \fB\fBCDROMVOLCTRL\fR\fR
168 This \fBioctl()\fR command controls the audio output level. The \fBSCSI\fR
169 command allows the control of up to four channels. The current implementation
170 of the supported \fBCD-ROM\fR drive only uses channel 0 and channel 1. The
171 valid values of volume control are between 0x00 and 0xFF, with a value of 0xFF
172 indicating maximum volume. The third argument of the \fBioctl()\fR call is a
173 pointer to \fBstruct\fR \fBcdrom_volctrl\fR which contains the output volume
179 * definition of audio volume control structure
181 struct cdrom_volctrl {
182 unsigned char channel0;
183 unsigned char channel1;
184 unsigned char channel2;
185 unsigned char channel3;
194 The following \fBI/O\fR controls take a pointer that will have data returned to
195 the user program from the \fBCD-ROM\fR driver.
199 \fB\fBCDROMREADTOCHDR\fR\fR
202 This \fBioctl()\fR command returns the header of the table of contents (TOC).
203 The header consists of the starting tracking number and the ending track number
204 of the disc. These two numbers are returned through a pointer of \fBstruct
205 cdrom_tochdr\fR. While the disc can start at any number, all tracks between the
206 first and last tracks are in contiguous ascending order.
211 * definition of read toc header structure
213 struct cdrom_tochdr {
214 unsigned char cdth_trk0; /* starting track*/
215 unsigned char cdth_trk1; /* ending track*/
225 \fB\fBCDROMREADTOCENTRY\fR\fR
228 This \fBioctl()\fR command returns the information of a specified track. The
229 third argument of the function call is a pointer to the type \fBstruct
230 cdrom_tocentry\fR. The caller needs to supply the track number and the address
231 format. This command will return a 4-bit \fBadr\fR field, a 4-bit \fBctrl\fR
232 field, the starting address in \fBMSF\fR format or \fBLBA\fR format, and the
233 data mode if the track is a data track. The \fBctrl\fR field specifies whether
234 the track is data or audio.
239 * definition of read toc entry structure
241 struct cdrom_tocentry {
242 unsigned char cdte_track;
243 unsigned char cdte_adr :4;
244 unsigned char cdte_ctrl :4;
245 unsigned char cdte_format;
248 unsigned char minute;
249 unsigned char second;
254 unsigned char cdte_datamode;
259 To get the information from the leadout track, the following value is
260 appropriate for the \fBcdte_track\fR field:
264 \fB\fBCDROM_LEADOUT\fR\fR
270 To get the information from the data track, the following value is appropriate
271 for the \fBcdte_ctrl\fR field:
275 \fB\fBCDROM_DATA_TRACK\fR\fR
281 The following values are appropriate for the \fBcdte_format\fR field:
285 \fB\fBCDROM_LBA\fR\fR
294 \fB\fBCDROM_MSF\fR\fR
305 \fB\fBCDROMSUBCHNL\fR\fR
308 This \fBioctl()\fR command reads the Q sub-channel data of the current block.
309 The subchannel data includes track number, index number, absolute \fBCD-ROM\fR
310 address, track relative \fBCD-ROM\fR address, control data and audio status.
311 All information is returned through a pointer to \fBstruct cdrom_subchnl\fR.
312 The caller needs to supply the address format for the returned address.
316 struct cdrom_subchnl {
317 unsigned char cdsc_format;
318 unsigned char cdsc_audiostatus;
319 unsigned char cdsc_adr: 4;
320 unsigned char cdsc_ctrl: 4;
321 unsigned char cdsc_trk;
322 unsigned char cdsc_ind;
325 unsigned char minute;
326 unsigned char second;
333 unsigned char minute;
334 unsigned char second;
343 The following values are valid for the audio status field returned from
344 \fBREAD\fR \fBSUBCHANNEL\fR command:
348 \fB\fBCDROM_AUDIO_INVALID\fR\fR
351 Audio status not supported.
357 \fB\fBCDROM_AUDIO_PLAY\fR\fR
360 Audio play operation in progress.
366 \fB\fBCDROM_AUDIO_PAUSED\fR\fR
369 Audio play operation paused.
375 \fB\fBCDROM_AUDIO_COMPLETED\fR\fR
378 Audio play successfully completed.
384 \fB\fBCDROM_AUDIO_ERROR\fR\fR
387 Audio play stopped due to error.
393 \fB\fBCDROM_AUDIO_NO_STATUS\fR\fR
396 No current audio status to return.
404 \fB\fBCDROMREADOFFSET\fR\fR
407 This \fBioctl()\fR command returns the absolute \fBCD-ROM\fR address of the
408 first track in the last session of a Multi-Session \fBCD-ROM\fR. The third
409 argument of the \fBioctl()\fR call is a pointer to an \fBint\fR.
415 \fB\fBCDROMCDDA\fR\fR
418 This \fBioctl()\fR command returns the \fBCD-DA\fR data or the subcode data.
419 The third argument of the \fBioctl()\fR call is a pointer to the type \fBstruct
420 cdrom_cdda\fR. In addition to allocating memory and supplying its address, the
421 caller needs to supply the starting address of the data, the transfer length in
422 terms of the number of blocks to be transferred, and the subcode options. The
423 caller also needs to issue the \fBCDROMREADTOCENTRY\fR \fBioctl()\fR to find
424 out which tracks contain \fBCD-DA\fR data before issuing this \fBioctl()\fR.
429 * Definition of CD-DA structure
432 unsigned int cdda_addr;
433 unsigned int cdda_length;
435 unsigned char cdda_subcode;
440 \fBcdda_addr\fR signifies the starting logical block address.
442 \fBcdda_length\fR signifies the transfer length in blocks. The length of the
443 block depends on the \fBcdda_subcode\fR selection, which is explained below.
445 To get the subcode information related to \fBCD-DA\fR data, the following
446 values are appropriate for the \fBcdda_subcode\fR field:
450 \fB\fBCDROM_DA_NO_SUBCODE\fR\fR
453 \fBCD-DA\fR data with no subcode.
459 \fB\fBCDROM_DA_SUBQ\fR\fR
462 \fBCD-DA\fR data with sub Q code.
468 \fB\fBCDROM_DA_ALL_SUBCODE\fR\fR
471 \fBCD-DA\fR data with all subcode.
477 \fB\fBCDROM_DA_SUBCODE_ONLY\fR\fR
483 To allocate the memory related to \fBCD-DA\fR and/or subcode data, the
484 following values are appropriate for each data block transferred:
488 \fB\fBCD-DA\fR data with no subcode\fR
498 \fB\fBCD-DA\fR data with sub Q code\fR
508 \fB\fBCD-DA\fR data with all subcode\fR
518 \fBAll subcode only\fR
530 \fB\fBCDROMCDXA\fR\fR
533 This \fBioctl()\fR command returns the \fBCD-ROM\fR \fBXA\fR (CD-ROM Extended
534 Architecture) data according to \fBCD-ROM\fR \fBXA\fR format. The third
535 argument of the \fBioctl()\fR call is a pointer to the type \fBstruct
536 cdrom_cdxa\fR. In addition to allocating memory and supplying its address, the
537 caller needs to supply the starting address of the data, the transfer length
538 in terms of number of blocks, and the format. The caller also needs to issue
539 the \fBCDROMREADTOCENTRY\fR \fBioctl()\fR to find out which tracks contain
540 \fBCD-ROM\fR \fBXA\fR data before issuing this \fBioctl()\fR.
545 * Definition of CD-ROM XA structure
548 unsigned int cdxa_addr;
549 unsigned int cdxa_length;
551 unsigned char cdxa_format;
556 To get the proper \fBCD-ROM\fR \fBXA\fR data, the following values are
557 appropriate for the \fBcdxa_format\fR field:
561 \fB\fBCDROM_XA_DATA\fR\fR
564 \fBCD-ROM\fR \fBXA\fR data only
570 \fB\fBCDROM_XA_SECTOR_DATA\fR\fR
573 \fBCD-ROM\fR \fBXA\fR all sector data
579 \fB\fBCDROM_XA_DATA_W_ERROR\fR\fR
582 \fBCD-ROM\fR \fBXA\fR data with error flags data
585 To allocate the memory related to \fBCD-ROM\fR \fBXA\fR format, the following
586 values are appropriate for each data block transferred:
590 \fB\fBCD-ROM XA\fR data only\fR
600 \fB\fBCD-ROM XA\fR all sector data\fR
610 \fB\fBCD-ROM XA\fR data with error flags data\fR
622 \fB\fBCDROMSUBCODE\fR\fR
625 This \fBioctl()\fR command returns raw subcode data (subcodes P ~ W are
626 described in the "Red Book," see \fBSEE ALSO\fR) to the initiator while the
627 target is playing audio. The third argument of the \fBioctl()\fR call is a
628 pointer to the type \fBstruct cdrom_subcode\fR. The caller needs to supply the
629 transfer length in terms of number of blocks and allocate memory for subcode
630 data. The memory allocated should be a multiple of 96 bytes depending on the
636 * Definition of subcode structure
638 struct cdrom_subcode {
639 unsigned int cdsc_length;
649 The next group of \fBI/O\fR controls get and set various \fBCD-ROM\fR drive
654 \fB\fBCDROMGBLKMODE\fR\fR
657 This \fBioctl()\fR command returns the current block size used by the
658 \fBCD-ROM\fR drive. The third argument of the \fBioctl()\fR call is a pointer
665 \fB\fBCDROMSBLKMODE\fR\fR
668 This \fBioctl()\fR command requests the \fBCD-ROM\fR drive to change from the
669 current block size to the requested block size. The third argument of the
670 \fBioctl()\fR call is an integer which contains the requested block size.
672 This \fBioctl()\fR command operates in exclusive-use mode only. The caller must
673 ensure that no other processes can operate on the same \fBCD-ROM\fR device
674 before issuing this \fBioctl()\fR. \fBread\fR(2) behavior subsequent to this
675 \fBioctl()\fR remains the same: the caller is still constrained to read the raw
676 device on block boundaries and in block multiples.
678 To set the proper block size, the following values are appropriate:
682 \fB\fBCDROM_BLK_512\fR\fR
691 \fB\fBCDROM_BLK_1024\fR\fR
700 \fB\fBCDROM_BLK_2048\fR\fR
709 \fB\fBCDROM_BLK_2056\fR\fR
718 \fB\fBCDROM_BLK_2336\fR\fR
727 \fB\fBCDROM_BLK_2340\fR\fR
736 \fB\fBCDROM_BLK_2352\fR\fR
745 \fB\fBCDROM_BLK_2368\fR\fR
754 \fB\fBCDROM_BLK_2448\fR\fR
763 \fB\fBCDROM_BLK_2646\fR\fR
772 \fB\fBCDROM_BLK_2647\fR\fR
783 \fB\fBCDROMGDRVSPEED\fR\fR
786 This \fBioctl()\fR command returns the current \fBCD-ROM\fR drive speed. The
787 third argument of the \fBioctl()\fR call is a pointer to an integer.
793 \fB\fBCDROMSDRVSPEED\fR\fR
796 This \fBioctl()\fR command requests the \fBCD-ROM\fR drive to change the
797 current drive speed to the requested drive speed. This speed setting is only
798 applicable when reading data areas. The third argument of the \fBioctl()\fR is
799 an integer which contains the requested drive speed.
801 To set the \fBCD-ROM\fR drive to the proper speed, the following values are
806 \fB\fBCDROM_NORMAL_SPEED\fR\fR
815 \fB\fBCDROM_DOUBLE_SPEED\fR\fR
824 \fB\fBCDROM_QUAD_SPEED\fR\fR
833 \fB\fBCDROM_MAXIMUM_SPEED\fR\fR
836 300k/second (2x drive) 600k/second (4x drive)
839 Note that these numbers are only accurate when reading 2048 byte blocks. The
840 \fBCD-ROM\fR drive will automatically switch to normal speed when playing audio
841 tracks and will switch back to the speed setting when accessing data.
847 \fBioctl\fR(2), \fBread\fR(2)
850 N. V. Phillips and Sony Corporation, \fISystem Description Compact Disc Digital
851 Audio\fR, ("Red Book").
854 N. V. Phillips and Sony Corporation, \fISystem Description of Compact Disc Read
855 Only Memory\fR, ("Yellow Book").
858 N. V. Phillips, Microsoft, and Sony Corporation, \fISystem Description CD-ROM
862 \fIVolume and File Structure of CD-ROM for Information Interchange\fR, ISO
866 \fISCSI-2\fR \fIStandard,\fR \fIdocument\fR \fIX3T9.2/86-109\fR
869 \fISCSI Multimedia Commands, Version 2 (MMC-2)\fR
873 The \fBCDROMCDDA\fR, \fBCDROMCDXA\fR, \fBCDROMSUBCODE\fR,
874 \fBCDROMGDRVSPEED\fR, \fBCDROMSDRVSPEED\fR, and some of the block sizes in
875 \fBCDROMSBLKMODE\fR are designed for new Sun-supported \fBCD-ROM\fR drives and
876 might not work on some of the older \fBCD-ROM\fR drives.
879 CDROMCDDA, CDROMCDXA and CDROMSUBCODE will return error if the transfer length
880 exceeds valid limits as determined appropriate. Example: for MMC-2 drives,
881 length can not exceed 3 bytes (i.e. 0xffffff). The same restriction is
882 enforced for older, pre-MMC-2 drives, as no limit was published for these older
883 drives (and 3 bytes is reasonable for all media). Note that enforcing this
884 limit does not imply that values passed in below this limit will actually be
885 applicable for each and every piece of media.
888 The interface to this device is preliminary and subject to change in future
889 releases. Programs should be written in a modular fashion so that future
890 changes can be easily incorporated.