1993-10-12 06:08:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright 1993 by Holger Veit (data part)
|
|
|
|
* Copyright 1993 by Brian Moore (audio part)
|
1994-02-22 08:44:31 +00:00
|
|
|
* Changes Copyright 1993 by Gary Clark II
|
1995-02-22 01:11:36 +00:00
|
|
|
* Changes Copyright (C) 1994-1995 by Andrey A. Chernov, Moscow, Russia
|
1994-02-22 08:44:31 +00:00
|
|
|
*
|
|
|
|
* Rewrote probe routine to work on newer Mitsumi drives.
|
|
|
|
* Additional changes (C) 1994 by Jordan K. Hubbard
|
|
|
|
*
|
1993-10-12 06:08:31 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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, this list of conditions and the following disclaimer.
|
|
|
|
* 2. 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.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This software was developed by Holger Veit and Brian Moore
|
1994-02-22 08:44:31 +00:00
|
|
|
* for use with "386BSD" and similar operating systems.
|
1993-10-12 06:08:31 +00:00
|
|
|
* "Similar operating systems" includes mainly non-profit oriented
|
|
|
|
* systems for research and education, including but not restricted to
|
|
|
|
* "NetBSD", "FreeBSD", "Mach" (by CMU).
|
|
|
|
* 4. Neither the name of the developer(s) nor the name "386BSD"
|
|
|
|
* may be used to endorse or promote products derived from this
|
|
|
|
* software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
2003-08-24 17:55:58 +00:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
1996-06-12 05:11:41 +00:00
|
|
|
static const char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";
|
1993-10-12 06:08:31 +00:00
|
|
|
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2000-05-28 13:40:48 +00:00
|
|
|
#include <sys/kernel.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <sys/conf.h>
|
1997-03-23 03:37:54 +00:00
|
|
|
#include <sys/fcntl.h>
|
2000-05-05 09:59:14 +00:00
|
|
|
#include <sys/bio.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <sys/cdio.h>
|
2002-10-06 00:19:38 +00:00
|
|
|
#include <sys/disk.h>
|
2000-05-28 13:40:48 +00:00
|
|
|
#include <sys/bus.h>
|
1994-10-23 21:28:03 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
#include <machine/bus_pio.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <sys/rman.h>
|
1995-03-28 07:58:53 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
#include <isa/isavar.h>
|
|
|
|
|
|
|
|
#include <dev/mcd/mcdreg.h>
|
|
|
|
#include <dev/mcd/mcdvar.h>
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2003-05-31 18:21:40 +00:00
|
|
|
#define MCD_TRACE(format, args...) \
|
1995-05-09 11:39:40 +00:00
|
|
|
{ \
|
2002-10-04 07:14:19 +00:00
|
|
|
if (sc->debug) { \
|
|
|
|
device_printf(sc->dev, "status=0x%02x: ", \
|
|
|
|
sc->data.status); \
|
1995-05-09 11:39:40 +00:00
|
|
|
printf(format, ## args); \
|
|
|
|
} \
|
|
|
|
}
|
1993-10-12 06:08:31 +00:00
|
|
|
|
1994-08-29 21:19:27 +00:00
|
|
|
#define RAW_PART 2
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
/* flags */
|
1996-03-17 13:33:42 +00:00
|
|
|
#define MCDVALID 0x0001 /* parameters loaded */
|
|
|
|
#define MCDINIT 0x0002 /* device is init'd */
|
|
|
|
#define MCDNEWMODEL 0x0004 /* device is new model */
|
|
|
|
#define MCDLABEL 0x0008 /* label is read */
|
|
|
|
#define MCDPROBING 0x0010 /* probing */
|
|
|
|
#define MCDREADRAW 0x0020 /* read raw mode (2352 bytes) */
|
|
|
|
#define MCDVOLINFO 0x0040 /* already read volinfo */
|
|
|
|
#define MCDTOC 0x0080 /* already read toc */
|
|
|
|
#define MCDMBXBSY 0x0100 /* local mbx is busy */
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
/* status */
|
|
|
|
#define MCDAUDIOBSY MCD_ST_AUDIOBSY /* playing audio */
|
|
|
|
#define MCDDSKCHNG MCD_ST_DSKCHNG /* sensed change of disk */
|
|
|
|
#define MCDDSKIN MCD_ST_DSKIN /* sensed disk in drive */
|
|
|
|
#define MCDDOOROPEN MCD_ST_DOOROPEN /* sensed door open */
|
|
|
|
|
1994-03-06 14:14:49 +00:00
|
|
|
/* These are apparently the different states a mitsumi can get up to */
|
|
|
|
#define MCDCDABSENT 0x0030
|
|
|
|
#define MCDCDPRESENT 0x0020
|
|
|
|
#define MCDSCLOSED 0x0080
|
|
|
|
#define MCDSOPEN 0x00a0
|
1994-03-05 03:54:19 +00:00
|
|
|
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
#define MCD_MD_UNKNOWN (-1)
|
|
|
|
|
1994-11-14 19:25:43 +00:00
|
|
|
#define MCD_TYPE_UNKNOWN 0
|
|
|
|
#define MCD_TYPE_LU002S 1
|
|
|
|
#define MCD_TYPE_LU005S 2
|
1996-02-03 00:06:49 +00:00
|
|
|
#define MCD_TYPE_LU006S 3
|
|
|
|
#define MCD_TYPE_FX001 4
|
|
|
|
#define MCD_TYPE_FX001D 5
|
1994-11-14 19:25:43 +00:00
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
/* reader state machine */
|
|
|
|
#define MCD_S_BEGIN 0
|
|
|
|
#define MCD_S_BEGIN1 1
|
|
|
|
#define MCD_S_WAITSTAT 2
|
|
|
|
#define MCD_S_WAITMODE 3
|
|
|
|
#define MCD_S_WAITREAD 4
|
|
|
|
|
|
|
|
/* prototypes */
|
2002-10-04 07:14:19 +00:00
|
|
|
static void mcd_start(struct mcd_softc *);
|
1995-10-28 15:39:31 +00:00
|
|
|
#ifdef NOTYET
|
2002-10-04 07:14:19 +00:00
|
|
|
static void mcd_configure(struct mcd_softc *sc);
|
1995-10-28 15:39:31 +00:00
|
|
|
#endif
|
2002-10-04 07:14:19 +00:00
|
|
|
static int mcd_get(struct mcd_softc *, char *buf, int nmax);
|
|
|
|
static int mcd_setflags(struct mcd_softc *);
|
|
|
|
static int mcd_getstat(struct mcd_softc *,int sflg);
|
|
|
|
static int mcd_send(struct mcd_softc *, int cmd,int nretrys);
|
|
|
|
static void hsg2msf(int hsg, bcd_t *msf);
|
|
|
|
static int msf2hsg(bcd_t *msf, int relative);
|
|
|
|
static int mcd_volinfo(struct mcd_softc *);
|
|
|
|
static int mcd_waitrdy(struct mcd_softc *,int dly);
|
|
|
|
static timeout_t mcd_timeout;
|
|
|
|
static void mcd_doread(struct mcd_softc *, int state, struct mcd_mbx *mbxin);
|
|
|
|
static void mcd_soft_reset(struct mcd_softc *);
|
|
|
|
static int mcd_hard_reset(struct mcd_softc *);
|
|
|
|
static int mcd_setmode(struct mcd_softc *, int mode);
|
|
|
|
static int mcd_getqchan(struct mcd_softc *, struct mcd_qchninfo *q);
|
|
|
|
static int mcd_subchan(struct mcd_softc *, struct ioc_read_subchannel *sc);
|
|
|
|
static int mcd_toc_header(struct mcd_softc *, struct ioc_toc_header *th);
|
|
|
|
static int mcd_read_toc(struct mcd_softc *);
|
|
|
|
static int mcd_toc_entrys(struct mcd_softc *, struct ioc_read_toc_entry *te);
|
1997-11-07 08:53:44 +00:00
|
|
|
#if 0
|
2002-10-04 07:14:19 +00:00
|
|
|
static int mcd_toc_entry(struct mcd_softc *, struct ioc_read_toc_single_entry *te);
|
1997-11-07 08:53:44 +00:00
|
|
|
#endif
|
2002-10-04 07:14:19 +00:00
|
|
|
static int mcd_stop(struct mcd_softc *);
|
|
|
|
static int mcd_eject(struct mcd_softc *);
|
|
|
|
static int mcd_inject(struct mcd_softc *);
|
|
|
|
static int mcd_playtracks(struct mcd_softc *, struct ioc_play_track *pt);
|
|
|
|
static int mcd_play(struct mcd_softc *, struct mcd_read2 *pb);
|
|
|
|
static int mcd_playmsf(struct mcd_softc *, struct ioc_play_msf *pt);
|
|
|
|
static int mcd_playblocks(struct mcd_softc *, struct ioc_play_blocks *);
|
|
|
|
static int mcd_pause(struct mcd_softc *);
|
|
|
|
static int mcd_resume(struct mcd_softc *);
|
|
|
|
static int mcd_lock_door(struct mcd_softc *, int lock);
|
|
|
|
static int mcd_close_tray(struct mcd_softc *);
|
2004-06-16 09:47:26 +00:00
|
|
|
static int mcd_size(struct cdev *dev);
|
2002-10-04 07:14:19 +00:00
|
|
|
|
|
|
|
static d_open_t mcdopen;
|
|
|
|
static d_close_t mcdclose;
|
|
|
|
static d_ioctl_t mcdioctl;
|
|
|
|
static d_strategy_t mcdstrategy;
|
1995-12-08 11:19:42 +00:00
|
|
|
|
1998-07-04 22:30:26 +00:00
|
|
|
static struct cdevsw mcd_cdevsw = {
|
2004-02-21 21:10:55 +00:00
|
|
|
.d_version = D_VERSION,
|
2003-03-03 12:15:54 +00:00
|
|
|
.d_open = mcdopen,
|
|
|
|
.d_close = mcdclose,
|
|
|
|
.d_read = physread,
|
|
|
|
.d_ioctl = mcdioctl,
|
|
|
|
.d_strategy = mcdstrategy,
|
|
|
|
.d_name = "mcd",
|
2004-02-21 21:10:55 +00:00
|
|
|
.d_flags = D_DISK | D_NEEDGIANT,
|
1999-05-30 16:53:49 +00:00
|
|
|
};
|
1995-12-08 11:19:42 +00:00
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
#define MCD_RETRYS 5
|
|
|
|
#define MCD_RDRETRYS 8
|
|
|
|
|
1995-02-22 01:11:36 +00:00
|
|
|
#define CLOSE_TRAY_SECS 8
|
|
|
|
#define DISK_SENSE_SECS 3
|
|
|
|
#define WAIT_FRAC 4
|
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
/* several delays */
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
#define RDELAY_WAITSTAT 300
|
|
|
|
#define RDELAY_WAITMODE 300
|
1993-10-12 06:08:31 +00:00
|
|
|
#define RDELAY_WAITREAD 800
|
|
|
|
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
#define MIN_DELAY 15
|
1995-08-15 19:56:59 +00:00
|
|
|
#define DELAY_GETREPLY 5000000
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
int
|
|
|
|
mcd_attach(struct mcd_softc *sc)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
2002-10-04 07:14:19 +00:00
|
|
|
int unit;
|
|
|
|
|
|
|
|
unit = device_get_unit(sc->dev);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.flags |= MCDINIT;
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_soft_reset(sc);
|
2002-11-06 08:08:55 +00:00
|
|
|
bioq_init(&sc->data.head);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
#ifdef NOTYET
|
|
|
|
/* wire controller for interrupts and dma */
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_configure(sc);
|
1993-10-12 06:08:31 +00:00
|
|
|
#endif
|
1994-11-14 19:25:43 +00:00
|
|
|
/* name filled in probe */
|
2002-10-06 00:19:38 +00:00
|
|
|
sc->mcd_dev_t = make_dev(&mcd_cdevsw, 8 * unit,
|
2002-10-04 07:14:19 +00:00
|
|
|
UID_ROOT, GID_OPERATOR, 0640, "mcd%d", unit);
|
|
|
|
|
2002-10-06 00:19:38 +00:00
|
|
|
sc->mcd_dev_t->si_drv1 = (void *)sc;
|
2002-10-04 07:14:19 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
2002-10-04 02:21:26 +00:00
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
mcdopen(struct cdev *dev, int flags, int fmt, struct thread *td)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
2002-10-04 07:14:19 +00:00
|
|
|
struct mcd_softc *sc;
|
2002-10-06 00:19:38 +00:00
|
|
|
int r,retry;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
sc = (struct mcd_softc *)dev->si_drv1;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
/* not initialized*/
|
2002-11-06 08:08:55 +00:00
|
|
|
if (!(sc->data.flags & MCDINIT))
|
|
|
|
return (ENXIO);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
/* invalidated in the meantime? mark all open part's invalid */
|
2002-11-06 08:08:55 +00:00
|
|
|
if (!(sc->data.flags & MCDVALID) && sc->data.openflags)
|
|
|
|
return (ENXIO);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_getstat(sc, 1) == -1)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
1995-02-22 01:11:36 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if ( (sc->data.status & (MCDDSKCHNG|MCDDOOROPEN))
|
|
|
|
|| !(sc->data.status & MCDDSKIN))
|
1995-02-22 01:11:36 +00:00
|
|
|
for (retry = 0; retry < DISK_SENSE_SECS * WAIT_FRAC; retry++) {
|
2002-11-06 08:08:55 +00:00
|
|
|
(void) tsleep((caddr_t)sc, PSOCK | PCATCH, "mcdsn1", hz/WAIT_FRAC);
|
2002-10-04 07:14:19 +00:00
|
|
|
if ((r = mcd_getstat(sc, 1)) == -1)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
1995-02-22 01:11:36 +00:00
|
|
|
if (r != -2)
|
|
|
|
break;
|
|
|
|
}
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.status & MCDDOOROPEN) {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "door is open\n");
|
2002-11-06 08:08:55 +00:00
|
|
|
return (ENXIO);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
}
|
2002-11-06 08:08:55 +00:00
|
|
|
if (!(sc->data.status & MCDDSKIN)) {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "no CD inside\n");
|
2002-11-06 08:08:55 +00:00
|
|
|
return (ENXIO);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
}
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.status & MCDDSKCHNG) {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "CD not sensed\n");
|
2002-11-06 08:08:55 +00:00
|
|
|
return (ENXIO);
|
1995-02-22 01:11:36 +00:00
|
|
|
}
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2003-03-02 14:30:54 +00:00
|
|
|
if (mcd_size(dev) < 0) {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "failed to get disk size\n");
|
2002-11-06 08:08:55 +00:00
|
|
|
return (ENXIO);
|
2002-10-06 00:19:38 +00:00
|
|
|
}
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
dev->si_bsize_phys = sc->data.blksize;
|
1999-09-09 19:08:44 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.openflags = 1;
|
|
|
|
sc->data.partflags |= MCDREADRAW;
|
|
|
|
sc->data.flags |= MCDVALID;
|
2002-10-06 00:19:38 +00:00
|
|
|
|
|
|
|
(void) mcd_lock_door(sc, MCD_LK_LOCK);
|
2002-11-06 08:08:55 +00:00
|
|
|
if (!(sc->data.flags & MCDVALID))
|
|
|
|
return (ENXIO);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
return mcd_read_toc(sc);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
2002-10-04 02:21:26 +00:00
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
mcdclose(struct cdev *dev, int flags, int fmt, struct thread *td)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
2002-10-04 07:14:19 +00:00
|
|
|
struct mcd_softc *sc;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
sc = (struct mcd_softc *)dev->si_drv1;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (!(sc->data.flags & MCDINIT) || !sc->data.openflags)
|
|
|
|
return (ENXIO);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
(void) mcd_lock_door(sc, MCD_LK_UNLOCK);
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.openflags = 0;
|
|
|
|
sc->data.partflags &= ~MCDREADRAW;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
2002-10-04 02:21:26 +00:00
|
|
|
static void
|
2000-04-15 05:54:02 +00:00
|
|
|
mcdstrategy(struct bio *bp)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
2002-10-04 07:14:19 +00:00
|
|
|
struct mcd_softc *sc;
|
1993-10-12 06:08:31 +00:00
|
|
|
int s;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
sc = (struct mcd_softc *)bp->bio_dev->si_drv1;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
/* if device invalidated (e.g. media change, door open), error */
|
2002-11-06 08:08:55 +00:00
|
|
|
if (!(sc->data.flags & MCDVALID)) {
|
2002-10-06 00:19:38 +00:00
|
|
|
device_printf(sc->dev, "media changed\n");
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_error = EIO;
|
1993-10-12 06:08:31 +00:00
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read only */
|
2000-04-15 05:54:02 +00:00
|
|
|
if (!(bp->bio_cmd == BIO_READ)) {
|
|
|
|
bp->bio_error = EROFS;
|
1993-10-12 06:08:31 +00:00
|
|
|
goto bad;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
/* no data to read */
|
2000-04-15 05:54:02 +00:00
|
|
|
if (bp->bio_bcount == 0)
|
1993-10-12 06:08:31 +00:00
|
|
|
goto done;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (!(sc->data.flags & MCDTOC)) {
|
2002-10-06 00:19:38 +00:00
|
|
|
bp->bio_error = EIO;
|
|
|
|
goto bad;
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
2002-10-06 00:19:38 +00:00
|
|
|
bp->bio_resid = 0;
|
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
/* queue it */
|
|
|
|
s = splbio();
|
2003-04-01 15:06:26 +00:00
|
|
|
bioq_disksort(&sc->data.head, bp);
|
1993-10-12 06:08:31 +00:00
|
|
|
splx(s);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
/* now check whether we can perform processing */
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_start(sc);
|
1993-10-12 06:08:31 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
bad:
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_flags |= BIO_ERROR;
|
1993-10-12 06:08:31 +00:00
|
|
|
done:
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_resid = bp->bio_bcount;
|
1993-10-12 06:08:31 +00:00
|
|
|
biodone(bp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-10-04 02:21:26 +00:00
|
|
|
static void
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_start(struct mcd_softc *sc)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
2000-04-15 05:54:02 +00:00
|
|
|
struct bio *bp;
|
1999-05-06 18:54:19 +00:00
|
|
|
int s = splbio();
|
1995-05-30 08:16:23 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.flags & MCDMBXBSY) {
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
splx(s);
|
1993-10-12 06:08:31 +00:00
|
|
|
return;
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
}
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
bp = bioq_first(&sc->data.head);
|
1996-05-03 14:57:27 +00:00
|
|
|
if (bp != 0) {
|
1993-10-12 06:08:31 +00:00
|
|
|
/* block found to process, dequeue */
|
|
|
|
/*MCD_TRACE("mcd_start: found block bp=0x%x\n",bp,0,0,0);*/
|
2002-11-06 08:08:55 +00:00
|
|
|
bioq_remove(&sc->data.head, bp);
|
|
|
|
sc->data.flags |= MCDMBXBSY;
|
1993-10-12 06:08:31 +00:00
|
|
|
splx(s);
|
|
|
|
} else {
|
|
|
|
/* nothing to do */
|
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.mbx.retry = MCD_RETRYS;
|
|
|
|
sc->data.mbx.bp = bp;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
mcd_doread(sc, MCD_S_BEGIN,&(sc->data.mbx));
|
1993-10-12 06:08:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-10-04 02:21:26 +00:00
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
mcdioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
2002-10-04 07:14:19 +00:00
|
|
|
struct mcd_softc *sc;
|
2002-10-06 00:19:38 +00:00
|
|
|
int retry,r;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
sc = (struct mcd_softc *)dev->si_drv1;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_getstat(sc, 1) == -1) /* detect disk change too */
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
1998-07-13 09:53:11 +00:00
|
|
|
MCD_TRACE("ioctl called 0x%lx\n", cmd);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
switch (cmd) {
|
1996-02-27 18:53:50 +00:00
|
|
|
case CDIOCSETPATCH:
|
|
|
|
case CDIOCGETVOL:
|
|
|
|
case CDIOCSETVOL:
|
|
|
|
case CDIOCSETMONO:
|
|
|
|
case CDIOCSETSTERIO:
|
|
|
|
case CDIOCSETMUTE:
|
|
|
|
case CDIOCSETLEFT:
|
|
|
|
case CDIOCSETRIGHT:
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EINVAL);
|
1996-02-27 18:53:50 +00:00
|
|
|
case CDIOCEJECT:
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_eject(sc);
|
1996-02-27 18:53:50 +00:00
|
|
|
case CDIOCSETDEBUG:
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.debug = 1;
|
|
|
|
return (0);
|
1996-02-27 18:53:50 +00:00
|
|
|
case CDIOCCLRDEBUG:
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.debug = 0;
|
|
|
|
return (0);
|
1996-02-27 18:53:50 +00:00
|
|
|
case CDIOCRESET:
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_hard_reset(sc);
|
1996-02-27 18:53:50 +00:00
|
|
|
case CDIOCALLOW:
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_lock_door(sc, MCD_LK_UNLOCK);
|
1996-02-27 18:53:50 +00:00
|
|
|
case CDIOCPREVENT:
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_lock_door(sc, MCD_LK_LOCK);
|
1996-02-27 18:53:50 +00:00
|
|
|
case CDIOCCLOSE:
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_inject(sc);
|
1996-02-27 18:53:50 +00:00
|
|
|
}
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (!(sc->data.flags & MCDVALID)) {
|
|
|
|
if ( (sc->data.status & (MCDDSKCHNG|MCDDOOROPEN))
|
|
|
|
|| !(sc->data.status & MCDDSKIN))
|
1996-02-27 18:53:50 +00:00
|
|
|
for (retry = 0; retry < DISK_SENSE_SECS * WAIT_FRAC; retry++) {
|
2002-11-06 08:08:55 +00:00
|
|
|
(void) tsleep((caddr_t)sc, PSOCK | PCATCH, "mcdsn2", hz/WAIT_FRAC);
|
2002-10-04 07:14:19 +00:00
|
|
|
if ((r = mcd_getstat(sc, 1)) == -1)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
1996-02-27 18:53:50 +00:00
|
|
|
if (r != -2)
|
|
|
|
break;
|
|
|
|
}
|
2002-11-06 08:08:55 +00:00
|
|
|
if ( (sc->data.status & (MCDDOOROPEN|MCDDSKCHNG))
|
|
|
|
|| !(sc->data.status & MCDDSKIN)
|
2003-03-02 14:30:54 +00:00
|
|
|
|| mcd_size(dev) < 0
|
1996-02-27 18:53:50 +00:00
|
|
|
)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (ENXIO);
|
|
|
|
sc->data.flags |= MCDVALID;
|
|
|
|
sc->data.partflags |= MCDREADRAW;
|
2002-10-04 07:14:19 +00:00
|
|
|
(void) mcd_lock_door(sc, MCD_LK_LOCK);
|
2002-11-06 08:08:55 +00:00
|
|
|
if (!(sc->data.flags & MCDVALID))
|
|
|
|
return (ENXIO);
|
1996-02-27 18:53:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (cmd) {
|
2002-10-06 00:19:38 +00:00
|
|
|
case DIOCGMEDIASIZE:
|
2002-11-06 08:08:55 +00:00
|
|
|
*(off_t *)addr = (off_t)sc->data.disksize * sc->data.blksize;
|
2002-10-06 00:19:38 +00:00
|
|
|
return (0);
|
|
|
|
case DIOCGSECTORSIZE:
|
2002-11-06 08:08:55 +00:00
|
|
|
*(u_int *)addr = sc->data.blksize;
|
2002-10-06 00:19:38 +00:00
|
|
|
return (0);
|
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
case CDIOCPLAYTRACKS:
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_playtracks(sc, (struct ioc_play_track *) addr);
|
1993-10-12 06:08:31 +00:00
|
|
|
case CDIOCPLAYBLOCKS:
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_playblocks(sc, (struct ioc_play_blocks *) addr);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
case CDIOCPLAYMSF:
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_playmsf(sc, (struct ioc_play_msf *) addr);
|
1993-10-12 06:08:31 +00:00
|
|
|
case CDIOCREADSUBCHANNEL:
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_subchan(sc, (struct ioc_read_subchannel *) addr);
|
1993-10-12 06:08:31 +00:00
|
|
|
case CDIOREADTOCHEADER:
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_toc_header(sc, (struct ioc_toc_header *) addr);
|
1993-10-12 06:08:31 +00:00
|
|
|
case CDIOREADTOCENTRYS:
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_toc_entrys(sc, (struct ioc_read_toc_entry *) addr);
|
1993-10-12 06:08:31 +00:00
|
|
|
case CDIOCRESUME:
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_resume(sc);
|
1993-10-12 06:08:31 +00:00
|
|
|
case CDIOCPAUSE:
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_pause(sc);
|
1993-10-12 06:08:31 +00:00
|
|
|
case CDIOCSTART:
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_setmode(sc, MCD_MD_COOKED) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
case CDIOCSTOP:
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_stop(sc);
|
1993-10-12 06:08:31 +00:00
|
|
|
default:
|
2002-11-06 08:08:55 +00:00
|
|
|
return (ENOTTY);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
2002-10-04 02:21:26 +00:00
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
mcd_size(struct cdev *dev)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
2002-10-04 07:14:19 +00:00
|
|
|
struct mcd_softc *sc;
|
1993-10-12 06:08:31 +00:00
|
|
|
int size;
|
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
sc = (struct mcd_softc *)dev->si_drv1;
|
|
|
|
|
|
|
|
if (mcd_volinfo(sc) == 0) {
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.blksize = MCDBLK;
|
|
|
|
size = msf2hsg(sc->data.volinfo.vol_msf, 0);
|
|
|
|
sc->data.disksize = size * (MCDBLK/DEV_BSIZE);
|
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
2002-11-06 08:08:55 +00:00
|
|
|
return (-1);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************
|
|
|
|
* lower level of driver starts here
|
|
|
|
**************************************************************/
|
|
|
|
|
|
|
|
#ifdef NOTDEF
|
1994-02-22 08:44:31 +00:00
|
|
|
static char
|
|
|
|
irqs[] = {
|
1993-10-12 06:08:31 +00:00
|
|
|
0x00,0x00,0x10,0x20,0x00,0x30,0x00,0x00,
|
|
|
|
0x00,0x10,0x40,0x50,0x00,0x00,0x00,0x00
|
|
|
|
};
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static char
|
|
|
|
drqs[] = {
|
1993-10-12 06:08:31 +00:00
|
|
|
0x00,0x01,0x00,0x03,0x00,0x05,0x06,0x07,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
1995-10-28 15:39:31 +00:00
|
|
|
#ifdef NOT_YET
|
1994-02-22 08:44:31 +00:00
|
|
|
static void
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_configure(struct mcd_softc *sc)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_CONFIG, sc->data.config);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
1995-10-28 15:39:31 +00:00
|
|
|
#endif
|
1993-10-12 06:08:31 +00:00
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
/* Wait for non-busy - return 0 on timeout */
|
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
twiddle_thumbs(struct mcd_softc *sc, int count, char *whine)
|
1994-02-22 08:44:31 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
2002-10-04 07:14:19 +00:00
|
|
|
if (!(MCD_READ(sc, MCD_FLAGS) & MFL_STATUS_NOT_AVAIL))
|
2002-11-06 08:08:55 +00:00
|
|
|
return (1);
|
1994-02-22 08:44:31 +00:00
|
|
|
}
|
1996-01-23 22:55:08 +00:00
|
|
|
if (bootverbose)
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "timeout %s\n", whine);
|
2002-11-06 08:08:55 +00:00
|
|
|
return (0);
|
1994-02-22 08:44:31 +00:00
|
|
|
}
|
|
|
|
|
1994-01-16 23:34:17 +00:00
|
|
|
/* check to see if a Mitsumi CD-ROM is attached to the ISA bus */
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
int
|
|
|
|
mcd_probe(struct mcd_softc *sc)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
1994-02-22 08:44:31 +00:00
|
|
|
int i, j;
|
|
|
|
unsigned char stbytes[3];
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->data.flags = MCDPROBING;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
#ifdef NOTDEF
|
|
|
|
/* get irq/drq configuration word */
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->data.config = irqs[dev->id_irq]; /* | drqs[dev->id_drq];*/
|
1993-10-12 06:08:31 +00:00
|
|
|
#else
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->data.config = 0;
|
1993-10-12 06:08:31 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* send a reset */
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_FLAGS, M_RESET);
|
1994-02-22 08:44:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* delay awhile by getting any pending garbage (old data) and
|
|
|
|
* throwing it away.
|
|
|
|
*/
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
for (i = 1000000; i != 0; i--)
|
2002-10-04 07:14:19 +00:00
|
|
|
(void)MCD_READ(sc, MCD_FLAGS);
|
1994-02-22 08:44:31 +00:00
|
|
|
|
|
|
|
/* Get status */
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_DATA, MCD_CMDGETSTAT);
|
|
|
|
if (!twiddle_thumbs(sc, 1000000, "getting status"))
|
|
|
|
return (ENXIO); /* Timeout */
|
1994-02-22 08:44:31 +00:00
|
|
|
/* Get version information */
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_DATA, MCD_CMDCONTINFO);
|
1994-02-22 08:44:31 +00:00
|
|
|
for (j = 0; j < 3; j++) {
|
2002-10-04 07:14:19 +00:00
|
|
|
if (!twiddle_thumbs(sc, 3000, "getting version info"))
|
|
|
|
return (ENXIO);
|
|
|
|
stbytes[j] = (MCD_READ(sc, MCD_DATA) & 0xFF);
|
1994-02-22 08:44:31 +00:00
|
|
|
}
|
1994-12-21 15:17:59 +00:00
|
|
|
if (stbytes[1] == stbytes[2])
|
2002-10-04 07:14:19 +00:00
|
|
|
return (ENXIO);
|
1994-12-24 13:24:02 +00:00
|
|
|
if (stbytes[2] >= 4 || stbytes[1] != 'M') {
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_CTRL, M_PICKLE);
|
|
|
|
sc->data.flags |= MCDNEWMODEL;
|
1994-02-22 08:44:31 +00:00
|
|
|
}
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->data.read_command = MCD_CMDSINGLESPEEDREAD;
|
1994-11-14 19:25:43 +00:00
|
|
|
switch (stbytes[1]) {
|
|
|
|
case 'M':
|
1996-02-03 00:06:49 +00:00
|
|
|
if (stbytes[2] <= 2) {
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->data.type = MCD_TYPE_LU002S;
|
|
|
|
sc->data.name = "Mitsumi LU002S";
|
1996-02-03 00:06:49 +00:00
|
|
|
} else if (stbytes[2] <= 5) {
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->data.type = MCD_TYPE_LU005S;
|
|
|
|
sc->data.name = "Mitsumi LU005S";
|
1994-11-14 19:25:43 +00:00
|
|
|
} else {
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->data.type = MCD_TYPE_LU006S;
|
|
|
|
sc->data.name = "Mitsumi LU006S";
|
1994-11-14 19:25:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'F':
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->data.type = MCD_TYPE_FX001;
|
|
|
|
sc->data.name = "Mitsumi FX001";
|
1994-11-14 19:25:43 +00:00
|
|
|
break;
|
|
|
|
case 'D':
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->data.type = MCD_TYPE_FX001D;
|
|
|
|
sc->data.name = "Mitsumi FX001D";
|
|
|
|
sc->data.read_command = MCD_CMDDOUBLESPEEDREAD;
|
1994-11-14 19:25:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->data.type = MCD_TYPE_UNKNOWN;
|
|
|
|
sc->data.name = "Mitsumi ???";
|
1994-11-14 19:25:43 +00:00
|
|
|
break;
|
|
|
|
}
|
1994-12-24 13:24:02 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (bootverbose)
|
|
|
|
device_printf(sc->dev, "type %s, version info: %c %x\n",
|
|
|
|
sc->data.name, stbytes[1], stbytes[2]);
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-01-16 23:34:17 +00:00
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_waitrdy(struct mcd_softc *sc, int dly)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
1994-12-24 13:24:02 +00:00
|
|
|
/* wait until flag port senses status ready */
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
for (i=0; i<dly; i+=MIN_DELAY) {
|
2002-10-04 07:14:19 +00:00
|
|
|
if (!(MCD_READ(sc, MCD_FLAGS) & MFL_STATUS_NOT_AVAIL))
|
2002-11-06 08:08:55 +00:00
|
|
|
return (0);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
DELAY(MIN_DELAY);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
2002-11-06 08:08:55 +00:00
|
|
|
return (-1);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_getreply(struct mcd_softc *sc, int dly)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/* wait data to become ready */
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_waitrdy(sc, dly)<0) {
|
|
|
|
device_printf(sc->dev, "timeout getreply\n");
|
2002-11-06 08:08:55 +00:00
|
|
|
return (-1);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get the data */
|
2002-11-06 08:08:55 +00:00
|
|
|
return (MCD_READ(sc, MCD_REG_STATUS) & 0xFF);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_getstat(struct mcd_softc *sc, int sflg)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* get the status */
|
|
|
|
if (sflg)
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDGETSTAT);
|
|
|
|
i = mcd_getreply(sc, DELAY_GETREPLY);
|
1995-02-22 01:11:36 +00:00
|
|
|
if (i<0 || (i & MCD_ST_CMDCHECK)) {
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.curr_mode = MCD_MD_UNKNOWN;
|
|
|
|
return (-1);
|
1995-02-22 01:11:36 +00:00
|
|
|
}
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.status = i;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_setflags(sc) < 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (-2);
|
|
|
|
return (sc->data.status);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_setflags(struct mcd_softc *sc)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
2002-10-04 07:14:19 +00:00
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
/* check flags */
|
2002-11-06 08:08:55 +00:00
|
|
|
if ( (sc->data.status & (MCDDSKCHNG|MCDDOOROPEN))
|
|
|
|
|| !(sc->data.status & MCDDSKIN)) {
|
1995-05-09 11:39:40 +00:00
|
|
|
MCD_TRACE("setflags: sensed DSKCHNG or DOOROPEN or !DSKIN\n");
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_soft_reset(sc);
|
2002-11-06 08:08:55 +00:00
|
|
|
return (-1);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.status & MCDAUDIOBSY)
|
|
|
|
sc->data.audio_status = CD_AS_PLAY_IN_PROGRESS;
|
|
|
|
else if (sc->data.audio_status == CD_AS_PLAY_IN_PROGRESS)
|
|
|
|
sc->data.audio_status = CD_AS_PLAY_COMPLETED;
|
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_get(struct mcd_softc *sc, char *buf, int nmax)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
|
|
|
int i,k;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
for (i=0; i<nmax; i++) {
|
|
|
|
/* wait for data */
|
2002-10-04 07:14:19 +00:00
|
|
|
if ((k = mcd_getreply(sc, DELAY_GETREPLY)) < 0) {
|
|
|
|
device_printf(sc->dev, "timeout mcd_get\n");
|
2002-11-06 08:08:55 +00:00
|
|
|
return (-1);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
buf[i] = k;
|
|
|
|
}
|
2002-11-06 08:08:55 +00:00
|
|
|
return (i);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_send(struct mcd_softc *sc, int cmd,int nretrys)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
int i,k=0;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
/*MCD_TRACE("mcd_send: command = 0x%02x\n",cmd,0,0,0);*/
|
1993-10-12 06:08:31 +00:00
|
|
|
for (i=0; i<nretrys; i++) {
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, cmd);
|
|
|
|
if ((k=mcd_getstat(sc, 0)) != -1)
|
1993-10-12 06:08:31 +00:00
|
|
|
break;
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
}
|
|
|
|
if (k == -2) {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "media changed\n");
|
2002-11-06 08:08:55 +00:00
|
|
|
return (-1);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
if (i == nretrys) {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "mcd_send retry cnt exceeded\n");
|
2002-11-06 08:08:55 +00:00
|
|
|
return (-1);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
/*MCD_TRACE("mcd_send: done\n",0,0,0,0);*/
|
2002-11-06 08:08:55 +00:00
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static void
|
|
|
|
hsg2msf(int hsg, bcd_t *msf)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
|
|
|
hsg += 150;
|
|
|
|
F_msf(msf) = bin2bcd(hsg % 75);
|
1996-01-30 23:27:20 +00:00
|
|
|
hsg /= 75;
|
|
|
|
S_msf(msf) = bin2bcd(hsg % 60);
|
|
|
|
hsg /= 60;
|
|
|
|
M_msf(msf) = bin2bcd(hsg);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
1996-01-30 23:27:20 +00:00
|
|
|
msf2hsg(bcd_t *msf, int relative)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
1996-01-30 23:27:20 +00:00
|
|
|
return (bcd2bin(M_msf(msf)) * 60 + bcd2bin(S_msf(msf))) * 75 +
|
|
|
|
bcd2bin(F_msf(msf)) - (!relative) * 150;
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_volinfo(struct mcd_softc *sc)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/* Just return if we already have it */
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.flags & MCDVOLINFO) return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
/*MCD_TRACE("mcd_volinfo: enter\n",0,0,0,0);*/
|
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
/* send volume info command */
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_send(sc, MCD_CMDGETVOLINFO,MCD_RETRYS) < 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
/* get data */
|
2002-11-06 08:08:55 +00:00
|
|
|
if (mcd_get(sc, (char*) &sc->data.volinfo,sizeof(struct mcd_volinfo)) < 0) {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "mcd_volinfo: error read data\n");
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.volinfo.trk_low > 0 &&
|
|
|
|
sc->data.volinfo.trk_high >= sc->data.volinfo.trk_low
|
1995-02-22 01:11:36 +00:00
|
|
|
) {
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.flags |= MCDVOLINFO; /* volinfo is OK */
|
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EINVAL);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* state machine to process read requests
|
|
|
|
* initialize with MCD_S_BEGIN: calculate sizes, and read status
|
|
|
|
* MCD_S_WAITSTAT: wait for status reply, set mode
|
|
|
|
* MCD_S_WAITMODE: waits for status reply from set mode, set read command
|
|
|
|
* MCD_S_WAITREAD: wait for read ready, read data
|
|
|
|
*/
|
1997-04-20 17:26:55 +00:00
|
|
|
static void
|
|
|
|
mcd_timeout(void *arg)
|
|
|
|
{
|
2002-10-04 07:14:19 +00:00
|
|
|
struct mcd_softc *sc;
|
|
|
|
|
|
|
|
sc = (struct mcd_softc *)arg;
|
|
|
|
|
|
|
|
mcd_doread(sc, sc->ch_state, sc->ch_mbxsave);
|
1997-04-20 17:26:55 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static void
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_doread(struct mcd_softc *sc, int state, struct mcd_mbx *mbxin)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
2002-10-04 07:14:19 +00:00
|
|
|
struct mcd_mbx *mbx;
|
|
|
|
struct bio *bp;
|
|
|
|
int rm, i, k;
|
1993-10-12 06:08:31 +00:00
|
|
|
struct mcd_read2 rbuf;
|
2002-10-04 07:14:19 +00:00
|
|
|
int blknum;
|
1993-10-12 06:08:31 +00:00
|
|
|
caddr_t addr;
|
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
mbx = (state!=MCD_S_BEGIN) ? sc->ch_mbxsave : mbxin;
|
|
|
|
bp = mbx->bp;
|
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
loop:
|
|
|
|
switch (state) {
|
|
|
|
case MCD_S_BEGIN:
|
2002-10-04 07:14:19 +00:00
|
|
|
mbx = sc->ch_mbxsave = mbxin;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
case MCD_S_BEGIN1:
|
1995-01-30 06:44:40 +00:00
|
|
|
retry_status:
|
1995-02-22 01:11:36 +00:00
|
|
|
/* get status */
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDGETSTAT);
|
1993-10-12 06:08:31 +00:00
|
|
|
mbx->count = RDELAY_WAITSTAT;
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->ch_state = MCD_S_WAITSTAT;
|
|
|
|
sc->ch = timeout(mcd_timeout, (caddr_t)sc, hz/100); /* XXX */
|
1993-10-12 06:08:31 +00:00
|
|
|
return;
|
|
|
|
case MCD_S_WAITSTAT:
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->ch_state = MCD_S_WAITSTAT;
|
|
|
|
untimeout(mcd_timeout,(caddr_t)sc, sc->ch);
|
1993-10-12 06:08:31 +00:00
|
|
|
if (mbx->count-- >= 0) {
|
2002-10-04 07:14:19 +00:00
|
|
|
if (MCD_READ(sc, MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
|
|
|
|
sc->ch_state = MCD_S_WAITSTAT;
|
|
|
|
timeout(mcd_timeout, (caddr_t)sc, hz/100); /* XXX */
|
1993-10-12 06:08:31 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.status = MCD_READ(sc, MCD_REG_STATUS) & 0xFF;
|
|
|
|
if (sc->data.status & MCD_ST_CMDCHECK)
|
1995-01-30 06:44:40 +00:00
|
|
|
goto retry_status;
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_setflags(sc) < 0)
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
goto changed;
|
1994-02-22 08:44:31 +00:00
|
|
|
MCD_TRACE("got WAITSTAT delay=%d\n",
|
1995-05-09 11:39:40 +00:00
|
|
|
RDELAY_WAITSTAT-mbx->count);
|
1993-10-12 06:08:31 +00:00
|
|
|
/* reject, if audio active */
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.status & MCDAUDIOBSY) {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "audio is active\n");
|
1993-10-12 06:08:31 +00:00
|
|
|
goto readerr;
|
|
|
|
}
|
1995-02-22 01:11:36 +00:00
|
|
|
|
1995-01-30 06:44:40 +00:00
|
|
|
retry_mode:
|
1993-10-12 06:08:31 +00:00
|
|
|
/* to check for raw/cooked mode */
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.flags & MCDREADRAW) {
|
1994-11-12 13:26:13 +00:00
|
|
|
rm = MCD_MD_RAW;
|
1993-10-12 06:08:31 +00:00
|
|
|
mbx->sz = MCDRBLK;
|
|
|
|
} else {
|
1994-11-12 13:26:13 +00:00
|
|
|
rm = MCD_MD_COOKED;
|
2002-11-06 08:08:55 +00:00
|
|
|
mbx->sz = sc->data.blksize;
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (rm == sc->data.curr_mode)
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
goto modedone;
|
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
mbx->count = RDELAY_WAITMODE;
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.curr_mode = MCD_MD_UNKNOWN;
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
mbx->mode = rm;
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDSETMODE);
|
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, rm);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->ch_state = MCD_S_WAITMODE;
|
|
|
|
sc->ch = timeout(mcd_timeout, (caddr_t)sc, hz/100); /* XXX */
|
1993-10-12 06:08:31 +00:00
|
|
|
return;
|
|
|
|
} else {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "timeout getstatus\n");
|
1993-10-12 06:08:31 +00:00
|
|
|
goto readerr;
|
|
|
|
}
|
|
|
|
|
|
|
|
case MCD_S_WAITMODE:
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->ch_state = MCD_S_WAITMODE;
|
|
|
|
untimeout(mcd_timeout, (caddr_t)sc, sc->ch);
|
1993-10-12 06:08:31 +00:00
|
|
|
if (mbx->count-- < 0) {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "timeout set mode\n");
|
1993-10-12 06:08:31 +00:00
|
|
|
goto readerr;
|
|
|
|
}
|
2002-10-04 07:14:19 +00:00
|
|
|
if (MCD_READ(sc, MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
|
|
|
|
sc->ch_state = MCD_S_WAITMODE;
|
|
|
|
sc->ch = timeout(mcd_timeout, (caddr_t)sc, hz/100);
|
1993-10-12 06:08:31 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.status = MCD_READ(sc, MCD_REG_STATUS) & 0xFF;
|
|
|
|
if (sc->data.status & MCD_ST_CMDCHECK) {
|
|
|
|
sc->data.curr_mode = MCD_MD_UNKNOWN;
|
1995-01-30 06:44:40 +00:00
|
|
|
goto retry_mode;
|
|
|
|
}
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_setflags(sc) < 0)
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
goto changed;
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.curr_mode = mbx->mode;
|
1994-02-22 08:44:31 +00:00
|
|
|
MCD_TRACE("got WAITMODE delay=%d\n",
|
1995-05-09 11:39:40 +00:00
|
|
|
RDELAY_WAITMODE-mbx->count);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
modedone:
|
1993-10-12 06:08:31 +00:00
|
|
|
/* for first block */
|
2000-04-15 05:54:02 +00:00
|
|
|
mbx->nblk = (bp->bio_bcount + (mbx->sz-1)) / mbx->sz;
|
1993-10-12 06:08:31 +00:00
|
|
|
mbx->skip = 0;
|
|
|
|
|
|
|
|
nextblock:
|
2003-10-18 17:44:01 +00:00
|
|
|
blknum = bp->bio_offset / mbx->sz + mbx->skip/mbx->sz;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
1995-05-11 19:26:53 +00:00
|
|
|
MCD_TRACE("mcd_doread: read blknum=%d for bp=%p\n",
|
1995-05-09 11:39:40 +00:00
|
|
|
blknum, bp);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
/* build parameter block */
|
|
|
|
hsg2msf(blknum,rbuf.start_msf);
|
1995-01-30 06:44:40 +00:00
|
|
|
retry_read:
|
1993-10-12 06:08:31 +00:00
|
|
|
/* send the read command */
|
2002-11-10 03:45:49 +00:00
|
|
|
critical_enter();
|
2002-11-06 08:08:55 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, sc->data.read_command);
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, rbuf.start_msf[0]);
|
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, rbuf.start_msf[1]);
|
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, rbuf.start_msf[2]);
|
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, 0);
|
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, 0);
|
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, 1);
|
2002-11-10 03:45:49 +00:00
|
|
|
critical_exit();
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
1994-09-14 20:28:25 +00:00
|
|
|
/* Spin briefly (<= 2ms) to avoid missing next block */
|
|
|
|
for (i = 0; i < 20; i++) {
|
2002-10-04 07:14:19 +00:00
|
|
|
k = MCD_READ(sc, MCD_FLAGS);
|
1994-12-24 13:24:02 +00:00
|
|
|
if (!(k & MFL_DATA_NOT_AVAIL))
|
1994-09-14 20:28:25 +00:00
|
|
|
goto got_it;
|
|
|
|
DELAY(100);
|
|
|
|
}
|
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
mbx->count = RDELAY_WAITREAD;
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->ch_state = MCD_S_WAITREAD;
|
|
|
|
sc->ch = timeout(mcd_timeout, (caddr_t)sc, hz/100); /* XXX */
|
1993-10-12 06:08:31 +00:00
|
|
|
return;
|
|
|
|
case MCD_S_WAITREAD:
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->ch_state = MCD_S_WAITREAD;
|
|
|
|
untimeout(mcd_timeout, (caddr_t)sc, sc->ch);
|
1993-10-12 06:08:31 +00:00
|
|
|
if (mbx->count-- > 0) {
|
2002-10-04 07:14:19 +00:00
|
|
|
k = MCD_READ(sc, MCD_FLAGS);
|
1994-12-24 13:24:02 +00:00
|
|
|
if (!(k & MFL_DATA_NOT_AVAIL)) { /* XXX */
|
1994-02-22 08:44:31 +00:00
|
|
|
MCD_TRACE("got data delay=%d\n",
|
1995-05-09 11:39:40 +00:00
|
|
|
RDELAY_WAITREAD-mbx->count);
|
1994-09-14 20:28:25 +00:00
|
|
|
got_it:
|
1993-10-12 06:08:31 +00:00
|
|
|
/* data is ready */
|
2000-04-15 05:54:02 +00:00
|
|
|
addr = bp->bio_data + mbx->skip;
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_CTL2,0x04); /* XXX */
|
1993-10-12 06:08:31 +00:00
|
|
|
for (i=0; i<mbx->sz; i++)
|
2002-10-04 07:14:19 +00:00
|
|
|
*addr++ = MCD_READ(sc, MCD_REG_RDATA);
|
|
|
|
MCD_WRITE(sc, MCD_REG_CTL2,0x0c); /* XXX */
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
k = MCD_READ(sc, MCD_FLAGS);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
/* If we still have some junk, read it too */
|
1994-12-24 13:24:02 +00:00
|
|
|
if (!(k & MFL_DATA_NOT_AVAIL)) {
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_CTL2, 0x04); /* XXX */
|
|
|
|
(void)MCD_READ(sc, MCD_REG_RDATA);
|
|
|
|
(void)MCD_READ(sc, MCD_REG_RDATA);
|
|
|
|
MCD_WRITE(sc, MCD_REG_CTL2, 0x0c); /* XXX */
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
}
|
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
if (--mbx->nblk > 0) {
|
|
|
|
mbx->skip += mbx->sz;
|
|
|
|
goto nextblock;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return buffer */
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_resid = 0;
|
1993-10-12 06:08:31 +00:00
|
|
|
biodone(bp);
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.flags &= ~(MCDMBXBSY|MCDREADRAW);
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_start(sc);
|
1993-10-12 06:08:31 +00:00
|
|
|
return;
|
|
|
|
}
|
1994-12-24 13:24:02 +00:00
|
|
|
if (!(k & MFL_STATUS_NOT_AVAIL)) {
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.status = MCD_READ(sc, MCD_REG_STATUS) & 0xFF;
|
|
|
|
if (sc->data.status & MCD_ST_CMDCHECK)
|
1995-01-30 06:44:40 +00:00
|
|
|
goto retry_read;
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_setflags(sc) < 0)
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
goto changed;
|
|
|
|
}
|
2002-10-04 07:14:19 +00:00
|
|
|
sc->ch_state = MCD_S_WAITREAD;
|
|
|
|
sc->ch = timeout(mcd_timeout, (caddr_t)sc, hz/100); /* XXX */
|
1993-10-12 06:08:31 +00:00
|
|
|
return;
|
|
|
|
} else {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "timeout read data\n");
|
1993-10-12 06:08:31 +00:00
|
|
|
goto readerr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
readerr:
|
|
|
|
if (mbx->retry-- > 0) {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "retrying\n");
|
1993-10-12 06:08:31 +00:00
|
|
|
state = MCD_S_BEGIN1;
|
|
|
|
goto loop;
|
|
|
|
}
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
harderr:
|
1993-10-12 06:08:31 +00:00
|
|
|
/* invalidate the buffer */
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_flags |= BIO_ERROR;
|
|
|
|
bp->bio_resid = bp->bio_bcount;
|
1993-10-12 06:08:31 +00:00
|
|
|
biodone(bp);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.flags &= ~(MCDMBXBSY|MCDREADRAW);
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_start(sc);
|
1993-10-12 06:08:31 +00:00
|
|
|
return;
|
|
|
|
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
changed:
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "media changed\n");
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
goto harderr;
|
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
#ifdef NOTDEF
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "unit timeout, resetting\n");
|
|
|
|
MCD_WRITE(sc, MCD_REG_RESET, MCD_CMDRESET);
|
1993-10-12 06:08:31 +00:00
|
|
|
DELAY(300000);
|
2002-10-04 07:14:19 +00:00
|
|
|
(void)mcd_getstat(sc, 1);
|
|
|
|
(void)mcd_getstat(sc, 1);
|
2002-11-06 08:08:55 +00:00
|
|
|
/*sc->data.status &= ~MCDDSKCHNG; */
|
|
|
|
sc->data.debug = 1; /* preventive set debug mode */
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_lock_door(struct mcd_softc *sc, int lock)
|
1995-02-22 01:11:36 +00:00
|
|
|
{
|
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDLOCKDRV);
|
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, lock);
|
|
|
|
if (mcd_getstat(sc, 0) == -1)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
|
|
|
return (0);
|
1995-02-22 01:11:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_close_tray(struct mcd_softc *sc)
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
{
|
1995-02-22 01:11:36 +00:00
|
|
|
int retry, r;
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_getstat(sc, 1) == -1)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
|
|
|
if (sc->data.status & MCDDOOROPEN) {
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDCLOSETRAY);
|
1995-02-22 01:11:36 +00:00
|
|
|
for (retry = 0; retry < CLOSE_TRAY_SECS * WAIT_FRAC; retry++) {
|
2002-10-04 07:14:19 +00:00
|
|
|
if (MCD_READ(sc, MCD_FLAGS) & MFL_STATUS_NOT_AVAIL)
|
2002-11-06 08:08:55 +00:00
|
|
|
(void) tsleep((caddr_t)sc, PSOCK | PCATCH, "mcdcls", hz/WAIT_FRAC);
|
1995-02-22 01:11:36 +00:00
|
|
|
else {
|
2002-10-04 07:14:19 +00:00
|
|
|
if ((r = mcd_getstat(sc, 0)) == -1)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
|
|
|
return (0);
|
1995-02-22 01:11:36 +00:00
|
|
|
}
|
|
|
|
}
|
2002-11-06 08:08:55 +00:00
|
|
|
return (ENXIO);
|
1995-02-22 01:11:36 +00:00
|
|
|
}
|
2002-11-06 08:08:55 +00:00
|
|
|
return (0);
|
1995-02-22 01:11:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_eject(struct mcd_softc *sc)
|
1995-02-22 01:11:36 +00:00
|
|
|
{
|
2002-10-04 07:14:19 +00:00
|
|
|
int r;
|
1995-02-22 01:11:36 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_getstat(sc, 1) == -1) /* detect disk change too */
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
|
|
|
if (sc->data.status & MCDDOOROPEN)
|
|
|
|
return (0);
|
2002-10-04 07:14:19 +00:00
|
|
|
if ((r = mcd_stop(sc)) == EIO)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (r);
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDEJECTDISK);
|
|
|
|
if (mcd_getstat(sc, 0) == -1)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
|
|
|
return (0);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
}
|
|
|
|
|
1996-02-02 22:08:28 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_inject(struct mcd_softc *sc)
|
1996-02-02 22:08:28 +00:00
|
|
|
{
|
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_getstat(sc, 1) == -1) /* detect disk change too */
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
|
|
|
if (sc->data.status & MCDDOOROPEN)
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_close_tray(sc);
|
2002-11-06 08:08:55 +00:00
|
|
|
return (0);
|
1996-02-02 22:08:28 +00:00
|
|
|
}
|
|
|
|
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_hard_reset(struct mcd_softc *sc)
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
{
|
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_RESET, MCD_CMDRESET);
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.curr_mode = MCD_MD_UNKNOWN;
|
|
|
|
sc->data.audio_status = CD_AS_AUDIO_INVALID;
|
|
|
|
return (0);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_soft_reset(struct mcd_softc *sc)
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
{
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.flags &= (MCDINIT|MCDPROBING|MCDNEWMODEL);
|
|
|
|
sc->data.curr_mode = MCD_MD_UNKNOWN;
|
|
|
|
sc->data.partflags = 0;
|
|
|
|
sc->data.audio_status = CD_AS_AUDIO_INVALID;
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_setmode(struct mcd_softc *sc, int mode)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
int retry, st;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.curr_mode == mode)
|
|
|
|
return (0);
|
|
|
|
if (sc->data.debug)
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "setting mode to %d\n", mode);
|
1993-10-12 06:08:31 +00:00
|
|
|
for(retry=0; retry<MCD_RETRYS; retry++)
|
|
|
|
{
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.curr_mode = MCD_MD_UNKNOWN;
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDSETMODE);
|
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, mode);
|
|
|
|
if ((st = mcd_getstat(sc, 0)) >= 0) {
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.curr_mode = mode;
|
|
|
|
return (0);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
}
|
|
|
|
if (st == -2) {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "media changed\n");
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
break;
|
|
|
|
}
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
return (-1);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_toc_header(struct mcd_softc *sc, struct ioc_toc_header *th)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
int r;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if ((r = mcd_volinfo(sc)) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (r);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
th->starting_track = bcd2bin(sc->data.volinfo.trk_low);
|
|
|
|
th->ending_track = bcd2bin(sc->data.volinfo.trk_high);
|
1996-02-03 00:06:49 +00:00
|
|
|
th->len = 2 * sizeof(u_char) /* start & end tracks */ +
|
|
|
|
(th->ending_track + 1 - th->starting_track + 1) *
|
|
|
|
sizeof(struct cd_toc_entry);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_read_toc(struct mcd_softc *sc)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
|
|
|
struct ioc_toc_header th;
|
|
|
|
struct mcd_qchninfo q;
|
|
|
|
int rc, trk, idx, retry;
|
|
|
|
|
|
|
|
/* Only read TOC if needed */
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.flags & MCDTOC)
|
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.debug)
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "reading toc header\n");
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if ((rc = mcd_toc_header(sc, &th)) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (rc);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_send(sc, MCD_CMDSTOPAUDIO, MCD_RETRYS) < 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
1995-02-23 17:40:16 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_setmode(sc, MCD_MD_TOC) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.debug)
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "get_toc reading qchannel info\n");
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
1993-10-12 06:08:31 +00:00
|
|
|
for(trk=th.starting_track; trk<=th.ending_track; trk++)
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.toc[trk].idx_no = 0;
|
1993-10-12 06:08:31 +00:00
|
|
|
trk = th.ending_track - th.starting_track + 1;
|
1995-02-22 02:12:10 +00:00
|
|
|
for(retry=0; retry<600 && trk>0; retry++)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_getqchan(sc, &q) < 0) break;
|
1993-10-12 06:08:31 +00:00
|
|
|
idx = bcd2bin(q.idx_no);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
if (idx>=th.starting_track && idx<=th.ending_track && q.trk_no==0) {
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.toc[idx].idx_no == 0) {
|
|
|
|
sc->data.toc[idx] = q;
|
1993-10-12 06:08:31 +00:00
|
|
|
trk--;
|
|
|
|
}
|
1994-02-22 08:44:31 +00:00
|
|
|
}
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_setmode(sc, MCD_MD_COOKED) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
if (trk != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (ENXIO);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
/* add a fake last+1 */
|
|
|
|
idx = th.ending_track + 1;
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.toc[idx].control = sc->data.toc[idx-1].control;
|
|
|
|
sc->data.toc[idx].addr_type = sc->data.toc[idx-1].addr_type;
|
|
|
|
sc->data.toc[idx].trk_no = 0;
|
|
|
|
sc->data.toc[idx].idx_no = MCD_LASTPLUS1;
|
|
|
|
sc->data.toc[idx].hd_pos_msf[0] = sc->data.volinfo.vol_msf[0];
|
|
|
|
sc->data.toc[idx].hd_pos_msf[1] = sc->data.volinfo.vol_msf[1];
|
|
|
|
sc->data.toc[idx].hd_pos_msf[2] = sc->data.volinfo.vol_msf[2];
|
|
|
|
|
|
|
|
if (sc->data.debug)
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
{ int i;
|
|
|
|
for (i = th.starting_track; i <= idx; i++)
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "trk %d idx %d pos %d %d %d\n",
|
|
|
|
i,
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.toc[i].idx_no > 0x99 ? sc->data.toc[i].idx_no :
|
|
|
|
bcd2bin(sc->data.toc[i].idx_no),
|
|
|
|
bcd2bin(sc->data.toc[i].hd_pos_msf[0]),
|
|
|
|
bcd2bin(sc->data.toc[i].hd_pos_msf[1]),
|
|
|
|
bcd2bin(sc->data.toc[i].hd_pos_msf[2]));
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
}
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.flags |= MCDTOC;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1997-11-07 08:53:44 +00:00
|
|
|
#if 0
|
1997-05-04 15:24:23 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_toc_entry(struct mcd_softc *sc, struct ioc_read_toc_single_entry *te)
|
1997-05-04 15:24:23 +00:00
|
|
|
{
|
|
|
|
struct ioc_toc_header th;
|
|
|
|
int rc, trk;
|
|
|
|
|
|
|
|
if (te->address_format != CD_MSF_FORMAT
|
|
|
|
&& te->address_format != CD_LBA_FORMAT)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EINVAL);
|
1997-05-04 15:24:23 +00:00
|
|
|
|
|
|
|
/* Copy the toc header */
|
2002-10-04 07:14:19 +00:00
|
|
|
if ((rc = mcd_toc_header(sc, &th)) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (rc);
|
1997-05-04 15:24:23 +00:00
|
|
|
|
|
|
|
/* verify starting track */
|
|
|
|
trk = te->track;
|
|
|
|
if (trk == 0)
|
|
|
|
trk = th.starting_track;
|
|
|
|
else if (trk == MCD_LASTPLUS1)
|
|
|
|
trk = th.ending_track + 1;
|
|
|
|
else if (trk < th.starting_track || trk > th.ending_track + 1)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EINVAL);
|
1997-05-04 15:24:23 +00:00
|
|
|
|
|
|
|
/* Make sure we have a valid toc */
|
2002-10-04 07:14:19 +00:00
|
|
|
if ((rc=mcd_read_toc(sc)) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (rc);
|
1997-05-04 15:24:23 +00:00
|
|
|
|
|
|
|
/* Copy the TOC data. */
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.toc[trk].idx_no == 0)
|
|
|
|
return (EIO);
|
1997-05-04 15:24:23 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
te->entry.control = sc->data.toc[trk].control;
|
|
|
|
te->entry.addr_type = sc->data.toc[trk].addr_type;
|
1997-05-04 15:24:23 +00:00
|
|
|
te->entry.track =
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.toc[trk].idx_no > 0x99 ? sc->data.toc[trk].idx_no :
|
|
|
|
bcd2bin(sc->data.toc[trk].idx_no);
|
1997-05-04 15:24:23 +00:00
|
|
|
switch (te->address_format) {
|
|
|
|
case CD_MSF_FORMAT:
|
|
|
|
te->entry.addr.msf.unused = 0;
|
2002-11-06 08:08:55 +00:00
|
|
|
te->entry.addr.msf.minute = bcd2bin(sc->data.toc[trk].hd_pos_msf[0]);
|
|
|
|
te->entry.addr.msf.second = bcd2bin(sc->data.toc[trk].hd_pos_msf[1]);
|
|
|
|
te->entry.addr.msf.frame = bcd2bin(sc->data.toc[trk].hd_pos_msf[2]);
|
1997-05-04 15:24:23 +00:00
|
|
|
break;
|
|
|
|
case CD_LBA_FORMAT:
|
2002-11-06 08:08:55 +00:00
|
|
|
te->entry.addr.lba = htonl(msf2hsg(sc->data.toc[trk].hd_pos_msf, 0));
|
1997-05-04 15:24:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-11-06 08:08:55 +00:00
|
|
|
return (0);
|
1997-05-04 15:24:23 +00:00
|
|
|
}
|
1997-11-07 08:53:44 +00:00
|
|
|
#endif
|
1997-05-04 15:24:23 +00:00
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_toc_entrys(struct mcd_softc *sc, struct ioc_read_toc_entry *te)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
struct cd_toc_entry entries[MCD_MAXTOCS];
|
1993-10-12 06:08:31 +00:00
|
|
|
struct ioc_toc_header th;
|
1996-01-30 13:15:28 +00:00
|
|
|
int rc, n, trk, len;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
1996-01-30 13:15:28 +00:00
|
|
|
if ( te->data_len < sizeof(entries[0])
|
|
|
|
|| (te->data_len % sizeof(entries[0])) != 0
|
1999-05-06 18:44:42 +00:00
|
|
|
|| (te->address_format != CD_MSF_FORMAT
|
|
|
|
&& te->address_format != CD_LBA_FORMAT)
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EINVAL);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
/* Copy the toc header */
|
2002-10-04 07:14:19 +00:00
|
|
|
if ((rc = mcd_toc_header(sc, &th)) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (rc);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
1996-01-30 10:31:12 +00:00
|
|
|
/* verify starting track */
|
|
|
|
trk = te->starting_track;
|
|
|
|
if (trk == 0)
|
|
|
|
trk = th.starting_track;
|
|
|
|
else if (trk == MCD_LASTPLUS1)
|
|
|
|
trk = th.ending_track + 1;
|
|
|
|
else if (trk < th.starting_track || trk > th.ending_track + 1)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EINVAL);
|
1996-01-30 10:31:12 +00:00
|
|
|
|
1996-01-30 13:15:28 +00:00
|
|
|
len = ((th.ending_track + 1 - trk) + 1) *
|
|
|
|
sizeof(entries[0]);
|
|
|
|
if (te->data_len < len)
|
|
|
|
len = te->data_len;
|
|
|
|
if (len > sizeof(entries))
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EINVAL);
|
1996-01-30 13:15:28 +00:00
|
|
|
|
1996-01-30 10:31:12 +00:00
|
|
|
/* Make sure we have a valid toc */
|
2002-10-04 07:14:19 +00:00
|
|
|
if ((rc=mcd_read_toc(sc)) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (rc);
|
1996-01-30 10:31:12 +00:00
|
|
|
|
|
|
|
/* Copy the TOC data. */
|
|
|
|
for (n = 0; len > 0 && trk <= th.ending_track + 1; trk++) {
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.toc[trk].idx_no == 0)
|
1996-01-30 10:31:12 +00:00
|
|
|
continue;
|
2002-11-06 08:08:55 +00:00
|
|
|
entries[n].control = sc->data.toc[trk].control;
|
|
|
|
entries[n].addr_type = sc->data.toc[trk].addr_type;
|
1996-01-30 10:31:12 +00:00
|
|
|
entries[n].track =
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.toc[trk].idx_no > 0x99 ? sc->data.toc[trk].idx_no :
|
|
|
|
bcd2bin(sc->data.toc[trk].idx_no);
|
1996-01-30 10:31:12 +00:00
|
|
|
switch (te->address_format) {
|
|
|
|
case CD_MSF_FORMAT:
|
|
|
|
entries[n].addr.msf.unused = 0;
|
2002-11-06 08:08:55 +00:00
|
|
|
entries[n].addr.msf.minute = bcd2bin(sc->data.toc[trk].hd_pos_msf[0]);
|
|
|
|
entries[n].addr.msf.second = bcd2bin(sc->data.toc[trk].hd_pos_msf[1]);
|
|
|
|
entries[n].addr.msf.frame = bcd2bin(sc->data.toc[trk].hd_pos_msf[2]);
|
1996-01-30 10:31:12 +00:00
|
|
|
break;
|
|
|
|
case CD_LBA_FORMAT:
|
2002-11-06 08:08:55 +00:00
|
|
|
entries[n].addr.lba = htonl(msf2hsg(sc->data.toc[trk].hd_pos_msf, 0));
|
1996-01-30 10:31:12 +00:00
|
|
|
break;
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
}
|
|
|
|
len -= sizeof(struct cd_toc_entry);
|
1996-01-30 10:31:12 +00:00
|
|
|
n++;
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* copy the data back */
|
1996-01-30 10:31:12 +00:00
|
|
|
return copyout(entries, te->data, n * sizeof(struct cd_toc_entry));
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_stop(struct mcd_softc *sc)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
|
|
|
|
1995-02-22 01:11:36 +00:00
|
|
|
/* Verify current status */
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.audio_status != CD_AS_PLAY_IN_PROGRESS &&
|
|
|
|
sc->data.audio_status != CD_AS_PLAY_PAUSED &&
|
|
|
|
sc->data.audio_status != CD_AS_PLAY_COMPLETED) {
|
|
|
|
if (sc->data.debug)
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev,
|
|
|
|
"stop attempted when not playing, audio status %d\n",
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.audio_status);
|
|
|
|
return (EINVAL);
|
1995-02-22 01:11:36 +00:00
|
|
|
}
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.audio_status == CD_AS_PLAY_IN_PROGRESS)
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_send(sc, MCD_CMDSTOPAUDIO, MCD_RETRYS) < 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
|
|
|
sc->data.audio_status = CD_AS_PLAY_COMPLETED;
|
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_getqchan(struct mcd_softc *sc, struct mcd_qchninfo *q)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_send(sc, MCD_CMDGETQCHN, MCD_RETRYS) < 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (-1);
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_get(sc, (char *) q, sizeof(struct mcd_qchninfo)) < 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (-1);
|
|
|
|
if (sc->data.debug) {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev,
|
|
|
|
"getqchan control=0x%x addr_type=0x%x trk=%d ind=%d ttm=%d:%d.%d dtm=%d:%d.%d\n",
|
|
|
|
q->control, q->addr_type,
|
|
|
|
bcd2bin(q->trk_no),
|
|
|
|
bcd2bin(q->idx_no),
|
|
|
|
bcd2bin(q->trk_size_msf[0]),
|
|
|
|
bcd2bin(q->trk_size_msf[1]),
|
|
|
|
bcd2bin(q->trk_size_msf[2]),
|
|
|
|
bcd2bin(q->hd_pos_msf[0]),
|
|
|
|
bcd2bin(q->hd_pos_msf[1]),
|
|
|
|
bcd2bin(q->hd_pos_msf[2]));
|
1994-02-22 08:44:31 +00:00
|
|
|
}
|
2002-11-06 08:08:55 +00:00
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_subchan(struct mcd_softc *sc, struct ioc_read_subchannel *sch)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
|
|
|
struct mcd_qchninfo q;
|
|
|
|
struct cd_sub_channel_info data;
|
1996-01-30 23:27:20 +00:00
|
|
|
int lba;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.debug)
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "subchan af=%d, df=%d\n",
|
|
|
|
sch->address_format,
|
|
|
|
sch->data_format);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (sch->address_format != CD_MSF_FORMAT &&
|
|
|
|
sch->address_format != CD_LBA_FORMAT)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EINVAL);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (sch->data_format != CD_CURRENT_POSITION &&
|
|
|
|
sch->data_format != CD_MEDIA_CATALOG)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EINVAL);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_setmode(sc, MCD_MD_COOKED) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_getqchan(sc, &q) < 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
data.header.audio_status = sc->data.audio_status;
|
2002-10-04 07:14:19 +00:00
|
|
|
data.what.position.data_format = sch->data_format;
|
1996-02-03 14:33:56 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
switch (sch->data_format) {
|
1996-02-03 14:33:56 +00:00
|
|
|
case CD_MEDIA_CATALOG:
|
|
|
|
data.what.media_catalog.mc_valid = 1;
|
|
|
|
data.what.media_catalog.mc_number[0] = '\0';
|
1996-01-30 10:31:12 +00:00
|
|
|
break;
|
1996-02-03 14:33:56 +00:00
|
|
|
|
|
|
|
case CD_CURRENT_POSITION:
|
|
|
|
data.what.position.control = q.control;
|
|
|
|
data.what.position.addr_type = q.addr_type;
|
|
|
|
data.what.position.track_number = bcd2bin(q.trk_no);
|
|
|
|
data.what.position.index_number = bcd2bin(q.idx_no);
|
2002-10-04 07:14:19 +00:00
|
|
|
switch (sch->address_format) {
|
1996-02-03 14:33:56 +00:00
|
|
|
case CD_MSF_FORMAT:
|
|
|
|
data.what.position.reladdr.msf.unused = 0;
|
|
|
|
data.what.position.reladdr.msf.minute = bcd2bin(q.trk_size_msf[0]);
|
|
|
|
data.what.position.reladdr.msf.second = bcd2bin(q.trk_size_msf[1]);
|
|
|
|
data.what.position.reladdr.msf.frame = bcd2bin(q.trk_size_msf[2]);
|
|
|
|
data.what.position.absaddr.msf.unused = 0;
|
|
|
|
data.what.position.absaddr.msf.minute = bcd2bin(q.hd_pos_msf[0]);
|
|
|
|
data.what.position.absaddr.msf.second = bcd2bin(q.hd_pos_msf[1]);
|
|
|
|
data.what.position.absaddr.msf.frame = bcd2bin(q.hd_pos_msf[2]);
|
|
|
|
break;
|
|
|
|
case CD_LBA_FORMAT:
|
|
|
|
lba = msf2hsg(q.trk_size_msf, 1);
|
|
|
|
/*
|
|
|
|
* Pre-gap has index number of 0, and decreasing MSF
|
|
|
|
* address. Must be converted to negative LBA, per
|
|
|
|
* SCSI spec.
|
|
|
|
*/
|
|
|
|
if (data.what.position.index_number == 0)
|
|
|
|
lba = -lba;
|
|
|
|
data.what.position.reladdr.lba = htonl(lba);
|
|
|
|
data.what.position.absaddr.lba = htonl(msf2hsg(q.hd_pos_msf, 0));
|
|
|
|
break;
|
|
|
|
}
|
1996-01-30 10:31:12 +00:00
|
|
|
break;
|
1995-02-23 17:40:16 +00:00
|
|
|
}
|
1994-11-12 14:19:11 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
return copyout(&data, sch->data, min(sizeof(struct cd_sub_channel_info), sch->data_len));
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_playmsf(struct mcd_softc *sc, struct ioc_play_msf *p)
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
{
|
|
|
|
struct mcd_read2 pb;
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.debug)
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "playmsf: from %d:%d.%d to %d:%d.%d\n",
|
1996-02-01 19:15:41 +00:00
|
|
|
p->start_m, p->start_s, p->start_f,
|
|
|
|
p->end_m, p->end_s, p->end_f);
|
|
|
|
|
|
|
|
if ((p->start_m * 60 * 75 + p->start_s * 75 + p->start_f) >=
|
|
|
|
(p->end_m * 60 * 75 + p->end_s * 75 + p->end_f) ||
|
|
|
|
(p->end_m * 60 * 75 + p->end_s * 75 + p->end_f) >
|
2002-11-06 08:08:55 +00:00
|
|
|
M_msf(sc->data.volinfo.vol_msf) * 60 * 75 +
|
|
|
|
S_msf(sc->data.volinfo.vol_msf) * 75 +
|
|
|
|
F_msf(sc->data.volinfo.vol_msf))
|
|
|
|
return (EINVAL);
|
1996-02-01 19:15:41 +00:00
|
|
|
|
|
|
|
pb.start_msf[0] = bin2bcd(p->start_m);
|
|
|
|
pb.start_msf[1] = bin2bcd(p->start_s);
|
|
|
|
pb.start_msf[2] = bin2bcd(p->start_f);
|
|
|
|
pb.end_msf[0] = bin2bcd(p->end_m);
|
|
|
|
pb.end_msf[1] = bin2bcd(p->end_s);
|
|
|
|
pb.end_msf[2] = bin2bcd(p->end_f);
|
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_setmode(sc, MCD_MD_COOKED) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_play(sc, &pb);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_playtracks(struct mcd_softc *sc, struct ioc_play_track *pt)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
|
|
|
struct mcd_read2 pb;
|
|
|
|
int a = pt->start_track;
|
|
|
|
int z = pt->end_track;
|
1994-11-12 14:19:11 +00:00
|
|
|
int rc, i;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if ((rc = mcd_read_toc(sc)) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (rc);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.debug)
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "playtracks from %d:%d to %d:%d\n",
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
a, pt->start_index, z, pt->end_index);
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if ( a < bcd2bin(sc->data.volinfo.trk_low)
|
|
|
|
|| a > bcd2bin(sc->data.volinfo.trk_high)
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|| a > z
|
2002-11-06 08:08:55 +00:00
|
|
|
|| z < bcd2bin(sc->data.volinfo.trk_low)
|
|
|
|
|| z > bcd2bin(sc->data.volinfo.trk_high))
|
|
|
|
return (EINVAL);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
1994-11-12 14:19:11 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
2002-11-06 08:08:55 +00:00
|
|
|
pb.start_msf[i] = sc->data.toc[a].hd_pos_msf[i];
|
|
|
|
pb.end_msf[i] = sc->data.toc[z+1].hd_pos_msf[i];
|
1994-11-12 14:19:11 +00:00
|
|
|
}
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_setmode(sc, MCD_MD_COOKED) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
1996-02-01 19:15:41 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_play(sc, &pb);
|
1996-02-01 19:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_playblocks(struct mcd_softc *sc, struct ioc_play_blocks *p)
|
1996-02-01 19:15:41 +00:00
|
|
|
{
|
|
|
|
struct mcd_read2 pb;
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.debug)
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "playblocks: blkno %d length %d\n",
|
|
|
|
p->blk, p->len);
|
1996-02-01 19:15:41 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (p->blk > sc->data.disksize || p->len > sc->data.disksize ||
|
1996-02-01 19:15:41 +00:00
|
|
|
p->blk < 0 || p->len < 0 ||
|
2002-11-06 08:08:55 +00:00
|
|
|
(p->blk + p->len) > sc->data.disksize)
|
|
|
|
return (EINVAL);
|
1996-02-01 19:15:41 +00:00
|
|
|
|
|
|
|
hsg2msf(p->blk, pb.start_msf);
|
|
|
|
hsg2msf(p->blk + p->len, pb.end_msf);
|
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_setmode(sc, MCD_MD_COOKED) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
1996-02-01 19:15:41 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
return mcd_play(sc, &pb);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_play(struct mcd_softc *sc, struct mcd_read2 *pb)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
int retry, st = -1, status;
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.lastpb = *pb;
|
1994-02-22 08:44:31 +00:00
|
|
|
for(retry=0; retry<MCD_RETRYS; retry++) {
|
1993-10-12 06:08:31 +00:00
|
|
|
|
2002-11-10 03:45:49 +00:00
|
|
|
critical_enter();
|
2002-10-04 07:14:19 +00:00
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDSINGLESPEEDREAD);
|
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, pb->start_msf[0]);
|
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, pb->start_msf[1]);
|
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, pb->start_msf[2]);
|
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, pb->end_msf[0]);
|
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, pb->end_msf[1]);
|
|
|
|
MCD_WRITE(sc, MCD_REG_COMMAND, pb->end_msf[2]);
|
2002-11-10 03:45:49 +00:00
|
|
|
critical_exit();
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
2002-10-04 07:14:19 +00:00
|
|
|
status=mcd_getstat(sc, 0);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
if (status == -1)
|
|
|
|
continue;
|
|
|
|
else if (status != -2)
|
|
|
|
st = 0;
|
|
|
|
break;
|
1994-02-22 08:44:31 +00:00
|
|
|
}
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
|
|
|
|
if (status == -2) {
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev, "media changed\n");
|
2002-11-06 08:08:55 +00:00
|
|
|
return (ENXIO);
|
1994-02-22 08:44:31 +00:00
|
|
|
}
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.debug)
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev,
|
|
|
|
"mcd_play retry=%d, status=0x%02x\n", retry, status);
|
Newly implemented ioctls list:
DIOCGDINFO, DIOCGPART, DIOCWDINFO, DIOCSDINFO, CDIOCPLAYMSF, CDIOCRESET,
CDIOCEJECT.
CDIOCPLAYBLOCKS removed (old implementation completely wrong and I don't
know how to implement it correctly).
All routines now detects media change correctly.
DELAY_GETREPLAY increased for long time access from first track
to last.
mcd_waitrdy() now use MIN_DELAY=15 as minimal delay which independs
of machine speed.
mcd_doread() now uses real status (old code uses obsoleted soft copy of it).
clear XBSY on error in mcd_doread()
mcd_statrt(): add missing splx(s), cause dead hang with unmatched slpbio()
optimize mcd_doread(), don't set CD mode each time, keep soft copy of mode.
call getdisklabel() _after_ mcdsize() for proper sizes
mcdopen(): old code forget to set MCDREADRAW in flags when open RAW
partition, doread check it for setting RAW CD mode.
Do nothing on stray interrupt (which sometimes occurse, because driver
read data block too slow, DOS driver use 'insb' here). Old stray code
cause timeouts.
Read toc entries code rewritten to return many requested entries
(as supposed) instead of one entry with incorrect structure.
CMDREAD2 requests covered with disable_intr()/enable_intr()
(from DOS driver)
Read junk code added after read block code in doread (from DOS driver)
mcd_read_toc() code fixed to read all needed entries, old code cause
some audio tracks is not played.
mcd_playtracks() code fixed to proper check valid track range.
New binary read modes implemented (from DOS driver).
1994-09-03 16:48:13 +00:00
|
|
|
if (st < 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (ENXIO);
|
|
|
|
sc->data.audio_status = CD_AS_PLAY_IN_PROGRESS;
|
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_pause(struct mcd_softc *sc)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
|
|
|
struct mcd_qchninfo q;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* Verify current status */
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.audio_status != CD_AS_PLAY_IN_PROGRESS &&
|
|
|
|
sc->data.audio_status != CD_AS_PLAY_PAUSED) {
|
|
|
|
if (sc->data.debug)
|
2002-10-04 07:14:19 +00:00
|
|
|
device_printf(sc->dev,
|
|
|
|
"pause attempted when not playing, audio status %d\n",
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.audio_status);
|
|
|
|
return (EINVAL);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the current position */
|
2002-10-04 07:14:19 +00:00
|
|
|
if (mcd_getqchan(sc, &q) < 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (EIO);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
/* Copy it into lastpb */
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.lastpb.start_msf[0] = q.hd_pos_msf[0];
|
|
|
|
sc->data.lastpb.start_msf[1] = q.hd_pos_msf[1];
|
|
|
|
sc->data.lastpb.start_msf[2] = q.hd_pos_msf[2];
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
/* Stop playing */
|
2002-10-04 07:14:19 +00:00
|
|
|
if ((rc=mcd_stop(sc)) != 0)
|
2002-11-06 08:08:55 +00:00
|
|
|
return (rc);
|
1993-10-12 06:08:31 +00:00
|
|
|
|
|
|
|
/* Set the proper status and exit */
|
2002-11-06 08:08:55 +00:00
|
|
|
sc->data.audio_status = CD_AS_PLAY_PAUSED;
|
|
|
|
return (0);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-22 08:44:31 +00:00
|
|
|
static int
|
2002-10-04 07:14:19 +00:00
|
|
|
mcd_resume(struct mcd_softc *sc)
|
1993-10-12 06:08:31 +00:00
|
|
|
{
|
|
|
|
|
2002-11-06 08:08:55 +00:00
|
|
|
if (sc->data.audio_status != CD_AS_PLAY_PAUSED)
|
|
|
|
return (EINVAL);
|
|
|
|
return mcd_play(sc, &sc->data.lastpb);
|
1993-10-12 06:08:31 +00:00
|
|
|
}
|