summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--share/man/man4/man4.i386/Makefile2
-rw-r--r--share/man/man4/man4.i386/matcd.4394
-rw-r--r--sys/conf/files.i3861
-rw-r--r--sys/conf/files.pc981
-rw-r--r--sys/conf/majors1
-rw-r--r--sys/i386/conf/NOTES5
-rw-r--r--sys/i386/isa/matcd/TODO42
-rw-r--r--sys/i386/isa/matcd/audio.c514
-rw-r--r--sys/i386/isa/matcd/creative.h142
-rw-r--r--sys/i386/isa/matcd/matcd.c2706
-rw-r--r--sys/i386/isa/matcd/matcddrv.h198
-rw-r--r--sys/i386/isa/matcd/options.h283
12 files changed, 1 insertions, 4288 deletions
diff --git a/share/man/man4/man4.i386/Makefile b/share/man/man4/man4.i386/Makefile
index c3ee1cd..dbdce3f 100644
--- a/share/man/man4/man4.i386/Makefile
+++ b/share/man/man4/man4.i386/Makefile
@@ -3,7 +3,7 @@
MAN= aic.4 alpm.4 amdpm.4 apm.4 ar.4 asc.4 asr.4 \
cs.4 cx.4 cy.4 \
dgb.4 el.4 en.4 ep.4 ex.4 fe.4 gsc.4 \
- ie.4 io.4 le.4 linux.4 lnc.4 longrun.4 matcd.4 mcd.4 \
+ ie.4 io.4 le.4 linux.4 lnc.4 longrun.4 mcd.4 \
meteor.4 mse.4 npx.4 \
pcf.4 perfmon.4 pnp.4 pnpbios.4 \
ray.4 rdp.4 scd.4 \
diff --git a/share/man/man4/man4.i386/matcd.4 b/share/man/man4/man4.i386/matcd.4
deleted file mode 100644
index e66b128..0000000
--- a/share/man/man4/man4.i386/matcd.4
+++ /dev/null
@@ -1,394 +0,0 @@
-.\"Matsushita(Panasonic) / Creative CD-ROM Driver (matcd)
-.\"Authored by Frank Durda IV
-.\"
-.\"Program and Documentation are Copyright 1994, 1995 Frank Durda IV.
-.\"All rights reserved.
-.\" "FDIV" is a trademark of Frank Durda IV.
-.\"
-.\"
-.\"Redistribution and use in source and binary forms, with or
-.\"without modification, are permitted provided that the following
-.\"conditions are met:
-.\"1. Redistributions of source code must retain the above copyright
-.\" notice positioned at the very beginning of this file without
-.\" modification, all copyright strings, all related programming
-.\" codes that display the copyright strings, this list of
-.\" conditions and the following disclaimer.
-.\"2. Redistributions in binary form must contain all copyright strings
-.\" and related programming code that display the copyright strings.
-.\"3. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in
-.\" the documentation and/or other materials provided with the
-.\" distribution.
-.\"4. All advertising materials mentioning features or use of this
-.\" software must display the following acknowledgement:
-.\" "The Matsushita/Panasonic CD-ROM driver was developed
-.\" by Frank Durda IV for use with "FreeBSD" and similar
-.\" operating systems."
-.\" "Similar operating systems" includes mainly non-profit oriented
-.\" systems for research and education, including but not restricted
-.\" to "NetBSD", "386BSD", and "Mach" (by CMU). The wording of the
-.\" acknowledgement (in electronic form or printed text) may not be
-.\" changed without permission from the author.
-.\"5. Absolutely no warranty of function, fitness or purpose is made
-.\" by the author Frank Durda IV.
-.\"6. Neither the name of the author nor the name "FreeBSD" may
-.\" be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\" (The author can be reached at bsdmail@nemesis.lonestar.org)
-.\"7. The product containing this software must meet all of these
-.\" conditions even if it is unsupported, not a complete system
-.\" and/or does not contain compiled code.
-.\"8. These conditions will be in force for the full life of the
-.\" copyright.
-.\"9. If all the above conditions are met, modifications to other
-.\" parts of this file may be freely made, although any person
-.\" or persons making changes do not receive the right to add their
-.\" name or names to the copyright strings and notices in this
-.\" software. Persons making changes are encouraged to insert edit
-.\" history in matcd.c and to put your name and details of the
-.\" change there.
-.\"10. You must have prior written permission from the author to
-.\" deviate from these terms.
-.\"
-.\"Vendors who produce product(s) containing this code are encouraged
-.\"(but not required) to provide copies of the finished product(s) to
-.\"the author and to correspond with the author about development
-.\"activity relating to this code. Donations of development hardware
-.\"and/or software are also welcome. (This is one of the faster ways
-.\"to get a driver developed for a device.)
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``AS IS'' AND ANY
-.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER(S) BE
-.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
-.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-.\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\"--------------------------------------------------------------------------
-.\"Dedicated to: My family and Max, my Golden Retriever
-.\"-----No changes are allowed above this line-------------------------------
-.\"
-.\" Please note any documentation updates here including your name
-.\" and the date.
-.\"<2> Text brought in sync with changes made in versions 1(17) - 1(21)
-.\" Frank Durda IV 4-Jul-95
-.\"<3> Text brought in sync with changes made in versions 1(22) - 1(25)
-.\" Frank Durda IV 24-Sep-95
-.\"
-.\" $FreeBSD$
-.\"
-.Dd September 24, 1995
-.Dt MATCD 4 i386
-.\"Synchronized to Version 1(25) of matcd.c
-.Os
-.Sh NAME
-.Nm matcd
-.Nd Matsushita (Panasonic) CD-ROM driver
-.Sh SYNOPSIS
-.Cd "device matcd 1"
-.Pp
-In
-.Pa /boot/device.hints :
-.Cd hint.matcd.0.at="isa"
-.Sh DESCRIPTION
-The
-.Nm
-driver controls the CR-562-x and CR-563-x CD-ROM drives made by
-Matsushita-Kotobuki Electronics Industries, or Matsushita for short.
-These CD-ROM drives have been sold under the Panasonic (which is a trade
-name for Matsushita), Creative Labs (omniCD) and Reveal names, and have
-been included in computers made by Tandy, AST, Packard Bell and many others.
-.Pp
-These drives connect to the PC ISA bus through a proprietary host interface.
-This interface can exist as a stand-alone ISA card, or can be included on
-a sound card.
-.Sh DRIVER CONFIGURATION
-The
-.Nm
-driver supports up to four host interfaces with up to four drives on each
-interface. Audio activity may occur on all drives simultaneously. Data
-read operations are limited to one drive per host interface at any instant.
-.Pp
-To support multiple host interfaces, it is necessary to modify the
-entries in the kernel configuration file. Normally your system comes
-with the file \fI/usr/src/sys/i386/conf/GENERIC\fR. You should make
-a copy of this file and give it the name of your system.
-You can then edit the new file to include devices you want the system
-to support and delete the device entries that you don't want.
-.Pp
-In this file, you will find an entry like:
-.Bd -literal -offset indent
-device matcd 1
-.Ed
-.Pp
-To support two host interfaces, change the file so it reads:
-.Bd -literal -offset indent
-device matcd 2
-.Ed
-.Pp
-(If you want to support up to three or four host interfaces,
-increase the number at the end of the line).
-.Pp
-Note that the kernel configuration does not need to be modified to support
-up to four drives on a single host interface. It is also not necessary to
-have four drives on a single interface before adding a second interface.
-.Pp
-By default,
-.Nm
-searches for the CD-ROM host interface adapters by using a table of known I/O
-ports on Creative host adapters (see \fIoptions.h\fR). Although this
-is very flexible, it can cause problems when your system has other devices
-that are located at the I/O ports that
-.Nm
-is checking for CD-ROM host interfaces. In addition, checking multiple
-locations can cause the boot process to take longer than it could.
-.Pp
-If you are having these problems, you can solve them by explicitly specifying
-where the CD-ROM host interfaces are located. For example, by default most
-SoundBlaster cards have the Matsushita CD-ROM host interface
-located at I/O port 0x230. (This is 0x10 above the I/O port for the
-audio section of the card.) If this is the case for your system, you could
-change where the kernel looks for the hardware by entering a line in
-.Pa /boot/device.hints .
-For example, to change the I/O port for
-.Nm
-adapter zero to 0x340, you would put
-.Pp
-.Dl hint.matcd.0.port="0x340"
-.Pp
-in the file.
-.Pp
-With this change, the
-.Nm
-driver will only look at I/O port 0x340 for the first CD-ROM host interface
-and will not disturb any other I/O ports.
-.Pp
-You can specify the I/O port for the second, third, and fourth
-adapters in the same fashion:
-.Pp
-.Dl hint.matcd.0.port="0x230"
-.Dl hint.matcd.1.port="0x340"
-.Sh SUPPORTED HARDWARE
-At this time, there are only two known drive models that work with the
-.Nm
-driver:
-.Bl -item -width CR-123-X -compact -offset indent
-.It
-Matsushita CR-562-x
-.It
-Matsushita CR-563-x
-.El
-Most resellers leave these original markings on the drives since the label
-also has the FCC, VDE, CSA and RU certification marks.
-.Pp
-Both of these drive models have motorized trays. There is also a custom
-version of these drives that does not have the volume control or headphone
-jack (seen on some Tandy computers), but this drive also works with
-.Nm .
-.Pp
-The Matsushita CR-522-x and CR-523-x CD-ROM drive is not usable with
-.Nm .
-The CR-522 and CR-523 can also be identified from the front as it
-requires a CD-caddy.
-.Pp
-Drives with IDE interfaces must use an IDE driver.
-.Pp
-The TEAC CD-55 4X CD-ROM drive also uses the Creative/Panasonic interface
-but the TEAC drive is \fInot\fR compatible with the Matsushita CR-56x drives.
-The TEAC drive cannot be used with
-.Nm .
-.Pp
-The most common source of host interface adapters for the Panasonic drives
-are found in products from Creative Labs, including SoundBlaster sound
-cards. There are numerous models of SoundBlaster sound cards, and most
-of the newer cards provide the appropriate interface, sometimes labeled as
-the "Creative/Panasonic" interface.
-.Pp
-The following host interface adapters are known to work with the
-.Nm
-driver:
-.Bl -tag -width LONGNAME -compact -offset indent
-.It Creative
-Sound Blaster Pro (SBPRO) (CT1330A)
-.It Creative
-Sound Blaster 16 (CT1730)
-.It Creative
-Sound Blaster 16 - cost-reduced (CT1740)
-.It Creative
-OmniCD upgrade kit adapter card - stand-alone CD (CT1810)
-.It Creative
-Sound Blaster 16 - 2-layer, cost-reduced (CT2230)
-.It Creative
-Sound Blaster 16 (Vibra16) - 2-layer, single-chip (CT2260)
-.It Creative
-Sound Blaster 16 Value (SB16) - 2-layer, cost-reduced (CT2770)
-.It Creative
-PhoneBlaster SB16 + Sierra 14.4K Voice/FAX/Data/Speakerphone modem combo (CT3100)
-.It Reveal
-(SC400)
-.El
-.Pp
-Caution: Some of these sound boards can be optionally manufactured to not
-include the Panasonic/Creative interface, so check the board before buying
-solely based on model number.
-.Pp
-This is by no means a complete list as Creative Labs and other vendors
-that produce sound cards with an identical Creative/Panasonic drive
-interface release new versions of their adapters all the time.
-.Pp
-In addition to Creative Labs adapters, adapters that are compatible with
-Media Vision, IBM and Lasermate adapters are also supported. However,
-these adapters use a wide range of I/O port addresses, so the driver
-must be reconfigured to locate these adapters.
-.Pp
-It is important to understand that some manufacturers have a different
-host interface implementation. If you have a board that won't communicate
-with the drives under MS-DOS using the genuine Creative Labs drivers, then
-.Nm
-may not work with that host adapter.
-.Sh SUPPORTED OPERATIONS
-The
-.Nm
-driver supports block and character access. Partition "a" returns
-2048-byte User Data blocks from data CDs. Partition "c" returns the full
-2352-byte Frames from any type of CD, including audio CDs. (Partition
-"c" cannot be "mounted" with cd9660 or other filesystem emulators.)
-No other partitions are supported.
-.Pp
-The
-.Nm matcdl
-devices work the same as the normal
-.Nm
-devices except that the drive trays are locked and
-remain locked until all of the devs on that drive are closed.
-.Pp
-.Nm Matcd
-accepts numerous
-.Fn ioctl
-commands, including disk and functions related to CD-ROM audio and tray
-control features. The commands are:
-.Pp
-.Bl -tag -width CDIOCREADSUBCHANNELXXX -compact -offset indent
-.It DIOCGDINFO
-get disklabel.
-.It DIOCGDPART
-get partition.
-.It DIOCWDINFO
-set update disk.
-.It DIOCSDINFO
-set disklabel.
-.It CDIOCREADSUBCHANNEL
-get sub-channel information on current status of disc playing.
-.It CDIOCREADTOCHEADER
-reads table of contents summary.
-.It CDIOCREADTOCENTRYS
-reads length and other track information.
-.It CDIOCPLAYTRACKS
-plays audio starting at a track/index and stopping at a track/index.
-.It CDIOCPLAYMSF
-plays audio starting at a particular time offset.
-.It CDIOCPAUSE
-pauses a playing disc.
-.It CDIOCRESUME
-resumes playing a previously paused disc. Ignored if the drive is
-already playing.
-.It CDIOCSTOP
-stops playing a disc.
-.It CDIOCEJECT
-opens the disc tray.
-.It CDIOCCLOSE
-closes the disc tray.
-.It CDIOCPREVENT
-blocks further attempts to open the drive door until all devices close
-or a CDIOCALLOW ioctl is issued.
-.It CDIOCALLOW
-unlocks the drive door if it was locked. This ioctl is rejected if
-any locking devices are open.
-.It CDIOCGETVOL
-returns the current volume settings of the drive.
-.It CDIOCSETVOL
-sets the volume settings of the drive.
-.It CDIOCSETSTEREO
-causes the left channel audio to be sent to the left channel output and the
-right channel audio is sent to the right channel output. This is the
-default state.
-.It CDIOCSETMUTE
-causes the audio output to be turned off. The drive continues to read
-the audio on the disc and that audio is discarded until the audio is
-turned back on.
-.It CDIOCSETLEFT
-causes the left channel audio to be sent to the left and right channel outputs.
-.It CDIOCSETRIGHT
-causes the right channel audio to be sent to the left and right channel
-outputs.
-.It CDIOCSETPATCH
-causes the audio to be routed as specified in the provided bit maps.
-.It CDIOCSETPITCH
-changes the playback speed of the audio to increase or decrease
-(as in Karaoke).
-.It CDIOCCAPABILITY
-report the capabilities of the drive and driver.
-.El
-.Pp
-The
-.Fn ioctl
-commands defined above are the only ones that the
-.Nm
-driver supports.
-.Sh FILES
-.Bl -tag -width /dev/(r)matcd0a_/dev/(r)matcd0la -compact
-.It Pa /dev/[r]matcd0a /dev/[r]matcd0la
-is used to access 2048-byte blocks of data on a CD-ROM disc
-that is recorded in the Mode 1 Form 1 format.
-.It Pa /dev/[r]matcd0c /dev/[r]matcd0lc
-is used to access 2352-byte frames on a CD-ROM disc
-recorded in any format.
-.It Pa /usr/src/sys/i386/isa/matcd/*
-Source code and compilation options for
-.Nm .
-.El
-.Pp
-The file \fIoptions.h\fR contains all of the compilation options.
-By default, the driver is configured to run on the current version of
-.Fx .
-.Sh NOTES
-The Creative/Panasonic interface does not use interrupts or DMA
-although the drives themselves are capable of using both.
-.Pp
-If the disc tray is opened while one or more partitions are open, further
-I/O to all partitions on the drive will be rejected until all partitions
-are closed.
-.Pp
-There must be a drive on each host interface that is addressed as
-physical drive 0. If this isn't the case, the driver will be unable
-to find the host interface or any of the connected drives.
-.Pp
-Drives on a second host interface start are considered logical
-drives 4-7, 8-11 on the third interface and 12-15 on the fourth.
-.Pp
-The first drive on the second host interface is logical drive 4 regardless
-of how many drives are present on the first host interface.
-.Pp
-Host interfaces are numbered in the order they are declared in the
-kernel configuration file, or in the order they are found if the kernel
-configuration file uses "?" for the port address. Host interface
-numbers are always contiguous.
-.Sh SEE ALSO
-.Pa /usr/include/sys/cdio.h
-.Sh AUTHORS
-The driver and documentation was written by
-.An Frank Durda IV .
-.Pp
-Program and Documentation are Copyright 1994, 1995,
-All rights reserved.
-.Sh HISTORY
-The
-.Nm
-driver appeared in
-.Fx 2.0.5 .
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index 0e8f44a..8d85a8a 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -264,7 +264,6 @@ i386/isa/isa_compat.c optional isa compat_oldisa \
i386/isa/isa_dma.c optional isa
i386/isa/istallion.c optional stli nowerror
i386/isa/loran.c optional loran
-i386/isa/matcd/matcd.c count matcd
i386/isa/mca_machdep.c optional mca
i386/isa/mcd.c count mcd
i386/isa/mse.c optional mse
diff --git a/sys/conf/files.pc98 b/sys/conf/files.pc98
index 22d382c..aa529dd 100644
--- a/sys/conf/files.pc98
+++ b/sys/conf/files.pc98
@@ -242,7 +242,6 @@ i386/isa/isa_compat.c optional isa compat_oldisa \
warning "Old ISA driver compatibility shims present."
i386/isa/istallion.c optional stli nowerror
i386/isa/loran.c optional loran
-i386/isa/matcd/matcd.c count matcd
i386/isa/mcd.c count mcd
i386/isa/npx.c optional npx
i386/isa/pcf.c optional pcf
diff --git a/sys/conf/majors b/sys/conf/majors
index 3977077..87611ca 100644
--- a/sys/conf/majors
+++ b/sys/conf/majors
@@ -63,7 +63,6 @@ chrdev name comments
43 vn vnode "disk" device (retired)
44 gp GPIB
45 scd Sony CDROM interface
-46 matcd Matsushita/Panasonic/Creative(SB) CDROM interface
47 gsc Genius Scanner
48 cy Cyclades
49 ?? was ssc
diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES
index e0d1acf..1285eb8 100644
--- a/sys/i386/conf/NOTES
+++ b/sys/i386/conf/NOTES
@@ -508,7 +508,6 @@ device aacp # SCSI Passthrough interface (optional, CAM required)
#
# mcd: Mitsumi CD-ROM using proprietary (non-ATAPI) interface
# scd: Sony CD-ROM using proprietary (non-ATAPI) interface
-# matcd: Matsushita/Panasonic CD-ROM using proprietary (non-ATAPI) interface
# wt: Wangtek and Archive QIC-02/QIC-36 tape drives
# ctx: Cortex-I frame grabber
# apm: Laptop Advanced Power Management (experimental)
@@ -587,10 +586,6 @@ hint.mcd.0.irq="10"
device scd 1
hint.scd.0.at="isa"
hint.scd.0.port="0x230"
-# for the SoundBlaster 16 multicd - up to 4 devices
-device matcd 1
-hint.matcd.0.at="isa"
-hint.matcd.0.port="0x230"
device wt 1
hint.wt.0.at="isa"
hint.wt.0.port="0x300"
diff --git a/sys/i386/isa/matcd/TODO b/sys/i386/isa/matcd/TODO
deleted file mode 100644
index 138f470..0000000
--- a/sys/i386/isa/matcd/TODO
+++ /dev/null
@@ -1,42 +0,0 @@
-Things to do for the matcd driver 4-Jul-95
-
-1. Someone wants to switch all drivers from disklabel and
- its assorted mechanisms over to disk slicing and its mechanisms,
- but I was unable to find any useful documentation on how to
- implement the changes for a read-only, single-partition,
- removable (ie, partition can change size) device.
- So this will have to wait until after 2.1.
-
-2. Support for reading R-W subcodes while playing audio. This would be
- useful if you have any CD+G or CD+MIDI discs, but the demand for this
- is pretty low, unless you like Karaoke. Someone will also have to
- write a CD+G viewer for X. The code for the driver to add this is
- pretty minor but there aren't any precedents on how to handle the
- data transfer to the application.
-
-3. Support for reading the ISBN and UPC labels. The ioctl structures
- for these appear to be defined but no other driver seems to do this.
-
-4. Multi-session support. There are two forms of this; what
- Philips defined and what Kodak uses. This will be quite
- complicated and will probably require changes in the filesystem
- layer. The drive support for Kodak multi-session is known to work.
-
-5. Multiple data tracks. My vision here was to add an ioctl
- that caused a track offset to be inserted into block requests,
- effectively shifting the base to the specified track. Very
- easy to add but not a big deal since I have only two discs
- in my collection that have multiple data tracks and I mastered
- one of them.
-
-6. A curses-based CD-Player app (ie, not X). I will probably do this
- mainly for its value as a debugging tool. It was pretty annoying
- not finding a single application that actually issued all the
- defined ioctls, let alone any new ones.
-
-If you feel the urge to work on one or more of these remaining items,
-please contact the author first at bsdmail@nemesis.lonestar.org
-to make sure the work hasn't already been done or started.
-
- Frank Durda IV
-
diff --git a/sys/i386/isa/matcd/audio.c b/sys/i386/isa/matcd/audio.c
deleted file mode 100644
index b395fb4..0000000
--- a/sys/i386/isa/matcd/audio.c
+++ /dev/null
@@ -1,514 +0,0 @@
-/*audio.c--------------------------------------------------------------------
-
- Matsushita(Panasonic) / Creative CD-ROM Driver (matcd)
- Authored by Frank Durda IV
-
- Copyright 1994, 1995 Frank Durda IV. All rights reserved.
- "FDIV" is a trademark of Frank Durda IV.
-
-
- Redistribution and use in source and binary forms, with or
- without modification, are permitted provided that the following
- conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice positioned at the very beginning of this file without
- modification, all copyright strings, all related programming
- codes that display the copyright strings, this list of
- conditions and the following disclaimer.
- 2. Redistributions in binary form must contain all copyright strings
- and related programming code that display the copyright strings.
- 3. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- 4. All advertising materials mentioning features or use of this
- software must display the following acknowledgement:
- "The Matsushita/Panasonic CD-ROM driver was developed
- by Frank Durda IV for use with "FreeBSD" and similar
- operating systems."
- "Similar operating systems" includes mainly non-profit oriented
- systems for research and education, including but not restricted
- to "NetBSD", "386BSD", and "Mach" (by CMU). The wording of the
- acknowledgement (in electronic form or printed text) may not be
- changed without permission from the author.
- 5. Absolutely no warranty of function, fitness or purpose is made
- by the author Frank Durda IV.
- 6. Neither the name of the author nor the name "FreeBSD" may
- be used to endorse or promote products derived from this software
- without specific prior written permission.
- (The author can be reached at bsdmail@nemesis.lonestar.org)
- 7. The product containing this software must meet all of these
- conditions even if it is unsupported, not a complete system
- and/or does not contain compiled code.
- 8. These conditions will be in force for the full life of the
- copyright.
- 9. If all the above conditions are met, modifications to other
- parts of this file may be freely made, although any person
- or persons making changes do not receive the right to add their
- name or names to the copyright strings and notices in this
- software. Persons making changes are encouraged to insert edit
- history in matcd.c and to put your name and details of the
- change there.
- 10. You must have prior written permission from the author to
- deviate from these terms.
-
- Vendors who produce product(s) containing this code are encouraged
- (but not required) to provide copies of the finished product(s) to
- the author and to correspond with the author about development
- activity relating to this code. Donations of development hardware
- and/or software are also welcome. (This is one of the faster ways
- to get a driver developed for a device.)
-
- THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER(S) BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
------No changes are allowed above this line------------------------------------
-
- The following functions are related to the audio playback
- capabilities of the drive. They can be omitted from the
- finished driver using the FULLDRIVER conditional.
-
- The full set of features the drive is capable of are currently
- not implemented but will be added in upcoming releases.
------------------------------------------------------------------------------*/
-/*-----------------------------------------------------------------------------
- matcd_playtracks - Plays one or more audio tracks
------------------------------------------------------------------------------*/
-
-static int matcd_playtracks(int ldrive, int cdrive, int controller,
- struct ioc_play_track *pt)
-{
- struct matcd_data *cd;
- int start,end;
- int i,port;
- unsigned char cmd[MAXCMDSIZ];
-
- cd=&matcd_data[ldrive];
- port=cd->iobase;
-
- if ((cd->flags & MATCDLABEL)==0)
- return(EIO); /*Refuse after chg error*/
-
- start=pt->start_track;
- end=pt->end_track;
-
- if (start < 1 || /*Starting track valid?*/
- end < 1 || /*Ending track valid?*/
- start > end || /*Start higher than end?*/
- end > cd->volinfo.trk_high) /*End track higher than disc size?*/
- return(ESPIPE); /*Track out of range*/
-
- lockbus(controller, ldrive); /*<16>Request bus*/
- i=matcd_setmode(ldrive, MODE_DA);/*Force drive into audio mode*/
- unlockbus(controller, ldrive); /*<16>Release bus*/
- if (i!=0) {
- return(i); /*Not legal for this media?*/
- }
- zero_cmd(cmd);
- cmd[0]=PLAYTRKS; /*Play Audio Track/Index*/
- cmd[1]=start;
- cmd[2]=pt->start_index;
- cmd[3]=end;
- cmd[4]=pt->end_index;
- i=docmd(cmd,ldrive,cdrive,controller,port); /*Issue command*/
-#ifdef DEBUGIOCTL
- printf("matcd%d: Play track results %d \n",ldrive,i);
-#endif /*DEBUGIOCTL*/
- if (i==0) cd->status=CD_AS_PLAY_IN_PROGRESS; /*<14>*/
- return(i);
-}
-
-
-/*-----------------------------------------------------------------------------
- matcd_playmsf - Plays between a range of blocks
------------------------------------------------------------------------------*/
-
-static int matcd_playmsf(int ldrive, int cdrive, int controller,
- struct ioc_play_msf *pt)
-{
- struct matcd_data *cd;
- int i,port;
- unsigned char cmd[MAXCMDSIZ];
-
- cd=&matcd_data[ldrive];
- port=cd->iobase;
-
-#ifdef DEBUGIOCTL
- printf("matcd%d: playmsf %2x %2x %2x -> %2x %2x %2x\n",
- ldrive,pt->start_m, pt->start_s, pt->start_f, pt->end_m,
- pt->end_s,pt->end_f);
-#endif /*DEBUGIOCTL*/
-
- if ((cd->flags & MATCDLABEL)==0)
- return(EIO); /*Refuse after chg error*/
-
- if ((cd->volinfo.vol_msf[0]==0 &&
- cd->volinfo.vol_msf[1]<2) || /*Must be after 0'1"75F*/
- msf_to_blk((char *)&pt->start_m) >
- msf_to_blk((char *)&cd->volinfo.vol_msf)) {
-#ifdef DEBUGIOCTL
- printf("matcd%d: Invalid block combination\n",ldrive);
-#endif /*DEBUGIOCTL*/
- return(ESPIPE); /*Track out of range*/
- }
-
-
- lockbus(controller, ldrive); /*<16>Request bus*/
- i=matcd_setmode(ldrive, MODE_DA);/*Force drive into audio mode*/
- unlockbus(controller, ldrive); /*<16>Release bus*/
- if (i!=0) {
- return(i); /*Not legal for this media?*/
- }
- zero_cmd(cmd);
- cmd[0]=PLAYBLOCKS; /*Play Audio Blocks*/
- cmd[1]=pt->start_m;
- cmd[2]=pt->start_s;
- cmd[3]=pt->start_f;
- cmd[4]=pt->end_m;
- cmd[5]=pt->end_s;
- cmd[6]=pt->end_f;
- i=docmd(cmd,ldrive,cdrive,controller,port); /*Issue command*/
- if (i==0) cd->status=CD_AS_PLAY_IN_PROGRESS; /*<14>*/
- return(i);
-}
-
-
-/*-----------------------------------------------------------------------------
- matcd_pause - Pause or Resume audio playback
------------------------------------------------------------------------------*/
-
-static int matcd_pause(int ldrive, int cdrive, int controller, int action)
-{
- struct matcd_data *cd;
- int i,z,port;
- unsigned char cmd[MAXCMDSIZ];
-
- cd=&matcd_data[ldrive];
- port=cd->iobase;
-
- if ((cd->flags & MATCDLABEL)==0)
- return(EIO); /*Refuse after chg error*/
-
- zero_cmd(cmd);
- cmd[0]=NOP; /*<14>Just find out whats going on*/
-
- lockbus(controller, ldrive); /*<16>Request bus*/
- matcd_slowcmd(port,ldrive,cdrive,cmd); /*<14>*/
- i=waitforit(10*TICKRES,DTEN,port,"matpau"); /*<25>*/
- z=get_stat(port,ldrive); /*<14>Read status byte*/
- if ((z & MATCD_ST_ERROR)) { /*<14>Something went wrong*/
- i=get_error(port, ldrive, cdrive); /*<14>*/
- unlockbus(controller, ldrive); /*<16>Release bus*/
- return(EIO); /*<14>*/
- } /*<14>*/
- unlockbus(controller, ldrive); /*<16>Release bus*/
-
- if ((z & MATCD_ST_AUDIOBSY) == 0 && /*<14>If drive is idle*/
- cd->status==CD_AS_PLAY_IN_PROGRESS) { /*<14>but was playing*/
- cd->status=CD_AS_PLAY_COMPLETED; /*<14>then its done*/
- return(0);
- }
-
- if (action) { /*<14>Set state for subq ioctl*/
-#ifndef KRYTEN
- if (cd->status==CD_AS_PLAY_IN_PROGRESS) {/*<14>Don't resume*/
- return(0); /*<14>if already playing*/
- } /*<14>Max Headroom sound occurs*/
-#endif /*KRYTEN*/
- cd->status=CD_AS_PLAY_IN_PROGRESS; /*<14>to read*/
- } else { /*<14>There is no way to ask the*/
- cd->status=CD_AS_PLAY_PAUSED;/*<14>drive if it is paused*/
- } /*<14>*/
-
- cmd[0]=PAUSE; /*Pause or Resume playing audio*/
- cmd[1]=action;
- i=docmd(cmd,ldrive,cdrive,controller,port); /*Issue command*/
-#ifdef DEBUGIOCTL
- printf("matcd%d: Pause / Resume results %d \n",ldrive,i);
-#endif /*DEBUGIOCTL*/
- return(i);
-}
-
-
-
-/*-----------------------------------------------------------------------------
- matcd_stop - Stop audio playback
------------------------------------------------------------------------------*/
-
-static int matcd_stop(int ldrive, int cdrive, int controller)
-{
- struct matcd_data *cd;
- int i,port;
- unsigned char cmd[MAXCMDSIZ];
-
- cd=&matcd_data[ldrive];
- port=cd->iobase;
-
- if ((cd->flags & MATCDLABEL)==0)
- return(EIO); /*Refuse after chg error*/
-
- zero_cmd(cmd);
- cmd[0]=ABORT; /*Abort playing audio*/
- i=docmd(cmd,ldrive,cdrive,controller,port); /*Issue command*/
-#ifdef DEBUGIOCTL
- printf("matcd%d: Abort results %d \n",ldrive,i);
-#endif /*DEBUGIOCTL*/
- cd->status=CD_AS_PLAY_COMPLETED;/*<14>the drive if it is paused*/
- return(i);
-}
-
-
-/*-----------------------------------------------------------------------------
- matcd_level - Read or set the audio levels
-<12> New for Edit 12
------------------------------------------------------------------------------*/
-
-static int matcd_level(int ldrive, int cdrive, int controller,
- struct ioc_vol * level, unsigned long action)
-{
- struct matcd_data *cd;
- int i,z,port;
- unsigned char c;
- unsigned char cmd[MAXCMDSIZ];
- unsigned char data[5];
-
- cd=&matcd_data[ldrive];
- port=cd->iobase;
-
- zero_cmd(cmd);
- if (action==CDIOCSETVOL) { /*We are setting new volume settings*/
-
-/* Here we set the volume levels. Note that the same command
- also sets the patching (routing) of audio, so we have to rely
- on previously-stored settings to fill in these fields.
-*/
- cmd[0]=MODESELECT; /*Write drive settings*/
- cmd[1]=AUDIOPARM; /*Audio/routing settings*/
-
-/* Although the drive allows a left and right channel volume to be
- specified separately, the drive refuses the settings if the
- values are different.
-*/
- c=level->vol[0] | level->vol[1]; /*Or them together*/
-
- cmd[4]=cd->volume[0]=c; /*Channel 0 (Left) volume*/
- cmd[6]=cd->volume[1]=c; /*Channel 1 (Right) volume*/
- cmd[3]=cd->patch[0]; /*Channel 0 (Left) patching*/
- cmd[5]=cd->patch[1]; /*Channel 1 (Right) patching*/
- i=docmd(cmd,ldrive,cdrive,controller,port);/*Issue cmd*/
-#ifdef DEBUGIOCTL
- printf("matcd%d: Volume set %d\n",ldrive,i);
-#endif /*DEBUGIOCTL*/
- return(i);
- } else { /*Read existing settings*/
-
-
-/* This code reads the settings for the drive back - note that
- volume and patching are both returned so we have to keep
- both internally.
-*/
- cmd[0]=MODESENSE; /*Read drive settings*/
- cmd[1]=AUDIOPARM; /*Audio/routing settings*/
- lockbus(controller, ldrive); /*<16>Request bus*/
- matcd_slowcmd(port,ldrive,cdrive,cmd);
- i=waitforit(10*TICKRES,DTEN,port,"matlvl"); /*<25>*/
- matcd_pread(port, 5, data); /*Read data returned*/
- z=get_stat(port,ldrive);/*Read status byte*/
- unlockbus(controller, ldrive); /*<16>Release bus*/
-#ifdef DEBUGIOCTL
- printf("matcd%d: Data got was %x %x %x %x %x ",ldrive,
- data[0],data[1],data[2], data[3],data[4]);
- printf("status byte %x\n",z);
-#endif /*DEBUGIOCTL*/
- cd->volume[0]=level->vol[0]= /*Channel 0 (Left) volume*/
- data[2];
- cd->volume[1]=level->vol[1]= /*Channel 1 (Right) volume*/
- data[4];
- level->vol[2]=level->vol[3]=0; /*Channel 2 & 3 not avail*/
-
- cd->patch[0]=data[1]; /*Channel 0 (Left) patching*/
- cd->patch[1]=data[3]; /*Channel 1 (Right) patching*/
-
- return(0);
- }
-
-}
-
-
-/*-----------------------------------------------------------------------------
- matcd_routing - Set the audio routing (patching)
-<12> New for Edit 12
------------------------------------------------------------------------------*/
-
-static int matcd_route(int ldrive, int cdrive, int controller,
- unsigned long command)
-{
- struct matcd_data *cd;
- int i,port;
- unsigned char l,r;
- unsigned char cmd[MAXCMDSIZ];
-
- cd=&matcd_data[ldrive];
- port=cd->iobase;
-
- zero_cmd(cmd);
- switch (command) {
- case CDIOCSETMUTE:
- l=r=0;
- break;
-
- case CDIOCSETLEFT:
- l=r=OUTLEFT;
- break;
-
- case CDIOCSETRIGHT:
- l=r=OUTRIGHT;
- break;
-
- default:
- case CDIOCSETSTEREO:
- l=OUTLEFT;
- r=OUTRIGHT;
- break;
- }
-
-/* Here we set the volume levels. Note that the same command
- also sets the patching (routing) of audio, so we have to rely
- on previously-stored settings to fill in these fields.
-*/
- cmd[0]=MODESELECT; /*Write drive settings*/
- cmd[1]=AUDIOPARM; /*Audio/routing settings*/
-
-
-/* Although the drive allows a left and right channel volume to be
- specified separately, the drive refuses the settings if the
- values are different.
-*/
- cmd[4]=cd->volume[0]; /*Channel 0 (Left) volume*/
- cmd[6]=cd->volume[1]; /*Channel 1 (Right) volume*/
- cmd[3]=cd->patch[0]=l; /*Channel 0 (Left) patching*/
- cmd[5]=cd->patch[1]=r; /*Channel 1 (Right) patching*/
- i=docmd(cmd,ldrive,cdrive,controller,port);/*Issue cmd*/
-#ifdef DEBUGIOCTL
- printf("matcd%d: Routing set %d\n",ldrive,i);
-#endif /*DEBUGIOCTL*/
- return(i);
-
-}
-
-
-/*-----------------------------------------------------------------------------
- matcd_patch - Set the audio routing (patching)
-<12> New for Edit 12
------------------------------------------------------------------------------*/
-
-static int matcd_patch(int ldrive, int cdrive, int controller,
- struct ioc_patch * routing)
-{
- struct matcd_data *cd;
- int i,port;
- unsigned char cmd[MAXCMDSIZ];
-
- cd=&matcd_data[ldrive];
- port=cd->iobase;
-
- zero_cmd(cmd);
-
-/* Here we set the volume levels. Note that the same command
- also sets the patching (routing) of audio, so we have to rely
- on previously-stored settings to fill in these fields.
-*/
- cmd[0]=MODESELECT; /*Write drive settings*/
- cmd[1]=AUDIOPARM; /*Audio/routing settings*/
-
-
-/* Although the drive allows a left and right channel volume to be
- specified separately, the drive refuses the settings if the
- values are different.
-*/
- cmd[4]=cd->volume[0]; /*Channel 0 (Left) volume*/
- cmd[6]=cd->volume[1]; /*Channel 1 (Right) volume*/
- cmd[3]=cd->patch[0]= /*Channel 0 (Left) patching*/
- (routing->patch[0] & 0x03);
- cmd[5]=cd->patch[1]= /*Channel 1 (Right) patching*/
- (routing->patch[1] & 0x03);
- i=docmd(cmd,ldrive,cdrive,controller,port);/*Issue cmd*/
-#ifdef DEBUGIOCTL
- printf("matcd%d: Routing set %d\n",ldrive,i);
-#endif /*DEBUGIOCTL*/
- return(i);
-
-}
-
-/*-----------------------------------------------------------------------------
- matcd_pitch - Change audio playback rate
- Apart from making things sound funny, the only
- other application might be Karaoke. Ugh.
-<12> New for Edit 12
------------------------------------------------------------------------------*/
-
-static int matcd_pitch(int ldrive, int cdrive, int controller,
- struct ioc_pitch * speed)
-{
- struct matcd_data *cd;
- short i;
- int z,port;
- unsigned char cmd[MAXCMDSIZ];
-
- cd=&matcd_data[ldrive];
- port=cd->iobase;
-
- zero_cmd(cmd);
-
-/* This function sets the audio playback rate. In SCSI devices this is
- referred to as the logical block addresses per second parameter.
- Uh huh. Sounds like they didn't want anyone to find it.
- Anyway, a study found that no one else has implemented this ioctl
- but the capability does exist in the SCSI standard so I am following
- the SCSI scheme even though it really doesn't fit this drive well.
-
- I define the parameter to this ioctl as -32767 to -1 being
- "play slower", 0x0000 flat and 1 to 32767 being "play faster"
- within the scale allowed by the device. The value is scaled to fit
- the allowed by the device and any excess is treated as being
- the positive or negative limit. No ioctl input value is considered
- invalid.
-
- This device has a +/- 13% playback pitch specified by a range
- -130 to +130. The drive does a hard enforcement on this.
-
- SCSI defines a 16 bit LBAS count, and a "multiplier" that
- is either x1 or x(1/256). The Matsushita drive only provides
- 10 bits total for indicating pitch so the LSbits are discarded.
-*/
-
- cmd[0]=MODESELECT; /*Write drive settings*/
- cmd[1]=SPEEDPARM; /*Audio speed settings*/
-
- i=speed->speed>>7; /*Scale down to our usable range*/
-
- if (i!=0) { /*Real pitch value*/
- if (i < -130) i=-130; /*Force into range we support*/
- else if (i > 130) i=130;
- cmd[3]=((i>>8)&0x03) | 0x04; /*Get upper bits*/
- cmd[4]=(i & 0xff); /*Set lower bits*/
- }
- z=docmd(cmd,ldrive,cdrive,controller,port);/*Issue cmd*/
-#ifdef DEBUGIOCTL
- printf("matcd%d: Pitch set %d\n",ldrive,i);
-#endif /*DEBUGIOCTL*/
- return(z);
-}
-
-/*End of audio.c*/
-
diff --git a/sys/i386/isa/matcd/creative.h b/sys/i386/isa/matcd/creative.h
deleted file mode 100644
index 72a12ad..0000000
--- a/sys/i386/isa/matcd/creative.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*creative.h-------------------------------------------------------------------
-
- Matsushita(Panasonic) / Creative CD-ROM Driver (matcd)
- Authored by Frank Durda IV
-
- Copyright 1994, 1995 Frank Durda IV. All rights reserved.
- "FDIV" is a trademark of Frank Durda IV.
-
-
- Redistribution and use in source and binary forms, with or
- without modification, are permitted provided that the following
- conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice positioned at the very beginning of this file without
- modification, all copyright strings, all related programming
- codes that display the copyright strings, this list of
- conditions and the following disclaimer.
- 2. Redistributions in binary form must contain all copyright strings
- and related programming code that display the copyright strings.
- 3. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- 4. All advertising materials mentioning features or use of this
- software must display the following acknowledgement:
- "The Matsushita/Panasonic CD-ROM driver was developed
- by Frank Durda IV for use with "FreeBSD" and similar
- operating systems."
- "Similar operating systems" includes mainly non-profit oriented
- systems for research and education, including but not restricted
- to "NetBSD", "386BSD", and "Mach" (by CMU). The wording of the
- acknowledgement (in electronic form or printed text) may not be
- changed without permission from the author.
- 5. Absolutely no warranty of function, fitness or purpose is made
- by the author Frank Durda IV.
- 6. Neither the name of the author nor the name "FreeBSD" may
- be used to endorse or promote products derived from this software
- without specific prior written permission.
- (The author can be reached at bsdmail@nemesis.lonestar.org)
- 7. The product containing this software must meet all of these
- conditions even if it is unsupported, not a complete system
- and/or does not contain compiled code.
- 8. These conditions will be in force for the full life of the
- copyright.
- 9. If all the above conditions are met, modifications to other
- parts of this file may be freely made, although any person
- or persons making changes do not receive the right to add their
- name or names to the copyright strings and notices in this
- software. Persons making changes are encouraged to insert edit
- history in matcd.c and to put your name and details of the
- change there.
- 10. You must have prior written permission from the author to
- deviate from these terms.
-
- Vendors who produce product(s) containing this code are encouraged
- (but not required) to provide copies of the finished product(s) to
- the author and to correspond with the author about development
- activity relating to this code. Donations of development hardware
- and/or software are also welcome. (This is one of the faster ways
- to get a driver developed for a device.)
-
- THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER(S) BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
------No changes are allowed above this line------------------------------------
-
-See matcd.c for Edit History
-
- These are the I/O port mapping offsets and bit assignments used
- by Creative Labs in their implementation of the host interface for
- the Matsushita CD-ROM drive. These may be different in the adapter
- cards (including sound cards) made by other vendors.
- It is unknown if the Creative interface is based on a reference design
- provided by Matsushita (other interface vendors would similar or
- identical if this was the case).
-
- The drive is actually capable of some things that the Creative
- interface doesn't implement, such as DMA and interrupts.
-
- See matcd.h for defines related to the Matsushita drive itself.
-*/
-
-
-/* Creative Labs (and compatible) I/O port mapping offsets
-*/
-
-#define NUMPORTS 4 /*Four ports are decoded by the i/f*/
-
-#define CMD 0 /*Write - commands*/
-#define DATA 0 /*Read - data/status from drive*/
-#ifdef PC98
-#define PHASE 0x100 /*Write - switch between data/status*/
-#define STATUS 0x100 /*Read - bus status */
-#define RESET 0x200 /*Write - reset all attached drives*/
-#define ALTDATA 0x200 /*<20>Read - data on non Creative bds.*/
-#define SELECT 0x300 /*Write - drive select*/
-#else /* !PC98 */
-#define PHASE 1 /*Write - switch between data/status*/
-#define STATUS 1 /*Read - bus status*/
-#define RESET 2 /*Write - reset all attached drives*/
- /*Any value written will reset*/
-#define ALTDATA 2 /*<20>Read - data on non Creative bds.*/
-#define SELECT 3 /*Write - drive select*/
-#endif /*PC98*/
-
-/* Creative PHASE port bit assignments
-*/
-
-#define PHASENA 1 /*Access data bytes instead of status*/
-
-
-/* Creative STATUS port register bits
-*/
-
-#define DTEN 2 /*When low, in data xfer phase*/
-#define STEN 4 /*When low, in status phase*/
-#define TEST 1 /*Function is unknown*/
-
-
-/* Creative drive SELECT port bit assignments
- Note that in the Creative interface, DS0==Bit 1 and
- DS1==Bit 0 (DS is Drive Select).
-*/
-
-#define CRDRIVE0 0x00
-#define CRDRIVE1 0x02
-#define CRDRIVE2 0x01
-#define CRDRIVE3 0x03
-
-/*End of creative.h*/
-
-
diff --git a/sys/i386/isa/matcd/matcd.c b/sys/i386/isa/matcd/matcd.c
deleted file mode 100644
index c220aca..0000000
--- a/sys/i386/isa/matcd/matcd.c
+++ /dev/null
@@ -1,2706 +0,0 @@
-#include "opt_geom.h"
-#ifndef GEOM
-/*matcd.c--------------------------------------------------------------------
-
- Matsushita(Panasonic) / Creative CD-ROM Driver (matcd)
- Authored by Frank Durda IV
-
- Copyright 1994, 1995 Frank Durda IV. All rights reserved.
- "FDIV" is a trademark of Frank Durda IV.
-
-
- Redistribution and use in source and binary forms, with or
- without modification, are permitted provided that the following
- conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice positioned at the very beginning of this file without
- modification, all copyright strings, all related programming
- codes that display the copyright strings, this list of
- conditions and the following disclaimer.
- 2. Redistributions in binary form must contain all copyright strings
- and related programming code that display the copyright strings.
- 3. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- 4. All advertising materials mentioning features or use of this
- software must display the following acknowledgement:
- "The Matsushita/Panasonic CD-ROM driver was developed
- by Frank Durda IV for use with "FreeBSD" and similar
- operating systems."
- "Similar operating systems" includes mainly non-profit oriented
- systems for research and education, including but not restricted
- to "NetBSD", "386BSD", and "Mach" (by CMU). The wording of the
- acknowledgement (in electronic form or printed text) may not be
- changed without permission from the author.
- 5. Absolutely no warranty of function, fitness or purpose is made
- by the author Frank Durda IV.
- 6. Neither the name of the author nor the name "FreeBSD" may
- be used to endorse or promote products derived from this software
- without specific prior written permission.
- (The author can be reached at bsdmail@nemesis.lonestar.org)
- 7. The product containing this software must meet all of these
- conditions even if it is unsupported, not a complete system
- and/or does not contain compiled code.
- 8. These conditions will be in force for the full life of the
- copyright.
- 9. If all the above conditions are met, modifications to other
- parts of this file may be freely made, although any person
- or persons making changes do not receive the right to add their
- name or names to the copyright strings and notices in this
- software. Persons making changes are encouraged to insert edit
- history in matcd.c and to put your name and details of the
- change there.
- 10. You must have prior written permission from the author to
- deviate from these terms.
-
- Vendors who produce product(s) containing this code are encouraged
- (but not required) to provide copies of the finished product(s) to
- the author and to correspond with the author about development
- activity relating to this code. Donations of development hardware
- and/or software are also welcome. (This is one of the faster ways
- to get a driver developed for a device.)
-
- THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER(S) BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
------------------------------------------------------------------------------
-Dedicated to: My family, my Grandfather,
- and Max, my Golden Retriever
-
-Thanks to: Jordan Hubbard (jkh) for getting me ramped-up to 2.x system
- quickly enough to make the 2.1 release. He put up with
- plenty of silly questions and might get the post of
- ambassador some day.
-
-and The people who donated equipment and other material to make
- development of this driver possible. Donations and
- sponsors for projects are appreciated.
-
-
------No changes are allowed above this line------------------------------------
-
-Edit History - (should be in sync with any source control log entries)
-
- Never seen one of these before? Ok, here is how it works.
- Every time you change the code, you increment the edit number,
- that number over there in the <%d> and in the (%d) in the
- version string. You never set this number lower than it is.
- Near, or preferably on lines that change, insert the edit
- number. If there is a number there already, you can replace it
- with a newer one. This makes searches for code changes very fast.
-
- In the edit history, start with the edit number, and a good
- description of what changes were made. Then follow it with
- the date, your name and an EMAIL address where you can be reached.
-
- Please follow this practice; it helps leave understandable code in
- your wake.
-
- FYI, you have major and minor release codes. Major releases numbered
- 1 thru n. Major feature additions should get a new major release
- number. Minor releases start with a null and then letters
- A thru Z. So 3A(456) is Major release 3, Minor release 1,
- Edit 456 (in Microsoft-ese that would be 03.01.456), and 5(731)
- is Major release 5, Minor release 0, Edit 731. Typically only the
- author will change the major and minor release codes in small
- projects.
-
- EDIT edit Edit HISTORY history History
-
-<1> This initial version is to get basic filesystem I/O working
- using the SoundBlaster 16 interface. The stand-alone adapter
- card doesn't work yet.
- December 1994 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<2> Corrections to resolve a race condition when multiple drives
- on the same controller was active. Fixed drive 1 & 2 swap
- problem. See selectdrive().
- 21-Jan-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<3> Added automatic probing and support for all Creative Labs sound
- cards with the Creative/Panasonic interface and the stand-alone
- interface adapters. See AUTOHUNT and FULLCONFIG conditionals
- for more information.
- 21-Jan-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<4> Rebundled debug conditionals.
- 14-Feb-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<5> Changes needed to work on FreeBSD 2.1. Also added draincmd
- since some conditions cause the drive to produce surprise data.
- See setmode and draincmd
- 19-Feb-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<6> Got rid of some redundant error code by creating chk_error().
- Also built a nice generic bus-lock function.
- 20-Feb-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<7> Improved comments, general structuring.
- Fixed a problem with disc eject not working if LOCKDRIVE was set.
- Apparently the drive will reject an EJECT command if the drive
- is LOCKED.
- 21-Feb-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-Edit number code marking begins here - earlier edits were during development.
-
-<8> Final device name selected and actually made to compile under
- >2.0. For newer systems, it is "matcd", for older it is "mat".
- 24-Feb-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<9> Added some additional disk-related ioctl functions that didn't
- make it into earlier versions.
- 26-Feb-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<10> Updated some conditionals so the code will compile under
- 1.1.5.1, although this is not the supported platform.
- Also found that some other devices probe code was changing the
- settings for the port 0x302 debug board, so added code to set it
- to a sane state before we use it.
- 26-Feb-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<11> The Copyright and Use statement has been replaced in all files
- with a new version.
- 1-Mar-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<12> Added ioctls having to do with audio volume, routing and playback
- speed. Also added some code I think is for dynamic loading.
- 12-Mar-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<13> Added ioctls to return TOC headers and entries.
- 19-Mar-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<14> More ioctls to finish out general audio support and some clean-up.
- Also fixed a bug in open where CD label information would not
- always be cleared after a disc change.
-
- Added a check to block attempts to resume audio if already playing.
- The resulting sound is a cross between Kryten and Max Headroom.
- But, if you *want* this "feature", enable #define KRYTEN
- in options.h.
-
- So it is not BSD-ish enough, eh? What, too many comments? :-)
- 21-Mar-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<15> LOCKDRIVE has been modified so that a new series of minor
- numbers are created. When these are opened, the selected
- drive will have its door locked and the device must be completely
- closed to unlock the media. The EJECT ioctl will be refused
- when the drive is locked this way. This is useful for
- servers and other places where the media needs to remain in the
- drive. Bit 7 of the minor number controls locking.
-
- As of this edit, the code compiles with no warnings with -Wall set.
- 22-Mar-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<16> Added a new check in the probe code that looks for the drive
- interface being in an idle state after issuing a reset. If this
- isn't the case, then the device at this location isn't a
- Matsushita CD-ROM drive. This will prevent hangs in draincmd later.
- Added the tray close ioctl. This required modifications to open
- to allow the character devices to be "partially" opened so that
- the close ioctl could be issued when the open would otherwise fail.
- Close also delays slightly after completing because the drive
- doesn't update its disc and media status instantly.
- Also created the capability ioctl that lets an application find out
- up front what things a drive can do.
- Fixed a global spelling error.
- Changed matcddriver structure to simply say "matcd". The original
- string "matcd interface " broke the kernel -c boot mechanism.
- Updated the #includes in response to a complaint in first release.
- Updated and tested conditionals so that driver will still compile
- under FreeBSD 1.1.5.1 as well as 2.0 and early 2.1.
- 4-Apr-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<17> The function matcd_toc_entries which is executed in response to
- the CDIOREADTOCENTRYS ioctl didn't cope with programs that only
- requested part of the TOC. This change is based on code submitted
- by Doug Robson (dfr@render.com).
- (This change was introduced out of order and exists in FreeBSD
- 2.0.5 without the version stamp being updated. I.N.M.F.)
- 1-Jun-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<18> While working on the TEAC CD-ROM driver (teaccd) that is reusing
- chunks of code from this driver, I discovered several functions,
- arrays and other things that should have been declared 'static'.
- These changes are necessary if the TEAC CD-ROM driver is to be
- present at the same time as matcd.
- Also fixed the residual buss vs bus symbols and strings.
- There are no functional code changes in this edit.
- 2-May-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<19> Creative has changed the Status port slightly in their
- sound boards based on the Vibra-16 (and probably the Vibra-16S)
- chipset. This change masks some unused bits that were formally
- on all the time and are doing different things in this design.
- The changes are transparent to all other supported boards.
- 20-Jun-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<20> Code was added to detect non-Creative (SoundBlaster) host
- interfaces, and the driver will switch to code compatible with the
- detected host interface. This should add support for MediaVision,
- IBM, Reveal, and other compatible adapters with split
- data/status-ports. This code allows a mix of SoundBlaster (Type 0)
- and non-SoundBlaster (Type 1) boards in the same system with no
- special configuration.
-
- I also updated the attach code to display the interface type and
- changed the host interface probe messages to reflect the "c" for
- controller in controller-specific messages as the existing messages
- were confusing when a second card was in place . The kernel -c
- tables have been updated accordingly, so you now have a matcdc%d
- controller to change settings on.
- 24-Jun-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<21> Added interface handling code in two of those "this should not
- happen" routines, draincmd and get_stat. Since these routines are
- called by functions during probing that may not know what type
- interface is out there, the code assumes that a given adapter is
- both a type 0 and a type 1 adapter at the same time. Plus,
- this code gets executed once in a very long time so the cost of
- assuming both host adapter types is not significant.
- 4-Jul-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<22> Four external interface prototypes were altered by someone else.
- I believe these changes are for making GCC and/or the linker shut-up
- when building some other part of the system since matcd already
- compiles -Wall with no warnings...
- 8-Sep-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<23> This change implements the ioctls for preventing media removal
- and allowing media removal.
- Currently, these calls will work according to the following rules:
- No "l" devs opened Any "l" dev open
- CDALLOW accepted always rejected always
- CDPREVENT accepted always accepted always
-
- One refinement might be to allow CDALLOW/CDPREVENT to always
- work if UID 0 issued the ioctl, but that will wait for later.
-
- I also made a change to the information that the toc_entry code
- returns so that xcdplayer won't malfunction. (It would not play
- the last track on a non-mixed mode audio CD.) Unlike cdplayer,
- xcdplayer asks for track information one track at a time, and
- calls for information on the lead-out track by its official
- number (0xaa), rather than referring to the "after last" (n+1) track
- as cdplayer does. Anyway, this change should make both players
- happy.
- 16-Sep-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<24> In Edit 15 when the extra devs were created for selective locking,
- the door locking was broken if a non-locking dev on the drive is
- closed. The problem was caused by not tracking locked devs and
- non-locking devs as being different partitions. The change is to
- simply use the locking dev bit to flag a set of shadow partitions
- when it comes to lock operations. All other operations treat the
- locked and unlocked partitions as being identical.
- 18-Sep-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<25> During work on Edit 23, I noted that on slow and very busy systems,
- sometimes the driver would go to sleep forever. The problem appears
- to have been a race condition caused by doing separate timeout/sleep
- calls without using SPL first. The change here is to use tsleep
- which provides the equivalent of timeout/sleep timeout/tsleep if the
- last paremeter is tsleep is set to the time value that would have been
- given to timeout.
- I also fixed some duplicate location strings in the tsleep calls.
- 24-Sep-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<26> Moved a function declaration that generated two warnings with
- the FULLCONFIG/FULLDRIVER conditionals disabled.
- Updated the igot function so that it correctly reports limited
- functions when a sub-set driver is compiled.
- Eliminated FULLCONFIG conditional and now set controller counts
- based on the NMATCD #define produced by the config process.
- Also, disable the audio-related ioctls based on the BOOTMFS
- conditional to help make the boot floppy kernel smaller.
- 18-Oct-95 Frank Durda IV bsdmail@nemesis.lonestar.org
-
-<27> Incorporated changes needed to move the cdevsw and bdevsw
- entries into the drivers (including this one). Also
- include a quick first pass cut at DEVFS suppport. (removed later)
-
----------------------------------------------------------------------------*/
-
-/*Match this format: Version_dc(d)__dd-mmm-yy */
-static char MATCDVERSION[]="Version 1(26) 18-Oct-95";
-
-/* The following strings may not be changed*/
-static char MATCDCOPYRIGHT[] = "Matsushita CD-ROM driver, Copr. 1994,1995 Frank Durda IV";
-/* The proceeding strings may not be changed*/
-
-/* $FreeBSD$ */
-
-/*---------------------------------------------------------------------------
- Include declarations
----------------------------------------------------------------------------*/
-
-#include "matcd.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-
-#include <sys/bio.h>
-#include <sys/cdio.h>
-#include <sys/disklabel.h>
-#include <sys/fcntl.h>
-
-#include "i386/isa/matcd/options.h" /*Conditional compile options
- and probe port hints*/
-#include "i386/isa/matcd/matcddrv.h" /*Drive-related defs & strings*/
-#include "i386/isa/matcd/creative.h" /*Host interface related defs*/
-
-#include <sys/conf.h>
-#include <sys/kernel.h>
-#include <sys/bus.h>
-
-#include <i386/isa/isa_device.h>
-
-#ifndef COMPAT_OLDISA
-#error "The matcd device requires the old isa compatibility shims"
-#endif
-
-/*---------------------------------------------------------------------------
- Defines and structures
----------------------------------------------------------------------------*/
-
-#define DRIVESPERC 4 /*This is a constant*/
-#define TOTALDRIVES NUMCTRLRS*DRIVESPERC /*Max possible drives*/
-
-#define TICKRES 10 /*Our coarse timer resolution*/
-#define ISABUSKHZ 8330 /*Number of IN/OUT ISA/sec*/
-#define MAXTRKS 101 /*Maximum possible tracks*/
-
-#define RAW_DEVICE 46 /*<16>Dev number for raw device*/
-
-
-#define MATCDBLK 2048 /*Standard block size*/
-#define MATCDRBLK 2352 /*Raw and/or DA block size*/
-#define MATCD_RETRYS 5 /*Number of retries for read ops*/
-#define MATCD_READ_1 0x80 /*Read state machine defines*/
-#define MATCD_READ_2 0x90 /*Read state machine defines*/
-
-struct matcd_volinfo {
- unsigned char type; /*00 CD-DA or CD-ROM
- 10 CD-I
- 20 XA */
- unsigned char trk_low; /*Normally 1*/
- unsigned char trk_high; /*Highest track number*/
- unsigned char vol_msf[3]; /*Size of disc in min/sec/frame*/
-};
-
-
-struct matcd_mbx {
- short controller;
- short ldrive;
- short partition;
- short port;
- short iftype; /*<20>Host interface type*/
- short retry;
- short nblk;
- int sz;
- u_long skip;
- struct bio *bp;
- int p_offset;
- short count;
-};
-
-static struct matcd_data {
- short drivemode; /*Last state drive was set to*/
- short flags;
- short status; /*Last audio-related function*/
- int blksize;
- u_long disksize;
- short iobase;
- short iftype; /*<20>Host interface type*/
- struct disklabel dlabel;
- unsigned int partflags[MAXPARTITIONS];
- unsigned int openflags;
- struct matcd_volinfo volinfo;
- struct matcd_mbx mbx;
- u_char patch[2]; /*<12>Last known audio routing*/
- u_char volume[2]; /*<12>Last known volume setting*/
-} matcd_data[TOTALDRIVES];
-
-
-/* Bit equates for matcd_data.flags*/
-
-#define MATCDINIT 0x0001 /*Probe ran on host adapter*/
-#define MATCDLABEL 0x0004 /*Valid TOC exists*/
-#define MATCDLOCK 0x0008 /*<15>Drive door is locked*/
-#define MATCDWARN 0x0020 /*Have reported an open disc change*/
-
-
-/* Bit equates for matcd_data.partflags*/
-
-#define MATCDOPEN 0x0001
-#define MATCDREADRAW 0x0002
-
-
-/* Error classes returned by chk_error()*/
-
-#define ERR_RETRY 1 /*A retry might recover this*/
-#define ERR_INIT 2 /*A retry certainly will get this*/
-#define ERR_FATAL 3 /*This cannot be recovered from*/
-
-
-static struct bio_queue_head request_head[NUMCTRLRS]; /*<18>A queue for each host interface*/
-static int nextcontroller=0; /*<18>Number of interface units found*/
-static int drivepresent=0; /*<18>Don't change this - see license*/
-static int iftype; /*<20>Probe/Attach i.f. type relay*/
-
-static unsigned char if_state[4]={0,0,0,0}; /*<18>State of the host I/F and bus*/
-
-/* Flags in the if_state array
-*/
-
-#define BUSBUSY 0x01 /*<18>Bus is already busy*/
-
-
-struct matcd_read2 {
- unsigned char start_msf[3];
- unsigned char end_msf[3];
-};
-
-
-/* This mystery structure is supposed to make dynamic driver
- loading possible.
-*/
-
-
-/*---------------------------------------------------------------------------
- These macros take apart the minor number and yield the
- partition, drive on controller, and controller.
- This must match the settings in /dev/MAKEDEV.
----------------------------------------------------------------------------*/
-
-#define matcd_partition(dev) ((minor(dev)) & 0x07)
-#define matcd_ldrive(dev) (((minor(dev)) & 0x78) >> 3)
-#define matcd_cdrive(dev) (((minor(dev)) & 0x18) >> 3)
-#define matcd_controller(dev) (((minor(dev)) & 0x60) >> 5)
-#ifdef LOCKDRIVE
-#define matcd_lockable(dev) (((minor(dev)) & 0x80) >> 5)
-#endif /*LOCKDRIVE*/
-
-
-
-
-/*---------------------------------------------------------------------------
- Entry points and other connections to/from kernel - see also conf.h
- --- not any more :)
----------------------------------------------------------------------------*/
-
-static int matcd_probe(struct isa_device *dev);
-static int matcd_attach(struct isa_device *dev);
-struct isa_driver matcddriver={
- INTR_TYPE_BIO,
- matcd_probe,
- matcd_attach,
- "matcd"
-};
-COMPAT_ISA_DRIVER(matcd, matcddriver);
-
-
-static d_open_t matcdopen;
-static d_close_t matcdclose;
-static d_ioctl_t matcdioctl;
-static d_psize_t matcdsize;
-static d_strategy_t matcdstrategy;
-
-#define CDEV_MAJOR 46
-
-static struct cdevsw matcd_cdevsw = {
- /* open */ matcdopen,
- /* close */ matcdclose,
- /* read */ physread,
- /* write */ nowrite,
- /* ioctl */ matcdioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ matcdstrategy,
- /* name */ "matcd",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_DISK,
-};
-
-/*---------------------------------------------------------------------------
- Internal function declarations
----------------------------------------------------------------------------*/
-
-static void matcd_start(int controller);
-static void zero_cmd(char *);
-static void matcd_pread(int port, int count, unsigned char * data);
-static int matcd_fastcmd(int port,int ldrive,int cdrive,
- unsigned char * cp);
-static void matcd_slowcmd(int port,int ldrive,int cdrive,
- unsigned char * cp);
-static timeout_t matcd_timeout;
-static void matcd_blockread(int state);
-static void selectdrive(int port,int drive);
-static void doreset(int port,int cdrive);
-static int doprobe(int port,int cdrive);
-static void lockbus(int controller, int ldrive);
-static void unlockbus(int controller, int ldrive);
-static int matcd_volinfo(int ldrive);
-static void draincmd(int port,int cdrive,int ldrive);
-static int get_error(int port, int ldrive, int cdrive);
-static int chk_error(int errnum);
-static int msf_to_blk(unsigned char * cd);
-#ifdef FULLDRIVER
-static int matcd_playtracks(int ldrive, int cdrive, int controller,
- struct ioc_play_track *pt);
-static int matcd_playmsf(int ldrive, int cdrive, int controller,
- struct ioc_play_msf *pt);
-static int matcd_pause(int ldrive, int cdrive, int controller,
- int action);
-static int matcd_stop(int ldrive, int cdrive, int controller);
-static int matcd_level(int ldrive, int cdrive, int controller,
- struct ioc_vol * volume, unsigned long action);
-static int matcd_patch(int ldrive, int cdrive, int controller,
- struct ioc_patch * routing);
-static int matcd_route(int ldrive, int cdrive, int controller,
- unsigned long command);
-static int matcd_pitch(int ldrive, int cdrive, int controller,
- struct ioc_pitch * speed);
-#endif /*FULLDRIVER*/
-static int matcd_toc_header(int ldrive, int cdrive, int controller,
- struct ioc_toc_header * toc);
-static int matcd_toc_entries(int ldrive, int cdrive,
- int controller,
- struct ioc_read_toc_entry *ioc_entry);
-static int matcd_toc_entry(int ldrive, int cdrive,
- int controller,
- struct ioc_read_toc_single_entry *ioc_entry);
-static int matcd_read_subq(int ldrive, int cdrive, int controller,
- struct ioc_read_subchannel * sqp);
-static int matcd_igot(struct ioc_capability * sqp);
-static int waitforit(int timelimit, int state, int port,
- char * where);
-static int get_stat(int port, int ldrive);
-static int media_chk(struct matcd_data *cd,int errnum,
- int ldrive,int test);
-static int matcd_eject(int ldrive, int cdrive, int controller);
-static int matcd_doorclose(int ldrive, int cdrive, int controller);
-static int matcd_dlock(int ldrive, int cdrive,
- int controller, int action);
-static int docmd(char * cmd, int ldrive, int cdrive,
- int controller, int port);
-
-
-/*---------------------------------------------------------------------------
- matcdopen - Open the device
-
- This routine actually gets called every time anybody opens
- any partition on a drive. But the first call is the one that
- does all the work.
-
-<15> If LOCKDRIVE is enabled, additional minor number devices allow
-<15> the drive to be locked while being accessed.
----------------------------------------------------------------------------*/
-int matcdopen(dev_t dev, int flags, int fmt,
- struct thread *td)
-{
- int cdrive,ldrive,partition,controller,lock;
- struct matcd_data *cd;
- int i,z,port;
- unsigned char cmd[MAXCMDSIZ];
-
- ldrive=matcd_ldrive(dev);
- cdrive=matcd_cdrive(dev);
- partition=matcd_partition(dev);
- controller=matcd_controller(dev);
- lock=matcd_lockable(dev);
- cd= &matcd_data[ldrive];
- port=cd->iobase; /*and port#*/
-
- if (ldrive >= TOTALDRIVES) return(ENXIO);
-
-#ifdef DEBUGOPEN
- printf("matcd%d: Open: dev %x partition %x controller %x flags %x cdrive %x\n",
- ldrive,(int)dev,partition,controller,cd->flags,
- matcd_cdrive(dev));
-#endif /*DEBUGOPEN*/
-
- if (!(cd->flags & MATCDINIT)) { /*Did probe find this drive*/
- return(ENXIO);
- }
-
- if (!(cd->flags & MATCDLABEL) &&
- cd->openflags) { /*Has drive completely closed?*/
- return(ENXIO); /*No, all partitions must close*/
- }
-
-
-/* Now, test to see if the media is ready
-*/
-
- lockbus(controller,ldrive);
- zero_cmd(cmd);
- cmd[0]=NOP; /*Test drive*/
- matcd_slowcmd(port,ldrive,cdrive,cmd);
- i=waitforit(10*TICKRES,DTEN,port,"matopen");
- z=get_stat(port,ldrive); /*Read status byte*/
-#ifdef DEBUGOPEN
- printf("matcd%d Result of NOP is %x %x\n",ldrive,i,z);
-#endif /*DEBUGOPEN*/
- if ((z & MATCD_ST_DSKIN)==0) { /*Is there a disc in the drive?*/
-#ifdef DEBUGOPEN
- printf("matcd%d: No Disc in open\n",ldrive);
-#endif /*DEBUGOPEN*/
- unlockbus(controller, ldrive); /*Release bus lock*/
- cd->flags &= ~MATCDLABEL; /*<16>Mark label as invalid*/
- if (major(dev)==RAW_DEVICE) { /*<16>Is the char device?*/
- return(0); /*<16>Allow Semi open*/
- }
- else {
- return(ENXIO); /*<16>Normally blow off*/
- }
- }
- if (z & MATCD_ST_ERROR) { /*Was there an error*/
- i=get_error(port,ldrive,cdrive);/*Find out what it was*/
-#ifdef DEBUGOPEN
- printf("matcd%d NOP Error was %x\n",ldrive,i);
-#endif /*DEBUGOPEN*/
- if (cd->openflags) { /*Any parts open?*/
- if (media_chk(cd,i,ldrive,0)) { /*<14>Was it a disc chg?*/
-#ifdef DEBUGOPEN
- printf("matcd%d: Disc change detected i %x z %x\n",
- ldrive,i,z);
-#endif /*DEBUGOPEN*/
- unlockbus(controller, ldrive); /*Release bus lock*/
- return(ENOTTY);
- }
-
- } else {
- media_chk(cd,i,ldrive,1);/*<14>Was it a disc chg?*/
- /*<14>Clear volume info*/
- }
- }
- unlockbus(controller, ldrive); /*Release bus lock*/
-
-/* Here we fill in the disklabel structure although most is
- hardcoded.
-*/
-
- if ((cd->flags & MATCDLABEL)==0) {
- bzero(&cd->dlabel,sizeof(struct disklabel));
-
-/* Now we query the drive for the actual size of the media.
- This is where we find out of there is any media or if the
- media isn't a Mode 1 or Mode 2/XA disc.
- See version information about Mode 2/XA support.
-*/
- lockbus(controller,ldrive);
- i=matcdsize(dev);
- unlockbus(controller, ldrive); /*Release bus lock*/
-#ifdef DEBUGOPEN
- printf("matcd%d: Bus unlocked in open\n",ldrive);
-#endif /*DEBUGOPEN*/
- if (i < 0) {
- printf("matcd%d: Could not read the disc size\n",ldrive);
- return(ENXIO);
- } /*matcdsize filled in rest of dlabel*/
-
-/* Based on the results, fill in the variable entries in the disklabel
-*/
- cd->dlabel.d_secsize=cd->blksize;
- cd->dlabel.d_ncylinders=(cd->disksize/100)+1;
- cd->dlabel.d_secperunit=cd->disksize;
- cd->dlabel.d_partitions[0].p_size=cd->disksize;
- cd->dlabel.d_checksum=dkcksum(&cd->dlabel);
-
-
-/* Now fill in the hardcoded section
-*/
- /*123456789012345678*/
- strncpy(cd->dlabel.d_typename,"Matsushita CDR ",16);
- strncpy(cd->dlabel.d_packname,"(c) 1994, fdiv ",16);
- cd->dlabel.d_magic=DISKMAGIC;
- cd->dlabel.d_magic2=DISKMAGIC;
- cd->dlabel.d_nsectors=100;
- cd->dlabel.d_secpercyl=100;
- cd->dlabel.d_ntracks=1;
- cd->dlabel.d_interleave=1;
- cd->dlabel.d_rpm=300;
- cd->dlabel.d_npartitions=1; /*See note below*/
- cd->dlabel.d_partitions[0].p_offset=0;
- cd->dlabel.d_partitions[0].p_fstype=9;
- cd->dlabel.d_flags=D_REMOVABLE;
-
-/* I originally considered allowing the partition match tracks or
- sessions on the media, but since you are allowed up to 99
- tracks in the RedBook world, this would not fit in with the
- BSD fixed partition count scheme. So ioctls will be used to shift
- the track to be accessed into partition 1.
-*/
-
- cd->flags |= MATCDLABEL; /*Mark drive as having TOC*/
- }
-
- dev->si_bsize_phys = cd->blksize;
-
-#ifdef DEBUGOPEN
- printf("matcd%d open2: partition=%d disksize=%d blksize=%x flags=%x\n",
- ldrive,partition,(int)cd->disksize,cd->blksize,cd->flags);
-#endif /*DEBUGOPEN*/
-
-#ifdef LOCKDRIVE
- if (cd->openflags==0 && lock) {
- zero_cmd(cmd);
- cmd[0]=LOCK; /*Lock drive*/
- cmd[1]=1;
- docmd(cmd,ldrive,cdrive,controller,port);/*<15>Issue cmd*/
- cd->flags |= MATCDLOCK; /*<15>Drive is now locked*/
- }
-#endif /*LOCKDRIVE*/
- cd->openflags |= (1<<(partition+lock));/*<24>Mark partition open*/
-
- if (partition==RAW_PART ||
- (partition < cd->dlabel.d_npartitions &&
- cd->dlabel.d_partitions[partition].p_fstype != FS_UNUSED)) {
- cd->partflags[partition] |= MATCDOPEN;
- if (partition == RAW_PART) {
- cd->partflags[partition] |= MATCDREADRAW;
- }
-#ifdef DEBUGOPEN
- printf("matcd%d: Open is complete - openflags %x\n",
- ldrive,cd->openflags);
-#endif /*DEBUGOPEN*/
- return(0);
- }
-#ifdef DEBUGOPEN
- printf("matcd%d: Open FAILED\n",ldrive);
-#endif /*DEBUGOPEN*/
- return(ENXIO);
-}
-
-
-/*---------------------------------------------------------------------------
- matcdclose - Close the device
-
- Close may not do much other than clear some driver settings.
- Note that audio playback will continue.
-
-<15> If you define LOCKDRIVE, and the drive has been opened using
-<15> one of the locking minor numbers, code in close will unlock
-<15> the drive.
----------------------------------------------------------------------------*/
-
-int matcdclose(dev_t dev, int flags, int fmt,
- struct thread *td)
-{
- int ldrive,cdrive,port,partition,controller,lock;
- struct matcd_data *cd;
-#ifdef LOCKDRIVE
- unsigned char cmd[MAXCMDSIZ];
-#endif /*LOCKDRIVE*/
-
- ldrive=matcd_ldrive(dev);
- cdrive=matcd_cdrive(dev);
- lock=matcd_lockable(dev);
- cd=matcd_data+ldrive;
- port=cd->iobase; /*and port#*/
-
- if (ldrive >= TOTALDRIVES)
- return(ENXIO);
-
- partition = matcd_partition(dev);
- controller=matcd_controller(dev);
-#ifdef DEBUGOPEN
- printf("matcd%d: Close partition=%d flags %x openflags %x partflags %x\n",
- ldrive,partition,cd->flags,cd->openflags,
- cd->partflags[partition]);
-#endif /*DEBUGOPEN*/
-
- if (!(cd->flags & MATCDINIT))
- return(ENXIO);
-
- cd->partflags[partition] &= ~(MATCDOPEN|MATCDREADRAW);
- cd->openflags &= ~(1<<(partition+lock));
- if (cd->openflags==0) { /*<24>Really last close?*/
-#ifdef LOCKDRIVE
- if (cd->flags & MATCDLOCK) { /*<24>Was drive locked?*/
- zero_cmd(cmd); /*Yes, so unlock it*/
- cmd[0]=LOCK; /*Unlock drive*/
- docmd(cmd,ldrive,cdrive,controller,port);
- }
-#endif /*LOCKDRIVE*/
- cd->flags &= ~(MATCDWARN|MATCDLOCK);
- /*<15>Clear warning flag*/
- }
- return(0);
-}
-
-
-/*---------------------------------------------------------------------------
- matcdstrategy - Accepts I/O requests from kernel for processing
-
- This routine accepts a read request block pointer (historically
- but somewhat inaccurately called *bp for buffer pointer).
- Various sanity checks are performed on the request.
- When we are happy with the request and the state of the device,
- the request is added to the queue of requests for the interface
- that the drive is connected to. We support multiple interfaces
- so there are multiple queues. Once the request is added, we
- call the matcd_start routine to start the device in case it isn't
- doing something already. All I/O including ioctl requests
- rely on the current request starting the next one before exiting.
----------------------------------------------------------------------------*/
-
-void matcdstrategy(struct bio *bp)
-{
- struct matcd_data *cd;
- int s;
- int ldrive,controller;
-
- ldrive=matcd_ldrive(bp->bio_dev);
- controller=matcd_controller(bp->bio_dev);
- cd= &matcd_data[ldrive];
-
-#ifdef DEBUGIO
- printf("matcd%d: Strategy: buf=0x%lx, block#=%ld bcount=%ld\n",
- ldrive,(unsigned long)bp,bp->bio_blkno,bp->bio_bcount);
-#endif /*DEBUGIO*/
-
-
- if (ldrive >= TOTALDRIVES || bp->bio_blkno < 0) {
- printf("matcd%d: Bogus parameters received - kernel may be corrupted\n",ldrive);
- bp->bio_error=EINVAL;
- goto bad;
- }
-
- if (!(cd->flags & MATCDLABEL)) {
- bp->bio_error = EIO;
- goto bad;
- }
-
- if (!(bp->bio_cmd == BIO_READ)) {
- bp->bio_error = EROFS;
- goto bad;
- }
-
- if (bp->bio_bcount==0) /*Request is zero-length - all done*/
- goto done;
-
- if (matcd_partition(bp->bio_dev) != RAW_PART) {
- if (bounds_check_with_label(bp,&cd->dlabel,1) <= 0) {
- goto done;
- }
- } else {
- bp->bio_pblkno=bp->bio_blkno;
- bp->bio_resid=0;
- }
-
- s=splbio(); /*Make sure we don't get intr'ed*/
- bioqdisksort(&request_head[controller], bp);/*Add new request (bp) to queue (dp
- and sort the requests in a way that
- may not be ideal for CD-ROM media*/
-
-
- matcd_start(controller); /*Ok, with our newly sorted queue,
- see if we can start an I/O operation
- right now*/
- splx(s); /*Return priorities to normal*/
- return; /*All done*/
-
-bad: bp->bio_flags |= BIO_ERROR; /*Request bad in some way*/
-done: bp->bio_resid = bp->bio_bcount; /*Show amount of data un read*/
- biodone(bp); /*Signal we have done all we plan to*/
- return;
-}
-
-
-/*---------------------------------------------------------------------------
- matcd_start - Pull a request from the queue and consider doing it.
----------------------------------------------------------------------------*/
-
-static void matcd_start(int controller)
-{
- struct matcd_data *cd;
- struct bio *bp;
- struct partition *p;
- int part,ldrive;
-
- bp = bioq_first(&request_head[controller]);
- if (bp == NULL) { /*Nothing on read queue to do?*/
- wakeup((caddr_t)&matcd_data->status); /*Wakeup any blocked*/
- return; /* opens, ioctls, etc*/
- }
-
- ldrive=matcd_ldrive(bp->bio_dev); /*Get logical drive#*/
- cd=&matcd_data[ldrive]; /*Get pointer to data for this drive*/
-#ifdef DEBUGIO
- printf("matcd%d: In start controller %d\n",ldrive,controller);
-#endif /*DEBUGIO*/
-
- if (if_state[controller] & BUSBUSY) {
-#ifdef DEBUGIO
- printf("matcd%d: Dropping thread in start, controller %d\n",
- ldrive,controller);
-#endif /*DEBUGIO*/
- return;
- }
-
-/* Ok, the controller is idle (not necessarily the drive) and so
- get the command to do and issue it
-*/
-
- bioq_remove(&request_head[controller], bp);
-
- part=matcd_partition(bp->bio_dev);
- p=cd->dlabel.d_partitions + part;
-
- if_state[controller] |= BUSBUSY;/*<18>Mark bus as busy*/
- cd->mbx.ldrive=ldrive; /*Save current logical drive*/
- cd->mbx.controller=controller; /*and controller*/
- cd->mbx.partition=part; /*and partition (2048 vs 2532)*/
- cd->mbx.port=cd->iobase; /*and port#*/
- cd->mbx.iftype=cd->iftype; /*<20>interface type*/
- cd->mbx.retry=MATCD_RETRYS; /*and the retry count*/
- cd->mbx.bp=bp; /*and the bp*/
- cd->mbx.p_offset=p->p_offset; /*and where the data will go*/
- matcd_blockread(MATCD_READ_1+ldrive); /*Actually start the read*/
- return; /*Dropping thread. matcd_blockread
- must have scheduled a timeout or
- we will go to sleep forever*/
-}
-
-
-/*---------------------------------------------------------------------------
- matcdioctl - Process things that aren't block reads
-
- In this driver, ioctls are used mainly to change
- the mode the drive is running in, play audio and other
- things that don't fit into the block read scheme of things.
----------------------------------------------------------------------------*/
-
-int matcdioctl(dev_t dev, u_long command, caddr_t addr,
- int flags, struct thread *td)
-{
- struct matcd_data *cd;
- int ldrive,cdrive,partition;
- int port, controller;
-#ifdef DEBUGIOCTL
- int i;
-#endif /*DEBUGIOCTL*/
-
- ldrive=matcd_ldrive(dev);
- cdrive=matcd_cdrive(dev);
- partition=matcd_partition(dev);
- controller=ldrive>>2;
- cd = &matcd_data[ldrive];
- port=cd->iobase;
-
-#ifdef DEBUGIOCTL
- printf("matcd%d: ioctl %lx cdrive %x parms ",ldrive,command,cdrive);
- for (i=0;i<10;i++) {
- printf("%02x ",(unsigned int)addr[i]);
- }
- printf(" flags %x\n",cd->flags);
-#endif /*DEBUGIOCTL*/
-
- if (command==CDIOCCLOSE) /*<16>Allow close if door open*/
- return(matcd_doorclose(ldrive, cdrive, controller));
-
- if (!(cd->flags & MATCDLABEL)) /*Did we read TOC OK?*/
- return(EIO); /*<16>then drive really isn't ready*/
-
- switch(command) {
-
- case DIOCGDINFO:
- *(struct disklabel *) addr = cd->dlabel;
- return(0);
-
- case DIOCWDINFO:
- case DIOCSDINFO:
- if ((flags & FWRITE) == 0) {
- return(EBADF);
- }
- else {
- return setdisklabel(&cd->dlabel,
- (struct disklabel *) addr, 0);
- }
- case DIOCWLABEL:
- return(EBADF);
-
- case CDIOCEJECT:
- return(matcd_eject(ldrive, cdrive, controller));
-
- case CDIOCALLOW:
- return(matcd_dlock(ldrive, cdrive,
- controller,0));
-
- case CDIOCPREVENT:
- return(matcd_dlock(ldrive, cdrive,
- controller, MATCDLOCK));
-
-#ifdef FULLDRIVER
- case CDIOCPLAYTRACKS:
- return(matcd_playtracks(ldrive, cdrive, controller,
- (struct ioc_play_track *) addr));
-
- case CDIOCPLAYMSF:
- return(matcd_playmsf(ldrive, cdrive, controller,
- (struct ioc_play_msf *) addr));
-
- case CDIOCRESUME:
- return(matcd_pause(ldrive, cdrive, controller,RESUME));
-
- case CDIOCPAUSE:
- return(matcd_pause(ldrive, cdrive, controller,0));
-
- case CDIOCSTOP:
- return(matcd_stop(ldrive, cdrive, controller));
-
- case CDIOCGETVOL:
- case CDIOCSETVOL:
- return(matcd_level(ldrive, cdrive, controller,
- (struct ioc_vol *) addr, command));
-
- case CDIOCSETMONO: /*<12>This drive can't do mono*/
- return(EINVAL); /*<12>but it looks like it should*/
-
- /*<12>SRC OUT SRC OUT*/
- case CDIOCSETSTEREO: /*<12>0 -> L 1 -> R*/
- case CDIOCSETMUTE: /*<12>0 -> NULL 1 -> NULL*/
- case CDIOCSETLEFT: /*<12>0 -> L&R 1 -> NULL*/
- case CDIOCSETRIGHT: /*<12>0 -> NULL 1 -> L&R*/
- /*<12>Adjust audio routing*/
- return(matcd_route(ldrive, cdrive, controller, command));
-
- case CDIOCSETPATCH: /*<12>Allow precise routing*/
- return(matcd_patch(ldrive, cdrive, controller,
- (struct ioc_patch *) addr));
-
- case CDIOCPITCH: /*<12>Adjust playback speed*/
- return(matcd_pitch(ldrive, cdrive, controller,
- (struct ioc_pitch *) addr));
-
- case CDIOCSTART: /*<12>Only reason this isn't*/
- return(EINVAL); /*<12>implemented is I can't find out*/
- /*<12>what it should do!*/
-#endif /*FULLDRIVER*/
-
- case CDIOREADTOCHEADER:
- return(matcd_toc_header(ldrive, cdrive, controller,
- (struct ioc_toc_header *) addr));
-
- case CDIOREADTOCENTRYS:
- return(matcd_toc_entries(ldrive, cdrive, controller,
- (struct ioc_read_toc_entry *) addr));
-
- case CDIOREADTOCENTRY:
- return(matcd_toc_entry(ldrive, cdrive, controller,
- (struct ioc_read_toc_single_entry *) addr));
-
- case CDIOCREADSUBCHANNEL:
- return(matcd_read_subq(ldrive, cdrive, controller,
- (struct ioc_read_subchannel *) addr));
-
- case CDIOCCAPABILITY: /*<16>Request drive/driver capability*/
- return(matcd_igot((struct ioc_capability *) addr));
-
- case CDIOCRESET: /*<12>There is no way to hard reset*/
- return(EINVAL); /*<12>just one drive*/
-
- default:
- return(ENOTTY);
- }
-}
-
-/*---------------------------------------------------------------------------
- matcdsize - Reports how many blocks exist on the disc.
----------------------------------------------------------------------------*/
-
-int matcdsize(dev_t dev)
-{
- int size,blksize;
- int ldrive,part;
- struct matcd_data *cd;
-
- ldrive=matcd_ldrive(dev);
- part=matcd_partition(dev);
- if (part==RAW_PART)
- blksize=MATCDRBLK; /*2352*/
- else
- blksize=MATCDBLK; /*2048*/
-
- cd = &matcd_data[ldrive];
-
- if (matcd_volinfo(ldrive) >= 0) {
- cd->blksize=blksize;
- size=msf_to_blk((char * )&cd->volinfo.vol_msf);
-
- cd->disksize=size*(blksize/DEV_BSIZE);
-#ifdef DEBUGOPEN
- printf("matcd%d: Media size %d\n",ldrive,size);
-#endif /*DEBUGOPEN*/
- return(0);
- }
- return(-1);
-}
-
-/*---------------------------------------------------------------------------
- matcd_probe - Search for host interface/adapters
-
- The probe routine hunts for the first drive on the interface since
- there is no way to locate just the adapter. It also resets the
- entire drive chain while it is there. matcd_attach() takes care of
- the rest of the initialization.
-
- The probe routine can be compiled two ways. In AUTOHUNT mode,
- the kernel config file can say "port?" and we will check all ports
- listed in the port_hint array (see above).
-
- Without AUTOHUNT set, the config file must list a specific port
- address to check.
-
- Note that specifying the explicit addresses makes boot-up a lot
- faster.
-
- The probe will locate Panasonic/Creative interface on the following
- Creative adapter boards:
- #1330A Sound Blaster PRO
- #1730 Sound Blaster 16
- #1740 Sound Blaster 16 (cost reduced)
- #2230 Sound Blaster 16 (cost reduced)
- #2770 Sound Blaster 16 Value (cost reduced)
- #1810 omniCD upgrade kit adapter card (stand-alone CD)
- #3100 PhoneBlaster SB16 + Sierra 14.4K modem combo
- Creative releases a newer and cheaper-to-make Sound Blaster
- board every few months, so by the original release date of this
- software, there are probably 8 different board models called
- Sound Blaster 16. These include "Vibra", "Value", etc.
-
- Please report additional part numbers and board descriptions
- and new port numbers that work to the author.
-
----------------------------------------------------------------------------*/
-
-static int
-matcd_probe(struct isa_device *dev)
-{
- int i,cdrive;
- unsigned char y;
- int port = dev->id_iobase; /*Take port hint from config file*/
-
- cdrive=nextcontroller; /*Controller defined by pass for now*/
- if (nextcontroller==NUMCTRLRS) {
- printf("matcd%d: - Too many interfaces specified in config\n",
- nextcontroller);
- return(0);
- }
- if (nextcontroller==0) { /*Very first time to be called*/
- for (i=0; i<TOTALDRIVES; i++) {
- matcd_data[i].drivemode=MODE_UNKNOWN;
- matcd_data[i].flags=0;
- }
- }
-
- i=nextcontroller*DRIVESPERC; /*Precompute controller offset*/
- for (y=0; y<DRIVESPERC; y++) {
- matcd_data[i+y].flags=0;
- }
-
-#ifdef DEBUGPROBE
- printf("matcd%d: In probe i %d y %d port %x\n",
- nextcontroller,i,y,port);
-#endif /*DEBUGPROBE*/
-#ifdef AUTOHUNT
-#ifdef DEBUGPROBE
- printf("matcd%d: size of port_hints %d\n",
- nextcontroller,sizeof(port_hints));
-#endif /*DEBUGPROBE*/
- if (port==-1) {
- for(i=0;i<(sizeof(port_hints)/sizeof(short));i++) {
- port=port_hints[i];
-#ifdef DEBUGPROBE
- printf("matcd%d: Port hint %x\n",nextcontroller,port);
-#endif /*DEBUGPROBE*/
- if (port==-1) {
- dev->id_iobase=-1; /*Put port ? back*/
- return(0);/*Nothing left to try*/
- }
- if (port!=0) { /*Untested port found*/
- dev->id_iobase=port;
- port_hints[i]=0;/*Don't use that port again*/
- if (doprobe(port,cdrive)==0) return(NUMPORTS);
- }
- }
- dev->id_iobase=-1; /*Put port ? back as it was*/
- return(0); /*Interface not found*/
-
- } else { /*Config specified a port*/
- i=0; /*so eliminate it from the hint list*/
- for(i=0;;i++) { /*or we might try to assign it again*/
- if (port_hints[i]== -1) break; /*End of list*/
- if (port_hints[i]==port) {
- port_hints[i]=0; /*Clear duplicate*/
- break;
- }
- }
- if (doprobe(port,cdrive)==0) return(NUMPORTS);
- else return(0);
- }
-#else /*AUTOHUNT*/
- if (port==-1) {
- printf("matcd%d: AUTOHUNT disabled but port? specified in config\n",
- nextcontroller);
- return(0);
- }
- if (doprobe(port,cdrive)==0) return(NUMPORTS);
- else return(0);
-#endif /*AUTOHUNT*/
-}
-
-/*---------------------------------------------------------------------------
- doprobe - Common probe code that actually checks the ports we
- have decided to test.
-
-<20> Edit 20 changes adds code to determine if the host interface
- is one that behaves like the Creative SoundBlaster cards,
- or whether the host interface like those used by some boards
- made by Media Vision and a version known as Lasermate.
----------------------------------------------------------------------------*/
-
-int doprobe(int port,int cdrive)
-{
- unsigned char cmd[MAXCMDSIZ];
- int i;
-
-#ifdef RESETONBOOT
- doreset(port,cdrive); /*Reset what might be our device*/
-#endif /*RESETONBOOT*/
- outb(port+PHASE,0); /*<16>Guarantee status phase*/
- zero_cmd(cmd);
- cmd[0]=NOP; /*A reasonably harmless command.
- This command will fail after
- power-up or after reset. That's OK*/
-#ifdef RESETONBOOT
- if (((inb(port+STATUS) & (DTEN|STEN)) != (DTEN|STEN)) ||
- (inb(port+DATA) != 0xff))
- return(-1); /*<20>Something detected but it isn't
- the device we wanted*/
-#endif /*RESETONBOOT*/
- if (matcd_fastcmd(port,0,0,cmd)==0) {/*Issue command*/
- outb(port+PHASE,1); /*<20>Switch to Creative Data phase*/
- i=inb(port+CMD); /*<20>Read a byte in data phase*/
- outb(port+PHASE,0); /*<20>Switch to Creative Status phase*/
- if ((inb(port+STATUS) & (DTEN|STEN))
- == (DTEN|STEN)) { /*<20>Drive went idle*/
- iftype=1; /*<20>It is not a Creative interface.*/
- } else { /*<20>Status byte still available*/
- iftype=0;
- inb(port+CMD); /*<20>Read status byte*/
- }
-#ifdef DEBUGPROBE
- printf("matcd%d: Probe found something\n",nextcontroller);
-#endif /*DEBUGPROBE*/
-/*------Don't change anything below this line - see license -----------------*/
- if (drivepresent==0) { /*Don't change*/
- printf("matcd - Matsushita (Panasonic) CD-ROM Driver by FDIV, %s\n",
- /*Don't change*/
- MATCDVERSION); /*Don't change*/
- drivepresent++; /*Don't change*/
- if (drivepresent==0) /*Don't change - make LINT happy*/
- printf("%s\n",MATCDCOPYRIGHT); /*Don't change*/
- } /*Don't change*/
-/*------Don't change anything above this line - see license -----------------*/
- return(0); /*Drive 0 detected*/
- }
-#ifdef DEBUGPROBE
- printf("matcd%d: Probe DID NOT find something\n",nextcontroller);
-#endif /*DEBUGPROBE*/
- return(1);
-}
-
-
-/*---------------------------------------------------------------------------
- matcd_attach - Locates drives on the adapters that were located.
- If we got here, we located an interface and at least one
- drive. Now we figure out how many drives are under that
- interface. The Panasonic interface is too simple to call
- it a controller, but in the existing PDP model, that is
- what it would be.
----------------------------------------------------------------------------*/
-
-static int
-matcd_attach(struct isa_device *dev)
-{
- int i;
- unsigned int z,cdrive;
- unsigned char cmd[MAXCMDSIZ];
- unsigned char data[12];
- struct matcd_data *cd;
- int port = dev->id_iobase; /*Take port ID selected in probe()*/
-
-#ifdef DEBUGPROBE
- printf("matcd: Attach dev %x id_unit %d\n",
- (unsigned int)dev,dev->id_unit);
-#endif /*DEBUGPROBE*/
- printf("matcd%d Host interface type %d\n",
- nextcontroller,iftype);
- bioq_init(&request_head[nextcontroller]);
- for (cdrive=0; cdrive<4; cdrive++) { /*We're hunting drives...*/
- zero_cmd(cmd);
- cmd[0]=NOP; /*A reasonably harmless command.
- This command will fail after
- power-up or after reset. It's OK*/
- i=cdrive+(DRIVESPERC*nextcontroller);
- if (matcd_fastcmd(port,i,cdrive,cmd)==0) { /*Issue cmd*/
- z=get_stat(port,cdrive);/*Read status byte*/
- if ((z & MATCD_ST_ERROR)) { /*If there was an error,
- we must ask for error info
- or subsequent cmds fail*/
- zero_cmd(cmd);
- cmd[0]=READERROR; /*Inquire*/
- matcd_fastcmd(port,i,cdrive,cmd);
- matcd_pread(port,8,data);/*Read data returned*/
- z=get_stat(port,i);/*Read status byte*/
-#ifdef DEBUGPROBE
- printf("matcd%d: Status byte %x ",i,z);
-#endif /*DEBUGPROBE*/
- }
- zero_cmd(cmd);
- cmd[0]=READID; /*Get drive ID*/
- matcd_fastcmd(port,i,cdrive,cmd);
- matcd_pread(port,10,data);/*Read Drive Parm*/
- get_stat(port,i); /*Read and toss status byte*/
- data[10]=0; /*Build ASCIZ string*/
- printf("matcd%d: [%s] ",i,data);
- cd=&matcd_data[i];
- cd->flags |= MATCDINIT;
- cd->iobase=dev->id_iobase;
- cd->iftype=iftype;
- cd->openflags=0;
- cd->volume[0]=cd->volume[1]=DEFVOL;
- /*<12>Match volume drive resets to*/
- cd->patch[0]=0x01; /*<12>Channel 0 to Left*/
- cd->patch[1]=0x02; /*<12>Channel 1 to Right*/
- cd->status=CD_AS_NO_STATUS;
- for (i=0; i<MAXPARTITIONS; i++) {
- cd->partflags[i]=0;
- }
- make_dev(&matcd_cdevsw, dkmakeminor(i, 0, 0),
- UID_ROOT, GID_OPERATOR, 0640, "rmatcd%da", i);
- make_dev(&matcd_cdevsw, dkmakeminor(i, 0, RAW_PART),
- UID_ROOT, GID_OPERATOR, 0640, "rmatcd%dc", i);
- make_dev(&matcd_cdevsw, 0x80 | dkmakeminor(i, 0, 0),
- UID_ROOT, GID_OPERATOR, 0640, "rmatcd%dla", i);
- make_dev(&matcd_cdevsw,
- 0x80 | dkmakeminor(i, 0, RAW_PART),
- UID_ROOT, GID_OPERATOR, 0640, "rmatcd%dc", i);
- }
- }
- nextcontroller++; /*Bump ctlr assign to next number*/
- printf("\n"); /*End line of drive reports*/
-
- return(1);
-}
-
-
-/*---------------------------------------------------------------------------
- zero_cmd - Initialize command buffer
----------------------------------------------------------------------------*/
-
-void zero_cmd(char * lcmd)
-{
- int i;
-
- for (i=0; i<MAXCMDSIZ; lcmd[i++]=0);
- return;
-}
-
-
-/*---------------------------------------------------------------------------
- doreset - Resets all the drives connected to a interface
----------------------------------------------------------------------------*/
-
-void doreset(int port,int cdrive)
-{
- register int i,z;
- outb(port+RESET,0); /*Reset what might be our device*/
- /*Although this ensures a known
- state, it does close the drive
- door (if open) and aborts any
- audio playback in progress. */
- for (i=0;i<(125*ISABUSKHZ);i++){/*DELAY 500msec minimum. Worst
- case is door open and none or
- unreadable media */
- z=inb(port+CMD); /*This makes the loop run at a
- known speed. This value is ok
- for 8.33MHz bus*/
- }
- for (i=0;i<4;i++) {
- matcd_data[(cdrive*4)+i].drivemode=MODE_UNKNOWN;
- }
- return;
-}
-
-
-/*---------------------------------------------------------------------------
- matcd_fastcmd - Send a command to a drive
-
- This routine executed commands that return instantly (or reasonably
- quick), such as RESET, NOP, READ ERROR, etc. The only difference
- between it and handling for slower commands, is the slower commands
- will invoke a timeout/sleep if they don't get an instant response.
-
- Fastcmd is mainly used in probe(), attach() and error related
- functions. Every attempt should be made to NOT use this
- function for any command that might be executed when the system
- is up.
----------------------------------------------------------------------------*/
-
-int matcd_fastcmd(int port,int ldrive,int cdrive,unsigned char * cp)
-{
- unsigned int i;
- unsigned char z;
- int level;
-#ifdef DEBUGCMD
- unsigned char *cx;
-#endif /*DEBUGCMD*/
-
-
-
- draincmd(port,cdrive,ldrive); /*Make sure bus is really idle*/
-#ifdef DEBUGCMD
- cx=cp;
- printf("matcd%d: Fast Send port %x sel %d command %x %x %x %x %x %x %x\n",
- ldrive,port,cdrive,cx[0],cx[1],cx[2],cx[3],cx[4],cx[5],cx[6]);
-#endif /*DEBUGCMD*/
- selectdrive(port,cdrive); /*Enable the desired target drive*/
- level=splhigh(); /*----------------------------------------*/
- for (i=0; i<7; i++) { /*The seven bytes of the command*/
- outb(port+CMD,*cp++); /*must be sent within 10msec or*/
- } /*the drive will ignore the cmd*/
- splx(level); /*------------------------------------------------*/
-
-/* Now we wait a maximum of 240msec for a response.
- Only in a few rare cases does it take this long.
- If it is longer, the command should probably be slept on
- rather than increasing the timing value
-*/
-
- for (i=0; i<(60*ISABUSKHZ); i++) {
- z = (inb(port+STATUS)) & (DTEN|STEN);
- if (z != (DTEN|STEN)) break;
- }
-
-/* We are now either in a data or status phase, OR we timed-out.*/
-
- if (z == (DTEN|STEN)) {
-#ifdef DEBUGCMD
- printf("matcd%d: Command time-out\n",ldrive);
-#endif /*DEBUGCMD*/
- return(-1);
- }
- if (z != DTEN) {
- return(1);
- }
- return(0);
-}
-
-
-/*---------------------------------------------------------------------------
- matcd_slowcmd - Issue a command to the drive
-
- This routine is for commands that might take a long time, such
- as a read or seek. The caller must determine if the command
- completes instantly or schedule a poll later on.
----------------------------------------------------------------------------*/
-
-void matcd_slowcmd(int port,int ldrive,int cdrive,unsigned char * cp)
-{
- unsigned int i;
- int level,size;
-#ifdef DEBUGCMD
- unsigned char *cx;
-#endif /*DEBUGCMD*/
-
-
- draincmd(port,cdrive,ldrive); /*Make sure bus is really idle*/
-
-#ifdef DEBUGCMD
- cx=cp;
- printf("matcd%d: Slow Send port %x sel %d command %x %x %x %x %x %x %x\n",
- ldrive,port,cdrive,cx[0],cx[1],cx[2],cx[3],cx[4],cx[5],cx[6]);
-#endif /*DEBUGCMD*/
- selectdrive(port,cdrive); /*Enable the desired target drive*/
- if (*cp==ABORT) size=1;
- else size=7;
- level=splhigh(); /*----------------------------------------*/
- for (i=0; i<size; i++) { /*The seven bytes of the command*/
- outb(port+CMD,*cp++); /*must be sent within 10msec or*/
- } /*the drive will ignore the cmd*/
- splx(level); /*------------------------------------------------*/
- return;
-}
-
-
-/*---------------------------------------------------------------------------
- draincmd - Makes certain the bus is idle and throws away
- any residual data from the drive if there is any.
- Called as preface to most commands.
- Added in Edit 5.
-
- This was added because switching drive modes causes
- the drive to emit buffers that were meant to be sent
- to the D-to-A to be sent to the host. See setmode.
----------------------------------------------------------------------------*/
-void draincmd(int port,int cdrive,int ldrive)
-{
- int i,z;
-
- i=inb(port+STATUS);
- if ((i & (DTEN|STEN)) == (DTEN|STEN)) return;
-
- printf("matcd%d: in draincmd: bus not idle %x - trying to fix\n",
- ldrive,inb(port+STATUS));
- if ((i & (DTEN|STEN)) == STEN) {
-#ifdef DEBUGCMD
- printf("matcd%d: Data present READING - ",ldrive);
-#endif /*DEBUGCMD*/
- i=0;
- outb(port+PHASE,1); /*<16>Enable data read*/
- while ((inb(port+STATUS) & (DTEN|STEN)) == STEN) {
- inb(port+DATA); /*<21>Ok for Creative*/
- inb(port+ALTDATA); /*<21>Ok for others*/
- i++;
- }
- outb(port+PHASE,0);
-#ifdef DEBUGCMD
- printf("%d bytes read\n",i);
-#endif /*DEBUGCMD*/
- }
-#ifdef DEBUGCMD
- printf("matcd%d: Now read status: ",ldrive);
-#endif /*DEBUGCMD*/
- i=get_stat(port,ldrive); /*Read status byte*/
- z=inb(port+STATUS); /*Read bus status*/
-#ifdef DEBUGCMD
- printf("Data byte %x and status is now %x\n",i,z);
-#endif /*DEBUGCMD*/
- if ((z & (DTEN|STEN)) != (DTEN|STEN)) {
- printf("matcd%d: Bus not idle %x - resetting\n",
- cdrive,inb(port+STATUS));
- doreset(port,cdrive);
- }
- return;
-}
-
-
-/*---------------------------------------------------------------------------
- selectdrive - Swaps drive select bits
-
- On Creative SB/SB16/stand-alone adapters, possibly to make them
- hard to reverse engineer, the drive select signals are swapped.
----------------------------------------------------------------------------*/
-
-void selectdrive(int port,int drive)
-{
- switch(drive) {
- case 0: /*0x00 -> 0x00*/
- outb(port+SELECT,CRDRIVE0);
- break;
- case 1: /*0x01 -> 0x02*/
- outb(port+SELECT,CRDRIVE1);
- break;
- case 2: /*0x02 -> 0x01*/
- outb(port+SELECT,CRDRIVE2);
- break;
- case 3: /*0x03 -> 0x03*/
- outb(port+SELECT,CRDRIVE3);
- break;
- }
- return;
-}
-
-
-/*---------------------------------------------------------------------------
- matcd_pread - Read small blocks of control data from a drive
----------------------------------------------------------------------------*/
-
-void matcd_pread(int port, int count, unsigned char * data)
-{
- int i;
-
- for (i=0; i<count; i++) {
- *data++ = inb(port+CMD);
- }
- return;
-}
-
-
-/*---------------------------------------------------------------------------
- matcd_setmode - Configures disc to run in the desired data mode
-
- This routine assumes the drive is already idle.
-
-NOTE - Undocumented action of hardware: If you change (or reaffirm) data
- modes with MODESELECT + BLOCKPARAM immediately after a command was
- issued that aborted a DA play operation, the drive will unexpectedly
- return 2532 bytes of data in a data phase on the first or second
- subsequent command.
-
- Original Symptom: drive will refuse to go idle after reading data
- and status expected for a command. State mechanics for this are
- not fully understood.
----------------------------------------------------------------------------*/
-
-static int
-matcd_setmode(int ldrive, int mode)
-{
- struct matcd_data *cd;
- int retries;
- int i,port,cdrive;
- unsigned char cmd[MAXCMDSIZ];
-
- cd = matcd_data + ldrive;
- retries=3;
- cdrive=ldrive&0x03;
- port=cd->iobase;
- if (cd->drivemode==mode) {
- return(0); /*Drive already set*/
- }
-
-/* The drive is not in the right mode, so we need to set it.
-*/
-
- zero_cmd(cmd);
- cmd[0]=MODESELECT; /*Set drive transfer modes*/
-/* cmd[1]=BLOCKPARAM; BLOCKPARAM==0*/
- cmd[2]=mode;
- switch(mode) {
- case MODE_DATA:
- cmd[3]=0x08; /*2048 bytes*/
- break;
- case MODE_USER:
- cmd[3]=0x09; /*2352 bytes*/
- cmd[4]=0x30;
- break;
- case MODE_DA:
- cmd[3]=0x09; /*2352 bytes*/
- cmd[4]=0x30;
- break;
- }
- i=0;
- while(retries-- > 0) {
- i=matcd_fastcmd(port,ldrive,cdrive,cmd);
- get_stat(port,ldrive); /*Read and toss status byte*/
- if (i==0) {
- cd->drivemode=mode; /*Set new mode*/
- return(i);
- }
- get_error(port,ldrive,cdrive);
- }
- cd->drivemode=MODE_UNKNOWN; /*We failed*/
- return(i);
-}
-
-
-/*---------------------------------------------------------------------------
- matcd_volinfo - Read information from disc Table of Contents
----------------------------------------------------------------------------*/
-
-static int matcd_volinfo(int ldrive)
-{
- struct matcd_data *cd;
- int port,i;
- int z,cdrive;
- int retry;
- unsigned char cmd[MAXCMDSIZ];
- unsigned char data[12];
-
- retry=10; /*<16>This may take a long time*/
- cd = &matcd_data[ldrive];
- cdrive=ldrive&0x03;
- port=cd->iobase;
-
-#ifdef DEBUGOPEN
- printf("matcd%d: In volinfo, port %x\n",ldrive,port);
-#endif /*DEBUGOPEN*/
-
- while(retry>0) {
- zero_cmd(cmd);
- cmd[0]=READDINFO; /*Read Disc Info*/
- matcd_slowcmd(port,ldrive,cdrive,cmd);
- i=waitforit(10*TICKRES,DTEN,port,"matvinf");
- if (i) { /*THIS SHOULD NOT HAPPEN*/
- z=get_stat(port,ldrive);/*Read status byte*/
- printf("matcd%d: command failed, status %x\n",
- ldrive,z);
- return(-1);
- }
- matcd_pread(port, 6, data); /*Read data returned*/
- z=get_stat(port,ldrive);/*Read status byte*/
-#ifdef DEBUGOPEN
- printf("matcd%d: Data got was %x %x %x %x %x %x ",ldrive,
- data[0],data[1],data[2], data[3],data[4],data[5]);
- printf("status byte %x\n",z);
-#endif /*DEBUGOPEN*/
- if ((z & MATCD_ST_ERROR)==0)
- break; /*No Error*/
-
-/* If media change or other error, you have to read error data or
- the drive will reject subsequent commands.
-*/
-
- if (chk_error(get_error(port, ldrive, cdrive))==ERR_FATAL) {
-#ifdef DEBUGOPEN
- printf("matcd%d: command failed, status %x\n",
- ldrive,z);
-#endif /*DEBUGOPEN*/
- return(-1);
- }
- tsleep((caddr_t)&nextcontroller, PRIBIO, "matvi2", hz);
- if ((--retry)==0) return(-1);
-#ifdef DEBUGOPEN
- printf("matcd%d: Retrying",ldrive);
-#endif /*DEBUGOPEN*/
- }
-#ifdef DEBUGOPEN
- printf("matcd%d: Status port %x \n",ldrive,inb(port+STATUS));
-#endif /*DEBUGOPEN*/
-
- cd->volinfo.type=data[0];
- cd->volinfo.trk_high=data[2];
- cd->volinfo.trk_low=data[1];
- cd->volinfo.vol_msf[0]=data[3];
- cd->volinfo.vol_msf[1]=data[4];
- cd->volinfo.vol_msf[2]=data[5];
-
- if (cd->volinfo.trk_low + cd->volinfo.trk_high) {
- cd->flags |= MATCDLABEL;
- return(0);
- }
- return(-1);
-}
-
-
-/*---------------------------------------------------------------------------
- blk_to_msf - Convert block numbers into CD disk block ids
----------------------------------------------------------------------------*/
-
-static void blk_to_msf(int blk, unsigned char *msf)
-{
- blk=blk+150; /*2 seconds skip required to
- reach ISO data*/
- msf[0]=blk/4500;
- blk=blk%4500;
- msf[1]=blk/75;
- msf[2]=blk%75;
- return;
-}
-
-
-/*---------------------------------------------------------------------------
- msf_to_blk - Convert CD disk block ids into block numbers
----------------------------------------------------------------------------*/
-
-static int msf_to_blk(unsigned char * cd)
-{
- return(((cd[0]*60) /*Convert MSF to*/
- +cd[1])*75 /*Blocks minus 2*/
- +cd[2]-150); /*seconds*/
-}
-
-static void matcd_timeout(void *arg)
-{
- matcd_blockread((int)arg);
-}
-
-/*---------------------------------------------------------------------------
- matcd_blockread - Performs actual background disc I/O operations
-
- This routine is handed the block number to read, issues the
- command to the drive, waits for it to complete, reads the
- data or error, retries if needed, and returns the results
- to the host.
----------------------------------------------------------------------------*/
-
-static void matcd_blockread(int state)
-{
- struct matcd_mbx *mbx;
- int ldrive,cdrive;
- int port, controller;
- short iftype;
- struct bio *bp;
- struct matcd_data *cd;
- int i;
- struct matcd_read2 rbuf;
- int blknum;
- caddr_t addr;
- int status;
- int errtyp;
- int phase;
- unsigned char cmd[MAXCMDSIZ];
-
- mbx = &matcd_data[state & 0x0f].mbx;
- ldrive=mbx->ldrive; /*ldrive is logical drive #*/
- cdrive=ldrive & 0x03; /*cdrive is drive # on a controller*/
- port=mbx->port; /*port is base port for i/f*/
- iftype=mbx->iftype;
- bp= mbx->bp;
- cd=&matcd_data[ldrive];
- controller = cd->mbx.controller;
-
-#ifdef DEBUGIO
- printf("matcd%d: Show state %x cdrive %d partition %d\n",
- ldrive,state,cdrive,mbx->partition);
-#endif /*DEBUGIO*/
-
-loop:
-#ifdef DEBUGIO
- printf("matcd%d: Top dp %x\n",ldrive,(unsigned int)dp);
-#endif /*DEBUGIO*/
- switch (state & 0xf0) {
- case MATCD_READ_1:
-#ifdef DEBUGIO
- printf("matcd%d: State 1 cd->flags %x\n",ldrive,cd->flags);
-#endif /*DEBUGIO*/
- /* to check for raw/cooked mode */
- if (cd->partflags[mbx->partition] & MATCDREADRAW) {
- mbx->sz = MATCDRBLK;
- i=matcd_setmode(ldrive, MODE_DA);
-#ifdef DEBUGIO
- printf("matcd%d: Set MODE_DA result %d\n",ldrive,i);
-#endif /*DEBUGIO*/
- } else {
- mbx->sz = cd->blksize;
- i=matcd_setmode(ldrive, MODE_DATA);
-#ifdef DEBUGIO
- printf("matcd%d: Set MODE_DATA result %d\n",ldrive,i);
-#endif /*DEBUGIO*/
- }
- /*for first block*/
-#ifdef DEBUGIO
- printf("matcd%d: A mbx %x bp %x b_bcount %x sz %x\n",
- ldrive,(unsigned int)mbx,(unsigned int)bp,
- (unsigned int)bp->bio_bcount,mbx->sz);
-#endif /*DEBUGIO*/
- mbx->nblk = (bp->bio_bcount + (mbx->sz-1)) / mbx->sz;
- mbx->skip=0;
-nextblock:
-#ifdef DEBUGIO
- printf("matcd%d: at Nextblock b_blkno %d\n",
- ldrive,(unsigned int)bp->bio_blkno);
-#endif /*DEBUGIO*/
-
- blknum=(bp->bio_blkno / (mbx->sz/DEV_BSIZE))
- + mbx->p_offset + mbx->skip/mbx->sz;
-
- blk_to_msf(blknum,rbuf.start_msf);
-
- zero_cmd(cmd);
- cmd[0]=READ; /*Get drive ID*/
- cmd[1]=rbuf.start_msf[0];
- cmd[2]=rbuf.start_msf[1];
- cmd[3]=rbuf.start_msf[2];
- cmd[6]=1; /*Xfer only one block*/
- matcd_slowcmd(port,ldrive,cdrive,cmd);
-
-/* Now that we have issued the command, check immediately to
- see if data is ready. The drive has read-ahead caching, so
- it is possible the data is already in the drive buffer.
-
- If the data is not ready, schedule a wakeup and later on this
- code will run again to see if the data is ready then.
-*/
-
- case MATCD_READ_2:
- state=MATCD_READ_2+ldrive;
- phase = (inb(port+STATUS)) & (DTEN|STEN);
-#ifdef DEBUGIO
- printf("matcd%d: In state 2 status %x ",ldrive,phase);
-#endif /*DEBUGIO*/
- switch(phase) {
- case (DTEN|STEN): /*DTEN==H STEN==H*/
-#ifdef DEBUGIO
- printf("matcd%d: Sleeping\n",ldrive);
-#endif /*DEBUGIO*/
- timeout(matcd_timeout,
- (caddr_t)MATCD_READ_2+ldrive,hz/100);
- return;
-
-
- case STEN: /*DTEN=L STEN=H*/
- case 0: /*DTEN=L STEN=L*/
-#ifdef DEBUGIO
- printf("matcd%d: Data Phase\n",ldrive);
-#endif /*DEBUGIO*/
- addr=bp->bio_data + mbx->skip;
-#ifdef DEBUGIO
- printf("matcd%d: Xfer Addr %x size %x",
- ldrive,(unsigned int)addr,mbx->sz);
- i=0; /*<20>Reset read count*/
-#endif /*DEBUGIO*/
- if (iftype==0) { /*<20>Creative host I/F*/
- outb(port+PHASE,1); /*Enable data read*/
- while((inb(port+STATUS) &
- (DTEN|STEN))==STEN) {
- *addr++=inb(port+DATA);
-#ifdef DEBUGIO
- i++;
-#endif /*DEBUGIO*/
- }
- outb(port+PHASE,0); /*Disable read*/
- } else { /*<20>Not Creative interface*/
- while((inb(port+STATUS) &
- (DTEN|STEN))==STEN) {
- *addr++=inb(port+ALTDATA);
-#ifdef DEBUGIO
- i++;
-#endif /*DEBUGIO*/
- }
- }
-#ifdef DEBUGIO
- printf("matcd%d: Read %d bytes\n",ldrive,i);
-#endif /*DEBUGIO*/
-
-
-/* Now, wait for the Status phase to arrive. This will also
- tell us if any went wrong with the request.
-*/
- while((inb(port+STATUS)&(DTEN|STEN)) != DTEN);
- status=get_stat(port,ldrive); /*Read status byte*/
-#ifdef DEBUGIO
- printf("matcd%d: Status port %x byte %x ",
- ldrive,i,status);
-#endif /*DEBUGIO*/
- if (status & MATCD_ST_ERROR) {
- i=get_error(port,ldrive,cdrive);
- printf("matcd%d: %s while reading block %d [Soft]\n",
- ldrive,matcderrors[i],(int)bp->bio_blkno);
- media_chk(cd,i,ldrive,0);/*<14>was wrong place*/
- }
-
- if (--mbx->nblk > 0) {
- mbx->skip += mbx->sz;
- goto nextblock; /*Oooooh, you flunk the course*/
- }
- bp->bio_resid=0;
- biodone(bp); /*Signal transfer complete*/
-
- unlockbus(ldrive>>2, ldrive); /*Release bus lock*/
- matcd_start(controller);/*See if other drives have work*/
- return;
-
-/* Here we skipped the data phase and went directly to status.
- This indicates a hard error.
-*/
-
- case DTEN: /*DTEN=H STEN=L*/
- status=get_stat(port,ldrive); /*Read status byte*/
-#ifdef DEBUGIO
- printf("matcd%d: error, status was %x\n",
- ldrive,status);
-#endif /*DEBUGIO*/
-
-/* Ok, we need more details, so read error. This is needed to issue
- any further commands anyway
-*/
-
- errtyp=get_error(port,ldrive,cdrive);
- printf("matcd%d: %s while reading block %d\n",
- ldrive,matcderrors[errtyp],(int)bp->bio_blkno);
-
- if (media_chk(cd,errtyp,ldrive,0)==0) {
- errtyp=chk_error(errtyp);
- if (errtyp==ERR_RETRY) {/*<14>We can retry*/
- /*<14>this error but the drive*/
- /*<14>probably has already*/
- if (mbx->retry-- > 0 ) {
- state=MATCD_READ_1+ldrive;
-#ifdef DEBUGIO
- printf("matcd%d: Attempting retry\n",
- ldrive);
-#endif /*DEBUGIO*/
- goto loop;
- }
- }
- }
-/*<14> The other error types are either something very bad or the media
-<14> has been removed by the user. In both cases there is no retry
-<14> for this call. We will invalidate the label in both cases.
-*/
- bp->bio_flags |= BIO_ERROR;
- bp->bio_resid = bp->bio_bcount;
- biodone(bp);
- unlockbus(ldrive>>2, ldrive);
- matcd_start(controller);
- return;
- }
- }
-}
-
-
-/*---------------------------------------------------------------------------
- docmd - Get the bus, do the command, wait for completion,
- attempt retries, give up the bus.
- For commands that do not return data.
----------------------------------------------------------------------------*/
-
-int docmd(char * cmd, int ldrive, int cdrive, int controller, int port)
-{
- int retries,i=0,z;
-
- lockbus(controller, ldrive); /*Request bus*/
- retries=3;
- while(retries-- > 0) {
- matcd_slowcmd(port,ldrive,cdrive,cmd);
- i=waitforit(80*TICKRES,DTEN,port,"matcmd");
- z=get_stat(port,ldrive);/*Read status byte*/
- if ((z & MATCD_ST_ERROR)==0) break;
- i=chk_error(get_error(port,ldrive,cdrive));
- if (i!=ERR_INIT) {
- unlockbus(controller, ldrive); /*Release bus*/
- return(EFAULT);
- }
- }
- unlockbus(controller, ldrive); /*Release bus*/
- return(i);
-}
-
-
-/*---------------------------------------------------------------------------
- get_error - Read the error that aborted a command.
- Created in Edit 6
----------------------------------------------------------------------------*/
-
-int get_error(int port, int ldrive, int cdrive)
-{
- int status,errnum;
- unsigned char cmd1[MAXCMDSIZ];
- unsigned char data[12];
-
- zero_cmd(cmd1);
- cmd1[0]=READERROR; /*Enquire*/
- matcd_fastcmd(port,ldrive,cdrive,cmd1);
- matcd_pread(port, 8, data); /*Read data returned*/
- errnum=data[2]; /*Caller wants it classified*/
- status=get_stat(port,ldrive); /*Read status byte*/
-
-#ifdef DEBUGCMD
- printf("matcd%d: Chkerror found %x on command %x addrval %x statusdata %x statusport %x\n",
- ldrive,errnum,data[1],data[0],status,inb(port+STATUS));
-#endif /*DEBUGCMD*/
- return(errnum);
-}
-
-
-/*---------------------------------------------------------------------------
- chk_error - Classify the error that the drive reported
- Created in Edit 6
----------------------------------------------------------------------------*/
-
-int chk_error(int errnum)
-{
- switch(errnum) {
-/* These are errors we can attempt a retry for, although the drive
- has already done so.
-*/
- case UNRECV_ERROR:
- case SEEK_ERROR:
- case TRACK_ERROR:
- case FOCUS_ERROR:
- case CLV_ERROR:
- case DATA_ERROR:
- case MODE_ERROR: /*<16>Make this retryable*/
- return(ERR_RETRY);
-
-/* These errors usually indicate the user took the media from the
- drive while the dev was open. We will invalidate the unit
- until it closes when we see this.
-*/
- case NOT_READY:
- case MEDIA_CHANGED:
- case DISC_OUT:
- case HARD_RESET:
- return (ERR_INIT);
-
-/* These errors indicate the system is confused about the drive
- or media, and point to bugs in the driver or OS. These errors
- cannot be retried since you will always get the same error.
-*/
-
- case RAM_ERROR:
- case DIAG_ERROR:
- case CDB_ERROR:
- case END_ADDRESS:
- case ILLEGAL_REQ:
- case ADDRESS_ERROR:
- default:
- return (ERR_FATAL);
- }
-}
-
-
-/*---------------------------------------------------------------------------
- get_stat - Reads status byte
-
- This routine should be totally unnecessary, performing the
- task with a single line of in-line code. However in special
- cases, the drives return blocks of data that are not associated
- with the command in question. This appears to be at least one
- firmware error and the rest of the driver makes an effort to avoid
- triggering the fault. However, reading and throwing this
- bogus data is faster and less destructive than resetting all
- the drives on a given controller, plus it leaves the other drives
- unaffected.
----------------------------------------------------------------------------*/
-
-int get_stat(int port,int ldrive)
-{
- int status,busstat;
-
- status=inb(port+DATA); /*Read status byte, last step of cmd*/
- busstat=inb(port+STATUS); /*<16>Get bus status - should be 0xff*/
- while ((busstat & (DTEN|STEN)) != (DTEN|STEN)) {
- printf("matcd%d: get_stat: After reading status byte, bus didn't go idle %x %x %x\n",ldrive,status,busstat,port);
- if (( busstat & (DTEN|STEN)) == STEN) {
- int k;
- k=0;
-#ifdef DEBUGCMD
- printf("matcd%d: DATA PRESENT!!!! DISCARDING\n",ldrive);
-#endif /*DEBUGCMD*/
- outb(port+PHASE,1); /*Enable data read*/
- while ((inb(port+STATUS) & (DTEN|STEN)) == STEN) {
- inb(port+DATA);
- inb(port+ALTDATA);
-/* printf("%2x ",inb(port+DATA));*/
- k++;
- }
- outb(port+PHASE,0);
-#ifdef DEBUGCMD
- printf("\nmatcd%d: BYTES READ IN DATA was %d\n",
- ldrive,k);
-#endif /*DEBUGCMD*/
- }
- status=inb(port+DATA); /*Read the status byte again*/
-#ifdef DEBUGCMD
- printf("matcd%d: Next status byte is %x\n",ldrive,status);
-#endif /*DEBUGCMD*/
- busstat=inb(port+STATUS);
- }
- return(status);
-}
-
-
-/*---------------------------------------------------------------------------
- waitforit - Waits for a command started by slowcmd to complete.
----------------------------------------------------------------------------*/
-
-int waitforit(int timelimit, int state, int port, char * where)
-{
- int i,j;
-
- j=i=0;
-#ifdef DEBUGCMD
- printf("matcd: waitforit port %x timelimit %x hz %x\n",
- port,timelimit,hz);
-#endif /*DEBUGCMD*/
- while (i<timelimit) {
- j=inb(port+STATUS) & (STEN|DTEN); /*Read status*/
- if (j!=(STEN|DTEN)) break;
- tsleep((caddr_t)&nextcontroller, PRIBIO, where, hz/100);
- i++;
- }
-#ifdef DEBUGCMD
- printf("matcd: Count was %d\n",i);
-#endif /*DEBUGCMD*/
- if (j==state) return(0); /*Command complete*/
-#ifdef DEBUGCMD
- printf("matcd: Timeout!");
-#endif /*DEBUGCMD*/
- return(1); /*Timeout occurred*/
-}
-
-
-/*---------------------------------------------------------------------------
- lockbus - Wait for the bus on the requested driver interface
- to go idle and acquire it.
- Created in Edit 6
----------------------------------------------------------------------------*/
-
-void lockbus(int controller, int ldrive)
-{
- while ((if_state[controller] & BUSBUSY)) {
-#ifdef DEBUGSLEEP
- printf("matcd%d: Can't do it now - going to sleep\n",
- ldrive);
-#endif /*DEBUGSLEEP*/
- tsleep((caddr_t)&matcd_data->status, PRIBIO,
- "matlck", 0);
- }
- if_state[controller] |= BUSBUSY; /*<18>It's ours NOW*/
-#ifdef DEBUGSLEEP
- printf("matcd%d: BUS locked in lockbus\n",ldrive);
-#endif /*DEBUGSLEEP*/
-}
-
-
-/*---------------------------------------------------------------------------
- unlockbus - Release the host interface bus we already have so
- someone else can use it.
- Created in Edit 6
----------------------------------------------------------------------------*/
-
-void unlockbus(int controller, int ldrive)
-{
- if_state[controller] &= ~BUSBUSY;
-#ifdef DEBUGSLEEP
- printf("matcd%d: bus unlocked\n",ldrive);
-#endif /*DEBUGSLEEP*/
- wakeup((caddr_t)&matcd_data->status); /*Wakeup other users*/
- matcd_start(controller); /*Wake up any block I/O*/
-}
-
-
-/*---------------------------------------------------------------------------
- media_chk - Checks error for types related to media
- changes.
----------------------------------------------------------------------------*/
-
-int media_chk(struct matcd_data *cd,int errnum,int ldrive,int test)
-{
- if (errnum==NOT_READY ||
- errnum==MEDIA_CHANGED ||
- errnum==HARD_RESET ||
- errnum==DISC_OUT) {
- cd->flags &= ~MATCDLABEL; /*Mark label as invalid*/
- if (test==0) { /*<14>Do warn by default*/
-
- if ((cd->flags & MATCDWARN)==0) {/*<14>Msg already?*/
- printf("matcd%d: Media changed - Further I/O aborted until device closed\n",ldrive);
- cd->flags |= MATCDWARN;
- }
- }
- return(1);
- }
- if (errnum==MODE_ERROR) /*<16>Maybe the setting is*/
- cd->drivemode=MODE_UNKNOWN; /*<16>wrong so force a reset*/
- return(0);
-}
-
-
-/*---------------------------------------------------------------------------
- matcd_eject - Open drive tray
----------------------------------------------------------------------------*/
-
-int matcd_eject(int ldrive, int cdrive, int controller)
-{
- int i,port;
- struct matcd_data *cd;
- unsigned char cmd[MAXCMDSIZ];
-
- cd=&matcd_data[ldrive];
- port=cd->iobase; /*Get I/O port base*/
-
-#ifdef LOCKDRIVE
- if (cd->flags & MATCDLOCK) { /*<15>Drive was locked via open*/
- return(EINVAL); /*<15>so don't allow the eject*/
- }
-#endif /*LOCKDRIVE*/
- zero_cmd(cmd); /*Initialize command buffer*/
- cmd[0]=LOCK; /*Unlock drive*/
- i=docmd(cmd,ldrive,cdrive,controller,port); /*Issue command*/
- cmd[0]=DOOROPEN; /*Open Door*/
- i=docmd(cmd,ldrive,cdrive,controller,port); /*Issue command*/
- cd->flags &= ~(MATCDLABEL|MATCDLOCK); /*<15>Mark vol info invalid*/
- return(i); /*Return result we got*/
-}
-
-
-/*---------------------------------------------------------------------------
- matcd_doorclose - Close drive tray
-<16> Added in Edit 16
----------------------------------------------------------------------------*/
-
-int matcd_doorclose(int ldrive, int cdrive, int controller)
-{
- int i,port;
- struct matcd_data *cd;
- unsigned char cmd[MAXCMDSIZ];
-
- cd=&matcd_data[ldrive];
- port=cd->iobase; /*Get I/O port base*/
-
- zero_cmd(cmd); /*Initialize command buffer*/
- cmd[0]=DOORCLOSE; /*Open Door*/
- i=docmd(cmd,ldrive,cdrive,controller,port); /*Issue command*/
- cd->flags &= ~(MATCDLABEL|MATCDLOCK); /*Mark vol info invalid*/
- tsleep((caddr_t)&nextcontroller, PRIBIO, "matclos", hz);
- return(i); /*Return result we got*/
-}
-
-
-/*---------------------------------------------------------------------------
-<23> matcd_dlock - Honor/Reject drive tray requests
----------------------------------------------------------------------------*/
-
-int matcd_dlock(int ldrive, int cdrive, int controller, int action)
-{
- int i,port;
- struct matcd_data *cd;
- unsigned char cmd[MAXCMDSIZ];
-
- cd=&matcd_data[ldrive];
- port=cd->iobase; /*<23>Get I/O port base*/
-
- zero_cmd(cmd); /*<23>Initialize command buffer*/
- cmd[0]=LOCK; /*<23>Unlock drive*/
-
- if (action) { /*<23>They want to lock the door?*/
- cd->flags |= MATCDLOCK; /*<23>Remember we did this*/
- cmd[1]=1; /*<23>Lock Door command*/
- } else {
- cd->flags &= ~MATCDLOCK;/*<23>Remember we did this*/
- /*<23>Unlock Door command*/
- }
- i=docmd(cmd,ldrive,cdrive,controller,port); /*<23>Issue command*/
- return(i); /*<23>Return result we got*/
-}
-
-
-/*---------------------------------------------------------------------------
- matcd_toc_header - Return Table of Contents header to caller
-<13> New for Edit 13
----------------------------------------------------------------------------*/
-
-static int matcd_toc_header(int ldrive, int cdrive, int controller,
- struct ioc_toc_header * toc)
-{
- struct matcd_data *cd;
-
- cd=&matcd_data[ldrive];
- if ((cd->flags & MATCDLABEL)==0)
- return(EIO); /*Refuse after chg error*/
-
- toc->len=msf_to_blk(cd->volinfo.vol_msf); /*In frames*/
- toc->starting_track=cd->volinfo.trk_low; /*1*/
- toc->ending_track=cd->volinfo.trk_high; /*Last track*/
-
- return(0);
-
-}
-
-
-/*---------------------------------------------------------------------------
- matcd_toc_entries - Read all of the TOC entries
-
- These entries are cached by the drive, but it might be worth
- the space investment to have the driver cache these as well.
- For a disc with 40 tracks, it means 41 command calls to get
- this information from the drive.
-<13> New for Edit 13
----------------------------------------------------------------------------*/
-
-static int matcd_toc_entries(int ldrive, int cdrive, int controller,
- struct ioc_read_toc_entry * ioc_entry)
-{
- struct matcd_data *cd;
- struct cd_toc_entry entries[MAXTRKS];
- struct cd_toc_entry *from;
- struct cd_toc_entry *to;
- int len,trk,i,z,port;
- unsigned char cmd[MAXCMDSIZ];
- unsigned char data[8];
-
- cd=&matcd_data[ldrive];
- port=cd->iobase;
-
- if ((cd->flags & MATCDLABEL)==0)
- return(EIO); /*Refuse after chg error*/
-
- zero_cmd(cmd);
- cmd[0]=READTOC;
-
- for(trk=cd->volinfo.trk_low-1; trk<cd->volinfo.trk_high; trk++) {
- cmd[2]=trk+1;
- lockbus(controller, ldrive); /*Request bus*/
- matcd_slowcmd(port,ldrive,cdrive,cmd);
- i=waitforit(10*TICKRES,DTEN,port,"mats1");
- matcd_pread(port, 8, data); /*Read data returned*/
- z=get_stat(port,ldrive); /*Read status byte*/
- if ((z & MATCD_ST_ERROR)) { /*Something went wrong*/
- i=get_error(port, ldrive, cdrive);
- unlockbus(controller, ldrive); /*Release bus*/
- return(EIO);
- }
- unlockbus(controller, ldrive); /*Release bus*/
-
-#ifdef DEBUGIOCTL
- printf("Track %d addr/ctrl %x m %x s %x f %x\n",data[2],
- data[1],data[4],data[5],data[6]);
-#endif /*DEBUGIOCTL*/
-
- entries[trk].control=data[1]; /*Track type*/
- entries[trk].addr_type=ioc_entry->address_format;/*Type*/
- entries[trk].track=data[2]; /*Track #, can be Out of Order*/
- if (ioc_entry->address_format == CD_MSF_FORMAT) {
- entries[trk].addr.msf.unused=0;
- entries[trk].addr.msf.minute=data[4]; /*Min*/
- entries[trk].addr.msf.second=data[5]; /*Sec*/
- entries[trk].addr.msf.frame=data[6]; /*Frame*/
- }
- }
- entries[trk].control=data[2]; /*Copy from last valid track*/
- entries[trk].track=0xaa; /*<23>Lead-out*/
- entries[trk].addr.msf.unused=0; /*Fill*/
- entries[trk].addr.msf.minute=cd->volinfo.vol_msf[0];
- entries[trk].addr.msf.second=cd->volinfo.vol_msf[1];
- entries[trk].addr.msf.frame=cd->volinfo.vol_msf[2];
- trk++; /*Bump to include leadout track*/
-
-
-/* Now that we have read all the data from the drive, copy the
- array from the kernel address space into the user address space
-*/
-
- len=ioc_entry->data_len;
- i=ioc_entry->starting_track; /*<23>What did they want?*/
- if (i==0xaa) i=trk-1; /*<23>Give them lead-out info*/
- else i=ioc_entry->starting_track - 1; /*<23>start where they asked*/
- from = &entries[i];
- to = ioc_entry->data;
-
- while (i < trk && len >= sizeof(struct cd_toc_entry)) {
- if (copyout(from,to,sizeof(struct cd_toc_entry))
- != 0) {
- return (EFAULT);
- }
- i++;
- len -= sizeof(struct cd_toc_entry);
- from++;
- to++;
- }
- return(0);
-
-}
-
-/*---------------------------------------------------------------------------
- matcd_toc_entriy - Read a single TOC entry
----------------------------------------------------------------------------*/
-
-static int matcd_toc_entry(int ldrive, int cdrive, int controller,
- struct ioc_read_toc_single_entry * ioc_entry)
-{
- struct matcd_data *cd;
- int trk,origtrk,i,z,port;
- unsigned char cmd[MAXCMDSIZ];
- unsigned char data[5];
-
- cd=&matcd_data[ldrive];
- port=cd->iobase;
-
- if ((cd->flags & MATCDLABEL)==0)
- return(EIO); /*Refuse after chg error*/
-
- zero_cmd(cmd);
- cmd[0]=READTOC;
-
- origtrk=trk=ioc_entry->track;
- if (trk == 0xaa)
- /* leadout */
- trk=cd->volinfo.trk_high-1;
- cmd[2]=trk+1;
- lockbus(controller, ldrive); /*Request bus*/
- matcd_slowcmd(port,ldrive,cdrive,cmd);
- i=waitforit(10*TICKRES,DTEN,port,"mats1");
- matcd_pread(port, 8, data); /*Read data returned*/
- z=get_stat(port,ldrive); /*Read status byte*/
- if ((z & MATCD_ST_ERROR)) { /*Something went wrong*/
- i=get_error(port, ldrive, cdrive);
- unlockbus(controller, ldrive); /*Release bus*/
- return(EIO);
- }
- unlockbus(controller, ldrive); /*Release bus*/
-
-#ifdef DEBUGIOCTL
- printf("Track %d addr/ctrl %x m %x s %x f %x\n",data[2],
- data[1],data[4],data[5],data[6]);
-#endif /*DEBUGIOCTL*/
-
- ioc_entry->entry.control=data[1]; /*Track type*/
- ioc_entry->entry.addr_type=ioc_entry->address_format;/*Type*/
- ioc_entry->entry.track=data[2]; /*Track #, can be Out of Order*/
- if (ioc_entry->address_format == CD_MSF_FORMAT) {
- ioc_entry->entry.addr.msf.unused=0;
- ioc_entry->entry.addr.msf.minute=data[4]; /*Min*/
- ioc_entry->entry.addr.msf.second=data[5]; /*Sec*/
- ioc_entry->entry.addr.msf.frame=data[6]; /*Frame*/
- }
- if (origtrk == 0xaa) {
- /* Handle leadout */
- ioc_entry->entry.control=data[2]; /*Copy from last valid track*/
- ioc_entry->entry.track=0xaa; /*Lead-out*/
- ioc_entry->entry.addr.msf.unused=0; /*Fill*/
- ioc_entry->entry.addr.msf.minute=cd->volinfo.vol_msf[0];
- ioc_entry->entry.addr.msf.second=cd->volinfo.vol_msf[1];
- ioc_entry->entry.addr.msf.frame=cd->volinfo.vol_msf[2];
- }
- return(0);
-
-}
-
-/*---------------------------------------------------------------------------
- matcd_subq - Read the Sub-Q packet - (where are we?)
-
- This call gives a snapshot state of where the optical
- pick-up is when the command is issued.
-<14> New for Edit 14
----------------------------------------------------------------------------*/
-
-static int matcd_read_subq(int ldrive, int cdrive, int controller,
- struct ioc_read_subchannel * sqp)
-{
- struct matcd_data *cd;
- int i,z,port;
- unsigned char cmd[MAXCMDSIZ];
- unsigned char data[12];
- struct cd_sub_channel_info subq; /*Build result here*/
-
- cd=&matcd_data[ldrive];
- port=cd->iobase;
-
- if ((cd->flags & MATCDLABEL)==0)
- return(EIO); /*Refuse after chg error*/
-
-/* We only support the ioctl functions we could get information
- on, so test for the things we can do
-*/
-
- if (sqp->data_format!=CD_CURRENT_POSITION ||
- sqp->address_format!=CD_MSF_FORMAT) {
- return(EINVAL);
- }
-
- zero_cmd(cmd);
- cmd[0]=READSUBQ;
- lockbus(controller, ldrive); /*Request bus*/
- matcd_slowcmd(port,ldrive,cdrive,cmd);
-
-/* While we wait, fill in the hard-coded entries of the table*/
-
- subq.what.position.data_format=CD_MSF_FORMAT;
- subq.what.position.absaddr.msf.unused=0;
- subq.what.position.reladdr.msf.unused=0;
-
- i=waitforit(10*TICKRES,DTEN,port,"mats2");
- matcd_pread(port, 11, data); /*Read data returned*/
- z=get_stat(port,ldrive); /*Read status byte*/
- if ((z & MATCD_ST_ERROR)) { /*Something went wrong*/
- i=get_error(port, ldrive, cdrive);
- unlockbus(controller, ldrive); /*Release bus*/
- return(EIO);
- }
- unlockbus(controller, ldrive); /*Release bus*/
-
-#ifdef DEBUGIOCTL
- printf("Subq track %d index %d adr/ctl %x abs %d:%2d:%2d rel %d:%2d:%2d UPC %x\n",
- data[2],data[3],data[1],data[4],data[5],data[6],
- data[7],data[8],data[9],data[10]);
-#endif /*DEBUGIOCTL*/
-
- if (z & MATCD_ST_AUDIOBSY) { /*Drive playing or paused*/
- if (cd->status==CD_AS_PLAY_PAUSED) { /*Have we issued*/
- i=cd->status; /*a pause command?*/
- } else {
- i=CD_AS_PLAY_IN_PROGRESS;/*No, we really are playing*/
- }
- } else {
- if (cd->status==CD_AS_PLAY_IN_PROGRESS) {/*It was playing*/
- i=CD_AS_PLAY_COMPLETED; /*so it finished*/
- } else { /*Any other status reported*/
- i=cd->status; /*as we get it*/
- }
- }
-
- subq.header.audio_status=cd->status=i; /*Store status we selected*/
-
- subq.what.position.track_number=data[2];
- subq.what.position.index_number=data[3];
-
- subq.what.position.absaddr.msf.minute=data[4];
- subq.what.position.absaddr.msf.second=data[5];
- subq.what.position.absaddr.msf.frame=data[6];
-
- subq.what.position.reladdr.msf.minute=data[7];
- subq.what.position.reladdr.msf.second=data[8];
- subq.what.position.reladdr.msf.frame=data[9];
-
-/* Ok, now copy our nicely-built structure from the kernel address
- space into the user address space (we hope)
-*/
-
- if (copyout(&subq, sqp->data,
- min(sizeof(struct cd_sub_channel_info), sqp->data_len))!=0) {
- return(EFAULT);
- }
- return(0);
-}
-
-/*---------------------------------------------------------------------------
- matcd_igot - Like the song, report the capabilities that the
- drive/driver has available.
-
- This call returns a structure of flags indicating what
- functions are available so that the application can offer
- only the functions the drive is actually capable of.
-<16> New for Edit 16
----------------------------------------------------------------------------*/
-
-static int matcd_igot(struct ioc_capability * sqp)
-{
-
-#ifdef FULLDRIVER
- sqp->play_function=(CDDOPLAYTRK | /*Can play trks/indx*/
- CDDOPLAYMSF | /*Can play msf to msf*/
- CDDOPAUSE | /*Can pause playback*/
- CDDORESUME | /*Can resume playback*/
- CDDOSTOP | /*Can stop playback*/
- CDDOPITCH); /*Can change play pitch*/
-
- sqp->routing_function=(CDREADVOLUME | /*Can read volume*/
- CDSETVOLUME | /*Can set volume*/
- CDSETSTEREO | /*Can select stereo play*/
- CDSETLEFT | /*Can select left-only*/
- CDSETRIGHT | /*Can select right-only*/
- CDSETMUTE | /*Can mute audio*/
- CDSETPATCH); /*Direct patch settings*/
-#else /*FULLDRIVER*/
- sqp->play_function=0; /*No audio capability*/
- sqp->routing_function=0; /*No audio capability*/
-#endif /*FULLDRIVER*/
-
- sqp->special_function=(CDDOEJECT | /*Door can be opened*/
- CDDOCLOSE | /*Door can be closed*/
- CDDOLOCK | /*Door can be locked*/
- CDREADSUBQ | /*Can read subchannel*/
- CDREADENTRIES | /*Can read TOC entries*/
- CDREADHEADER); /*Can read TOC*/
- return(0);
-}
-
-
-#ifdef FULLDRIVER
-#include <i386/isa/matcd/audio.c> /*<15>ioctls related to
- audio are here*/
-#endif /*FULLDRIVER*/
-
-/*End of matcd.c*/
-
-#endif /* GEOM */
diff --git a/sys/i386/isa/matcd/matcddrv.h b/sys/i386/isa/matcd/matcddrv.h
deleted file mode 100644
index 8802149..0000000
--- a/sys/i386/isa/matcd/matcddrv.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/*matcd.h---------------------------------------------------------------------
-
- Matsushita(Panasonic) / Creative CD-ROM Driver (matcd)
- Authored by Frank Durda IV
-
- Copyright 1994, 1995 Frank Durda IV. All rights reserved.
- "FDIV" is a trademark of Frank Durda IV.
-
-
- Redistribution and use in source and binary forms, with or
- without modification, are permitted provided that the following
- conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice positioned at the very beginning of this file without
- modification, all copyright strings, all related programming
- codes that display the copyright strings, this list of
- conditions and the following disclaimer.
- 2. Redistributions in binary form must contain all copyright strings
- and related programming code that display the copyright strings.
- 3. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- 4. All advertising materials mentioning features or use of this
- software must display the following acknowledgement:
- "The Matsushita/Panasonic CD-ROM driver was developed
- by Frank Durda IV for use with "FreeBSD" and similar
- operating systems."
- "Similar operating systems" includes mainly non-profit oriented
- systems for research and education, including but not restricted
- to "NetBSD", "386BSD", and "Mach" (by CMU). The wording of the
- acknowledgement (in electronic form or printed text) may not be
- changed without permission from the author.
- 5. Absolutely no warranty of function, fitness or purpose is made
- by the author Frank Durda IV.
- 6. Neither the name of the author nor the name "FreeBSD" may
- be used to endorse or promote products derived from this software
- without specific prior written permission.
- (The author can be reached at bsdmail@nemesis.lonestar.org)
- 7. The product containing this software must meet all of these
- conditions even if it is unsupported, not a complete system
- and/or does not contain compiled code.
- 8. These conditions will be in force for the full life of the
- copyright.
- 9. If all the above conditions are met, modifications to other
- parts of this file may be freely made, although any person
- or persons making changes do not receive the right to add their
- name or names to the copyright strings and notices in this
- software. Persons making changes are encouraged to insert edit
- history in matcd.c and to put your name and details of the
- change there.
- 10. You must have prior written permission from the author to
- deviate from these terms.
-
- Vendors who produce product(s) containing this code are encouraged
- (but not required) to provide copies of the finished product(s) to
- the author and to correspond with the author about development
- activity relating to this code. Donations of development hardware
- and/or software are also welcome. (This is one of the faster ways
- to get a driver developed for a device.)
-
- THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER(S) BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
------No changes are allowed above this line------------------------------------
-
-See matcd.c for Edit History information.
-
-
- Matsushita CR562/CR563 Commands
- This is not a complete list - just the ones this version uses
-*/
-
-#define NOP 0x05 /*No action - just return status*/
-#define DOOROPEN 0x06 /*Open tray*/
-#define DOORCLOSE 0x07 /*Close tray*/
-#define ABORT 0x08 /*Abort command*/
-#define MODESELECT 0x09 /*Set drive parameters*/
-#define LOCK 0x0c /*Prevent/Allow medium removal*/
-#define PAUSE 0x0d /*Pause/Resume playback*/
-#define PLAYBLOCKS 0x0e /*Play audio - block to block*/
-#define PLAYTRKS 0x0f /*Play audio - tracks & index*/
-#define READ 0x10 /*Read data*/
-#define READERROR 0x82 /*Read Error*/
-#define READID 0x83 /*Read Drive Type & Firmware Info*/
-#define MODESENSE 0x84 /*<12>Report drive settings*/
-#define READSUBQ 0x87 /*<14>Read Q channel information*/
-#define READDINFO 0x8b /*<13>Read TOC tracks & drive size*/
-#define READTOC 0x8c /*<13>Read entry from TOC*/
-
-#define BLOCKPARAM 0x00 /*Used with MODESELECT command*/
-#define SPEEDPARM 0x03 /*<12>Adjust audio playback speed*/
-#define AUDIOPARM 0x05 /*<12>Set/read audio levels & routing*/
-#define RESUME 0x80 /*Used with PAUSE command*/
-
-#define MAXCMDSIZ 12 /*Max command size with NULL*/
-
-/* Possible data transfers for MODESELECT + BLOCKPARAM */
-
-#define MODE_DATA 0x00 /*2048, 2340*/
-#define MODE_DA 0x82 /*2352*/
-#define MODE_USER 0x01 /*2048, 2052, 2336, 2340, 2352*/
-#define MODE_UNKNOWN 0xff /*Uninitialized state*/
-
-/*<12>The following mode is not implemented in the driver at this time*/
-
-#define MODE_XA 0x81 /*2048, 2060, 2324, 2336, 2340, 2352*/
-
-#define DEFVOL 0xff /*<12>Default drive volume level, 100%
- volume. Based on drive action.*/
-#define OUTLEFT 0x01 /*Output on Left*/
-#define OUTRIGHT 0x02 /*Output on Right*/
-
-/* Matsushita CR562/CR563 Status bits*/
-
-#define MATCD_ST_DOOROPEN 0x80 /*Door is open right now*/
-#define MATCD_ST_DSKIN 0x40 /*Disc in drive*/
-#define MATCD_ST_SPIN 0x20 /*Disc is spinning*/
-#define MATCD_ST_ERROR 0x10 /*Error on command*/
-#define MATCD_ST_AUDIOBSY 0x08 /*Drive is playing audio*/
-#define MATCD_ST_LOCK 0x04 /*<14>Drive is locked*/
-#define MATCD_ST_X2 0x02 /*<14>Media is at double-speed*/
-#define MATCD_ST_READY 0x01 /*<14>Drive is ready*/
-
-#define MATCDAUDIOBSY MATCD_ST_AUDIOBSY
-#define MATCDDSKCHNG MATCD_ST_DSKCHNG
-#define MATCDDSKIN MATCD_ST_DSKIN
-#define MATCDDOOROPEN MATCD_ST_DOOROPEN
-
-
-/* Error codes returned from READERROR command.*/
-
-#define NO_ERROR 0x00
-#define RECV_RETRY 0x01
-#define RECV_ECC 0x02
-#define NOT_READY 0x03
-#define TOC_ERROR 0x04
-#define UNRECV_ERROR 0x05
-#define SEEK_ERROR 0x06
-#define TRACK_ERROR 0x07
-#define RAM_ERROR 0x08
-#define DIAG_ERROR 0x09
-#define FOCUS_ERROR 0x0a
-#define CLV_ERROR 0x0b
-#define DATA_ERROR 0x0c
-#define ADDRESS_ERROR 0x0d
-#define CDB_ERROR 0x0e
-#define END_ADDRESS 0x0f
-#define MODE_ERROR 0x10
-#define MEDIA_CHANGED 0x11
-#define HARD_RESET 0x12
-#define ROM_ERROR 0x13
-#define CMD_ERROR 0x14
-#define DISC_OUT 0x15
-#define HARD_ERROR 0x16
-#define ILLEGAL_REQ 0x17
-
-
-/* Human-readable error messages - what a concept!*/
-
-static unsigned char * matcderrors[]={"No error", /* 00 */
- "Soft read error after retry", /* 01 */
- "Soft read error after error-correction", /* 02 */
- "Not ready", /* 03 */
- "Unable to read TOC", /* 04 */
- "Hard read error of data track",/* 05 */
- "Seek did not complete", /* 06 */
- "Tracking servo failure", /* 07 */
- "Drive RAM failure", /* 08 */
- "Drive self-test failed", /* 09 */
- "Focusing servo failure", /* 0a */
- "Spindle servo failure", /* 0b */
- "Data path failure", /* 0c */
- "Illegal logical block address",/* 0d */
- "Illegal field in CDB", /* 0e */
- "End of user encountered on this track", /* 0f */
- "Illegal data mode for this track", /* 10 */
- "Media changed", /* 11 */
- "Power-on or drive reset occurred", /* 12 */
- "Drive ROM failure", /* 13 */
- "Illegal drive command received from host",/* 14 */
- "Disc removed during operation",/* 15 */
- "Drive Hardware error", /* 16 */
- "Illegal request from host"}; /* 17 */
-
-/*End of matcd.h*/
-
-
diff --git a/sys/i386/isa/matcd/options.h b/sys/i386/isa/matcd/options.h
deleted file mode 100644
index 3fde880..0000000
--- a/sys/i386/isa/matcd/options.h
+++ /dev/null
@@ -1,283 +0,0 @@
-/*options.h--------------------------------------------------------------------
-
- Matsushita(Panasonic) / Creative CD-ROM Driver (matcd)
- Authored by Frank Durda IV
-
- Copyright 1994, 1995 Frank Durda IV. All rights reserved.
- "FDIV" is a trademark of Frank Durda IV.
-
-
- Redistribution and use in source and binary forms, with or
- without modification, are permitted provided that the following
- conditions are met:
- 1. Redistributions of source code must retain the above copyright
- notice positioned at the very beginning of this file without
- modification, all copyright strings, all related programming
- codes that display the copyright strings, this list of
- conditions and the following disclaimer.
- 2. Redistributions in binary form must contain all copyright strings
- and related programming code that display the copyright strings.
- 3. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- 4. All advertising materials mentioning features or use of this
- software must display the following acknowledgement:
- "The Matsushita/Panasonic CD-ROM driver was developed
- by Frank Durda IV for use with "FreeBSD" and similar
- operating systems."
- "Similar operating systems" includes mainly non-profit oriented
- systems for research and education, including but not restricted
- to "NetBSD", "386BSD", and "Mach" (by CMU). The wording of the
- acknowledgement (in electronic form or printed text) may not be
- changed without permission from the author.
- 5. Absolutely no warranty of function, fitness or purpose is made
- by the author Frank Durda IV.
- 6. Neither the name of the author nor the name "FreeBSD" may
- be used to endorse or promote products derived from this software
- without specific prior written permission.
- (The author can be reached at bsdmail@nemesis.lonestar.org)
- 7. The product containing this software must meet all of these
- conditions even if it is unsupported, not a complete system
- and/or does not contain compiled code.
- 8. These conditions will be in force for the full life of the
- copyright.
- 9. If all the above conditions are met, modifications to other
- parts of this file may be freely made, although any person
- or persons making changes do not receive the right to add their
- name or names to the copyright strings and notices in this
- software. Persons making changes are encouraged to insert edit
- history in matcd.c and to put your name and details of the
- change there.
- 10. You must have prior written permission from the author to
- deviate from these terms.
-
- Vendors who produce product(s) containing this code are encouraged
- (but not required) to provide copies of the finished product(s) to
- the author and to correspond with the author about development
- activity relating to this code. Donations of development hardware
- and/or software are also welcome. (This is one of the faster ways
- to get a driver developed for a device.)
-
- THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER(S) BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
------No changes are allowed above this line------------------------------------
------------------------------------------------------------------------------
- Conditional compilation flags - change to suit your system
----------------------------------------------------------------------------*/
-
-/* AUTOHUNT Adds extra code that allows the driver to search
- for interface cards rather than having to hard-code
- the locations in the kernel conf file.
- Leaving AUTOHUNT enabled is the recommended setting.
-*/
-
-#define AUTOHUNT
-
-
-/* NUMCTRLRS Configures support for between one and four
- host interfaces, for up to 16 drives.
- The number of entries in the kernel config
- file is used by default, but this may be changed
- to a specific value if desired.
-
- Leaving NUMCTRLRS based on NMATCD is the
- recommended setting.
-*/
-
-#if NMATCD >= 4
-#define NUMCTRLRS 4 /*Limit driver to four host interfaces*/
-#else /*NMATCD*/
-#define NUMCTRLRS NMATCD
-#endif /*NMATCD*/
-
-
-/* FULLDRIVER If not set, the audio, non-data functions and
- some error recovery functions are eliminated from
- the compiled driver. The resulting driver will be
- smaller and may help a kernel fit on a boot floppy.
- Leaving FULLDRIVER enabled is the recommended setting.
-*/
-
-#ifndef BOOTMFS
-#define FULLDRIVER
-#endif /*BOOTMFS*/
-
-
-/* RESETONBOOT causes the driver to reset the drive(s) to be
- reset during probing. This causes any audio
- playback to be aborted and the drives will close
- their trays if they are open.
- Leaving RESETONBOOT enabled is the recommended setting.
-*/
-
-#define RESETONBOOT
-
-
-/*<15> LOCKDRIVE If enabled, when a drive is opened using a
-<15> minor number greater than 127, the drive door is
-<15> locked. The drive door remains locked until all
-<23> partitions on the drive are closed. The EJECT,
-<23> ALLOW and PREVENT ioctls are refused when this locking
-<23> mechanism is active.
-<15> The additional code size is small so enabling
-<15> LOCKDRIVE is the recommended setting.
-*/
-
-#define LOCKDRIVE
-
-
-/*<14> KRYTEN This enables a bug that someone might consider
-<14> to be a feature. If KRYTEN is enabled and you are
-<14> playing audio and you issue the resume-play ioctl,
-<14> the audio will stutter, playing the same quarter
-<14> of a second or so of audio several times before
-<14> resuming normally. Resuming from a pause acts
-<14> normally regardless of the setting of this flag.
-<14> Leaving KRYTEN disabled is the recommended setting.
-<14>*/
-
-/*#define KRYTEN*/
-
-
-/*---------------------------------------------------------------------------
- This structure contains the hints for where we should look for the
- host adapter. If you want to change where we search or reduce the
- places we search to avoid confusing some other device, either
- specify explicit addresses in the kernel config file (preferred)
- or change this array.
-
- If the kernel config file has multiple ? entries, the probe routines
- will use this table multiple times and will eliminate each failed
- entry that probe tries.
-
- WARNING: The number of controller entries for this driver in config
- must be less than or equal to the number of hints if hints are used.
-
- If you add entries to the table, add them immediately before
- the -1 end-of-table marker. The values already present are
- the ones used by Creative Labs boards and those of a few
- other vendors.
-
- Each additional entry increases the boot time by four seconds,
- and can increase the chance of accessing some other device.
- Therefore, the list should be kept to a minimum. Once the
- devices have been correctly located, the kernel should be
- configured so that it looks only at the correct location from
- that point on.
-
- Be sure to search devices located below 0x3ff BEFORE scanning
- higher locations. Some boards don't decode all I/O address lines,
- so 0x230 and 0x630 appear identical.
----------------------------------------------------------------------------*/
-
-#ifdef AUTOHUNT
-static int port_hints[]={
-#ifdef PC98
- 0x30d2,
- 0x30d0,
- 0x30d4,
- 0x30d6,
- 0x30d8,
- 0x30da,
- 0x30dc,
- 0x30de,
-#else /* IBM-PC */
- 0x230, /*SB Pro & SB16*/
- 0x240, /*SB Pro & SB16*/
- 0x250, /*Creative omniCD standalone boards*/
- 0x260, /*Creative omniCD standalone boards*/
- 0x340, /*Laser Mate*/
- 0x360, /*Laser Mate*/
- 0x630, /*IBM*/
-#if 0
-/* These locations are alternate settings for LaserMate and IBM
- boards, but they usually conflict with network and SCSI cards.
- I recommend against probing these randomly.
-*/
- 0x310, /*Laser Mate*/
- 0x320, /*Laser Mate*/
- 0x330, /*Laser Mate*/
- 0x350, /*Laser Mate*/
- 0x370, /*Laser Mate*/
- 0x650, /*IBM*/
- 0x670, /*IBM*/
- 0x690, /*IBM*/
-#endif /*0*/
-#endif /* PC98 */
- -1}; /*use. Table MUST end with -1*/
-#endif /*AUTOHUNT*/
-
-
-/*---------------------------------------------------------------------------
- Debugging flags - Turn these on only if you are looking at a
- problem.
----------------------------------------------------------------------------*/
-
-/* DEBUGOPEN If enabled, debug messages for open and close
- operations.
-*/
-
-/*#define DEBUGOPEN*/
-
-
-/* DEBUGIO If enabled, reports on calls to strategy, start
- and other I/O related functions.
-*/
-
-/*#define DEBUGIO*/
-
-
-/* DEBUGQUEUE If enabled, shows activity on disk request queues.
- Warning - This debug is VERY VERY NOISY and will
- loop endlessly if queues are not null terminated
- as they should be.
-*/
-
-/*#define DEBUGQUEUE*/
-
-
-/* DEBUGCMD If enabled, shows the actual commands being issued
- to the CD-ROM drives.
-*/
-
-/*#define DEBUGCMD*/
-
-
-/* DEBUGSLEEP If enabled, reports on timeouts, wakeups, dropped
- threads, etc.
-*/
-
-/*#define DEBUGSLEEP*/
-
-
-/* DEBUGIOCTL If enabled, reports on the various ioctl-related
- calls and operations. You might have to enable
- DEBUGCMD as well to get enough debugging information.
-*/
-
-/*#define DEBUGIOCTL*/
-
-
-/* DEBUGPROBE If enabled, reports on the process of locating
- adapters and drives. The debugging in matcdprobe()
- and matcdattach() routines is enabled with this
- flag.
-*/
-
-/*#define DEBUGPROBE*/
-
-
-/*End of options.h*/
-
OpenPOWER on IntegriCloud