Lines Matching +full:rate +full:- +full:b

1 // SPDX-License-Identifier: GPL-2.0-or-later
9 - 02/15/2004 first release
11 This Driver is based on the OSS Driver version from Linuxant (riptide-0.6lnxtbeta03111100)
17 ----------------------------- -------- -----
23 ----------------------------- -------- -----
29 ----------------------------- -------- -----
36 ----------------------------- -------- -----
44 ----------------------------- -------- -----
59 ----------------------------- -------- -----
65 ----------------------------- -------- -----
71 ----------------------------- -------- -----
113 static int joystick_port[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS - 1)] = 0x200 };
115 static int mpu_port[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS - 1)] = 0x330 };
116 static int opl3_port[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS - 1)] = 0x388 };
168 #define READ_AUDIO_CONTROL(p) READ_PORT_ULONG(p->audio_control)
169 #define WRITE_AUDIO_CONTROL(p,x) WRITE_PORT_ULONG(p->audio_control,x)
170 #define UMASK_AUDIO_CONTROL(p,x) WRITE_PORT_ULONG(p->audio_control,READ_PORT_ULONG(p->audio_contro…
171 #define MASK_AUDIO_CONTROL(p,x) WRITE_PORT_ULONG(p->audio_control,READ_PORT_ULONG(p->audio_contro…
172 #define READ_AUDIO_STATUS(p) READ_PORT_ULONG(p->audio_status)
192 #define IS_CMDE(a) (READ_PORT_ULONG(a->stat)&0x1) /* cmd empty */
193 #define IS_DATF(a) (READ_PORT_ULONG(a->stat)&0x2) /* data filled */
228 #define SEND_GETV(p,b) sendcmd(p,RESP,GETV,0,RET(b)) /* get version */ argument
229 #define SEND_GETC(p,b,c) sendcmd(p,PARM|RESP,GETC,c,RET(b)) argument
230 #define SEND_GUNS(p,b) sendcmd(p,RESP,GUNS,0,RET(b)) argument
231 #define SEND_SCID(p,b) sendcmd(p,RESP,SCID,0,RET(b)) argument
232 #define SEND_RMEM(p,b,c,d) sendcmd(p,PARM|RESP,RMEM|BYTE1(b),LONG0(c),RET(d)) /* memory acc… argument
233 #define SEND_SMEM(p,b,c) sendcmd(p,PARM,SMEM|BYTE1(b),LONG0(c),RET(0)) /* memory access f… argument
234 #define SEND_WMEM(p,b,c) sendcmd(p,PARM,WMEM|BYTE1(b),LONG0(c),RET(0)) /* memory access f… argument
235 #define SEND_SDTM(p,b,c) sendcmd(p,PARM|RESP,SDTM|TRINIB1(b),0,RET(c)) /* memory access f… argument
236 #define SEND_GOTO(p,b) sendcmd(p,PARM,GOTO,LONG0(b),RET(0)) /* memory access for firmwa… argument
238 #define SEND_SSTR(p,b,c) sendcmd(p,PARM,SSTR|BYTE3(b),LONG0(c),RET(0)) /* start stream */ argument
239 #define SEND_PSTR(p,b) sendcmd(p,PARM,PSTR,BYTE3(b),RET(0)) /* pause stream */ argument
240 #define SEND_KSTR(p,b) sendcmd(p,PARM,KSTR,BYTE3(b),RET(0)) /* stop stream */ argument
242 #define SEND_GPOS(p,b,c,d) sendcmd(p,PARM|RESP,GPOS,BYTE3(c)|BYTE2(b),RET(d)) /* get positi… argument
243 #define SEND_SETF(p,b,c,d,e,f,g) sendcmd(p,PARM,SETF|WORD1(b)|BYTE3(c),d|BYTE1(e)|BYTE2(f)|BYTE3(… argument
244 #define SEND_GSTS(p,b,c,d) sendcmd(p,PARM|RESP,GSTS,BYTE3(c)|BYTE2(b),RET(d)) argument
245 #define SEND_NGPOS(p,b,c,d) sendcmd(p,PARM|RESP,NGPOS,BYTE3(c)|BYTE2(b),RET(d)) argument
246 #define SEND_PSEL(p,b,c) sendcmd(p,PARM,PSEL,BYTE2(b)|BYTE3(c),RET(0)) /* activate lbus p… argument
247 #define SEND_PCLR(p,b,c) sendcmd(p,PARM,PCLR,BYTE2(b)|BYTE3(c),RET(0)) /* deactivate lbus… argument
248 #define SEND_PLST(p,b) sendcmd(p,PARM,PLST,BYTE3(b),RET(0)) argument
249 #define SEND_RSSV(p,b,c,d) sendcmd(p,PARM|RESP,RSSV,BYTE2(b)|BYTE3(c),RET(d)) argument
250 #define SEND_LSEL(p,b,c,d,e,f,g,h) sendcmd(p,PARM,LSEL|BYTE1(b)|BYTE2(c)|BYTE3(d),BYTE0(e)|BYTE1(f)… argument
251 #define SEND_SSRC(p,b,c,d,e) sendcmd(p,PARM,SSRC|BYTE1(b)|WORD2(c),WORD0(d)|WORD2(e),RET(0)) … argument
252 #define SEND_SLST(p,b) sendcmd(p,PARM,SLST,BYTE3(b),RET(0)) argument
253 #define SEND_RSRC(p,b,c) sendcmd(p,RESP,RSRC|BYTE1(b),0,RET(c)) /* read source config */ argument
254 #define SEND_SSRB(p,b,c) sendcmd(p,PARM,SSRB|BYTE1(b),WORD2(c),RET(0)) argument
255 #define SEND_SDGV(p,b,c,d,e) sendcmd(p,PARM,SDGV|BYTE2(b)|BYTE3(c),WORD0(d)|WORD2(e),RET(0)) … argument
256 #define SEND_RDGV(p,b,c,d) sendcmd(p,PARM|RESP,RDGV|BYTE2(b)|BYTE3(c),0,RET(d)) /* read dig… argument
257 #define SEND_DLST(p,b) sendcmd(p,PARM,DLST,BYTE3(b),RET(0)) argument
258 #define SEND_SACR(p,b,c) sendcmd(p,PARM,SACR,WORD0(b)|WORD2(c),RET(0)) /* set AC97 regist… argument
259 #define SEND_RACR(p,b,c) sendcmd(p,PARM|RESP,RACR,WORD2(b),RET(c)) /* get AC97 register */ argument
260 #define SEND_ALST(p,b) sendcmd(p,PARM,ALST,BYTE3(b),RET(0)) argument
261 #define SEND_TXAC(p,b,c,d,e,f) sendcmd(p,PARM,TXAC|BYTE1(b)|WORD2(c),WORD0(d)|BYTE2(e)|BYTE3(f)… argument
262 #define SEND_RXAC(p,b,c,d) sendcmd(p,PARM|RESP,RXAC,BYTE2(b)|BYTE3(c),RET(d)) argument
263 #define SEND_SI2S(p,b) sendcmd(p,PARM,SI2S,WORD2(b),RET(0)) argument
412 #define get_pcmhwdev(substream) (struct pcmhw *)(substream->runtime->private_data)
470 unsigned int rate; member
487 unsigned char *b);
657 c = in[len - 1]; in atoh()
662 --len; in atoh()
677 return -EACCES; in senddata()
684 return -EACCES; in senddata()
685 i -= 4; in senddata()
716 err = -EACCES; in loadfirmware()
725 size--; in loadfirmware()
731 dev_dbg(cif->dev, "load firmware return %d\n", err); in loadfirmware()
744 dev_dbg(cif->dev, "alloc path 0x%x->0x%x\n", source, sink); in alloclbuspath()
750 *mixer = sink - DIGITAL_MIXER_IN0; in alloclbuspath()
782 dev_dbg(cif->dev, "free path 0x%x->0x%x\n", source, sink); in freelbuspath()
805 while (--i) { in writearm()
815 dev_dbg(cif->dev, "send arm 0x%x 0x%x 0x%x return %d\n", addr, data, mask, in writearm()
831 return -EINVAL; in sendcmd()
833 hwport = cif->hwport; in sendcmd()
834 if (cif->errcnt > MAX_ERROR_COUNT) { in sendcmd()
835 if (cif->is_reset) { in sendcmd()
836 dev_err(cif->dev, in sendcmd()
839 cif->errcnt = 0; in sendcmd()
840 return -EIO; in sendcmd()
843 dev_err(cif->dev, "Riptide: Initialization failed.\n"); in sendcmd()
844 return -EINVAL; in sendcmd()
847 ret->retlongs[0] = 0; in sendcmd()
848 ret->retlongs[1] = 0; in sendcmd()
851 spin_lock_irqsave(&cif->lock, irqflags); in sendcmd()
852 while (i++ < CMDIF_TIMEOUT && !IS_READY(cif->hwport)) in sendcmd()
855 err = -EBUSY; in sendcmd()
861 cmdport = &(hwport->port[j % 2]); in sendcmd()
863 READ_PORT_ULONG(cmdport->data1); in sendcmd()
864 READ_PORT_ULONG(cmdport->data2); in sendcmd()
868 WRITE_PORT_ULONG(cmdport->data2, parm); in sendcmd()
869 WRITE_PORT_ULONG(cmdport->data1, cmd); /* write cmd */ in sendcmd()
877 ret->retlongs[0] = in sendcmd()
878 READ_PORT_ULONG(cmdport->data1); in sendcmd()
879 ret->retlongs[1] = in sendcmd()
880 READ_PORT_ULONG(cmdport->data2); in sendcmd()
882 err = -ENOSYS; in sendcmd()
891 err = -ENODATA; in sendcmd()
894 spin_unlock_irqrestore(&cif->lock, irqflags); in sendcmd()
896 cif->cmdcnt++; /* update command statistics */ in sendcmd()
897 cif->cmdtime += time; in sendcmd()
898 if (time > cif->cmdtimemax) in sendcmd()
899 cif->cmdtimemax = time; in sendcmd()
900 if (time < cif->cmdtimemin) in sendcmd()
901 cif->cmdtimemin = time; in sendcmd()
902 if ((cif->cmdcnt) % 1000 == 0) in sendcmd()
903 dev_dbg(cif->dev, in sendcmd()
905 cif->cmdcnt, cif->cmdtime, cif->cmdtimemin, in sendcmd()
906 cif->cmdtimemax, cif->errcnt); in sendcmd()
910 cif->errcnt++; in sendcmd()
911 spin_unlock_irqrestore(&cif->lock, irqflags); in sendcmd()
912 dev_dbg(cif->dev, in sendcmd()
914 cif->cmdcnt, (int)((void *)&(cmdport->stat) - (void *)hwport), in sendcmd()
915 flags, cmd, parm, ret ? ret->retlongs[0] : 0, in sendcmd()
916 ret ? ret->retlongs[1] : 0, IS_CMDE(cmdport), IS_DATF(cmdport), in sendcmd()
927 dev_dbg(cif->dev, "sent mixer %d: 0x%x 0x%x\n", num, rval, lval); in setmixer()
934 dev_dbg(cif->dev, "sent mixer failed\n"); in setmixer()
935 return -EIO; in setmixer()
956 unsigned char *a, unsigned char *b) in getsourcesink() argument
962 return -EIO; in getsourcesink()
964 *b = rptr.retbytes[1]; in getsourcesink()
965 dev_dbg(cif->dev, "%s 0x%x 0x%x\n", __func__, *a, *b); in getsourcesink()
970 getsamplerate(struct cmdif *cif, unsigned char *intdec, unsigned int *rate) in getsamplerate() argument
982 return -EIO; in getsamplerate()
992 dev_dbg(cif->dev, "rates differ %d %d\n", p[0], p[1]); in getsamplerate()
993 *rate = (unsigned int)p[0]; in getsamplerate()
995 *rate = (unsigned int)p[1]; in getsamplerate()
996 dev_dbg(cif->dev, "getsampleformat %d %d %d\n", intdec[0], intdec[1], *rate); in getsamplerate()
1007 dev_dbg(cif->dev, in setsampleformat()
1017 dev_dbg(cif->dev, "%s failed\n", __func__); in setsampleformat()
1018 return -EIO; in setsampleformat()
1024 setsamplerate(struct cmdif *cif, unsigned char *intdec, unsigned int rate) in setsamplerate() argument
1030 dev_dbg(cif->dev, "%s intdec: %d,%d rate: %d\n", __func__, in setsamplerate()
1031 intdec[0], intdec[1], rate); in setsamplerate()
1033 M = ((rate == 48000) ? 47999 : rate) * 65536; in setsamplerate()
1046 dev_dbg(cif->dev, "sent samplerate %d: %d failed\n", in setsamplerate()
1047 *intdec, rate); in setsamplerate()
1048 return -EIO; in setsamplerate()
1063 return -EIO; in getmixer()
1066 dev_dbg(cif->dev, "got mixer %d: 0x%x 0x%x\n", num, *rval, *lval); in getmixer()
1073 struct cmdif *cif = chip->cif; in riptide_handleirq()
1086 substream[i] = chip->playback_substream[i]; in riptide_handleirq()
1087 substream[i] = chip->capture_substream; in riptide_handleirq()
1091 runtime = substream[i]->runtime; in riptide_handleirq()
1094 data = runtime->private_data; in riptide_handleirq()
1097 if (data->state != ST_STOP) { in riptide_handleirq()
1099 for (j = 0; j < data->pages; j++) { in riptide_handleirq()
1100 c = &data->sgdbuf[j]; in riptide_handleirq()
1101 flag = le32_to_cpu(c->dwStat_Ctl); in riptide_handleirq()
1103 pos += le32_to_cpu(c->dwSegLen); in riptide_handleirq()
1105 pos += le32_to_cpu(c->dwSegLen); in riptide_handleirq()
1107 && (data->state == ST_PLAY)) { in riptide_handleirq()
1108 data->state = ST_STOP; in riptide_handleirq()
1109 dev_err(cif->dev, in riptide_handleirq()
1112 c->dwStat_Ctl = in riptide_handleirq()
1117 data->pointer += pos; in riptide_handleirq()
1118 pos += data->oldpos; in riptide_handleirq()
1119 if (data->state != ST_STOP) { in riptide_handleirq()
1122 runtime->period_size); in riptide_handleirq()
1123 dev_dbg(cif->dev, in riptide_handleirq()
1125 READ_AUDIO_STATUS(cif->hwport), in riptide_handleirq()
1127 runtime->period_size); in riptide_handleirq()
1132 pos -= period_bytes; in riptide_handleirq()
1134 data->oldpos = pos; in riptide_handleirq()
1147 struct snd_riptide *chip = card->private_data; in riptide_suspend()
1149 chip->in_suspend = 1; in riptide_suspend()
1151 snd_ac97_suspend(chip->ac97); in riptide_suspend()
1158 struct snd_riptide *chip = card->private_data; in riptide_resume()
1161 snd_ac97_resume(chip->ac97); in riptide_resume()
1163 chip->in_suspend = 0; in riptide_resume()
1175 WRITE_PORT_ULONG(cif->hwport->port[i].data1, 0); in try_to_load_firmware()
1176 WRITE_PORT_ULONG(cif->hwport->port[i].data2, 0); in try_to_load_firmware()
1178 SET_GRESET(cif->hwport); in try_to_load_firmware()
1180 UNSET_GRESET(cif->hwport); in try_to_load_firmware()
1183 for (timeout = 100000; --timeout; udelay(10)) { in try_to_load_firmware()
1184 if (IS_READY(cif->hwport) && !IS_GERR(cif->hwport)) in try_to_load_firmware()
1188 dev_err(cif->dev, in try_to_load_firmware()
1190 READ_AUDIO_STATUS(cif->hwport), in try_to_load_firmware()
1191 IS_READY(cif->hwport), IS_GERR(cif->hwport)); in try_to_load_firmware()
1192 return -EIO; in try_to_load_firmware()
1194 dev_dbg(cif->dev, in try_to_load_firmware()
1196 READ_AUDIO_STATUS(cif->hwport), in try_to_load_firmware()
1197 IS_READY(cif->hwport), IS_GERR(cif->hwport)); in try_to_load_firmware()
1201 dev_dbg(cif->dev, in try_to_load_firmware()
1215 dev_dbg(cif->dev, "Writing Firmware\n"); in try_to_load_firmware()
1216 if (!chip->fw_entry) { in try_to_load_firmware()
1217 err = request_firmware(&chip->fw_entry, "riptide.hex", in try_to_load_firmware()
1218 &chip->pci->dev); in try_to_load_firmware()
1220 dev_err(cif->dev, in try_to_load_firmware()
1222 return -EIO; in try_to_load_firmware()
1225 err = loadfirmware(cif, chip->fw_entry->data, chip->fw_entry->size); in try_to_load_firmware()
1227 dev_err(cif->dev, in try_to_load_firmware()
1232 chip->firmware = firmware; in try_to_load_firmware()
1243 return -EINVAL; in riptide_reset()
1245 cif->cmdcnt = 0; in riptide_reset()
1246 cif->cmdtime = 0; in riptide_reset()
1247 cif->cmdtimemax = 0; in riptide_reset()
1248 cif->cmdtimemin = 0xffffffff; in riptide_reset()
1249 cif->errcnt = 0; in riptide_reset()
1250 cif->is_reset = 0; in riptide_reset()
1257 } while (!err && --tries); in riptide_reset()
1261 dev_dbg(cif->dev, "AC97: 0x%x 0x%x\n", rptr.retlongs[0], rptr.retlongs[1]); in riptide_reset()
1295 SET_AIACK(cif->hwport); in riptide_reset()
1296 SET_AIE(cif->hwport); in riptide_reset()
1297 SET_AIACK(cif->hwport); in riptide_reset()
1298 cif->is_reset = 1; in riptide_reset()
1346 struct snd_pcm_runtime *runtime = substream->runtime; in snd_riptide_pointer()
1348 struct cmdif *cif = chip->cif; in snd_riptide_pointer()
1352 SEND_GPOS(cif, 0, data->id, &rptr); in snd_riptide_pointer()
1353 if (data->size && runtime->period_size) { in snd_riptide_pointer()
1354 dev_dbg(cif->dev, in snd_riptide_pointer()
1356 data->id, rptr.retlongs[1], rptr.retlongs[1] % data->size, in snd_riptide_pointer()
1359 rptr.retlongs[1]) % runtime->period_size); in snd_riptide_pointer()
1360 if (rptr.retlongs[1] > data->pointer) in snd_riptide_pointer()
1363 rptr.retlongs[1] % data->size); in snd_riptide_pointer()
1367 data->pointer % data->size); in snd_riptide_pointer()
1369 dev_dbg(cif->dev, in snd_riptide_pointer()
1371 data->size, runtime->period_size); in snd_riptide_pointer()
1382 struct cmdif *cif = chip->cif; in snd_riptide_trigger()
1385 spin_lock(&chip->lock); in snd_riptide_trigger()
1389 if (!(data->state & ST_PLAY)) { in snd_riptide_trigger()
1390 SEND_SSTR(cif, data->id, data->sgdlist.addr); in snd_riptide_trigger()
1391 SET_AIE(cif->hwport); in snd_riptide_trigger()
1392 data->state = ST_PLAY; in snd_riptide_trigger()
1393 if (data->mixer != 0xff) in snd_riptide_trigger()
1394 setmixer(cif, data->mixer, 0x7fff, 0x7fff); in snd_riptide_trigger()
1395 chip->openstreams++; in snd_riptide_trigger()
1396 data->oldpos = 0; in snd_riptide_trigger()
1397 data->pointer = 0; in snd_riptide_trigger()
1402 if (data->mixer != 0xff) in snd_riptide_trigger()
1403 setmixer(cif, data->mixer, 0, 0); in snd_riptide_trigger()
1404 setmixer(cif, data->mixer, 0, 0); in snd_riptide_trigger()
1405 SEND_KSTR(cif, data->id); in snd_riptide_trigger()
1406 data->state = ST_STOP; in snd_riptide_trigger()
1407 chip->openstreams--; in snd_riptide_trigger()
1411 SEND_GPOS(cif, 0, data->id, &rptr); in snd_riptide_trigger()
1415 dev_err(cif->dev, "Riptide: Could not stop stream!"); in snd_riptide_trigger()
1418 if (!(data->state & ST_PAUSE)) { in snd_riptide_trigger()
1419 SEND_PSTR(cif, data->id); in snd_riptide_trigger()
1420 data->state |= ST_PAUSE; in snd_riptide_trigger()
1421 chip->openstreams--; in snd_riptide_trigger()
1425 if (data->state & ST_PAUSE) { in snd_riptide_trigger()
1426 SEND_SSTR(cif, data->id, data->sgdlist.addr); in snd_riptide_trigger()
1427 data->state &= ~ST_PAUSE; in snd_riptide_trigger()
1428 chip->openstreams++; in snd_riptide_trigger()
1432 spin_unlock(&chip->lock); in snd_riptide_trigger()
1433 return -EINVAL; in snd_riptide_trigger()
1435 spin_unlock(&chip->lock); in snd_riptide_trigger()
1442 struct snd_pcm_runtime *runtime = substream->runtime; in snd_riptide_prepare()
1444 struct cmdif *cif = chip->cif; in snd_riptide_prepare()
1446 unsigned int rate, channels; in snd_riptide_prepare() local
1451 return -EINVAL; in snd_riptide_prepare()
1453 dev_dbg(cif->dev, "prepare id %d ch: %d f:0x%x r:%d\n", data->id, in snd_riptide_prepare()
1454 runtime->channels, runtime->format, runtime->rate); in snd_riptide_prepare()
1456 spin_lock_irq(&chip->lock); in snd_riptide_prepare()
1457 channels = runtime->channels; in snd_riptide_prepare()
1458 format = runtime->format; in snd_riptide_prepare()
1459 rate = runtime->rate; in snd_riptide_prepare()
1462 if (rate == 48000 && format == SNDRV_PCM_FORMAT_S16_LE) in snd_riptide_prepare()
1463 lbuspath = data->paths.noconv; in snd_riptide_prepare()
1465 lbuspath = data->paths.mono; in snd_riptide_prepare()
1468 if (rate == 48000 && format == SNDRV_PCM_FORMAT_S16_LE) in snd_riptide_prepare()
1469 lbuspath = data->paths.noconv; in snd_riptide_prepare()
1471 lbuspath = data->paths.stereo; in snd_riptide_prepare()
1474 dev_dbg(cif->dev, "use sgdlist at 0x%p\n", data->sgdlist.area); in snd_riptide_prepare()
1475 if (data->sgdlist.area) { in snd_riptide_prepare()
1479 size = frames_to_bytes(runtime, runtime->buffer_size); in snd_riptide_prepare()
1480 period = frames_to_bytes(runtime, runtime->period_size); in snd_riptide_prepare()
1482 while ((size + (f >> 1) - 1) <= (f << 7) && (f << 1) > period) in snd_riptide_prepare()
1485 data->size = size; in snd_riptide_prepare()
1486 data->pages = pages; in snd_riptide_prepare()
1487 dev_dbg(cif->dev, in snd_riptide_prepare()
1494 c = &data->sgdbuf[i]; in snd_riptide_prepare()
1496 p->dwNextLink = cpu_to_le32(data->sgdlist.addr + in snd_riptide_prepare()
1500 c->dwNextLink = cpu_to_le32(data->sgdlist.addr); in snd_riptide_prepare()
1503 c->dwSegPtrPhys = cpu_to_le32(addr); in snd_riptide_prepare()
1507 c->dwSegLen = cpu_to_le32(f); in snd_riptide_prepare()
1508 c->dwStat_Ctl = in snd_riptide_prepare()
1512 size -= f; in snd_riptide_prepare()
1514 data->sgdbuf[i].dwSegLen = cpu_to_le32(size); in snd_riptide_prepare()
1516 if (lbuspath && lbuspath != data->lbuspath) { in snd_riptide_prepare()
1517 if (data->lbuspath) in snd_riptide_prepare()
1518 freelbuspath(cif, data->source, data->lbuspath); in snd_riptide_prepare()
1519 alloclbuspath(cif, data->source, lbuspath, in snd_riptide_prepare()
1520 &data->mixer, data->intdec); in snd_riptide_prepare()
1521 data->lbuspath = lbuspath; in snd_riptide_prepare()
1522 data->rate = 0; in snd_riptide_prepare()
1524 if (data->rate != rate || data->format != format || in snd_riptide_prepare()
1525 data->channels != channels) { in snd_riptide_prepare()
1526 data->rate = rate; in snd_riptide_prepare()
1527 data->format = format; in snd_riptide_prepare()
1528 data->channels = channels; in snd_riptide_prepare()
1530 (cif, data->mixer, data->id, channels, format) in snd_riptide_prepare()
1531 || setsamplerate(cif, data->intdec, rate)) in snd_riptide_prepare()
1532 err = -EIO; in snd_riptide_prepare()
1534 spin_unlock_irq(&chip->lock); in snd_riptide_prepare()
1544 struct snd_dma_buffer *sgdlist = &data->sgdlist; in snd_riptide_hw_params()
1547 dev_dbg(chip->card->dev, "hw params id %d (sgdlist: 0x%p 0x%lx %d)\n", in snd_riptide_hw_params()
1548 data->id, sgdlist->area, (unsigned long)sgdlist->addr, in snd_riptide_hw_params()
1549 (int)sgdlist->bytes); in snd_riptide_hw_params()
1550 if (sgdlist->area) in snd_riptide_hw_params()
1552 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev, in snd_riptide_hw_params()
1556 dev_err(chip->card->dev, in snd_riptide_hw_params()
1561 data->sgdbuf = (struct sgd *)sgdlist->area; in snd_riptide_hw_params()
1569 struct cmdif *cif = chip->cif; in snd_riptide_hw_free()
1572 if (data->lbuspath) in snd_riptide_hw_free()
1573 freelbuspath(cif, data->source, data->lbuspath); in snd_riptide_hw_free()
1574 data->lbuspath = NULL; in snd_riptide_hw_free()
1575 data->source = 0xff; in snd_riptide_hw_free()
1576 data->intdec[0] = 0xff; in snd_riptide_hw_free()
1577 data->intdec[1] = 0xff; in snd_riptide_hw_free()
1579 if (data->sgdlist.area) { in snd_riptide_hw_free()
1580 snd_dma_free_pages(&data->sgdlist); in snd_riptide_hw_free()
1581 data->sgdlist.area = NULL; in snd_riptide_hw_free()
1590 struct snd_pcm_runtime *runtime = substream->runtime; in snd_riptide_playback_open()
1592 int sub_num = substream->number; in snd_riptide_playback_open()
1594 chip->playback_substream[sub_num] = substream; in snd_riptide_playback_open()
1595 runtime->hw = snd_riptide_playback; in snd_riptide_playback_open()
1599 return -ENOMEM; in snd_riptide_playback_open()
1600 data->paths = lbus_play_paths[sub_num]; in snd_riptide_playback_open()
1601 data->id = play_ids[sub_num]; in snd_riptide_playback_open()
1602 data->source = play_sources[sub_num]; in snd_riptide_playback_open()
1603 data->intdec[0] = 0xff; in snd_riptide_playback_open()
1604 data->intdec[1] = 0xff; in snd_riptide_playback_open()
1605 data->state = ST_STOP; in snd_riptide_playback_open()
1606 runtime->private_data = data; in snd_riptide_playback_open()
1614 struct snd_pcm_runtime *runtime = substream->runtime; in snd_riptide_capture_open()
1617 chip->capture_substream = substream; in snd_riptide_capture_open()
1618 runtime->hw = snd_riptide_capture; in snd_riptide_capture_open()
1622 return -ENOMEM; in snd_riptide_capture_open()
1623 data->paths = lbus_rec_path; in snd_riptide_capture_open()
1624 data->id = PADC; in snd_riptide_capture_open()
1625 data->source = ACLNK2PADC; in snd_riptide_capture_open()
1626 data->intdec[0] = 0xff; in snd_riptide_capture_open()
1627 data->intdec[1] = 0xff; in snd_riptide_capture_open()
1628 data->state = ST_STOP; in snd_riptide_capture_open()
1629 runtime->private_data = data; in snd_riptide_capture_open()
1638 int sub_num = substream->number; in snd_riptide_playback_close()
1640 substream->runtime->private_data = NULL; in snd_riptide_playback_close()
1641 chip->playback_substream[sub_num] = NULL; in snd_riptide_playback_close()
1651 substream->runtime->private_data = NULL; in snd_riptide_capture_close()
1652 chip->capture_substream = NULL; in snd_riptide_capture_close()
1681 err = snd_pcm_new(chip->card, "RIPTIDE", device, PLAYBACK_SUBSTREAMS, 1, in snd_riptide_pcm()
1689 pcm->private_data = chip; in snd_riptide_pcm()
1690 pcm->info_flags = 0; in snd_riptide_pcm()
1691 strscpy(pcm->name, "RIPTIDE"); in snd_riptide_pcm()
1692 chip->pcm = pcm; in snd_riptide_pcm()
1694 &chip->pci->dev, 64 * 1024, 128 * 1024); in snd_riptide_pcm()
1702 struct cmdif *cif = chip->cif; in snd_riptide_interrupt()
1706 chip->received_irqs++; in snd_riptide_interrupt()
1707 if (IS_EOBIRQ(cif->hwport) || IS_EOSIRQ(cif->hwport) || in snd_riptide_interrupt()
1708 IS_EOCIRQ(cif->hwport)) { in snd_riptide_interrupt()
1709 chip->handled_irqs++; in snd_riptide_interrupt()
1712 if (chip->rmidi && IS_MPUIRQ(cif->hwport)) { in snd_riptide_interrupt()
1713 chip->handled_irqs++; in snd_riptide_interrupt()
1715 chip->rmidi->private_data); in snd_riptide_interrupt()
1717 SET_AIACK(cif->hwport); in snd_riptide_interrupt()
1726 struct snd_riptide *chip = ac97->private_data; in snd_riptide_codec_write()
1727 struct cmdif *cif = chip->cif; in snd_riptide_codec_write()
1734 dev_dbg(cif->dev, "Write AC97 reg 0x%x 0x%x\n", reg, val); in snd_riptide_codec_write()
1740 dev_dbg(cif->dev, "Write AC97 reg failed\n"); in snd_riptide_codec_write()
1746 struct snd_riptide *chip = ac97->private_data; in snd_riptide_codec_read()
1747 struct cmdif *cif = chip->cif; in snd_riptide_codec_read()
1755 dev_dbg(cif->dev, "Read AC97 reg 0x%x got 0x%x\n", reg, rptr.retwords[1]); in snd_riptide_codec_read()
1766 return -EINVAL; in snd_riptide_initialize()
1768 cif = chip->cif; in snd_riptide_initialize()
1772 return -ENOMEM; in snd_riptide_initialize()
1773 cif->dev = chip->card->dev; in snd_riptide_initialize()
1774 cif->hwport = (struct riptideport *)chip->port; in snd_riptide_initialize()
1775 spin_lock_init(&cif->lock); in snd_riptide_initialize()
1776 chip->cif = cif; in snd_riptide_initialize()
1778 cif->is_reset = 0; in snd_riptide_initialize()
1782 device_id = chip->device_id; in snd_riptide_initialize()
1787 dev_dbg(cif->dev, "Modem enable?\n"); in snd_riptide_initialize()
1791 dev_dbg(cif->dev, "Enabling MPU IRQs\n"); in snd_riptide_initialize()
1792 if (chip->rmidi) in snd_riptide_initialize()
1793 SET_EMPUIRQ(cif->hwport); in snd_riptide_initialize()
1799 struct snd_riptide *chip = card->private_data; in snd_riptide_free()
1802 cif = chip->cif; in snd_riptide_free()
1804 SET_GRESET(cif->hwport); in snd_riptide_free()
1806 UNSET_GRESET(cif->hwport); in snd_riptide_free()
1807 kfree(chip->cif); in snd_riptide_free()
1809 release_firmware(chip->fw_entry); in snd_riptide_free()
1815 struct snd_riptide *chip = card->private_data; in snd_riptide_create()
1823 spin_lock_init(&chip->lock); in snd_riptide_create()
1824 chip->card = card; in snd_riptide_create()
1825 chip->pci = pci; in snd_riptide_create()
1826 chip->irq = -1; in snd_riptide_create()
1827 chip->openstreams = 0; in snd_riptide_create()
1828 chip->port = pci_resource_start(pci, 0); in snd_riptide_create()
1829 chip->received_irqs = 0; in snd_riptide_create()
1830 chip->handled_irqs = 0; in snd_riptide_create()
1831 chip->cif = NULL; in snd_riptide_create()
1832 card->private_free = snd_riptide_free; in snd_riptide_create()
1837 hwport = (struct riptideport *)chip->port; in snd_riptide_create()
1840 if (devm_request_threaded_irq(&pci->dev, pci->irq, in snd_riptide_create()
1844 dev_err(&pci->dev, "Riptide: unable to grab IRQ %d\n", in snd_riptide_create()
1845 pci->irq); in snd_riptide_create()
1846 return -EBUSY; in snd_riptide_create()
1848 chip->irq = pci->irq; in snd_riptide_create()
1849 card->sync_irq = chip->irq; in snd_riptide_create()
1850 chip->device_id = pci->device; in snd_riptide_create()
1863 struct snd_riptide *chip = entry->private_data; in snd_riptide_proc_read()
1869 unsigned int rate; in snd_riptide_proc_read() local
1874 snd_iprintf(buffer, "%s\n\n", chip->card->longname); in snd_riptide_proc_read()
1876 chip->device_id, chip->handled_irqs, chip->received_irqs); in snd_riptide_proc_read()
1879 (i % 16) ? ' ' : '\n', i, inl(chip->port + i)); in snd_riptide_proc_read()
1880 cif = chip->cif; in snd_riptide_proc_read()
1884 chip->firmware.firmware.ASIC, in snd_riptide_proc_read()
1885 chip->firmware.firmware.CODEC, in snd_riptide_proc_read()
1886 chip->firmware.firmware.AUXDSP, in snd_riptide_proc_read()
1887 chip->firmware.firmware.PROG); in snd_riptide_proc_read()
1895 cif->cmdcnt, cif->errcnt, in snd_riptide_proc_read()
1896 cif->cmdtime, cif->cmdtimemax, cif->cmdtimemin); in snd_riptide_proc_read()
1898 snd_iprintf(buffer, "\nOpen streams %d:\n", chip->openstreams); in snd_riptide_proc_read()
1900 if (!chip->playback_substream[i] || in snd_riptide_proc_read()
1901 !chip->playback_substream[i]->runtime) in snd_riptide_proc_read()
1903 data = chip->playback_substream[i]->runtime->private_data; in snd_riptide_proc_read()
1907 data->id, data->mixer, data->source, in snd_riptide_proc_read()
1908 data->intdec[0], data->intdec[1]); in snd_riptide_proc_read()
1909 if (!(getsamplerate(cif, data->intdec, &rate))) in snd_riptide_proc_read()
1910 snd_iprintf(buffer, "rate: %d\n", rate); in snd_riptide_proc_read()
1913 if (chip->capture_substream && chip->capture_substream->runtime) { in snd_riptide_proc_read()
1914 data = chip->capture_substream->runtime->private_data; in snd_riptide_proc_read()
1918 data->id, data->mixer, in snd_riptide_proc_read()
1919 data->source, data->intdec[0], data->intdec[1]); in snd_riptide_proc_read()
1920 if (!(getsamplerate(cif, data->intdec, &rate))) in snd_riptide_proc_read()
1921 snd_iprintf(buffer, "rate: %d\n", rate); in snd_riptide_proc_read()
1927 i -= 2; in snd_riptide_proc_read()
1928 snd_iprintf(buffer, "%x->%x ", p[i], p[i + 1]); in snd_riptide_proc_read()
1935 snd_card_ro_proc_new(chip->card, "riptide", chip, in snd_riptide_proc_init()
1953 err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus); in snd_riptide_mixer()
1957 chip->ac97_bus = pbus; in snd_riptide_mixer()
1958 ac97.pci = chip->pci; in snd_riptide_mixer()
1959 err = snd_ac97_mixer(pbus, &ac97, &chip->ac97); in snd_riptide_mixer()
1975 return -ENODEV; in snd_riptide_joystick_probe()
1978 ret = -ENOENT; in snd_riptide_joystick_probe()
1989 ret = -ENOMEM; in snd_riptide_joystick_probe()
1993 dev_err(&pci->dev, in snd_riptide_joystick_probe()
1997 ret = -EBUSY; in snd_riptide_joystick_probe()
2001 gameport->io = joystick_port[dev]; in snd_riptide_joystick_probe()
2015 release_region(gameport->io, 8); in snd_riptide_joystick_remove()
2031 return -ENODEV; in __snd_card_riptide_probe()
2034 return -ENOENT; in __snd_card_riptide_probe()
2037 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in __snd_card_riptide_probe()
2041 chip = card->private_data; in __snd_card_riptide_probe()
2061 val |= (chip->irq << 4) & 0xf0; in __snd_card_riptide_probe()
2062 pci_write_config_word(chip->pci, PCI_EXT_Legacy_Mask, val); in __snd_card_riptide_probe()
2065 pci_write_config_word(chip->pci, PCI_EXT_MPU_Base, val); in __snd_card_riptide_probe()
2067 val, MPU401_INFO_IRQ_HOOK, -1, in __snd_card_riptide_probe()
2068 &chip->rmidi); in __snd_card_riptide_probe()
2070 dev_warn(&pci->dev, in __snd_card_riptide_probe()
2074 chip->mpuaddr = val; in __snd_card_riptide_probe()
2078 pci_write_config_word(chip->pci, PCI_EXT_FM_Base, val); in __snd_card_riptide_probe()
2080 OPL3_HW_RIPTIDE, 0, &chip->opl3); in __snd_card_riptide_probe()
2082 dev_warn(&pci->dev, in __snd_card_riptide_probe()
2086 chip->opladdr = val; in __snd_card_riptide_probe()
2087 err = snd_opl3_hwdep_new(chip->opl3, 0, 1, NULL); in __snd_card_riptide_probe()
2089 dev_warn(&pci->dev, in __snd_card_riptide_probe()
2090 "Riptide: Can't Allocate OPL3-HWDEP\n"); in __snd_card_riptide_probe()
2096 pci_write_config_word(chip->pci, PCI_EXT_Game_Base, val); in __snd_card_riptide_probe()
2097 chip->gameaddr = val; in __snd_card_riptide_probe()
2101 strscpy(card->driver, "RIPTIDE"); in __snd_card_riptide_probe()
2102 strscpy(card->shortname, "Riptide"); in __snd_card_riptide_probe()
2104 scnprintf(card->longname, sizeof(card->longname), in __snd_card_riptide_probe()
2106 card->shortname, chip->port, chip->irq, chip->mpuaddr, in __snd_card_riptide_probe()
2107 chip->opladdr, chip->gameaddr); in __snd_card_riptide_probe()
2109 scnprintf(card->longname, sizeof(card->longname), in __snd_card_riptide_probe()
2111 card->shortname, chip->port, chip->irq, chip->mpuaddr, in __snd_card_riptide_probe()
2112 chip->opladdr); in __snd_card_riptide_probe()
2126 return snd_card_free_on_error(&pci->dev, __snd_card_riptide_probe(pci, pci_id)); in snd_card_riptide_probe()
2140 .name = KBUILD_MODNAME "-joystick",