1 /* $NetBSD: scsipi_cd.h,v 1.21 2009/04/01 12:19:04 reinoud Exp $ */ 2 3 /* 4 * Written by Julian Elischer (julian@tfs.com) 5 * for TRW Financial Systems. 6 * 7 * TRW Financial Systems, in accordance with their agreement with Carnegie 8 * Mellon University, makes this software available to CMU to distribute 9 * or use in any manner that they see fit as long as this message is kept with 10 * the software. For this reason TFS also grants any other persons or 11 * organisations permission to use or modify this software. 12 * 13 * TFS supplies this software to be publicly redistributed 14 * on the understanding that TFS is not responsible for the correct 15 * functioning of this software in any circumstances. 16 * 17 * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 18 */ 19 20 /* 21 * Define two bits always in the same place in byte 2 (flag byte) 22 */ 23 #define CD_RELADDR 0x01 24 #define CD_MSF 0x02 25 26 /* 27 * SCSI and SCSI-like command format 28 */ 29 30 #define LOAD_UNLOAD 0xa6 31 struct scsipi_load_unload { 32 u_int8_t opcode; 33 u_int8_t unused1[3]; 34 u_int8_t options; 35 u_int8_t unused2[3]; 36 u_int8_t slot; 37 u_int8_t unused3[3]; 38 } __packed; 39 40 #define PAUSE 0x4b /* cdrom pause in 'play audio' mode */ 41 struct scsipi_pause { 42 u_int8_t opcode; 43 u_int8_t byte2; 44 u_int8_t unused[6]; 45 u_int8_t resume; 46 u_int8_t control; 47 } __packed; 48 #define PA_PAUSE 0x00 49 #define PA_RESUME 0x01 50 51 #define PLAY_MSF 0x47 /* cdrom play Min,Sec,Frames mode */ 52 struct scsipi_play_msf { 53 u_int8_t opcode; 54 u_int8_t byte2; 55 u_int8_t unused; 56 u_int8_t start_m; 57 u_int8_t start_s; 58 u_int8_t start_f; 59 u_int8_t end_m; 60 u_int8_t end_s; 61 u_int8_t end_f; 62 u_int8_t control; 63 } __packed; 64 65 #define PLAY 0x45 /* cdrom play 'play audio' mode */ 66 struct scsipi_play { 67 u_int8_t opcode; 68 u_int8_t byte2; 69 u_int8_t blk_addr[4]; 70 u_int8_t unused; 71 u_int8_t xfer_len[2]; 72 u_int8_t control; 73 } __packed; 74 75 #define READ_HEADER 0x44 /* cdrom read header */ 76 struct scsipi_read_header { 77 u_int8_t opcode; 78 u_int8_t byte2; 79 u_int8_t blk_addr[4]; 80 u_int8_t unused; 81 u_int8_t data_len[2]; 82 u_int8_t control; 83 } __packed; 84 85 #define READ_SUBCHANNEL 0x42 /* cdrom read Subchannel */ 86 struct scsipi_read_subchannel { 87 u_int8_t opcode; 88 u_int8_t byte2; 89 u_int8_t byte3; 90 #define SRS_SUBQ 0x40 91 u_int8_t subchan_format; 92 u_int8_t unused[2]; 93 u_int8_t track; 94 u_int8_t data_len[2]; 95 u_int8_t control; 96 } __packed; 97 98 #define READ_TOC 0x43 /* cdrom read TOC */ 99 struct scsipi_read_toc { 100 u_int8_t opcode; 101 u_int8_t addr_mode; 102 u_int8_t resp_format; 103 u_int8_t unused[3]; 104 u_int8_t from_track; /* session nr in format 2 */ 105 u_int8_t data_len[2]; 106 u_int8_t control; 107 } __packed; 108 109 struct scsipi_toc_header { 110 uint8_t length[2]; 111 uint8_t first; /* track or session */ 112 uint8_t last; 113 } __packed; 114 115 /* read TOC form 0 result entries */ 116 struct scsipi_toc_formatted { 117 uint8_t unused1; 118 uint8_t adrcontrol; 119 uint8_t tracknr; 120 uint8_t unused2; 121 uint8_t msf_lba[4]; /* union msf_lba from cdio.h */ 122 } __packed; 123 124 /* read TOC form 1 result entries */ 125 struct scsipi_toc_msinfo { 126 uint8_t unused1; 127 uint8_t adrcontol; 128 uint8_t tracknr; /* first track last compl. session */ 129 uint8_t unused2; 130 uint8_t msf_lba[4]; /* union msf_lba from cdio.h */ 131 } __packed; 132 133 /* read TOC form 2 result entries */ 134 struct scsipi_toc_rawtoc { 135 uint8_t sessionnr; 136 uint8_t adrcontrol; 137 uint8_t tno; 138 uint8_t point; 139 uint8_t min; 140 uint8_t sec; 141 uint8_t frame; 142 uint8_t zero; /* zero/unused */ 143 uint8_t pmin; 144 uint8_t psec; 145 uint8_t pframe; 146 } __packed; 147 148 /* read TOC form 3, 4 and 5 obmitted yet */ 149 150 #define GET_CONFIGURATION 0x46 /* Get configuration */ 151 #define GET_CONF_NO_FEATURES_LEN 8 152 struct scsipi_get_configuration { 153 uint8_t opcode; 154 uint8_t request_type; 155 uint8_t start_at_feature[2]; 156 uint8_t unused[3]; 157 uint8_t data_len[2]; 158 uint8_t control; 159 } __packed; 160 161 struct scsipi_get_conf_data { 162 uint8_t data_len[4]; 163 uint8_t unused[2]; 164 uint8_t mmc_profile[2]; /* current mmc profile for disk */ 165 uint8_t feature_desc[1]; /* feature descriptors follow */ 166 } __packed; 167 168 struct scsipi_get_conf_feature { /* feature descriptor */ 169 uint8_t featurecode[2]; 170 uint8_t flags; 171 uint8_t additional_length; /* length of feature dependent */ 172 uint8_t feature_dependent[256]; 173 } __packed; 174 #define FEATUREFLAG_CURRENT 1 175 #define FEATUREFLAG_PERSISTENT 2 176 177 178 #define READ_DISCINFO 0x51 179 struct scsipi_read_discinfo { 180 uint8_t opcode; 181 uint8_t unused[6]; 182 uint8_t data_len[2]; 183 uint8_t control; 184 } __packed; 185 186 #define READ_DISCINFO_SMALLSIZE 12 187 #define READ_DISCINFO_BIGSIZE 34 /* + entries */ 188 struct scsipi_read_discinfo_data { 189 uint8_t data_len[2]; 190 uint8_t disc_state; 191 uint8_t first_track; 192 uint8_t num_sessions_lsb; 193 uint8_t first_track_last_session_lsb; 194 uint8_t last_track_last_session_lsb; 195 uint8_t disc_state2; 196 uint8_t disc_type; 197 uint8_t num_sessions_msb; 198 uint8_t first_track_last_session_msb; 199 uint8_t last_track_last_session_msb; 200 uint8_t discid[4]; 201 uint8_t last_session_leadin_hmsf[4]; 202 uint8_t last_possible_start_leadout_hmsf[4]; 203 uint8_t disc_bar_code[8]; 204 uint8_t application_code; 205 uint8_t num_opc_table_entries; 206 uint8_t opc_table_entries[1]; /* opc table entries follow */ 207 } __packed; 208 209 210 #define READ_TRACKINFO 0x52 211 struct scsipi_read_trackinfo { 212 uint8_t opcode; 213 uint8_t addr_type; 214 uint8_t address[4]; 215 uint8_t nothing; 216 uint8_t data_len[2]; 217 uint8_t control; 218 } __packed; 219 #define READ_TRACKINFO_ADDR_LBA 0 220 #define READ_TRACKINFO_ADDR_TRACK 1 221 #define READ_TRACKINFO_ADDR_SESS 2 222 223 struct scsipi_read_trackinfo_data { 224 uint8_t data_len[2]; 225 uint8_t track_lsb; 226 uint8_t session_lsb; 227 uint8_t unused1; 228 uint8_t track_info_1; 229 uint8_t track_info_2; 230 uint8_t data_valid; 231 uint8_t track_start[4]; 232 uint8_t next_writable[4]; 233 uint8_t free_blocks[4]; 234 uint8_t packet_size[4]; 235 uint8_t track_size[4]; 236 uint8_t last_recorded[4]; 237 uint8_t track_msb; 238 uint8_t session_msb; 239 uint8_t unused2[2]; 240 } __packed; 241 #define READ_TRACKINFO_RETURNSIZE 36 242 243 244 #define CLOSE_TRACKSESSION 0x5B 245 struct scsipi_close_tracksession { 246 uint8_t opcode; 247 uint8_t addr_type; /* bit 1 holds immediate */ 248 uint8_t function; /* bits 2,1,0 */ 249 uint8_t unused1; 250 uint8_t tracksessionnr[2]; 251 uint8_t unused2[3]; 252 uint8_t control; 253 } __packed; 254 255 256 #define RESERVE_TRACK 0x53 257 struct scsipi_reserve_track { 258 uint8_t opcode; 259 uint8_t reserved[4]; 260 uint8_t reservation_size[4]; 261 uint8_t control; 262 } __packed; 263 264 265 #define REPAIR_TRACK 0x58 266 struct scsipi_repair_track { 267 uint8_t opcode; 268 uint8_t reserved1; /* bit 1 holds immediate */ 269 uint8_t reserved2[2]; 270 uint8_t tracknr[2]; /* logical track nr */ 271 uint8_t reserved3[3]; 272 uint8_t control; 273 } __packed; 274 275 276 #define READ_CD_CAPACITY 0x25 /* slightly different from disk */ 277 struct scsipi_read_cd_capacity { 278 u_int8_t opcode; 279 u_int8_t byte2; 280 u_int8_t addr[4]; 281 u_int8_t unused[3]; 282 u_int8_t control; 283 } __packed; 284 285 struct scsipi_read_cd_cap_data { 286 u_int8_t addr[4]; 287 u_int8_t length[4]; 288 } __packed; 289 290 291 /* mod pages common to scsi and atapi */ 292 struct cd_audio_page { 293 u_int8_t pg_code; 294 #define AUDIO_PAGE 0x0e 295 u_int8_t pg_length; 296 u_int8_t flags; 297 #define CD_PA_SOTC 0x02 298 #define CD_PA_IMMED 0x04 299 u_int8_t unused[2]; 300 u_int8_t format_lba; /* valid only for SCSI CDs */ 301 #define CD_PA_FORMAT_LBA 0x0F 302 #define CD_PA_APR_VALID 0x80 303 u_int8_t lb_per_sec[2]; 304 struct port_control { 305 u_int8_t channels; 306 #define CHANNEL 0x0F 307 #define CHANNEL_0 1 308 #define CHANNEL_1 2 309 #define CHANNEL_2 4 310 #define CHANNEL_3 8 311 #define LEFT_CHANNEL CHANNEL_0 312 #define RIGHT_CHANNEL CHANNEL_1 313 #define MUTE_CHANNEL 0x0 314 #define BOTH_CHANNEL LEFT_CHANNEL | RIGHT_CHANNEL 315 u_int8_t volume; 316 } port[4]; 317 #define LEFT_PORT 0 318 #define RIGHT_PORT 1 319 }; 320