This is the new submission of the matcd driver. In addition to the

new driver code, there are diffs to several other existing files
on the system and a man page.

This version of matcd implements the rest of the key ioctls related to
playing audio CDs and reading table of contents information from any
type of disc.

This update also corrects several problems detected since the original
version 1(10) was released.  These include:
1.	Jordons report on the kernel -c string problem.
2.	A problem with the driver being confused by other types of
	devices located at addresses it probes.
3.	An old CD TOC wouldn't always be cleared after a disc change.
4.	Cleaned up code so -Wall yields no warnings on 2.0 and later.
5.	A problem with drive getting out of sync with the driver when
	changing between CD-Data and CD-DA.

There have only been two reports from the field relating to problems
so either the first release isn't really being used or doesn't have
many problems.

If there are any problems with this submission, please let me know.

Submitted by:	Frank Durda IV <uhclem%nemesis@fw.ast.com>
This commit is contained in:
Jordan K. Hubbard 1995-04-09 15:50:27 +00:00
parent 83376d5b95
commit 08d5844ce1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=7717
9 changed files with 3742 additions and 18 deletions

View file

@ -1,7 +1,7 @@
# This file tells config what files go into building a kernel,
# files marked standard are always included.
#
# $Id: files.i386,v 1.92 1995/03/27 19:39:45 ache Exp $
# $Id: files.i386,v 1.93 1995/04/08 09:36:04 phk Exp $
#
aic7xxx optional ahc device-driver \
dependency "$S/gnu/misc/aic7xxx/aic7xxx.c" \
@ -93,7 +93,7 @@ i386/isa/mse.c optional mse device-driver
i386/isa/ncr5380.c optional nca device-driver
i386/isa/npx.c optional npx device-driver
i386/isa/pcaudio.c optional pca device-driver
i386/isa/matcd.c optional matcd device-driver
i386/isa/matcd/matcd.c optional matcd device-driver
i386/isa/pcibus.c optional pci device-driver
i386/isa/pcic.c optional ze device-driver
i386/isa/pcic.c optional zp device-driver

View file

@ -1,7 +1,7 @@
# This file tells config what files go into building a kernel,
# files marked standard are always included.
#
# $Id: files.i386,v 1.92 1995/03/27 19:39:45 ache Exp $
# $Id: files.i386,v 1.93 1995/04/08 09:36:04 phk Exp $
#
aic7xxx optional ahc device-driver \
dependency "$S/gnu/misc/aic7xxx/aic7xxx.c" \
@ -93,7 +93,7 @@ i386/isa/mse.c optional mse device-driver
i386/isa/ncr5380.c optional nca device-driver
i386/isa/npx.c optional npx device-driver
i386/isa/pcaudio.c optional pca device-driver
i386/isa/matcd.c optional matcd device-driver
i386/isa/matcd/matcd.c optional matcd device-driver
i386/isa/pcibus.c optional pci device-driver
i386/isa/pcic.c optional ze device-driver
i386/isa/pcic.c optional zp device-driver

View file

