blob: 6bf0290ef7ce7855ec4bbcc11fca977709d3acca [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001$Id: README.aztcd,v 2.60 1997/11/29 09:51:25 root Exp root $
2 Readme-File Documentation/cdrom/aztcd
3 for
4 AZTECH CD-ROM CDA268-01A, ORCHID CD-3110,
5 OKANO/WEARNES CDD110, CONRAD TXC, CyCDROM CR520, CR540
6 CD-ROM Drives
7 Version 2.6 and newer
8 (for other drives see 6.-8.)
9
10NOTE: THIS DRIVER WILL WORK WITH THE CD-ROM DRIVES LISTED, WHICH HAVE
11 A PROPRIETARY INTERFACE (implemented on a sound card or on an
12 ISA-AT-bus card).
13 IT WILL DEFINITELY NOT WORK WITH CD-ROM DRIVES WITH *IDE*-INTERFACE,
14 such as the Aztech CDA269-031SE !!! (The only known exceptions are
15 'faked' IDE drives like the CyCDROM CR520ie which work with aztcd
16 under certain conditions, see 7.). IF YOU'RE USING A CD-ROM DRIVE
17 WITH IDE-INTERFACE, SOMETIMES ALSO CALLED ATAPI-COMPATIBLE, PLEASE
18 USE THE ide-cd.c DRIVER, WRITTEN BY MARK LORD AND SCOTT SNYDER !
19 THE STANDARD-KERNEL 1.2.x NOW ALSO SUPPORTS IDE-CDROM-DRIVES, SEE THE
20 HARDDISK (!) SECTION OF make config, WHEN COMPILING A NEW KERNEL!!!
21----------------------------------------------------------------------------
22
23Contents of this file:
24 1. NOTE
25 2. INSTALLATION
26 3. CONFIGURING YOUR KERNEL
27 4. RECOMPILING YOUR KERNEL
28 4.1 AZTCD AS A RUN-TIME LOADABLE MODULE
29 4.2 CDROM CONNECTED TO A SOUNDCARD
30 5. KNOWN PROBLEMS, FUTURE DEVELOPMENTS
31 5.1 MULTISESSION SUPPORT
32 5.2 STATUS RECOGNITION
33 5.3 DOSEMU's CDROM SUPPORT
34 6. BUG REPORTS
35 7. OTHER DRIVES
36 8. IF YOU DON'T SUCCEED ... DEBUGGING
37 9. TECHNICAL HISTORY OF THE DRIVER
38 10. ACKNOWLEDGMENTS
39 11. PROGRAMMING ADD ONS: CDPLAY.C
40 APPENDIX: Source code of cdplay.c
41----------------------------------------------------------------------------
42
431. NOTE
44This software has been successfully in alpha and beta test and is part of
45the standard kernel since kernel 1.1.8x since December 1994. It works with
46AZTECH CDA268-01A, ORCHID CDS-3110, ORCHID/WEARNES CDD110 and CONRAD TXC
47(Nr.99 31 23 -series 04) and has proven to be stable with kernel
48versions 1.0.9 and newer. But with any software there still may be bugs in it.
49So if you encounter problems, you are invited to help us improve this software.
50Please send me a detailed bug report (see chapter BUG REPORTS). You are also
51invited in helping us to increase the number of drives, which are supported.
52
53Please read the README-files carefully and always keep a backup copy of your
54old kernel, in order to reboot if something goes wrong!
55
562. INSTALLATION
57The driver consists of a header file 'aztcd.h', which normally should reside
58in /usr/src/linux/drivers/cdrom and the source code 'aztcd.c', which normally
59resides in the same place. It uses /dev/aztcd (/dev/aztcd0 in some distri-
60butions), which must be a valid block device with major number 29 and reside
61in directory /dev. To mount a CD-ROM, your kernel needs to have the ISO9660-
62filesystem support included.
63
64PLEASE NOTE: aztcd.c has been developed in parallel to the linux kernel,
65which had and is having many major and minor changes which are not backward
66compatible. Quite definitely aztcd.c version 1.80 and newer will NOT work
67in kernels older than 1.3.33. So please always use the most recent version
68of aztcd.c with the appropriate linux-kernel.
69
703. CONFIGURING YOUR KERNEL
71If your kernel is already configured for using the AZTECH driver you will
72see the following message while Linux boots:
73 Aztech CD-ROM Init: DriverVersion=<version number> BaseAddress=<baseaddress>
74 Aztech CD-ROM Init: FirmwareVersion=<firmware version id of your I/O-card>>>
75 Aztech CD-ROM Init: <drive type> detected
76 Aztech CD-ROM Init: End
77If the message looks different and you are sure to have a supported drive,
78it may have a different base address. The Aztech driver does look for the
79CD-ROM drive at the base address specified in aztcd.h at compile time. This
80address can be overwritten by boot parameter aztcd=....You should reboot and
81start Linux with boot parameter aztcd=<base address>, e.g. aztcd=0x320. If
82you do not know the base address, start your PC with DOS and look at the boot
83message of your CD-ROM's DOS driver. If that still does not help, use boot
84parameter aztcd=<base address>,0x79 , this tells aztcd to try a little harder.
85aztcd may be configured to use autoprobing the base address by recompiling
86it (see chapter 4.).
87
88If the message looks correct, as user 'root' you should be able to mount the
89drive by
90 mount -t iso9660 -r /dev/aztcd0 /mnt
91and use it as any other filesystem. (If this does not work, check if
92/dev/aztcd0 and /mnt do exist and create them, if necessary by doing
93 mknod /dev/aztcd0 b 29 0
94 mkdir /mnt
95
96If you still get a different message while Linux boots or when you get the
97message, that the ISO9660-filesystem is not supported by your kernel, when
98you try to mount the CD-ROM drive, you have to recompile your kernel.
99
100If you do *not* have an Aztech/Orchid/Okano/Wearnes/TXC drive and want to
101bypass drive detection during Linux boot up, start with boot parameter aztcd=0.
102
103Most distributions nowadays do contain a boot disk image containing aztcd.
104Please note, that this driver will not work with IDE/ATAPI drives! With these
105you must use ide-cd.c instead.
106
1074. RECOMPILING YOUR KERNEL
108If your kernel is not yet configured for the AZTECH driver and the ISO9660-
109filesystem, you have to recompile your kernel:
110
111- Edit aztcd.h to set the I/O-address to your I/O-Base address (AZT_BASE_ADDR),
112 the driver does not use interrupts or DMA, so if you are using an AZTECH
113 CD268, an ORCHID CD-3110 or ORCHID/WEARNES CDD110 that's the only item you
114 have to set up. If you have a soundcard, read chapter 4.2.
115 Users of other drives should read chapter OTHER DRIVES of this file.
116 You also can configure that address by kernel boot parameter aztcd=...
117- aztcd may be configured to use autoprobing the base address by setting
118 AZT_BASE_ADDR to '-1'. In that case aztcd probes the addresses listed
119 under AZT_BASE_AUTO. But please remember, that autoprobing always may
120 incorrectly influence other hardware components too!
121- There are some other points, which may be configured, e.g. auto-eject the
122 CD when unmounting a drive, tray locking etc., see aztcd.h for details.
123- If you're using a linux kernel version prior to 2.1.0, in aztcd.h
124 uncomment the line '#define AZT_KERNEL_PRIOR_2_1'
125- Build a new kernel, configure it for 'Aztech/Orchid/Okano/Wearnes support'
126 (if you want aztcd to be part of the kernel). Do not configure it for
127 'Aztech... support', if you want to use aztcd as a run time loadable module.
128 But in any case you must have the ISO9660-filesystem included in your
129 kernel.
130- Activate the new kernel, normally this is done by running LILO (don't for-
131 get to configure it before and to keep a copy of your old kernel in case
132 something goes wrong!).
133- Reboot
134- If you've included aztcd in your kernel, you now should see during boot
135 some messages like
136 Aztech CD-ROM Init: DriverVersion=<version number> BaseAddress=<baseaddress>
137 Aztech CD-ROM Init: FirmwareVersion=<firmware version id of your I/O-card>
138 Aztech CD-ROM Init: <drive type> detected
139 Aztech CD-ROM Init: End
140- If you have not included aztcd in your kernel, but want to load aztcd as a
141 run time loadable module see 4.1.
142- If the message looks correct, as user 'root' you should be able to mount
143 the drive by
144 mount -t iso9660 -r /dev/aztcd0 /mnt
145 and use it as any other filesystem. (If this does not work, check if
146 /dev/aztcd0 and /mnt do exist and create them, if necessary by doing
147 mknod /dev/aztcd0 b 29 0
148 mkdir /mnt
149- If this still does not help, see chapters OTHER DRIVES and DEBUGGING.
150
1514.1 AZTCD AS A RUN-TIME LOADABLE MODULE
152If you do not need aztcd permanently, you can also load and remove the driver
153during runtime via insmod and rmmod. To build aztcd as a loadable module you
154must configure your kernel for AZTECH module support (answer 'm' when con-
155figuring the kernel). Anyhow, you may run into problems, if the version of
156your boot kernel is not the same than the source kernel version, from which
157you create the modules. So rebuild your kernel, if necessary.
158
159Now edit the base address of your AZTECH interface card in
160/usr/src/linux/drivers/cdrom/aztcd.h to the appropriate value.
161aztcd may be configured to use autoprobing the base address by setting
162AZT_BASE_ADDR to '-1'. In that case aztcd probes the addresses listed
163under AZT_BASE_AUTO. But please remember, that autoprobing always may
164incorrectly influence other hardware components too!
165There are also some special features which may be configured, e.g.
166auto-eject a CD when unmounting the drive etc; see aztcd.h for details.
167Then change to /usr/src/linux and do a
168 make modules
169 make modules_install
170After that you can run-time load the driver via
171 insmod /lib/modules/X.X.X/misc/aztcd.o
172and remove it via rmmod aztcd.
173If you did not set the correct base address in aztcd.h, you can also supply the
174base address when loading the driver via
175 insmod /lib/modules/X.X.X/misc/aztcd.o aztcd=<base address>
176Again specifying aztcd=-1 will cause autoprobing.
177If you do not have the iso9660-filesystem in your boot kernel, you also have
178to load it before you can mount the CDROM:
179 insmod /lib/modules/X.X.X/fs/isofs.o
180The mount procedure works as described in 4. above.
181(In all commands 'X.X.X' is the current linux kernel version number)
182
1834.2 CDROM CONNECTED TO A SOUNDCARD
184Most soundcards do have a bus interface to the CDROM-drive. In many cases
185this soundcard needs to be configured, before the CDROM can be used. This
186configuration procedure consists of writing some kind of initialization
187data to the soundcard registers. The AZTECH-CDROM driver in the moment does
188only support one type of soundcard (SoundWave32). Users of other soundcards
189should try to boot DOS first and let their DOS drivers initialize the
190soundcard and CDROM, then warm boot (or use loadlin) their PC to start
191Linux.
192Support for the CDROM-interface of SoundWave32-soundcards is directly
193implemented in the AZTECH driver. Please edit linux/drivers/cdrom/aztdc.h,
194uncomment line '#define AZT_SW32' and set the appropriate value for
195AZT_BASE_ADDR and AZT_SW32_BASE_ADDR. This support was tested with an Orchid
196CDS-3110 connected to a SoundWave32.
197If you want your soundcard to be supported, find out, how it needs to be
198configured and mail me (see 6.) the appropriate information.
199
2005. KNOWN PROBLEMS, FUTURE DEVELOPMENTS
2015.1 MULTISESSION SUPPORT
202Multisession support for CD's still is a myth. I implemented and tested a basic
203support for multisession and XA CDs, but I still have not enough CDs and appli-
204cations to test it rigorously. So if you'd like to help me, please contact me
205(Email address see below). As of version 1.4 and newer you can enable the
206multisession support in aztcd.h by setting AZT_MULTISESSION to 1. Doing so
207will cause the ISO9660-filesystem to deal with multisession CDs, ie. redirect
208requests to the Table of Contents (TOC) information from the last session,
209which contains the info of all previous sessions etc.. If you do set
210AZT_MULTISESSION to 0, you can use multisession CDs anyway. In that case the
211drive's firmware will do automatic redirection. For the ISO9660-filesystem any
212multisession CD will then look like a 'normal' single session CD. But never-
213theless the data of all sessions are viewable and accessible. So with practical-
214ly all real world applications you won't notice the difference. But as future
215applications may make use of advanced multisession features, I've started to
216implement the interface for the ISO9660 multisession interface via ioctl
217CDROMMULTISESSION.
218
2195.2 STATUS RECOGNITION
220The drive status recognition does not work correctly in all cases. Changing
221a disk or having the door open, when a drive is already mounted, is detected
222by the Aztech driver itself, but nevertheless causes multiple read attempts
223by the different layers of the ISO9660-filesystem driver, which finally timeout,
224so you have to wait quite a little... But isn't it bad style to change a disk
225in a mounted drive, anyhow ?!
226
227The driver uses busy wait in most cases for the drive handshake (macros
228STEN_LOW and DTEN_LOW). I tested with a 486/DX2 at 66MHz and a Pentium at
22960MHz and 90MHz. Whenever you use a much faster machine you are likely to get
230timeout messages. In that case edit aztcd.h and increase the timeout value
231AZT_TIMEOUT.
232
233For some 'slow' drive commands I implemented waiting with a timer waitqueue
234(macro STEN_LOW_WAIT). If you get this timeout message, you may also edit
235aztcd.h and increase the timeout value AZT_STATUS_DELAY. The waitqueue has
236shown to be a little critical. If you get kernel panic messages, edit aztcd.c
237and substitute STEN_LOW_WAIT by STEN_LOW. Busy waiting with STEN_LOW is more
238stable, but also causes CPU overhead.
239
2405.3 DOSEMU's CD-ROM SUPPORT
241With release 1.20 aztcd was modified to allow access to CD-ROMS when running
242under dosemu-0.60.0 aztcd-versions before 1.20 are most likely to crash
243Linux, when a CD-ROM is accessed under dosemu. This problem has partly been
244fixed, but still when accessing a directory for the first time the system
245might hang for some 30sec. So be patient, when using dosemu's CD-ROM support
246in combination with aztcd :-) !
247This problem has now (July 1995) been fixed by a modification to dosemu's
248CD-ROM driver. The new version came with dosemu-0.60.2, see dosemu's
249README.CDROM.
250
2516. BUG REPORTS
252Please send detailed bug reports and bug fixes via EMail to
253
254 Werner.Zimmermann@fht-esslingen.de
255
256Please include a description of your CD-ROM drive type and interface card,
257the exact firmware message during Linux bootup, the version number of the
258AZTECH-CDROM-driver and the Linux kernel version. Also a description of your
259system's other hardware could be of interest, especially microprocessor type,
260clock frequency, other interface cards such as soundcards, ethernet adapter,
261game cards etc..
262
263I will try to collect the reports and make the necessary modifications from
264time to time. I may also come back to you directly with some bug fixes and
265ask you to do further testing and debugging.
266
267Editors of CD-ROMs are invited to send a 'cooperation' copy of their
268CD-ROMs to the volunteers, who provided the CD-ROM support for Linux. My
269snail mail address for such 'stuff' is
270 Prof. Dr. W. Zimmermann
271 Fachhochschule fuer Technik Esslingen
272 Fachbereich IT
273 Flandernstrasse 101
274 D-73732 Esslingen
275 Germany
276
277
2787. OTHER DRIVES
279The following drives ORCHID CDS3110, OKANO CDD110, WEARNES CDD110 and Conrad
280TXC Nr. 993123-series 04 nearly look the same as AZTECH CDA268-01A, especially
281they seem to use the same command codes. So it was quite simple to make the
282AZTECH driver work with these drives.
283
284Unfortunately I do not have any of these drives available, so I couldn't test
285it myself. In some installations, it seems necessary to initialize the drive
286with the DOS driver before (especially if combined with a sound card) and then
287do a warm boot (CTRL-ALT-RESET) or start Linux from DOS, e.g. with 'loadlin'.
288
289If you do not succeed, read chapter DEBUGGING. Thanks in advance!
290
291Sorry for the inconvenience, but it is difficult to develop for hardware,
292which you don't have available for testing. So if you like, please help us.
293
294If you do have a CyCDROM CR520ie thanks to Hilmar Berger's help your chances
295are good, that it will work with aztcd. The CR520ie is sold as an IDE-drive
296and really is connected to the IDE interface (primary at 0x1F0 or secondary
297at 0x170, configured as slave, not as master). Nevertheless it is not ATAPI
298compatible but still uses Aztech's command codes.
299
300
3018. DEBUGGING : IF YOU DON'T SUCCEED, TRY THE FOLLOWING
302-reread the complete README file
303-make sure, that your drive is hardware configured for
304 transfer mode: polled
305 IRQ: not used
306 DMA: not used
307 Base Address: something like 300, 320 ...
308 You can check this, when you start the DOS driver, which came with your
309 drive. By appropriately configuring the drive and the DOS driver you can
310 check, whether your drive does operate in this mode correctly under DOS. If
311 it does not operate under DOS, it won't under Linux.
312 If your drive's base address is something like 0x170 or 0x1F0 (and it is
313 not a CyCDROM CR520ie or CR 940ie) you most likely are having an IDE/ATAPI-
314 compatible drive, which is not supported by aztcd.c, use ide-cd.c instead.
315 Make sure the Base Address is configured correctly in aztcd.h, also make
316 sure, that /dev/aztcd0 exists with the correct major number (compare it with
317 the entry in file /usr/include/linux/major.h for the Aztech drive).
318-insert a CD-ROM and close the tray
319-cold boot your PC (i.e. via the power on switch or the reset button)
320-if you start Linux via DOS, e.g. using loadlin, make sure, that the DOS
321 driver for the CD-ROM drive is not loaded (comment out the calling lines
322 in DOS' config.sys!)
323-look for the aztcd: init message during Linux init and note them exactly
324-log in as root and do a mount -t iso9660 /dev/aztcd0 /mnt
325-if you don't succeed in the first time, try several times. Try also to open
326 and close the tray, then mount again. Please note carefully all commands
327 you typed in and the aztcd-messages, which you get.
328-if you get an 'Aztech CD-ROM init: aborted' message, read the remarks about
329 the version string below.
330
331If this does not help, do the same with the following differences
332-start DOS before; make now sure, that the DOS driver for the CD-ROM is
333 loaded under DOS (i.e. uncomment it again in config.sys)
334-warm boot your PC (i.e. via CTRL-ALT-DEL)
335 if you have it, you can also start via loadlin (try both).
336 ...
337 Again note all commands and the aztcd-messages.
338
339If you see STEN_LOW or STEN_LOW_WAIT error messages, increase the timeout
340values.
341
342If this still does not help,
343-look in aztcd.c for the lines #if 0
344 #define AZT_TEST1
345 ...
346 #endif
347 and substitute '#if 0' by '#if 1'.
348-recompile your kernel and repeat the above two procedures. You will now get
349 a bundle of debugging messages from the driver. Again note your commands
350 and the appropriate messages. If you have syslogd running, these messages
351 may also be found in syslogd's kernel log file. Nevertheless in some
352 installations syslogd does not yet run, when init() is called, thus look for
353 the aztcd-messages during init, before the login-prompt appears.
354 Then look in aztcd.c, to find out, what happened. The normal calling sequence
355 is: aztcd_init() during Linux bootup procedure init()
356 after doing a 'mount -t iso9660 /dev/aztcd0 /mnt' the normal calling sequence is
357 aztcd_open() -> Status 2c after cold reboot with CDROM or audio CD inserted
358 -> Status 8 after warm reboot with CDROM inserted
359 -> Status 2e after cold reboot with no disk, closed tray
360 -> Status 6e after cold reboot, mount with door open
361 aztUpdateToc()
362 aztGetDiskInfo()
363 aztGetQChannelInfo() repeated several times
364 aztGetToc()
365 aztGetQChannelInfo() repeated several times
366 a list of track information
367 do_aztcd_request() }
368 azt_transfer() } repeated several times
369 azt_poll }
370 Check, if there is a difference in the calling sequence or the status flags!
371
372 There are a lot of other messages, eg. the ACMD-command code (defined in
373 aztcd.h), status info from the getAztStatus-command and the state sequence of
374 the finite state machine in azt_poll(). The most important are the status
375 messages, look how they are defined and try to understand, if they make
376 sense in the context where they appear. With a CD-ROM inserted the status
377 should always be 8, except in aztcd_open(). Try to open the tray, insert an
378 audio disk, insert no disk or reinsert the CD-ROM and check, if the status
379 bits change accordingly. The status bits are the most likely point, where
380 the drive manufacturers may implement changes.
381
382If you still don't succeed, a good point to start is to look in aztcd.c in
383function aztcd_init, where the drive should be detected during init. Do the
384following:
385-reboot the system with boot parameter 'aztcd=<your base address>,0x79'. With
386 parameter 0x79 most of the drive version detection is bypassed. After that
387 you should see the complete version string including leading and trailing
388 blanks during init.
389 Now adapt the statement
390 if ((result[1]=='A')&&(result[2]=='Z' ...)
391 in aztcd_init() to exactly match the first 3 or 4 letters you have seen.
392-Another point is the 'smart' card detection feature in aztcd_init(). Normally
393 the CD-ROM drive is ready, when aztcd_init is trying to read the version
394 string and a time consuming ACMD_SOFT_RESET command can be avoided. This is
395 detected by looking, if AFL_OP_OK can be read correctly. If the CD-ROM drive
396 hangs in some unknown state, e.g. because of an error before a warm start or
397 because you first operated under DOS, even the version string may be correct,
398 but the following commands will not. Then change the code in such a way,
399 that the ACMD_SOFT_RESET is issued in any case, by substituting the
400 if-statement 'if ( ...=AFL_OP_OK)' by 'if (1)'.
401
402If you succeed, please mail me the exact version string of your drive and
403the code modifications, you have made together with a short explanation.
404If you don't succeed, you may mail me the output of the debugging messages.
405But remember, they are only useful, if they are exact and complete and you
406describe in detail your hardware setup and what you did (cold/warm reboot,
407with/without DOS, DOS-driver started/not started, which Linux-commands etc.)
408
409
4109. TECHNICAL HISTORY OF THE DRIVER
411The AZTECH-Driver is a rework of the Mitsumi-Driver. Four major items had to
412be reworked:
413
414a) The Mitsumi drive does issue complete status information acknowledging
415each command, the Aztech drive does only signal that the command was
416processed. So whenever the complete status information is needed, an extra
417ACMD_GET_STATUS command is issued. The handshake procedure for the drive
418can be found in the functions aztSendCmd(), sendAztCmd() and getAztStatus().
419
420b) The Aztech Drive does not have a ACMD_GET_DISK_INFO command, so the
421necessary info about the number of tracks (firstTrack, lastTrack), disk
422length etc. has to be read from the TOC in the lead in track (see function
423aztGetDiskInfo()).
424
425c) Whenever data is read from the drive, the Mitsumi drive is started with a
426command to read an indefinite (0xffffff) number of sectors. When the appropriate
427number of sectors is read, the drive is stopped by a ACDM_STOP command. This
428does not work with the Aztech drive. I did not find a way to stop it. The
429stop and pause commands do only work in AUDIO mode but not in DATA mode.
430Therefore I had to modify the 'finite state machine' in function azt_poll to
431only read a certain number of sectors and then start a new read on demand. As I
432have not completely understood, how the buffer/caching scheme of the Mitsumi
433driver was implemented, I am not sure, if I have covered all cases correctly,
434whenever you get timeout messages, the bug is most likely to be in that
435function azt_poll() around switch(cmd) .... case ACD_S_DATA.
436
437d) I did not get information about changing drive mode. So I doubt, that the
438code around function azt_poll() case AZT_S_MODE does work. In my test I have
439not been able to switch to reading in raw mode. For reading raw mode, Aztech
440uses a different command than for cooked mode, which I only have implemen-
441ted in the ioctl-section but not in the section which is used by the ISO9660.
442
443The driver was developed on an AST PC with Intel 486/DX2, 8MB RAM, 340MB IDE
444hard disk and on an AST PC with Intel Pentium 60MHz, 16MB RAM, 520MB IDE
445running Linux kernel version 1.0.9 from the LST 1.8 Distribution. The kernel
446was compiled with gcc.2.5.8. My CD-ROM drive is an Aztech CDA268-01A. My
447drive says, that it has Firmware Version AZT26801A1.3. It came with an ISA-bus
448interface card and works with polled I/O without DMA and without interrupts.
449The code for all other drives was 'remote' tested and debugged by a number of
450volunteers on the Internet.
451
452Points, where I feel that possible problems might be and all points where I
453did not completely understand the drive's behaviour or trust my own code are
454marked with /*???*/ in the source code. There are also some parts in the
455Mitsumi driver, where I did not completely understand their code.
456
457
45810. ACKNOWLEDGMENTS
459Without the help of P.Bush, Aztech, who delivered technical information
460about the Aztech Drive and without the help of E.Moenkeberg, GWDG, who did a
461great job in analyzing the command structure of various CD-ROM drives, this
462work would not have been possible. E.Moenkeberg was also a great help in
463making the software 'kernel ready' and in answering many of the CDROM-related
464questions in the newsgroups. He really is *the* Linux CD-ROM guru. Thanks
465also to all the guys on the Internet, who collected valuable technical
466information about CDROMs.
467
468Joe Nardone (joe@access.digex.net) was a patient tester even for my first
469trial, which was more than slow, and made suggestions for code improvement.
470Especially the 'finite state machine' azt_poll() was rewritten by Joe to get
471clean C code and avoid the ugly 'gotos', which I copied from mcd.c.
472
473Robby Schirmer (schirmer@fmi.uni-passau.de) tested the audio stuff (ioctls)
474and suggested a lot of patches for them.
475
476Joseph Piskor and Peter Nugent were the first users with the ORCHID CD3110
477and also were very patient with the problems which occurred.
478
479Reinhard Max delivered the information for the CDROM-interface of the
480SoundWave32 soundcards.
481
482Jochen Kunz and Olaf Kaluza delivered the information for supporting Conrad's
483TXC drive.
484
485Hilmar Berger delivered the patches for supporting CyCDROM CR520ie.
486
487Anybody, who is interested in these items should have a look at 'ftp.gwdg.de',
488directory 'pub/linux/cdrom' and at 'ftp.cdrom.com', directory 'pub/cdrom'.
489
49011. PROGRAMMING ADD ONs: cdplay.c
491You can use the ioctl-functions included in aztcd.c in your own programs. As
492an example on how to do this, you will find a tiny CD Player for audio CDs
493named 'cdplay.c'. It allows you to play audio CDs. You can play a specified
494track, pause and resume or skip tracks forward and backwards. If you quit the
495program without stopping the drive, playing is continued. You can also
496(mis)use cdplay to read and hexdump data disks. You can find the code in the
497APPENDIX of this file, which you should cut out with an editor and store in a
498separate file 'cdplay.c'. To compile it and make it executable, do
499 gcc -s -Wall -O2 -L/usr/lib cdplay.c -o /usr/local/bin/cdplay # compiles it
500 chmod +755 /usr/local/bin/cdplay # makes it executable
501 ln -s /dev/aztcd0 /dev/cdrom # creates a link
502 (for /usr/lib substitute the top level directory, where your include files
503 reside, and for /usr/local/bin the directory, where you want the executable
504 binary to reside )
505
506You have to set the correct permissions for cdplay *and* for /dev/mcd0 or
507/dev/aztcd0 in order to use it. Remember, that you should not have /dev/cdrom
508mounted, when you're playing audio CDs.
509
510This program is just a hack for testing the ioctl-functions in aztcd.c. I will
511not maintain it, so if you run into problems, discard it or have a look into
512the source code 'cdplay.c'. The program does only contain a minimum of user
513protection and input error detection. If you use the commands in the wrong
514order or if you try to read a CD at wrong addresses, you may get error messages
515or even hang your machine. If you get STEN_LOW, STEN_LOW_WAIT or segment violation
516error messages when using cdplay, after that, the system might not be stable
517any more, so you'd better reboot. As the ioctl-functions run in kernel mode,
518most normal Linux-multitasking protection features do not work. By using
519uninitialized 'wild' pointers etc., it is easy to write to other users' data
520and program areas, destroy kernel tables etc.. So if you experiment with ioctls
521as always when you are doing systems programming and kernel hacking, you
522should have a backup copy of your system in a safe place (and you also
523should try restoring from a backup copy first)!
524
525A reworked and improved version called 'cdtester.c', which has yet more
526features for testing CDROM-drives can be found in
527Documentation/cdrom/sbpcd, written by E.Moenkeberg.
528
529Werner Zimmermann
530Fachhochschule fuer Technik Esslingen
531(EMail: Werner.Zimmermann@fht-esslingen.de)
532October, 1997
533
534---------------------------------------------------------------------------
535APPENDIX: Source code of cdplay.c
536
537/* Tiny Audio CD Player
538
539 Copyright 1994, 1995, 1996 Werner Zimmermann (Werner.Zimmermann@fht-esslingen.de)
540
541This program originally was written to test the audio functions of the
542AZTECH.CDROM-driver, but it should work with every CD-ROM drive. Before
543using it, you should set a symlink from /dev/cdrom to your real CDROM
544device.
545
546The GNU General Public License applies to this program.
547
548History: V0.1 W.Zimmermann: First release. Nov. 8, 1994
549 V0.2 W.Zimmermann: Enhanced functionality. Nov. 9, 1994
550 V0.3 W.Zimmermann: Additional functions. Nov. 28, 1994
551 V0.4 W.Zimmermann: fixed some bugs. Dec. 17, 1994
552 V0.5 W.Zimmermann: clean 'scanf' commands without compiler warnings
553 Jan. 6, 1995
554 V0.6 W.Zimmermann: volume control (still experimental). Jan. 24, 1995
555 V0.7 W.Zimmermann: read raw modified. July 26, 95
556*/
557
558#include <stdio.h>
559#include <ctype.h>
560#include <sys/ioctl.h>
561#include <sys/types.h>
562#include <fcntl.h>
563#include <unistd.h>
564#include <linux/cdrom.h>
565#include <linux/../../drivers/cdrom/aztcd.h>
566
567void help(void)
568{ printf("Available Commands: STOP s EJECT/CLOSE e QUIT q\n");
569 printf(" PLAY TRACK t PAUSE p RESUME r\n");
570 printf(" NEXT TRACK n REPEAT LAST l HELP h\n");
571 printf(" SUB CHANNEL c TRACK INFO i PLAY AT a\n");
572 printf(" READ d READ RAW w VOLUME v\n");
573}
574
575int main(void)
576{ int handle;
577 unsigned char command=' ', ini=0, first=1, last=1;
578 unsigned int cmd, i,j,k, arg1,arg2,arg3;
579 struct cdrom_ti ti;
580 struct cdrom_tochdr tocHdr;
581 struct cdrom_subchnl subchnl;
582 struct cdrom_tocentry entry;
583 struct cdrom_msf msf;
584 union { struct cdrom_msf msf;
585 unsigned char buf[CD_FRAMESIZE_RAW];
586 } azt;
587 struct cdrom_volctrl volctrl;
588
589 printf("\nMini-Audio CD-Player V0.72 (C) 1994,1995,1996 W.Zimmermann\n");
590 handle=open("/dev/cdrom",O_RDWR);
591 ioctl(handle,CDROMRESUME);
592
593 if (handle<=0)
594 { printf("Drive Error: already playing, no audio disk, door open\n");
595 printf(" or no permission (you must be ROOT in order to use this program)\n");
596 }
597 else
598 { help();
599 while (1)
600 { printf("Type command (h = help): ");
601 scanf("%s",&command);
602 switch (command)
603 { case 'e': cmd=CDROMEJECT;
604 ioctl(handle,cmd);
605 break;
606 case 'p': if (!ini)
607 { printf("Command not allowed - play track first\n");
608 }
609 else
610 { cmd=CDROMPAUSE;
611 if (ioctl(handle,cmd)) printf("Drive Error\n");
612 }
613 break;
614 case 'r': if (!ini)
615 { printf("Command not allowed - play track first\n");
616 }
617 else
618 { cmd=CDROMRESUME;
619 if (ioctl(handle,cmd)) printf("Drive Error\n");
620 }
621 break;
622 case 's': cmd=CDROMPAUSE;
623 if (ioctl(handle,cmd)) printf("Drive error or already stopped\n");
624 cmd=CDROMSTOP;
625 if (ioctl(handle,cmd)) printf("Drive error\n");
626 break;
627 case 't': cmd=CDROMREADTOCHDR;
628 if (ioctl(handle,cmd,&tocHdr)) printf("Drive Error\n");
629 first=tocHdr.cdth_trk0;
630 last= tocHdr.cdth_trk1;
631 if ((first==0)||(first>last))
632 { printf ("--could not read TOC\n");
633 }
634 else
635 { printf("--first track: %d --last track: %d --enter track number: ",first,last);
636 cmd=CDROMPLAYTRKIND;
637 scanf("%i",&arg1);
638 ti.cdti_trk0=arg1;
639 if (ti.cdti_trk0<first) ti.cdti_trk0=first;
640 if (ti.cdti_trk0>last) ti.cdti_trk0=last;
641 ti.cdti_ind0=0;
642 ti.cdti_trk1=last;
643 ti.cdti_ind1=0;
644 if (ioctl(handle,cmd,&ti)) printf("Drive Error\n");
645 ini=1;
646 }
647 break;
648 case 'n': if (!ini++)
649 { if (ioctl(handle,CDROMREADTOCHDR,&tocHdr)) printf("Drive Error\n");
650 first=tocHdr.cdth_trk0;
651 last= tocHdr.cdth_trk1;
652 ti.cdti_trk0=first-1;
653 }
654 if ((first==0)||(first>last))
655 { printf ("--could not read TOC\n");
656 }
657 else
658 { cmd=CDROMPLAYTRKIND;
659 if (++ti.cdti_trk0 > last) ti.cdti_trk0=last;
660 ti.cdti_ind0=0;
661 ti.cdti_trk1=last;
662 ti.cdti_ind1=0;
663 if (ioctl(handle,cmd,&ti)) printf("Drive Error\n");
664 ini=1;
665 }
666 break;
667 case 'l': if (!ini++)
668 { if (ioctl(handle,CDROMREADTOCHDR,&tocHdr)) printf("Drive Error\n");
669 first=tocHdr.cdth_trk0;
670 last= tocHdr.cdth_trk1;
671 ti.cdti_trk0=first+1;
672 }
673 if ((first==0)||(first>last))
674 { printf ("--could not read TOC\n");
675 }
676 else
677 { cmd=CDROMPLAYTRKIND;
678 if (--ti.cdti_trk0 < first) ti.cdti_trk0=first;
679 ti.cdti_ind0=0;
680 ti.cdti_trk1=last;
681 ti.cdti_ind1=0;
682 if (ioctl(handle,cmd,&ti)) printf("Drive Error\n");
683 ini=1;
684 }
685 break;
686 case 'c': subchnl.cdsc_format=CDROM_MSF;
687 if (ioctl(handle,CDROMSUBCHNL,&subchnl))
688 printf("Drive Error\n");
689 else
690 { printf("AudioStatus:%s Track:%d Mode:%d MSF=%d:%d:%d\n", \
691 subchnl.cdsc_audiostatus==CDROM_AUDIO_PLAY ? "PLAYING":"NOT PLAYING",\
692 subchnl.cdsc_trk,subchnl.cdsc_adr, \
693 subchnl.cdsc_absaddr.msf.minute, subchnl.cdsc_absaddr.msf.second, \
694 subchnl.cdsc_absaddr.msf.frame);
695 }
696 break;
697 case 'i': if (!ini)
698 { printf("Command not allowed - play track first\n");
699 }
700 else
701 { cmd=CDROMREADTOCENTRY;
702 printf("Track No.: ");
703 scanf("%d",&arg1);
704 entry.cdte_track=arg1;
705 if (entry.cdte_track<first) entry.cdte_track=first;
706 if (entry.cdte_track>last) entry.cdte_track=last;
707 entry.cdte_format=CDROM_MSF;
708 if (ioctl(handle,cmd,&entry))
709 { printf("Drive error or invalid track no.\n");
710 }
711 else
712 { printf("Mode %d Track, starts at %d:%d:%d\n", \
713 entry.cdte_adr,entry.cdte_addr.msf.minute, \
714 entry.cdte_addr.msf.second,entry.cdte_addr.msf.frame);
715 }
716 }
717 break;
718 case 'a': cmd=CDROMPLAYMSF;
719 printf("Address (min:sec:frame) ");
720 scanf("%d:%d:%d",&arg1,&arg2,&arg3);
721 msf.cdmsf_min0 =arg1;
722 msf.cdmsf_sec0 =arg2;
723 msf.cdmsf_frame0=arg3;
724 if (msf.cdmsf_sec0 > 59) msf.cdmsf_sec0 =59;
725 if (msf.cdmsf_frame0> 74) msf.cdmsf_frame0=74;
726 msf.cdmsf_min1=60;
727 msf.cdmsf_sec1=00;
728 msf.cdmsf_frame1=00;
729 if (ioctl(handle,cmd,&msf))
730 { printf("Drive error or invalid address\n");
731 }
732 break;
733#ifdef AZT_PRIVATE_IOCTLS /*not supported by every CDROM driver*/
734 case 'd': cmd=CDROMREADCOOKED;
735 printf("Address (min:sec:frame) ");
736 scanf("%d:%d:%d",&arg1,&arg2,&arg3);
737 azt.msf.cdmsf_min0 =arg1;
738 azt.msf.cdmsf_sec0 =arg2;
739 azt.msf.cdmsf_frame0=arg3;
740 if (azt.msf.cdmsf_sec0 > 59) azt.msf.cdmsf_sec0 =59;
741 if (azt.msf.cdmsf_frame0> 74) azt.msf.cdmsf_frame0=74;
742 if (ioctl(handle,cmd,&azt.msf))
743 { printf("Drive error, invalid address or unsupported command\n");
744 }
745 k=0;
746 getchar();
747 for (i=0;i<128;i++)
748 { printf("%4d:",i*16);
749 for (j=0;j<16;j++)
750 { printf("%2x ",azt.buf[i*16+j]);
751 }
752 for (j=0;j<16;j++)
753 { if (isalnum(azt.buf[i*16+j]))
754 printf("%c",azt.buf[i*16+j]);
755 else
756 printf(".");
757 }
758 printf("\n");
759 k++;
760 if (k>=20)
761 { printf("press ENTER to continue\n");
762 getchar();
763 k=0;
764 }
765 }
766 break;
767 case 'w': cmd=CDROMREADRAW;
768 printf("Address (min:sec:frame) ");
769 scanf("%d:%d:%d",&arg1,&arg2,&arg3);
770 azt.msf.cdmsf_min0 =arg1;
771 azt.msf.cdmsf_sec0 =arg2;
772 azt.msf.cdmsf_frame0=arg3;
773 if (azt.msf.cdmsf_sec0 > 59) azt.msf.cdmsf_sec0 =59;
774 if (azt.msf.cdmsf_frame0> 74) azt.msf.cdmsf_frame0=74;
775 if (ioctl(handle,cmd,&azt))
776 { printf("Drive error, invalid address or unsupported command\n");
777 }
778 k=0;
779 for (i=0;i<147;i++)
780 { printf("%4d:",i*16);
781 for (j=0;j<16;j++)
782 { printf("%2x ",azt.buf[i*16+j]);
783 }
784 for (j=0;j<16;j++)
785 { if (isalnum(azt.buf[i*16+j]))
786 printf("%c",azt.buf[i*16+j]);
787 else
788 printf(".");
789 }
790 printf("\n");
791 k++;
792 if (k>=20)
793 { getchar();
794 k=0;
795 }
796 }
797 break;
798#endif
799 case 'v': cmd=CDROMVOLCTRL;
800 printf("--Channel 0 Left (0-255): ");
801 scanf("%d",&arg1);
802 printf("--Channel 1 Right (0-255): ");
803 scanf("%d",&arg2);
804 volctrl.channel0=arg1;
805 volctrl.channel1=arg2;
806 volctrl.channel2=0;
807 volctrl.channel3=0;
808 if (ioctl(handle,cmd,&volctrl))
809 { printf("Drive error or unsupported command\n");
810 }
811 break;
812 case 'q': if (close(handle)) printf("Drive Error: CLOSE\n");
813 exit(0);
814 case 'h': help();
815 break;
816 default: printf("unknown command\n");
817 break;
818 }
819 }
820 }
821 return 0;
822}