Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ cdio(7) — SunOS 5.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ioctl(2)

sd(7)

cdio(7)

NAME

cdio − CDROM control operations

SYNOPSIS

#include <sys/cdio.h>

DESCRIPTION

A SCSI driver sd(7) supports most of this set of ioctl(2) commands for audio operations and CDROM specific operations.  Basic to these cdio ioctl() requests are the definitions in <sys/cdio.h>. 

Several CDROM specific commands can report addresses either in LBA format or in MSF format.  The READ HEADER , READ SUBCHANNEL , and READ TABLE OF CONTENTS commands have this feature. 

LBA format represents logical block address for the CDROM absolute address field or for the offset from the beginning of the current track expressed as a number of logical blocks in a CDROM track relative address field.  MSF format represents physical address written on CDROM discs.  Expressed as a sector count relative to either the beginning of the medium or to the beginning of the current track. 

IOCTLS

The following ioctl()s do not have any additional data passed into or received from them. 

CDROMSTART This ioctl() spins up the disc and seeks to the last address requested. 

CDROMSTOP This ioctl() spins down the disc. 

CDROMPAUSE This ioctl() pauses the current audio play operation. 

CDROMRESUME This ioctl() resumes the paused audio play operation. 

CDROMEJECT This ioctl() ejects the caddy with the disc. 

The following ioctl()s require a pointer to the structure for that ioctl, with data being passed into the ioctl. 

CDROMPLAYMSF This ioctl() command requests the drive to output the audio signals at the specified starting address and continue the audio play until the specified ending address is detected.  The address is in MSF (minute, second, frame) format.  The third argument of the ioctl() call is a pointer to the type struct cdrom_msf. 

/∗
 ∗ definition of play audio msf structure
 ∗/
struct cdrom_msf {
unsigned charcdmsf_min0;/∗ starting minute ∗/
unsigned charcdmsf_sec0;/∗ starting second ∗/
unsigned charcdmsf_frame0;/∗ starting frame ∗/
unsigned charcdmsf_min1;/∗ ending minute ∗/
unsigned charcdmsf_sec1;/∗ ending second ∗/
unsigned charcdmsf_frame1;/∗ ending frame ∗/
};

CDROMPLAYTRKIND
This ioctl() command is similar to CDROMPLAYMSF.  The starting and ending address is in track/index format.  The third argument of the ioctl() call is a pointer to the type struct cdrom_ti. 

/∗
 ∗ definition of play audio track/index structure
 ∗/
struct cdrom_ti {
unsigned charcdti_trk0;/∗ starting track ∗/
unsigned charcdti_ind0;/∗ starting index ∗/
unsigned charcdti_trk1;/∗ ending track ∗/
unsigned charcdti_ind1;/∗ ending index ∗/
};

CDROMVOLCTRL This ioctl() command controls the audio output level.  The SCSI command allows the control of up to 4 channels.  The current implementation of the supported CDROM drive only uses channel 0 and channel 1.  The valid values of volume control are between 0x00 and 0xFF, with a value of 0xFF indicating maximum volume.  The third argument of the ioctl() call is a pointer to struct cdrom_volctrl which contains the output volume values. 

/∗
 ∗ definition of audio volume control structure
 ∗/
struct cdrom_volctrl {
unsigned charchannel0;
unsigned charchannel1;
unsigned charchannel2;
unsigned charchannel3;
};

The next group of ioctl() commands take a pointer that will have data returned to the user program from the CDROM driver. 

CDROMREADTOCHDR
This ioctl() command returns the header of the TOC (table of contents).  The header consists of the starting tracking number and the ending track number of the disc.  These two numbers are returned through a pointer of struct cdrom_tochdr.  While the disc can start at any number, all tracks between the first and last tracks are in contiguous ascending order. 

/∗
 ∗ definition of read toc header structure
 ∗/
struct cdrom_tochdr {
unsigned charcdth_trk0;/∗ starting track ∗/
unsigned charcdth_trk1;/∗ ending track ∗/
};

CDROMREADTOCENTRY
This ioctl() command returns the information of a specified track.  The third argument of the function call is a pointer to the type struct cdrom_tocentry.  The caller need to supply the track number and the address format.  This command will return a 4-bit adr field, a 4-bit ctrl field, the starting address in MSF format or LBA format, and the data mode if the track is a data track.  The ctrl field specifies whether the track is data or audio.  To get information for the lead-out area, supply the ioctl() command with the track field set to CDROM_LEADOUT (0xAA). 

/∗
 ∗ definition of read toc entry structure
 ∗/
struct cdrom_tocentry {
unsigned charcdte_track;
unsigned charcdte_adr:4;
unsigned charcdte_ctrl:4;
unsigned charcdte_format;
union {
struct {
unsigned charminute;
unsigned charsecond;
unsigned charframe;
} msf;
intlba;
} cdte_addr;
unsigned charcdte_datamode;
};

To get the information from leadout track, the following value is appropriate for cdte_track field:

CDROM_LEADOUT Leadout track

To get the information form data track, the following value is appropriate for cdte_ctrl field:

CDROM_DATA_TRACK
Data track

The following values are appropriate for cdte_adr field:

CDROM_LBA LBA format

CDROM_MSF MSF format

CDROMSUBCHNL This ioctl() command reads the Q sub-channel data of the current block.  The sub-channel data includes track number, index number, absolute CDROM address, track relative CDROM address, control data and audio status.  All information is returned through a pointer to struct cdrom_subchnl.  The caller needs to supply the address format for the returned address. 

struct cdrom_subchnl {
unsigned charcdsc_format;
unsigned charcdsc_audiostatus;
unsigned charcdsc_adr:4;
unsigned charcdsc_ctrl:4;
unsigned charcdsc_trk;
unsigned charcdsc_ind;
union {
struct {
unsigned charminute;
unsigned charsecond;
unsigned charframe;
} msf;
intlba;
} cdsc_absaddr;
union {
struct {
unsigned charminute;
unsigned charsecond;
unsigned charframe;
} msf;
intlba;
} cdsc_reladdr;
};

The following values are valid for audio status field returned from READ SUBCHANNEL command:

CDROM_AUDIO_INVALID Audio status not supported

CDROM_AUDIO_PLAY Audio play operation in progress

CDROM_AUDIO_PAUSED Audio play operation paused

CDROM_AUDIO_COMPLETED
Audio play successfully completed

CDROM_AUDIO_ERROR Audio play stopped due to error

CDROM_AUDIO_NO_STATUS
No current audio status to return

CDROMREADOFFSET
This ioctl() command returns the absolute CDROM address of the first track in the last session of a Multi-Session CDROM . The third argument of the ioctl() call is a pointer to an int .

SEE ALSO

ioctl(2), sd(7)

SCSI-2 Standard, document X3T9.2/86-109

NOTES

The interface to this device is preliminary and subject to change in future releases.  You are encouraged to write your programs in a modular fashion so that you can easily incorporate future changes. 

SunOS 5.2  —  Last change: 19 February 1993

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026