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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [Documentation/] [cdrom/] [sbpcd] - Diff between revs 1765 and 1782

Only display areas with differences | Details | Blame | View Log

Rev 1765 Rev 1782
This README belongs to release 4.2 or newer of the SoundBlaster Pro
This README belongs to release 4.2 or newer of the SoundBlaster Pro
(Matsushita, Kotobuki, Panasonic, CreativeLabs, Longshine and Teac)
(Matsushita, Kotobuki, Panasonic, CreativeLabs, Longshine and Teac)
CD-ROM driver for Linux.
CD-ROM driver for Linux.
sbpcd really, really is NOT for ANY IDE/ATAPI drive!
sbpcd really, really is NOT for ANY IDE/ATAPI drive!
Not even if you have an "original" SoundBlaster card with an IDE interface!
Not even if you have an "original" SoundBlaster card with an IDE interface!
So, you better have a look into README.ide if your port address is 0x1F0,
So, you better have a look into README.ide if your port address is 0x1F0,
0x170, 0x1E8, 0x168 or similar.
0x170, 0x1E8, 0x168 or similar.
I get tons of mails from IDE/ATAPI drive users - I really can't continue
I get tons of mails from IDE/ATAPI drive users - I really can't continue
any more to answer them all. So, if your drive/interface information sheets
any more to answer them all. So, if your drive/interface information sheets
mention "IDE" (primary, secondary, tertiary, quaternary) and the DOS driver
mention "IDE" (primary, secondary, tertiary, quaternary) and the DOS driver
invoking line within your CONFIG.SYS is using an address below 0x230:
invoking line within your CONFIG.SYS is using an address below 0x230:
DON'T ROB MY LAST NERVE - jumper your interface to address 0x170 and IRQ 15
DON'T ROB MY LAST NERVE - jumper your interface to address 0x170 and IRQ 15
(that is the "secondary IDE" configuration), set your drive to "master" and
(that is the "secondary IDE" configuration), set your drive to "master" and
use ide-cd as your driver. If you do not have a second IDE hard disk, use the
use ide-cd as your driver. If you do not have a second IDE hard disk, use the
LILO commands
LILO commands
   hdb=noprobe hdc=cdrom
   hdb=noprobe hdc=cdrom
and get lucky.
and get lucky.
To make it fully clear to you: if you mail me about IDE/ATAPI drive problems,
To make it fully clear to you: if you mail me about IDE/ATAPI drive problems,
my answer is above, and I simply will discard your mail, hoping to stop the
my answer is above, and I simply will discard your mail, hoping to stop the
flood and to find time to lead my 12-years old son towards happy computing.
flood and to find time to lead my 12-years old son towards happy computing.
The driver is able to drive the whole family of "traditional" AT-style (that
The driver is able to drive the whole family of "traditional" AT-style (that
is NOT the new "Enhanced IDE" or "ATAPI" drive standard) Matsushita,
is NOT the new "Enhanced IDE" or "ATAPI" drive standard) Matsushita,
Kotobuki, Panasonic drives, sometimes labelled as "CreativeLabs". The
Kotobuki, Panasonic drives, sometimes labelled as "CreativeLabs". The
well-known drives are CR-521, CR-522, CR-523, CR-562, CR-563.
well-known drives are CR-521, CR-522, CR-523, CR-562, CR-563.
CR-574 is an IDE/ATAPI drive.
CR-574 is an IDE/ATAPI drive.
The Longshine LCS-7260 is a double-speed drive which uses the "old"
The Longshine LCS-7260 is a double-speed drive which uses the "old"
Matsushita command set. It is supported - with help by Serge Robyns.
Matsushita command set. It is supported - with help by Serge Robyns.
Vertos ("Elitegroup Computer Systems", ECS) has a similar drive - support
Vertos ("Elitegroup Computer Systems", ECS) has a similar drive - support
has started; come in contact if you have such a "Vertos 100" or "ECS-AT"
has started; come in contact if you have such a "Vertos 100" or "ECS-AT"
drive.
drive.
There exists an "IBM External ISA CD-ROM Drive" which in fact is a CR-563
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
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
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
an internal drive, and you can use it as an internal, too - f.e. plug it into
a soundcard).
a soundcard).
CreativeLabs has a new drive "CD200" and a similar drive "CD200F". The latter
CreativeLabs has a new drive "CD200" and a similar drive "CD200F". The latter
is made by Funai and sometimes named "E2550UA", newer models may be named
is made by Funai and sometimes named "E2550UA", newer models may be named
"MK4015". The CD200F drives should fully work.
"MK4015". The CD200F drives should fully work.
CD200 drives without "F" are still giving problems: drive detection and
CD200 drives without "F" are still giving problems: drive detection and
playing audio should work, data access will result in errors. I need qualified
playing audio should work, data access will result in errors. I need qualified
feedback about the bugs within the data functions or a drive (I never saw a
feedback about the bugs within the data functions or a drive (I never saw a
CD200).
CD200).
The quad-speed Teac CD-55A drive is supported, but still does not reach "full
The quad-speed Teac CD-55A drive is supported, but still does not reach "full
speed". The data rate already reaches 500 kB/sec if you set SBP_BUFFER_FRAMES
speed". The data rate already reaches 500 kB/sec if you set SBP_BUFFER_FRAMES
to 64 (it is not recommended to do that for normal "file access" usage, but it
to 64 (it is not recommended to do that for normal "file access" usage, but it
can speed up things a lot if you use something like "dd" to read from the
can speed up things a lot if you use something like "dd" to read from the
drive; I use it for verifying self-written CDs this way).
drive; I use it for verifying self-written CDs this way).
The drive itself is able to deliver 600 kB/sec, so this has to get a point of
The drive itself is able to deliver 600 kB/sec, so this has to get a point of
work; with the normal setup, the performance currently is not even as good as
work; with the normal setup, the performance currently is not even as good as
double-speed.
double-speed.
This driver is NOT for Mitsumi or Sony or Aztech or Philips or XXX drives,
This driver is NOT for Mitsumi or Sony or Aztech or Philips or XXX drives,
and again: this driver is in no way usable for any IDE/ATAPI drive. If you
and again: this driver is in no way usable for any IDE/ATAPI drive. If you
think your drive should work and it doesn't: send me the DOS driver for your
think your drive should work and it doesn't: send me the DOS driver for your
beast (gzipped + uuencoded) and your CONFIG.SYS if you want to ask me for help,
beast (gzipped + uuencoded) and your CONFIG.SYS if you want to ask me for help,
and include an original log message excerpt, and try to give all information
and include an original log message excerpt, and try to give all information
a complete idiot needs to understand your hassle already with your first
a complete idiot needs to understand your hassle already with your first
mail. And if you want to say "as I have mailed you before", be sure that I
mail. And if you want to say "as I have mailed you before", be sure that I
don't remember your "case" by such remarks; at the moment, I have some
don't remember your "case" by such remarks; at the moment, I have some
hundreds open correspondences about Linux CDROM questions (hope to reduce if
hundreds open correspondences about Linux CDROM questions (hope to reduce if
the IDE/ATAPI user questions disappear).
the IDE/ATAPI user questions disappear).
This driver will work with the soundcard interfaces (SB Pro, SB 16, Galaxy,
This driver will work with the soundcard interfaces (SB Pro, SB 16, Galaxy,
SoundFX, Mozart, MAD16 ...) and with the "no-sound" cards (Panasonic CI-101P,
SoundFX, Mozart, MAD16 ...) and with the "no-sound" cards (Panasonic CI-101P,
LaserMate, WDH-7001C, Longshine LCS-6853, Teac ...).
LaserMate, WDH-7001C, Longshine LCS-6853, Teac ...).
It works with the "configurable" interface "Sequoia S-1000", too, which is
It works with the "configurable" interface "Sequoia S-1000", too, which is
used on the Spea Media FX and Ensonic Soundscape sound cards. You have to
used on the Spea Media FX and Ensonic Soundscape sound cards. You have to
specify the type "SBPRO 2" and the true CDROM port address with it, not the
specify the type "SBPRO 2" and the true CDROM port address with it, not the
"configuration port" address.
"configuration port" address.
If you have a sound card which needs a "configuration driver" instead of
If you have a sound card which needs a "configuration driver" instead of
jumpers for interface types and addresses (like Mozart cards) - those
jumpers for interface types and addresses (like Mozart cards) - those
drivers get invoked before the DOS CDROM driver in your CONFIG.SYS, typical
drivers get invoked before the DOS CDROM driver in your CONFIG.SYS, typical
names are "cdsetup.sys" and "mztinit.sys" -, let the sound driver do the
names are "cdsetup.sys" and "mztinit.sys" -, let the sound driver do the
CDROM port configuration (the leading comments in linux/drivers/sound/mad16.c
CDROM port configuration (the leading comments in linux/drivers/sound/mad16.c
are just for you!). Hannu Savolainen's mad16.c code is able to set up my
are just for you!). Hannu Savolainen's mad16.c code is able to set up my
Mozart card - I simply had to add
Mozart card - I simply had to add
   #define MAD16_CONF 0x06
   #define MAD16_CONF 0x06
   #define MAD16_CDSEL 0x03
   #define MAD16_CDSEL 0x03
