1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_CDIO_H 28 #define _SYS_CDIO_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* 37 * CDROM io controls type definitions 38 */ 39 struct cdrom_msf { 40 unsigned char cdmsf_min0; /* starting minute */ 41 unsigned char cdmsf_sec0; /* starting second */ 42 unsigned char cdmsf_frame0; /* starting frame */ 43 unsigned char cdmsf_min1; /* ending minute */ 44 unsigned char cdmsf_sec1; /* ending second */ 45 unsigned char cdmsf_frame1; /* ending frame */ 46 }; 47 48 struct cdrom_ti { 49 unsigned char cdti_trk0; /* starting track */ 50 unsigned char cdti_ind0; /* starting index */ 51 unsigned char cdti_trk1; /* ending track */ 52 unsigned char cdti_ind1; /* ending index */ 53 }; 54 55 struct cdrom_tochdr { 56 unsigned char cdth_trk0; /* starting track */ 57 unsigned char cdth_trk1; /* ending track */ 58 }; 59 60 struct cdrom_tocentry { 61 unsigned char cdte_track; 62 unsigned cdte_adr :4; 63 unsigned cdte_ctrl :4; 64 unsigned char cdte_format; 65 union { 66 struct { 67 unsigned char minute; 68 unsigned char second; 69 unsigned char frame; 70 } msf; 71 int lba; 72 } cdte_addr; 73 unsigned char cdte_datamode; 74 }; 75 76 /* 77 * CDROM address format definition, for use with struct cdrom_tocentry 78 */ 79 #define CDROM_LBA 0x01 80 #define CDROM_MSF 0x02 81 82 /* 83 * Bitmask for CD-ROM data track in the cdte_ctrl field 84 * A track is either data or audio. 85 */ 86 #define CDROM_DATA_TRACK 0x04 87 88 /* 89 * For CDROMREADTOCENTRY, set the cdte_track to CDROM_LEADOUT to get 90 * the information for the leadout track. 91 */ 92 #define CDROM_LEADOUT 0xAA 93 94 struct cdrom_subchnl { 95 unsigned char cdsc_format; 96 unsigned char cdsc_audiostatus; 97 unsigned cdsc_adr: 4; 98 unsigned cdsc_ctrl: 4; 99 unsigned char cdsc_trk; 100 unsigned char cdsc_ind; 101 union { 102 struct { 103 unsigned char minute; 104 unsigned char second; 105 unsigned char frame; 106 } msf; 107 int lba; 108 } cdsc_absaddr; 109 union { 110 struct { 111 unsigned char minute; 112 unsigned char second; 113 unsigned char frame; 114 } msf; 115 int lba; 116 } cdsc_reladdr; 117 }; 118 119 /* 120 * Definition for audio status returned from Read Sub-channel 121 */ 122 #define CDROM_AUDIO_INVALID 0x00 /* audio status not supported */ 123 #define CDROM_AUDIO_PLAY 0x11 /* audio play operation in progress */ 124 #define CDROM_AUDIO_PAUSED 0x12 /* audio play operation paused */ 125 #define CDROM_AUDIO_COMPLETED 0x13 /* audio play successfully completed */ 126 #define CDROM_AUDIO_ERROR 0x14 /* audio play stopped due to error */ 127 #define CDROM_AUDIO_NO_STATUS 0x15 /* no current audio status to return */ 128 129 /* 130 * definition of audio volume control structure 131 */ 132 struct cdrom_volctrl { 133 unsigned char channel0; 134 unsigned char channel1; 135 unsigned char channel2; 136 unsigned char channel3; 137 }; 138 139 struct cdrom_read { 140 int cdread_lba; 141 caddr_t cdread_bufaddr; 142 int cdread_buflen; 143 }; 144 145 #if defined(_SYSCALL32) 146 147 struct cdrom_read32 { 148 int cdread_lba; 149 caddr32_t cdread_bufaddr; 150 int cdread_buflen; 151 }; 152 153 #define cdrom_read32tocdrom_read(cdrd32, cdrd) \ 154 cdrd->cdread_lba = cdrd32->cdread_lba; \ 155 cdrd->cdread_bufaddr = (caddr_t)(uintptr_t)cdrd32->cdread_bufaddr; \ 156 cdrd->cdread_buflen = cdrd32->cdread_buflen 157 158 #define cdrom_readtocdrom_read32(cdrd, cdrd32) \ 159 cdrd32->cdread_lba = cdrd->cdread_lba; \ 160 cdrd32->cdread_bufaddr = (caddr32_t)(uintptr_t)cdrd->cdread_bufaddr; \ 161 cdrd32->cdread_buflen = cdrd->cdread_buflen 162 163 #endif /* _SYSCALL32 */ 164 165 /* 166 * Definition of CD/DA structure 167 */ 168 struct cdrom_cdda { 169 unsigned int cdda_addr; 170 unsigned int cdda_length; 171 caddr_t cdda_data; 172 unsigned char cdda_subcode; 173 }; 174 175 #if defined(_SYSCALL32) 176 struct cdrom_cdda32 { 177 unsigned int cdda_addr; 178 unsigned int cdda_length; 179 caddr32_t cdda_data; 180 unsigned char cdda_subcode; 181 }; 182 183 #define cdrom_cdda32tocdrom_cdda(cdda32, cdda) \ 184 cdda->cdda_addr = cdda32->cdda_addr; \ 185 cdda->cdda_length = cdda32->cdda_length; \ 186 cdda->cdda_data = (caddr_t)(uintptr_t)cdda32->cdda_data; \ 187 cdda->cdda_subcode = cdda32->cdda_subcode 188 189 #define cdrom_cddatocdrom_cdda32(cdda, cdda32) \ 190 cdda32->cdda_addr = cdda->cdda_addr; \ 191 cdda32->cdda_length = cdda->cdda_length; \ 192 cdda32->cdda_data = (caddr32_t)(uintptr_t)cdda->cdda_data; \ 193 cdda32->cdda_subcode = cdda->cdda_subcode 194 195 #endif /* _SYSCALL32 */ 196 197 /* 198 * Definitions for cdda_subcode field 199 */ 200 #define CDROM_DA_NO_SUBCODE 0x00 /* CD/DA data with no subcode */ 201 #define CDROM_DA_SUBQ 0x01 /* CD/DA data with sub Q code */ 202 #define CDROM_DA_ALL_SUBCODE 0x02 /* CD/DA data with all subcode */ 203 #define CDROM_DA_SUBCODE_ONLY 0x03 /* All subcode only */ 204 205 /* 206 * Definition of CD/XA structure 207 */ 208 struct cdrom_cdxa { 209 unsigned int cdxa_addr; 210 unsigned int cdxa_length; 211 caddr_t cdxa_data; 212 unsigned char cdxa_format; 213 }; 214 215 #if defined(_SYSCALL32) 216 217 struct cdrom_cdxa32 { 218 unsigned int cdxa_addr; 219 unsigned int cdxa_length; 220 caddr32_t cdxa_data; 221 unsigned char cdxa_format; 222 }; 223 224 #define cdrom_cdxa32tocdrom_cdxa(cdxa32, cdxa) \ 225 cdxa->cdxa_addr = cdxa32->cdxa_addr; \ 226 cdxa->cdxa_length = cdxa32->cdxa_length; \ 227 cdxa->cdxa_data = (caddr_t)(uintptr_t)cdxa32->cdxa_data; \ 228 cdxa->cdxa_format = cdxa32->cdxa_format 229 230 #define cdrom_cdxatocdrom_cdxa32(cdxa, cdxa32) \ 231 cdxa32->cdxa_addr = cdxa->cdxa_addr; \ 232 cdxa32->cdxa_length = cdxa->cdxa_length; \ 233 cdxa32->cdxa_data = (caddr32_t)(uintptr_t)cdxa->cdxa_data; \ 234 cdxa32->cdxa_format = cdxa->cdxa_format 235 236 #endif /* _SYSCALL32 */ 237 238 /* 239 * Definitions for cdxa_format field 240 */ 241 #define CDROM_XA_DATA 0x00 /* CD/XA data only */ 242 #define CDROM_XA_SECTOR_DATA 0x01 /* CD/XA all sector data */ 243 #define CDROM_XA_DATA_W_ERROR 0x02 /* CD/XA data with error flags data */ 244 245 /* 246 * Definition of subcode structure 247 */ 248 struct cdrom_subcode { 249 unsigned int cdsc_length; 250 caddr_t cdsc_addr; 251 }; 252 253 #if defined(_SYSCALL32) 254 255 struct cdrom_subcode32 { 256 unsigned int cdsc_length; 257 caddr32_t cdsc_addr; 258 }; 259 260 #define cdrom_subcode32tocdrom_subcode(cdsc32, cdsc) \ 261 cdsc->cdsc_length = cdsc32->cdsc_length; \ 262 cdsc->cdsc_addr = (caddr_t)(uintptr_t)cdsc32->cdsc_addr 263 264 #define cdrom_subcodetocdrom_subcode32(cdsc, cdsc32) \ 265 cdsc32->cdsc_length = cdsc->cdsc_length; \ 266 cdsc32->cdsc_addr = (caddr32_t)(uintptr_t)cdsc->cdsc_addr 267 268 #endif /* _SYSCALL32 */ 269 270 /* 271 * Definitions for block size supported 272 */ 273 #define CDROM_BLK_512 512 274 #define CDROM_BLK_1024 1024 275 #define CDROM_BLK_2048 2048 276 #define CDROM_BLK_2056 2056 277 #define CDROM_BLK_2324 2324 278 #define CDROM_BLK_2336 2336 279 #define CDROM_BLK_2340 2340 280 #define CDROM_BLK_2352 2352 281 #define CDROM_BLK_2368 2368 282 #define CDROM_BLK_2448 2448 283 #define CDROM_BLK_2646 2646 284 #define CDROM_BLK_2647 2647 285 #define CDROM_BLK_SUBCODE 96 286 287 /* 288 * Definitions for drive speed supported 289 */ 290 #define CDROM_NORMAL_SPEED 0x00 291 #define CDROM_DOUBLE_SPEED 0x01 292 #define CDROM_QUAD_SPEED 0x03 293 #define CDROM_TWELVE_SPEED 0x0C 294 #define CDROM_MAXIMUM_SPEED 0xff 295 296 /* 297 * CDROM io control commands 298 */ 299 #define CDIOC (0x04 << 8) 300 #define CDROMPAUSE (CDIOC|151) /* Pause Audio Operation */ 301 #define CDROMRESUME (CDIOC|152) /* Resume paused Audio Operation */ 302 #define CDROMPLAYMSF (CDIOC|153) /* Play Audio MSF */ 303 #define CDROMPLAYTRKIND (CDIOC|154) /* Play Audio Track/index */ 304 #define CDROMREADTOCHDR (CDIOC|155) /* Read TOC header */ 305 #define CDROMREADTOCENTRY (CDIOC|156) /* Read a TOC entry */ 306 #define CDROMSTOP (CDIOC|157) /* Stop the cdrom drive */ 307 #define CDROMSTART (CDIOC|158) /* Start the cdrom drive */ 308 #define CDROMEJECT (CDIOC|159) /* Ejects the cdrom caddy */ 309 #define CDROMVOLCTRL (CDIOC|160) /* control output volume */ 310 #define CDROMSUBCHNL (CDIOC|161) /* read the subchannel data */ 311 #define CDROMREADMODE2 (CDIOC|162) /* read CDROM mode 2 data */ 312 #define CDROMREADMODE1 (CDIOC|163) /* read CDROM mode 1 data */ 313 314 #define CDROMREADOFFSET (CDIOC|164) /* read multi-session offset */ 315 316 #define CDROMGBLKMODE (CDIOC|165) /* get current block mode */ 317 #define CDROMSBLKMODE (CDIOC|166) /* set current block mode */ 318 #define CDROMCDDA (CDIOC|167) /* read CD/DA data */ 319 #define CDROMCDXA (CDIOC|168) /* read CD/XA data */ 320 #define CDROMSUBCODE (CDIOC|169) /* read subcode */ 321 #define CDROMGDRVSPEED (CDIOC|170) /* get current drive speed */ 322 #define CDROMSDRVSPEED (CDIOC|171) /* set current drive speed */ 323 324 #define CDROMCLOSETRAY (CDIOC|172) /* close cd tray,load media */ 325 326 /* 327 * Additional commands for CD-ROM 328 */ 329 /* 330 * 331 * Group 2 Commands 332 * 333 */ 334 335 #define SCMD_READ_TOC 0x43 /* optional SCSI command */ 336 #define SCMD_PLAYAUDIO_MSF 0x47 /* optional SCSI command */ 337 #define SCMD_PLAYAUDIO_TI 0x48 /* optional SCSI command */ 338 #define SCMD_PAUSE_RESUME 0x4B /* optional SCSI command */ 339 #define SCMD_READ_SUBCHANNEL 0x42 /* optional SCSI command */ 340 #define SCMD_PLAYAUDIO10 0x45 /* optional SCSI command */ 341 #define SCMD_PLAYTRACK_REL10 0x49 /* optional SCSI command */ 342 #define SCMD_READ_HEADER 0x44 /* optional SCSI command */ 343 344 /* 345 * 346 * Group 5 Commands 347 * 348 */ 349 #define SCMD_PLAYAUDIO12 0xA5 /* optional SCSI command */ 350 #define SCMD_PLAYTRACK_REL12 0xA9 /* optional SCSI command */ 351 #define SCMD_READ_CD 0xBE /* Universal way of accessing CD data */ 352 353 /* 354 * These defines are for SCMD_READ_CD command. 355 * See Expected Sector Type Field Definition (SCSI MMC-2 Spec section 6.1.15) 356 * This information is used to figure out which block size to use. 357 */ 358 #define READ_CD_EST_ALLTYPE 0x0 /* All Types */ 359 #define READ_CD_EST_CDDA 0x1 /* Only CD-DA */ 360 #define READ_CD_EST_MODE1 0x2 /* Only Yellow Book 2048 bytes */ 361 #define READ_CD_EST_MODE2 0x3 /* Only Yellow Book 2336 byte sectors */ 362 #define READ_CD_EST_MODE2FORM1 0x4 /* Only sectors with 2048 bytes */ 363 #define READ_CD_EST_MODE2FORM2 0x5 /* Only sectors with 2324 bytes */ 364 #define READ_CD_EST_RSVD1 0x6 /* reserved */ 365 #define READ_CD_EST_RSVD2 0x7 /* reserved */ 366 367 368 /* 369 * 370 * Group 6 Commands 371 * 372 */ 373 374 #define SCMD_CD_PLAYBACK_CONTROL 0xC9 /* SONY unique SCSI command */ 375 #define SCMD_CD_PLAYBACK_STATUS 0xC4 /* SONY unique SCSI command */ 376 #define SCMD_READ_CDDA 0xD8 /* Vendor unique SCSI command */ 377 #define SCMD_READ_CDXA 0xDB /* Vendor unique SCSI command */ 378 #define SCMD_READ_ALL_SUBCODES 0xDF /* Vendor unique SCSI command */ 379 380 #define CDROM_MODE2_SIZE 2336 381 382 #ifdef __cplusplus 383 } 384 #endif 385 386 #endif /* _SYS_CDIO_H */ 387