1 /*
2 * sbpcd.h Specify interface address and interface type here.
3 */
4
5 /*
6 * the definitions for the first controller can get overridden by
7 * the kernel command line ("lilo boot option").
8 * Examples:
9 * sbpcd=0x230,SoundBlaster
10 * or
11 * sbpcd=0x300,LaserMate
12 * or
13 * sbpcd=0x330,SPEA
14 *
15 * These strings are case sensitive !!!
16 */
17
18 /*
19 * put your CDROM port base address into CDROM_PORT
20 * and specify the type of your interface in SBPRO.
21 *
22 * SBPRO addresses typically are 0x0230 (=0x220+0x10), 0x0250, ...
23 * LASERMATE (CI-101P, WDH-7001C) addresses typically are 0x0300, 0x0310, ...
24 * SPEA addresses are 0x320, 0x330, 0x340, 0x350
25 * there are some soundcards on the market with 0x0630, 0x0650, ...
26 *
27 * example: if your SBPRO audio address is 0x220, specify 0x230.
28 *
29 *
30 * set SBPRO to 1 for "true" SoundBlaster card
31 * set SBPRO to 0 for "poor" (no sound) interface cards
32 * and for "compatible" soundcards.
33 * set SBPRO to 2 for the SPEA Media FX card
34 *
35 * most "compatible" sound boards like Galaxy need to set SBPRO to 0 !!!
36 * if SBPRO gets set wrong, the drive will get found - but any
37 * data access will give errors (audio access will work).
38 * The OmniCD interface card from CreativeLabs needs SBPRO 1.
39 *
40 * mail to emoenke@gwdg.de if your "compatible" card needs SBPRO 1
41 * (currently I do not know any "compatible" with SBPRO 1)
42 * then I can include better information with the next release.
43 */
44 #if !(SBPCD_ISSUE-1) /* first (or if you have only one) interface board: */
45 #define CDROM_PORT 0x0340
46 #define SBPRO 0
47 #endif
48
49 /*
50 * If you have a "compatible" soundcard of type "SBPRO 0" or "SBPRO 2",
51 * enter your sound card's base address here if you want sbpcd to turn
52 * the CD sound channels on.
53 *
54 * Example: #define SOUND_BASE 0x220 enables the sound card's CD channels
55 * #define SOUND_BASE 0 leaves the soundcard untouched
56 */
57 #define SOUND_BASE 0x220
58
59 /* ignore the rest if you have only one interface board & driver */
60
61 #if !(SBPCD_ISSUE-2) /* second interface board: */
62 #define CDROM_PORT 0x0320
63 #define SBPRO 0
64 #endif
65 #if !(SBPCD_ISSUE-3) /* third interface board: */
66 #define CDROM_PORT 0x0630
67 #define SBPRO 1
68 #endif
69 #if !(SBPCD_ISSUE-4) /* fourth interface board: */
70 #define CDROM_PORT 0x0634
71 #define SBPRO 0
72 #endif
73
74 /*==========================================================================*/
75 /*==========================================================================*/
76 /*
77 * nothing to change below here if you are not experimenting
78 */
79 #ifndef _LINUX_SBPCD_H
80
81 #define _LINUX_SBPCD_H
82
83 /*==========================================================================*/
84 /*==========================================================================*/
85 /*
86 * DDI interface definitions
87 * "invented" by Fred N. van Kempen..
88 */
89 #define DDIOCSDBG 0x9000
90 #define DPRINTF(x) sbpcd_dprintf x
91
92 /*==========================================================================*/
93 /*
94 * Debug output levels
95 */
96 #define DBG_INF 1 /* necessary information */
97 #define DBG_BSZ 2 /* BLOCK_SIZE trace */
98 #define DBG_REA 3 /* "read" status trace */
99 #define DBG_CHK 4 /* "media check" trace */
100 #define DBG_TIM 5 /* datarate timer test */
101 #define DBG_INI 6 /* initialization trace */
102 #define DBG_TOC 7 /* tell TocEntry values */
103 #define DBG_IOC 8 /* ioctl trace */
104 #define DBG_STA 9 /* "ResponseStatus" trace */
105 #define DBG_ERR 10 /* "xx_ReadError" trace */
106 #define DBG_CMD 11 /* "cmd_out" trace */
107 #define DBG_WRN 12 /* give explanation before auto-probing */
108 #define DBG_MUL 13 /* multi session code test */
109 #define DBG_ID 14 /* "drive_id !=0" test code */
110 #define DBG_IOX 15 /* some special information */
111 #define DBG_DID 16 /* drive ID test */
112 #define DBG_RES 17 /* drive reset info */
113 #define DBG_SPI 18 /* SpinUp test */
114 #define DBG_IOS 19 /* ioctl trace: "subchannel" */
115 #define DBG_IO2 20 /* ioctl trace: general */
116 #define DBG_UPC 21 /* show UPC information */
117 #define DBG_XA 22 /* XA mode debugging */
118 #define DBG_LCK 23 /* door (un)lock info */
119 #define DBG_SQ 24 /* dump SubQ frame */
120 #define DBG_AUD 25 /* "read audio" debugging */
121 #define DBG_SEQ 26 /* Sequoia interface configuration trace */
122 #define DBG_LCS 27 /* Longshine LCS-7260 debugging trace */
123 #define DBG_CD2 28 /* MKE CD200 debugging trace */
124 #define DBG_000 29 /* unnecessary information */
125
126 /*==========================================================================*/
127 /*==========================================================================*/
128
129 /*
130 * bits of flags_cmd_out:
131 */
132 #define f_respo3 0x100
133 #define f_putcmd 0x80
134 #define f_respo2 0x40
135 #define f_lopsta 0x20
136 #define f_getsta 0x10
137 #define f_ResponseStatus 0x08
138 #define f_obey_p_check 0x04
139 #define f_bit1 0x02
140 #define f_wait_if_busy 0x01
141
142 /*
143 * diskstate_flags:
144 */
145 #define x80_bit 0x80
146 #define upc_bit 0x40
147 #define volume_bit 0x20
148 #define toc_bit 0x10
149 #define multisession_bit 0x08
150 #define cd_size_bit 0x04
151 #define subq_bit 0x02
152 #define frame_size_bit 0x01
153
154 /*
155 * disk states (bits of diskstate_flags):
156 */
157 #define upc_valid (DriveStruct[d].diskstate_flags&upc_bit)
158 #define volume_valid (DriveStruct[d].diskstate_flags&volume_bit)
159 #define toc_valid (DriveStruct[d].diskstate_flags&toc_bit)
160 #define cd_size_valid (DriveStruct[d].diskstate_flags&cd_size_bit)
161 #define subq_valid (DriveStruct[d].diskstate_flags&subq_bit)
162 #define frame_size_valid (DriveStruct[d].diskstate_flags&frame_size_bit)
163
164 /*
165 * bits of the status_byte (result of xx_ReadStatus):
166 */
167 #define p_door_closed 0x80
168 #define p_caddy_in 0x40
169 #define p_spinning 0x20
170 #define p_check 0x10
171 #define p_busy_new 0x08
172 #define p_door_locked 0x04
173 #define p_bit_1 0x02 /* hopefully unused now */
174 #define p_lcs_door_locked 0x02 /* new use of old bit */
175 #define p_disk_ok 0x01
176 #define p_lcs_door_closed 0x01 /* new use of old bit */
177 /*
178 * "old" drives status result bits:
179 */
180 #define p_caddin_old 0x40
181 #define p_success_old 0x08
182 #define p_busy_old 0x04
183
184 /*
185 * "generation specific" defs of the status_byte:
186 */
187 #define p0_door_closed 0x80
188 #define p0_caddy_in 0x40
189 #define p0_spinning 0x20
190 #define p0_check 0x10
191 #define p0_success 0x08 /* unused */
192 #define p0_busy 0x04
193 #define p0_bit_1 0x02 /* unused */
194 #define p0_disk_ok 0x01
195
196 #define p1_door_closed 0x80
197 #define p1_disk_in 0x40
198 #define p1_spinning 0x20
199 #define p1_check 0x10
200 #define p1_busy 0x08
201 #define p1_door_locked 0x04
202 #define p1_bit_1 0x02 /* unused */
203 #define p1_disk_ok 0x01
204
205 #define p2_disk_ok 0x80
206 #define p2_door_locked 0x40
207 #define p2_spinning 0x20
208 #define p2_busy2 0x10
209 #define p2_busy1 0x08
210 #define p2_door_closed 0x04
211 #define p2_disk_in 0x02
212 #define p2_check 0x01
213
214 /*
215 * used drive states:
216 */
217 #define st_door_closed (DriveStruct[d].status_byte&p_door_closed)
218 #define st_caddy_in (DriveStruct[d].status_byte&p_caddy_in)
219 #define st_spinning (DriveStruct[d].status_byte&p_spinning)
220 #define st_check (DriveStruct[d].status_byte&p_check)
221 #define st_busy (DriveStruct[d].status_byte&p_busy_new)
222 #define st_door_locked (DriveStruct[d].status_byte&p_door_locked)
223 #define st_diskok (DriveStruct[d].status_byte&p_disk_ok)
224
225 /*
226 * bits of the CDi_status register:
227 */
228 #define s_not_result_ready 0x04 /* 0: "result ready" */
229 #define s_not_data_ready 0x02 /* 0: "data ready" */
230 #define s_attention 0x01 /* 1: "attention required" */
231 /*
232 * usable as:
233 */
234 #define DRV_ATTN ((inb(CDi_status)&s_attention)!=0)
235 #define DATA_READY ((inb(CDi_status)&s_not_data_ready)==0)
236 #define RESULT_READY ((inb(CDi_status)&s_not_result_ready)==0)
237
238 /*
239 * drive types (firmware versions):
240 */
241 #define drv_fam0 0x08 /* CR-52x family */
242 #define drv_199 (drv_fam0+0x01) /* <200 */
243 #define drv_200 (drv_fam0+0x02) /* <201 */
244 #define drv_201 (drv_fam0+0x03) /* <210 */
245 #define drv_210 (drv_fam0+0x04) /* <211 */
246 #define drv_211 (drv_fam0+0x05) /* <300 */
247 #define drv_300 (drv_fam0+0x06) /* >=300 */
248
249 #define drv_famL 0x10 /* Longshine family */
250 #define drv_260 (drv_famL+0x01) /* LCS-7260 */
251
252 #define drv_fam1 0x20 /* CR-56x family */
253 #define drv_099 (drv_fam1+0x01) /* <100 */
254 #define drv_100 (drv_fam1+0x02) /* >=100 */
255
256 #define drv_fam2 0x80 /* CD200 family */
257
258 #define fam0_drive (DriveStruct[d].drv_type&drv_fam0)
259 #define famL_drive (DriveStruct[d].drv_type&drv_famL)
260 #define fam1_drive (DriveStruct[d].drv_type&drv_fam1)
261 #define fam2_drive (DriveStruct[d].drv_type&drv_fam2)
262 #define fam0L_drive (DriveStruct[d].drv_type&(drv_fam0|drv_famL))
263 #define fam1L_drive (DriveStruct[d].drv_type&(drv_fam1|drv_famL))
264 #define fam01_drive (DriveStruct[d].drv_type&(drv_fam0|drv_fam1))
265
266 /*
267 * audio states:
268 */
269 #define audio_playing 2
270 #define audio_pausing 1
271
272 /*
273 * drv_pattern, drv_options:
274 */
275 #define speed_auto 0x80
276 #define speed_300 0x40
277 #define speed_150 0x20
278 #define audio_mono 0x04
279
280 /*
281 * values of cmd_type (0 else):
282 */
283 #define READ_M1 0x01 /* "data mode 1": 2048 bytes per frame */
284 #define READ_M2 0x02 /* "data mode 2": 12+2048+280 bytes per frame */
285 #define READ_SC 0x04 /* "subchannel info": 96 bytes per frame */
286 #define READ_AU 0x08 /* "audio frame": 2352 bytes per frame */
287
288 /*
289 * sense_byte:
290 *
291 * values: 00
292 * 01
293 * 81
294 * 82 "raw audio" mode
295 * xx from infobuf[0] after 85 00 00 00 00 00 00
296 */
297
298 /* audio status (bin) */
299 #define aud_00 0x00 /* Audio status byte not supported or not valid */
300 #define audx11 0x0b /* Audio play operation in progress */
301 #define audx12 0x0c /* Audio play operation paused */
302 #define audx13 0x0d /* Audio play operation successfully completed */
303 #define audx14 0x0e /* Audio play operation stopped due to error */
304 #define audx15 0x0f /* No current audio status to return */
305
306 /* audio status (bcd) */
307 #define aud_11 0x11 /* Audio play operation in progress */
308 #define aud_12 0x12 /* Audio play operation paused */
309 #define aud_13 0x13 /* Audio play operation successfully completed */
310 #define aud_14 0x14 /* Audio play operation stopped due to error */
311 #define aud_15 0x15 /* No current audio status to return */
312
313
314 /*
315 * highest allowed drive number (MINOR+1)
316 */
317 #define NR_SBPCD 4
318
319 /*
320 * we try to never disable interrupts - seems to work
321 */
322 #define SBPCD_DIS_IRQ 0
323
324 /*
325 * "write byte to port"
326 */
327 #define OUT(x,y) outb(y,x)
328
329 /*
330 * use "REP INSB" for strobing the data in:
331 */
332 #define READ_DATA(port, buf, nr) insb(port, buf, nr)
333
334 /*==========================================================================*/
335
336 #define MIXER_CD_Volume 0x28 /* internal SB Pro register address */
337
338 /*==========================================================================*/
339 /*
340 * Creative Labs Programmers did this:
341 */
342 #define MAX_TRACKS 120 /* why more than 99? */
343
344 /*==========================================================================*/
345 /*
346 * To make conversions easier (machine dependent!)
347 */
348 typedef union _msf
349 {
350 u_int n;
351 u_char c[4];
352 }
353 MSF;
354
355 typedef union _blk
356 {
357 u_int n;
358 u_char c[4];
359 }
360 BLK;
361
362 /*==========================================================================*/
363
364 /*============================================================================
365 ==============================================================================
366
367 COMMAND SET of "old" drives like CR-521, CR-522
368 (the CR-562 family is different):
369
370 No. Command Code
371 --------------------------------------------
372
373 Drive Commands:
374 1 Seek 01
375 2 Read Data 02
376 3 Read XA-Data 03
377 4 Read Header 04
378 5 Spin Up 05
379 6 Spin Down 06
380 7 Diagnostic 07
381 8 Read UPC 08
382 9 Read ISRC 09
383 10 Play Audio 0A
384 11 Play Audio MSF 0B
385 12 Play Audio Track/Index 0C
386
387 Status Commands:
388 13 Read Status 81
389 14 Read Error 82
390 15 Read Drive Version 83
391 16 Mode Select 84
392 17 Mode Sense 85
393 18 Set XA Parameter 86
394 19 Read XA Parameter 87
395 20 Read Capacity 88
396 21 Read SUB_Q 89
397 22 Read Disc Code 8A
398 23 Read Disc Information 8B
399 24 Read TOC 8C
400 25 Pause/Resume 8D
401 26 Read Packet 8E
402 27 Read Path Check 00
403
404
405 all numbers (lba, msf-bin, msf-bcd, counts) to transfer high byte first
406
407 mnemo 7-byte command #bytes response (r0...rn)
408 ________ ____________________ ____
409
410 Read Status:
411 status: 81. (1) one-byte command, gives the main
412 status byte
413 Read Error:
414 check1: 82 00 00 00 00 00 00. (6) r1: audio status
415
416 Read Packet:
417 check2: 8e xx 00 00 00 00 00. (xx) gets xx bytes response, relating
418 to commands 01 04 05 07 08 09
419
420 Play Audio:
421 play: 0a ll-bb-aa nn-nn-nn. (0) play audio, ll-bb-aa: starting block (lba),
422 nn-nn-nn: #blocks
423 Play Audio MSF:
424 0b mm-ss-ff mm-ss-ff (0) play audio from/to
425
426 Play Audio Track/Index:
427 0c ...
428
429 Pause/Resume:
430 pause: 8d pr 00 00 00 00 00. (0) pause (pr=00)
431 resume (pr=80) audio playing
432
433 Mode Select:
434 84 00 nn-nn ??-?? 00 (0) nn-nn: 2048 or 2340
435 possibly defines transfer size
436
437 set_vol: 84 83 00 00 sw le 00. (0) sw(itch): lrxxxxxx (off=1)
438 le(vel): min=0, max=FF, else half
439 (firmware 2.11)
440
441 Mode Sense:
442 get_vol: 85 03 00 00 00 00 00. (2) tell current audio volume setting
443
444 Read Disc Information:
445 tocdesc: 8b 00 00 00 00 00 00. (6) read the toc descriptor ("msf-bin"-format)
446
447 Read TOC:
448 tocent: 8c fl nn 00 00 00 00. (8) read toc entry #nn
449 (fl=0:"lba"-, =2:"msf-bin"-format)
450
451 Read Capacity:
452 capacit: 88 00 00 00 00 00 00. (5) "read CD-ROM capacity"
453
454
455 Read Path Check:
456 ping: 00 00 00 00 00 00 00. (2) r0=AA, r1=55
457 ("ping" if the drive is connected)
458
459 Read Drive Version:
460 ident: 83 00 00 00 00 00 00. (12) gives "MATSHITAn.nn"
461 (n.nn = 2.01, 2.11., 3.00, ...)
462
463 Seek:
464 seek: 01 00 ll-bb-aa 00 00. (0)
465 seek: 01 02 mm-ss-ff 00 00. (0)
466
467 Read Data:
468 read: 02 xx-xx-xx nn-nn fl. (??) read nn-nn blocks of 2048 bytes,
469 starting at block xx-xx-xx
470 fl=0: "lba"-, =2:"msf-bcd"-coded xx-xx-xx
471
472 Read XA-Data:
473 read: 03 xx-xx-xx nn-nn fl. (??) read nn-nn blocks of 2340 bytes,
474 starting at block xx-xx-xx
475 fl=0: "lba"-, =2:"msf-bcd"-coded xx-xx-xx
476
477 Read SUB_Q:
478 89 fl 00 00 00 00 00. (13) r0: audio status, r4-r7: lba/msf,
479 fl=0: "lba", fl=2: "msf"
480
481 Read Disc Code:
482 8a 00 00 00 00 00 00. (14) possibly extended "check condition"-info
483
484 Read Header:
485 04 00 ll-bb-aa 00 00. (0) 4 bytes response with "check2"
486 04 02 mm-ss-ff 00 00. (0) 4 bytes response with "check2"
487
488 Spin Up:
489 05 00 ll-bb-aa 00 00. (0) possibly implies a "seek"
490
491 Spin Down:
492 06 ...
493
494 Diagnostic:
495 07 00 ll-bb-aa 00 00. (2) 2 bytes response with "check2"
496 07 02 mm-ss-ff 00 00. (2) 2 bytes response with "check2"
497
498 Read UPC:
499 08 00 ll-bb-aa 00 00. (16)
500 08 02 mm-ss-ff 00 00. (16)
501
502 Read ISRC:
503 09 00 ll-bb-aa 00 00. (15) 15 bytes response with "check2"
504 09 02 mm-ss-ff 00 00. (15) 15 bytes response with "check2"
505
506 Set XA Parameter:
507 86 ...
508
509 Read XA Parameter:
510 87 ...
511
512 ==============================================================================
513 ============================================================================*/
514
515 /*
516 * commands
517 *
518 * CR-52x: CMD0_
519 * CR-56x: CMD1_
520 * CD200: CMD2_
521 * LCS-7260: CMDL_
522 */
523 #define CMD1_RESET 0x0a
524 #define CMD2_RESET 0x01
525 #define CMD1_LOCK_CTL 0x0c
526 #define CMD2_LOCK_CTL 0x1e
527 #define CMDL_LOCK_CTL 0x0e
528 #define CMD1_TRAY_CTL 0x07
529 #define CMD2_TRAY_CTL 0x1b
530 #define CMDL_TRAY_CTL 0x0d
531 #define CMD1_MULTISESS 0x8d
532 #define CMDL_MULTISESS 0x8c
533 #define CMD1_SUBCHANINF 0x11
534 #define CMD2_SUBCHANINF 0x
535 #define CMD2_x02 0x02
536 #define CMD1_x08 0x08
537 #define CMD2_x08 0x08
538 #define CMD2_SETSPEED 0xda
539
540 #define CMD0_PATH_CHECK 0x00
541 #define CMD1_PATH_CHECK 0x00
542 #define CMD2_PATH_CHECK 0x
543 #define CMDL_PATH_CHECK 0x00
544 #define CMD0_SEEK 0x01
545 #define CMD1_SEEK 0x01
546 #define CMD2_SEEK 0x2b
547 #define CMDL_SEEK 0x01
548 #define CMD0_READ 0x02
549 #define CMD1_READ 0x10
550 #define CMD2_READ 0x28
551 #define CMDL_READ 0x02
552 #define CMD0_READ_XA 0x03
553 #define CMD2_READ_XA 0xd4
554 #define CMDL_READ_XA 0x03 /* really ?? */
555 #define CMD0_READ_HEAD 0x04
556 #define CMD0_SPINUP 0x05
557 #define CMD1_SPINUP 0x02
558 #define CMD2_SPINUP CMD2_TRAY_CTL
559 #define CMDL_SPINUP 0x05
560 #define CMD0_SPINDOWN 0x06 /* really??? */
561 #define CMD1_SPINDOWN 0x06
562 #define CMD2_SPINDOWN CMD2_TRAY_CTL
563 #define CMDL_SPINDOWN 0x0d
564 #define CMD0_DIAG 0x07
565 #define CMD0_READ_UPC 0x08
566 #define CMD1_READ_UPC 0x88
567 #define CMD2_READ_UPC 0x
568 #define CMDL_READ_UPC 0x08
569 #define CMD0_READ_ISRC 0x09
570 #define CMD0_PLAY 0x0a
571 #define CMD1_PLAY 0x
572 #define CMD2_PLAY 0x
573 #define CMDL_PLAY 0x0a
574 #define CMD0_PLAY_MSF 0x0b
575 #define CMD1_PLAY_MSF 0x0e
576 #define CMD2_PLAY_MSF 0x47
577 #define CMDL_PLAY_MSF 0x
578 #define CMD0_PLAY_TI 0x0c
579 #define CMD0_STATUS 0x81
580 #define CMD1_STATUS 0x05
581 #define CMD2_STATUS 0x00
582 #define CMDL_STATUS 0x81
583 #define CMD0_READ_ERR 0x82
584 #define CMD1_READ_ERR 0x82
585 #define CMD2_READ_ERR 0x03
586 #define CMDL_READ_ERR 0x82
587 #define CMD0_READ_VER 0x83
588 #define CMD1_READ_VER 0x83
589 #define CMD2_READ_VER 0x12
590 #define CMDL_READ_VER 0x83
591 #define CMD0_SETMODE 0x84
592 #define CMD1_SETMODE 0x09
593 #define CMD2_SETMODE 0x55
594 #define CMDL_SETMODE 0x84
595 #define CMD0_GETMODE 0x85
596 #define CMD1_GETMODE 0x84
597 #define CMD2_GETMODE 0x5a
598 #define CMDL_GETMODE 0x85
599 #define CMD0_SET_XA 0x86
600 #define CMD0_GET_XA 0x87
601 #define CMD0_CAPACITY 0x88
602 #define CMD1_CAPACITY 0x85
603 #define CMD2_CAPACITY 0x25
604 #define CMDL_CAPACITY 0x88
605 #define CMD0_READSUBQ 0x89
606 #define CMD1_READSUBQ 0x87
607 #define CMD2_READSUBQ 0x42
608 #define CMDL_READSUBQ 0x89
609 #define CMD0_DISKCODE 0x8a
610 #define CMD0_DISKINFO 0x8b
611 #define CMD1_DISKINFO 0x8b
612 #define CMD2_DISKINFO 0x43
613 #define CMDL_DISKINFO 0x8b
614 #define CMD0_READTOC 0x8c
615 #define CMD1_READTOC 0x8c
616 #define CMD2_READTOC 0x
617 #define CMDL_READTOC 0x8c
618 #define CMD0_PAU_RES 0x8d
619 #define CMD1_PAU_RES 0x0d
620 #define CMD2_PAU_RES 0x4b
621 #define CMDL_PAU_RES 0x8d
622 #define CMD0_PACKET 0x8e
623 #define CMD1_PACKET 0x8e
624 #define CMD2_PACKET 0x
625 #define CMDL_PACKET 0x8e
626
627 /*==========================================================================*/
628 /*==========================================================================*/
629 #endif _LINUX_SBPCD_H