to configure the CDROM interface for type "Panasonic" (LaserMate) and address
to configure the CDROM interface for type "Panasonic" (LaserMate) and address
0x340.
0x340.
The interface type has to get configured in /usr/include/linux/sbpcd.h,
The interface type has to get configured in /usr/include/linux/sbpcd.h,
because the register layout is different between the "SoundBlaster" and the
because the register layout is different between the "SoundBlaster" and the
"LaserMate" type.
"LaserMate" type.
I got a report that the Teac interface card "I/F E117098" is of type
I got a report that the Teac interface card "I/F E117098" is of type
"SoundBlaster" (i.e. you have to set SBPRO to 1) even with the addresses
"SoundBlaster" (i.e. you have to set SBPRO to 1) even with the addresses
0x300 and above. This is unusual, and it can't get covered by the auto
0x300 and above. This is unusual, and it can't get covered by the auto
probing scheme.
probing scheme.
The Teac 16-bit interface cards (like P/N E950228-00A, default address 0x2C0)
The Teac 16-bit interface cards (like P/N E950228-00A, default address 0x2C0)
need the SBPRO 3 setup.
need the SBPRO 3 setup.
If auto-probing found the drive, the address is correct. The reported type
If auto-probing found the drive, the address is correct. The reported type
may be wrong. A "mount" will give success only if the interface type is set
may be wrong. A "mount" will give success only if the interface type is set
right. Playing audio should work with a wrong set interface type, too.
right. Playing audio should work with a wrong set interface type, too.
With some Teac and some CD200 drives I have seen interface cards which seem
With some Teac and some CD200 drives I have seen interface cards which seem
to lack the "drive select" lines; always drive 0 gets addressed. To avoid
to lack the "drive select" lines; always drive 0 gets addressed. To avoid
"mirror drives" (four drives detected where you only have one) with such
"mirror drives" (four drives detected where you only have one) with such
interface cards, set MAX_DRIVES to 1 and jumper your drive to ID 0 (if
interface cards, set MAX_DRIVES to 1 and jumper your drive to ID 0 (if
possible).
possible).
Up to 4 drives per interface card, and up to 4 interface cards are supported.
Up to 4 drives per interface card, and up to 4 interface cards are supported.
All supported drive families can be mixed, but the CR-521 drives are
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
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
drive has to get a unique minor number (0...3), corresponding indirectly to
its drive ID.
its drive ID.
The drive IDs may be selected freely from 0 to 3 - they do not have to be in
The drive IDs may be selected freely from 0 to 3 - they do not have to be in
consecutive order.
consecutive order.
As Don Carroll, don@ds9.us.dell.com or FIDO 1:382/14, told me, it is possible
As Don Carroll, don@ds9.us.dell.com or FIDO 1:382/14, told me, it is possible
to change old drives to any ID, too. He writes in this sense:
to change old drives to any ID, too. He writes in this sense:
   "In order to be able to use more than one single speed drive
   "In order to be able to use more than one single speed drive
   (they do not have the ID jumpers) you must add a DIP switch
   (they do not have the ID jumpers) you must add a DIP switch
   and two resistors. The pads are already on the board next to
   and two resistors. The pads are already on the board next to
   the power connector. You will see the silkscreen for the
   the power connector. You will see the silkscreen for the
   switch if you remove the top cover.
   switch if you remove the top cover.
                    1 2 3 4
                    1 2 3 4
             ID 0 = x F F x             O = "on"
             ID 0 = x F F x             O = "on"
             ID 1 = x O F x             F = "off"
             ID 1 = x O F x             F = "off"
             ID 2 = x F O x             x = "don't care"
             ID 2 = x F O x             x = "don't care"
             ID 3 = x O O x
             ID 3 = x O O x
   Next to the switch are the positions for R76 (7k) and R78
   Next to the switch are the positions for R76 (7k) and R78
   (12k). I had to play around with the resistor values - ID 3
   (12k). I had to play around with the resistor values - ID 3
   did not work with other values. If the values are not good,
   did not work with other values. If the values are not good,
   ID 3 behaves like ID 0."
   ID 3 behaves like ID 0."
To use more than 4 drives, you simply need a second controller card at a
To use more than 4 drives, you simply need a second controller card at a
different address and a second cable.
different address and a second cable.
The driver supports reading of data from the CD and playing of audio tracks.
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
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.
CDplayer and WorkBone - tell me if it is not compatible with other software.
The only accepted measure for correctness with the audio functions is the
The only accepted measure for correctness with the audio functions is the
"cdtester" utility (appended) - most audio player programmers seem to be
"cdtester" utility (appended) - most audio player programmers seem to be
better musicians than programmers. ;-)
better musicians than programmers. ;-)
With the CR-56x and the CD200 drives, the reading of audio frames is possible.
With the CR-56x and the CD200 drives, the reading of audio frames is possible.
This is implemented by an IOCTL function which reads READ_AUDIO frames of
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).
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
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
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
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
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
get corrected by external, "higher level" software which reads the same frame
again and tries to find and eliminate overlapping chunks (24-byte-pieces).
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.
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
This can be better reading bigger chunks, but the "missing" chunks possibly
occur at the beginning of each single frame.
occur at the beginning of each single frame.
The software interface possibly may change a bit the day the SCSI driver
The software interface possibly may change a bit the day the SCSI driver
supports it too.
supports it too.
With all but the CR-52x drives, MultiSession is supported.
With all but the CR-52x drives, MultiSession is supported.
Photo CDs work (the "old" drives like CR-521 can access only the first
Photo CDs work (the "old" drives like CR-521 can access only the first
session of a photoCD).
session of a photoCD).
At ftp.gwdg.de:/pub/linux/hpcdtoppm/ you will find Hadmut Danisch's package to
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.
convert photo CD image files and Gerd Knorr's viewing utility.
The transfer rate will reach 150 kB/sec with CR-52x drives, 300 kB/sec with
The transfer rate will reach 150 kB/sec with CR-52x drives, 300 kB/sec with
CR-56x drives, and currently not more than 500 kB/sec (usually less than
CR-56x drives, and currently not more than 500 kB/sec (usually less than
250 kB/sec) with the Teac quad speed drives.
250 kB/sec) with the Teac quad speed drives.
XA (PhotoCD) disks with "old" drives give only 50 kB/sec.
XA (PhotoCD) disks with "old" drives give only 50 kB/sec.
This release consists of
This release consists of
- this README file
- this README file
- the driver file linux/drivers/cdrom/sbpcd.c
- the driver file linux/drivers/cdrom/sbpcd.c
- the stub files linux/drivers/cdrom/sbpcd[234].c
- the stub files linux/drivers/cdrom/sbpcd[234].c
- the header file linux/include/linux/sbpcd.h.
- the header file linux/include/linux/sbpcd.h.
To install:
To install:
-----------
-----------
1. Setup your hardware parameters. Though the driver does "auto-probing" at a
1. Setup your hardware parameters. Though the driver does "auto-probing" at a
   lot of (not all possible!) addresses, this step is recommended for
   lot of (not all possible!) addresses, this step is recommended for
   every-day use. You should let sbpcd auto-probe once and use the reported
   every-day use. You should let sbpcd auto-probe once and use the reported
   address if a drive got found. The reported type may be incorrect; it is
   address if a drive got found. The reported type may be incorrect; it is
   correct if you can mount a data CD. There is no choice for you with the
   correct if you can mount a data CD. There is no choice for you with the
   type; only one is the right, the others are deadly wrong.
   type; only one is the right, the others are deadly wrong.
   a. Go into /usr/src/linux/include/linux/sbpcd.h and configure it for your
   a. Go into /usr/src/linux/include/linux/sbpcd.h and configure it for your
      hardware (near the beginning):
      hardware (near the beginning):
      a1. Set it up for the appropriate type of interface board.
      a1. Set it up for the appropriate type of interface board.
          "Original" CreativeLabs sound cards need "SBPRO 1".
          "Original" CreativeLabs sound cards need "SBPRO 1".
          Most "compatible" sound cards (almost all "non-CreativeLabs" cards)
          Most "compatible" sound cards (almost all "non-CreativeLabs" cards)
          need "SBPRO 0".
          need "SBPRO 0".
          The "no-sound" board from OmniCd needs the "SBPRO 1" setup.
          The "no-sound" board from OmniCd needs the "SBPRO 1" setup.
          The Teac 8-bit "no-sound" boards need the "SBPRO 1" setup.
          The Teac 8-bit "no-sound" boards need the "SBPRO 1" setup.
          The Teac 16-bit "no-sound" boards need the "SBPRO 3" setup.
          The Teac 16-bit "no-sound" boards need the "SBPRO 3" setup.
          All other "no-sound" boards need the "SBPRO 0" setup.
          All other "no-sound" boards need the "SBPRO 0" setup.
          The Spea Media FX and Ensoniq SoundScape cards need "SBPRO 2".
          The Spea Media FX and Ensoniq SoundScape cards need "SBPRO 2".
          sbpcd.c holds some examples in its 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,
          If you configure "SBPRO" wrong, the playing of audio CDs will work,
          but you will not be able to mount a data CD.
          but you will not be able to mount a data CD.
      a2. Tell the address of your CDROM_PORT (not of the sound port).
      a2. Tell the address of your CDROM_PORT (not of the sound port).
      a3. If 4 drives get found, but you have only one, set MAX_DRIVES to 1.
      a3. If 4 drives get found, but you have only one, set MAX_DRIVES to 1.
      a4. Set DISTRIBUTION to 0.
      a4. Set DISTRIBUTION to 0.
   b. Additionally for 2.a1 and 2.a2, the setup may be done during
   b. Additionally for 2.a1 and 2.a2, the setup may be done during
      boot time (via the "kernel command line" or "LILO option"):
      boot time (via the "kernel command line" or "LILO option"):
          sbpcd=0x320,LaserMate
          sbpcd=0x320,LaserMate
      or
      or
          sbpcd=0x230,SoundBlaster
          sbpcd=0x230,SoundBlaster
      or
      or
          sbpcd=0x338,SoundScape
          sbpcd=0x338,SoundScape
      or
      or
          sbpcd=0x2C0,Teac16bit
          sbpcd=0x2C0,Teac16bit
      This is especially useful if you install a fresh distribution.
      This is especially useful if you install a fresh distribution.
      If the second parameter is a number, it gets taken as the type
      If the second parameter is a number, it gets taken as the type
      setting; 0 is "LaserMate", 1 is "SoundBlaster", 2 is "SoundScape",
      setting; 0 is "LaserMate", 1 is "SoundBlaster", 2 is "SoundScape",
      3 is "Teac16bit".
      3 is "Teac16bit".
      So, for example
      So, for example
          sbpcd=0x230,1
          sbpcd=0x230,1
      is equivalent to
      is equivalent to
          sbpcd=0x230,SoundBlaster
          sbpcd=0x230,SoundBlaster
