1 /* 2 * sbpcd.h Specify interface address and interface type here. 3 */ 4 5 /* 6 * these definitions can get overridden by the kernel command line 7 * ("lilo boot option"). Examples: 8 * sbpcd=0x230,SoundBlaster 9 * or 10 * sbpcd=0x300,LaserMate 11 * these strings are case sensitive !!! 12 */ 13 14 /* 15 * change this to select the type of your interface board: 16 * 17 * set SBPRO to 1 for "true" SoundBlaster card 18 * set SBPRO to 0 for "poor" (no sound) interface cards 19 * and for "compatible" soundcards. 20 * 21 * most "compatible" sound boards like Galaxy need to set SBPRO to 0 !!! 22 * if SBPRO gets set wrong, the drive will get found - but any 23 * data access will give errors (audio access will work). 24 * The OmniCD interface card from CreativeLabs needs SBPRO 1. 25 * 26 * mail to emoenke@gwdg.de if your "compatible" card needs SBPRO 1 27 * (currently I do not know any "compatible" with SBPRO 1) 28 * then I can include better information with the next release. 29 */ 30 #define SBPRO 1 31 32 /* 33 * put your CDROM port base address here: 34 * SBPRO addresses typically are 0x0230 (=0x220+0x10), 0x0250, ... 35 * LASERMATE (CI-101P) adresses typically are 0x0300, 0x0310, ... 36 * there are some soundcards on the market with 0x0630, 0x0650, ... 37 * 38 * example: if your SBPRO audio address is 0x220, specify 0x230. 39 * 40 */ 41 #define CDROM_PORT 0x0230 42 43 44 /*==========================================================================*/ 45 /*==========================================================================*/ 46 /* 47 * nothing to change below here if you are not experimenting 48 */ 49 /*==========================================================================*/ 50 /*==========================================================================*/ 51 /* 52 * Debug output levels 53 */ 54 #define DBG_INF 1 /* necessary information */ 55 #define DBG_IRQ 2 /* interrupt trace */ 56 #define DBG_REA 3 /* "read" status trace */ 57 #define DBG_CHK 4 /* "media check" trace */ 58 #define DBG_TIM 5 /* datarate timer test */ 59 #define DBG_INI 6 /* initialization trace */ 60 #define DBG_TOC 7 /* tell TocEntry values */ 61 #define DBG_IOC 8 /* ioctl trace */ 62 #define DBG_STA 9 /* "ResponseStatus" trace */ 63 #define DBG_ERR 10 /* "xx_ReadError" trace */ 64 #define DBG_CMD 11 /* "cmd_out" trace */ 65 #define DBG_WRN 12 /* give explanation before auto-probing */ 66 #define DBG_MUL 13 /* multi session code test */ 67 #define DBG_ID 14 /* "drive_id !=0" test code */ 68 #define DBG_IOX 15 /* some special information */ 69 #define DBG_DID 16 /* drive ID test */ 70 #define DBG_RES 17 /* drive reset info */ 71 #define DBG_SPI 18 /* SpinUp test */ 72 #define DBG_IOS 19 /* ioctl trace: "subchannel" */ 73 #define DBG_IO2 20 /* ioctl trace: general */ 74 #define DBG_000 21 /* unnecessary information */ 75 76 /*==========================================================================*/ 77 /*==========================================================================*/ 78 79 /* 80 * bits of flags_cmd_out: 81 */ 82 #define f_respo3 0x100 83 #define f_putcmd 0x80 84 #define f_respo2 0x40 85 #define f_lopsta 0x20 86 #define f_getsta 0x10 87 #define f_ResponseStatus 0x08 88 #define f_obey_p_check 0x04 89 #define f_bit1 0x02 90 #define f_wait_if_busy 0x01 91 92 /* 93 * diskstate_flags: 94 */ 95 #define upc_bit 0x40 96 #define volume_bit 0x20 97 #define toc_bit 0x10 98 #define multisession_bit 0x08 99 #define cd_size_bit 0x04 100 #define subq_bit 0x02 101 #define frame_size_bit 0x01 102 103 /* 104 * disk states (bits of diskstate_flags): 105 */ 106 #define upc_valid (DS[d].diskstate_flags&upc_bit) 107 #define volume_valid (DS[d].diskstate_flags&volume_bit) 108 #define toc_valid (DS[d].diskstate_flags&toc_bit) 109 #define multisession_valid (DS[d].diskstate_flags&multisession_bit) 110 #define cd_size_valid (DS[d].diskstate_flags&cd_size_bit) 111 #define subq_valid (DS[d].diskstate_flags&subq_bit) 112 #define frame_size_valid (DS[d].diskstate_flags&frame_size_bit) 113 114 115 /* 116 * bits of the status_byte (result of xx_ReadStatus): 117 */ 118 #define p_door_closed 0x80 119 #define p_caddy_in 0x40 120 #define p_spinning 0x20 121 #define p_check 0x10 122 #define p_busy_new 0x08 123 #define p_door_locked 0x04 124 #define p_bit_1 0x02 125 #define p_disk_ok 0x01 126 /* 127 * "old" drives status result bits: 128 */ 129 #define p_caddin_old 0x40 130 #define p_success_old 0x08 131 #define p_busy_old 0x04 132 133 /* 134 * used drive states: 135 */ 136 #define st_door_closed (DS[d].status_byte&p_door_closed) 137 #define st_caddy_in (DS[d].status_byte&p_caddy_in) 138 #define st_spinning (DS[d].status_byte&p_spinning) 139 #define st_check (DS[d].status_byte&p_check) 140 #define st_busy (DS[d].status_byte&p_busy_new) 141 #define st_door_locked (DS[d].status_byte&p_door_locked) 142 #define st_diskok (DS[d].status_byte&p_disk_ok) 143 144 /* 145 * bits of the CDi_status register: 146 */ 147 #define s_not_result_ready 0x04 /* 0: "result ready" */ 148 #define s_not_data_ready 0x02 /* 0: "data ready" */ 149 #define s_attention 0x01 /* 1: "attention required" */ 150 /* 151 * usable as: 152 */ 153 #define DRV_ATTN ((inb(CDi_status)&s_attention)!=0) 154 #define DATA_READY ((inb(CDi_status)&s_not_data_ready)==0) 155 #define RESULT_READY ((inb(CDi_status)&s_not_result_ready)==0) 156 157 /* 158 * drive types (firmware versions): 159 */ 160 #define drv_199 0 /* <200 */ 161 #define drv_200 1 /* <201 */ 162 #define drv_201 2 /* <210 */ 163 #define drv_210 3 /* <211 */ 164 #define drv_211 4 /* <300 */ 165 #define drv_300 5 /* else */ 166 #define drv_099 0x10 /* new, <100 */ 167 #define drv_100 0x11 /* new, >=100 */ 168 #define drv_new 0x10 /* all new drives have that bit set */ 169 #define drv_old 0x00 /* */ 170 171 /* 172 * drv_099 and drv_100 are the "new" drives 173 */ 174 #define new_drive (DS[d].drv_type&0x10) 175 176 /* 177 * audio states: 178 */ 179 #define audio_playing 2 180 #define audio_pausing 1 181 182 /* 183 * drv_pattern, drv_options: 184 */ 185 #define speed_auto 0x80 186 #define speed_300 0x40 187 #define speed_150 0x20 188 #define sax_a 0x04 189 #define sax_xn2 0x02 190 #define sax_xn1 0x01 191 192 /* 193 * values of cmd_type (0 else): 194 */ 195 #define cmd_type_READ_M1 0x01 /* "data mode 1": 2048 bytes per frame */ 196 #define cmd_type_READ_M2 0x02 /* "data mode 2": 12+2048+280 bytes per frame */ 197 #define cmd_type_READ_SC 0x04 /* "subchannel info": 96 bytes per frame */ 198 199 /* 200 * sense byte: used only if new_drive 201 * only during cmd 09 00 xx ah al 00 00 202 * 203 * values: 00 204 * 82 205 * xx from infobuf[0] after 85 00 00 00 00 00 00 206 */ 207 208 209 #define CD_MINS 75 /* minutes per CD */ 210 #define CD_SECS 60 /* seconds per minutes */ 211 #define CD_FRAMES 75 /* frames per second */ 212 #define CD_FRAMESIZE 2048 /* bytes per frame, data mode */ 213 #define CD_FRAMESIZE_XA 2340 /* bytes per frame, "xa" mode */ 214 #define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */ 215 #define CD_BLOCK_OFFSET 150 /* offset of first logical frame */ 216 217 218 /* audio status (bin) */ 219 #define aud_00 0x00 /* Audio status byte not supported or not valid */ 220 #define audx11 0x0b /* Audio play operation in progress */ 221 #define audx12 0x0c /* Audio play operation paused */ 222 #define audx13 0x0d /* Audio play operation successfully completed */ 223 #define audx14 0x0e /* Audio play operation stopped due to error */ 224 #define audx15 0x0f /* No current audio status to return */ 225 226 /* audio status (bcd) */ 227 #define aud_11 0x11 /* Audio play operation in progress */ 228 #define aud_12 0x12 /* Audio play operation paused */ 229 #define aud_13 0x13 /* Audio play operation successfully completed */ 230 #define aud_14 0x14 /* Audio play operation stopped due to error */ 231 #define aud_15 0x15 /* No current audio status to return */ 232 233 /*============================================================================ 234 ============================================================================== 235 236 COMMAND SET of "old" drives like CR-521, CR-522 237 (the CR-562 family is different): 238 239 No. Command Code 240 -------------------------------------------- 241 242 Drive Commands: 243 1 Seek 01 244 2 Read Data 02 245 3 Read XA-Data 03 246 4 Read Header 04 247 5 Spin Up 05 248 6 Spin Down 06 249 7 Diagnostic 07 250 8 Read UPC 08 251 9 Read ISRC 09 252 10 Play Audio 0A 253 11 Play Audio MSF 0B 254 12 Play Audio Track/Index 0C 255 256 Status Commands: 257 13 Read Status 81 258 14 Read Error 82 259 15 Read Drive Version 83 260 16 Mode Select 84 261 17 Mode Sense 85 262 18 Set XA Parameter 86 263 19 Read XA Parameter 87 264 20 Read Capacity 88 265 21 Read SUB_Q 89 266 22 Read Disc Code 8A 267 23 Read Disc Information 8B 268 24 Read TOC 8C 269 25 Pause/Resume 8D 270 26 Read Packet 8E 271 27 Read Path Check 00 272 273 274 all numbers (lba, msf-bin, msf-bcd, counts) to transfer high byte first 275 276 mnemo 7-byte command #bytes response (r0...rn) 277 ________ ____________________ ____ 278 279 Read Status: 280 status: 81. (1) one-byte command, gives the main 281 status byte 282 Read Error: 283 check1: 82 00 00 00 00 00 00. (6) r1: audio status 284 285 Read Packet: 286 check2: 8e xx 00 00 00 00 00. (xx) gets xx bytes response, relating 287 to commands 01 04 05 07 08 09 288 289 Play Audio: 290 play: 0a ll-bb-aa nn-nn-nn. (0) play audio, ll-bb-aa: starting block (lba), 291 nn-nn-nn: #blocks 292 Play Audio MSF: 293 0b mm-ss-ff mm-ss-ff (0) play audio from/to 294 295 Play Audio Track/Index: 296 0c ... 297 298 Pause/Resume: 299 pause: 8d pr 00 00 00 00 00. (0) pause (pr=00) 300 resume (pr=80) audio playing 301 302 Mode Select: 303 84 00 nn-nn ??-?? 00 (0) nn-nn: 2048 or 2340 304 possibly defines transfer size 305 306 set_vol: 84 83 00 00 sw le 00. (0) sw(itch): lrxxxxxx (off=1) 307 le(vel): min=0, max=FF, else half 308 (firmware 2.11) 309 310 Mode Sense: 311 get_vol: 85 03 00 00 00 00 00. (2) tell current audio volume setting 312 313 Read Disc Information: 314 tocdesc: 8b 00 00 00 00 00 00. (6) read the toc descriptor ("msf-bin"-format) 315 316 Read TOC: 317 tocent: 8c fl nn 00 00 00 00. (8) read toc entry #nn 318 (fl=0:"lba"-, =2:"msf-bin"-format) 319 320 Read Capacity: 321 capacit: 88 00 00 00 00 00 00. (5) "read CD-ROM capacity" 322 323 324 Read Path Check: 325 ping: 00 00 00 00 00 00 00. (2) r0=AA, r1=55 326 ("ping" if the drive is connected) 327 328 Read Drive Version: 329 ident: 83 00 00 00 00 00 00. (12) gives "MATSHITAn.nn" 330 (n.nn = 2.01, 2.11., 3.00, ...) 331 332 Seek: 333 seek: 01 00 ll-bb-aa 00 00. (0) 334 seek: 01 02 mm-ss-ff 00 00. (0) 335 336 Read Data: 337 read: 02 xx-xx-xx nn-nn fl. (??) read nn-nn blocks of 2048 bytes, 338 starting at block xx-xx-xx 339 fl=0: "lba"-, =2:"msf-bcd"-coded xx-xx-xx 340 341 Read XA-Data: 342 read: 03 xx-xx-xx nn-nn fl. (??) read nn-nn blocks of 2340 bytes, 343 starting at block xx-xx-xx 344 fl=0: "lba"-, =2:"msf-bcd"-coded xx-xx-xx 345 346 Read SUB_Q: 347 89 fl 00 00 00 00 00. (13) r0: audio status, r4-r7: lba/msf, 348 fl=0: "lba", fl=2: "msf" 349 350 Read Disc Code: 351 8a 00 00 00 00 00 00. (14) possibly extended "check condition"-info 352 353 Read Header: 354 04 00 ll-bb-aa 00 00. (0) 4 bytes response with "check2" 355 04 02 mm-ss-ff 00 00. (0) 4 bytes response with "check2" 356 357 Spin Up: 358 05 00 ll-bb-aa 00 00. (0) possibly implies a "seek" 359 360 Spin Down: 361 06 ... 362 363 Diagnostic: 364 07 00 ll-bb-aa 00 00. (2) 2 bytes response with "check2" 365 07 02 mm-ss-ff 00 00. (2) 2 bytes response with "check2" 366 367 Read UPC: 368 08 00 ll-bb-aa 00 00. (16) 369 08 02 mm-ss-ff 00 00. (16) 370 371 Read ISRC: 372 09 00 ll-bb-aa 00 00. (15) 15 bytes response with "check2" 373 09 02 mm-ss-ff 00 00. (15) 15 bytes response with "check2" 374 375 Set XA Parameter: 376 86 ... 377 378 Read XA Parameter: 379 87 ... 380 381 ============================================================================== 382 ============================================================================*/ 383 384 /*==========================================================================*/ 385 /*==========================================================================*/ 386 387 /* 388 * highest allowed drive number (MINOR+1) 389 * currently only one controller, maybe later up to 4 390 */ 391 #define NR_SBPCD 4 392 393 /* 394 * we try to never disable interrupts - seems to work 395 */ 396 #define SBPCD_DIS_IRQ 0 397 398 /* 399 * we don't use the IRQ line - leave it free for the sound driver 400 */ 401 #define SBPCD_USE_IRQ 0 402 403 /* 404 * you can set the interrupt number of your interface board here: 405 * It is not used at this time. No need to set it correctly. 406 */ 407 #define SBPCD_INTR_NR 7 408 409 /* 410 * "write byte to port" 411 */ 412 #define OUT(x,y) outb(y,x) 413 414 415 #define MIXER_CD_Volume 0x28 416 417 /*==========================================================================*/ 418 /* 419 * use "REP INSB" for strobing the data in: 420 */ 421 #define READ_DATA(port, buf, nr) insb(port, buf, nr) 422 423 /*==========================================================================*/ 424 /* 425 * to fork and execute a function after some elapsed time: 426 * one "jifs" unit is 10 msec. 427 */ 428 #define SET_TIMER(func, jifs) \ 429 ((timer_table[SBPCD_TIMER].expires = jiffies + jifs), \ 430 (timer_table[SBPCD_TIMER].fn = func), \ 431 (timer_active |= 1<<SBPCD_TIMER)) 432 433 #define CLEAR_TIMER timer_active &= ~(1<<SBPCD_TIMER) 434 435 /*==========================================================================*/ 436 /* 437 * Creative Labs Programmers did this: 438 */ 439 #define MAX_TRACKS 120 /* why more than 99? */ 440 441 442 /*==========================================================================*/ 443 /* 444 * To make conversions easier (machine dependent!) 445 */ 446 typedef union _msf 447 { 448 u_int n; 449 u_char c[4]; 450 } 451 MSF; 452 453 typedef union _blk 454 { 455 u_int n; 456 u_char c[4]; 457 } 458 BLK; 459 460 /*==========================================================================*/ 461 462 463 464 465 466