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 * or
12 * sbpcd=0x330,SPEA
13 * these strings are case sensitive !!!
14 */
15
16 /*
17 * change this to select the type of your interface board:
18 *
19 * set SBPRO to 1 for "true" SoundBlaster card
20 * set SBPRO to 0 for "poor" (no sound) interface cards
21 * and for "compatible" soundcards.
22 * set SBPRO to 2 for the SPEA Media FX card
23 *
24 * most "compatible" sound boards like Galaxy need to set SBPRO to 0 !!!
25 * if SBPRO gets set wrong, the drive will get found - but any
26 * data access will give errors (audio access will work).
27 * The OmniCD interface card from CreativeLabs needs SBPRO 1.
28 *
29 * mail to emoenke@gwdg.de if your "compatible" card needs SBPRO 1
30 * (currently I do not know any "compatible" with SBPRO 1)
31 * then I can include better information with the next release.
32 */
33 #define SBPRO 1
34
35 /*
36 * put your CDROM port base address here:
37 * SBPRO addresses typically are 0x0230 (=0x220+0x10), 0x0250, ...
38 * LASERMATE (CI-101P) adresses typically are 0x0300, 0x0310, ...
39 * SPEA addresses are 0x320, 0x330, 0x340, 0x350
40 * there are some soundcards on the market with 0x0630, 0x0650, ...
41 *
42 * example: if your SBPRO audio address is 0x220, specify 0x230.
43 *
44 */
45 #define CDROM_PORT 0x0230
46
47
48 /*==========================================================================*/
49 /*==========================================================================*/
50 /*
51 * nothing to change below here if you are not experimenting
52 */
53 /*==========================================================================*/
54 /*==========================================================================*/
55 /*
56 * Debug output levels
57 */
58 #define DBG_INF 1 /* necessary information */
59 #define DBG_BSZ 2 /* BLOCK_SIZE trace */
60 #define DBG_REA 3 /* "read" status trace */
61 #define DBG_CHK 4 /* "media check" trace */
62 #define DBG_TIM 5 /* datarate timer test */
63 #define DBG_INI 6 /* initialization trace */
64 #define DBG_TOC 7 /* tell TocEntry values */
65 #define DBG_IOC 8 /* ioctl trace */
66 #define DBG_STA 9 /* "ResponseStatus" trace */
67 #define DBG_ERR 10 /* "xx_ReadError" trace */
68 #define DBG_CMD 11 /* "cmd_out" trace */
69 #define DBG_WRN 12 /* give explanation before auto-probing */
70 #define DBG_MUL 13 /* multi session code test */
71 #define DBG_ID 14 /* "drive_id !=0" test code */
72 #define DBG_IOX 15 /* some special information */
73 #define DBG_DID 16 /* drive ID test */
74 #define DBG_RES 17 /* drive reset info */
75 #define DBG_SPI 18 /* SpinUp test */
76 #define DBG_IOS 19 /* ioctl trace: "subchannel" */
77 #define DBG_IO2 20 /* ioctl trace: general */
78 #define DBG_UPC 21 /* show UPC information */
79 #define DBG_XA 22 /* XA mode debugging */
80 #define DBG_LCK 23 /* door (un)lock info */
81 #define DBG_SQ 24 /* dump SubQ frame */
82 #define DBG_AUD 25 /* "read audio" debugging */
83 #define DBG_000 26 /* unnecessary information */
84
85 /*==========================================================================*/
86 /*==========================================================================*/
87
88 /*
89 * bits of flags_cmd_out:
90 */
91 #define f_respo3 0x100
92 #define f_putcmd 0x80
93 #define f_respo2 0x40
94 #define f_lopsta 0x20
95 #define f_getsta 0x10
96 #define f_ResponseStatus 0x08
97 #define f_obey_p_check 0x04
98 #define f_bit1 0x02
99 #define f_wait_if_busy 0x01
100
101 /*
102 * diskstate_flags:
103 */
104 #define upc_bit 0x40
105 #define volume_bit 0x20
106 #define toc_bit 0x10
107 #define multisession_bit 0x08
108 #define cd_size_bit 0x04
109 #define subq_bit 0x02
110 #define frame_size_bit 0x01
111
112 /*
113 * disk states (bits of diskstate_flags):
114 */
115 #define upc_valid (DriveStruct[d].diskstate_flags&upc_bit)
116 #define volume_valid (DriveStruct[d].diskstate_flags&volume_bit)
117 #define toc_valid (DriveStruct[d].diskstate_flags&toc_bit)
118 #define multisession_valid (DriveStruct[d].diskstate_flags&multisession_bit)
119 #define cd_size_valid (DriveStruct[d].diskstate_flags&cd_size_bit)
120 #define subq_valid (DriveStruct[d].diskstate_flags&subq_bit)
121 #define frame_size_valid (DriveStruct[d].diskstate_flags&frame_size_bit)
122
123
124 /*
125 * bits of the status_byte (result of xx_ReadStatus):
126 */
127 #define p_door_closed 0x80
128 #define p_caddy_in 0x40
129 #define p_spinning 0x20
130 #define p_check 0x10
131 #define p_busy_new 0x08
132 #define p_door_locked 0x04
133 #define p_bit_1 0x02
134 #define p_disk_ok 0x01
135 /*
136 * "old" drives status result bits:
137 */
138 #define p_caddin_old 0x40
139 #define p_success_old 0x08
140 #define p_busy_old 0x04
141
142 /*
143 * used drive states:
144 */
145 #define st_door_closed (DriveStruct[d].status_byte&p_door_closed)
146 #define st_caddy_in (DriveStruct[d].status_byte&p_caddy_in)
147 #define st_spinning (DriveStruct[d].status_byte&p_spinning)
148 #define st_check (DriveStruct[d].status_byte&p_check)
149 #define st_busy (DriveStruct[d].status_byte&p_busy_new)
150 #define st_door_locked (DriveStruct[d].status_byte&p_door_locked)
151 #define st_diskok (DriveStruct[d].status_byte&p_disk_ok)
152
153 /*
154 * bits of the CDi_status register:
155 */
156 #define s_not_result_ready 0x04 /* 0: "result ready" */
157 #define s_not_data_ready 0x02 /* 0: "data ready" */
158 #define s_attention 0x01 /* 1: "attention required" */
159 /*
160 * usable as:
161 */
162 #define DRV_ATTN ((inb(CDi_status)&s_attention)!=0)
163 #define DATA_READY ((inb(CDi_status)&s_not_data_ready)==0)
164 #define RESULT_READY ((inb(CDi_status)&s_not_result_ready)==0)
165
166 /*
167 * drive types (firmware versions):
168 */
169 #define drv_199 0 /* <200 */
170 #define drv_200 1 /* <201 */
171 #define drv_201 2 /* <210 */
172 #define drv_210 3 /* <211 */
173 #define drv_211 4 /* <300 */
174 #define drv_300 5 /* else */
175 #define drv_099 0x10 /* new, <100 */
176 #define drv_100 0x11 /* new, >=100 */
177 #define drv_new 0x10 /* all new drives have that bit set */
178 #define drv_old 0x00 /* */
179
180 /*
181 * drv_099 and drv_100 are the "new" drives
182 */
183 #define new_drive (DriveStruct[d].drv_type&0x10)
184
185 /*
186 * audio states:
187 */
188 #define audio_playing 2
189 #define audio_pausing 1
190
191 /*
192 * drv_pattern, drv_options:
193 */
194 #define speed_auto 0x80
195 #define speed_300 0x40
196 #define speed_150 0x20
197 #define sax_a 0x04
198 #define sax_xn2 0x02
199 #define sax_xn1 0x01
200
201 /*
202 * values of cmd_type (0 else):
203 */
204 #define READ_M1 0x01 /* "data mode 1": 2048 bytes per frame */
205 #define READ_M2 0x02 /* "data mode 2": 12+2048+280 bytes per frame */
206 #define READ_SC 0x04 /* "subchannel info": 96 bytes per frame */
207 #define READ_AU 0x08 /* "audio frame": 2352 bytes per frame */
208
209 /*
210 * preliminary extensions to cdrom.h for transfering audio frames:
211 */
212 #define CDROMREADAUDIO 0xE0 /* IOCTL function (arg = &cdrom_aud) */
213
214 struct cdrom_aud { u_int lba; /* frame address */
215 u_char *buf; /* frame buffer (2352 bytes) */
216 };
217
218 /*
219 * sense byte: used only if new_drive
220 * only during cmd 09 00 xx ah al 00 00
221 *
222 * values: 00
223 * 82
224 * xx from infobuf[0] after 85 00 00 00 00 00 00
225 */
226
227
228 #define CD_MINS 75 /* minutes per CD */
229 #define CD_SECS 60 /* seconds per minutes */
230 #define CD_FRAMES 75 /* frames per second */
231 #define CD_FRAMESIZE 2048 /* bytes per frame, data mode */
232 #define CD_FRAMESIZE_XA 2340 /* bytes per frame, "xa" mode */
233 #define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */
234 #define CD_FRAMESIZE_SUB 96 /* subchannel data size */
235 #define CD_BLOCK_OFFSET 150 /* offset of first logical frame */
236 #define CD_XA_HEAD 12 /* header size of XA frame */
237 #define CD_XA_TAIL 280 /* tail size of XA frame */
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 * currently only one controller, maybe later up to 4
410 */
411 #define NR_SBPCD 4
412
413 /*
414 * we try to never disable interrupts - seems to work
415 */
416 #define SBPCD_DIS_IRQ 0
417
418 /*
419 * "write byte to port"
420 */
421 #define OUT(x,y) outb(y,x)
422
423
424 #define MIXER_CD_Volume 0x28
425
426 /*==========================================================================*/
427 /*
428 * use "REP INSB" for strobing the data in:
429 */
430 #define READ_DATA(port, buf, nr) insb(port, buf, nr)
431
432 /*==========================================================================*/
433 /*
434 * to fork and execute a function after some elapsed time:
435 * one "jifs" unit is 10 msec.
436 */
437 #define SET_TIMER(func, jifs) \
438 ((timer_table[SBPCD_TIMER].expires = jiffies + jifs), \
439 (timer_table[SBPCD_TIMER].fn = func), \
440 (timer_active |= 1<<SBPCD_TIMER))
441
442 #define CLEAR_TIMER timer_active &= ~(1<<SBPCD_TIMER)
443
444 /*==========================================================================*/
445 /*
446 * Creative Labs Programmers did this:
447 */
448 #define MAX_TRACKS 120 /* why more than 99? */
449
450
451 /*==========================================================================*/
452 /*
453 * To make conversions easier (machine dependent!)
454 */
455 typedef union _msf
456 {
457 u_int n;
458 u_char c[4];
459 }
460 MSF;
461
462 typedef union _blk
463 {
464 u_int n;
465 u_char c[4];
466 }
467 BLK;
468
469 /*==========================================================================*/