2. "cd /usr/src/linux" and do a "make config" and select "y" for Matsushita
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
   CD-ROM support and for ISO9660 FileSystem support. If you do not have a
   second, third, or fourth controller installed, do not say "y" to the
   second, third, or fourth controller installed, do not say "y" to the
   secondary Matsushita CD-ROM questions.
   secondary Matsushita CD-ROM questions.
3. Then do a "make dep", then make the kernel image ("make zlilo" or else).
3. Then do a "make dep", then make the kernel image ("make zlilo" or else).
4. Make the device file(s). This step usually already has been done by the
4. Make the device file(s). This step usually already has been done by the
   MAKEDEV script.
   MAKEDEV script.
   The driver uses MAJOR 25, so, if necessary, do
   The driver uses MAJOR 25, so, if necessary, do
        mknod /dev/sbpcd  b 25 0       (if you have only one drive)
        mknod /dev/sbpcd  b 25 0       (if you have only one drive)
   and/or
   and/or
        mknod /dev/sbpcd0 b 25 0
        mknod /dev/sbpcd0 b 25 0
        mknod /dev/sbpcd1 b 25 1
        mknod /dev/sbpcd1 b 25 1
        mknod /dev/sbpcd2 b 25 2
        mknod /dev/sbpcd2 b 25 2
        mknod /dev/sbpcd3 b 25 3
        mknod /dev/sbpcd3 b 25 3
   to make the node(s).
   to make the node(s).
   The "first found" drive gets MINOR 0 (regardless to its jumpered ID), the
   The "first found" drive gets MINOR 0 (regardless to its jumpered ID), the
   "next found" (at the same cable) gets MINOR 1, ...
   "next found" (at the same cable) gets MINOR 1, ...
   For a second interface board, you have to make nodes like
   For a second interface board, you have to make nodes like
        mknod /dev/sbpcd4 b 26 0
        mknod /dev/sbpcd4 b 26 0
        mknod /dev/sbpcd5 b 26 1
        mknod /dev/sbpcd5 b 26 1
   and so on. Use the MAJORs 26, 27, 28.
   and so on. Use the MAJORs 26, 27, 28.
   If you further make a link like
   If you further make a link like
        ln -s sbpcd /dev/cdrom
        ln -s sbpcd /dev/cdrom
   you can use the name /dev/cdrom, too.
   you can use the name /dev/cdrom, too.
5. Reboot with the new kernel.
5. Reboot with the new kernel.
You should now be able to do
You should now be able to do
              mkdir /CD
              mkdir /CD
and
and
              mount -rt iso9660 /dev/sbpcd /CD
              mount -rt iso9660 /dev/sbpcd /CD
or
or
              mount -rt iso9660 -o block=2048 /dev/sbpcd /CD
              mount -rt iso9660 -o block=2048 /dev/sbpcd /CD
and see the contents of your CD in the /CD directory.
and see the contents of your CD in the /CD directory.
To use audio CDs, a mounting is not recommended (and it would fail if the
To use audio CDs, a mounting is not recommended (and it would fail if the
first track is not a data track).
first track is not a data track).
Using sbpcd as a "loadable module":
Using sbpcd as a "loadable module":
-----------------------------------
-----------------------------------
If you do NOT select "Matsushita/Panasonic CDROM driver support" during the
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.
"make config" of your kernel, you can build the "loadable module" sbpcd.o.
Read /usr/src/linux/Documentation/modules.txt on this.
Read /usr/src/linux/Documentation/modules.txt on this.
If sbpcd gets used as a module, the support of more than one interface
If sbpcd gets used as a module, the support of more than one interface
card (i.e. drives 4...15) is disabled.
card (i.e. drives 4...15) is disabled.
You can specify interface address and type with the "insmod" command like:
You can specify interface address and type with the "insmod" command like:
 # insmod /usr/src/linux/modules/sbpcd.o sbpcd=0x340,0
 # insmod /usr/src/linux/modules/sbpcd.o sbpcd=0x340,0
or
or
 # insmod /usr/src/linux/modules/sbpcd.o sbpcd=0x230,1
 # insmod /usr/src/linux/modules/sbpcd.o sbpcd=0x230,1
or
or
 # insmod /usr/src/linux/modules/sbpcd.o sbpcd=0x338,2
 # insmod /usr/src/linux/modules/sbpcd.o sbpcd=0x338,2
where the last number represents the SBPRO setting (no strings allowed here).
where the last number represents the SBPRO setting (no strings allowed here).
Things of interest:
Things of interest:
-------------------
-------------------
The driver is configured to try the LaserMate type of interface at I/O port
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
0x0340 first. If this is not appropriate, sbpcd.h should get changed
(you will find the right place - just at the beginning).
(you will find the right place - just at the beginning).
No DMA and no IRQ is used.
No DMA and no IRQ is used.
To reduce or increase the amount of kernel messages, edit sbpcd.c and play
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").
with the "DBG_xxx" switches (initialization of the variable "sbpcd_debug").
Don't forget to reflect what you do; enabling all DBG_xxx switches at once
Don't forget to reflect what you do; enabling all DBG_xxx switches at once
may crash your system, and each message line is accompanied by a delay.
may crash your system, and each message line is accompanied by a delay.
The driver uses the "variable BLOCK_SIZE" feature. To use it, you have to
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
specify "block=2048" as a mount option. Doing this will disable the direct
execution of a binary from the CD; you have to copy it to a device with the
execution of a binary from the CD; you have to copy it to a device with the
standard BLOCK_SIZE (1024) before. So, do not use this if your system is
standard BLOCK_SIZE (1024) before. So, do not use this if your system is
directly "running from the CDROM" (like some of YGGDRASIL's installation
directly "running from the CDROM" (like some of YGGDRASIL's installation
variants). There are CDs on the market (like the german "unifix" Linux
variants). There are CDs on the market (like the german "unifix" Linux
distribution) which MUST get handled with a block_size of 1024. Generally,
distribution) which MUST get handled with a block_size of 1024. Generally,
one can say all the CDs which hold files of the name YMTRANS.TBL are defective;
one can say all the CDs which hold files of the name YMTRANS.TBL are defective;
do not use block=2048 with those.
do not use block=2048 with those.
Within sbpcd.h, you will find some "#define"s (f.e. EJECT and JUKEBOX). With
Within sbpcd.h, you will find some "#define"s (f.e. EJECT and JUKEBOX). With
that, you can configure the driver for some special things.
that, you can configure the driver for some special things.
You can use the appended program "cdtester" to set the auto-eject feature
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)
during runtime. Jeff Tranter's "eject" utility can do this, too (and more)
for you.
for you.
There is an ioctl CDROMMULTISESSION to obtain with a user program if
There is an 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
the CD is an XA disk and - if it is - where the last session starts. The
"cdtester" program illustrates how to call it.
"cdtester" program illustrates how to call it.
Auto-probing at boot time:
Auto-probing at boot time:
--------------------------
--------------------------
The driver does auto-probing at many well-known interface card addresses,
The driver does auto-probing at many well-known interface card addresses,
but not all:
but not all:
Some probings can cause a hang if an NE2000 ethernet card gets touched, because
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.
SBPCD's auto-probing happens before the initialization of the net drivers.
Those "hazardous" addresses are excluded from auto-probing; the "kernel
Those "hazardous" addresses are excluded from auto-probing; the "kernel
command line" feature has to be used during installation if you have your
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
drive at those addresses. The "module" version is allowed to probe at those
addresses, too.
addresses, too.
The 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
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,
driver within installation boot floppies, and for any non-standard address,
too.
too.
Auto-probing will make an assumption about the interface type ("SBPRO" or not),
Auto-probing will make an assumption about the interface type ("SBPRO" or not),
based upon the address. That assumption may be wrong (initialization will be
based upon the address. That assumption may be wrong (initialization will be
o.k., but you will get I/O errors during mount). In that case, use the "kernel
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
command line" feature and specify address & type at boot time to find out the
right setup.
right setup.
For every-day use, address and type should get configured within sbpcd.h. That
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.
will stop the auto-probing due to success with the first try.
The kernel command "sbpcd=0" suppresses each auto-probing and causes
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
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. ;-)
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
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.
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
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
useful within "universal" CDROM installation boot floppies (but using the
loadable module would be better because it allows an "extended" auto-probing
loadable module would be better because it allows an "extended" auto-probing
without fearing NE2000 cards).
without fearing NE2000 cards).
To shorten the auto-probing list to a single entry, set DISTRIBUTION 0 within
To shorten the auto-probing list to a single entry, set DISTRIBUTION 0 within
sbpcd.h.
sbpcd.h.
Setting up address and interface type:
Setting up address and interface type:
--------------------------------------
--------------------------------------
If your I/O port address is not 0x340, you have to look for the #defines near
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
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.
change CDROM_PORT to the address of your CDROM I/O port.
Almost all of the "SoundBlaster compatible" cards behave like the no-sound
Almost all of the "SoundBlaster compatible" cards behave like the no-sound
interfaces, i.e. need SBPRO 0!
interfaces, i.e. need SBPRO 0!
With "original" SB Pro cards, an initial setting of CD_volume through the
With "original" SB Pro cards, an initial setting of CD_volume through the
sound cards MIXER register gets done.
sound cards MIXER register gets done.
If you are using a "compatible" sound card of types "LaserMate" or "SPEA",
If you are using a "compatible" sound card of types "LaserMate" or "SPEA",
you can set SOUND_BASE (in sbpcd.h) to get it done with your card, too...
you can set SOUND_BASE (in sbpcd.h) to get it done with your card, too...
Using audio CDs:
Using audio CDs:
----------------
----------------
Workman, WorkBone, xcdplayer, cdplayer and the nice little tool "cdplay" (see
Workman, WorkBone, xcdplayer, cdplayer and the nice little tool "cdplay" (see
README.aztcd from the Aztech driver package) should work.
README.aztcd from the Aztech driver package) should work.
The program CDplayer likes to talk to "/dev/mcd" only, xcdplayer wants
The program CDplayer likes to talk to "/dev/mcd" only, xcdplayer wants
"/dev/rsr0", workman loves "/dev/sr0" or "/dev/cdrom" - so, do the appropriate
"/dev/rsr0", workman loves "/dev/sr0" or "/dev/cdrom" - so, do the appropriate
links for using them without the need of supplying parameters.
links for using them without the need of supplying parameters.
Copying audio tracks:
Copying audio tracks:
---------------------
---------------------
The following program will copy track 1 (or a piece of it) from an audio CD
The following program will copy track 1 (or a piece of it) from an audio CD
into the file "track01":
into the file "track01":
/*=================== begin program ========================================*/
/*=================== begin program ========================================*/
/*
/*
 * read an audio track from a CD
 * read an audio track from a CD
 *
 *
 * (c) 1994 Eberhard Moenkeberg 
 * (c) 1994 Eberhard Moenkeberg 
 *          may be used & enhanced freely
 *          may be used & enhanced freely
 *
 *
 * Due to non-existent sync bytes at the beginning of each audio frame (or due
 * Due to non-existent sync bytes at the beginning of each audio frame (or due
 * to a firmware bug within all known drives?), it is currently a kind of
 * to a firmware bug within all known drives?), it is currently a kind of
 * fortune if two consecutive frames fit together.
 * fortune if two consecutive frames fit together.
 * Usually, they overlap, or a little piece is missing. This happens in units
 * Usually, they overlap, or a little piece is missing. This happens in units
 * of 24-byte chunks. It has to get fixed by higher-level software (reading
 * of 24-byte chunks. It has to get fixed by higher-level software (reading
 * until an overlap occurs, and then eliminate the overlapping chunks).
 * until an overlap occurs, and then eliminate the overlapping chunks).
 * ftp.gwdg.de:/pub/linux/misc/cdda2wav-sbpcd.*.tar.gz holds an example of
 * ftp.gwdg.de:/pub/linux/misc/cdda2wav-sbpcd.*.tar.gz holds an example of
 * such an algorithm.
 * such an algorithm.
 * This example program further is missing to obtain the SubChannel data
 * This example program further is missing to obtain the SubChannel data
 * which belong to each frame.
 * which belong to each frame.
 *
 *
 * This is only an example of the low-level access routine. The read data are
 * 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
 * pure 16-bit CDDA values; they have to get converted to make sound out of
 * them.
 * them.
 * It is no fun to listen to it without prior overlap/underlap correction!
 * It is no fun to listen to it without prior overlap/underlap correction!
 */
 */
