mcd.c (10624) | mcd.c (11872) |
---|---|
1/* 2 * Copyright 1993 by Holger Veit (data part) 3 * Copyright 1993 by Brian Moore (audio part) 4 * Changes Copyright 1993 by Gary Clark II 5 * Changes Copyright (C) 1994-1995 by Andrey A. Chernov, Moscow, Russia 6 * 7 * Rewrote probe routine to work on newer Mitsumi drives. 8 * Additional changes (C) 1994 by Jordan K. Hubbard --- 26 unchanged lines hidden (view full) --- 35 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 36 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 37 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 38 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 * | 1/* 2 * Copyright 1993 by Holger Veit (data part) 3 * Copyright 1993 by Brian Moore (audio part) 4 * Changes Copyright 1993 by Gary Clark II 5 * Changes Copyright (C) 1994-1995 by Andrey A. Chernov, Moscow, Russia 6 * 7 * Rewrote probe routine to work on newer Mitsumi drives. 8 * Additional changes (C) 1994 by Jordan K. Hubbard --- 26 unchanged lines hidden (view full) --- 35 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 36 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 37 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 38 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 * |
43 * $Id: mcd.c,v 1.45 1995/08/15 19:56:59 joerg Exp $ | 43 * $Id: mcd.c,v 1.46 1995/09/08 11:07:48 bde Exp $ |
44 */ 45static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore"; 46 47#include "mcd.h" 48#if NMCD > 0 49#include <sys/types.h> 50#include <sys/param.h> 51#include <sys/systm.h> --- 112 unchanged lines hidden (view full) --- 164#define MCD_S_WAITREAD 4 165 166/* prototypes */ 167int mcdopen(dev_t dev, int flags, int fmt, struct proc *p); 168int mcdclose(dev_t dev, int flags, int fmt, struct proc *p); 169void mcdstrategy(struct buf *bp); 170int mcdioctl(dev_t dev, int cmd, caddr_t addr, int flags, struct proc *p); 171int mcdsize(dev_t dev); | 44 */ 45static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore"; 46 47#include "mcd.h" 48#if NMCD > 0 49#include <sys/types.h> 50#include <sys/param.h> 51#include <sys/systm.h> --- 112 unchanged lines hidden (view full) --- 164#define MCD_S_WAITREAD 4 165 166/* prototypes */ 167int mcdopen(dev_t dev, int flags, int fmt, struct proc *p); 168int mcdclose(dev_t dev, int flags, int fmt, struct proc *p); 169void mcdstrategy(struct buf *bp); 170int mcdioctl(dev_t dev, int cmd, caddr_t addr, int flags, struct proc *p); 171int mcdsize(dev_t dev); |
172static void mcd_done(struct mcd_mbx *mbx); | |
173static void mcd_start(int unit); 174static int mcd_getdisklabel(int unit); | 172static void mcd_start(int unit); 173static int mcd_getdisklabel(int unit); |
174#ifdef NOTYET |
|
175static void mcd_configure(struct mcd_data *cd); | 175static void mcd_configure(struct mcd_data *cd); |
176#endif |
|
176static int mcd_get(int unit, char *buf, int nmax); 177static int mcd_setflags(int unit,struct mcd_data *cd); 178static int mcd_getstat(int unit,int sflg); 179static int mcd_send(int unit, int cmd,int nretrys); 180static int bcd2bin(bcd_t b); 181static bcd_t bin2bcd(int b); 182static void hsg2msf(int hsg, bcd_t *msf); 183static int msf2hsg(bcd_t *msf); --- 14 unchanged lines hidden (view full) --- 198static int mcd_play(int unit, struct mcd_read2 *pb); 199static int mcd_playmsf(int unit, struct ioc_play_msf *pt); 200static int mcd_pause(int unit); 201static int mcd_resume(int unit); 202static int mcd_lock_door(int unit, int lock); 203static int mcd_close_tray(int unit); 204 205extern int hz; | 177static int mcd_get(int unit, char *buf, int nmax); 178static int mcd_setflags(int unit,struct mcd_data *cd); 179static int mcd_getstat(int unit,int sflg); 180static int mcd_send(int unit, int cmd,int nretrys); 181static int bcd2bin(bcd_t b); 182static bcd_t bin2bcd(int b); 183static void hsg2msf(int hsg, bcd_t *msf); 184static int msf2hsg(bcd_t *msf); --- 14 unchanged lines hidden (view full) --- 199static int mcd_play(int unit, struct mcd_read2 *pb); 200static int mcd_playmsf(int unit, struct ioc_play_msf *pt); 201static int mcd_pause(int unit); 202static int mcd_resume(int unit); 203static int mcd_lock_door(int unit, int lock); 204static int mcd_close_tray(int unit); 205 206extern int hz; |
206extern int mcd_probe(struct isa_device *dev); 207extern int mcd_attach(struct isa_device *dev); | 207static int mcd_probe(struct isa_device *dev); 208static int mcd_attach(struct isa_device *dev); |
208struct isa_driver mcddriver = { mcd_probe, mcd_attach, "mcd" }; 209 210#define mcd_put(port,byte) outb(port,byte) 211 212#define MCD_RETRYS 5 213#define MCD_RDRETRYS 8 214 215#define CLOSE_TRAY_SECS 8 --- 27 unchanged lines hidden (view full) --- 243 kdc_mcd[id->id_unit].kdc_unit = id->id_unit; 244 kdc_mcd[id->id_unit].kdc_isa = id; 245 dev_attach(&kdc_mcd[id->id_unit]); 246} 247 248int mcd_attach(struct isa_device *dev) 249{ 250 struct mcd_data *cd = mcd_data + dev->id_unit; | 209struct isa_driver mcddriver = { mcd_probe, mcd_attach, "mcd" }; 210 211#define mcd_put(port,byte) outb(port,byte) 212 213#define MCD_RETRYS 5 214#define MCD_RDRETRYS 8 215 216#define CLOSE_TRAY_SECS 8 --- 27 unchanged lines hidden (view full) --- 244 kdc_mcd[id->id_unit].kdc_unit = id->id_unit; 245 kdc_mcd[id->id_unit].kdc_isa = id; 246 dev_attach(&kdc_mcd[id->id_unit]); 247} 248 249int mcd_attach(struct isa_device *dev) 250{ 251 struct mcd_data *cd = mcd_data + dev->id_unit; |
251 int i; | |
252 253 cd->iobase = dev->id_iobase; 254 cd->flags |= MCDINIT; 255 mcd_soft_reset(dev->id_unit); 256 257#ifdef NOTYET 258 /* wire controller for interrupts and dma */ 259 mcd_configure(cd); --- 184 unchanged lines hidden (view full) --- 444 return; 445} 446 447static void mcd_start(int unit) 448{ 449 struct mcd_data *cd = mcd_data + unit; 450 struct buf *bp, *qp = &cd->head; 451 struct partition *p; | 252 253 cd->iobase = dev->id_iobase; 254 cd->flags |= MCDINIT; 255 mcd_soft_reset(dev->id_unit); 256 257#ifdef NOTYET 258 /* wire controller for interrupts and dma */ 259 mcd_configure(cd); --- 184 unchanged lines hidden (view full) --- 444 return; 445} 446 447static void mcd_start(int unit) 448{ 449 struct mcd_data *cd = mcd_data + unit; 450 struct buf *bp, *qp = &cd->head; 451 struct partition *p; |
452 int part; | |
453 register s = splbio(); 454 455 if (cd->flags & MCDMBXBSY) { 456 splx(s); 457 return; 458 } 459 460 if ((bp = qp->b_actf) != 0) { --- 213 unchanged lines hidden (view full) --- 674}; 675 676static char 677drqs[] = { 678 0x00,0x01,0x00,0x03,0x00,0x05,0x06,0x07, 679}; 680#endif 681 | 452 register s = splbio(); 453 454 if (cd->flags & MCDMBXBSY) { 455 splx(s); 456 return; 457 } 458 459 if ((bp = qp->b_actf) != 0) { --- 213 unchanged lines hidden (view full) --- 673}; 674 675static char 676drqs[] = { 677 0x00,0x01,0x00,0x03,0x00,0x05,0x06,0x07, 678}; 679#endif 680 |
681#ifdef NOT_YET |
|
682static void 683mcd_configure(struct mcd_data *cd) 684{ 685 outb(cd->iobase+mcd_config,cd->config); 686} | 682static void 683mcd_configure(struct mcd_data *cd) 684{ 685 outb(cd->iobase+mcd_config,cd->config); 686} |
687#endif |
|
687 688/* Wait for non-busy - return 0 on timeout */ 689static int 690twiddle_thumbs(int port, int unit, int count, char *whine) 691{ 692 int i; 693 694 for (i = 0; i < count; i++) { --- 7 unchanged lines hidden (view full) --- 702/* check to see if a Mitsumi CD-ROM is attached to the ISA bus */ 703 704int 705mcd_probe(struct isa_device *dev) 706{ 707 int port = dev->id_iobase; 708 int unit = dev->id_unit; 709 int i, j; | 688 689/* Wait for non-busy - return 0 on timeout */ 690static int 691twiddle_thumbs(int port, int unit, int count, char *whine) 692{ 693 int i; 694 695 for (i = 0; i < count; i++) { --- 7 unchanged lines hidden (view full) --- 703/* check to see if a Mitsumi CD-ROM is attached to the ISA bus */ 704 705int 706mcd_probe(struct isa_device *dev) 707{ 708 int port = dev->id_iobase; 709 int unit = dev->id_unit; 710 int i, j; |
710 int status; | |
711 unsigned char stbytes[3]; 712 713 mcd_registerdev(dev); 714 mcd_data[unit].flags = MCDPROBING; 715 716#ifdef NOTDEF 717 /* get irq/drq configuration word */ 718 mcd_data[unit].config = irqs[dev->id_irq]; /* | drqs[dev->id_drq];*/ --- 72 unchanged lines hidden (view full) --- 791 DELAY(MIN_DELAY); 792 } 793 return -1; 794} 795 796static int 797mcd_getreply(int unit,int dly) 798{ | 711 unsigned char stbytes[3]; 712 713 mcd_registerdev(dev); 714 mcd_data[unit].flags = MCDPROBING; 715 716#ifdef NOTDEF 717 /* get irq/drq configuration word */ 718 mcd_data[unit].config = irqs[dev->id_irq]; /* | drqs[dev->id_drq];*/ --- 72 unchanged lines hidden (view full) --- 791 DELAY(MIN_DELAY); 792 } 793 return -1; 794} 795 796static int 797mcd_getreply(int unit,int dly) 798{ |
799 int i; | |
800 struct mcd_data *cd = mcd_data + unit; 801 int port = cd->iobase; 802 803 /* wait data to become ready */ 804 if (mcd_waitrdy(port,dly)<0) { 805 printf("mcd%d: timeout getreply\n",unit); 806 return -1; 807 } --- 41 unchanged lines hidden (view full) --- 849 else if (cd->audio_status == CD_AS_PLAY_IN_PROGRESS) 850 cd->audio_status = CD_AS_PLAY_COMPLETED; 851 return 0; 852} 853 854static int 855mcd_get(int unit, char *buf, int nmax) 856{ | 799 struct mcd_data *cd = mcd_data + unit; 800 int port = cd->iobase; 801 802 /* wait data to become ready */ 803 if (mcd_waitrdy(port,dly)<0) { 804 printf("mcd%d: timeout getreply\n",unit); 805 return -1; 806 } --- 41 unchanged lines hidden (view full) --- 848 else if (cd->audio_status == CD_AS_PLAY_IN_PROGRESS) 849 cd->audio_status = CD_AS_PLAY_COMPLETED; 850 return 0; 851} 852 853static int 854mcd_get(int unit, char *buf, int nmax) 855{ |
857 int port = mcd_data[unit].iobase; | |
858 int i,k; 859 860 for (i=0; i<nmax; i++) { 861 /* wait for data */ 862 if ((k = mcd_getreply(unit,DELAY_GETREPLY)) < 0) { 863 printf("mcd%d: timeout mcd_get\n",unit); 864 return -1; 865 } --- 55 unchanged lines hidden (view full) --- 921 bcd2bin(S_msf(msf))) * 75 + 922 bcd2bin(F_msf(msf)) - 150; 923} 924 925static int 926mcd_volinfo(int unit) 927{ 928 struct mcd_data *cd = mcd_data + unit; | 856 int i,k; 857 858 for (i=0; i<nmax; i++) { 859 /* wait for data */ 860 if ((k = mcd_getreply(unit,DELAY_GETREPLY)) < 0) { 861 printf("mcd%d: timeout mcd_get\n",unit); 862 return -1; 863 } --- 55 unchanged lines hidden (view full) --- 919 bcd2bin(S_msf(msf))) * 75 + 920 bcd2bin(F_msf(msf)) - 150; 921} 922 923static int 924mcd_volinfo(int unit) 925{ 926 struct mcd_data *cd = mcd_data + unit; |
929 int i; | |
930 931 /* Just return if we already have it */ 932 if (cd->flags & MCDVOLINFO) return 0; 933 934/*MCD_TRACE("mcd_volinfo: enter\n",0,0,0,0);*/ 935 936 /* send volume info command */ 937 if (mcd_send(unit,MCD_CMDGETVOLINFO,MCD_RETRYS) < 0) --- 733 unchanged lines hidden --- | 927 928 /* Just return if we already have it */ 929 if (cd->flags & MCDVOLINFO) return 0; 930 931/*MCD_TRACE("mcd_volinfo: enter\n",0,0,0,0);*/ 932 933 /* send volume info command */ 934 if (mcd_send(unit,MCD_CMDGETVOLINFO,MCD_RETRYS) < 0) --- 733 unchanged lines hidden --- |