diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /Documentation/cdrom/sbpcd |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'Documentation/cdrom/sbpcd')
-rw-r--r-- | Documentation/cdrom/sbpcd | 1057 |
1 files changed, 1057 insertions, 0 deletions
diff --git a/Documentation/cdrom/sbpcd b/Documentation/cdrom/sbpcd new file mode 100644 index 000000000000..d1825dffca34 --- /dev/null +++ b/Documentation/cdrom/sbpcd | |||
@@ -0,0 +1,1057 @@ | |||
1 | This README belongs to release 4.2 or newer of the SoundBlaster Pro | ||
2 | (Matsushita, Kotobuki, Panasonic, CreativeLabs, Longshine and Teac) | ||
3 | CD-ROM driver for Linux. | ||
4 | |||
5 | sbpcd really, really is NOT for ANY IDE/ATAPI drive! | ||
6 | Not even if you have an "original" SoundBlaster card with an IDE interface! | ||
7 | So, you'd better have a look into README.ide if your port address is 0x1F0, | ||
8 | 0x170, 0x1E8, 0x168 or similar. | ||
9 | I get tons of mails from IDE/ATAPI drive users - I really can't continue | ||
10 | any more to answer them all. So, if your drive/interface information sheets | ||
11 | mention "IDE" (primary, secondary, tertiary, quaternary) and the DOS driver | ||
12 | invoking line within your CONFIG.SYS is using an address below 0x230: | ||
13 | DON'T ROB MY LAST NERVE - jumper your interface to address 0x170 and IRQ 15 | ||
14 | (that is the "secondary IDE" configuration), set your drive to "master" and | ||
15 | use ide-cd as your driver. If you do not have a second IDE hard disk, use the | ||
16 | LILO commands | ||
17 | hdb=noprobe hdc=cdrom | ||
18 | and get lucky. | ||
19 | To make it fully clear to you: if you mail me about IDE/ATAPI drive problems, | ||
20 | my answer is above, and I simply will discard your mail, hoping to stop the | ||
21 | flood and to find time to lead my 12-year old son towards happy computing. | ||
22 | |||
23 | The driver is able to drive the whole family of "traditional" AT-style (that | ||
24 | is NOT the new "Enhanced IDE" or "ATAPI" drive standard) Matsushita, | ||
25 | Kotobuki, Panasonic drives, sometimes labelled as "CreativeLabs". The | ||
26 | well-known drives are CR-521, CR-522, CR-523, CR-562, CR-563. | ||
27 | CR-574 is an IDE/ATAPI drive. | ||
28 | |||
29 | The Longshine LCS-7260 is a double-speed drive which uses the "old" | ||
30 | Matsushita command set. It is supported - with help by Serge Robyns. | ||
31 | Vertos ("Elitegroup Computer Systems", ECS) has a similar drive - support | ||
32 | has started; get in contact if you have such a "Vertos 100" or "ECS-AT" | ||
33 | drive. | ||
34 | |||
35 | There exists an "IBM External ISA CD-ROM Drive" which in fact is a CR-563 | ||
36 | with a special controller board. This drive is supported (the interface is | ||
37 | of the "LaserMate" type), and it is possibly the best buy today (cheaper than | ||
38 | an internal drive, and you can use it as an internal, too - e.g. plug it into | ||
39 | a soundcard). | ||
40 | |||
41 | CreativeLabs has a new drive "CD200" and a similar drive "CD200F". The latter | ||
42 | is made by Funai and sometimes named "E2550UA", newer models may be named | ||
43 | "MK4015". The CD200F drives should fully work. | ||
44 | CD200 drives without "F" are still giving problems: drive detection and | ||
45 | playing audio should work, data access will result in errors. I need qualified | ||
46 | feedback about the bugs within the data functions or a drive (I never saw a | ||
47 | CD200). | ||
48 | |||
49 | The quad-speed Teac CD-55A drive is supported, but still does not reach "full | ||
50 | speed". The data rate already reaches 500 kB/sec if you set SBP_BUFFER_FRAMES | ||
51 | to 64 (it is not recommended to do that for normal "file access" usage, but it | ||
52 | can speed up things a lot if you use something like "dd" to read from the | ||
53 | drive; I use it for verifying self-written CDs this way). | ||
54 | The drive itself is able to deliver 600 kB/sec, so this needs | ||
55 | work; with the normal setup, the performance currently is not even as good as | ||
56 | double-speed. | ||
57 | |||
58 | This driver is NOT for Mitsumi or Sony or Aztech or Philips or XXX drives, | ||
59 | and again: this driver is in no way usable for any IDE/ATAPI drive. If you | ||
60 | think your drive should work and it doesn't: send me the DOS driver for your | ||
61 | beast (gzipped + uuencoded) and your CONFIG.SYS if you want to ask me for help, | ||
62 | and include an original log message excerpt, and try to give all information | ||
63 | a complete idiot needs to understand your hassle already with your first | ||
64 | mail. And if you want to say "as I have mailed you before", be sure that I | ||
65 | don't remember your "case" by such remarks; at the moment, I have some | ||
66 | hundreds of open correspondences about Linux CDROM questions (hope to reduce if | ||
67 | the IDE/ATAPI user questions disappear). | ||
68 | |||
69 | |||
70 | This driver will work with the soundcard interfaces (SB Pro, SB 16, Galaxy, | ||
71 | SoundFX, Mozart, MAD16 ...) and with the "no-sound" cards (Panasonic CI-101P, | ||
72 | LaserMate, WDH-7001C, Longshine LCS-6853, Teac ...). | ||
73 | |||
74 | It works with the "configurable" interface "Sequoia S-1000", too, which is | ||
75 | used on the Spea Media FX and Ensonic Soundscape sound cards. You have to | ||
76 | specify the type "SBPRO 2" and the true CDROM port address with it, not the | ||
77 | "configuration port" address. | ||
78 | |||
79 | If you have a sound card which needs a "configuration driver" instead of | ||
80 | jumpers for interface types and addresses (like Mozart cards) - those | ||
81 | drivers get invoked before the DOS CDROM driver in your CONFIG.SYS, typical | ||
82 | names are "cdsetup.sys" and "mztinit.sys" - let the sound driver do the | ||
83 | CDROM port configuration (the leading comments in linux/drivers/sound/mad16.c | ||
84 | are just for you!). Hannu Savolainen's mad16.c code is able to set up my | ||
85 | Mozart card - I simply had to add | ||
86 | #define MAD16_CONF 0x06 | ||
87 | #define MAD16_CDSEL 0x03 | ||
88 | to configure the CDROM interface for type "Panasonic" (LaserMate) and address | ||
89 | 0x340. | ||
90 | |||
91 | The interface type has to get configured in linux/drivers/cdrom/sbpcd.h, | ||
92 | because the register layout is different between the "SoundBlaster" and the | ||
93 | "LaserMate" type. | ||
94 | |||
95 | I got a report that the Teac interface card "I/F E117098" is of type | ||
96 | "SoundBlaster" (i.e. you have to set SBPRO to 1) even with the addresses | ||
97 | 0x300 and above. This is unusual, and it can't get covered by the auto | ||
98 | probing scheme. | ||
99 | The Teac 16-bit interface cards (like P/N E950228-00A, default address 0x2C0) | ||
100 | need the SBPRO 3 setup. | ||
101 | |||
102 | If auto-probing found the drive, the address is correct. The reported type | ||
103 | may be wrong. A "mount" will give success only if the interface type is set | ||
104 | right. Playing audio should work with a wrong set interface type, too. | ||
105 | |||
106 | With some Teac and some CD200 drives I have seen interface cards which seem | ||
107 | to lack the "drive select" lines; always drive 0 gets addressed. To avoid | ||
108 | "mirror drives" (four drives detected where you only have one) with such | ||
109 | interface cards, set MAX_DRIVES to 1 and jumper your drive to ID 0 (if | ||
110 | possible). | ||
111 | |||
112 | |||
113 | Up to 4 drives per interface card, and up to 4 interface cards are supported. | ||
114 | All supported drive families can be mixed, but the CR-521 drives are | ||
115 | hard-wired to drive ID 0. The drives have to use different drive IDs, and each | ||
116 | drive has to get a unique minor number (0...3), corresponding indirectly to | ||
117 | its drive ID. | ||
118 | The drive IDs may be selected freely from 0 to 3 - they do not have to be in | ||
119 | consecutive order. | ||
120 | |||
121 | As Don Carroll, don@ds9.us.dell.com or FIDO 1:382/14, told me, it is possible | ||
122 | to change old drives to any ID, too. He writes in this sense: | ||
123 | "In order to be able to use more than one single speed drive | ||
124 | (they do not have the ID jumpers) you must add a DIP switch | ||
125 | and two resistors. The pads are already on the board next to | ||
126 | the power connector. You will see the silkscreen for the | ||
127 | switch if you remove the top cover. | ||
128 | 1 2 3 4 | ||
129 | ID 0 = x F F x O = "on" | ||
130 | ID 1 = x O F x F = "off" | ||
131 | ID 2 = x F O x x = "don't care" | ||
132 | ID 3 = x O O x | ||
133 | Next to the switch are the positions for R76 (7k) and R78 | ||
134 | (12k). I had to play around with the resistor values - ID 3 | ||
135 | did not work with other values. If the values are not good, | ||
136 | ID 3 behaves like ID 0." | ||
137 | |||
138 | To use more than 4 drives, you simply need a second controller card at a | ||
139 | different address and a second cable. | ||
140 | |||
141 | The driver supports reading of data from the CD and playing of audio tracks. | ||
142 | The audio part should run with WorkMan, xcdplayer, with the "non-X11" products | ||
143 | CDplayer and WorkBone - tell me if it is not compatible with other software. | ||
144 | The only accepted measure for correctness with the audio functions is the | ||
145 | "cdtester" utility (appended) - most audio player programmers seem to be | ||
146 | better musicians than programmers. ;-) | ||
147 | |||
148 | With the CR-56x and the CD200 drives, the reading of audio frames is possible. | ||
149 | This is implemented by an IOCTL function which reads READ_AUDIO frames of | ||
150 | 2352 bytes at once (configurable with the "READ_AUDIO" define, default is 0). | ||
151 | Reading the same frame a second time gives different data; the frame data | ||
152 | start at a different position, but all read bytes are valid, and we always | ||
153 | read 98 consecutive chunks (of 24 Bytes) as a frame. Reading more than 1 frame | ||
154 | at once possibly misses some chunks at each frame boundary. This lack has to | ||
155 | get corrected by external, "higher level" software which reads the same frame | ||
156 | again and tries to find and eliminate overlapping chunks (24-byte-pieces). | ||
157 | |||
158 | The transfer rate with reading audio (1-frame-pieces) currently is very slow. | ||
159 | This can be better reading bigger chunks, but the "missing" chunks possibly | ||
160 | occur at the beginning of each single frame. | ||
161 | The software interface possibly may change a bit the day the SCSI driver | ||
162 | supports it too. | ||
163 | |||
164 | With all but the CR-52x drives, MultiSession is supported. | ||
165 | Photo CDs work (the "old" drives like CR-521 can access only the first | ||
166 | session of a photoCD). | ||
167 | At ftp.gwdg.de:/pub/linux/hpcdtoppm/ you will find Hadmut Danisch's package to | ||
168 | convert photo CD image files and Gerd Knorr's viewing utility. | ||
169 | |||
170 | The transfer rate will reach 150 kB/sec with CR-52x drives, 300 kB/sec with | ||
171 | CR-56x drives, and currently not more than 500 kB/sec (usually less than | ||
172 | 250 kB/sec) with the Teac quad speed drives. | ||
173 | XA (PhotoCD) disks with "old" drives give only 50 kB/sec. | ||
174 | |||
175 | This release consists of | ||
176 | - this README file | ||
177 | - the driver file linux/drivers/cdrom/sbpcd.c | ||
178 | - the stub files linux/drivers/cdrom/sbpcd[234].c | ||
179 | - the header file linux/drivers/cdrom/sbpcd.h. | ||
180 | |||
181 | |||
182 | To install: | ||
183 | ----------- | ||
184 | |||
185 | 1. Setup your hardware parameters. Though the driver does "auto-probing" at a | ||
186 | lot of (not all possible!) addresses, this step is recommended for | ||
187 | everyday use. You should let sbpcd auto-probe once and use the reported | ||
188 | address if a drive got found. The reported type may be incorrect; it is | ||
189 | correct if you can mount a data CD. There is no choice for you with the | ||
190 | type; only one is right, the others are deadly wrong. | ||
191 | |||
192 | a. Go into /usr/src/linux/drivers/cdrom/sbpcd.h and configure it for your | ||
193 | hardware (near the beginning): | ||
194 | a1. Set it up for the appropriate type of interface board. | ||
195 | "Original" CreativeLabs sound cards need "SBPRO 1". | ||
196 | Most "compatible" sound cards (almost all "non-CreativeLabs" cards) | ||
197 | need "SBPRO 0". | ||
198 | The "no-sound" board from OmniCd needs the "SBPRO 1" setup. | ||
199 | The Teac 8-bit "no-sound" boards need the "SBPRO 1" setup. | ||
200 | The Teac 16-bit "no-sound" boards need the "SBPRO 3" setup. | ||
201 | All other "no-sound" boards need the "SBPRO 0" setup. | ||
202 | The Spea Media FX and Ensoniq SoundScape cards need "SBPRO 2". | ||
203 | sbpcd.c holds some examples in its auto-probe list. | ||
204 | If you configure "SBPRO" wrong, the playing of audio CDs will work, | ||
205 | but you will not be able to mount a data CD. | ||
206 | a2. Tell the address of your CDROM_PORT (not of the sound port). | ||
207 | a3. If 4 drives get found, but you have only one, set MAX_DRIVES to 1. | ||
208 | a4. Set DISTRIBUTION to 0. | ||
209 | b. Additionally for 2.a1 and 2.a2, the setup may be done during | ||
210 | boot time (via the "kernel command line" or "LILO option"): | ||
211 | sbpcd=0x320,LaserMate | ||
212 | or | ||
213 | sbpcd=0x230,SoundBlaster | ||
214 | or | ||
215 | sbpcd=0x338,SoundScape | ||
216 | or | ||
217 | sbpcd=0x2C0,Teac16bit | ||
218 | This is especially useful if you install a fresh distribution. | ||
219 | If the second parameter is a number, it gets taken as the type | ||
220 | setting; 0 is "LaserMate", 1 is "SoundBlaster", 2 is "SoundScape", | ||
221 | 3 is "Teac16bit". | ||
222 | So, for example | ||
223 | sbpcd=0x230,1 | ||
224 | is equivalent to | ||
225 | sbpcd=0x230,SoundBlaster | ||
226 | |||
227 | 2. "cd /usr/src/linux" and do a "make config" and select "y" for Matsushita | ||
228 | CD-ROM support and for ISO9660 FileSystem support. If you do not have a | ||
229 | second, third, or fourth controller installed, do not say "y" to the | ||
230 | secondary Matsushita CD-ROM questions. | ||
231 | |||
232 | 3. Then make the kernel image ("make zlilo" or similar). | ||
233 | |||
234 | 4. Make the device file(s). This step usually already has been done by the | ||
235 | MAKEDEV script. | ||
236 | The driver uses MAJOR 25, so, if necessary, do | ||
237 | mknod /dev/sbpcd b 25 0 (if you have only one drive) | ||
238 | and/or | ||
239 | mknod /dev/sbpcd0 b 25 0 | ||
240 | mknod /dev/sbpcd1 b 25 1 | ||
241 | mknod /dev/sbpcd2 b 25 2 | ||
242 | mknod /dev/sbpcd3 b 25 3 | ||
243 | to make the node(s). | ||
244 | |||
245 | The "first found" drive gets MINOR 0 (regardless of its jumpered ID), the | ||
246 | "next found" (at the same cable) gets MINOR 1, ... | ||
247 | |||
248 | For a second interface board, you have to make nodes like | ||
249 | mknod /dev/sbpcd4 b 26 0 | ||
250 | mknod /dev/sbpcd5 b 26 1 | ||
251 | and so on. Use the MAJORs 26, 27, 28. | ||
252 | |||
253 | If you further make a link like | ||
254 | ln -s sbpcd /dev/cdrom | ||
255 | you can use the name /dev/cdrom, too. | ||
256 | |||
257 | 5. Reboot with the new kernel. | ||
258 | |||
259 | You should now be able to do | ||
260 | mkdir /CD | ||
261 | and | ||
262 | mount -rt iso9660 /dev/sbpcd /CD | ||
263 | or | ||
264 | mount -rt iso9660 -o block=2048 /dev/sbpcd /CD | ||
265 | and see the contents of your CD in the /CD directory. | ||
266 | To use audio CDs, a mounting is not recommended (and it would fail if the | ||
267 | first track is not a data track). | ||
268 | |||
269 | |||
270 | Using sbpcd as a "loadable module": | ||
271 | ----------------------------------- | ||
272 | |||
273 | If you do NOT select "Matsushita/Panasonic CDROM driver support" during the | ||
274 | "make config" of your kernel, you can build the "loadable module" sbpcd.o. | ||
275 | |||
276 | If sbpcd gets used as a module, the support of more than one interface | ||
277 | card (i.e. drives 4...15) is disabled. | ||
278 | |||
279 | You can specify interface address and type with the "insmod" command like: | ||
280 | # insmod /usr/src/linux/modules/sbpcd.o sbpcd=0x340,0 | ||
281 | or | ||
282 | # insmod /usr/src/linux/modules/sbpcd.o sbpcd=0x230,1 | ||
283 | or | ||
284 | # insmod /usr/src/linux/modules/sbpcd.o sbpcd=0x338,2 | ||
285 | where the last number represents the SBPRO setting (no strings allowed here). | ||
286 | |||
287 | |||
288 | Things of interest: | ||
289 | ------------------- | ||
290 | |||
291 | The driver is configured to try the LaserMate type of interface at I/O port | ||
292 | 0x0340 first. If this is not appropriate, sbpcd.h should get changed | ||
293 | (you will find the right place - just at the beginning). | ||
294 | |||
295 | No DMA and no IRQ is used. | ||
296 | |||
297 | To reduce or increase the amount of kernel messages, edit sbpcd.c and play | ||
298 | with the "DBG_xxx" switches (initialization of the variable "sbpcd_debug"). | ||
299 | Don't forget to reflect on what you do; enabling all DBG_xxx switches at once | ||
300 | may crash your system, and each message line is accompanied by a delay. | ||
301 | |||
302 | The driver uses the "variable BLOCK_SIZE" feature. To use it, you have to | ||
303 | specify "block=2048" as a mount option. Doing this will disable the direct | ||
304 | execution of a binary from the CD; you have to copy it to a device with the | ||
305 | standard BLOCK_SIZE (1024) first. So, do not use this if your system is | ||
306 | directly "running from the CDROM" (like some of Yggdrasil's installation | ||
307 | variants). There are CDs on the market (like the German "unifix" Linux | ||
308 | distribution) which MUST get handled with a block_size of 1024. Generally, | ||
309 | one can say all the CDs which hold files of the name YMTRANS.TBL are defective; | ||
310 | do not use block=2048 with those. | ||
311 | |||
312 | Within sbpcd.h, you will find some "#define"s (e.g. EJECT and JUKEBOX). With | ||
313 | these, you can configure the driver for some special things. | ||
314 | You can use the appended program "cdtester" to set the auto-eject feature | ||
315 | during runtime. Jeff Tranter's "eject" utility can do this, too (and more) | ||
316 | for you. | ||
317 | |||
318 | There is an ioctl CDROMMULTISESSION to obtain with a user program if | ||
319 | the CD is an XA disk and - if it is - where the last session starts. The | ||
320 | "cdtester" program illustrates how to call it. | ||
321 | |||
322 | |||
323 | Auto-probing at boot time: | ||
324 | -------------------------- | ||
325 | |||
326 | The driver does auto-probing at many well-known interface card addresses, | ||
327 | but not all: | ||
328 | Some probings can cause a hang if an NE2000 ethernet card gets touched, because | ||
329 | SBPCD's auto-probing happens before the initialization of the net drivers. | ||
330 | Those "hazardous" addresses are excluded from auto-probing; the "kernel | ||
331 | command line" feature has to be used during installation if you have your | ||
332 | drive at those addresses. The "module" version is allowed to probe at those | ||
333 | addresses, too. | ||
334 | |||
335 | The auto-probing looks first at the configured address resp. the address | ||
336 | submitted by the kernel command line. With this, it is possible to use this | ||
337 | driver within installation boot floppies, and for any non-standard address, | ||
338 | too. | ||
339 | |||
340 | Auto-probing will make an assumption about the interface type ("SBPRO" or not), | ||
341 | based upon the address. That assumption may be wrong (initialization will be | ||
342 | o.k., but you will get I/O errors during mount). In that case, use the "kernel | ||
343 | command line" feature and specify address & type at boot time to find out the | ||
344 | right setup. | ||
345 | |||
346 | For everyday use, address and type should get configured within sbpcd.h. That | ||
347 | will stop the auto-probing due to success with the first try. | ||
348 | |||
349 | The kernel command "sbpcd=0" suppresses each auto-probing and causes | ||
350 | the driver not to find any drive; it is meant for people who love sbpcd | ||
351 | so much that they do not want to miss it, even if they miss the drives. ;-) | ||
352 | |||
353 | If you configure "#define CDROM_PORT 0" in sbpcd.h, the auto-probing is | ||
354 | initially disabled and needs an explicit kernel command to get activated. | ||
355 | Once activated, it does not stop before success or end-of-list. This may be | ||
356 | useful within "universal" CDROM installation boot floppies (but using the | ||
357 | loadable module would be better because it allows an "extended" auto-probing | ||
358 | without fearing NE2000 cards). | ||
359 | |||
360 | To shorten the auto-probing list to a single entry, set DISTRIBUTION 0 within | ||
361 | sbpcd.h. | ||
362 | |||
363 | |||
364 | Setting up address and interface type: | ||
365 | -------------------------------------- | ||
366 | |||
367 | If your I/O port address is not 0x340, you have to look for the #defines near | ||
368 | the beginning of sbpcd.h and configure them: set SBPRO to 0 or 1 or 2, and | ||
369 | change CDROM_PORT to the address of your CDROM I/O port. | ||
370 | |||
371 | Almost all of the "SoundBlaster compatible" cards behave like the no-sound | ||
372 | interfaces, i.e. need SBPRO 0! | ||
373 | |||
374 | With "original" SB Pro cards, an initial setting of CD_volume through the | ||
375 | sound card's MIXER register gets done. | ||
376 | If you are using a "compatible" sound card of types "LaserMate" or "SPEA", | ||
377 | you can set SOUND_BASE (in sbpcd.h) to get it done with your card, too... | ||
378 | |||
379 | |||
380 | Using audio CDs: | ||
381 | ---------------- | ||
382 | |||
383 | Workman, WorkBone, xcdplayer, cdplayer and the nice little tool "cdplay" (see | ||
384 | README.aztcd from the Aztech driver package) should work. | ||
385 | |||
386 | The program CDplayer likes to talk to "/dev/mcd" only, xcdplayer wants | ||
387 | "/dev/rsr0", workman loves "/dev/sr0" or "/dev/cdrom" - so, make the | ||
388 | appropriate links to use them without the need to supply parameters. | ||
389 | |||
390 | |||
391 | Copying audio tracks: | ||
392 | --------------------- | ||
393 | |||
394 | The following program will copy track 1 (or a piece of it) from an audio CD | ||
395 | into the file "track01": | ||
396 | |||
397 | /*=================== begin program ========================================*/ | ||
398 | /* | ||
399 | * read an audio track from a CD | ||
400 | * | ||
401 | * (c) 1994 Eberhard Moenkeberg <emoenke@gwdg.de> | ||
402 | * may be used & enhanced freely | ||
403 | * | ||
404 | * Due to non-existent sync bytes at the beginning of each audio frame (or due | ||
405 | * to a firmware bug within all known drives?), it is currently a kind of | ||
406 | * fortune if two consecutive frames fit together. | ||
407 | * Usually, they overlap, or a little piece is missing. This happens in units | ||
408 | * of 24-byte chunks. It has to get fixed by higher-level software (reading | ||
409 | * until an overlap occurs, and then eliminate the overlapping chunks). | ||
410 | * ftp.gwdg.de:/pub/linux/misc/cdda2wav-sbpcd.*.tar.gz holds an example of | ||
411 | * such an algorithm. | ||
412 | * This example program further is missing to obtain the SubChannel data | ||
413 | * which belong to each frame. | ||
414 | * | ||
415 | * This is only an example of the low-level access routine. The read data are | ||
416 | * pure 16-bit CDDA values; they have to get converted to make sound out of | ||
417 | * them. | ||
418 | * It is no fun to listen to it without prior overlap/underlap correction! | ||
419 | */ | ||
420 | #include <stdio.h> | ||
421 | #include <sys/ioctl.h> | ||
422 | #include <linux/cdrom.h> | ||
423 | |||
424 | static struct cdrom_tochdr hdr; | ||
425 | static struct cdrom_tocentry entry[101]; | ||
426 | static struct cdrom_read_audio arg; | ||
427 | static u_char buffer[CD_FRAMESIZE_RAW]; | ||
428 | static int datafile, drive; | ||
429 | static int i, j, limit, track, err; | ||
430 | static char filename[32]; | ||
431 | |||
432 | main(int argc, char *argv[]) | ||
433 | { | ||
434 | /* | ||
435 | * open /dev/cdrom | ||
436 | */ | ||
437 | drive=open("/dev/cdrom", 0); | ||
438 | if (drive<0) | ||
439 | { | ||
440 | fprintf(stderr, "can't open drive.\n"); | ||
441 | exit (-1); | ||
442 | } | ||
443 | /* | ||
444 | * get TocHeader | ||
445 | */ | ||
446 | fprintf(stdout, "getting TocHeader...\n"); | ||
447 | err=ioctl(drive, CDROMREADTOCHDR, &hdr); | ||
448 | if (err!=0) | ||
449 | { | ||
450 | fprintf(stderr, "can't get TocHeader (error %d).\n", err); | ||
451 | exit (-1); | ||
452 | } | ||
453 | else | ||
454 | fprintf(stdout, "TocHeader: %d %d\n", hdr.cdth_trk0, hdr.cdth_trk1); | ||
455 | /* | ||
456 | * get and display all TocEntries | ||
457 | */ | ||
458 | fprintf(stdout, "getting TocEntries...\n"); | ||
459 | for (i=1;i<=hdr.cdth_trk1+1;i++) | ||
460 | { | ||
461 | if (i!=hdr.cdth_trk1+1) entry[i].cdte_track = i; | ||
462 | else entry[i].cdte_track = CDROM_LEADOUT; | ||
463 | entry[i].cdte_format = CDROM_LBA; | ||
464 | err=ioctl(drive, CDROMREADTOCENTRY, &entry[i]); | ||
465 | if (err!=0) | ||
466 | { | ||
467 | fprintf(stderr, "can't get TocEntry #%d (error %d).\n", i, err); | ||
468 | exit (-1); | ||
469 | } | ||
470 | else | ||
471 | { | ||
472 | fprintf(stdout, "TocEntry #%d: %1X %1X %06X %02X\n", | ||
473 | entry[i].cdte_track, | ||
474 | entry[i].cdte_adr, | ||
475 | entry[i].cdte_ctrl, | ||
476 | entry[i].cdte_addr.lba, | ||
477 | entry[i].cdte_datamode); | ||
478 | } | ||
479 | } | ||
480 | fprintf(stdout, "got all TocEntries.\n"); | ||
481 | /* | ||
482 | * ask for track number (not implemented here) | ||
483 | */ | ||
484 | track=1; | ||
485 | #if 0 /* just read a little piece (4 seconds) */ | ||
486 | entry[track+1].cdte_addr.lba=entry[track].cdte_addr.lba+300; | ||
487 | #endif | ||
488 | /* | ||
489 | * read track into file | ||
490 | */ | ||
491 | sprintf(filename, "track%02d\0", track); | ||
492 | datafile=creat(filename, 0755); | ||
493 | if (datafile<0) | ||
494 | { | ||
495 | fprintf(stderr, "can't open datafile %s.\n", filename); | ||
496 | exit (-1); | ||
497 | } | ||
498 | arg.addr.lba=entry[track].cdte_addr.lba; | ||
499 | arg.addr_format=CDROM_LBA; /* CDROM_MSF would be possible here, too. */ | ||
500 | arg.nframes=1; | ||
501 | arg.buf=&buffer[0]; | ||
502 | limit=entry[track+1].cdte_addr.lba; | ||
503 | for (;arg.addr.lba<limit;arg.addr.lba++) | ||
504 | { | ||
505 | err=ioctl(drive, CDROMREADAUDIO, &arg); | ||
506 | if (err!=0) | ||
507 | { | ||
508 | fprintf(stderr, "can't read abs. frame #%d (error %d).\n", | ||
509 | arg.addr.lba, err); | ||
510 | } | ||
511 | j=write(datafile, &buffer[0], CD_FRAMESIZE_RAW); | ||
512 | if (j!=CD_FRAMESIZE_RAW) | ||
513 | { | ||
514 | fprintf(stderr,"I/O error (datafile) at rel. frame %d\n", | ||
515 | arg.addr.lba-entry[track].cdte_addr.lba); | ||
516 | } | ||
517 | arg.addr.lba++; | ||
518 | } | ||
519 | } | ||
520 | /*===================== end program ========================================*/ | ||
521 | |||
522 | At ftp.gwdg.de:/pub/linux/misc/cdda2wav-sbpcd.*.tar.gz is an adapted version of | ||
523 | Heiko Eissfeldt's digital-audio to .WAV converter (the original is there, too). | ||
524 | This is preliminary, as Heiko himself will care about it. | ||
525 | |||
526 | |||
527 | Known problems: | ||
528 | --------------- | ||
529 | |||
530 | Currently, the detection of disk change or removal is actively disabled. | ||
531 | |||
532 | Most attempts to read the UPC/EAN code result in a stream of zeroes. All my | ||
533 | drives are mostly telling there is no UPC/EAN code on disk or there is, but it | ||
534 | is an all-zero number. I guess now almost no CD holds such a number. | ||
535 | |||
536 | Bug reports, comments, wishes, donations (technical information is a donation, | ||
537 | too :-) etc. to emoenke@gwdg.de. | ||
538 | |||
539 | SnailMail address, preferable for CD editors if they want to submit a free | ||
540 | "cooperation" copy: | ||
541 | Eberhard Moenkeberg | ||
542 | Reinholdstr. 14 | ||
543 | D-37083 Goettingen | ||
544 | Germany | ||
545 | --- | ||
546 | |||
547 | |||
548 | Appendix -- the "cdtester" utility: | ||
549 | |||
550 | /* | ||
551 | * cdtester.c -- test the audio functions of a CD driver | ||
552 | * | ||
553 | * (c) 1995 Eberhard Moenkeberg <emoenke@gwdg.de> | ||
554 | * published under the GPL | ||
555 | * | ||
556 | * made under heavy use of the "Tiny Audio CD Player" | ||
557 | * from Werner Zimmermann <zimmerma@rz.fht-esslingen.de> | ||
558 | * (see linux/drivers/block/README.aztcd) | ||
559 | */ | ||
560 | #undef AZT_PRIVATE_IOCTLS /* not supported by every CDROM driver */ | ||
561 | #define SBP_PRIVATE_IOCTLS /* not supported by every CDROM driver */ | ||
562 | |||
563 | #include <stdio.h> | ||
564 | #include <stdio.h> | ||
565 | #include <malloc.h> | ||
566 | #include <sys/ioctl.h> | ||
567 | #include <linux/cdrom.h> | ||
568 | |||
569 | #ifdef AZT_PRIVATE_IOCTLS | ||
570 | #include <linux/../../drivers/cdrom/aztcd.h> | ||
571 | #endif AZT_PRIVATE_IOCTLS | ||
572 | #ifdef SBP_PRIVATE_IOCTLS | ||
573 | #include <linux/../../drivers/cdrom/sbpcd.h> | ||
574 | #include <linux/fs.h> | ||
575 | #endif SBP_PRIVATE_IOCTLS | ||
576 | |||
577 | struct cdrom_tochdr hdr; | ||
578 | struct cdrom_tochdr tocHdr; | ||
579 | struct cdrom_tocentry TocEntry[101]; | ||
580 | struct cdrom_tocentry entry; | ||
581 | struct cdrom_multisession ms_info; | ||
582 | struct cdrom_read_audio read_audio; | ||
583 | struct cdrom_ti ti; | ||
584 | struct cdrom_subchnl subchnl; | ||
585 | struct cdrom_msf msf; | ||
586 | struct cdrom_volctrl volctrl; | ||
587 | #ifdef AZT_PRIVATE_IOCTLS | ||
588 | union | ||
589 | { | ||
590 | struct cdrom_msf msf; | ||
591 | unsigned char buf[CD_FRAMESIZE_RAW]; | ||
592 | } azt; | ||
593 | #endif AZT_PRIVATE_IOCTLS | ||
594 | int i, i1, i2, i3, j, k; | ||
595 | unsigned char sequence=0; | ||
596 | unsigned char command[80]; | ||
597 | unsigned char first=1, last=1; | ||
598 | char *default_device="/dev/cdrom"; | ||
599 | char dev[20]; | ||
600 | char filename[20]; | ||
601 | int drive; | ||
602 | int datafile; | ||
603 | int rc; | ||
604 | |||
605 | void help(void) | ||
606 | { | ||
607 | printf("Available Commands:\n"); | ||
608 | printf("STOP s EJECT e QUIT q\n"); | ||
609 | printf("PLAY TRACK t PAUSE p RESUME r\n"); | ||
610 | printf("NEXT TRACK n REPEAT LAST l HELP h\n"); | ||
611 | printf("SUBCHANNEL_Q c TRACK INFO i PLAY AT a\n"); | ||
612 | printf("READ d READ RAW w READ AUDIO A\n"); | ||
613 | printf("MS-INFO M TOC T START S\n"); | ||
614 | printf("SET EJECTSW X DEVICE D DEBUG Y\n"); | ||
615 | printf("AUDIO_BUFSIZ Z RESET R SET VOLUME v\n"); | ||
616 | printf("GET VOLUME V\n"); | ||
617 | } | ||
618 | |||
619 | /* | ||
620 | * convert MSF number (3 bytes only) to Logical_Block_Address | ||
621 | */ | ||
622 | int msf2lba(u_char *msf) | ||
623 | { | ||
624 | int i; | ||
625 | |||
626 | i=(msf[0] * CD_SECS + msf[1]) * CD_FRAMES + msf[2] - CD_BLOCK_OFFSET; | ||
627 | if (i<0) return (0); | ||
628 | return (i); | ||
629 | } | ||
630 | /* | ||
631 | * convert logical_block_address to m-s-f_number (3 bytes only) | ||
632 | */ | ||
633 | void lba2msf(int lba, unsigned char *msf) | ||
634 | { | ||
635 | lba += CD_BLOCK_OFFSET; | ||
636 | msf[0] = lba / (CD_SECS*CD_FRAMES); | ||
637 | lba %= CD_SECS*CD_FRAMES; | ||
638 | msf[1] = lba / CD_FRAMES; | ||
639 | msf[2] = lba % CD_FRAMES; | ||
640 | } | ||
641 | |||
642 | int init_drive(char *dev) | ||
643 | { | ||
644 | unsigned char msf_ent[3]; | ||
645 | |||
646 | /* | ||
647 | * open the device | ||
648 | */ | ||
649 | drive=open(dev,0); | ||
650 | if (drive<0) return (-1); | ||
651 | /* | ||
652 | * get TocHeader | ||
653 | */ | ||
654 | printf("getting TocHeader...\n"); | ||
655 | rc=ioctl(drive,CDROMREADTOCHDR,&hdr); | ||
656 | if (rc!=0) | ||
657 | { | ||
658 | printf("can't get TocHeader (error %d).\n",rc); | ||
659 | return (-2); | ||
660 | } | ||
661 | else | ||
662 | first=hdr.cdth_trk0; | ||
663 | last=hdr.cdth_trk1; | ||
664 | printf("TocHeader: %d %d\n",hdr.cdth_trk0,hdr.cdth_trk1); | ||
665 | /* | ||
666 | * get and display all TocEntries | ||
667 | */ | ||
668 | printf("getting TocEntries...\n"); | ||
669 | for (i=1;i<=hdr.cdth_trk1+1;i++) | ||
670 | { | ||
671 | if (i!=hdr.cdth_trk1+1) TocEntry[i].cdte_track = i; | ||
672 | else TocEntry[i].cdte_track = CDROM_LEADOUT; | ||
673 | TocEntry[i].cdte_format = CDROM_LBA; | ||
674 | rc=ioctl(drive,CDROMREADTOCENTRY,&TocEntry[i]); | ||
675 | if (rc!=0) | ||
676 | { | ||
677 | printf("can't get TocEntry #%d (error %d).\n",i,rc); | ||
678 | } | ||
679 | else | ||
680 | { | ||
681 | lba2msf(TocEntry[i].cdte_addr.lba,&msf_ent[0]); | ||
682 | if (TocEntry[i].cdte_track==CDROM_LEADOUT) | ||
683 | { | ||
684 | printf("TocEntry #%02X: %1X %1X %02d:%02d:%02d (lba: 0x%06X) %02X\n", | ||
685 | TocEntry[i].cdte_track, | ||
686 | TocEntry[i].cdte_adr, | ||
687 | TocEntry[i].cdte_ctrl, | ||
688 | msf_ent[0], | ||
689 | msf_ent[1], | ||
690 | msf_ent[2], | ||
691 | TocEntry[i].cdte_addr.lba, | ||
692 | TocEntry[i].cdte_datamode); | ||
693 | } | ||
694 | else | ||
695 | { | ||
696 | printf("TocEntry #%02d: %1X %1X %02d:%02d:%02d (lba: 0x%06X) %02X\n", | ||
697 | TocEntry[i].cdte_track, | ||
698 | TocEntry[i].cdte_adr, | ||
699 | TocEntry[i].cdte_ctrl, | ||
700 | msf_ent[0], | ||
701 | msf_ent[1], | ||
702 | msf_ent[2], | ||
703 | TocEntry[i].cdte_addr.lba, | ||
704 | TocEntry[i].cdte_datamode); | ||
705 | } | ||
706 | } | ||
707 | } | ||
708 | return (hdr.cdth_trk1); /* number of tracks */ | ||
709 | } | ||
710 | |||
711 | void display(int size,unsigned char *buffer) | ||
712 | { | ||
713 | k=0; | ||
714 | getchar(); | ||
715 | for (i=0;i<(size+1)/16;i++) | ||
716 | { | ||
717 | printf("%4d:",i*16); | ||
718 | for (j=0;j<16;j++) | ||
719 | { | ||
720 | printf(" %02X",buffer[i*16+j]); | ||
721 | } | ||
722 | printf(" "); | ||
723 | for (j=0;j<16;j++) | ||
724 | { | ||
725 | if (isalnum(buffer[i*16+j])) | ||
726 | printf("%c",buffer[i*16+j]); | ||
727 | else | ||
728 | printf("."); | ||
729 | } | ||
730 | printf("\n"); | ||
731 | k++; | ||
732 | if (k>=20) | ||
733 | { | ||
734 | printf("press ENTER to continue\n"); | ||
735 | getchar(); | ||
736 | k=0; | ||
737 | } | ||
738 | } | ||
739 | } | ||
740 | |||
741 | main(int argc, char *argv[]) | ||
742 | { | ||
743 | printf("\nTesting tool for a CDROM driver's audio functions V0.1\n"); | ||
744 | printf("(C) 1995 Eberhard Moenkeberg <emoenke@gwdg.de>\n"); | ||
745 | printf("initializing...\n"); | ||
746 | |||
747 | rc=init_drive(default_device); | ||
748 | if (rc<0) printf("could not open %s (rc=%d).\n",default_device,rc); | ||
749 | help(); | ||
750 | while (1) | ||
751 | { | ||
752 | printf("Give a one-letter command (h = help): "); | ||
753 | scanf("%s",command); | ||
754 | command[1]=0; | ||
755 | switch (command[0]) | ||
756 | { | ||
757 | case 'D': | ||
758 | printf("device name (f.e. /dev/sbpcd3): ? "); | ||
759 | scanf("%s",&dev); | ||
760 | close(drive); | ||
761 | rc=init_drive(dev); | ||
762 | if (rc<0) printf("could not open %s (rc %d).\n",dev,rc); | ||
763 | break; | ||
764 | case 'e': | ||
765 | rc=ioctl(drive,CDROMEJECT); | ||
766 | if (rc<0) printf("CDROMEJECT: rc=%d.\n",rc); | ||
767 | break; | ||
768 | case 'p': | ||
769 | rc=ioctl(drive,CDROMPAUSE); | ||
770 | if (rc<0) printf("CDROMPAUSE: rc=%d.\n",rc); | ||
771 | break; | ||
772 | case 'r': | ||
773 | rc=ioctl(drive,CDROMRESUME); | ||
774 | if (rc<0) printf("CDROMRESUME: rc=%d.\n",rc); | ||
775 | break; | ||
776 | case 's': | ||
777 | rc=ioctl(drive,CDROMSTOP); | ||
778 | if (rc<0) printf("CDROMSTOP: rc=%d.\n",rc); | ||
779 | break; | ||
780 | case 'S': | ||
781 | rc=ioctl(drive,CDROMSTART); | ||
782 | if (rc<0) printf("CDROMSTART: rc=%d.\n",rc); | ||
783 | break; | ||
784 | case 't': | ||
785 | rc=ioctl(drive,CDROMREADTOCHDR,&tocHdr); | ||
786 | if (rc<0) | ||
787 | { | ||
788 | printf("CDROMREADTOCHDR: rc=%d.\n",rc); | ||
789 | break; | ||
790 | } | ||
791 | first=tocHdr.cdth_trk0; | ||
792 | last= tocHdr.cdth_trk1; | ||
793 | if ((first==0)||(first>last)) | ||
794 | { | ||
795 | printf ("--got invalid TOC data.\n"); | ||
796 | } | ||
797 | else | ||
798 | { | ||
799 | printf("--enter track number(first=%d, last=%d): ",first,last); | ||
800 | scanf("%d",&i1); | ||
801 | ti.cdti_trk0=i1; | ||
802 | if (ti.cdti_trk0<first) ti.cdti_trk0=first; | ||
803 | if (ti.cdti_trk0>last) ti.cdti_trk0=last; | ||
804 | ti.cdti_ind0=0; | ||
805 | ti.cdti_trk1=last; | ||
806 | ti.cdti_ind1=0; | ||
807 | rc=ioctl(drive,CDROMSTOP); | ||
808 | rc=ioctl(drive,CDROMPLAYTRKIND,&ti); | ||
809 | if (rc<0) printf("CDROMPLAYTRKIND: rc=%d.\n",rc); | ||
810 | } | ||
811 | break; | ||
812 | case 'n': | ||
813 | rc=ioctl(drive,CDROMSTOP); | ||
814 | if (++ti.cdti_trk0>last) ti.cdti_trk0=last; | ||
815 | ti.cdti_ind0=0; | ||
816 | ti.cdti_trk1=last; | ||
817 | ti.cdti_ind1=0; | ||
818 | rc=ioctl(drive,CDROMPLAYTRKIND,&ti); | ||
819 | if (rc<0) printf("CDROMPLAYTRKIND: rc=%d.\n",rc); | ||
820 | break; | ||
821 | case 'l': | ||
822 | rc=ioctl(drive,CDROMSTOP); | ||
823 | if (--ti.cdti_trk0<first) ti.cdti_trk0=first; | ||
824 | ti.cdti_ind0=0; | ||
825 | ti.cdti_trk1=last; | ||
826 | ti.cdti_ind1=0; | ||
827 | rc=ioctl(drive,CDROMPLAYTRKIND,&ti); | ||
828 | if (rc<0) printf("CDROMPLAYTRKIND: rc=%d.\n",rc); | ||
829 | break; | ||
830 | case 'c': | ||
831 | subchnl.cdsc_format=CDROM_MSF; | ||
832 | rc=ioctl(drive,CDROMSUBCHNL,&subchnl); | ||
833 | if (rc<0) printf("CDROMSUBCHNL: rc=%d.\n",rc); | ||
834 | else | ||
835 | { | ||
836 | printf("AudioStatus:%s Track:%d Mode:%d MSF=%02d:%02d:%02d\n", | ||
837 | subchnl.cdsc_audiostatus==CDROM_AUDIO_PLAY ? "PLAYING":"NOT PLAYING", | ||
838 | subchnl.cdsc_trk,subchnl.cdsc_adr, | ||
839 | subchnl.cdsc_absaddr.msf.minute, | ||
840 | subchnl.cdsc_absaddr.msf.second, | ||
841 | subchnl.cdsc_absaddr.msf.frame); | ||
842 | } | ||
843 | break; | ||
844 | case 'i': | ||
845 | printf("Track No.: "); | ||
846 | scanf("%d",&i1); | ||
847 | entry.cdte_track=i1; | ||
848 | if (entry.cdte_track<first) entry.cdte_track=first; | ||
849 | if (entry.cdte_track>last) entry.cdte_track=last; | ||
850 | entry.cdte_format=CDROM_MSF; | ||
851 | rc=ioctl(drive,CDROMREADTOCENTRY,&entry); | ||
852 | if (rc<0) printf("CDROMREADTOCENTRY: rc=%d.\n",rc); | ||
853 | else | ||
854 | { | ||
855 | printf("Mode %d Track, starts at %02d:%02d:%02d\n", | ||
856 | entry.cdte_adr, | ||
857 | entry.cdte_addr.msf.minute, | ||
858 | entry.cdte_addr.msf.second, | ||
859 | entry.cdte_addr.msf.frame); | ||
860 | } | ||
861 | break; | ||
862 | case 'a': | ||
863 | printf("Address (min:sec:frm) "); | ||
864 | scanf("%d:%d:%d",&i1,&i2,&i3); | ||
865 | msf.cdmsf_min0=i1; | ||
866 | msf.cdmsf_sec0=i2; | ||
867 | msf.cdmsf_frame0=i3; | ||
868 | if (msf.cdmsf_sec0>59) msf.cdmsf_sec0=59; | ||
869 | if (msf.cdmsf_frame0>74) msf.cdmsf_frame0=74; | ||
870 | lba2msf(TocEntry[last+1].cdte_addr.lba-1,&msf.cdmsf_min1); | ||
871 | rc=ioctl(drive,CDROMSTOP); | ||
872 | rc=ioctl(drive,CDROMPLAYMSF,&msf); | ||
873 | if (rc<0) printf("CDROMPLAYMSF: rc=%d.\n",rc); | ||
874 | break; | ||
875 | case 'V': | ||
876 | rc=ioctl(drive,CDROMVOLREAD,&volctrl); | ||
877 | if (rc<0) printf("CDROMVOLCTRL: rc=%d.\n",rc); | ||
878 | printf("Volume: channel 0 (left) %d, channel 1 (right) %d\n",volctrl.channel0,volctrl.channel1); | ||
879 | break; | ||
880 | case 'R': | ||
881 | rc=ioctl(drive,CDROMRESET); | ||
882 | if (rc<0) printf("CDROMRESET: rc=%d.\n",rc); | ||
883 | break; | ||
884 | #ifdef AZT_PRIVATE_IOCTLS /*not supported by every CDROM driver*/ | ||
885 | case 'd': | ||
886 | printf("Address (min:sec:frm) "); | ||
887 | scanf("%d:%d:%d",&i1,&i2,&i3); | ||
888 | azt.msf.cdmsf_min0=i1; | ||
889 | azt.msf.cdmsf_sec0=i2; | ||
890 | azt.msf.cdmsf_frame0=i3; | ||
891 | if (azt.msf.cdmsf_sec0>59) azt.msf.cdmsf_sec0=59; | ||
892 | if (azt.msf.cdmsf_frame0>74) azt.msf.cdmsf_frame0=74; | ||
893 | rc=ioctl(drive,CDROMREADMODE1,&azt.msf); | ||
894 | if (rc<0) printf("CDROMREADMODE1: rc=%d.\n",rc); | ||
895 | else display(CD_FRAMESIZE,azt.buf); | ||
896 | break; | ||
897 | case 'w': | ||
898 | printf("Address (min:sec:frame) "); | ||
899 | scanf("%d:%d:%d",&i1,&i2,&i3); | ||
900 | azt.msf.cdmsf_min0=i1; | ||
901 | azt.msf.cdmsf_sec0=i2; | ||
902 | azt.msf.cdmsf_frame0=i3; | ||
903 | if (azt.msf.cdmsf_sec0>59) azt.msf.cdmsf_sec0=59; | ||
904 | if (azt.msf.cdmsf_frame0>74) azt.msf.cdmsf_frame0=74; | ||
905 | rc=ioctl(drive,CDROMREADMODE2,&azt.msf); | ||
906 | if (rc<0) printf("CDROMREADMODE2: rc=%d.\n",rc); | ||
907 | else display(CD_FRAMESIZE_RAW,azt.buf); /* currently only 2336 */ | ||
908 | break; | ||
909 | #endif | ||
910 | case 'v': | ||
911 | printf("--Channel 0 (Left) (0-255): "); | ||
912 | scanf("%d",&i1); | ||
913 | volctrl.channel0=i1; | ||
914 | printf("--Channel 1 (Right) (0-255): "); | ||
915 | scanf("%d",&i1); | ||
916 | volctrl.channel1=i1; | ||
917 | volctrl.channel2=0; | ||
918 | volctrl.channel3=0; | ||
919 | rc=ioctl(drive,CDROMVOLCTRL,&volctrl); | ||
920 | if (rc<0) printf("CDROMVOLCTRL: rc=%d.\n",rc); | ||
921 | break; | ||
922 | case 'q': | ||
923 | close(drive); | ||
924 | exit(0); | ||
925 | case 'h': | ||
926 | help(); | ||
927 | break; | ||
928 | case 'T': /* display TOC entry - without involving the driver */ | ||
929 | scanf("%d",&i); | ||
930 | if ((i<hdr.cdth_trk0)||(i>hdr.cdth_trk1)) | ||
931 | printf("invalid track number.\n"); | ||
932 | else | ||
933 | printf("TocEntry %02d: adr=%01X ctrl=%01X msf=%02d:%02d:%02d mode=%02X\n", | ||
934 | TocEntry[i].cdte_track, | ||
935 | TocEntry[i].cdte_adr, | ||
936 | TocEntry[i].cdte_ctrl, | ||
937 | TocEntry[i].cdte_addr.msf.minute, | ||
938 | TocEntry[i].cdte_addr.msf.second, | ||
939 | TocEntry[i].cdte_addr.msf.frame, | ||
940 | TocEntry[i].cdte_datamode); | ||
941 | break; | ||
942 | case 'A': /* read audio data into file */ | ||
943 | printf("Address (min:sec:frm) ? "); | ||
944 | scanf("%d:%d:%d",&i1,&i2,&i3); | ||
945 | read_audio.addr.msf.minute=i1; | ||
946 | read_audio.addr.msf.second=i2; | ||
947 | read_audio.addr.msf.frame=i3; | ||
948 | read_audio.addr_format=CDROM_MSF; | ||
949 | printf("# of frames ? "); | ||
950 | scanf("%d",&i1); | ||
951 | read_audio.nframes=i1; | ||
952 | k=read_audio.nframes*CD_FRAMESIZE_RAW; | ||
953 | read_audio.buf=malloc(k); | ||
954 | if (read_audio.buf==NULL) | ||
955 | { | ||
956 | printf("can't malloc %d bytes.\n",k); | ||
957 | break; | ||
958 | } | ||
959 | sprintf(filename,"audio_%02d%02d%02d_%02d.%02d\0", | ||
960 | read_audio.addr.msf.minute, | ||
961 | read_audio.addr.msf.second, | ||
962 | read_audio.addr.msf.frame, | ||
963 | read_audio.nframes, | ||
964 | ++sequence); | ||
965 | datafile=creat(filename, 0755); | ||
966 | if (datafile<0) | ||
967 | { | ||
968 | printf("can't open datafile %s.\n",filename); | ||
969 | break; | ||
970 | } | ||
971 | rc=ioctl(drive,CDROMREADAUDIO,&read_audio); | ||
972 | if (rc!=0) | ||
973 | { | ||
974 | printf("CDROMREADAUDIO: rc=%d.\n",rc); | ||
975 | } | ||
976 | else | ||
977 | { | ||
978 | rc=write(datafile,&read_audio.buf,k); | ||
979 | if (rc!=k) printf("datafile I/O error (%d).\n",rc); | ||
980 | } | ||
981 | close(datafile); | ||
982 | break; | ||
983 | case 'X': /* set EJECT_SW (0: disable, 1: enable auto-ejecting) */ | ||
984 | scanf("%d",&i); | ||
985 | rc=ioctl(drive,CDROMEJECT_SW,i); | ||
986 | if (rc!=0) | ||
987 | printf("CDROMEJECT_SW: rc=%d.\n",rc); | ||
988 | else | ||
989 | printf("EJECT_SW set to %d\n",i); | ||
990 | break; | ||
991 | case 'M': /* get the multisession redirection info */ | ||
992 | ms_info.addr_format=CDROM_LBA; | ||
993 | rc=ioctl(drive,CDROMMULTISESSION,&ms_info); | ||
994 | if (rc!=0) | ||
995 | { | ||
996 | printf("CDROMMULTISESSION(lba): rc=%d.\n",rc); | ||
997 | } | ||
998 | else | ||
999 | { | ||
1000 | if (ms_info.xa_flag) printf("MultiSession offset (lba): %d (0x%06X)\n",ms_info.addr.lba,ms_info.addr.lba); | ||
1001 | else | ||
1002 | { | ||
1003 | printf("this CD is not an XA disk.\n"); | ||
1004 | break; | ||
1005 | } | ||
1006 | } | ||
1007 | ms_info.addr_format=CDROM_MSF; | ||
1008 | rc=ioctl(drive,CDROMMULTISESSION,&ms_info); | ||
1009 | if (rc!=0) | ||
1010 | { | ||
1011 | printf("CDROMMULTISESSION(msf): rc=%d.\n",rc); | ||
1012 | } | ||
1013 | else | ||
1014 | { | ||
1015 | if (ms_info.xa_flag) | ||
1016 | printf("MultiSession offset (msf): %02d:%02d:%02d (0x%02X%02X%02X)\n", | ||
1017 | ms_info.addr.msf.minute, | ||
1018 | ms_info.addr.msf.second, | ||
1019 | ms_info.addr.msf.frame, | ||
1020 | ms_info.addr.msf.minute, | ||
1021 | ms_info.addr.msf.second, | ||
1022 | ms_info.addr.msf.frame); | ||
1023 | else printf("this CD is not an XA disk.\n"); | ||
1024 | } | ||
1025 | break; | ||
1026 | #ifdef SBP_PRIVATE_IOCTLS | ||
1027 | case 'Y': /* set the driver's message level */ | ||
1028 | #if 0 /* not implemented yet */ | ||
1029 | printf("enter switch name (f.e. DBG_CMD): "); | ||
1030 | scanf("%s",&dbg_switch); | ||
1031 | j=get_dbg_num(dbg_switch); | ||
1032 | #else | ||
1033 | printf("enter DDIOCSDBG switch number: "); | ||
1034 | scanf("%d",&j); | ||
1035 | #endif | ||
1036 | printf("enter 0 for \"off\", 1 for \"on\": "); | ||
1037 | scanf("%d",&i); | ||
1038 | if (i==0) j|=0x80; | ||
1039 | printf("calling \"ioctl(drive,DDIOCSDBG,%d)\"\n",j); | ||
1040 | rc=ioctl(drive,DDIOCSDBG,j); | ||
1041 | printf("DDIOCSDBG: rc=%d.\n",rc); | ||
1042 | break; | ||
1043 | case 'Z': /* set the audio buffer size */ | ||
1044 | printf("# frames wanted: ? "); | ||
1045 | scanf("%d",&j); | ||
1046 | rc=ioctl(drive,CDROMAUDIOBUFSIZ,j); | ||
1047 | printf("%d frames granted.\n",rc); | ||
1048 | break; | ||
1049 | #endif SBP_PRIVATE_IOCTLS | ||
1050 | default: | ||
1051 | printf("unknown command: \"%s\".\n",command); | ||
1052 | break; | ||
1053 | } | ||
1054 | } | ||
1055 | } | ||
1056 | /*==========================================================================*/ | ||
1057 | |||