@ -42,7 +42,7 @@
* SUCH DAMAGE.
*
* from: @(#)conf.c 5.8 (Berkeley) 5/12/91
* $Id: conf.c,v 1.79 1995/03/28 07:54:54 bde Exp $
* $Id: conf.c,v 1.80 1995/03/28 18:18:31 sos Exp $
*/
#include <sys/param.h>
@ -244,20 +244,20 @@ d_psize_t scdsize;
#include "matcd.h"
#if NMATCD > 0
d_open_t matcdopen;
d_close_t matcdclose;
d_strategy_t matcdstrategy;
d_ioctl_t matcdioctl;
d_dump_t matcddump;
d_psize_t matcdsize;
#define matcddump nxdump
d_open_t matcdopen;
d_close_t matcdclose;
d_strategy_t matcdstrategy;
d_ioctl_t matcdioctl;
d_dump_t matcddump;
d_psize_t matcdsize;
#define matcddump nxdump
#else
#define matcdopen nxopen
#define matcdclose nxclose
#define matcdstrategy nxstrategy
#define matcdioctl nxioctl
#define matcddump nxdump
#define matcdsize (d_psize_t *)0
#define matcdopen nxopen
#define matcdclose nxclose
#define matcdstrategy nxstrategy
#define matcdioctl nxioctl
#define matcddump nxdump
#define matcdsize (d_psize_t *)0
#endif
#include "ata.h"

50
sys/i386/isa/matcd/TODO Normal file
View file

@ -0,0 +1,50 @@
Things to do for the matcd driver 6-Apr-95
1. Just as I was finishing Edit 16, I discovered that there
may be a way to cause a drive to go "offline", allowing the host
to send a command to one or more other drives on the same
interface, similar to the SCSI disconnect mechanism. The changes
to the driver to take advantage of this aren't huge, but will have
to wait until after 2.1. Too much risk of breaking something.
Unless you have multiple drives, you won't see a difference.
2. 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.
3. 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.
4. 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.
5. 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.
6. 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.
7. 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

514
sys/i386/isa/matcd/audio.c Normal file
View file

@ -0,0 +1,514 @@
/*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,"sense"); /*<14>*/
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, int 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,"sense");
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,
int 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*/

View file

@ -0,0 +1,134 @@
/*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*/
#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 SELECT 3 /*Write - drive select*/
/* 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*/

2557
sys/i386/isa/matcd/matcd.c Normal file

File diff suppressed because it is too large Load diff

198
sys/i386/isa/matcd/matcd.h Normal file
View file

@ -0,0 +1,198 @@
/*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*/

View file

@ -0,0 +1,271 @@
/*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
/* FULLCONFIG Allows up to four host interface boards for a
total of 16 drives. If disabled, only a single
host interface (of any type) is allowed. The
additional driver size is insignificant.
Leaving FULLCONFIG enabled is the recommended setting.
*/
#define FULLCONFIG
/* 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.
*/
#define FULLDRIVER
/* 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
<15> partitions on the drive are closed. The EJECT
<15> ioctl is also refused when this locking mechanism
<15> is active.
<15> The additional code size is small so enabling
<15> LOCKDRIVE is the recommended setting.
*/
#define LOCKDRIVE
/*<5> FREE2 If enabled, the changes are inserted so this
<5> module will compile in the world of FreeBSD 2.x.
<5> Without this, it is known to work in
<14> FreeBSD 1.1.5.1. FREE2 should be set automatically
<14> by using the system version compile symbol below.
<5>*/
#if __FreeBSD__ >= 2
#define FREE2 /*<5>Correct setting for 2.x*/
#endif /*__FreeBSD__*/
/*<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 found on standard SoundBlaster 16 and standalone cards.
---------------------------------------------------------------------------*/
#ifdef AUTOHUNT
int port_hints[]={
0x230,0x240, /*Ports SB audio boards can use*/
0x250,0x260, /*Ports standalone CD/IF board can*/
-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*/
/* DIAGPORT If enabled, additional code is added to send
debugging state to a debug port. This should
not be enabled in production. The value
can be set to 0x80 or 0x302, depending on what
type of debugging board you own. The global variable
diagloop is used to make looping reports on these
devices.
Some other drivers (and possibly the kernel) fiddle
with the 0x80 debug port, so it may not be usable
for isolating failures that result in a kernel panic.
The 0x302 debug board is recommended in these cases.
It also displays a word of data, so you get more
detail.
<10> It was discovered the 0x302 board was getting set
<10> into a strange state by the probes for other
<10> devices. To resolve this, the display control port
<10> (0x300) is reset in our probe and open routines.
<10> DO NOT use DIAGPORT 0x302 if an adapter is present
<10> at that address. It could ruin the EEPROM settings
<10> on the device.
*/
/*#define DIAGPORT 0x80*/
/*#define DIAGPORT 0x302*/
/*End of options.h*/