Lines Matching refs:dbri

570 #define DBRI_STREAM(dbri, substream)	\  argument
571 &dbri->stream_info[DBRI_STREAMNO(substream)]
638 static void dbri_cmdwait(struct snd_dbri *dbri) in dbri_cmdwait() argument
644 spin_lock_irqsave(&dbri->lock, flags); in dbri_cmdwait()
645 while ((--maxloops) > 0 && (sbus_readl(dbri->regs + REG0) & D_P)) { in dbri_cmdwait()
646 spin_unlock_irqrestore(&dbri->lock, flags); in dbri_cmdwait()
648 spin_lock_irqsave(&dbri->lock, flags); in dbri_cmdwait()
650 spin_unlock_irqrestore(&dbri->lock, flags); in dbri_cmdwait()
662 static s32 *dbri_cmdlock(struct snd_dbri *dbri, int len) in dbri_cmdlock() argument
664 u32 dvma_addr = (u32)dbri->dma_dvma; in dbri_cmdlock()
668 spin_lock(&dbri->cmdlock); in dbri_cmdlock()
669 if (dbri->cmdptr - dbri->dma->cmd + len < DBRI_NO_CMDS - 2) in dbri_cmdlock()
670 return dbri->cmdptr + 2; in dbri_cmdlock()
671 else if (len < sbus_readl(dbri->regs + REG8) - dvma_addr) in dbri_cmdlock()
672 return dbri->dma->cmd; in dbri_cmdlock()
687 static void dbri_cmdsend(struct snd_dbri *dbri, s32 *cmd, int len) in dbri_cmdsend() argument
689 u32 dvma_addr = (u32)dbri->dma_dvma; in dbri_cmdsend()
699 addr = dvma_addr + (cmd - len - dbri->dma->cmd) * sizeof(s32); in dbri_cmdsend()
700 *(dbri->cmdptr+1) = addr; in dbri_cmdsend()
701 *(dbri->cmdptr) = DBRI_CMD(D_JUMP, 0, 0); in dbri_cmdsend()
704 if (cmd > dbri->cmdptr) { in dbri_cmdsend()
707 for (ptr = dbri->cmdptr; ptr < cmd+2; ptr++) in dbri_cmdsend()
711 s32 *ptr = dbri->cmdptr; in dbri_cmdsend()
716 for (ptr = dbri->dma->cmd; ptr < cmd+2; ptr++) in dbri_cmdsend()
723 tmp = sbus_readl(dbri->regs + REG0); in dbri_cmdsend()
725 sbus_writel(tmp, dbri->regs + REG0); in dbri_cmdsend()
727 dbri->cmdptr = cmd; in dbri_cmdsend()
728 spin_unlock(&dbri->cmdlock); in dbri_cmdsend()
732 static void dbri_reset(struct snd_dbri *dbri) in dbri_reset() argument
738 sbus_readl(dbri->regs + REG0), in dbri_reset()
739 sbus_readl(dbri->regs + REG2), in dbri_reset()
740 sbus_readl(dbri->regs + REG8), sbus_readl(dbri->regs + REG9)); in dbri_reset()
742 sbus_writel(D_R, dbri->regs + REG0); /* Soft Reset */ in dbri_reset()
743 for (i = 0; (sbus_readl(dbri->regs + REG0) & D_R) && i < 64; i++) in dbri_reset()
748 tmp = sbus_readl(dbri->regs + REG0); in dbri_reset()
751 sbus_writel(tmp, dbri->regs + REG0); in dbri_reset()
755 static void dbri_initialize(struct snd_dbri *dbri) in dbri_initialize() argument
757 u32 dvma_addr = (u32)dbri->dma_dvma; in dbri_initialize()
763 spin_lock_irqsave(&dbri->lock, flags); in dbri_initialize()
765 dbri_reset(dbri); in dbri_initialize()
769 dbri->pipes[n].desc = dbri->pipes[n].first_desc = -1; in dbri_initialize()
771 spin_lock_init(&dbri->cmdlock); in dbri_initialize()
776 dbri->dma->intr[0] = dma_addr; in dbri_initialize()
777 dbri->dbri_irqp = 1; in dbri_initialize()
781 spin_lock(&dbri->cmdlock); in dbri_initialize()
782 cmd = dbri->cmdptr = dbri->dma->cmd; in dbri_initialize()
786 dbri->cmdptr = cmd; in dbri_initialize()
790 sbus_writel(dma_addr, dbri->regs + REG8); in dbri_initialize()
791 spin_unlock(&dbri->cmdlock); in dbri_initialize()
793 spin_unlock_irqrestore(&dbri->lock, flags); in dbri_initialize()
794 dbri_cmdwait(dbri); in dbri_initialize()
811 static inline int pipe_active(struct snd_dbri *dbri, int pipe) in pipe_active() argument
813 return ((pipe >= 0) && (dbri->pipes[pipe].desc != -1)); in pipe_active()
821 static void reset_pipe(struct snd_dbri *dbri, int pipe) in reset_pipe() argument
833 sdp = dbri->pipes[pipe].sdp; in reset_pipe()
840 cmd = dbri_cmdlock(dbri, 3); in reset_pipe()
844 dbri_cmdsend(dbri, cmd, 3); in reset_pipe()
846 desc = dbri->pipes[pipe].first_desc; in reset_pipe()
849 dbri->dma->desc[desc].ba = 0; in reset_pipe()
850 dbri->dma->desc[desc].nda = 0; in reset_pipe()
851 desc = dbri->next_desc[desc]; in reset_pipe()
852 } while (desc != -1 && desc != dbri->pipes[pipe].first_desc); in reset_pipe()
854 dbri->pipes[pipe].desc = -1; in reset_pipe()
855 dbri->pipes[pipe].first_desc = -1; in reset_pipe()
861 static void setup_pipe(struct snd_dbri *dbri, int pipe, int sdp) in setup_pipe() argument
882 dbri->pipes[pipe].sdp = sdp; in setup_pipe()
883 dbri->pipes[pipe].desc = -1; in setup_pipe()
884 dbri->pipes[pipe].first_desc = -1; in setup_pipe()
886 reset_pipe(dbri, pipe); in setup_pipe()
892 static void link_time_slot(struct snd_dbri *dbri, int pipe, in link_time_slot() argument
907 if (dbri->pipes[pipe].sdp == 0 in link_time_slot()
908 || dbri->pipes[prevpipe].sdp == 0 in link_time_slot()
909 || dbri->pipes[nextpipe].sdp == 0) { in link_time_slot()
915 dbri->pipes[prevpipe].nextpipe = pipe; in link_time_slot()
916 dbri->pipes[pipe].nextpipe = nextpipe; in link_time_slot()
917 dbri->pipes[pipe].length = length; in link_time_slot()
919 cmd = dbri_cmdlock(dbri, 4); in link_time_slot()
921 if (dbri->pipes[pipe].sdp & D_SDP_TO_SER) { in link_time_slot()
928 cycle = dbri->chi_bpf; in link_time_slot()
944 dbri_cmdsend(dbri, cmd, 4); in link_time_slot()
951 static void unlink_time_slot(struct snd_dbri *dbri, int pipe,
966 cmd = dbri_cmdlock(dbri, 4);
981 dbri_cmdsend(dbri, cmd, 4);
1001 static void xmit_fixed(struct snd_dbri *dbri, int pipe, unsigned int data) in xmit_fixed() argument
1011 if (D_SDP_MODE(dbri->pipes[pipe].sdp) == 0) { in xmit_fixed()
1017 if (D_SDP_MODE(dbri->pipes[pipe].sdp) != D_SDP_FIXED) { in xmit_fixed()
1022 if (!(dbri->pipes[pipe].sdp & D_SDP_TO_SER)) { in xmit_fixed()
1030 if (dbri->pipes[pipe].sdp & D_SDP_MSB) in xmit_fixed()
1031 data = reverse_bytes(data, dbri->pipes[pipe].length); in xmit_fixed()
1033 cmd = dbri_cmdlock(dbri, 3); in xmit_fixed()
1039 spin_lock_irqsave(&dbri->lock, flags); in xmit_fixed()
1040 dbri_cmdsend(dbri, cmd, 3); in xmit_fixed()
1041 spin_unlock_irqrestore(&dbri->lock, flags); in xmit_fixed()
1042 dbri_cmdwait(dbri); in xmit_fixed()
1046 static void recv_fixed(struct snd_dbri *dbri, int pipe, volatile __u32 *ptr) in recv_fixed() argument
1054 if (D_SDP_MODE(dbri->pipes[pipe].sdp) != D_SDP_FIXED) { in recv_fixed()
1060 if (dbri->pipes[pipe].sdp & D_SDP_TO_SER) { in recv_fixed()
1066 dbri->pipes[pipe].recv_fixed_ptr = ptr; in recv_fixed()
1085 static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period) in setup_descs() argument
1087 struct dbri_streaminfo *info = &dbri->stream_info[streamno]; in setup_descs()
1088 u32 dvma_addr = (u32)dbri->dma_dvma; in setup_descs()
1100 if (dbri->pipes[info->pipe].sdp == 0) { in setup_descs()
1110 if (!(dbri->pipes[info->pipe].sdp & D_SDP_TO_SER)) { in setup_descs()
1116 if (dbri->pipes[info->pipe].sdp & D_SDP_TO_SER) { in setup_descs()
1125 if (pipe_active(dbri, info->pipe)) { in setup_descs()
1136 desc = dbri->pipes[info->pipe].first_desc; in setup_descs()
1139 dbri->dma->desc[desc].ba = 0; in setup_descs()
1140 dbri->dma->desc[desc].nda = 0; in setup_descs()
1141 desc = dbri->next_desc[desc]; in setup_descs()
1143 desc != dbri->pipes[info->pipe].first_desc); in setup_descs()
1145 dbri->pipes[info->pipe].desc = -1; in setup_descs()
1146 dbri->pipes[info->pipe].first_desc = -1; in setup_descs()
1153 if (!dbri->dma->desc[desc].ba) in setup_descs()
1170 dbri->next_desc[desc] = -1; in setup_descs()
1171 dbri->dma->desc[desc].ba = dvma_buffer; in setup_descs()
1172 dbri->dma->desc[desc].nda = 0; in setup_descs()
1175 dbri->dma->desc[desc].word1 = DBRI_TD_CNT(mylen); in setup_descs()
1176 dbri->dma->desc[desc].word4 = 0; in setup_descs()
1177 dbri->dma->desc[desc].word1 |= DBRI_TD_F | DBRI_TD_B; in setup_descs()
1179 dbri->dma->desc[desc].word1 = 0; in setup_descs()
1180 dbri->dma->desc[desc].word4 = in setup_descs()
1187 dbri->next_desc[last_desc] = desc; in setup_descs()
1188 dbri->dma->desc[last_desc].nda = in setup_descs()
1203 dbri->dma->desc[last_desc].nda = in setup_descs()
1205 dbri->next_desc[last_desc] = first_desc; in setup_descs()
1206 dbri->pipes[info->pipe].first_desc = first_desc; in setup_descs()
1207 dbri->pipes[info->pipe].desc = first_desc; in setup_descs()
1213 dbri->dma->desc[desc].word1, in setup_descs()
1214 dbri->dma->desc[desc].ba, in setup_descs()
1215 dbri->dma->desc[desc].nda, dbri->dma->desc[desc].word4); in setup_descs()
1216 desc = dbri->next_desc[desc]; in setup_descs()
1240 static void reset_chi(struct snd_dbri *dbri, in reset_chi() argument
1249 cmd = dbri_cmdlock(dbri, 4); in reset_chi()
1256 dbri_cmdsend(dbri, cmd, 4); in reset_chi()
1258 dbri->pipes[16].sdp = 1; in reset_chi()
1259 dbri->pipes[16].nextpipe = 16; in reset_chi()
1261 cmd = dbri_cmdlock(dbri, 4); in reset_chi()
1289 dbri->chi_bpf = bits_per_frame; in reset_chi()
1303 dbri_cmdsend(dbri, cmd, 4); in reset_chi()
1317 static void cs4215_setup_pipes(struct snd_dbri *dbri) in cs4215_setup_pipes() argument
1321 spin_lock_irqsave(&dbri->lock, flags); in cs4215_setup_pipes()
1337 setup_pipe(dbri, 4, D_SDP_MEM | D_SDP_TO_SER | D_SDP_MSB); in cs4215_setup_pipes()
1338 setup_pipe(dbri, 20, D_SDP_FIXED | D_SDP_TO_SER | D_SDP_MSB); in cs4215_setup_pipes()
1339 setup_pipe(dbri, 6, D_SDP_MEM | D_SDP_FROM_SER | D_SDP_MSB); in cs4215_setup_pipes()
1340 setup_pipe(dbri, 21, D_SDP_FIXED | D_SDP_FROM_SER | D_SDP_MSB); in cs4215_setup_pipes()
1342 setup_pipe(dbri, 17, D_SDP_FIXED | D_SDP_TO_SER | D_SDP_MSB); in cs4215_setup_pipes()
1343 setup_pipe(dbri, 18, D_SDP_FIXED | D_SDP_FROM_SER | D_SDP_MSB); in cs4215_setup_pipes()
1344 setup_pipe(dbri, 19, D_SDP_FIXED | D_SDP_FROM_SER | D_SDP_MSB); in cs4215_setup_pipes()
1345 spin_unlock_irqrestore(&dbri->lock, flags); in cs4215_setup_pipes()
1347 dbri_cmdwait(dbri); in cs4215_setup_pipes()
1384 static void cs4215_setdata(struct snd_dbri *dbri, int muted) in cs4215_setdata() argument
1387 dbri->mm.data[0] |= 63; in cs4215_setdata()
1388 dbri->mm.data[1] |= 63; in cs4215_setdata()
1389 dbri->mm.data[2] &= ~15; in cs4215_setdata()
1390 dbri->mm.data[3] &= ~15; in cs4215_setdata()
1393 struct dbri_streaminfo *info = &dbri->stream_info[DBRI_PLAY]; in cs4215_setdata()
1397 dbri->mm.data[0] &= ~0x3f; /* Reset the volume bits */ in cs4215_setdata()
1398 dbri->mm.data[1] &= ~0x3f; in cs4215_setdata()
1399 dbri->mm.data[0] |= (DBRI_MAX_VOLUME - left_gain); in cs4215_setdata()
1400 dbri->mm.data[1] |= (DBRI_MAX_VOLUME - right_gain); in cs4215_setdata()
1403 info = &dbri->stream_info[DBRI_REC]; in cs4215_setdata()
1406 dbri->mm.data[2] |= CS4215_LG(left_gain); in cs4215_setdata()
1407 dbri->mm.data[3] |= CS4215_RG(right_gain); in cs4215_setdata()
1410 xmit_fixed(dbri, 20, *(int *)dbri->mm.data); in cs4215_setdata()
1416 static void cs4215_open(struct snd_dbri *dbri) in cs4215_open() argument
1423 dbri->mm.channels, dbri->mm.precision); in cs4215_open()
1429 cs4215_setdata(dbri, 1); in cs4215_open()
1445 spin_lock_irqsave(&dbri->lock, flags); in cs4215_open()
1446 tmp = sbus_readl(dbri->regs + REG0); in cs4215_open()
1448 sbus_writel(tmp, dbri->regs + REG0); in cs4215_open()
1452 (dbri->mm.onboard ? D_PIO0 : D_PIO2), dbri->regs + REG2); in cs4215_open()
1454 reset_chi(dbri, CHIslave, 128); in cs4215_open()
1462 data_width = dbri->mm.channels * dbri->mm.precision; in cs4215_open()
1464 link_time_slot(dbri, 4, 16, 16, data_width, dbri->mm.offset); in cs4215_open()
1465 link_time_slot(dbri, 20, 4, 16, 32, dbri->mm.offset + 32); in cs4215_open()
1466 link_time_slot(dbri, 6, 16, 16, data_width, dbri->mm.offset); in cs4215_open()
1467 link_time_slot(dbri, 21, 6, 16, 16, dbri->mm.offset + 40); in cs4215_open()
1470 tmp = sbus_readl(dbri->regs + REG0); in cs4215_open()
1472 sbus_writel(tmp, dbri->regs + REG0); in cs4215_open()
1473 spin_unlock_irqrestore(&dbri->lock, flags); in cs4215_open()
1475 cs4215_setdata(dbri, 0); in cs4215_open()
1481 static int cs4215_setctrl(struct snd_dbri *dbri) in cs4215_setctrl() argument
1492 cs4215_setdata(dbri, 1); in cs4215_setctrl()
1499 val = D_ENPIO | D_PIO1 | (dbri->mm.onboard ? D_PIO0 : D_PIO2); in cs4215_setctrl()
1500 sbus_writel(val, dbri->regs + REG2); in cs4215_setctrl()
1522 spin_lock_irqsave(&dbri->lock, flags); in cs4215_setctrl()
1523 tmp = sbus_readl(dbri->regs + REG0); in cs4215_setctrl()
1525 sbus_writel(tmp, dbri->regs + REG0); in cs4215_setctrl()
1527 reset_chi(dbri, CHImaster, 128); in cs4215_setctrl()
1536 link_time_slot(dbri, 17, 16, 16, 32, dbri->mm.offset); in cs4215_setctrl()
1537 link_time_slot(dbri, 18, 16, 16, 8, dbri->mm.offset); in cs4215_setctrl()
1538 link_time_slot(dbri, 19, 18, 16, 8, dbri->mm.offset + 48); in cs4215_setctrl()
1539 spin_unlock_irqrestore(&dbri->lock, flags); in cs4215_setctrl()
1542 dbri->mm.ctrl[0] &= ~CS4215_CLB; in cs4215_setctrl()
1543 xmit_fixed(dbri, 17, *(int *)dbri->mm.ctrl); in cs4215_setctrl()
1545 spin_lock_irqsave(&dbri->lock, flags); in cs4215_setctrl()
1546 tmp = sbus_readl(dbri->regs + REG0); in cs4215_setctrl()
1548 sbus_writel(tmp, dbri->regs + REG0); in cs4215_setctrl()
1549 spin_unlock_irqrestore(&dbri->lock, flags); in cs4215_setctrl()
1551 for (i = 10; ((dbri->mm.status & 0xe4) != 0x20); --i) in cs4215_setctrl()
1556 dbri->mm.status); in cs4215_setctrl()
1563 recv_fixed(dbri, 19, NULL); in cs4215_setctrl()
1568 dbri->mm.ctrl[0] |= CS4215_CLB; in cs4215_setctrl()
1569 xmit_fixed(dbri, 17, *(int *)dbri->mm.ctrl); in cs4215_setctrl()
1574 cs4215_setdata(dbri, 0); in cs4215_setctrl()
1585 static int cs4215_prepare(struct snd_dbri *dbri, unsigned int rate, in cs4215_prepare() argument
1603 dbri->mm.ctrl[1] = CS4215_DFR_ULAW; in cs4215_prepare()
1604 dbri->mm.precision = 8; in cs4215_prepare()
1607 dbri->mm.ctrl[1] = CS4215_DFR_ALAW; in cs4215_prepare()
1608 dbri->mm.precision = 8; in cs4215_prepare()
1611 dbri->mm.ctrl[1] = CS4215_DFR_LINEAR8; in cs4215_prepare()
1612 dbri->mm.precision = 8; in cs4215_prepare()
1615 dbri->mm.ctrl[1] = CS4215_DFR_LINEAR16; in cs4215_prepare()
1616 dbri->mm.precision = 16; in cs4215_prepare()
1624 dbri->mm.ctrl[1] |= CS4215_FREQ[freq_idx].csval; in cs4215_prepare()
1625 dbri->mm.ctrl[2] = CS4215_XCLK | in cs4215_prepare()
1628 dbri->mm.channels = channels; in cs4215_prepare()
1630 dbri->mm.ctrl[1] |= CS4215_DFR_STEREO; in cs4215_prepare()
1632 ret = cs4215_setctrl(dbri); in cs4215_prepare()
1634 cs4215_open(dbri); /* set codec to data mode */ in cs4215_prepare()
1642 static int cs4215_init(struct snd_dbri *dbri) in cs4215_init() argument
1644 u32 reg2 = sbus_readl(dbri->regs + REG2); in cs4215_init()
1650 dbri->mm.onboard = 1; in cs4215_init()
1654 dbri->mm.onboard = 0; in cs4215_init()
1659 sbus_writel(D_ENPIO2, dbri->regs + REG2); in cs4215_init()
1668 cs4215_setup_pipes(dbri); in cs4215_init()
1669 cs4215_init_data(&dbri->mm); in cs4215_init()
1672 recv_fixed(dbri, 18, &dbri->mm.status); in cs4215_init()
1673 recv_fixed(dbri, 19, &dbri->mm.version); in cs4215_init()
1675 dbri->mm.offset = dbri->mm.onboard ? 0 : 8; in cs4215_init()
1676 if (cs4215_setctrl(dbri) == -1 || dbri->mm.version == 0xff) { in cs4215_init()
1678 dbri->mm.offset); in cs4215_init()
1681 dprintk(D_MM, "Found CS4215 at offset %d\n", dbri->mm.offset); in cs4215_init()
1706 static void xmit_descs(struct snd_dbri *dbri) in xmit_descs() argument
1714 if (dbri == NULL) in xmit_descs()
1717 dvma_addr = (u32)dbri->dma_dvma; in xmit_descs()
1718 info = &dbri->stream_info[DBRI_REC]; in xmit_descs()
1719 spin_lock_irqsave(&dbri->lock, flags); in xmit_descs()
1722 first_td = dbri->pipes[info->pipe].first_desc; in xmit_descs()
1728 cmd = dbri_cmdlock(dbri, 2); in xmit_descs()
1730 dbri->pipes[info->pipe].sdp in xmit_descs()
1734 dbri_cmdsend(dbri, cmd, 2); in xmit_descs()
1737 dbri->pipes[info->pipe].desc = first_td; in xmit_descs()
1741 info = &dbri->stream_info[DBRI_PLAY]; in xmit_descs()
1744 first_td = dbri->pipes[info->pipe].first_desc; in xmit_descs()
1750 cmd = dbri_cmdlock(dbri, 2); in xmit_descs()
1752 dbri->pipes[info->pipe].sdp in xmit_descs()
1756 dbri_cmdsend(dbri, cmd, 2); in xmit_descs()
1759 dbri->pipes[info->pipe].desc = first_td; in xmit_descs()
1763 spin_unlock_irqrestore(&dbri->lock, flags); in xmit_descs()
1780 static void transmission_complete_intr(struct snd_dbri *dbri, int pipe) in transmission_complete_intr() argument
1782 struct dbri_streaminfo *info = &dbri->stream_info[DBRI_PLAY]; in transmission_complete_intr()
1783 int td = dbri->pipes[pipe].desc; in transmission_complete_intr()
1792 status = DBRI_TD_STATUS(dbri->dma->desc[td].word4); in transmission_complete_intr()
1798 dbri->dma->desc[td].word4 = 0; /* Reset it for next time. */ in transmission_complete_intr()
1799 info->offset += DBRI_RD_CNT(dbri->dma->desc[td].word1); in transmission_complete_intr()
1801 td = dbri->next_desc[td]; in transmission_complete_intr()
1802 dbri->pipes[pipe].desc = td; in transmission_complete_intr()
1806 spin_unlock(&dbri->lock); in transmission_complete_intr()
1808 spin_lock(&dbri->lock); in transmission_complete_intr()
1811 static void reception_complete_intr(struct snd_dbri *dbri, int pipe) in reception_complete_intr() argument
1814 int rd = dbri->pipes[pipe].desc; in reception_complete_intr()
1822 dbri->pipes[pipe].desc = dbri->next_desc[rd]; in reception_complete_intr()
1823 status = dbri->dma->desc[rd].word1; in reception_complete_intr()
1824 dbri->dma->desc[rd].word1 = 0; /* Reset it for next time. */ in reception_complete_intr()
1826 info = &dbri->stream_info[DBRI_REC]; in reception_complete_intr()
1835 spin_unlock(&dbri->lock); in reception_complete_intr()
1837 spin_lock(&dbri->lock); in reception_complete_intr()
1840 static void dbri_process_one_interrupt(struct snd_dbri *dbri, int x) in dbri_process_one_interrupt() argument
1864 reception_complete_intr(dbri, channel); in dbri_process_one_interrupt()
1868 transmission_complete_intr(dbri, channel); in dbri_process_one_interrupt()
1880 int td = dbri->pipes[pipe].desc; in dbri_process_one_interrupt()
1882 dbri->dma->desc[td].word4 = 0; in dbri_process_one_interrupt()
1883 cmd = dbri_cmdlock(dbri, NoGetLock); in dbri_process_one_interrupt()
1885 dbri->pipes[pipe].sdp in dbri_process_one_interrupt()
1887 *(cmd++) = dbri->dma_dvma + dbri_dma_off(desc, td); in dbri_process_one_interrupt()
1888 dbri_cmdsend(dbri, cmd); in dbri_process_one_interrupt()
1894 if (dbri->pipes[channel].sdp & D_SDP_MSB) in dbri_process_one_interrupt()
1895 val = reverse_bytes(val, dbri->pipes[channel].length); in dbri_process_one_interrupt()
1897 if (dbri->pipes[channel].recv_fixed_ptr) in dbri_process_one_interrupt()
1898 *(dbri->pipes[channel].recv_fixed_ptr) = val; in dbri_process_one_interrupt()
1912 static void dbri_process_interrupt_buffer(struct snd_dbri *dbri) in dbri_process_interrupt_buffer() argument
1916 while ((x = dbri->dma->intr[dbri->dbri_irqp]) != 0) { in dbri_process_interrupt_buffer()
1917 dbri->dma->intr[dbri->dbri_irqp] = 0; in dbri_process_interrupt_buffer()
1918 dbri->dbri_irqp++; in dbri_process_interrupt_buffer()
1919 if (dbri->dbri_irqp == DBRI_INT_BLK) in dbri_process_interrupt_buffer()
1920 dbri->dbri_irqp = 1; in dbri_process_interrupt_buffer()
1922 dbri_process_one_interrupt(dbri, x); in dbri_process_interrupt_buffer()
1928 struct snd_dbri *dbri = dev_id; in snd_dbri_interrupt() local
1932 if (dbri == NULL) in snd_dbri_interrupt()
1934 spin_lock(&dbri->lock); in snd_dbri_interrupt()
1939 x = sbus_readl(dbri->regs + REG1); in snd_dbri_interrupt()
1969 dbri_reset(dbri); in snd_dbri_interrupt()
1971 tmp = sbus_readl(dbri->regs + REG0); in snd_dbri_interrupt()
1973 sbus_writel(tmp, dbri->regs + REG0); in snd_dbri_interrupt()
1977 dbri_process_interrupt_buffer(dbri); in snd_dbri_interrupt()
1979 spin_unlock(&dbri->lock); in snd_dbri_interrupt()
2045 struct snd_dbri *dbri = snd_pcm_substream_chip(substream); in snd_dbri_open() local
2047 struct dbri_streaminfo *info = DBRI_STREAM(dbri, substream); in snd_dbri_open()
2053 spin_lock_irqsave(&dbri->lock, flags); in snd_dbri_open()
2058 spin_unlock_irqrestore(&dbri->lock, flags); in snd_dbri_open()
2068 cs4215_open(dbri); in snd_dbri_open()
2075 struct snd_dbri *dbri = snd_pcm_substream_chip(substream); in snd_dbri_close() local
2076 struct dbri_streaminfo *info = DBRI_STREAM(dbri, substream); in snd_dbri_close()
2089 struct snd_dbri *dbri = snd_pcm_substream_chip(substream); in snd_dbri_hw_params() local
2090 struct dbri_streaminfo *info = DBRI_STREAM(dbri, substream); in snd_dbri_hw_params()
2095 ret = cs4215_prepare(dbri, params_rate(hw_params), in snd_dbri_hw_params()
2110 dma_map_single(&dbri->op->dev, in snd_dbri_hw_params()
2124 struct snd_dbri *dbri = snd_pcm_substream_chip(substream); in snd_dbri_hw_free() local
2125 struct dbri_streaminfo *info = DBRI_STREAM(dbri, substream); in snd_dbri_hw_free()
2138 dma_unmap_single(&dbri->op->dev, info->dvma_buffer, in snd_dbri_hw_free()
2143 reset_pipe(dbri, info->pipe); in snd_dbri_hw_free()
2152 struct snd_dbri *dbri = snd_pcm_substream_chip(substream); in snd_dbri_prepare() local
2153 struct dbri_streaminfo *info = DBRI_STREAM(dbri, substream); in snd_dbri_prepare()
2162 spin_lock_irq(&dbri->lock); in snd_dbri_prepare()
2168 ret = setup_descs(dbri, DBRI_STREAMNO(substream), in snd_dbri_prepare()
2171 spin_unlock_irq(&dbri->lock); in snd_dbri_prepare()
2179 struct snd_dbri *dbri = snd_pcm_substream_chip(substream); in snd_dbri_trigger() local
2180 struct dbri_streaminfo *info = DBRI_STREAM(dbri, substream); in snd_dbri_trigger()
2188 xmit_descs(dbri); in snd_dbri_trigger()
2192 reset_pipe(dbri, info->pipe); in snd_dbri_trigger()
2203 struct snd_dbri *dbri = snd_pcm_substream_chip(substream); in snd_dbri_pointer() local
2204 struct dbri_streaminfo *info = DBRI_STREAM(dbri, substream); in snd_dbri_pointer()
2269 struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol); in snd_cs4215_get_volume() local
2272 if (snd_BUG_ON(!dbri)) in snd_cs4215_get_volume()
2274 info = &dbri->stream_info[kcontrol->private_value]; in snd_cs4215_get_volume()
2284 struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol); in snd_cs4215_put_volume() local
2286 &dbri->stream_info[kcontrol->private_value]; in snd_cs4215_put_volume()
2312 cs4215_setdata(dbri, 1); in snd_cs4215_put_volume()
2314 cs4215_setdata(dbri, 0); in snd_cs4215_put_volume()
2335 struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol); in snd_cs4215_get_single() local
2341 if (snd_BUG_ON(!dbri)) in snd_cs4215_get_single()
2346 (dbri->mm.data[elem] >> shift) & mask; in snd_cs4215_get_single()
2349 (dbri->mm.ctrl[elem - 4] >> shift) & mask; in snd_cs4215_get_single()
2360 struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol); in snd_cs4215_put_single() local
2368 if (snd_BUG_ON(!dbri)) in snd_cs4215_put_single()
2377 dbri->mm.data[elem] = (dbri->mm.data[elem] & in snd_cs4215_put_single()
2379 changed = (val != dbri->mm.data[elem]); in snd_cs4215_put_single()
2381 dbri->mm.ctrl[elem - 4] = (dbri->mm.ctrl[elem - 4] & in snd_cs4215_put_single()
2383 changed = (val != dbri->mm.ctrl[elem - 4]); in snd_cs4215_put_single()
2389 dbri->mm.data[elem & 3]); in snd_cs4215_put_single()
2395 cs4215_setdata(dbri, 1); in snd_cs4215_put_single()
2397 cs4215_setdata(dbri, 0); in snd_cs4215_put_single()
2443 struct snd_dbri *dbri; in snd_dbri_mixer() local
2447 dbri = card->private_data; in snd_dbri_mixer()
2453 snd_ctl_new1(&dbri_controls[idx], dbri)); in snd_dbri_mixer()
2459 dbri->stream_info[idx].left_gain = 0; in snd_dbri_mixer()
2460 dbri->stream_info[idx].right_gain = 0; in snd_dbri_mixer()
2472 struct snd_dbri *dbri = entry->private_data; in dbri_regs_read() local
2474 snd_iprintf(buffer, "REG0: 0x%x\n", sbus_readl(dbri->regs + REG0)); in dbri_regs_read()
2475 snd_iprintf(buffer, "REG2: 0x%x\n", sbus_readl(dbri->regs + REG2)); in dbri_regs_read()
2476 snd_iprintf(buffer, "REG8: 0x%x\n", sbus_readl(dbri->regs + REG8)); in dbri_regs_read()
2477 snd_iprintf(buffer, "REG9: 0x%x\n", sbus_readl(dbri->regs + REG9)); in dbri_regs_read()
2484 struct snd_dbri *dbri = entry->private_data; in dbri_debug_read() local
2489 if (pipe_active(dbri, pipe)) { in dbri_debug_read()
2490 struct dbri_pipe *pptr = &dbri->pipes[pipe]; in dbri_debug_read()
2506 struct snd_dbri *dbri = card->private_data; in snd_dbri_proc() local
2508 snd_card_ro_proc_new(card, "regs", dbri, dbri_regs_read); in snd_dbri_proc()
2510 snd_card_ro_proc_new(card, "debug", dbri, dbri_debug_read); in snd_dbri_proc()
2519 static void snd_dbri_free(struct snd_dbri *dbri);
2525 struct snd_dbri *dbri = card->private_data; in snd_dbri_create() local
2528 spin_lock_init(&dbri->lock); in snd_dbri_create()
2529 dbri->op = op; in snd_dbri_create()
2530 dbri->irq = irq; in snd_dbri_create()
2532 dbri->dma = dma_alloc_coherent(&op->dev, sizeof(struct dbri_dma), in snd_dbri_create()
2533 &dbri->dma_dvma, GFP_KERNEL); in snd_dbri_create()
2534 if (!dbri->dma) in snd_dbri_create()
2538 dbri->dma, dbri->dma_dvma); in snd_dbri_create()
2541 dbri->regs_size = resource_size(&op->resource[0]); in snd_dbri_create()
2542 dbri->regs = of_ioremap(&op->resource[0], 0, in snd_dbri_create()
2543 dbri->regs_size, "DBRI Registers"); in snd_dbri_create()
2544 if (!dbri->regs) { in snd_dbri_create()
2547 (void *)dbri->dma, dbri->dma_dvma); in snd_dbri_create()
2551 err = request_irq(dbri->irq, snd_dbri_interrupt, IRQF_SHARED, in snd_dbri_create()
2552 "DBRI audio", dbri); in snd_dbri_create()
2554 printk(KERN_ERR "DBRI: Can't get irq %d\n", dbri->irq); in snd_dbri_create()
2555 of_iounmap(&op->resource[0], dbri->regs, dbri->regs_size); in snd_dbri_create()
2557 (void *)dbri->dma, dbri->dma_dvma); in snd_dbri_create()
2562 dbri_initialize(dbri); in snd_dbri_create()
2563 err = cs4215_init(dbri); in snd_dbri_create()
2565 snd_dbri_free(dbri); in snd_dbri_create()
2572 static void snd_dbri_free(struct snd_dbri *dbri) in snd_dbri_free() argument
2575 dbri_reset(dbri); in snd_dbri_free()
2577 if (dbri->irq) in snd_dbri_free()
2578 free_irq(dbri->irq, dbri); in snd_dbri_free()
2580 if (dbri->regs) in snd_dbri_free()
2581 of_iounmap(&dbri->op->resource[0], dbri->regs, dbri->regs_size); in snd_dbri_free()
2583 if (dbri->dma) in snd_dbri_free()
2584 dma_free_coherent(&dbri->op->dev, in snd_dbri_free()
2586 (void *)dbri->dma, dbri->dma_dvma); in snd_dbri_free()
2591 struct snd_dbri *dbri; in dbri_probe() local
2629 dbri = card->private_data; in dbri_probe()
2647 dev, dbri->regs, in dbri_probe()
2648 dbri->irq, op->dev.of_node->name[9], dbri->mm.version); in dbri_probe()
2654 snd_dbri_free(dbri); in dbri_probe()