73 #include <linux/module.h>
75 MODULE_AUTHOR(
"Rudolf Koenig, Brent Baccala and Martin Habets");
101 static int dbri_debug;
106 static char *
cmds[] = {
107 "WAIT",
"PAUSE",
"JUMP",
"IIQ",
"REX",
"SDP",
"CDP",
"DTS",
108 "SSP",
"CHI",
"NT",
"TE",
"CDEC",
"TEST",
"CDM",
"RESRV"
111 #define dprintk(a, x...) if (dbri_debug & a) printk(KERN_DEBUG x)
114 #define dprintk(a, x...) do { } while (0)
118 #define DBRI_CMD(cmd, intr, value) ((cmd << 28) | \
142 #define CS4215_CLB (1<<2)
143 #define CS4215_OLB (1<<3)
145 #define CS4215_MLB (1<<4)
146 #define CS4215_RSRVD_1 (1<<5)
149 #define CS4215_DFR_LINEAR16 0
150 #define CS4215_DFR_ULAW 1
151 #define CS4215_DFR_ALAW 2
152 #define CS4215_DFR_LINEAR8 3
153 #define CS4215_DFR_STEREO (1<<2)
159 { 8000, (1 << 4), (0 << 3) },
160 { 16000, (1 << 4), (1 << 3) },
161 { 27429, (1 << 4), (2 << 3) },
162 { 32000, (1 << 4), (3 << 3) },
165 { 48000, (1 << 4), (6 << 3) },
166 { 9600, (1 << 4), (7 << 3) },
167 { 5512, (2 << 4), (0 << 3) },
168 { 11025, (2 << 4), (1 << 3) },
169 { 18900, (2 << 4), (2 << 3) },
170 { 22050, (2 << 4), (3 << 3) },
171 { 37800, (2 << 4), (4 << 3) },
172 { 44100, (2 << 4), (5 << 3) },
173 { 33075, (2 << 4), (6 << 3) },
174 { 6615, (2 << 4), (7 << 3) },
178 #define CS4215_HPF (1<<7)
180 #define CS4215_12_MASK 0xfcbf
183 #define CS4215_XEN (1<<0)
184 #define CS4215_XCLK (1<<1)
185 #define CS4215_BSEL_64 (0<<2)
186 #define CS4215_BSEL_128 (1<<2)
187 #define CS4215_BSEL_256 (2<<2)
188 #define CS4215_MCK_MAST (0<<4)
189 #define CS4215_MCK_XTL1 (1<<4)
190 #define CS4215_MCK_XTL2 (2<<4)
191 #define CS4215_MCK_CLK1 (3<<4)
192 #define CS4215_MCK_CLK2 (4<<4)
195 #define CS4215_DAD (1<<0)
196 #define CS4215_ENL (1<<1)
204 #define CS4215_VERSION_MASK 0xf
214 #define CS4215_LO(v) v
215 #define CS4215_LE (1<<6)
216 #define CS4215_HE (1<<7)
219 #define CS4215_RO(v) v
220 #define CS4215_SE (1<<6)
221 #define CS4215_ADI (1<<7)
224 #define CS4215_LG(v) v
225 #define CS4215_IS (1<<4)
226 #define CS4215_OVR (1<<5)
227 #define CS4215_PIO0 (1<<6)
228 #define CS4215_PIO1 (1<<7)
231 #define CS4215_RG(v) v
232 #define CS4215_MA(v) (v<<4)
246 #define DBRI_NO_CMDS 64
247 #define DBRI_INT_BLK 64
248 #define DBRI_NO_DESCS 64
249 #define DBRI_NO_PIPES 32
250 #define DBRI_MAX_PIPE (DBRI_NO_PIPES - 1)
254 #define DBRI_NO_STREAMS 2
274 #define dbri_dma_off(member, elem) \
275 ((u32)(unsigned long) \
276 (&(((struct dbri_dma *)0)->member[elem])))
324 #define DBRI_MAX_VOLUME 63
325 #define DBRI_MAX_GAIN 15
342 #define D_LITTLE_END (1<<8)
343 #define D_BIG_END (0<<8)
351 #define D_ENPIO3 (1<<7)
352 #define D_ENPIO2 (1<<6)
353 #define D_ENPIO1 (1<<5)
354 #define D_ENPIO0 (1<<4)
355 #define D_ENPIO (0xf0)
356 #define D_PIO3 (1<<3)
357 #define D_PIO2 (1<<2)
358 #define D_PIO1 (1<<1)
359 #define D_PIO0 (1<<0)
379 #define D_PIPE(v) ((v)<<0)
383 #define D_SDP_2SAME (1<<18)
384 #define D_SDP_CHANGE (2<<18)
385 #define D_SDP_EVERY (3<<18)
386 #define D_SDP_EOL (1<<17)
387 #define D_SDP_IDLE (1<<16)
390 #define D_SDP_MEM (0<<13)
391 #define D_SDP_HDLC (2<<13)
392 #define D_SDP_HDLC_D (3<<13)
393 #define D_SDP_SER (4<<13)
394 #define D_SDP_FIXED (6<<13)
395 #define D_SDP_MODE(v) ((v)&(7<<13))
397 #define D_SDP_TO_SER (1<<12)
398 #define D_SDP_FROM_SER (0<<12)
399 #define D_SDP_MSB (1<<11)
400 #define D_SDP_LSB (0<<11)
401 #define D_SDP_P (1<<10)
402 #define D_SDP_A (1<<8)
403 #define D_SDP_C (1<<7)
406 #define D_DTS_VI (1<<17)
407 #define D_DTS_VO (1<<16)
408 #define D_DTS_INS (1<<15)
409 #define D_DTS_DEL (0<<15)
410 #define D_DTS_PRVIN(v) ((v)<<10)
411 #define D_DTS_PRVOUT(v) ((v)<<5)
414 #define D_TS_LEN(v) ((v)<<24)
415 #define D_TS_CYCLE(v) ((v)<<14)
416 #define D_TS_DI (1<<13)
417 #define D_TS_1CHANNEL (0<<10)
418 #define D_TS_MONITOR (2<<10)
419 #define D_TS_NONCONTIG (3<<10)
420 #define D_TS_ANCHOR (7<<10)
421 #define D_TS_MON(v) ((v)<<5)
422 #define D_TS_NEXT(v) ((v)<<0)
425 #define D_CHI_CHICM(v) ((v)<<16)
426 #define D_CHI_IR (1<<15)
427 #define D_CHI_EN (1<<14)
428 #define D_CHI_OD (1<<13)
429 #define D_CHI_FE (1<<12)
430 #define D_CHI_FD (1<<11)
431 #define D_CHI_BPF(v) ((v)<<0)
434 #define D_NT_FBIT (1<<17)
435 #define D_NT_NBF (1<<16)
436 #define D_NT_IRM_IMM (1<<15)
437 #define D_NT_IRM_EN (1<<14)
438 #define D_NT_ISNT (1<<13)
439 #define D_NT_FT (1<<12)
440 #define D_NT_EZ (1<<11)
441 #define D_NT_IFA (1<<10)
442 #define D_NT_ACT (1<<9)
443 #define D_NT_MFE (1<<8)
444 #define D_NT_RLB(v) ((v)<<5)
445 #define D_NT_LLB(v) ((v)<<2)
446 #define D_NT_FACT (1<<1)
447 #define D_NT_ABV (1<<0)
450 #define D_CDEC_CK(v) ((v)<<24)
451 #define D_CDEC_FED(v) ((v)<<12)
452 #define D_CDEC_RED(v) ((v)<<0)
455 #define D_TEST_RAM(v) ((v)<<16)
456 #define D_TEST_SIZE(v) ((v)<<11)
457 #define D_TEST_ROMONOFF 0x5
458 #define D_TEST_PROC 0x6
459 #define D_TEST_SER 0x7
460 #define D_TEST_RAMREAD 0x8
461 #define D_TEST_RAMWRITE 0x9
462 #define D_TEST_RAMBIST 0xa
463 #define D_TEST_MCBIST 0xb
464 #define D_TEST_DUMP 0xe
467 #define D_CDM_THI (1 << 8)
468 #define D_CDM_RHI (1 << 7)
469 #define D_CDM_RCE (1 << 6)
470 #define D_CDM_XCE (1 << 2)
471 #define D_CDM_XEN (1 << 1)
472 #define D_CDM_REN (1 << 0)
475 #define D_INTR_BRDY 1
476 #define D_INTR_MINT 2
477 #define D_INTR_IBEG 3
478 #define D_INTR_IEND 4
480 #define D_INTR_CMDI 6
481 #define D_INTR_XCMP 8
482 #define D_INTR_SBRI 9
483 #define D_INTR_FXDT 10
484 #define D_INTR_CHIL 11
485 #define D_INTR_COLL 11
486 #define D_INTR_DBYT 12
487 #define D_INTR_RBYT 13
488 #define D_INTR_LINT 14
489 #define D_INTR_UNDR 15
493 #define D_INTR_CHI 36
494 #define D_INTR_CMD 38
496 #define D_INTR_GETCHAN(v) (((v) >> 24) & 0x3f)
497 #define D_INTR_GETCODE(v) (((v) >> 20) & 0xf)
498 #define D_INTR_GETCMD(v) (((v) >> 16) & 0xf)
499 #define D_INTR_GETVAL(v) ((v) & 0xffff)
500 #define D_INTR_GETRVAL(v) ((v) & 0xfffff)
536 #define DBRI_TD_F (1 << 31)
537 #define DBRI_TD_D (1 << 30)
538 #define DBRI_TD_CNT(v) ((v) << 16)
539 #define DBRI_TD_B (1 << 15)
540 #define DBRI_TD_M (1 << 14)
541 #define DBRI_TD_I (1 << 13)
542 #define DBRI_TD_FCNT(v) (v)
543 #define DBRI_TD_UNR (1 << 3)
544 #define DBRI_TD_ABT (1 << 2)
545 #define DBRI_TD_TBC (1 << 0)
546 #define DBRI_TD_STATUS(v) ((v) & 0xff)
548 #define DBRI_TD_MAXCNT ((1 << 13) - 4)
551 #define DBRI_RD_F (1 << 31)
552 #define DBRI_RD_C (1 << 30)
553 #define DBRI_RD_B (1 << 15)
554 #define DBRI_RD_M (1 << 14)
555 #define DBRI_RD_BCNT(v) (v)
556 #define DBRI_RD_CRC (1 << 7)
557 #define DBRI_RD_BBC (1 << 6)
558 #define DBRI_RD_ABT (1 << 5)
559 #define DBRI_RD_OVRN (1 << 3)
560 #define DBRI_RD_STATUS(v) ((v) & 0xff)
561 #define DBRI_RD_CNT(v) (((v) >> 16) & 0x1fff)
565 #define DBRI_STREAMNO(substream) \
566 (substream->stream == \
567 SNDRV_PCM_STREAM_PLAYBACK ? DBRI_PLAY: DBRI_REC)
570 #define DBRI_STREAM(dbri, substream) \
571 &dbri->stream_info[DBRI_STREAMNO(substream)]
581 b = ((b & 0xffff0000) >> 16) | ((b & 0x0000ffff) << 16);
583 b = ((b & 0xff00ff00) >> 8) | ((b & 0x00ff00ff) << 8);
585 b = ((b & 0xf0f0f0f0) >> 4) | ((b & 0x0f0f0f0f) << 4);
587 b = ((b & 0xcccccccc) >> 2) | ((b & 0x33333333) << 2);
589 b = ((b & 0xaaaaaaaa) >> 1) | ((b & 0x55555555) << 1);
634 static void dbri_cmdwait(
struct snd_dbri *dbri)
642 spin_unlock_irqrestore(&dbri->
lock, flags);
646 spin_unlock_irqrestore(&dbri->
lock, flags);
658 static s32 *dbri_cmdlock(
struct snd_dbri *dbri,
int len)
666 return dbri->
dma->cmd;
681 static void dbri_cmdsend(
struct snd_dbri *dbri,
s32 *
cmd,
int len)
684 static int wait_id = 0;
692 addr = dbri->
dma_dvma + (cmd - len - dbri->
dma->cmd) *
sizeof(
s32);
700 for (ptr = dbri->
cmdptr; ptr < cmd+2; ptr++)
702 (
unsigned long)ptr, *ptr);
706 dprintk(
D_CMD,
"cmd: %lx:%08x\n", (
unsigned long)ptr, *ptr);
708 dprintk(
D_CMD,
"cmd: %lx:%08x\n", (
unsigned long)ptr, *ptr);
709 for (ptr = dbri->
dma->cmd; ptr < cmd+2; ptr++)
711 (
unsigned long)ptr, *ptr);
725 static void dbri_reset(
struct snd_dbri *dbri)
761 dbri->
pipes[n].desc = dbri->
pipes[n].first_desc = -1;
785 spin_unlock_irqrestore(&dbri->
lock, flags);
803 static inline int pipe_active(
struct snd_dbri *dbri,
int pipe)
805 return ((pipe >= 0) && (dbri->
pipes[pipe].desc != -1));
813 static void reset_pipe(
struct snd_dbri *dbri,
int pipe)
821 "illegal pipe number\n");
828 "on uninitialized pipe\n");
832 cmd = dbri_cmdlock(dbri, 3);
836 dbri_cmdsend(dbri, cmd, 3);
841 dbri->
dma->desc[desc].ba = 0;
842 dbri->
dma->desc[desc].nda = 0;
844 }
while (desc != -1 && desc != dbri->
pipes[pipe].first_desc);
853 static void setup_pipe(
struct snd_dbri *dbri,
int pipe,
int sdp)
857 "with illegal pipe number\n");
861 if ((sdp & 0xf800) != sdp) {
863 "with strange SDP value\n");
878 reset_pipe(dbri, pipe);
884 static void link_time_slot(
struct snd_dbri *dbri,
int pipe,
885 int prevpipe,
int nextpipe,
892 || prevpipe < 0 || prevpipe > DBRI_MAX_PIPE
893 || nextpipe < 0 || nextpipe > DBRI_MAX_PIPE) {
895 "DBRI: link_time_slot called with illegal pipe number\n");
899 if (dbri->
pipes[pipe].sdp == 0
900 || dbri->
pipes[prevpipe].sdp == 0
901 || dbri->
pipes[nextpipe].sdp == 0) {
903 "on uninitialized pipe\n");
911 cmd = dbri_cmdlock(dbri, 4);
919 if (prevpipe == 16 && cycle == 0)
936 dbri_cmdsend(dbri, cmd, 4);
943 static void unlink_time_slot(
struct snd_dbri *dbri,
int pipe,
951 || prevpipe < 0 || prevpipe > DBRI_MAX_PIPE
952 || nextpipe < 0 || nextpipe > DBRI_MAX_PIPE) {
954 "DBRI: unlink_time_slot called with illegal pipe number\n");
958 cmd = dbri_cmdlock(dbri, 4);
973 dbri_cmdsend(dbri, cmd, 4);
993 static void xmit_fixed(
struct snd_dbri *dbri,
int pipe,
unsigned int data)
1005 "Uninitialized pipe %d\n", pipe);
1014 if (!(dbri->
pipes[pipe].sdp & D_SDP_TO_SER)) {
1023 data = reverse_bytes(data, dbri->
pipes[pipe].length);
1025 cmd = dbri_cmdlock(dbri, 3);
1032 dbri_cmdsend(dbri, cmd, 3);
1033 spin_unlock_irqrestore(&dbri->
lock, flags);
1038 static void recv_fixed(
struct snd_dbri *dbri,
int pipe,
volatile __u32 *ptr)
1042 "illegal pipe number\n");
1048 "non-fixed pipe %d\n", pipe);
1052 if (dbri->
pipes[pipe].sdp & D_SDP_TO_SER) {
1054 "transmit pipe %d\n", pipe);
1077 static int setup_descs(
struct snd_dbri *dbri,
int streamno,
unsigned int period)
1083 int first_desc = -1;
1086 if (info->
pipe < 0 || info->
pipe > 15) {
1101 if (!(dbri->
pipes[info->
pipe].sdp & D_SDP_TO_SER)) {
1103 "Called on receive pipe %d\n", info->
pipe);
1107 if (dbri->
pipes[info->
pipe].sdp & D_SDP_TO_SER) {
1109 "DBRI: setup_descs: Called on transmit pipe %d\n",
1116 if (pipe_active(dbri, info->
pipe)) {
1118 "Called on active pipe %d\n", info->
pipe);
1127 desc = dbri->
pipes[info->
pipe].first_desc;
1130 dbri->
dma->desc[desc].ba = 0;
1131 dbri->
dma->desc[desc].nda = 0;
1133 }
while (desc != -1 &&
1134 desc != dbri->
pipes[info->
pipe].first_desc);
1137 dbri->
pipes[info->
pipe].first_desc = -1;
1144 if (!dbri->
dma->desc[desc].ba)
1148 if (desc == DBRI_NO_DESCS) {
1163 dbri->
dma->desc[desc].nda = 0;
1167 dbri->
dma->desc[desc].word4 = 0;
1170 dbri->
dma->desc[desc].word1 = 0;
1171 dbri->
dma->desc[desc].word4 =
1175 if (first_desc == -1)
1179 dbri->
dma->desc[last_desc].nda =
1184 dvma_buffer += mylen;
1188 if (first_desc == -1 || last_desc == -1) {
1190 " Not enough descriptors available\n");
1194 dbri->
dma->desc[last_desc].nda =
1196 dbri->
next_desc[last_desc] = first_desc;
1197 dbri->
pipes[info->
pipe].first_desc = first_desc;
1198 dbri->
pipes[info->
pipe].desc = first_desc;
1201 for (desc = first_desc; desc != -1;) {
1204 dbri->
dma->desc[desc].word1,
1205 dbri->
dma->desc[desc].ba,
1206 dbri->
dma->desc[desc].nda, dbri->
dma->desc[desc].word4);
1208 if (desc == first_desc)
1231 static void reset_chi(
struct snd_dbri *dbri,
1240 cmd = dbri_cmdlock(dbri, 4);
1247 dbri_cmdsend(dbri, cmd, 4);
1249 dbri->
pipes[16].sdp = 1;
1250 dbri->
pipes[16].nextpipe = 16;
1252 cmd = dbri_cmdlock(dbri, 4);
1269 int clockrate = bits_per_frame * 8;
1270 int divisor = 12288 / clockrate;
1272 if (divisor > 255 || divisor * clockrate != 12288)
1280 dbri->
chi_bpf = bits_per_frame;
1294 dbri_cmdsend(dbri, cmd, 4);
1310 unsigned long flags;
1328 setup_pipe(dbri, 4,
D_SDP_MEM | D_SDP_TO_SER | D_SDP_MSB);
1329 setup_pipe(dbri, 20,
D_SDP_FIXED | D_SDP_TO_SER | D_SDP_MSB);
1333 setup_pipe(dbri, 17,
D_SDP_FIXED | D_SDP_TO_SER | D_SDP_MSB);
1336 spin_unlock_irqrestore(&dbri->
lock, flags);
1375 static void cs4215_setdata(
struct snd_dbri *dbri,
int muted)
1378 dbri->
mm.data[0] |= 63;
1379 dbri->
mm.data[1] |= 63;
1380 dbri->
mm.data[2] &= ~15;
1381 dbri->
mm.data[3] &= ~15;
1388 dbri->
mm.data[0] &= ~0x3f;
1389 dbri->
mm.data[1] &= ~0x3f;
1401 xmit_fixed(dbri, 20, *(
int *)dbri->
mm.data);
1407 static void cs4215_open(
struct snd_dbri *dbri)
1411 unsigned long flags;
1413 dprintk(
D_MM,
"cs4215_open: %d channels, %d bits\n",
1414 dbri->
mm.channels, dbri->
mm.precision);
1420 cs4215_setdata(dbri, 1);
1453 data_width = dbri->
mm.channels * dbri->
mm.precision;
1455 link_time_slot(dbri, 4, 16, 16, data_width, dbri->
mm.offset);
1456 link_time_slot(dbri, 20, 4, 16, 32, dbri->
mm.offset + 32);
1457 link_time_slot(dbri, 6, 16, 16, data_width, dbri->
mm.offset);
1458 link_time_slot(dbri, 21, 6, 16, 16, dbri->
mm.offset + 40);
1464 spin_unlock_irqrestore(&dbri->
lock, flags);
1466 cs4215_setdata(dbri, 0);
1472 static int cs4215_setctrl(
struct snd_dbri *dbri)
1476 unsigned long flags;
1483 cs4215_setdata(dbri, 1);
1492 dprintk(
D_MM,
"cs4215_setctrl: reg2=0x%x\n", val);
1527 link_time_slot(dbri, 17, 16, 16, 32, dbri->
mm.offset);
1528 link_time_slot(dbri, 18, 16, 16, 8, dbri->
mm.offset);
1529 link_time_slot(dbri, 19, 18, 16, 8, dbri->
mm.offset + 48);
1530 spin_unlock_irqrestore(&dbri->
lock, flags);
1534 xmit_fixed(dbri, 17, *(
int *)dbri->
mm.ctrl);
1540 spin_unlock_irqrestore(&dbri->
lock, flags);
1542 for (i = 10; ((dbri->
mm.status & 0xe4) != 0x20); --
i)
1546 dprintk(
D_MM,
"CS4215 didn't respond to CLB (0x%02x)\n",
1554 recv_fixed(dbri, 19,
NULL);
1560 xmit_fixed(dbri, 17, *(
int *)dbri->
mm.ctrl);
1565 cs4215_setdata(dbri, 0);
1576 static int cs4215_prepare(
struct snd_dbri *dbri,
unsigned int rate,
1583 for (freq_idx = 0; CS4215_FREQ[freq_idx].freq != 0; freq_idx++) {
1584 if (CS4215_FREQ[freq_idx].
freq == rate)
1587 if (CS4215_FREQ[freq_idx].
freq != rate) {
1595 dbri->
mm.precision = 8;
1599 dbri->
mm.precision = 8;
1603 dbri->
mm.precision = 8;
1607 dbri->
mm.precision = 16;
1615 dbri->
mm.ctrl[1] |= CS4215_FREQ[freq_idx].csval;
1623 ret = cs4215_setctrl(dbri);
1641 dbri->
mm.onboard = 1;
1645 dbri->
mm.onboard = 0;
1647 if (reg2 & D_PIO2) {
1649 "ignoring onboard mmcodec.\n");
1654 if (!(reg2 & (D_PIO0 | D_PIO2))) {
1659 cs4215_setup_pipes(dbri);
1660 cs4215_init_data(&dbri->
mm);
1663 recv_fixed(dbri, 18, &dbri->
mm.status);
1664 recv_fixed(dbri, 19, &dbri->
mm.version);
1666 dbri->
mm.offset = dbri->
mm.onboard ? 0 : 8;
1667 if (cs4215_setctrl(dbri) == -1 || dbri->
mm.version == 0xff) {
1668 dprintk(
D_MM,
"CS4215 failed probe at offset %d\n",
1672 dprintk(
D_MM,
"Found CS4215 at offset %d\n", dbri->
mm.offset);
1697 static void xmit_descs(
struct snd_dbri *dbri)
1701 unsigned long flags;
1710 if (info->
pipe >= 0) {
1711 first_td = dbri->
pipes[info->
pipe].first_desc;
1716 if (first_td >= 0) {
1717 cmd = dbri_cmdlock(dbri, 2);
1723 dbri_cmdsend(dbri, cmd, 2);
1726 dbri->
pipes[info->
pipe].desc = first_td;
1732 if (info->
pipe >= 0) {
1733 first_td = dbri->
pipes[info->
pipe].first_desc;
1738 if (first_td >= 0) {
1739 cmd = dbri_cmdlock(dbri, 2);
1745 dbri_cmdsend(dbri, cmd, 2);
1748 dbri->
pipes[info->
pipe].desc = first_td;
1752 spin_unlock_irqrestore(&dbri->
lock, flags);
1769 static void transmission_complete_intr(
struct snd_dbri *dbri,
int pipe)
1776 if (td >= DBRI_NO_DESCS) {
1787 dbri->
dma->desc[
td].word4 = 0;
1795 spin_unlock(&dbri->
lock);
1797 spin_lock(&dbri->
lock);
1800 static void reception_complete_intr(
struct snd_dbri *dbri,
int pipe)
1806 if (rd < 0 || rd >= DBRI_NO_DESCS) {
1812 status = dbri->
dma->desc[
rd].word1;
1813 dbri->
dma->desc[
rd].word1 = 0;
1824 spin_unlock(&dbri->
lock);
1826 spin_lock(&dbri->
lock);
1829 static void dbri_process_one_interrupt(
struct snd_dbri *dbri,
int x)
1841 cmds[command], val);
1844 channel, code, rval);
1853 reception_complete_intr(dbri, channel);
1857 transmission_complete_intr(dbri, channel);
1871 dbri->
dma->desc[
td].word4 = 0;
1872 cmd = dbri_cmdlock(dbri, NoGetLock);
1874 dbri->
pipes[pipe].sdp
1877 dbri_cmdsend(dbri, cmd);
1883 if (dbri->
pipes[channel].sdp & D_SDP_MSB)
1884 val = reverse_bytes(val, dbri->
pipes[channel].length);
1886 if (dbri->
pipes[channel].recv_fixed_ptr)
1892 "DBRI: Ignored Interrupt: %d (0x%x)\n", code, x);
1901 static void dbri_process_interrupt_buffer(
struct snd_dbri *dbri)
1911 dbri_process_one_interrupt(dbri, x);
1918 static int errcnt = 0;
1923 spin_lock(&dbri->
lock);
1935 "DBRI: Multiple Error Ack on SBus reg1=0x%x\n",
1939 "DBRI: Multiple Late Error on SBus reg1=0x%x\n",
1943 "DBRI: Lost Bus Grant on SBus reg1=0x%x\n", x);
1946 "DBRI: Burst Error on SBus reg1=0x%x\n", x);
1956 if ((++errcnt) % 10 == 0) {
1966 dbri_process_interrupt_buffer(dbri);
1968 spin_unlock(&dbri->
lock);
1991 .buffer_bytes_max = 64 * 1024,
1992 .period_bytes_min = 1,
1995 .periods_max = 1024,
2009 return snd_mask_refine(f, &
fmt);
2022 snd_interval_any(&ch);
2037 unsigned long flags;
2040 runtime->
hw = snd_dbri_pcm_hw;
2047 spin_unlock_irqrestore(&dbri->
lock, flags);
2053 snd_hw_rule_channels,
NULL,
2084 ret = cs4215_prepare(dbri,
params_rate(hw_params),
2134 substream->
runtime->buffer_size, direction);
2137 if (info->
pipe != -1) {
2138 reset_pipe(dbri, info->
pipe);
2151 info->
size = snd_pcm_lib_buffer_bytes(substream);
2157 spin_lock_irq(&dbri->
lock);
2164 snd_pcm_lib_period_bytes(substream));
2166 spin_unlock_irq(&dbri->
lock);
2181 (
int)snd_pcm_lib_period_bytes(substream));
2187 reset_pipe(dbri, info->
pipe);
2203 % substream->
runtime->buffer_size;
2205 ret, substream->
runtime->buffer_size);
2210 .open = snd_dbri_open,
2211 .close = snd_dbri_close,
2213 .hw_params = snd_dbri_hw_params,
2214 .hw_free = snd_dbri_hw_free,
2215 .prepare = snd_dbri_prepare,
2216 .trigger = snd_dbri_trigger,
2217 .pointer = snd_dbri_pointer,
2242 64 * 1024, 64 * 1024)) < 0)
2252 static int snd_cs4215_info_volume(
struct snd_kcontrol *kcontrol,
2265 static int snd_cs4215_get_volume(
struct snd_kcontrol *kcontrol,
2280 static int snd_cs4215_put_volume(
struct snd_kcontrol *kcontrol,
2286 unsigned int vol[2];
2289 vol[0] = ucontrol->
value.integer.value[0];
2290 vol[1] = ucontrol->
value.integer.value[1];
2311 cs4215_setdata(dbri, 1);
2313 cs4215_setdata(dbri, 0);
2318 static int snd_cs4215_info_single(
struct snd_kcontrol *kcontrol,
2323 uinfo->
type = (mask == 1) ?
2331 static int snd_cs4215_get_single(
struct snd_kcontrol *kcontrol,
2344 ucontrol->
value.integer.value[0] =
2345 (dbri->
mm.data[
elem] >> shift) & mask;
2347 ucontrol->
value.integer.value[0] =
2348 (dbri->
mm.ctrl[elem - 4] >> shift) & mask;
2351 ucontrol->
value.integer.value[0] =
2352 mask - ucontrol->
value.integer.value[0];
2356 static int snd_cs4215_put_single(
struct snd_kcontrol *kcontrol,
2370 val = (ucontrol->
value.integer.value[0] &
mask);
2377 ~(mask << shift)) |
val;
2378 changed = (val != dbri->
mm.data[
elem]);
2380 dbri->
mm.ctrl[elem - 4] = (dbri->
mm.ctrl[elem - 4] &
2381 ~(mask << shift)) |
val;
2382 changed = (val != dbri->
mm.ctrl[elem - 4]);
2386 "mixer-value=%ld, mm-value=0x%x\n",
2387 mask, changed, ucontrol->
value.integer.value[0],
2388 dbri->
mm.data[elem & 3]);
2394 cs4215_setdata(dbri, 1);
2396 cs4215_setdata(dbri, 0);
2405 #define CS4215_SINGLE(xname, entry, shift, mask, invert) \
2406 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
2407 .info = snd_cs4215_info_single, \
2408 .get = snd_cs4215_get_single, .put = snd_cs4215_put_single, \
2409 .private_value = (entry) | ((shift) << 8) | ((mask) << 16) | \
2415 .name =
"Playback Volume",
2416 .info = snd_cs4215_info_volume,
2417 .get = snd_cs4215_get_volume,
2418 .put = snd_cs4215_put_volume,
2426 .name =
"Capture Volume",
2427 .info = snd_cs4215_info_volume,
2428 .get = snd_cs4215_get_volume,
2429 .put = snd_cs4215_put_volume,
2450 for (idx = 0; idx <
ARRAY_SIZE(dbri_controls); idx++) {
2485 snd_iprintf(buffer,
"debug=%d\n", dbri_debug);
2487 for (pipe = 0; pipe < 32; pipe++) {
2488 if (pipe_active(dbri, pipe)) {
2491 "Pipe %d: %s SDP=0x%x desc=%d, "
2494 (pptr->
sdp & D_SDP_TO_SER) ?
"output" :
2508 if (!snd_card_proc_new(card,
"regs", &entry))
2509 snd_info_set_text_ops(entry, dbri, dbri_regs_read);
2512 if (!snd_card_proc_new(card,
"debug", &entry)) {
2513 snd_info_set_text_ops(entry, dbri, dbri_debug_read);
2524 static void snd_dbri_free(
struct snd_dbri *dbri);
2559 "DBRI audio", dbri);
2569 dbri_initialize(dbri);
2570 err = cs4215_init(dbri);
2572 snd_dbri_free(dbri);
2579 static void snd_dbri_free(
struct snd_dbri *dbri)
2628 rp->
flags & 0xffL, (
unsigned long long)rp->
start, irq);
2630 err = snd_dbri_create(card, op, irq, dev);
2637 err = snd_dbri_pcm(card);
2641 err = snd_dbri_mixer(card);
2646 snd_dbri_proc(card);
2655 dbri->
irq, op->
dev.of_node->name[9], dbri->
mm.version);
2661 snd_dbri_free(dbri);
2680 .name =
"SUNW,DBRIe",
2683 .name =
"SUNW,DBRIf",
2694 .of_match_table = dbri_match,
2696 .probe = dbri_probe,