mcd.c (24203) | mcd.c (25056) |
---|---|
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.86 1997/03/23 03:34:51 bde Exp $ | 43 * $Id: mcd.c,v 1.87 1997/03/24 11:23:55 bde Exp $ |
44 */ 45static const 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> --- 128 unchanged lines hidden (view full) --- 180static int mcd_get(int unit, char *buf, int nmax); 181static int mcd_setflags(int unit,struct mcd_data *cd); 182static int mcd_getstat(int unit,int sflg); 183static int mcd_send(int unit, int cmd,int nretrys); 184static void hsg2msf(int hsg, bcd_t *msf); 185static int msf2hsg(bcd_t *msf, int relative); 186static int mcd_volinfo(int unit); 187static int mcd_waitrdy(int port,int dly); | 44 */ 45static const 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> --- 128 unchanged lines hidden (view full) --- 180static int mcd_get(int unit, char *buf, int nmax); 181static int mcd_setflags(int unit,struct mcd_data *cd); 182static int mcd_getstat(int unit,int sflg); 183static int mcd_send(int unit, int cmd,int nretrys); 184static void hsg2msf(int hsg, bcd_t *msf); 185static int msf2hsg(bcd_t *msf, int relative); 186static int mcd_volinfo(int unit); 187static int mcd_waitrdy(int port,int dly); |
188static timeout_t mcd_timeout; |
|
188static void mcd_doread(int state, struct mcd_mbx *mbxin); 189static void mcd_soft_reset(int unit); 190static int mcd_hard_reset(int unit); 191static int mcd_setmode(int unit, int mode); 192static int mcd_getqchan(int unit, struct mcd_qchninfo *q); 193static int mcd_subchan(int unit, struct ioc_read_subchannel *sc); 194static int mcd_toc_header(int unit, struct ioc_toc_header *th); 195static int mcd_read_toc(int unit); --- 782 unchanged lines hidden (view full) --- 978 * initialize with MCD_S_BEGIN: calculate sizes, and read status 979 * MCD_S_WAITSTAT: wait for status reply, set mode 980 * MCD_S_WAITMODE: waits for status reply from set mode, set read command 981 * MCD_S_WAITREAD: wait for read ready, read data 982 */ 983static struct mcd_mbx *mbxsave; 984 985static void | 189static void mcd_doread(int state, struct mcd_mbx *mbxin); 190static void mcd_soft_reset(int unit); 191static int mcd_hard_reset(int unit); 192static int mcd_setmode(int unit, int mode); 193static int mcd_getqchan(int unit, struct mcd_qchninfo *q); 194static int mcd_subchan(int unit, struct ioc_read_subchannel *sc); 195static int mcd_toc_header(int unit, struct ioc_toc_header *th); 196static int mcd_read_toc(int unit); --- 782 unchanged lines hidden (view full) --- 979 * initialize with MCD_S_BEGIN: calculate sizes, and read status 980 * MCD_S_WAITSTAT: wait for status reply, set mode 981 * MCD_S_WAITMODE: waits for status reply from set mode, set read command 982 * MCD_S_WAITREAD: wait for read ready, read data 983 */ 984static struct mcd_mbx *mbxsave; 985 986static void |
987mcd_timeout(void *arg) 988{ 989 mcd_doread((int)arg, mbxsave); 990} 991 992static void |
|
986mcd_doread(int state, struct mcd_mbx *mbxin) 987{ 988 struct mcd_mbx *mbx = (state!=MCD_S_BEGIN) ? mbxsave : mbxin; 989 int unit = mbx->unit; 990 int port = mbx->port; 991 int com_port = mbx->port + mcd_command; 992 int data_port = mbx->port + mcd_rdata; 993 struct buf *bp = mbx->bp; --- 9 unchanged lines hidden (view full) --- 1003 case MCD_S_BEGIN: 1004 mbx = mbxsave = mbxin; 1005 1006 case MCD_S_BEGIN1: 1007retry_status: 1008 /* get status */ 1009 outb(com_port, MCD_CMDGETSTAT); 1010 mbx->count = RDELAY_WAITSTAT; | 993mcd_doread(int state, struct mcd_mbx *mbxin) 994{ 995 struct mcd_mbx *mbx = (state!=MCD_S_BEGIN) ? mbxsave : mbxin; 996 int unit = mbx->unit; 997 int port = mbx->port; 998 int com_port = mbx->port + mcd_command; 999 int data_port = mbx->port + mcd_rdata; 1000 struct buf *bp = mbx->bp; --- 9 unchanged lines hidden (view full) --- 1010 case MCD_S_BEGIN: 1011 mbx = mbxsave = mbxin; 1012 1013 case MCD_S_BEGIN1: 1014retry_status: 1015 /* get status */ 1016 outb(com_port, MCD_CMDGETSTAT); 1017 mbx->count = RDELAY_WAITSTAT; |
1011 timeout((timeout_func_t)mcd_doread, | 1018 timeout(mcd_timeout, |
1012 (caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */ 1013 return; 1014 case MCD_S_WAITSTAT: | 1019 (caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */ 1020 return; 1021 case MCD_S_WAITSTAT: |
1015 untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITSTAT); | 1022 untimeout(mcd_timeout,(caddr_t)MCD_S_WAITSTAT); |
1016 if (mbx->count-- >= 0) { 1017 if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) { | 1023 if (mbx->count-- >= 0) { 1024 if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) { |
1018 timeout((timeout_func_t)mcd_doread, | 1025 timeout(mcd_timeout, |
1019 (caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */ 1020 return; 1021 } 1022 cd->status = inb(port+mcd_status) & 0xFF; 1023 if (cd->status & MCD_ST_CMDCHECK) 1024 goto retry_status; 1025 if (mcd_setflags(unit,cd) < 0) 1026 goto changed; --- 20 unchanged lines hidden (view full) --- 1047 1048 mbx->count = RDELAY_WAITMODE; 1049 1050 cd->curr_mode = MCD_MD_UNKNOWN; 1051 mbx->mode = rm; 1052 mcd_put(com_port, MCD_CMDSETMODE); 1053 mcd_put(com_port, rm); 1054 | 1026 (caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */ 1027 return; 1028 } 1029 cd->status = inb(port+mcd_status) & 0xFF; 1030 if (cd->status & MCD_ST_CMDCHECK) 1031 goto retry_status; 1032 if (mcd_setflags(unit,cd) < 0) 1033 goto changed; --- 20 unchanged lines hidden (view full) --- 1054 1055 mbx->count = RDELAY_WAITMODE; 1056 1057 cd->curr_mode = MCD_MD_UNKNOWN; 1058 mbx->mode = rm; 1059 mcd_put(com_port, MCD_CMDSETMODE); 1060 mcd_put(com_port, rm); 1061 |
1055 timeout((timeout_func_t)mcd_doread, | 1062 timeout(mcd_timeout, |
1056 (caddr_t)MCD_S_WAITMODE,hz/100); /* XXX */ 1057 return; 1058 } else { 1059 printf("mcd%d: timeout getstatus\n",unit); 1060 goto readerr; 1061 } 1062 1063 case MCD_S_WAITMODE: | 1063 (caddr_t)MCD_S_WAITMODE,hz/100); /* XXX */ 1064 return; 1065 } else { 1066 printf("mcd%d: timeout getstatus\n",unit); 1067 goto readerr; 1068 } 1069 1070 case MCD_S_WAITMODE: |
1064 untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITMODE); | 1071 untimeout(mcd_timeout,(caddr_t)MCD_S_WAITMODE); |
1065 if (mbx->count-- < 0) { 1066 printf("mcd%d: timeout set mode\n",unit); 1067 goto readerr; 1068 } 1069 if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) { | 1072 if (mbx->count-- < 0) { 1073 printf("mcd%d: timeout set mode\n",unit); 1074 goto readerr; 1075 } 1076 if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) { |
1070 timeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITMODE,hz/100); | 1077 timeout(mcd_timeout,(caddr_t)MCD_S_WAITMODE,hz/100); |
1071 return; 1072 } 1073 cd->status = inb(port+mcd_status) & 0xFF; 1074 if (cd->status & MCD_ST_CMDCHECK) { 1075 cd->curr_mode = MCD_MD_UNKNOWN; 1076 goto retry_mode; 1077 } 1078 if (mcd_setflags(unit,cd) < 0) --- 31 unchanged lines hidden (view full) --- 1110 for (i = 0; i < 20; i++) { 1111 k = inb(port+MCD_FLAGS); 1112 if (!(k & MFL_DATA_NOT_AVAIL)) 1113 goto got_it; 1114 DELAY(100); 1115 } 1116 1117 mbx->count = RDELAY_WAITREAD; | 1078 return; 1079 } 1080 cd->status = inb(port+mcd_status) & 0xFF; 1081 if (cd->status & MCD_ST_CMDCHECK) { 1082 cd->curr_mode = MCD_MD_UNKNOWN; 1083 goto retry_mode; 1084 } 1085 if (mcd_setflags(unit,cd) < 0) --- 31 unchanged lines hidden (view full) --- 1117 for (i = 0; i < 20; i++) { 1118 k = inb(port+MCD_FLAGS); 1119 if (!(k & MFL_DATA_NOT_AVAIL)) 1120 goto got_it; 1121 DELAY(100); 1122 } 1123 1124 mbx->count = RDELAY_WAITREAD; |
1118 timeout((timeout_func_t)mcd_doread, | 1125 timeout(mcd_timeout, |
1119 (caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */ 1120 return; 1121 case MCD_S_WAITREAD: | 1126 (caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */ 1127 return; 1128 case MCD_S_WAITREAD: |
1122 untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITREAD); | 1129 untimeout(mcd_timeout,(caddr_t)MCD_S_WAITREAD); |
1123 if (mbx->count-- > 0) { 1124 k = inb(port+MCD_FLAGS); 1125 if (!(k & MFL_DATA_NOT_AVAIL)) { /* XXX */ 1126 MCD_TRACE("got data delay=%d\n", 1127 RDELAY_WAITREAD-mbx->count); 1128 got_it: 1129 /* data is ready */ 1130 addr = bp->b_un.b_addr + mbx->skip; --- 27 unchanged lines hidden (view full) --- 1158 } 1159 if (!(k & MFL_STATUS_NOT_AVAIL)) { 1160 cd->status = inb(port+mcd_status) & 0xFF; 1161 if (cd->status & MCD_ST_CMDCHECK) 1162 goto retry_read; 1163 if (mcd_setflags(unit,cd) < 0) 1164 goto changed; 1165 } | 1130 if (mbx->count-- > 0) { 1131 k = inb(port+MCD_FLAGS); 1132 if (!(k & MFL_DATA_NOT_AVAIL)) { /* XXX */ 1133 MCD_TRACE("got data delay=%d\n", 1134 RDELAY_WAITREAD-mbx->count); 1135 got_it: 1136 /* data is ready */ 1137 addr = bp->b_un.b_addr + mbx->skip; --- 27 unchanged lines hidden (view full) --- 1165 } 1166 if (!(k & MFL_STATUS_NOT_AVAIL)) { 1167 cd->status = inb(port+mcd_status) & 0xFF; 1168 if (cd->status & MCD_ST_CMDCHECK) 1169 goto retry_read; 1170 if (mcd_setflags(unit,cd) < 0) 1171 goto changed; 1172 } |
1166 timeout((timeout_func_t)mcd_doread, | 1173 timeout(mcd_timeout, |
1167 (caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */ 1168 return; 1169 } else { 1170 printf("mcd%d: timeout read data\n",unit); 1171 goto readerr; 1172 } 1173 } 1174 --- 619 unchanged lines hidden --- | 1174 (caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */ 1175 return; 1176 } else { 1177 printf("mcd%d: timeout read data\n",unit); 1178 goto readerr; 1179 } 1180 } 1181 --- 619 unchanged lines hidden --- |