94 #include <linux/pci.h>
95 #include <linux/slab.h>
96 #include <linux/wait.h>
97 #include <linux/gameport.h>
98 #include <linux/device.h>
100 #include <linux/kernel.h>
101 #include <linux/module.h>
113 #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
114 #define SUPPORT_JOYSTICK 1
127 #ifdef SUPPORT_JOYSTICK
139 #ifdef SUPPORT_JOYSTICK
151 #define MPU401_HW_RIPTIDE MPU401_HW_MPU401
152 #define OPL3_HW_RIPTIDE OPL3_HW_OPL3
154 #define PCI_EXT_CapId 0x40
155 #define PCI_EXT_NextCapPrt 0x41
156 #define PCI_EXT_PWMC 0x42
157 #define PCI_EXT_PWSCR 0x44
158 #define PCI_EXT_Data00 0x46
159 #define PCI_EXT_PMSCR_BSE 0x47
160 #define PCI_EXT_SB_Base 0x48
161 #define PCI_EXT_FM_Base 0x4a
162 #define PCI_EXT_MPU_Base 0x4C
163 #define PCI_EXT_Game_Base 0x4E
164 #define PCI_EXT_Legacy_Mask 0x50
165 #define PCI_EXT_AsicRev 0x52
166 #define PCI_EXT_Reserved3 0x53
168 #define LEGACY_ENABLE_ALL 0x8000
169 #define LEGACY_ENABLE_SB 0x4000
170 #define LEGACY_ENABLE_FM 0x2000
171 #define LEGACY_ENABLE_MPU_INT 0x1000
172 #define LEGACY_ENABLE_MPU 0x0800
173 #define LEGACY_ENABLE_GAMEPORT 0x0400
175 #define MAX_WRITE_RETRY 10
176 #define MAX_ERROR_COUNT 10
177 #define CMDIF_TIMEOUT 50000
178 #define RESET_TRIES 5
180 #define READ_PORT_ULONG(p) inl((unsigned long)&(p))
181 #define WRITE_PORT_ULONG(p,x) outl(x,(unsigned long)&(p))
183 #define READ_AUDIO_CONTROL(p) READ_PORT_ULONG(p->audio_control)
184 #define WRITE_AUDIO_CONTROL(p,x) WRITE_PORT_ULONG(p->audio_control,x)
185 #define UMASK_AUDIO_CONTROL(p,x) WRITE_PORT_ULONG(p->audio_control,READ_PORT_ULONG(p->audio_control)|x)
186 #define MASK_AUDIO_CONTROL(p,x) WRITE_PORT_ULONG(p->audio_control,READ_PORT_ULONG(p->audio_control)&x)
187 #define READ_AUDIO_STATUS(p) READ_PORT_ULONG(p->audio_status)
189 #define SET_GRESET(p) UMASK_AUDIO_CONTROL(p,0x0001)
190 #define UNSET_GRESET(p) MASK_AUDIO_CONTROL(p,~0x0001)
191 #define SET_AIE(p) UMASK_AUDIO_CONTROL(p,0x0004)
192 #define UNSET_AIE(p) MASK_AUDIO_CONTROL(p,~0x0004)
193 #define SET_AIACK(p) UMASK_AUDIO_CONTROL(p,0x0008)
194 #define UNSET_AIACKT(p) MASKAUDIO_CONTROL(p,~0x0008)
195 #define SET_ECMDAE(p) UMASK_AUDIO_CONTROL(p,0x0010)
196 #define UNSET_ECMDAE(p) MASK_AUDIO_CONTROL(p,~0x0010)
197 #define SET_ECMDBE(p) UMASK_AUDIO_CONTROL(p,0x0020)
198 #define UNSET_ECMDBE(p) MASK_AUDIO_CONTROL(p,~0x0020)
199 #define SET_EDATAF(p) UMASK_AUDIO_CONTROL(p,0x0040)
200 #define UNSET_EDATAF(p) MASK_AUDIO_CONTROL(p,~0x0040)
201 #define SET_EDATBF(p) UMASK_AUDIO_CONTROL(p,0x0080)
202 #define UNSET_EDATBF(p) MASK_AUDIO_CONTROL(p,~0x0080)
203 #define SET_ESBIRQON(p) UMASK_AUDIO_CONTROL(p,0x0100)
204 #define UNSET_ESBIRQON(p) MASK_AUDIO_CONTROL(p,~0x0100)
205 #define SET_EMPUIRQ(p) UMASK_AUDIO_CONTROL(p,0x0200)
206 #define UNSET_EMPUIRQ(p) MASK_AUDIO_CONTROL(p,~0x0200)
207 #define IS_CMDE(a) (READ_PORT_ULONG(a->stat)&0x1)
208 #define IS_DATF(a) (READ_PORT_ULONG(a->stat)&0x2)
209 #define IS_READY(p) (READ_AUDIO_STATUS(p)&0x0001)
210 #define IS_DLREADY(p) (READ_AUDIO_STATUS(p)&0x0002)
211 #define IS_DLERR(p) (READ_AUDIO_STATUS(p)&0x0004)
212 #define IS_GERR(p) (READ_AUDIO_STATUS(p)&0x0008)
213 #define IS_CMDAEIRQ(p) (READ_AUDIO_STATUS(p)&0x0010)
214 #define IS_CMDBEIRQ(p) (READ_AUDIO_STATUS(p)&0x0020)
215 #define IS_DATAFIRQ(p) (READ_AUDIO_STATUS(p)&0x0040)
216 #define IS_DATBFIRQ(p) (READ_AUDIO_STATUS(p)&0x0080)
217 #define IS_EOBIRQ(p) (READ_AUDIO_STATUS(p)&0x0100)
218 #define IS_EOSIRQ(p) (READ_AUDIO_STATUS(p)&0x0200)
219 #define IS_EOCIRQ(p) (READ_AUDIO_STATUS(p)&0x0400)
220 #define IS_UNSLIRQ(p) (READ_AUDIO_STATUS(p)&0x0800)
221 #define IS_SBIRQ(p) (READ_AUDIO_STATUS(p)&0x1000)
222 #define IS_MPUIRQ(p) (READ_AUDIO_STATUS(p)&0x2000)
224 #define RESP 0x00000001
225 #define PARM 0x00000002
226 #define CMDA 0x00000004
227 #define CMDB 0x00000008
228 #define NILL 0x00000000
230 #define LONG0(a) ((u32)a)
231 #define BYTE0(a) (LONG0(a)&0xff)
232 #define BYTE1(a) (BYTE0(a)<<8)
233 #define BYTE2(a) (BYTE0(a)<<16)
234 #define BYTE3(a) (BYTE0(a)<<24)
235 #define WORD0(a) (LONG0(a)&0xffff)
236 #define WORD1(a) (WORD0(a)<<8)
237 #define WORD2(a) (WORD0(a)<<16)
238 #define TRINIB0(a) (LONG0(a)&0xffffff)
239 #define TRINIB1(a) (TRINIB0(a)<<8)
241 #define RET(a) ((union cmdret *)(a))
243 #define SEND_GETV(p,b) sendcmd(p,RESP,GETV,0,RET(b))
244 #define SEND_GETC(p,b,c) sendcmd(p,PARM|RESP,GETC,c,RET(b))
245 #define SEND_GUNS(p,b) sendcmd(p,RESP,GUNS,0,RET(b))
246 #define SEND_SCID(p,b) sendcmd(p,RESP,SCID,0,RET(b))
247 #define SEND_RMEM(p,b,c,d) sendcmd(p,PARM|RESP,RMEM|BYTE1(b),LONG0(c),RET(d))
248 #define SEND_SMEM(p,b,c) sendcmd(p,PARM,SMEM|BYTE1(b),LONG0(c),RET(0))
249 #define SEND_WMEM(p,b,c) sendcmd(p,PARM,WMEM|BYTE1(b),LONG0(c),RET(0))
250 #define SEND_SDTM(p,b,c) sendcmd(p,PARM|RESP,SDTM|TRINIB1(b),0,RET(c))
251 #define SEND_GOTO(p,b) sendcmd(p,PARM,GOTO,LONG0(b),RET(0))
252 #define SEND_SETDPLL(p) sendcmd(p,0,ARM_SETDPLL,0,RET(0))
253 #define SEND_SSTR(p,b,c) sendcmd(p,PARM,SSTR|BYTE3(b),LONG0(c),RET(0))
254 #define SEND_PSTR(p,b) sendcmd(p,PARM,PSTR,BYTE3(b),RET(0))
255 #define SEND_KSTR(p,b) sendcmd(p,PARM,KSTR,BYTE3(b),RET(0))
256 #define SEND_KDMA(p) sendcmd(p,0,KDMA,0,RET(0))
257 #define SEND_GPOS(p,b,c,d) sendcmd(p,PARM|RESP,GPOS,BYTE3(c)|BYTE2(b),RET(d))
258 #define SEND_SETF(p,b,c,d,e,f,g) sendcmd(p,PARM,SETF|WORD1(b)|BYTE3(c),d|BYTE1(e)|BYTE2(f)|BYTE3(g),RET(0))
259 #define SEND_GSTS(p,b,c,d) sendcmd(p,PARM|RESP,GSTS,BYTE3(c)|BYTE2(b),RET(d))
260 #define SEND_NGPOS(p,b,c,d) sendcmd(p,PARM|RESP,NGPOS,BYTE3(c)|BYTE2(b),RET(d))
261 #define SEND_PSEL(p,b,c) sendcmd(p,PARM,PSEL,BYTE2(b)|BYTE3(c),RET(0))
262 #define SEND_PCLR(p,b,c) sendcmd(p,PARM,PCLR,BYTE2(b)|BYTE3(c),RET(0))
263 #define SEND_PLST(p,b) sendcmd(p,PARM,PLST,BYTE3(b),RET(0))
264 #define SEND_RSSV(p,b,c,d) sendcmd(p,PARM|RESP,RSSV,BYTE2(b)|BYTE3(c),RET(d))
265 #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)|BYTE2(g)|BYTE3(h),RET(0))
266 #define SEND_SSRC(p,b,c,d,e) sendcmd(p,PARM,SSRC|BYTE1(b)|WORD2(c),WORD0(d)|WORD2(e),RET(0))
267 #define SEND_SLST(p,b) sendcmd(p,PARM,SLST,BYTE3(b),RET(0))
268 #define SEND_RSRC(p,b,c) sendcmd(p,RESP,RSRC|BYTE1(b),0,RET(c))
269 #define SEND_SSRB(p,b,c) sendcmd(p,PARM,SSRB|BYTE1(b),WORD2(c),RET(0))
270 #define SEND_SDGV(p,b,c,d,e) sendcmd(p,PARM,SDGV|BYTE2(b)|BYTE3(c),WORD0(d)|WORD2(e),RET(0))
271 #define SEND_RDGV(p,b,c,d) sendcmd(p,PARM|RESP,RDGV|BYTE2(b)|BYTE3(c),0,RET(d))
272 #define SEND_DLST(p,b) sendcmd(p,PARM,DLST,BYTE3(b),RET(0))
273 #define SEND_SACR(p,b,c) sendcmd(p,PARM,SACR,WORD0(b)|WORD2(c),RET(0))
274 #define SEND_RACR(p,b,c) sendcmd(p,PARM|RESP,RACR,WORD2(b),RET(c))
275 #define SEND_ALST(p,b) sendcmd(p,PARM,ALST,BYTE3(b),RET(0))
276 #define SEND_TXAC(p,b,c,d,e,f) sendcmd(p,PARM,TXAC|BYTE1(b)|WORD2(c),WORD0(d)|BYTE2(e)|BYTE3(f),RET(0))
277 #define SEND_RXAC(p,b,c,d) sendcmd(p,PARM|RESP,RXAC,BYTE2(b)|BYTE3(c),RET(d))
278 #define SEND_SI2S(p,b) sendcmd(p,PARM,SI2S,WORD2(b),RET(0))
280 #define EOB_STATUS 0x80000000
281 #define EOS_STATUS 0x40000000
282 #define EOC_STATUS 0x20000000
283 #define ERR_STATUS 0x10000000
284 #define EMPTY_STATUS 0x08000000
286 #define IEOB_ENABLE 0x1
287 #define IEOS_ENABLE 0x2
288 #define IEOC_ENABLE 0x4
290 #define DESC_MAX_MASK 0xff
298 #define I2S_SPLITTER 0
300 #define I2S_RATE 44100
302 #define MODEM_INTDEC 4
303 #define MODEM_MERGER 3
304 #define MODEM_SPLITTER 0
305 #define MODEM_MIXER 11
309 #define FM_SPLITTER 0
312 #define SPLIT_PATH 0x80
426 #define get_pcmhwdev(substream) (struct pcmhw *)(substream->runtime->private_data)
428 #define PLAYBACK_SUBSTREAMS 3
452 #ifdef SUPPORT_JOYSTICK
453 unsigned short gameaddr;
467 #ifdef CONFIG_PM_SLEEP
498 #define CMDRET_ZERO (union cmdret){{(u32)0, (u32) 0}}
502 static int getsourcesink(
struct cmdif *cif,
unsigned char source,
503 unsigned char sink,
unsigned char *
a,
519 #ifdef SUPPORT_JOYSTICK
534 static unsigned char lbusin2out[
E2SINK_MAX + 1][2] = {
574 static unsigned char lbus_play_opl3[] = {
577 static unsigned char lbus_play_modem[] = {
580 static unsigned char lbus_play_i2s[] = {
583 static unsigned char lbus_play_out[] = {
586 static unsigned char lbus_play_outhp[] = {
589 static unsigned char lbus_play_noconv1[] = {
592 static unsigned char lbus_play_stereo1[] = {
595 static unsigned char lbus_play_mono1[] = {
598 static unsigned char lbus_play_noconv2[] = {
601 static unsigned char lbus_play_stereo2[] = {
604 static unsigned char lbus_play_mono2[] = {
607 static unsigned char lbus_play_noconv3[] = {
610 static unsigned char lbus_play_stereo3[] = {
613 static unsigned char lbus_play_mono3[] = {
616 static unsigned char lbus_rec_noconv1[] = {
619 static unsigned char lbus_rec_stereo1[] = {
622 static unsigned char lbus_rec_mono1[] = {
626 static unsigned char play_ids[] = { 4, 1, 2, };
627 static unsigned char play_sources[] = {
630 static struct lbuspath lbus_play_paths[] = {
632 .noconv = lbus_play_noconv1,
633 .stereo = lbus_play_stereo1,
634 .mono = lbus_play_mono1,
637 .noconv = lbus_play_noconv2,
638 .stereo = lbus_play_stereo2,
639 .mono = lbus_play_mono2,
642 .noconv = lbus_play_noconv3,
643 .stereo = lbus_play_stereo3,
644 .mono = lbus_play_mono3,
647 static struct lbuspath lbus_rec_path = {
648 .noconv = lbus_rec_noconv1,
649 .stereo = lbus_rec_stereo1,
650 .mono = lbus_rec_mono1,
653 #define FIRMWARE_VERSIONS 1
665 static u32 atoh(
const unsigned char *
in,
unsigned int len)
668 unsigned int mult = 1;
684 static int senddata(
struct cmdif *cif,
const unsigned char *in,
u32 offset)
689 const unsigned char *
p;
692 addr = offset + atoh(&in[3], 4);
699 ((data & 0x0f0f0f0f) << 4) | ((data & 0xf0f0f0f0)
708 static int loadfirmware(
struct cmdif *cif,
const unsigned char *img,
711 const unsigned char *
in;
716 while (size > 0 && err == 0) {
722 err = senddata(cif, in, laddr + saddr);
725 saddr = atoh(&in[9], 4) << 4;
728 laddr = atoh(&in[9], 4) << 16;
731 val = atoh(&in[9], 8);
753 alloclbuspath(
struct cmdif *cif,
unsigned char source,
754 unsigned char *
path,
unsigned char *mixer,
unsigned char *
s)
756 while (*path != 0xff) {
761 snd_printdd(
"alloc path 0x%x->0x%x\n", source, sink);
763 source = lbusin2out[
sink][0];
764 type = lbusin2out[
sink][1];
782 unsigned char *npath =
path;
784 while (*npath != 0xff)
786 alloclbuspath(cif, source + 1, ++npath, mixer, s);
792 freelbuspath(
struct cmdif *cif,
unsigned char source,
unsigned char *path)
794 while (*path != 0xff) {
799 snd_printdd(
"free path 0x%x->0x%x\n", source, sink);
801 source = lbusin2out[
sink][0];
804 unsigned char *npath =
path;
806 while (*npath != 0xff)
808 freelbuspath(cif, source + 1, ++npath);
826 if ((rptr.
retlongs[0] & data) == data) {
832 snd_printdd(
"send arm 0x%x 0x%x 0x%x return %d\n", addr, data, mask,
842 unsigned int time = 0;
843 unsigned long irqflags;
854 "Riptide: Too many failed cmds, reinitializing\n");
855 if (riptide_reset(cif,
NULL) == 0) {
877 for (j = 0, time = 0; time <
CMDIF_TIMEOUT; j++, time += 2) {
878 cmdport = &(hwport->
port[j % 2]);
887 if ((flags &
RESP) && ret) {
889 time < CMDIF_TIMEOUT) {
893 if (time < CMDIF_TIMEOUT) {
907 if (time == CMDIF_TIMEOUT) {
911 spin_unlock_irqrestore(&cif->
lock, irqflags);
917 if (time < cif->cmdtimemin)
919 if ((cif->
cmdcnt) % 1000 == 0)
921 (
"send cmd %d time: %d mintime: %d maxtime %d err: %d\n",
928 spin_unlock_irqrestore(&cif->
lock, irqflags);
930 (
"send cmd %d hw: 0x%x flag: 0x%x cmd: 0x%x parm: 0x%x ret: 0x%x 0x%x CMDE: %d DATF: %d failed %d\n",
931 cif->
cmdcnt, (
int)((
void *)&(cmdport->
stat) - (
void *)hwport),
932 flags, cmd, parm, ret ? ret->
retlongs[0] : 0,
939 setmixer(
struct cmdif *cif,
short num,
unsigned short rval,
unsigned short lval)
944 snd_printdd(
"sent mixer %d: 0x%d 0x%d\n", num, rval, lval);
955 static int getpaths(
struct cmdif *cif,
unsigned char *o)
962 getsourcesink(cif, i, i, &src[i], &sink[i]);
963 if (sink[i] < E2SINK_MAX) {
972 getsourcesink(
struct cmdif *cif,
unsigned char source,
unsigned char sink,
973 unsigned char *
a,
unsigned char *
b)
977 if (
SEND_RSSV(cif, source, sink, &rptr) &&
987 getsamplerate(
struct cmdif *cif,
unsigned char *intdec,
unsigned int *
rate)
990 unsigned int p[2] = { 0, 0 };
995 for (i = 0; i < 2; i++) {
1010 *rate = (
unsigned int)p[0];
1012 *rate = (
unsigned int)p[1];
1013 snd_printdd(
"getsampleformat %d %d %d\n", intdec[0], intdec[1], *rate);
1018 setsampleformat(
struct cmdif *cif,
1019 unsigned char mixer,
unsigned char id,
1025 (
"setsampleformat mixer: %d id: %d channels: %d format: %d\n",
1026 mixer,
id, channels, format);
1032 if (
SEND_SETF(cif, mixer, w, ch, order, sig,
id) &&
1033 SEND_SETF(cif, mixer, w, ch, order, sig,
id)) {
1041 setsamplerate(
struct cmdif *cif,
unsigned char *intdec,
unsigned int rate)
1047 snd_printdd(
"setsamplerate intdec: %d,%d rate: %d\n", intdec[0],
1050 M = ((rate == 48000) ? 47999 : rate) * 65536;
1053 for (i = 0; i < 2; i++) {
1054 if (*intdec != 0xff) {
1074 getmixer(
struct cmdif *cif,
short num,
unsigned short *rval,
1075 unsigned short *lval)
1083 snd_printdd(
"got mixer %d: 0x%d 0x%d\n", num, *rval, *lval);
1087 static void riptide_handleirq(
unsigned long dev_id)
1094 unsigned int pos, period_bytes;
1105 for (i = 0; i < PLAYBACK_SUBSTREAMS + 1; i++) {
1107 (runtime = substream[i]->runtime) &&
1110 for (j = 0; j < data->
pages; j++) {
1121 "Riptide: DMA stopped unexpectedly\n");
1125 ~(EOS_STATUS | EOB_STATUS |
1132 frames_to_bytes(runtime,
1135 (
"interrupt 0x%x after 0x%lx of 0x%lx frames in period\n",
1137 bytes_to_frames(runtime, pos),
1140 if (pos >= period_bytes) {
1142 while (pos >= period_bytes)
1143 pos -= period_bytes;
1153 #ifdef CONFIG_PM_SLEEP
1154 static int riptide_suspend(
struct device *
dev)
1160 chip->in_suspend = 1;
1162 snd_pcm_suspend_all(chip->
pcm);
1163 snd_ac97_suspend(chip->
ac97);
1170 static int riptide_resume(
struct device *
dev)
1180 "disabling device\n");
1185 snd_riptide_initialize(chip);
1186 snd_ac97_resume(chip->
ac97);
1188 chip->in_suspend = 0;
1193 #define RIPTIDE_PM_OPS &riptide_pm
1195 #define RIPTIDE_PM_OPS NULL
1198 static int try_to_load_firmware(
struct cmdif *cif,
struct snd_riptide *chip)
1203 for (i = 0; i < 2; i++) {
1212 for (timeout = 100000; --timeout;
udelay(10)) {
1218 "Riptide: device not ready, audio status: 0x%x "
1219 "ready: %d gerr: %d\n",
1225 (
"Riptide: audio status: 0x%x ready: %d gerr: %d\n",
1231 snd_printdd(
"Firmware version: ASIC: %d CODEC %d AUXDSP %d PROG %d\n",
1239 if (!
memcmp(&firmware_versions[i], &firmware,
sizeof(firmware)))
1250 "Riptide: Firmware not available %d\n", err);
1257 "Riptide: Could not load firmware %d\n", err);
1283 err = try_to_load_firmware(cif, chip);
1286 }
while (!err && --tries);
1298 writearm(cif, 0x301F8, 1, 1);
1299 writearm(cif, 0x301F4, 1, 1);
1308 setmixer(cif,
FM_MIXER, 0x7fff, 0x7fff);
1309 writearm(cif, 0x30648 +
FM_MIXER * 4, 0x01, 0x00000005);
1310 writearm(cif, 0x301A8, 0x02, 0x00000002);
1311 writearm(cif, 0x30264, 0x08, 0xffffffff);
1316 ((
u32) I2S_RATE * 65536) % 48000);
1384 (
"pointer stream %d position 0x%x(0x%x in buffer) bytes 0x%lx(0x%lx in period) frames\n",
1386 bytes_to_frames(runtime, rptr.
retlongs[1]),
1387 bytes_to_frames(runtime,
1391 bytes_to_frames(runtime,
1395 bytes_to_frames(runtime,
1398 snd_printdd(
"stream not started or strange parms (%d %ld)\n",
1400 ret = bytes_to_frames(runtime, 0);
1413 spin_lock(&chip->
lock);
1421 if (data->
mixer != 0xff)
1422 setmixer(cif, data->
mixer, 0x7fff, 0x7fff);
1430 if (data->
mixer != 0xff)
1431 setmixer(cif, data->
mixer, 0, 0);
1432 setmixer(cif, data->
mixer, 0, 0);
1460 spin_unlock(&chip->
lock);
1463 spin_unlock(&chip->
lock);
1484 spin_lock_irq(&chip->
lock);
1486 format = runtime->
format;
1487 rate = runtime->
rate;
1491 lbuspath = data->
paths.noconv;
1493 lbuspath = data->
paths.mono;
1497 lbuspath = data->
paths.noconv;
1499 lbuspath = data->
paths.stereo;
1508 size = frames_to_bytes(runtime, runtime->
buffer_size);
1509 period = frames_to_bytes(runtime, runtime->
period_size);
1511 while ((size + (f >> 1) - 1) <= (f << 7) && (f << 1) > period)
1513 pages = (size + f - 1) / f;
1517 (
"create sgd size: 0x%x pages %d of size 0x%x for period 0x%x\n",
1518 size, pages, f, period);
1521 for (i = 0; i <
pages; i++) {
1522 unsigned int ofs,
addr;
1531 addr = snd_pcm_sgbuf_get_addr(substream, ofs) + pt;
1545 if (lbuspath && lbuspath != data->
lbuspath) {
1548 alloclbuspath(cif, data->
source, lbuspath,
1553 if (data->
rate != rate || data->
format != format ||
1559 (cif, data->
mixer, data->
id, channels, format)
1560 || setsamplerate(cif, data->
intdec, rate))
1563 spin_unlock_irq(&chip->
lock);
1576 snd_printdd(
"hw params id %d (sgdlist: 0x%p 0x%lx %d)\n", data->
id,
1577 sgdlist->
area, (
unsigned long)sgdlist->
addr,
1578 (
int)sgdlist->
bytes);
1621 int sub_num = substream->
number;
1624 runtime->
hw = snd_riptide_playback;
1629 data->
paths = lbus_play_paths[sub_num];
1630 data->
id = play_ids[sub_num];
1631 data->
source = play_sources[sub_num];
1647 runtime->
hw = snd_riptide_capture;
1652 data->
paths = lbus_rec_path;
1667 int sub_num = substream->
number;
1686 static struct snd_pcm_ops snd_riptide_playback_ops = {
1687 .open = snd_riptide_playback_open,
1688 .close = snd_riptide_playback_close,
1690 .hw_params = snd_riptide_hw_params,
1691 .hw_free = snd_riptide_hw_free,
1692 .prepare = snd_riptide_prepare,
1694 .trigger = snd_riptide_trigger,
1695 .pointer = snd_riptide_pointer,
1697 static struct snd_pcm_ops snd_riptide_capture_ops = {
1698 .open = snd_riptide_capture_open,
1699 .close = snd_riptide_capture_close,
1701 .hw_params = snd_riptide_hw_params,
1702 .hw_free = snd_riptide_hw_free,
1703 .prepare = snd_riptide_prepare,
1705 .trigger = snd_riptide_trigger,
1706 .pointer = snd_riptide_pointer,
1722 &snd_riptide_playback_ops);
1724 &snd_riptide_capture_ops);
1731 64 * 1024, 128 * 1024);
1738 snd_riptide_interrupt(
int irq,
void *dev_id)
1753 chip->
rmidi->private_data);
1761 snd_riptide_codec_write(
struct snd_ac97 *ac97,
unsigned short reg,
1772 snd_printdd(
"Write AC97 reg 0x%x 0x%x\n", reg, val);
1781 static unsigned short snd_riptide_codec_read(
struct snd_ac97 *ac97,
1797 static int snd_riptide_initialize(
struct snd_riptide *chip)
1815 if ((err = riptide_reset(cif, chip)) != 0)
1818 switch (device_id) {
1832 static int snd_riptide_free(
struct snd_riptide *chip)
1839 if ((cif = chip->
cif)) {
1853 static int snd_riptide_dev_free(
struct snd_device *device)
1857 return snd_riptide_free(chip);
1868 .dev_free = snd_riptide_dev_free,
1891 "Riptide: unable to grab region 0x%lx-0x%lx\n",
1893 snd_riptide_free(chip);
1900 KBUILD_MODNAME, chip)) {
1903 snd_riptide_free(chip);
1909 if ((err = snd_riptide_initialize(chip)) < 0) {
1910 snd_riptide_free(chip);
1915 snd_riptide_free(chip);
1933 unsigned char p[256];
1934 unsigned short rval = 0, lval = 0;
1940 snd_iprintf(buffer,
"%s\n\n", chip->
card->longname);
1941 snd_iprintf(buffer,
"Device ID: 0x%x\nReceived IRQs: (%ld)%ld\nPorts:",
1943 for (i = 0; i < 64; i += 4)
1944 snd_iprintf(buffer,
"%c%02x: %08x",
1945 (i % 16) ?
' ' :
'\n', i,
inl(chip->
port + i));
1946 if ((cif = chip->
cif)) {
1948 "\nVersion: ASIC: %d CODEC: %d AUXDSP: %d PROG: %d",
1953 snd_iprintf(buffer,
"\nDigital mixer:");
1954 for (i = 0; i < 12; i++) {
1955 getmixer(cif, i, &rval, &lval);
1956 snd_iprintf(buffer,
"\n %d: %d %d", i, rval, lval);
1959 "\nARM Commands num: %d failed: %d time: %d max: %d min: %d",
1963 snd_iprintf(buffer,
"\nOpen streams %d:\n", chip->
openstreams);
1970 "stream: %d mixer: %d source: %d (%d,%d)\n",
1973 if (!(getsamplerate(cif, data->
intdec, &rate)))
1974 snd_iprintf(buffer,
"rate: %d\n", rate);
1981 "stream: %d mixer: %d source: %d (%d,%d)\n",
1984 if (!(getsamplerate(cif, data->
intdec, &rate)))
1985 snd_iprintf(buffer,
"rate: %d\n", rate);
1987 snd_iprintf(buffer,
"Paths:\n");
1988 i = getpaths(cif, p);
1991 snd_iprintf(buffer,
"%x->%x ", p[i], p[i + 1]);
1993 snd_iprintf(buffer,
"\n");
2000 if (!snd_card_proc_new(chip->
card,
"riptide", &entry))
2001 snd_info_set_text_ops(entry, chip, snd_riptide_proc_read);
2010 .write = snd_riptide_codec_write,
2011 .read = snd_riptide_codec_read,
2014 memset(&ac97, 0,
sizeof(ac97));
2028 #ifdef SUPPORT_JOYSTICK
2043 if (!joystick_port[dev++])
2046 gameport = gameport_allocate_port();
2049 if (!
request_region(joystick_port[dev], 8,
"Riptide gameport")) {
2051 "Riptide: cannot grab gameport 0x%x\n",
2052 joystick_port[dev]);
2053 gameport_free_port(gameport);
2057 gameport->
io = joystick_port[
dev];
2058 gameport_register_port(gameport);
2059 pci_set_drvdata(pci, gameport);
2065 struct gameport *gameport = pci_get_drvdata(pci);
2069 pci_set_drvdata(pci,
NULL);
2093 err = snd_riptide_create(card, pci, &chip);
2097 err = snd_riptide_pcm(chip, 0,
NULL);
2100 err = snd_riptide_mixer(chip);
2107 #ifdef SUPPORT_JOYSTICK
2108 if (joystick_port[dev])
2113 val |= (chip->
irq << 4) & 0xf0;
2115 if (mpu_port[dev]) {
2116 val = mpu_port[
dev];
2123 "Riptide: Can't Allocate MPU at 0x%x\n",
2128 if (opl3_port[dev]) {
2129 val = opl3_port[
dev];
2135 "Riptide: Can't Allocate OPL3 at 0x%x\n",
2142 "Riptide: Can't Allocate OPL3-HWDEP\n");
2145 #ifdef SUPPORT_JOYSTICK
2146 if (joystick_port[dev]) {
2147 val = joystick_port[
dev];
2149 chip->gameaddr =
val;
2155 #ifdef SUPPORT_JOYSTICK
2157 "%s at 0x%lx, irq %i mpu 0x%x opl3 0x%x gameport 0x%x",
2159 chip->
opladdr, chip->gameaddr);
2162 "%s at 0x%lx, irq %i mpu 0x%x opl3 0x%x",
2166 snd_riptide_proc_init(chip);
2170 pci_set_drvdata(pci, card);
2182 pci_set_drvdata(pci,
NULL);
2186 .name = KBUILD_MODNAME,
2187 .id_table = snd_riptide_ids,
2188 .probe = snd_card_riptide_probe,
2195 #ifdef SUPPORT_JOYSTICK
2197 .
name = KBUILD_MODNAME
"-joystick",
2198 .id_table = snd_riptide_joystick_ids,
2199 .probe = snd_riptide_joystick_probe,
2200 .remove =
__devexit_p(snd_riptide_joystick_remove),
2204 static int __init alsa_card_riptide_init(
void)
2207 err = pci_register_driver(&driver);
2210 #if defined(SUPPORT_JOYSTICK)
2211 err = pci_register_driver(&joystick_driver);
2219 static void __exit alsa_card_riptide_exit(
void)
2222 #if defined(SUPPORT_JOYSTICK)