#include 
#include 
#include 
#include 
#include 
#include 
static struct cdrom_tochdr hdr;
static struct cdrom_tochdr hdr;
static struct cdrom_tocentry entry[101];
static struct cdrom_tocentry entry[101];
static struct cdrom_read_audio arg;
static struct cdrom_read_audio arg;
static u_char buffer[CD_FRAMESIZE_RAW];
static u_char buffer[CD_FRAMESIZE_RAW];
static int datafile, drive;
static int datafile, drive;
static int i, j, limit, track, err;
static int i, j, limit, track, err;
static char filename[32];
static char filename[32];
main(int argc, char *argv[])
main(int argc, char *argv[])
{
{
/*
/*
 * open /dev/cdrom
 * open /dev/cdrom
 */
 */
  drive=open("/dev/cdrom", 0);
  drive=open("/dev/cdrom", 0);
  if (drive<0)
  if (drive<0)
    {
    {
      fprintf(stderr, "can't open drive.\n");
      fprintf(stderr, "can't open drive.\n");
      exit (-1);
      exit (-1);
    }
    }
/*
/*
 * get TocHeader
 * get TocHeader
 */
 */
  fprintf(stdout, "getting TocHeader...\n");
  fprintf(stdout, "getting TocHeader...\n");
  err=ioctl(drive, CDROMREADTOCHDR, &hdr);
  err=ioctl(drive, CDROMREADTOCHDR, &hdr);
  if (err!=0)
  if (err!=0)
    {
    {
      fprintf(stderr, "can't get TocHeader (error %d).\n", err);
      fprintf(stderr, "can't get TocHeader (error %d).\n", err);
      exit (-1);
      exit (-1);
    }
    }
  else
  else
    fprintf(stdout, "TocHeader: %d %d\n", hdr.cdth_trk0, hdr.cdth_trk1);
    fprintf(stdout, "TocHeader: %d %d\n", hdr.cdth_trk0, hdr.cdth_trk1);
/*
/*
 * get and display all TocEntries
 * get and display all TocEntries
 */
 */
  fprintf(stdout, "getting TocEntries...\n");
  fprintf(stdout, "getting TocEntries...\n");
  for (i=1;i<=hdr.cdth_trk1+1;i++)
  for (i=1;i<=hdr.cdth_trk1+1;i++)
    {
    {
      if (i!=hdr.cdth_trk1+1) entry[i].cdte_track = i;
      if (i!=hdr.cdth_trk1+1) entry[i].cdte_track = i;
      else entry[i].cdte_track = CDROM_LEADOUT;
      else entry[i].cdte_track = CDROM_LEADOUT;
      entry[i].cdte_format = CDROM_LBA;
      entry[i].cdte_format = CDROM_LBA;
      err=ioctl(drive, CDROMREADTOCENTRY, &entry[i]);
      err=ioctl(drive, CDROMREADTOCENTRY, &entry[i]);
      if (err!=0)
      if (err!=0)
        {
        {
          fprintf(stderr, "can't get TocEntry #%d (error %d).\n", i, err);
          fprintf(stderr, "can't get TocEntry #%d (error %d).\n", i, err);
          exit (-1);
          exit (-1);
        }
        }
      else
      else
        {
        {
          fprintf(stdout, "TocEntry #%d: %1X %1X %06X %02X\n",
          fprintf(stdout, "TocEntry #%d: %1X %1X %06X %02X\n",
                 entry[i].cdte_track,
                 entry[i].cdte_track,
                 entry[i].cdte_adr,
                 entry[i].cdte_adr,
                 entry[i].cdte_ctrl,
                 entry[i].cdte_ctrl,
                 entry[i].cdte_addr.lba,
                 entry[i].cdte_addr.lba,
                 entry[i].cdte_datamode);
                 entry[i].cdte_datamode);
        }
        }
    }
    }
  fprintf(stdout, "got all TocEntries.\n");
  fprintf(stdout, "got all TocEntries.\n");
/*
/*
 * ask for track number (not implemented here)
 * ask for track number (not implemented here)
 */
 */
track=1;
track=1;
#if 0 /* just read a little piece (4 seconds) */
#if 0 /* just read a little piece (4 seconds) */
entry[track+1].cdte_addr.lba=entry[track].cdte_addr.lba+300;
entry[track+1].cdte_addr.lba=entry[track].cdte_addr.lba+300;
#endif
#endif
/*
/*
 * read track into file
 * read track into file
 */
 */
  sprintf(filename, "track%02d\0", track);
  sprintf(filename, "track%02d\0", track);
  datafile=creat(filename, 0755);
  datafile=creat(filename, 0755);
  if (datafile<0)
  if (datafile<0)
    {
    {
      fprintf(stderr, "can't open datafile %s.\n", filename);
      fprintf(stderr, "can't open datafile %s.\n", filename);
      exit (-1);
      exit (-1);
    }
    }
  arg.addr.lba=entry[track].cdte_addr.lba;
  arg.addr.lba=entry[track].cdte_addr.lba;
  arg.addr_format=CDROM_LBA; /* CDROM_MSF would be possible here, too. */
  arg.addr_format=CDROM_LBA; /* CDROM_MSF would be possible here, too. */
  arg.nframes=1;
  arg.nframes=1;
  arg.buf=&buffer[0];
  arg.buf=&buffer[0];
  limit=entry[track+1].cdte_addr.lba;
  limit=entry[track+1].cdte_addr.lba;
  for (;arg.addr.lba
  for (;arg.addr.lba
    {
    {
      err=ioctl(drive, CDROMREADAUDIO, &arg);
      err=ioctl(drive, CDROMREADAUDIO, &arg);
      if (err!=0)
      if (err!=0)
        {
        {
          fprintf(stderr, "can't read abs. frame #%d (error %d).\n",
          fprintf(stderr, "can't read abs. frame #%d (error %d).\n",
                 arg.addr.lba, err);
                 arg.addr.lba, err);
        }
        }
      j=write(datafile, &buffer[0], CD_FRAMESIZE_RAW);
      j=write(datafile, &buffer[0], CD_FRAMESIZE_RAW);
      if (j!=CD_FRAMESIZE_RAW)
      if (j!=CD_FRAMESIZE_RAW)
        {
        {
          fprintf(stderr,"I/O error (datafile) at rel. frame %d\n",
          fprintf(stderr,"I/O error (datafile) at rel. frame %d\n",
                         arg.addr.lba-entry[track].cdte_addr.lba);
                         arg.addr.lba-entry[track].cdte_addr.lba);
        }
        }
      arg.addr.lba++;
      arg.addr.lba++;
    }
    }
}
}
/*===================== end program ========================================*/
/*===================== end program ========================================*/
At ftp.gwdg.de:/pub/linux/misc/cdda2wav-sbpcd.*.tar.gz is an adapted version of
At ftp.gwdg.de:/pub/linux/misc/cdda2wav-sbpcd.*.tar.gz is an adapted version of
Heiko Eissfeldt's digital-audio to .WAV converter (the original is there, too).
Heiko Eissfeldt's digital-audio to .WAV converter (the original is there, too).
This is preliminary, as Heiko himself will care about it.
This is preliminary, as Heiko himself will care about it.
Known problems:
Known problems:
---------------
---------------
Currently, the detection of disk change or removal is actively disabled.
Currently, the detection of disk change or removal is actively disabled.
Most attempts to read the UPC/EAN code result in a stream of zeroes. All my
Most attempts to read the UPC/EAN code result in a stream of zeroes. All my
drives are mostly telling there is no UPC/EAN code on disk or there is, but it
drives are mostly telling there is no UPC/EAN code on disk or there is, but it
is an all-zero number. I guess now almost no CD holds such a number.
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,
Bug reports, comments, wishes, donations (technical information is a donation,
too :-) etc. to emoenke@gwdg.de.
too :-) etc. to emoenke@gwdg.de.
SnailMail address, preferable for CD editors if they want to submit a free
SnailMail address, preferable for CD editors if they want to submit a free
"cooperation" copy:
"cooperation" copy:
                         Eberhard Moenkeberg
                         Eberhard Moenkeberg
                         Reinholdstr. 14
                         Reinholdstr. 14
                         D-37083 Goettingen
                         D-37083 Goettingen
                         Germany
                         Germany
---
---
Appendix -- the "cdtester" utility:
Appendix -- the "cdtester" utility:
/*
/*
 * cdtester.c -- test the audio functions of a CD driver
 * cdtester.c -- test the audio functions of a CD driver
 *
 *
 * (c) 1995 Eberhard Moenkeberg 
 * (c) 1995 Eberhard Moenkeberg 
 *          published under the GPL
 *          published under the GPL
 *
 *
 *          made under heavy use of the "Tiny Audio CD Player"
 *          made under heavy use of the "Tiny Audio CD Player"
 *          from Werner Zimmermann 
 *          from Werner Zimmermann 
 *          (see linux/drivers/block/README.aztcd)
 *          (see linux/drivers/block/README.aztcd)
 */
 */
#undef AZT_PRIVATE_IOCTLS /* not supported by every CDROM driver */
#undef AZT_PRIVATE_IOCTLS /* not supported by every CDROM driver */
#define SBP_PRIVATE_IOCTLS /* not supported by every CDROM driver */
#define SBP_PRIVATE_IOCTLS /* not supported by every CDROM driver */
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#ifdef AZT_PRIVATE_IOCTLS
#ifdef AZT_PRIVATE_IOCTLS
#include 
#include 
#endif AZT_PRIVATE_IOCTLS
#endif AZT_PRIVATE_IOCTLS
#ifdef SBP_PRIVATE_IOCTLS
#ifdef SBP_PRIVATE_IOCTLS
#include 
#include 
#include 
#include 
#endif SBP_PRIVATE_IOCTLS
#endif SBP_PRIVATE_IOCTLS
struct cdrom_tochdr hdr;
struct cdrom_tochdr hdr;
struct cdrom_tochdr tocHdr;
struct cdrom_tochdr tocHdr;
struct cdrom_tocentry TocEntry[101];
struct cdrom_tocentry TocEntry[101];
struct cdrom_tocentry entry;
struct cdrom_tocentry entry;
struct cdrom_multisession ms_info;
struct cdrom_multisession ms_info;
struct cdrom_read_audio read_audio;
struct cdrom_read_audio read_audio;
struct cdrom_ti ti;
struct cdrom_ti ti;
struct cdrom_subchnl subchnl;
struct cdrom_subchnl subchnl;
struct cdrom_msf msf;
struct cdrom_msf msf;
struct cdrom_volctrl volctrl;
struct cdrom_volctrl volctrl;
#ifdef AZT_PRIVATE_IOCTLS
#ifdef AZT_PRIVATE_IOCTLS
union
union
{
{
        struct cdrom_msf msf;
        struct cdrom_msf msf;
        unsigned char buf[CD_FRAMESIZE_RAW];
        unsigned char buf[CD_FRAMESIZE_RAW];
} azt;
} azt;
#endif AZT_PRIVATE_IOCTLS
#endif AZT_PRIVATE_IOCTLS
int i, i1, i2, i3, j, k;
int i, i1, i2, i3, j, k;
unsigned char sequence=0;
unsigned char sequence=0;
unsigned char command[80];
unsigned char command[80];
unsigned char first=1, last=1;
unsigned char first=1, last=1;
char *default_device="/dev/cdrom";
char *default_device="/dev/cdrom";
char dev[20];
char dev[20];
char filename[20];
char filename[20];
int drive;
int drive;
int datafile;
int datafile;
int rc;
int rc;
void help(void)
void help(void)
{
{
        printf("Available Commands:\n");
        printf("Available Commands:\n");
        printf("STOP          s      EJECT        e       QUIT         q\n");
        printf("STOP          s      EJECT        e       QUIT         q\n");
        printf("PLAY TRACK    t      PAUSE        p       RESUME       r\n");
        printf("PLAY TRACK    t      PAUSE        p       RESUME       r\n");
        printf("NEXT TRACK    n      REPEAT LAST  l       HELP         h\n");
        printf("NEXT TRACK    n      REPEAT LAST  l       HELP         h\n");
        printf("SUBCHANNEL_Q  c      TRACK INFO   i       PLAY AT      a\n");
        printf("SUBCHANNEL_Q  c      TRACK INFO   i       PLAY AT      a\n");
        printf("READ          d      READ RAW     w       READ AUDIO   A\n");
        printf("READ          d      READ RAW     w       READ AUDIO   A\n");
        printf("MS-INFO       M      TOC          T       START        S\n");
        printf("MS-INFO       M      TOC          T       START        S\n");
        printf("SET EJECTSW   X      DEVICE       D       DEBUG        Y\n");
        printf("SET EJECTSW   X      DEVICE       D       DEBUG        Y\n");
        printf("AUDIO_BUFSIZ  Z      RESET        R       BLKRASET     B\n");
        printf("AUDIO_BUFSIZ  Z      RESET        R       BLKRASET     B\n");
        printf("SET VOLUME    v      GET VOLUME   V\n");
        printf("SET VOLUME    v      GET VOLUME   V\n");
}
}
/*
/*
 *  convert MSF number (3 bytes only) to Logical_Block_Address
 *  convert MSF number (3 bytes only) to Logical_Block_Address
 */
 */
int msf2lba(u_char *msf)
int msf2lba(u_char *msf)
{
{
        int i;
        int i;
        i=(msf[0] * CD_SECS + msf[1]) * CD_FRAMES + msf[2] - CD_BLOCK_OFFSET;
        i=(msf[0] * CD_SECS + msf[1]) * CD_FRAMES + msf[2] - CD_BLOCK_OFFSET;
        if (i<0) return (0);
        if (i<0) return (0);
        return (i);
        return (i);
}
}
/*
/*
 *  convert logical_block_address to m-s-f_number (3 bytes only)
 *  convert logical_block_address to m-s-f_number (3 bytes only)
 */
 */
void lba2msf(int lba, unsigned char *msf)
void lba2msf(int lba, unsigned char *msf)
{
{
        lba += CD_BLOCK_OFFSET;
        lba += CD_BLOCK_OFFSET;
        msf[0] = lba / (CD_SECS*CD_FRAMES);
        msf[0] = lba / (CD_SECS*CD_FRAMES);
        lba %= CD_SECS*CD_FRAMES;
        lba %= CD_SECS*CD_FRAMES;
        msf[1] = lba / CD_FRAMES;
        msf[1] = lba / CD_FRAMES;
        msf[2] = lba % CD_FRAMES;
        msf[2] = lba % CD_FRAMES;
}
}
int init_drive(char *dev)
int init_drive(char *dev)
{
{
        unsigned char msf_ent[3];
        unsigned char msf_ent[3];
        /*
        /*
         * open the device
         * open the device
         */
         */
        drive=open(dev,0);
        drive=open(dev,0);
        if (drive<0) return (-1);
        if (drive<0) return (-1);
        /*
        /*
         * get TocHeader
         * get TocHeader
         */
         */
        printf("getting TocHeader...\n");
        printf("getting TocHeader...\n");
        rc=ioctl(drive,CDROMREADTOCHDR,&hdr);
        rc=ioctl(drive,CDROMREADTOCHDR,&hdr);
        if (rc!=0)
        if (rc!=0)
        {
        {
                printf("can't get TocHeader (error %d).\n",rc);
                printf("can't get TocHeader (error %d).\n",rc);
                return (-2);
                return (-2);
        }
        }
        else
        else
                first=hdr.cdth_trk0;
                first=hdr.cdth_trk0;
                last=hdr.cdth_trk1;
                last=hdr.cdth_trk1;
                printf("TocHeader: %d %d\n",hdr.cdth_trk0,hdr.cdth_trk1);
                printf("TocHeader: %d %d\n",hdr.cdth_trk0,hdr.cdth_trk1);
        /*
        /*
         * get and display all TocEntries
         * get and display all TocEntries
         */
         */
        printf("getting TocEntries...\n");
        printf("getting TocEntries...\n");
        for (i=1;i<=hdr.cdth_trk1+1;i++)
        for (i=1;i<=hdr.cdth_trk1+1;i++)
        {
        {
                if (i!=hdr.cdth_trk1+1) TocEntry[i].cdte_track = i;
                if (i!=hdr.cdth_trk1+1) TocEntry[i].cdte_track = i;
                else TocEntry[i].cdte_track = CDROM_LEADOUT;
                else TocEntry[i].cdte_track = CDROM_LEADOUT;
                TocEntry[i].cdte_format = CDROM_LBA;
                TocEntry[i].cdte_format = CDROM_LBA;
                rc=ioctl(drive,CDROMREADTOCENTRY,&TocEntry[i]);
                rc=ioctl(drive,CDROMREADTOCENTRY,&TocEntry[i]);
                if (rc!=0)
                if (rc!=0)
                {
                {
                        printf("can't get TocEntry #%d (error %d).\n",i,rc);
                        printf("can't get TocEntry #%d (error %d).\n",i,rc);
                }
                }
                else
                else
                {
                {
                        lba2msf(TocEntry[i].cdte_addr.lba,&msf_ent[0]);
                        lba2msf(TocEntry[i].cdte_addr.lba,&msf_ent[0]);
                        if (TocEntry[i].cdte_track==CDROM_LEADOUT)
                        if (TocEntry[i].cdte_track==CDROM_LEADOUT)
                        {
                        {
                                printf("TocEntry #%02X: %1X %1X %02d:%02d:%02d (lba: 0x%06X) %02X\n",
                                printf("TocEntry #%02X: %1X %1X %02d:%02d:%02d (lba: 0x%06X) %02X\n",
                                       TocEntry[i].cdte_track,
                                       TocEntry[i].cdte_track,
                                       TocEntry[i].cdte_adr,
                                       TocEntry[i].cdte_adr,
                                       TocEntry[i].cdte_ctrl,
                                       TocEntry[i].cdte_ctrl,
                                       msf_ent[0],
                                       msf_ent[0],
                                       msf_ent[1],
                                       msf_ent[1],
                                       msf_ent[2],
                                       msf_ent[2],
                                       TocEntry[i].cdte_addr.lba,
                                       TocEntry[i].cdte_addr.lba,
                                       TocEntry[i].cdte_datamode);
                                       TocEntry[i].cdte_datamode);
                        }
                        }
                        else
                        else
                        {
                        {
                                printf("TocEntry #%02d: %1X %1X %02d:%02d:%02d (lba: 0x%06X) %02X\n",
                                printf("TocEntry #%02d: %1X %1X %02d:%02d:%02d (lba: 0x%06X) %02X\n",
                                       TocEntry[i].cdte_track,
                                       TocEntry[i].cdte_track,
                                       TocEntry[i].cdte_adr,
                                       TocEntry[i].cdte_adr,
                                       TocEntry[i].cdte_ctrl,
                                       TocEntry[i].cdte_ctrl,
                                       msf_ent[0],
                                       msf_ent[0],
                                       msf_ent[1],
                                       msf_ent[1],
                                       msf_ent[2],
                                       msf_ent[2],
                                       TocEntry[i].cdte_addr.lba,
                                       TocEntry[i].cdte_addr.lba,
                                       TocEntry[i].cdte_datamode);
                                       TocEntry[i].cdte_datamode);
                        }
                        }
                }
                }
        }
        }
        return (hdr.cdth_trk1); /* number of tracks */
        return (hdr.cdth_trk1); /* number of tracks */
}
}
void display(int size,unsigned char *buffer)
void display(int size,unsigned char *buffer)
{
{
        k=0;
        k=0;
        getchar();
        getchar();
        for (i=0;i<(size+1)/16;i++)
        for (i=0;i<(size+1)/16;i++)
        {
        {
                printf("%4d:",i*16);
                printf("%4d:",i*16);
                for (j=0;j<16;j++)
                for (j=0;j<16;j++)
                {
                {
                        printf(" %02X",buffer[i*16+j]);
                        printf(" %02X",buffer[i*16+j]);
                }
                }
                printf("  ");
                printf("  ");
                for (j=0;j<16;j++)
                for (j=0;j<16;j++)
                {
                {
                        if (isalnum(buffer[i*16+j]))
                        if (isalnum(buffer[i*16+j]))
                                printf("%c",buffer[i*16+j]);
                                printf("%c",buffer[i*16+j]);
                        else
                        else
                                printf(".");
                                printf(".");
                }
                }
                printf("\n");
                printf("\n");
                k++;
                k++;
                if (k>=20)
                if (k>=20)
                {
                {
                        printf("press ENTER to continue\n");
                        printf("press ENTER to continue\n");
                        getchar();
                        getchar();
                        k=0;
                        k=0;
                }
                }
        }
        }
}
}
main(int argc, char *argv[])
main(int argc, char *argv[])
{
{
        printf("\nTesting tool for a CDROM driver's audio functions V0.1\n");
        printf("\nTesting tool for a CDROM driver's audio functions V0.1\n");
        printf("(C) 1995 Eberhard Moenkeberg \n");
        printf("(C) 1995 Eberhard Moenkeberg \n");
        printf("initializing...\n");
        printf("initializing...\n");
        rc=init_drive(default_device);
        rc=init_drive(default_device);
        if (rc<0) printf("could not open %s (rc=%d).\n",default_device,rc);
        if (rc<0) printf("could not open %s (rc=%d).\n",default_device,rc);
        help();
        help();
        while (1)
        while (1)
        {
        {
                printf("Give a one-letter command (h = help): ");
                printf("Give a one-letter command (h = help): ");
                scanf("%s",command);
                scanf("%s",command);
                command[1]=0;
                command[1]=0;
                switch (command[0])
                switch (command[0])
                {
                {
                case 'D':
                case 'D':
                        printf("device name (f.e. /dev/sbpcd3): ? ");
                        printf("device name (f.e. /dev/sbpcd3): ? ");
                        scanf("%s",&dev);
                        scanf("%s",&dev);
                        close(drive);
                        close(drive);
                        rc=init_drive(dev);
                        rc=init_drive(dev);
                        if (rc<0) printf("could not open %s (rc %d).\n",dev,rc);
                        if (rc<0) printf("could not open %s (rc %d).\n",dev,rc);
                        break;
                        break;
                case 'e':
                case 'e':
                        rc=ioctl(drive,CDROMEJECT);
                        rc=ioctl(drive,CDROMEJECT);
                        if (rc<0) printf("CDROMEJECT: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMEJECT: rc=%d.\n",rc);
                        break;
                        break;
                case 'p':
                case 'p':
                        rc=ioctl(drive,CDROMPAUSE);
                        rc=ioctl(drive,CDROMPAUSE);
                        if (rc<0) printf("CDROMPAUSE: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMPAUSE: rc=%d.\n",rc);
                        break;
                        break;
                case 'r':
                case 'r':
                        rc=ioctl(drive,CDROMRESUME);
                        rc=ioctl(drive,CDROMRESUME);
                        if (rc<0) printf("CDROMRESUME: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMRESUME: rc=%d.\n",rc);
                        break;
                        break;
                case 's':
                case 's':
                        rc=ioctl(drive,CDROMSTOP);
                        rc=ioctl(drive,CDROMSTOP);
                        if (rc<0) printf("CDROMSTOP: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMSTOP: rc=%d.\n",rc);
                        break;
                        break;
                case 'S':
                case 'S':
                        rc=ioctl(drive,CDROMSTART);
                        rc=ioctl(drive,CDROMSTART);
                        if (rc<0) printf("CDROMSTART: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMSTART: rc=%d.\n",rc);
                        break;
                        break;
                case 't':
                case 't':
                        rc=ioctl(drive,CDROMREADTOCHDR,&tocHdr);
                        rc=ioctl(drive,CDROMREADTOCHDR,&tocHdr);
                        if (rc<0)
                        if (rc<0)
                        {
                        {
                                printf("CDROMREADTOCHDR: rc=%d.\n",rc);
                                printf("CDROMREADTOCHDR: rc=%d.\n",rc);
                                break;
                                break;
                        }
                        }
                        first=tocHdr.cdth_trk0;
                        first=tocHdr.cdth_trk0;
                        last= tocHdr.cdth_trk1;
                        last= tocHdr.cdth_trk1;
                        if ((first==0)||(first>last))
                        if ((first==0)||(first>last))
                        {
                        {
                                printf ("--got invalid TOC data.\n");
                                printf ("--got invalid TOC data.\n");
                        }
                        }
                        else
                        else
                        {
                        {
                                printf("--enter track number(first=%d, last=%d): ",first,last);
                                printf("--enter track number(first=%d, last=%d): ",first,last);
                                scanf("%d",&i1);
                                scanf("%d",&i1);
                                ti.cdti_trk0=i1;
                                ti.cdti_trk0=i1;
                                if (ti.cdti_trk0
                                if (ti.cdti_trk0
                                if (ti.cdti_trk0>last) ti.cdti_trk0=last;
                                if (ti.cdti_trk0>last) ti.cdti_trk0=last;
                                ti.cdti_ind0=0;
                                ti.cdti_ind0=0;
                                ti.cdti_trk1=last;
                                ti.cdti_trk1=last;
                                ti.cdti_ind1=0;
                                ti.cdti_ind1=0;
                                rc=ioctl(drive,CDROMSTOP);
                                rc=ioctl(drive,CDROMSTOP);
                                rc=ioctl(drive,CDROMPLAYTRKIND,&ti);
                                rc=ioctl(drive,CDROMPLAYTRKIND,&ti);
                                if (rc<0) printf("CDROMPLAYTRKIND: rc=%d.\n",rc);
                                if (rc<0) printf("CDROMPLAYTRKIND: rc=%d.\n",rc);
                        }
                        }
                        break;
                        break;
                case 'n':
                case 'n':
                        rc=ioctl(drive,CDROMSTOP);
                        rc=ioctl(drive,CDROMSTOP);
                        if (++ti.cdti_trk0>last) ti.cdti_trk0=last;
                        if (++ti.cdti_trk0>last) ti.cdti_trk0=last;
                        ti.cdti_ind0=0;
                        ti.cdti_ind0=0;
                        ti.cdti_trk1=last;
                        ti.cdti_trk1=last;
                        ti.cdti_ind1=0;
                        ti.cdti_ind1=0;
                        rc=ioctl(drive,CDROMPLAYTRKIND,&ti);
                        rc=ioctl(drive,CDROMPLAYTRKIND,&ti);
                        if (rc<0) printf("CDROMPLAYTRKIND: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMPLAYTRKIND: rc=%d.\n",rc);
                        break;
                        break;
                case 'l':
                case 'l':
                        rc=ioctl(drive,CDROMSTOP);
                        rc=ioctl(drive,CDROMSTOP);
                        if (--ti.cdti_trk0
                        if (--ti.cdti_trk0
                        ti.cdti_ind0=0;
                        ti.cdti_ind0=0;
                        ti.cdti_trk1=last;
                        ti.cdti_trk1=last;
                        ti.cdti_ind1=0;
                        ti.cdti_ind1=0;
                        rc=ioctl(drive,CDROMPLAYTRKIND,&ti);
                        rc=ioctl(drive,CDROMPLAYTRKIND,&ti);
                        if (rc<0) printf("CDROMPLAYTRKIND: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMPLAYTRKIND: rc=%d.\n",rc);
                        break;
                        break;
                case 'c':
                case 'c':
                        subchnl.cdsc_format=CDROM_MSF;
                        subchnl.cdsc_format=CDROM_MSF;
                        rc=ioctl(drive,CDROMSUBCHNL,&subchnl);
                        rc=ioctl(drive,CDROMSUBCHNL,&subchnl);
                        if (rc<0) printf("CDROMSUBCHNL: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMSUBCHNL: rc=%d.\n",rc);
                        else
                        else
                        {
                        {
                                printf("AudioStatus:%s  Track:%d  Mode:%d  MSF=%02d:%02d:%02d\n",
                                printf("AudioStatus:%s  Track:%d  Mode:%d  MSF=%02d:%02d:%02d\n",
                                       subchnl.cdsc_audiostatus==CDROM_AUDIO_PLAY ? "PLAYING":"NOT PLAYING",
                                       subchnl.cdsc_audiostatus==CDROM_AUDIO_PLAY ? "PLAYING":"NOT PLAYING",
                                       subchnl.cdsc_trk,subchnl.cdsc_adr,
                                       subchnl.cdsc_trk,subchnl.cdsc_adr,
                                       subchnl.cdsc_absaddr.msf.minute,
                                       subchnl.cdsc_absaddr.msf.minute,
                                       subchnl.cdsc_absaddr.msf.second,
                                       subchnl.cdsc_absaddr.msf.second,
                                       subchnl.cdsc_absaddr.msf.frame);
                                       subchnl.cdsc_absaddr.msf.frame);
                        }
                        }
                        break;
                        break;
                case 'i':
                case 'i':
                        printf("Track No.: ");
                        printf("Track No.: ");
                        scanf("%d",&i1);
                        scanf("%d",&i1);
                        entry.cdte_track=i1;
                        entry.cdte_track=i1;
                        if (entry.cdte_track
                        if (entry.cdte_track
                        if (entry.cdte_track>last)  entry.cdte_track=last;
                        if (entry.cdte_track>last)  entry.cdte_track=last;
                        entry.cdte_format=CDROM_MSF;
                        entry.cdte_format=CDROM_MSF;
                        rc=ioctl(drive,CDROMREADTOCENTRY,&entry);
                        rc=ioctl(drive,CDROMREADTOCENTRY,&entry);
                        if (rc<0) printf("CDROMREADTOCENTRY: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMREADTOCENTRY: rc=%d.\n",rc);
                        else
                        else
                        {
                        {
                                printf("Mode %d Track, starts at %02d:%02d:%02d\n",
                                printf("Mode %d Track, starts at %02d:%02d:%02d\n",
                                       entry.cdte_adr,
                                       entry.cdte_adr,
                                       entry.cdte_addr.msf.minute,
                                       entry.cdte_addr.msf.minute,
                                       entry.cdte_addr.msf.second,
                                       entry.cdte_addr.msf.second,
                                       entry.cdte_addr.msf.frame);
                                       entry.cdte_addr.msf.frame);
                        }
                        }
                        break;
                        break;
                case 'a':
                case 'a':
                        printf("Address (min:sec:frm)  ");
                        printf("Address (min:sec:frm)  ");
                        scanf("%d:%d:%d",&i1,&i2,&i3);
                        scanf("%d:%d:%d",&i1,&i2,&i3);
                        msf.cdmsf_min0=i1;
                        msf.cdmsf_min0=i1;
                        msf.cdmsf_sec0=i2;
                        msf.cdmsf_sec0=i2;
                        msf.cdmsf_frame0=i3;
                        msf.cdmsf_frame0=i3;
                        if (msf.cdmsf_sec0>59) msf.cdmsf_sec0=59;
                        if (msf.cdmsf_sec0>59) msf.cdmsf_sec0=59;
                        if (msf.cdmsf_frame0>74) msf.cdmsf_frame0=74;
                        if (msf.cdmsf_frame0>74) msf.cdmsf_frame0=74;
                        lba2msf(TocEntry[last+1].cdte_addr.lba-1,&msf.cdmsf_min1);
                        lba2msf(TocEntry[last+1].cdte_addr.lba-1,&msf.cdmsf_min1);
                        rc=ioctl(drive,CDROMSTOP);
                        rc=ioctl(drive,CDROMSTOP);
                        rc=ioctl(drive,CDROMPLAYMSF,&msf);
                        rc=ioctl(drive,CDROMPLAYMSF,&msf);
                        if (rc<0) printf("CDROMPLAYMSF: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMPLAYMSF: rc=%d.\n",rc);
                        break;
                        break;
                case 'V':
                case 'V':
                        rc=ioctl(drive,CDROMVOLREAD,&volctrl);
                        rc=ioctl(drive,CDROMVOLREAD,&volctrl);
                        if (rc<0) printf("CDROMVOLCTRL: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMVOLCTRL: rc=%d.\n",rc);
                        printf("Volume: channel 0 (left) %d, channel 1 (right) %d\n",volctrl.channel0,volctrl.channel1);
                        printf("Volume: channel 0 (left) %d, channel 1 (right) %d\n",volctrl.channel0,volctrl.channel1);
                        break;
                        break;
                case 'R':
                case 'R':
                        rc=ioctl(drive,CDROMRESET);
                        rc=ioctl(drive,CDROMRESET);
                        if (rc<0) printf("CDROMRESET: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMRESET: rc=%d.\n",rc);
                        break;
                        break;
                case 'B': /* set the driver's (?) read ahead value */
                case 'B': /* set the driver's (?) read ahead value */
                        printf("enter read-ahead size: ? ");
                        printf("enter read-ahead size: ? ");
                        scanf("%d",&i);
                        scanf("%d",&i);
                        rc=ioctl(drive,BLKRASET,i);
                        rc=ioctl(drive,BLKRASET,i);
                        if (rc<0) printf("BLKRASET: rc=%d.\n",rc);
                        if (rc<0) printf("BLKRASET: rc=%d.\n",rc);
                        break;
                        break;
#ifdef AZT_PRIVATE_IOCTLS /*not supported by every CDROM driver*/
#ifdef AZT_PRIVATE_IOCTLS /*not supported by every CDROM driver*/
                case 'd':
                case 'd':
                        printf("Address (min:sec:frm)  ");
                        printf("Address (min:sec:frm)  ");
                        scanf("%d:%d:%d",&i1,&i2,&i3);
                        scanf("%d:%d:%d",&i1,&i2,&i3);
                        azt.msf.cdmsf_min0=i1;
                        azt.msf.cdmsf_min0=i1;
                        azt.msf.cdmsf_sec0=i2;
                        azt.msf.cdmsf_sec0=i2;
                        azt.msf.cdmsf_frame0=i3;
                        azt.msf.cdmsf_frame0=i3;
                        if (azt.msf.cdmsf_sec0>59) azt.msf.cdmsf_sec0=59;
                        if (azt.msf.cdmsf_sec0>59) azt.msf.cdmsf_sec0=59;
                        if (azt.msf.cdmsf_frame0>74) azt.msf.cdmsf_frame0=74;
                        if (azt.msf.cdmsf_frame0>74) azt.msf.cdmsf_frame0=74;
                        rc=ioctl(drive,CDROMREADMODE1,&azt.msf);
                        rc=ioctl(drive,CDROMREADMODE1,&azt.msf);
                        if (rc<0) printf("CDROMREADMODE1: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMREADMODE1: rc=%d.\n",rc);
                        else display(CD_FRAMESIZE,azt.buf);
                        else display(CD_FRAMESIZE,azt.buf);
                        break;
                        break;
                case 'w':
                case 'w':
                        printf("Address (min:sec:frame)  ");
                        printf("Address (min:sec:frame)  ");
                        scanf("%d:%d:%d",&i1,&i2,&i3);
                        scanf("%d:%d:%d",&i1,&i2,&i3);
                        azt.msf.cdmsf_min0=i1;
                        azt.msf.cdmsf_min0=i1;
                        azt.msf.cdmsf_sec0=i2;
                        azt.msf.cdmsf_sec0=i2;
                        azt.msf.cdmsf_frame0=i3;
                        azt.msf.cdmsf_frame0=i3;
                        if (azt.msf.cdmsf_sec0>59) azt.msf.cdmsf_sec0=59;
                        if (azt.msf.cdmsf_sec0>59) azt.msf.cdmsf_sec0=59;
                        if (azt.msf.cdmsf_frame0>74) azt.msf.cdmsf_frame0=74;
                        if (azt.msf.cdmsf_frame0>74) azt.msf.cdmsf_frame0=74;
                        rc=ioctl(drive,CDROMREADMODE2,&azt.msf);
                        rc=ioctl(drive,CDROMREADMODE2,&azt.msf);
                        if (rc<0) printf("CDROMREADMODE2: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMREADMODE2: rc=%d.\n",rc);
                        else display(CD_FRAMESIZE_RAW,azt.buf); /* currently only 2336 */
                        else display(CD_FRAMESIZE_RAW,azt.buf); /* currently only 2336 */
                        break;
                        break;
#endif
#endif
                case 'v':
                case 'v':
                        printf("--Channel 0 (Left)  (0-255): ");
                        printf("--Channel 0 (Left)  (0-255): ");
                        scanf("%d",&i1);
                        scanf("%d",&i1);
                        volctrl.channel0=i1;
                        volctrl.channel0=i1;
                        printf("--Channel 1 (Right) (0-255): ");
                        printf("--Channel 1 (Right) (0-255): ");
                        scanf("%d",&i1);
                        scanf("%d",&i1);
                        volctrl.channel1=i1;
                        volctrl.channel1=i1;
                        volctrl.channel2=0;
                        volctrl.channel2=0;
                        volctrl.channel3=0;
                        volctrl.channel3=0;
                        rc=ioctl(drive,CDROMVOLCTRL,&volctrl);
                        rc=ioctl(drive,CDROMVOLCTRL,&volctrl);
                        if (rc<0) printf("CDROMVOLCTRL: rc=%d.\n",rc);
                        if (rc<0) printf("CDROMVOLCTRL: rc=%d.\n",rc);
                        break;
                        break;
                case 'q':
                case 'q':
                        close(drive);
                        close(drive);
                        exit(0);
                        exit(0);
                case 'h':
                case 'h':
                        help();
                        help();
                        break;
                        break;
                case 'T': /* display TOC entry - without involving the driver */
                case 'T': /* display TOC entry - without involving the driver */
                        scanf("%d",&i);
                        scanf("%d",&i);
                        if ((ihdr.cdth_trk1))
                        if ((ihdr.cdth_trk1))
                                printf("invalid track number.\n");
                                printf("invalid track number.\n");
                        else
                        else
                                printf("TocEntry %02d: adr=%01X ctrl=%01X msf=%02d:%02d:%02d mode=%02X\n",
                                printf("TocEntry %02d: adr=%01X ctrl=%01X msf=%02d:%02d:%02d mode=%02X\n",
                                       TocEntry[i].cdte_track,
                                       TocEntry[i].cdte_track,
                                       TocEntry[i].cdte_adr,
                                       TocEntry[i].cdte_adr,
                                       TocEntry[i].cdte_ctrl,
                                       TocEntry[i].cdte_ctrl,
                                       TocEntry[i].cdte_addr.msf.minute,
                                       TocEntry[i].cdte_addr.msf.minute,
                                       TocEntry[i].cdte_addr.msf.second,
                                       TocEntry[i].cdte_addr.msf.second,
                                       TocEntry[i].cdte_addr.msf.frame,
                                       TocEntry[i].cdte_addr.msf.frame,
                                       TocEntry[i].cdte_datamode);
                                       TocEntry[i].cdte_datamode);
                        break;
                        break;
                case 'A': /* read audio data into file */
                case 'A': /* read audio data into file */
                        printf("Address (min:sec:frm) ? ");
                        printf("Address (min:sec:frm) ? ");
                        scanf("%d:%d:%d",&i1,&i2,&i3);
                        scanf("%d:%d:%d",&i1,&i2,&i3);
                        read_audio.addr.msf.minute=i1;
                        read_audio.addr.msf.minute=i1;
                        read_audio.addr.msf.second=i2;
                        read_audio.addr.msf.second=i2;
                        read_audio.addr.msf.frame=i3;
                        read_audio.addr.msf.frame=i3;
                        read_audio.addr_format=CDROM_MSF;
                        read_audio.addr_format=CDROM_MSF;
                        printf("# of frames ? ");
                        printf("# of frames ? ");
                        scanf("%d",&i1);
                        scanf("%d",&i1);
                        read_audio.nframes=i1;
                        read_audio.nframes=i1;
                        k=read_audio.nframes*CD_FRAMESIZE_RAW;
                        k=read_audio.nframes*CD_FRAMESIZE_RAW;
                        read_audio.buf=malloc(k);
                        read_audio.buf=malloc(k);
                        if (read_audio.buf==NULL)
                        if (read_audio.buf==NULL)
                        {
                        {
                                printf("can't malloc %d bytes.\n",k);
                                printf("can't malloc %d bytes.\n",k);
                                break;
                                break;
                        }
                        }
                        sprintf(filename,"audio_%02d%02d%02d_%02d.%02d\0",
                        sprintf(filename,"audio_%02d%02d%02d_%02d.%02d\0",
                                read_audio.addr.msf.minute,
                                read_audio.addr.msf.minute,
                                read_audio.addr.msf.second,
                                read_audio.addr.msf.second,
                                read_audio.addr.msf.frame,
                                read_audio.addr.msf.frame,
                                read_audio.nframes,
                                read_audio.nframes,
                                ++sequence);
                                ++sequence);
                        datafile=creat(filename, 0755);
                        datafile=creat(filename, 0755);
                        if (datafile<0)
                        if (datafile<0)
                        {
                        {
                                printf("can't open datafile %s.\n",filename);
                                printf("can't open datafile %s.\n",filename);
                                break;
                                break;
                        }
                        }
                        rc=ioctl(drive,CDROMREADAUDIO,&read_audio);
                        rc=ioctl(drive,CDROMREADAUDIO,&read_audio);
                        if (rc!=0)
                        if (rc!=0)
                        {
                        {
                                printf("CDROMREADAUDIO: rc=%d.\n",rc);
                                printf("CDROMREADAUDIO: rc=%d.\n",rc);
                        }
                        }
                        else
                        else
                        {
                        {
                                rc=write(datafile,&read_audio.buf,k);
                                rc=write(datafile,&read_audio.buf,k);
                                if (rc!=k) printf("datafile I/O error (%d).\n",rc);
                                if (rc!=k) printf("datafile I/O error (%d).\n",rc);
                        }
                        }
                        close(datafile);
                        close(datafile);
                        break;
                        break;
                case 'X': /* set EJECT_SW (0: disable, 1: enable auto-ejecting) */
                case 'X': /* set EJECT_SW (0: disable, 1: enable auto-ejecting) */
                        scanf("%d",&i);
                        scanf("%d",&i);
                        rc=ioctl(drive,CDROMEJECT_SW,i);
                        rc=ioctl(drive,CDROMEJECT_SW,i);
                        if (rc!=0)
                        if (rc!=0)
                                printf("CDROMEJECT_SW: rc=%d.\n",rc);
                                printf("CDROMEJECT_SW: rc=%d.\n",rc);
                        else
                        else
                                printf("EJECT_SW set to %d\n",i);
                                printf("EJECT_SW set to %d\n",i);
                        break;
                        break;
                case 'M': /* get the multisession redirection info */
                case 'M': /* get the multisession redirection info */
                        ms_info.addr_format=CDROM_LBA;
                        ms_info.addr_format=CDROM_LBA;
                        rc=ioctl(drive,CDROMMULTISESSION,&ms_info);
                        rc=ioctl(drive,CDROMMULTISESSION,&ms_info);
                        if (rc!=0)
                        if (rc!=0)
                        {
                        {
                                printf("CDROMMULTISESSION(lba): rc=%d.\n",rc);
                                printf("CDROMMULTISESSION(lba): rc=%d.\n",rc);
                        }
                        }
                        else
                        else
                        {
                        {
                                if (ms_info.xa_flag) printf("MultiSession offset (lba): %d (0x%06X)\n",ms_info.addr.lba,ms_info.addr.lba);
                                if (ms_info.xa_flag) printf("MultiSession offset (lba): %d (0x%06X)\n",ms_info.addr.lba,ms_info.addr.lba);
                                else
                                else
                                {
                                {
                                        printf("this CD is not an XA disk.\n");
                                        printf("this CD is not an XA disk.\n");
                                        break;
                                        break;
                                }
                                }
                        }
                        }
                        ms_info.addr_format=CDROM_MSF;
                        ms_info.addr_format=CDROM_MSF;
                        rc=ioctl(drive,CDROMMULTISESSION,&ms_info);
                        rc=ioctl(drive,CDROMMULTISESSION,&ms_info);
                        if (rc!=0)
                        if (rc!=0)
                        {
                        {
                                printf("CDROMMULTISESSION(msf): rc=%d.\n",rc);
                                printf("CDROMMULTISESSION(msf): rc=%d.\n",rc);
                        }
                        }
                        else
                        else
                        {
                        {
                                if (ms_info.xa_flag)
                                if (ms_info.xa_flag)
                                        printf("MultiSession offset (msf): %02d:%02d:%02d (0x%02X%02X%02X)\n",
                                        printf("MultiSession offset (msf): %02d:%02d:%02d (0x%02X%02X%02X)\n",
                                               ms_info.addr.msf.minute,
                                               ms_info.addr.msf.minute,
                                               ms_info.addr.msf.second,
                                               ms_info.addr.msf.second,
                                               ms_info.addr.msf.frame,
                                               ms_info.addr.msf.frame,
                                               ms_info.addr.msf.minute,
                                               ms_info.addr.msf.minute,
                                               ms_info.addr.msf.second,
                                               ms_info.addr.msf.second,
                                               ms_info.addr.msf.frame);
                                               ms_info.addr.msf.frame);
                                else printf("this CD is not an XA disk.\n");
                                else printf("this CD is not an XA disk.\n");
                        }
                        }
                        break;
                        break;
#ifdef SBP_PRIVATE_IOCTLS
#ifdef SBP_PRIVATE_IOCTLS
                case 'Y': /* set the driver's message level */
                case 'Y': /* set the driver's message level */
#if 0 /* not implemented yet */
#if 0 /* not implemented yet */
                        printf("enter switch name (f.e. DBG_CMD): ");
                        printf("enter switch name (f.e. DBG_CMD): ");
                        scanf("%s",&dbg_switch);
                        scanf("%s",&dbg_switch);
                        j=get_dbg_num(dbg_switch);
                        j=get_dbg_num(dbg_switch);
#else
#else
                        printf("enter DDIOCSDBG switch number: ");
                        printf("enter DDIOCSDBG switch number: ");
                        scanf("%d",&j);
                        scanf("%d",&j);
#endif
#endif
                        printf("enter 0 for \"off\", 1 for \"on\": ");
                        printf("enter 0 for \"off\", 1 for \"on\": ");
                        scanf("%d",&i);
                        scanf("%d",&i);
                        if (i==0) j|=0x80;
                        if (i==0) j|=0x80;
                        printf("calling \"ioctl(drive,DDIOCSDBG,%d)\"\n",j);
                        printf("calling \"ioctl(drive,DDIOCSDBG,%d)\"\n",j);
                        rc=ioctl(drive,DDIOCSDBG,j);
                        rc=ioctl(drive,DDIOCSDBG,j);
                        printf("DDIOCSDBG: rc=%d.\n",rc);
                        printf("DDIOCSDBG: rc=%d.\n",rc);
                        break;
                        break;
                case 'Z': /* set the audio buffer size */
                case 'Z': /* set the audio buffer size */
                        printf("# frames wanted: ? ");
                        printf("# frames wanted: ? ");
                        scanf("%d",&j);
                        scanf("%d",&j);
                        rc=ioctl(drive,CDROMAUDIOBUFSIZ,j);
                        rc=ioctl(drive,CDROMAUDIOBUFSIZ,j);
                        printf("%d frames granted.\n",rc);
                        printf("%d frames granted.\n",rc);
                        break;
                        break;
#endif SBP_PRIVATE_IOCTLS
#endif SBP_PRIVATE_IOCTLS
                default:
                default:
                        printf("unknown command: \"%s\".\n",command);
                        printf("unknown command: \"%s\".\n",command);
                        break;
                        break;
                }
                }
        }
        }
}
}
/*==========================================================================*/
/*==========================================================================*/
 
 

powered by: WebSVN 2.1.0

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