aztcd 42 KB

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