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