home *** CD-ROM | disk | FTP | other *** search
- /*
- * cd_commands.h: header file for cd_commands.c
- *
- * History
- * -------
- * Mon Sep 16 15:57:35 PDT 1991 James C. Lee at NeXT
- * Created
- */
-
- #ifndef CD_COMMANDS
- #define CD_COMMANDS
-
- #import <sys/types.h>
- #import <libc.h>
- #import <nextdev/scsireg.h>
- #import <sys/time.h>
-
- /* start/stop command (C6OP_STARTSTOP = 1Bh) */
- struct start_stop_cmd {
- u_char ssc_opcode;
- u_char ssc_lun:3,
- ssc_reserved:4,
- ssc_imm:1;
- u_int ssc_reserved2:22,
- ssc_loej:1,
- ssc_start:1,
- ssc_control:8;
- };
-
- /* read toc reply header */
- struct rtr_header {
- u_int rtr_datalength:16,
- rtr_firsttrack:8,
- rtr_lasttrack:8;
- };
-
- /* read toc reply descriptor */
- struct rtr10_desc {
- u_int t10d_reserved:12,
- t10d_control:4,
- t10d_track:8,
- t10d_reserved2:8;
- u_int t10d_hour:8,
- t10d_min:8,
- t10d_sec:8,
- t10d_frame:8;
- };
-
- /* read toc reply with one descriptor, to read more than 1 descriptor
- blocks at a time, one must allocate
- sizeof(struct rtr10_desc)*num_descriptrs+sizeof(struct_rtr_header) bytes,
- and then traverse through the memory */
-
- struct toc10_rep$
- struct rtr_header h;
- struct rtr10_desc d; /* one descriptor block */
- };
-
- /* an entry to toc info */
- struct toc_info {
- u_char control; /* control bits */
- u_int hour:8, /* msf address */
- min:8,
- sec:8,
- frame; /* not too sure what this byte is */
- };
-
- /* control bits */
- #define PRE_EMPHASIS 0x1 /* pre-emphasis or not */
- #define DIGITAL_COPY 0x2 /* digital copy permitted (1) or not (0) */
- #define DATA_TRACK 0x4 /* data track (1) or autio track (0) */
- #define FOUR_CHANNEL 0x8 /* four channel (1) or two channel (0) */
-
- /* entire table of contents */
- struct toc_all {
- u_short firsttrack:8,
- lasttrack:8;
- int naudio, /* number of audio tracks */
- ndata, /* number of data tracks */
- lastDataBlock; /* very last data block */
- struct toc_info info[101]; /* 0-99 + transition area (100) */
- };
-
- #define C10OP_READTOC 0x43 /* read toc10 command */
- /* read toc10 command (C10OP_READTOC = 43h) */
- struct readtoc10_cmd {
- u_char rt10_op_code;
- u_char rt10_lun:3,
- rt10_reserved:3,
- rt10_msf:1,
- rt10_reserved2:1;
- u_int rt10_reserved3;
- u_int rt10_starttrack:8,
- rt10_length:16,
- rt10_control:8;
- };
-
- #define C6OP_PLAYAUDIO 0xc8
- /* play audio command (C6OP_PLAYAUDIO = c8h) */
- struct playaudio_cmd {
- u_char pa_op_code;
- u_char pa_lun:3,
- pa_reserved:5;
- u_int pa_lba; /* lba to start playing */
- u_int pa_reserved2:8,
- pa_length:16,
- pa_control:8;
- };
-
- #define C10OP_PAUSE 0xc5
- /* pause audio commnad (C10OP_PAUSE = c5h) */
- struct pause_cmd {
- u_char p_op_code;
- u_int p_lun:3,
- p_pause:1,
- p_reserved:28;
- u_int p_reserved2;
- u_char p_control;
- };
-
- /* msf data format */
- struct msf {
- u_int hour:8,
- min:8,
- sec:8,
- frame:8;
- };
-
- #define C10OP_PLAYAUDIO_MSF 0x47
- /* play audio msf command (C6OP_PLAYAUDIO = 47h) */
- struct playaudio_msf_cmd {
- u_char pam_op_code;
- u_char pam_lun:3,
- pam_reserved:5;
- u_int pam_reserved2:8,
- pam_start_min:8,
- pam_start_sec:8,
- pam_start_frame:8;
- u_int pam_end_min:8,
- pam_end_sec:8,
- pam_end_frame:8,
- pam_control:8;
- };
-
- /**********************************************************
- * sub channel
- **********************************************************/
- #define C10OP_READSUBHCANNEL 0x42
- /* read sub-channel (C10OP_READSUBHCANNEL = 42h) */
- struct readsc_cmd {
- u_int rsc_op_code:8,
- rsc_lun:3,
- rsc_reserved:3,
- rsc_msf:1,
- rsc_reserved2:2$ rsc_subq:1, /* sub-channel data or not (not=just header) */
- rsc_reserved3:6,
- rsc_dformat:8;
- u_short rsc_reserved4;
- u_int rsc_track:8,
- rsc_length:16,
- rsc_control:8;
- };
-
- /* sub-channel data header */
- struct sc_header {
- u_int sch_reserved:8,
- sch_astatus:8, /* audio status */
- sch_length:16; /* sub-channel data length */
- };
-
- /* sub-channel data format page 1: CD-ROM current position data block */
- struct sc_cur_pos {
- u_int sc1_data_code:8,
- sc1_reserved:4,
- sc1_control:4,
- sc1_track:8,
- sc1_index:8;
- u_int sc1_abs_addr;
- u_int sc1_rel_addr;
- };
-
- /* sub-channel data format page 2: Media Catalog Number Data Format */
- struct sc_med_cat {
- u_int sc2_data_code:8,
- sc2_reserved:24;
- u_char sc2_mcval:1,
- sc2_reserved2:7;
- u_char sc2_med_cat[15];
- };
-
- /* sub-channel data format page 3: Track International Standard Recording Data
- Format */
- struct sc_isrc {
- u_int sc3_data_code:8,
- sc3_reserved:8,
- sc3_track:8,
- sc3_reserved2:8;
- u_char sc3_tcval:1,
- sc3_reserved3:7;
- u_char sc3_isrc[15];
- };
-
- /* sub-channel reply */
- struct sc_reply {
- struct sc_header scr_header;
- union {
- struct sc_cur_pos u_scr_cur_pos;
- struct sc_med_cat u_scr_med_cat;
- struct sc_isrc u_scr_isrc;
- }u;
- };
-
- /**********************************************************
- * playback status & playback control
- **********************************************************/
- #define C10OP_PLAYBACKCONTROL 0xc9
- #define C10OP_PLAYBACKSTATUS 0xc4
- struct playback_cmd {
- u_char pb_opcode;
- u_int pb_lun:3,
- pb_reserved:29;
- u_int pb_reserved2:16,
- pb_length:16;
- u_char pb_control;
- };
-
- struct playback_data {
- u_int pbd_reserved;
- u_int pbd_reserved2;
- u_short pbd_reserved3;
- u_int pbd_reserved4:4,
- pbd_ch0_sel:4,
- pbd_ch0_vol:8,
- pbd_reserved5:4,
- pbd_ch1_sel:4,
- pbd_ch1_vol:8;
- u_int pbd_reserved6:4,
- pbd_ch2_sel:4,
- pbd_ch2_vol:8,
- pbd_reserved7:4,
- pbd_ch3_sel:4,
- pbd_ch3_vol:8;
- };
-
- int do_eject(int fd, struct timeval *tvp, struct esense_reply *erp);
- int do_spinup(int fd, struct timeval *tvp, struct esense_reply *erp);
- int do_readtoc(int fd, int track, struct toc10_reply *tocr,
- struct esense_reply *erp);
- int do_readtoc_all(int fd, struct toc_all *toc_all, struct esense_reply *erp);
- int do_playaudio(int fd, int lba, int length, struct esense_reply *erp);
- int do_pauseaudio(int fd, $ pause, struct esense_reply *erp);
- int do_playaudio_msf(int fd, struct msf startmsf, struct msf endmsf,
- struct esense_reply *erp);
- int do_readsubchannel(int fd, int msf, int subq, int page, int track,
- struct sc_reply *scrp, struct esense_reply *erp);
- int do_playbackstatus(int fd, struct playback_data *pbdatap,
- struct esense_reply *erp);
- int do_playbackcontrol(int fd, struct playback_data *pbdatap,
- struct esense_reply *erp);
-
-
- void printf_sc(int page, struct sc_reply *scrp);
- void printf_pb(struct playback_data *pbdatap);
-
- #endif