summaryrefslogtreecommitdiffstats
path: root/drivers/block/README.sbpcd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/README.sbpcd')
-rw-r--r--drivers/block/README.sbpcd823
1 files changed, 675 insertions, 148 deletions
diff --git a/drivers/block/README.sbpcd b/drivers/block/README.sbpcd
index 74f188c26..6a40abfb0 100644
--- a/drivers/block/README.sbpcd
+++ b/drivers/block/README.sbpcd
@@ -1,44 +1,60 @@
-This README belongs to release 2.8 or newer of the SoundBlaster Pro
-(Matsushita, Kotobuki, Panasonic, CreativeLabs) CD-ROM driver for Linux.
+This README belongs to release 3.7 or newer of the SoundBlaster Pro
+(Matsushita, Kotobuki, Panasonic, CreativeLabs, Longshine and TEAC)
+CD-ROM driver for Linux.
The driver is able to drive the whole family of "traditional" IDE-style (that
-has nothing to do with the new "Enhanced IDE" drive standard) Matsushita,
+is NOT the new "Enhanced IDE" or "ATAPI" drive standard) Matsushita,
Kotobuki, Panasonic drives, sometimes labelled as "CreativeLabs". The
well-known drives are CR-521, CR-522, CR-523, CR-562, CR-563.
The Longshine LCS-7260 is a double-speed drive which uses the "old"
-Matsushita command set. It should be fully supported soon, too.
+Matsushita command set. It is supported now - with help by Serge Robyns.
-There exists an "IBM External ISA CD-ROM Drive" which in fact is a CR-562
+There exists an "IBM External ISA CD-ROM Drive" which in fact is a CR-563
with a special controller board. This drive is supported (the interface is
of the "LaserMate" type), and it is possibly the best buy today (cheaper than
an internal drive, and you can use it as an internal, too - f.e. plug it into
-a soundcard). If you own such a drive, please mail me the DOS driver (gzipped
-and uuencoded) and the specifications (exact name, address range etc.) I still
-have to confirm my opinion. ;-)
+a soundcard).
-This driver is NOT for Mitsumi or Sony or Aztech or Philips or XXX drives.
-The matter that some other brand's drives work with newer sound card
-interfaces does NOT make the drives compatible. :-)
+CreativeLabs has a new drive "CD-200". Support is under construction.
+Drive detection and playing audio should already work. I need qualified
+feedback about the bugs within the data functions or a drive (I never saw
+a CD200).
-It will work with the soundcard interfaces (SB Pro, SB 16, Galaxy, SoundFX,
-...) and/or with the "no-sound" cards (Panasonic CI-101P, LaserMate,
+The quad-speed TEAC CD-55A drive is supported. The routines may still be
+a little bit buggy, but the data rate already reaches 500 kB/sec if you
+set SBP_BUFFER_FRAMES to 64. The drive is able to deliver 600 kB/sec, so
+this has to get a point of work.
+
+This driver is NOT for Mitsumi or Sony or Aztech or Philips or XXX drives,
+and this driver is in no way usable for any new IDE ATAPI drive.
+
+This driver will work with the soundcard interfaces (SB Pro, SB 16, Galaxy,
+SoundFX, ...) and/or with the "no-sound" cards (Panasonic CI-101P, LaserMate,
WDH-7001C, Longshine LCS-6853, older Aztech cards, ...).
+
It should work too now with the "configurable" interface "Sequoia S-1000",
which is found on the Spea Media FX sound card. I still need feedback about
-this.
+this, or such a card. Anyways, the procedure "boot DOS and wait until
+CONFIG.SYS is done, then use CTL-ALT-DEL to boot Linux" should make it
+work.
+
The interface type has to get configured in /usr/include/linux/sbpcd.h,
because the behavior of some sound card interfaces is different.
-The driver respects different drive firmware releases - my old drive is a 2.11,
-but it should work with "old" drives <2.01 ... >3.00 and with "new" drives
-(which count the releases around 0.75 or 1.00).
+With some TEAC drives I have seen interface cards which seem to lack the
+"drive select" lines; always drive 0 gets addressed. To avoid "mirror drives"
+with such interface cards, set MAX_DRIVES to 1 and jumper your drive to ID 0.
+
+The driver respects all known drive firmware releases - my old drive is a 2.11,
+but it should work with CR-52x drives <2.01 ... >3.00 and with CR-56x drives
+<0.75 .. 5.00.
Up to 4 drives per interface card, and up to 4 interface cards are supported.
-CR-52x ("old"), CR-56x ("new") and LCS drives can be mixed, but the CR-521
-ones are hard-wired to drive ID 0. The drives have to use different drive IDs,
-and each drive has to get a unique minor number (0...3), corresponding to it's
-drive ID.
+All supported drive families can be mixed, but the CR-521 drives are
+hard-wired to drive ID 0. The drives have to use different drive IDs, and each
+drive has to get a unique minor number (0...3), corresponding indirectly to
+its drive ID.
The drive IDs may be selected freely from 0 to 3 - they do not have to be in
consecutive order.
@@ -59,40 +75,38 @@ to change old drives to any ID, too. He writes in this sense:
did not work with other values. If the values are not good,
ID 3 behaves like ID 0."
-To use more than 4 drives (now that the single-speed CR-521's are as cheap as
-50$), you need a second interface card and you have to "duplicate" the driver.
-Just copy sbpcd.c into sbpcd2.c and so forth and change SBPCD_ISSUE (at top
-of sbpcd2.c) accordingly.
+To use more than 4 drives, you simply need a second controller card at a
+different address and a second cable.
The driver supports reading of data from the CD and playing of audio tracks.
The audio part should run with WorkMan, xcdplayer, with the "non-X11" products
CDplayer and WorkBone - tell me if it is not compatible with other software.
-With the "new" drive family CR-562 and CR-563, the reading of audio frames is
-possible. This is currently implemented by an IOCTL function which reads only
-up to 4 frames of 2352 bytes at once. Reading more than 1 frame at once misses
-some chunks at each frame boundary. Reading the same frame a second time gives
-different data; the frame data start at a different position. But all read
-bytes are valid, and we always read 98 consecutive chunks (of 24 Bytes) as a
-frame. This lack has to get corrected by higher level software which reads the
-same frame again and tries to find and eliminate overlapping chunks
-(24-byte-pieces).
-
-The transfer rate with reading audio (1-frame-pieces) is as slow as 32 kB/sec.
-This could be better reading bigger chunks, but the "missing" chunks occur at
-the beginning of each single frame.
+With the CR-562 and CR-563 drives, the reading of audio frames is possible.
+This is implemented by an IOCTL function which reads READ_AUDIO frames of
+2352 bytes at once (configurable with the "READ_AUDIO" define, default is 0).
+Reading the same frame a second time gives different data; the frame data
+start at a different position, but all read bytes are valid, and we always
+read 98 consecutive chunks (of 24 Bytes) as a frame. Reading more than 1 frame
+at once possibly misses some chunks at each frame boundary. This lack has to
+get corrected by external, "higher level" software which reads the same frame
+again and tries to find and eliminate overlapping chunks (24-byte-pieces).
+
+The transfer rate with reading audio (1-frame-pieces) currently is very slow.
+This can be better reading bigger chunks, but the "missing" chunks possibly
+occur at the beginning of each single frame.
The software interface possibly may change a bit the day the SCSI driver
supports it too.
-With the CR-562 and CR-563 drives, MultiSession is supported, "ManySession"
-(not recommended, see below) alternatively.
-Photo CDs work, too (the "old" drives like CR-521 can access only the first
+With all but the CR-52x drives, MultiSession is supported.
+Photo CDs work (the "old" drives like CR-521 can access only the first
session of a photoCD).
-At ftp.gwdg.de:/pub/linux/hpcdtoppm/ is Hadmut Danisch's package to convert
-photo CD image files.
+At ftp.gwdg.de:/pub/linux/hpcdtoppm/ you will find Hadmut Danisch's package to
+convert photo CD image files and Gerd Knorr's viewing utility.
-The transfer rate will reach 150 kB/sec with "old" drives and 300 kB/sec with
-double-speed drives. XA (PhotoCD) disks with "old" drives give only 50 kB/sec.
+The transfer rate will reach 150 kB/sec with "old" drives, 300 kB/sec with
+double-speed drives, and about 500 kB/sec with quad speed drives.
+XA (PhotoCD) disks with "old" drives give only 50 kB/sec.
This release is part of the standard kernel and consists of
- this README file
@@ -113,11 +127,13 @@ To install:
Most "compatible" sound cards (for example "Highscreen", "SoundFX"
and "Galaxy") need "SBPRO 0".
The "no-sound" board from OmniCd needs the "SBPRO 1" setup.
+ All other "no-sound" boards need the "SBPRO 0" setup.
The Spea Media FX sound card needs "SBPRO 2".
- sbpcd.c holds some examples in it's auto-probe list.
+ sbpcd.c holds some examples in its auto-probe list.
If you configure "SBPRO" wrong, the playing of audio CDs will work,
but you will not be able to mount a data CD.
a2. Tell the address of your CDROM_PORT (not of the sound port).
+ a3. Set DISTRIBUTION to 0.
b. Additionally for 2.a1 and 2.a2, the setup may be done during
boot time (via the "kernel command line" or "LILO option"):
sbpcd=0x230,SoundBlaster
@@ -125,31 +141,33 @@ To install:
sbpcd=0x320,LaserMate
or
sbpcd=0x330,SPEA
- (these strings are case sensitive!).
This is especially useful if you install a fresh distribution.
2. "cd /usr/src/linux" and do a "make config" and select "y" for Matsushita
CD-ROM support and for ISO9660 FileSystem support. If you do not have a
- second, third, or fourth controller and/or did not prepare sbpcd2 etc.,
- do not say "y" to the secondary Matsushita CD-ROM questions.
+ second, third, or fourth controller installed, do not say "y" to the
+ secondary Matsushita CD-ROM questions.
SCSI and/or SCSI CD-ROM support is not needed.
3. Then do a "make dep", then make the kernel image ("make zlilo" or else).
4. Make the device file(s). The driver uses definitely and exclusive the
MAJOR 25, so do
- mknod /dev/sbpcd b 25 0 (if you have only drive #0)
+ mknod /dev/sbpcd b 25 0 (if you have only one drive)
and/or
mknod /dev/sbpcd0 b 25 0
mknod /dev/sbpcd1 b 25 1
mknod /dev/sbpcd2 b 25 2
mknod /dev/sbpcd3 b 25 3
to make the node(s).
- Take care that you create a node with the same MINOR as your drive ID is.
- So, if the DOS driver tells you have drive id #3, you have to
- mknod /dev/<any_name> b 25 3
+
+ The driver no longer uses the "AT bus style" device numbering; the SCSI
+ scheme is used now; that means, the "first found" drive gets MINOR 0
+ (regardless to its jumpered ID), the "next found" (at the same cable)
+ gets MINOR 1, ...
For a second interface board, you have to make nodes like
mknod /dev/sbpcd4 b 26 0
+ mknod /dev/sbpcd5 b 26 1
and so on. Use the MAJORs 26, 27, 28.
If you further make a link like
@@ -168,29 +186,34 @@ and see the contents of your CD in the /CD directory, and/or hear music with
"workman -c /dev/sbpcd &".
+Using sbpcd as a "loadable module":
+-----------------------------------
+
+If you do NOT select "Matsushita/Panasonic CDROM driver support" during the
+"make config" of your kernel, you can build the "loadable module" sbpcd.o.
+Read /usr/src/linux/README.modules on this.
+
+If sbpcd gets used as a module, the support of more than one interface
+card (i.e. drives 4...15) is disabled.
+
+You can specify interface address and type with the "insmod" command like:
+ # insmod /usr/src/linux/modules/sbpcd.o sbpcd=0x340,0
+or
+ # insmod /usr/src/linux/modules/sbpcd.o sbpcd=0x230,1
+where the last number represents the SBPRO setting (no strings allowed here).
+
+
Things of interest:
-------------------
-The driver is configured to try the SoundBlaster Pro type of interface at
-I/O port 0x0230 first. If this is not appropriate, sbpcd.h should get changed
+The driver is configured to try the LaserMate type of interface at I/O port
+0x0340 first. If this is not appropriate, sbpcd.h should get changed
(you will find the right place - just at the beginning).
-No DMA and no IRQ is used, so the IRQ line stays free for the SB Pro sound
-drivers.
-
-To reduce or increase the amount of kernel messages, edit sbpcd.c and change
-the initialization of the variable "sbpcd_debug". This is the way to get rid
-of the initial warning message block, too.
+No DMA and no IRQ is used.
-With "#define MANY_SESSION 1" (sbpcd.c), the driver can use "many-session" CDs.
-This will work only with "new" drives like CR-562 or CR-563. That is NOT
-multisession - it is a CD with multiple independent sessions, each containing
-block addresses as if it were the only session. With this feature enabled, the
-driver will read the LAST session. Without it, the FIRST session gets read.
-If you would like the support of reading "in-between" sessions, drop me a mail
-and some food for the soul. :-)
-Those "many-session" CDs can get made by CDROM writers like Philips CDD 521.
-If you enable this feature, it is impossible to read true multisession CDs.
+To reduce or increase the amount of kernel messages, edit sbpcd.c and play
+with the "DBG_xxx" switches (initialization of the variable "sbpcd_debug").
The driver uses the "variable BLOCK_SIZE" feature. To use it, you have to
specify "block=2048" as a mount option. Doing this will disable the direct
@@ -204,65 +227,28 @@ do not use block=2048 with those.
At the beginning of sbpcd.c, you will find some "#define"s (f.e. EJECT and
JUKEBOX). With that, you can configure the driver for some special things.
-The following program disables the auto-eject feature during runtime:
-
-/*=================== begin program ========================================*/
-/*
- * set the "eject" switch (enable/disable auto-ejecting)
- *
- * (c) 1994 Eberhard Moenkeberg <emoenke@gwdg.de>
- * may be used & enhanced freely
- *
- * Disables or enables the auto-eject feature at run time.
- * Works only if a CD is in the drive (just like the feature itself ;-)
- * Useful for a "quiet" shutdown or for weird audio player programs.
- */
-#define EJECT 0 /* 0: disable, 1: enable auto-ejecting */
-
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <linux/cdrom.h>
-
-static char arg=EJECT;
-static int drive;
-static int err;
-
-main(int argc, char *argv[])
-{
-/*
- * open /dev/cdrom
- */
- drive=open("/dev/cdrom", 0);
- if (drive<0)
- {
- fprintf(stderr, "can't open drive /dev/cdrom.\n");
- exit (-1);
- }
-/*
- * set EJECT_SW
- */
- err=ioctl(drive, CDROMEJECT_SW, arg);
- if (err!=0)
- {
- fprintf(stderr, "can't set EJECT_SW (error %d).\n", err);
- exit (-1);
- }
- else
- fprintf(stdout, "EJECT_SW set to %d\n", arg);
-}
-/*===================== end program ========================================*/
+You can use the appended program "cdtester" to set the auto-eject feature
+during runtime. Jeff Tranter's "eject" utility can do this, too (and more)
+for you.
+There is a new ioctl CDROMMULTISESSION to obtain with a user program if
+the CD is an XA disk and - if it is - where the last session starts. The
+"cdtester" program illustrates how to call it.
Auto-probing at boot time:
--------------------------
-The driver does auto-probing at many well-known interface card addresses. The
-idea to do that came from Adam J. Richter (YGGDRASIL). Some well-known
-addresses are excluded from auto-probing because they can cause a hang if an
-ethernet card gets touched.
+The driver does auto-probing at many well-known interface card addresses,
+but not all:
+Some probings can cause a hang if an NE2000 ethernet card gets touched, because
+SBPCD's auto-probing happens before the initialization of the net drivers.
+Those "hazardous" addresses are excluded from auto-probing; the "kernel
+command line" feature has to be used during installation if you have your
+drive at those addresses. The "module" version is allowed to probe at those
+addresses, too.
-This auto-probing looks first at the configured address resp. the address
+The auto-probing looks first at the configured address resp. the address
submitted by the kernel command line. With this, it is possible to use this
driver within installation boot floppies, and for any non-standard address,
too.
@@ -273,20 +259,30 @@ o.k., but you will get I/O errors during mount). In that case, use the "kernel
command line" feature and specify address & type at boot time to find out the
right setup.
-SBPCD's auto-probing happens before the initialization of the net drivers. That
-makes a hang possible if an ethernet card gets touched.
-
For every-day use, address and type should get configured within sbpcd.h. That
will stop the auto-probing due to success with the first try.
+The kernel command "sbpcd=0" suppresses each auto-probing and causes
+the driver not to find any drive; it is meant for people who love sbpcd
+so much that they do not want to miss it, even if they miss the drives. ;-)
+
+If you configure "#define CDROM_PORT 0" in sbpcd.h, the auto-probing is
+initially disabled and needs an explicit kernel command to get activated.
+Once activated, it does not stop before success or end-of-list. This may be
+useful within "universal" CDROM installation boot floppies (but using the
+loadable module would be better because it allows an "extended" auto-probing
+without fearing NE2000 cards).
+
+To shorten the auto-probing list to a single entry, set DISTRIBUTION 0 within
+sbpcd.h.
+
Setting up address and interface type:
--------------------------------------
-If your I/O port address is not 0x0230 or if you use a "no-sound" interface
-other than OmniCD, you have to look for the #defines near the beginning of
-sbpcd.h and configure them: set SBPRO to 0 or 1 or 2, and change CDROM_PORT to
-the address of your CDROM I/O port.
+If your I/O port address is not 0x340, you have to look for the #defines near
+the beginning of sbpcd.h and configure them: set SBPRO to 0 or 1 or 2, and
+change CDROM_PORT to the address of your CDROM I/O port.
Most of the "SoundBlaster compatible" cards behave like the no-sound
interfaces!
@@ -300,19 +296,19 @@ you can set SOUND_BASE (in sbpcd.h) to get it done with your card, too...
Using audio CDs:
----------------
-Workman, WorkBone, xcdplayer and cdplayer should work good now, even with the
-double-speed drives.
+Workman, WorkBone, xcdplayer, cdplayer and the nice little tool "cdplay" (see
+README.aztcd from the Aztech driver package) should work.
The program CDplayer likes to talk to "/dev/mcd" only, xcdplayer wants
-"/dev/rsr0", workman loves "/dev/sr0" - so, do the appropriate links for using
-them without the need of supplying parameters.
+"/dev/rsr0", workman loves "/dev/sr0" or "/dev/cdrom" - so, do the appropriate
+links for using them without the need of supplying parameters.
Copying audio tracks:
---------------------
-The following little program will copy track 2 of an audio CD into the file
-"track02":
+The following program will copy track 1 (or a piece of it) from an audio CD
+into the file "track01":
/*=================== begin program ========================================*/
/*
@@ -335,13 +331,14 @@ The following little program will copy track 2 of an audio CD into the file
* This is only an example of the low-level access routine. The read data are
* pure 16-bit CDDA values; they have to get converted to make sound out of
* them.
+ * It is no fun to listen to it without prior overlap/underlap correction!
*/
#include <stdio.h>
#include <sys/ioctl.h>
#include <linux/cdrom.h>
static struct cdrom_tochdr hdr;
-static struct cdrom_tocentry entry[100];
+static struct cdrom_tocentry entry[101];
static struct cdrom_read_audio arg;
static u_char buffer[CD_FRAMESIZE_RAW];
static int datafile, drive;
@@ -400,10 +397,9 @@ main(int argc, char *argv[])
/*
* ask for track number (not implemented here)
*/
-track=2;
-#if 0 /* just read a little piece */
-entry[track].cdte_addr.lba=170;
-entry[track+1].cdte_addr.lba=190;
+track=1;
+#if 0 /* just read a little piece (4 seconds) */
+entry[track+1].cdte_addr.lba=entry[track].cdte_addr.lba+300;
#endif
/*
* read track into file
@@ -420,20 +416,19 @@ entry[track+1].cdte_addr.lba=190;
arg.nframes=1;
arg.buf=&buffer[0];
limit=entry[track+1].cdte_addr.lba;
- for (i=arg.addr.lba;i<limit;i++)
+ for (;arg.addr.lba<limit;arg.addr.lba++)
{
err=ioctl(drive, CDROMREADAUDIO, &arg);
if (err!=0)
{
- fprintf(stderr, "can't read frame #%d (error %d).\n",
- i-entry[track].cdte_addr.lba+1, err);
- exit (-1);
+ fprintf(stderr, "can't read abs. frame #%d (error %d).\n",
+ arg.addr.lba, err);
}
j=write(datafile, &buffer[0], CD_FRAMESIZE_RAW);
if (j!=CD_FRAMESIZE_RAW)
{
- fprintf(stderr,"I/O error (datafile) at frame %d\n",
- i-entry[track].cdte_addr.lba+1);
+ fprintf(stderr,"I/O error (datafile) at rel. frame %d\n",
+ arg.addr.lba-entry[track].cdte_addr.lba);
}
arg.addr.lba++;
}
@@ -457,10 +452,8 @@ is an all-zero number. I guess now almost no CD holds such a number.
Bug reports, comments, wishes, donations (technical information is a donation,
too :-) etc. to
emoenke@gwdg.de
- or to eberhard_moenkeberg@rollo.central.de
or to my FIDO address: Eberhard Moenkeberg, 2:2437/210.27
-
SnailMail address, preferable for CD editors if they want to submit a free
"cooperation" copy:
Eberhard Moenkeberg
@@ -468,3 +461,537 @@ SnailMail address, preferable for CD editors if they want to submit a free
D-37083 Goettingen
Germany
---
+
+
+Appendix -- the "cdtester" utility:
+
+/*
+ * cdtester.c -- test the audio functions of a CD driver
+ *
+ * (c) 1995 Eberhard Moenkeberg <emoenke@gwdg.de>
+ * published under the GPL
+ *
+ * made under heavy use of the "Tiny Audio CD Player"
+ * from Werner Zimmermann <zimmerma@rz.fht-esslingen.de>
+ * (see linux/drivers/block/README.aztcd)
+ */
+#undef AZT_PRIVATE_IOCTLS /* not supported by every CDROM driver */
+#define SBP_PRIVATE_IOCTLS /* not supported by every CDROM driver */
+
+#include <stdio.h>
+#include <stdio.h>
+#include <malloc.h>
+#include <sys/ioctl.h>
+#include <linux/cdrom.h>
+
+#ifdef AZT_PRIVATE_IOCTLS
+#include <linux/aztcd.h>
+#endif AZT_PRIVATE_IOCTLS
+#ifdef SBP_PRIVATE_IOCTLS
+#include <linux/sbpcd.h>
+#include <linux/fs.h>
+#endif SBP_PRIVATE_IOCTLS
+
+struct cdrom_tochdr hdr;
+struct cdrom_tochdr tocHdr;
+struct cdrom_tocentry TocEntry[101];
+struct cdrom_tocentry entry;
+struct cdrom_multisession ms_info;
+struct cdrom_read_audio read_audio;
+struct cdrom_ti ti;
+struct cdrom_subchnl subchnl;
+struct cdrom_msf msf;
+struct cdrom_volctrl volctrl;
+#ifdef AZT_PRIVATE_IOCTLS
+union
+{
+ struct cdrom_msf msf;
+ unsigned char buf[CD_FRAMESIZE_RAW];
+} azt;
+#endif AZT_PRIVATE_IOCTLS
+int i, i1, i2, i3, j, k;
+unsigned char sequence=0;
+unsigned char command[80];
+unsigned char first=1, last=1;
+char *default_device="/dev/cdrom";
+char dev[20];
+char filename[20];
+int drive;
+int datafile;
+int rc;
+
+void help(void)
+{
+ printf("Available Commands:\n");
+ printf("STOP s EJECT e QUIT q\n");
+ printf("PLAY TRACK t PAUSE p RESUME r\n");
+ printf("NEXT TRACK n REPEAT LAST l HELP h\n");
+ printf("SUBCHANNEL_Q c TRACK INFO i PLAY AT a\n");
+ printf("READ d READ RAW w READ AUDIO A\n");
+ printf("MS-INFO M TOC T START S\n");
+ printf("SET EJECTSW X DEVICE D DEBUG Y\n");
+ printf("AUDIO_BUFSIZ Z RESET R BLKRASET B\n");
+ printf("SET VOLUME v GET VOLUME V\n");
+}
+
+/*
+ * convert MSF number (3 bytes only) to Logical_Block_Address
+ */
+int msf2lba(u_char *msf)
+{
+ int i;
+
+ i=(msf[0] * CD_SECS + msf[1]) * CD_FRAMES + msf[2] - CD_BLOCK_OFFSET;
+ if (i<0) return (0);
+ return (i);
+}
+/*
+ * convert logical_block_address to m-s-f_number (3 bytes only)
+ */
+void lba2msf(int lba, unsigned char *msf)
+{
+ lba += CD_BLOCK_OFFSET;
+ msf[0] = lba / (CD_SECS*CD_FRAMES);
+ lba %= CD_SECS*CD_FRAMES;
+ msf[1] = lba / CD_FRAMES;
+ msf[2] = lba % CD_FRAMES;
+}
+
+int init_drive(char *dev)
+{
+ unsigned char msf_ent[3];
+
+ /*
+ * open the device
+ */
+ drive=open(dev,0);
+ if (drive<0) return (-1);
+ /*
+ * get TocHeader
+ */
+ printf("getting TocHeader...\n");
+ rc=ioctl(drive,CDROMREADTOCHDR,&hdr);
+ if (rc!=0)
+ {
+ printf("can't get TocHeader (error %d).\n",rc);
+ return (-2);
+ }
+ else
+ first=hdr.cdth_trk0;
+ last=hdr.cdth_trk1;
+ printf("TocHeader: %d %d\n",hdr.cdth_trk0,hdr.cdth_trk1);
+ /*
+ * get and display all TocEntries
+ */
+ printf("getting TocEntries...\n");
+ for (i=1;i<=hdr.cdth_trk1+1;i++)
+ {
+ if (i!=hdr.cdth_trk1+1) TocEntry[i].cdte_track = i;
+ else TocEntry[i].cdte_track = CDROM_LEADOUT;
+ TocEntry[i].cdte_format = CDROM_LBA;
+ rc=ioctl(drive,CDROMREADTOCENTRY,&TocEntry[i]);
+ if (rc!=0)
+ {
+ printf("can't get TocEntry #%d (error %d).\n",i,rc);
+ }
+ else
+ {
+ lba2msf(TocEntry[i].cdte_addr.lba,&msf_ent[0]);
+ if (TocEntry[i].cdte_track==CDROM_LEADOUT)
+ {
+ printf("TocEntry #%02X: %1X %1X %02d:%02d:%02d (lba: 0x%06X) %02X\n",
+ TocEntry[i].cdte_track,
+ TocEntry[i].cdte_adr,
+ TocEntry[i].cdte_ctrl,
+ msf_ent[0],
+ msf_ent[1],
+ msf_ent[2],
+ TocEntry[i].cdte_addr.lba,
+ TocEntry[i].cdte_datamode);
+ }
+ else
+ {
+ printf("TocEntry #%02d: %1X %1X %02d:%02d:%02d (lba: 0x%06X) %02X\n",
+ TocEntry[i].cdte_track,
+ TocEntry[i].cdte_adr,
+ TocEntry[i].cdte_ctrl,
+ msf_ent[0],
+ msf_ent[1],
+ msf_ent[2],
+ TocEntry[i].cdte_addr.lba,
+ TocEntry[i].cdte_datamode);
+ }
+ }
+ }
+ return (hdr.cdth_trk1); /* number of tracks */
+}
+
+void display(int size,unsigned char *buffer)
+{
+ k=0;
+ getchar();
+ for (i=0;i<(size+1)/16;i++)
+ {
+ printf("%4d:",i*16);
+ for (j=0;j<16;j++)
+ {
+ printf(" %02X",buffer[i*16+j]);
+ }
+ printf(" ");
+ for (j=0;j<16;j++)
+ {
+ if (isalnum(buffer[i*16+j]))
+ printf("%c",buffer[i*16+j]);
+ else
+ printf(".");
+ }
+ printf("\n");
+ k++;
+ if (k>=20)
+ {
+ printf("press ENTER to continue\n");
+ getchar();
+ k=0;
+ }
+ }
+}
+
+main(int argc, char *argv[])
+{
+ printf("\nTesting tool for a CDROM driver's audio functions V0.1\n");
+ printf("(C) 1995 Eberhard Moenkeberg <emoenke@gwdg.de>\n");
+ printf("initializing...\n");
+
+ rc=init_drive(default_device);
+ if (rc<0) printf("could not open %s (rc=%d).\n",default_device,rc);
+ help();
+ while (1)
+ {
+ printf("Give a one-letter command (h = help): ");
+ scanf("%s",command);
+ command[1]=0;
+ switch (command[0])
+ {
+ case 'D':
+ printf("device name (f.e. /dev/sbpcd3): ? ");
+ scanf("%s",&dev);
+ close(drive);
+ rc=init_drive(dev);
+ if (rc<0) printf("could not open %s (rc %d).\n",dev,rc);
+ break;
+ case 'e':
+ rc=ioctl(drive,CDROMEJECT);
+ if (rc<0) printf("CDROMEJECT: rc=%d.\n",rc);
+ break;
+ case 'p':
+ rc=ioctl(drive,CDROMPAUSE);
+ if (rc<0) printf("CDROMPAUSE: rc=%d.\n",rc);
+ break;
+ case 'r':
+ rc=ioctl(drive,CDROMRESUME);
+ if (rc<0) printf("CDROMRESUME: rc=%d.\n",rc);
+ break;
+ case 's':
+ rc=ioctl(drive,CDROMSTOP);
+ if (rc<0) printf("CDROMSTOP: rc=%d.\n",rc);
+ break;
+ case 'S':
+ rc=ioctl(drive,CDROMSTART);
+ if (rc<0) printf("CDROMSTART: rc=%d.\n",rc);
+ break;
+ case 't':
+ rc=ioctl(drive,CDROMREADTOCHDR,&tocHdr);
+ if (rc<0)
+ {
+ printf("CDROMREADTOCHDR: rc=%d.\n",rc);
+ break;
+ }
+ first=tocHdr.cdth_trk0;
+ last= tocHdr.cdth_trk1;
+ if ((first==0)||(first>last))
+ {
+ printf ("--got invalid TOC data.\n");
+ }
+ else
+ {
+ printf("--enter track number(first=%d, last=%d): ",first,last);
+ scanf("%d",&i1);
+ ti.cdti_trk0=i1;
+ if (ti.cdti_trk0<first) ti.cdti_trk0=first;
+ if (ti.cdti_trk0>last) ti.cdti_trk0=last;
+ ti.cdti_ind0=0;
+ ti.cdti_trk1=last;
+ ti.cdti_ind1=0;
+ rc=ioctl(drive,CDROMSTOP);
+ rc=ioctl(drive,CDROMPLAYTRKIND,&ti);
+ if (rc<0) printf("CDROMPLAYTRKIND: rc=%d.\n",rc);
+ }
+ break;
+ case 'n':
+ rc=ioctl(drive,CDROMSTOP);
+ if (++ti.cdti_trk0>last) ti.cdti_trk0=last;
+ ti.cdti_ind0=0;
+ ti.cdti_trk1=last;
+ ti.cdti_ind1=0;
+ rc=ioctl(drive,CDROMPLAYTRKIND,&ti);
+ if (rc<0) printf("CDROMPLAYTRKIND: rc=%d.\n",rc);
+ break;
+ case 'l':
+ rc=ioctl(drive,CDROMSTOP);
+ if (--ti.cdti_trk0<first) ti.cdti_trk0=first;
+ ti.cdti_ind0=0;
+ ti.cdti_trk1=last;
+ ti.cdti_ind1=0;
+ rc=ioctl(drive,CDROMPLAYTRKIND,&ti);
+ if (rc<0) printf("CDROMPLAYTRKIND: rc=%d.\n",rc);
+ break;
+ case 'c':
+ subchnl.cdsc_format=CDROM_MSF;
+ rc=ioctl(drive,CDROMSUBCHNL,&subchnl);
+ if (rc<0) printf("CDROMSUBCHNL: rc=%d.\n",rc);
+ else
+ {
+ printf("AudioStatus:%s Track:%d Mode:%d MSF=%02d:%02d:%02d\n",
+ subchnl.cdsc_audiostatus==CDROM_AUDIO_PLAY ? "PLAYING":"NOT PLAYING",
+ subchnl.cdsc_trk,subchnl.cdsc_adr,
+ subchnl.cdsc_absaddr.msf.minute,
+ subchnl.cdsc_absaddr.msf.second,
+ subchnl.cdsc_absaddr.msf.frame);
+ }
+ break;
+ case 'i':
+ printf("Track No.: ");
+ scanf("%d",&i1);
+ entry.cdte_track=i1;
+ if (entry.cdte_track<first) entry.cdte_track=first;
+ if (entry.cdte_track>last) entry.cdte_track=last;
+ entry.cdte_format=CDROM_MSF;
+ rc=ioctl(drive,CDROMREADTOCENTRY,&entry);
+ if (rc<0) printf("CDROMREADTOCENTRY: rc=%d.\n",rc);
+ else
+ {
+ printf("Mode %d Track, starts at %02d:%02d:%02d\n",
+ entry.cdte_adr,
+ entry.cdte_addr.msf.minute,
+ entry.cdte_addr.msf.second,
+ entry.cdte_addr.msf.frame);
+ }
+ break;
+ case 'a':
+ printf("Address (min:sec:frm) ");
+ scanf("%d:%d:%d",&i1,&i2,&i3);
+ msf.cdmsf_min0=i1;
+ msf.cdmsf_sec0=i2;
+ msf.cdmsf_frame0=i3;
+ if (msf.cdmsf_sec0>59) msf.cdmsf_sec0=59;
+ if (msf.cdmsf_frame0>74) msf.cdmsf_frame0=74;
+ lba2msf(TocEntry[last+1].cdte_addr.lba-1,&msf.cdmsf_min1);
+ rc=ioctl(drive,CDROMSTOP);
+ rc=ioctl(drive,CDROMPLAYMSF,&msf);
+ if (rc<0) printf("CDROMPLAYMSF: rc=%d.\n",rc);
+ break;
+#ifdef AZT_PRIVATE_IOCTLS /*not supported by every CDROM driver*/
+ case 'd':
+ printf("Address (min:sec:frm) ");
+ scanf("%d:%d:%d",&i1,&i2,&i3);
+ azt.msf.cdmsf_min0=i1;
+ azt.msf.cdmsf_sec0=i2;
+ azt.msf.cdmsf_frame0=i3;
+ if (azt.msf.cdmsf_sec0>59) azt.msf.cdmsf_sec0=59;
+ if (azt.msf.cdmsf_frame0>74) azt.msf.cdmsf_frame0=74;
+ rc=ioctl(drive,CDROMREADMODE1,&azt.msf);
+ if (rc<0) printf("CDROMREADMODE1: rc=%d.\n",rc);
+ else display(CD_FRAMESIZE,azt.buf);
+ break;
+ case 'w':
+ printf("Address (min:sec:frame) ");
+ scanf("%d:%d:%d",&i1,&i2,&i3);
+ azt.msf.cdmsf_min0=i1;
+ azt.msf.cdmsf_sec0=i2;
+ azt.msf.cdmsf_frame0=i3;
+ if (azt.msf.cdmsf_sec0>59) azt.msf.cdmsf_sec0=59;
+ if (azt.msf.cdmsf_frame0>74) azt.msf.cdmsf_frame0=74;
+ rc=ioctl(drive,CDROMREADMODE2,&azt.msf);
+ if (rc<0) printf("CDROMREADMODE2: rc=%d.\n",rc);
+ else display(CD_FRAMESIZE_RAW,azt.buf); /* currently only 2336 */
+ break;
+#endif
+ case 'v':
+ printf("--Channel 0 (Left) (0-255): ");
+ scanf("%d",&i1);
+ volctrl.channel0=i1;
+ printf("--Channel 1 (Right) (0-255): ");
+ scanf("%d",&i1);
+ volctrl.channel1=i1;
+ volctrl.channel2=0;
+ volctrl.channel3=0;
+ rc=ioctl(drive,CDROMVOLCTRL,&volctrl);
+ if (rc<0) printf("CDROMVOLCTRL: rc=%d.\n",rc);
+ break;
+ case 'q':
+ close(drive);
+ exit(0);
+ case 'h':
+ help();
+ break;
+ case 'T': /* display TOC entry - without involving the driver */
+ scanf("%d",&i);
+ if ((i<hdr.cdth_trk0)||(i>hdr.cdth_trk1))
+ printf("invalid track number.\n");
+ else
+ printf("TocEntry %02d: adr=%01X ctrl=%01X msf=%02d:%02d:%02d mode=%02X\n",
+ TocEntry[i].cdte_track,
+ TocEntry[i].cdte_adr,
+ TocEntry[i].cdte_ctrl,
+ TocEntry[i].cdte_addr.msf.minute,
+ TocEntry[i].cdte_addr.msf.second,
+ TocEntry[i].cdte_addr.msf.frame,
+ TocEntry[i].cdte_datamode);
+ break;
+ case 'A': /* read audio data into file */
+ printf("Address (min:sec:frm) ? ");
+ scanf("%d:%d:%d",&i1,&i2,&i3);
+ read_audio.addr.msf.minute=i1;
+ read_audio.addr.msf.second=i2;
+ read_audio.addr.msf.frame=i3;
+ read_audio.addr_format=CDROM_MSF;
+ printf("# of frames ? ");
+ scanf("%d",&i1);
+ read_audio.nframes=i1;
+ k=read_audio.nframes*CD_FRAMESIZE_RAW;
+ read_audio.buf=malloc(k);
+ if (read_audio.buf==NULL)
+ {
+ printf("can't malloc %d bytes.\n",k);
+ break;
+ }
+ sprintf(filename,"audio_%02d%02d%02d_%02d.%02d\0",
+ read_audio.addr.msf.minute,
+ read_audio.addr.msf.second,
+ read_audio.addr.msf.frame,
+ read_audio.nframes,
+ ++sequence);
+ datafile=creat(filename, 0755);
+ if (datafile<0)
+ {
+ printf("can't open datafile %s.\n",filename);
+ break;
+ }
+ rc=ioctl(drive,CDROMREADAUDIO,&read_audio);
+ if (rc!=0)
+ {
+ printf("CDROMREADAUDIO: rc=%d.\n",rc);
+ }
+ else
+ {
+ rc=write(datafile,&read_audio.buf,k);
+ if (rc!=k) printf("datafile I/O error (%d).\n",rc);
+ }
+ close(datafile);
+ break;
+ case 'X': /* set EJECT_SW (0: disable, 1: enable auto-ejecting) */
+ scanf("%d",&i);
+ rc=ioctl(drive,CDROMEJECT_SW,i);
+ if (rc!=0)
+ printf("CDROMEJECT_SW: rc=%d.\n",rc);
+ else
+ printf("EJECT_SW set to %d\n",i);
+ break;
+ case 'M': /* get the multisession redirection info */
+ ms_info.addr_format=CDROM_LBA;
+ rc=ioctl(drive,CDROMMULTISESSION,&ms_info);
+ if (rc!=0)
+ {
+ printf("CDROMMULTISESSION(lba): rc=%d.\n",rc);
+ }
+ else
+ {
+ if (ms_info.xa_flag) printf("MultiSession offset (lba): %d (0x%06X)\n",ms_info.addr.lba,ms_info.addr.lba);
+ else
+ {
+ printf("this CD is not an XA disk.\n");
+ break;
+ }
+ }
+ ms_info.addr_format=CDROM_MSF;
+ rc=ioctl(drive,CDROMMULTISESSION,&ms_info);
+ if (rc!=0)
+ {
+ printf("CDROMMULTISESSION(msf): rc=%d.\n",rc);
+ }
+ else
+ {
+ if (ms_info.xa_flag)
+ printf("MultiSession offset (msf): %02d:%02d:%02d (0x%02X%02X%02X)\n",
+ ms_info.addr.msf.minute,
+ ms_info.addr.msf.second,
+ ms_info.addr.msf.frame,
+ ms_info.addr.msf.minute,
+ ms_info.addr.msf.second,
+ ms_info.addr.msf.frame);
+ else printf("this CD is not an XA disk.\n");
+ }
+ break;
+#ifdef SBP_PRIVATE_IOCTLS
+ case 'Y': /* set the driver's message level */
+#if 0 /* not implemented yet */
+ printf("enter switch name (f.e. DBG_CMD): ");
+ scanf("%s",&dbg_switch);
+ j=get_dbg_num(dbg_switch);
+#else
+ printf("enter DDIOCSDBG switch number: ");
+ scanf("%d",&j);
+#endif
+ printf("enter 0 for \"off\", 1 for \"on\": ");
+ scanf("%d",&i);
+ if (i==0) j|=0x80;
+ printf("calling \"ioctl(drive,DDIOCSDBG,%d)\"\n",j);
+ rc=ioctl(drive,DDIOCSDBG,j);
+ printf("DDIOCSDBG: rc=%d.\n",rc);
+ break;
+ case 'Z': /* set the audio buffer size */
+ printf("# frames wanted: ? ");
+ scanf("%d",&j);
+ rc=ioctl(drive,CDROMAUDIOBUFSIZ,j);
+ printf("%d frames granted.\n",rc);
+ break;
+ case 'V':
+ rc=ioctl(drive,CDROMVOLREAD,&volctrl);
+ if (rc<0) printf("CDROMVOLCTRL: rc=%d.\n",rc);
+ printf("Volume: channel 0 (left) %d, channel 1 (right) %d\n",volctrl.channel0,volctrl.channel1);
+ break;
+ case 'R':
+ rc=ioctl(drive,CDROMRESET);
+ if (rc<0) printf("CDROMRESET: rc=%d.\n",rc);
+ break;
+ case 'B': /* set the driver's (?) read ahead value */
+ printf("enter read-ahead size: ? ");
+ scanf("%d",&i);
+ rc=ioctl(drive,BLKRASET,i);
+ if (rc<0) printf("BLKRASET: rc=%d.\n",rc);
+ break;
+#endif SBP_PRIVATE_IOCTLS
+ default:
+ printf("unknown command: \"%s\".\n",command);
+ break;
+ }
+ }
+}
+/*==========================================================================*/
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only. This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-indent-level: 8
+ * c-brace-imaginary-offset: 0
+ * c-brace-offset: -8
+ * c-argdecl-indent: 8
+ * c-label-offset: -8
+ * c-continued-statement-offset: 8
+ * c-continued-brace-offset: 0
+ * End:
+ */
+