| 1 | /*	$OpenBSD: cd.h,v 1.28 2019/11/29 14:06:21 krw Exp $	*/ |
| 2 | /*	$NetBSD: scsi_cd.h,v 1.6 1996/03/19 03:06:39 mycroft Exp $	*/ |
| 3 | |
| 4 | /* |
| 5 | * Written by Julian Elischer (julian@tfs.com) |
| 6 | * for TRW Financial Systems. |
| 7 | * |
| 8 | * TRW Financial Systems, in accordance with their agreement with Carnegie |
| 9 | * Mellon University, makes this software available to CMU to distribute |
| 10 | * or use in any manner that they see fit as long as this message is kept with |
| 11 | * the software. For this reason TFS also grants any other persons or |
| 12 | * organisations permission to use or modify this software. |
| 13 | * |
| 14 | * TFS supplies this software to be publicly redistributed |
| 15 | * on the understanding that TFS is not responsible for the correct |
| 16 | * functioning of this software in any circumstances. |
| 17 | * |
| 18 | * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 |
| 19 | */ |
| 20 | #ifndef	_SCSI_CD_H |
| 21 | #define _SCSI_CD_H |
| 22 | |
| 23 | /* |
| 24 | *	Define two bits always in the same place in byte 2 (flag byte) |
| 25 | */ |
| 26 | #define	CD_RELADDR	0x01 |
| 27 | #define	CD_MSF		0x02 |
| 28 | |
| 29 | /* |
| 30 | * SCSI command format |
| 31 | */ |
| 32 | |
| 33 | struct scsi_blank { |
| 34 | 	u_int8_t opcode; |
| 35 | 	u_int8_t byte2; |
| 36 | #define BLANK_DISC	0 |
| 37 | #define BLANK_MINIMAL	1 |
| 38 | 	u_int8_t addr[4]; |
| 39 | 	u_int8_t unused[5]; |
| 40 | 	u_int8_t control; |
| 41 | }; |
| 42 | |
| 43 | struct scsi_close_track { |
| 44 | 	u_int8_t opcode; |
| 45 | 	u_int8_t flags; |
| 46 | #define CT_IMMED	1 |
| 47 | 	u_int8_t closefunc; |
| 48 | #define CT_CLOSE_TRACK	1 |
| 49 | #define CT_CLOSE_SESS	2 |
| 50 | #define CT_CLOSE_BORDER 3 |
| 51 | 	u_int8_t unused; |
| 52 | 	u_int8_t track[2]; |
| 53 | 	u_int8_t unused1[3]; |
| 54 | 	u_int8_t control; |
| 55 | }; |
| 56 | |
| 57 | struct scsi_pause { |
| 58 | 	u_int8_t opcode; |
| 59 | 	u_int8_t byte2; |
| 60 | 	u_int8_t unused[6]; |
| 61 | 	u_int8_t resume; |
| 62 | 	u_int8_t control; |
| 63 | }; |
| 64 | #define	PA_PAUSE	1 |
| 65 | #define PA_RESUME	0 |
| 66 | |
| 67 | struct scsi_play_msf { |
| 68 | 	u_int8_t opcode; |
| 69 | 	u_int8_t byte2; |
| 70 | 	u_int8_t unused; |
| 71 | 	u_int8_t start_m; |
| 72 | 	u_int8_t start_s; |
| 73 | 	u_int8_t start_f; |
| 74 | 	u_int8_t end_m; |
| 75 | 	u_int8_t end_s; |
| 76 | 	u_int8_t end_f; |
| 77 | 	u_int8_t control; |
| 78 | }; |
| 79 | |
| 80 | struct scsi_play_track { |
| 81 | 	u_int8_t opcode; |
| 82 | 	u_int8_t byte2; |
| 83 | 	u_int8_t unused[2]; |
| 84 | 	u_int8_t start_track; |
| 85 | 	u_int8_t start_index; |
| 86 | 	u_int8_t unused1; |
| 87 | 	u_int8_t end_track; |
| 88 | 	u_int8_t end_index; |
| 89 | 	u_int8_t control; |
| 90 | }; |
| 91 | |
| 92 | struct scsi_play { |
| 93 | 	u_int8_t opcode; |
| 94 | 	u_int8_t byte2; |
| 95 | 	u_int8_t blk_addr[4]; |
| 96 | 	u_int8_t unused; |
| 97 | 	u_int8_t xfer_len[2]; |
| 98 | 	u_int8_t control; |
| 99 | }; |
| 100 | |
| 101 | struct scsi_play_big { |
| 102 | 	u_int8_t opcode; |
| 103 | 	u_int8_t byte2;	/* same as above */ |
| 104 | 	u_int8_t blk_addr[4]; |
| 105 | 	u_int8_t xfer_len[4]; |
| 106 | 	u_int8_t unused; |
| 107 | 	u_int8_t control; |
| 108 | }; |
| 109 | |
| 110 | struct scsi_play_rel_big { |
| 111 | 	u_int8_t opcode; |
| 112 | 	u_int8_t byte2;	/* same as above */ |
| 113 | 	u_int8_t blk_addr[4]; |
| 114 | 	u_int8_t xfer_len[4]; |
| 115 | 	u_int8_t track; |
| 116 | 	u_int8_t control; |
| 117 | }; |
| 118 | |
| 119 | struct scsi_read_header { |
| 120 | 	u_int8_t opcode; |
| 121 | 	u_int8_t byte2; |
| 122 | 	u_int8_t blk_addr[4]; |
| 123 | 	u_int8_t unused; |
| 124 | 	u_int8_t data_len[2]; |
| 125 | 	u_int8_t control; |
| 126 | }; |
| 127 | |
| 128 | struct scsi_read_subchannel { |
| 129 | 	u_int8_t opcode; |
| 130 | 	u_int8_t byte2; |
| 131 | 	u_int8_t byte3; |
| 132 | #define	SRS_SUBQ	0x40 |
| 133 | 	u_int8_t subchan_format; |
| 134 | 	u_int8_t unused[2]; |
| 135 | 	u_int8_t track; |
| 136 | 	u_int8_t data_len[2]; |
| 137 | 	u_int8_t control; |
| 138 | }; |
| 139 | |
| 140 | struct scsi_read_toc { |
| 141 | 	u_int8_t opcode; |
| 142 | 	u_int8_t byte2; |
| 143 | 	u_int8_t unused[4]; |
| 144 | 	u_int8_t from_track; |
| 145 | 	u_int8_t data_len[2]; |
| 146 | 	u_int8_t control; |
| 147 | }; |
| 148 | |
| 149 | struct scsi_read_track_info { |
| 150 | 	u_int8_t opcode; |
| 151 | 	u_int8_t addrtype; |
| 152 | #define RTI_LBA		0 |
| 153 | #define RTI_TRACK	1 |
| 154 | #define RTI_BORDER	2 |
| 155 | 	u_int8_t addr[4]; |
| 156 | 	u_int8_t unused; |
| 157 | 	u_int8_t data_len[2]; |
| 158 | 	u_int8_t control; |
| 159 | }; |
| 160 | |
| 161 | struct scsi_load_unload { |
| 162 | 	u_int8_t opcode; |
| 163 | 	u_int8_t reserved; |
| 164 | #define	IMMED	0x1 |
| 165 | 	u_int8_t reserved2[2]; |
| 166 | 	u_int8_t options; |
| 167 | #define START	0x1 |
| 168 | #define	LOUNLO	0x2 |
| 169 | 	u_int8_t reserved4[3]; |
| 170 | 	u_int8_t slot; |
| 171 | 	u_int8_t reserved5[2]; |
| 172 | 	u_int8_t control; |
| 173 | }; |
| 174 | |
| 175 | struct scsi_set_cd_speed { |
| 176 | 	u_int8_t opcode; |
| 177 | 	u_int8_t rotation; |
| 178 | #define ROTATE_CLV 0 |
| 179 | #define ROTATE_CAV 1 |
| 180 | 	u_int8_t read[2]; |
| 181 | 	u_int8_t write[2]; |
| 182 | 	u_int8_t reserved[5]; |
| 183 | 	u_int8_t control; |
| 184 | }; |
| 185 | |
| 186 | /* |
| 187 | * Opcodes |
| 188 | */ |
| 189 | |
| 190 | #define READ_SUBCHANNEL		0x42	/* cdrom read Subchannel */ |
| 191 | #define READ_TOC		0x43	/* cdrom read TOC */ |
| 192 | #define READ_HEADER		0x44	/* cdrom read header */ |
| 193 | #define PLAY			0x45	/* cdrom play 'play audio' mode */ |
| 194 | #define PLAY_MSF		0x47	/* cdrom play Min,Sec,Frames mode */ |
| 195 | #define PLAY_TRACK		0x48	/* cdrom play track/index mode */ |
| 196 | #define PLAY_TRACK_REL		0x49	/* cdrom play track/index mode */ |
| 197 | #define PAUSE			0x4b	/* cdrom pause in 'play audio' mode */ |
| 198 | #define READ_TRACK_INFO		0x52	/* read track/rzone info */ |
| 199 | #define CLOSE_TRACK		0x5b	/* close track/rzone/session/border */ |
| 200 | #define BLANK			0xa1	/* cdrom blank */ |
| 201 | #define PLAY_BIG		0xa5	/* cdrom pause in 'play audio' mode */ |
| 202 | #define LOAD_UNLOAD		0xa6	/* cdrom load/unload media */ |
| 203 | #define PLAY_TRACK_REL_BIG	0xa9	/* cdrom play track/index mode */ |
| 204 | #define SET_CD_SPEED		0xbb	/* set cdrom read/write speed */ |
| 205 | |
| 206 | /* |
| 207 | * Mode pages |
| 208 | */ |
| 209 | |
| 210 | #define ERR_RECOVERY_PAGE	0x01 |
| 211 | #define WRITE_PARAM_PAGE	0x05 |
| 212 | #define AUDIO_PAGE		0x0e |
| 213 | #define CDVD_CAPABILITIES_PAGE	0x2a |
| 214 | |
| 215 | struct cd_audio_page { |
| 216 | 	u_int8_t page_code; |
| 217 | #define	CD_PAGE_CODE	0x3F |
| 218 | #define	CD_PAGE_PS	0x80 |
| 219 | 	u_int8_t param_len; |
| 220 | 	u_int8_t flags; |
| 221 | #define		CD_PA_SOTC	0x02 |
| 222 | #define		CD_PA_IMMED	0x04 |
| 223 | 	u_int8_t unused[2]; |
| 224 | 	u_int8_t format_lba; |
| 225 | #define		CD_PA_FORMAT_LBA	0x0F |
| 226 | #define		CD_PA_APR_VALID	0x80 |
| 227 | 	u_int8_t lb_per_sec[2]; |
| 228 | 	struct	port_control { |
| 229 | 		u_int8_t channels; |
| 230 | #define	CHANNEL 0x0F |
| 231 | #define	CHANNEL_0 1 |
| 232 | #define	CHANNEL_1 2 |
| 233 | #define	CHANNEL_2 4 |
| 234 | #define	CHANNEL_3 8 |
| 235 | #define	LEFT_CHANNEL	CHANNEL_0 |
| 236 | #define	RIGHT_CHANNEL	CHANNEL_1 |
| 237 | #define MUTE_CHANNEL 0x0 |
| 238 | #define BOTH_CHANNEL LEFT_CHANNEL | RIGHT_CHANNEL |
| 239 | 		u_int8_t volume; |
| 240 | 	} port[4]; |
| 241 | #define	LEFT_PORT	0 |
| 242 | #define	RIGHT_PORT	1 |
| 243 | }; |
| 244 | |
| 245 | /* |
| 246 | * There are 2352 bytes in a CD digital audio frame. One frame is 1/75 of a |
| 247 | * second, at 44.1kHz sample rate, 16 bits/sample, 2 channels. |
| 248 | * |
| 249 | * The frame data have the two channels interleaved, with the left |
| 250 | * channel first. Samples are little endian 16-bit signed values. |
| 251 | */ |
| 252 | #define CD_DA_BLKSIZ		2352	/* # bytes in CD-DA frame */ |
| 253 | #define CD_NORMAL_DENSITY_CODE	0x00	/* from Toshiba CD-ROM specs */ |
| 254 | #define CD_DA_DENSITY_CODE	0x82	/* from Toshiba CD-ROM specs */ |
| 255 | |
| 256 | struct scsi_read_dvd_structure { |
| 257 | 	u_int8_t	opcode;		/* GPCMD_READ_DVD_STRUCTURE */ |
| 258 | 	u_int8_t	reserved; |
| 259 | 	u_int8_t	address[4]; |
| 260 | 	u_int8_t	layer; |
| 261 | 	u_int8_t	format; |
| 262 | 	u_int8_t	length[2]; |
| 263 | 	u_int8_t	agid;		/* bottom 6 bits reserved */ |
| 264 | 	u_int8_t	control; |
| 265 | }; |
| 266 | |
| 267 | struct scsi_read_dvd_structure_data { |
| 268 | 	u_int8_t	len[2];		/* Big-endian length of valid data. */ |
| 269 | 	u_int8_t	reserved[2]; |
| 270 | 	u_int8_t	data[2048]; |
| 271 | }; |
| 272 | |
| 273 | #endif /* _SCSI_CD_H */ |