OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [uclinux/] [uClinux-2.0.x/] [Documentation/] [cdrom/] [aztcd] - Blame information for rev 1765

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.