aboutsummaryrefslogtreecommitdiffstats
path: root/sound/sparc/dbri.c
diff options
context:
space:
mode:
authorKrzysztof Helt <krzysztof.h1@wp.pl>2006-08-21 13:29:59 -0400
committerJaroslav Kysela <perex@suse.cz>2006-09-23 04:42:28 -0400
commit294a30dc8cf13c492913f2ed3a6540bdf6e84e39 (patch)
tree3c92542d4cd9834e65b72241ac1ea2dd54c1d51f /sound/sparc/dbri.c
parentd1fdf07e22efdb9fa53739c0f0fec1f6b24c2056 (diff)
[ALSA] sparc dbri: simplifed linking time slot function
A simplified routines to link and unlink time slots. Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/sparc/dbri.c')
-rw-r--r--sound/sparc/dbri.c125
1 files changed, 41 insertions, 84 deletions
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c
index 810f8b99a60e..5696f792e3d1 100644
--- a/sound/sparc/dbri.c
+++ b/sound/sparc/dbri.c
@@ -274,7 +274,6 @@ enum in_or_out { PIPEinput, PIPEoutput };
274struct dbri_pipe { 274struct dbri_pipe {
275 u32 sdp; /* SDP command word */ 275 u32 sdp; /* SDP command word */
276 int nextpipe; /* Next pipe in linked list */ 276 int nextpipe; /* Next pipe in linked list */
277 int cycle; /* Offset of timeslot (bits) */
278 int length; /* Length of timeslot (bits) */ 277 int length; /* Length of timeslot (bits) */
279 int first_desc; /* Index of first descriptor */ 278 int first_desc; /* Index of first descriptor */
280 int desc; /* Index of active descriptor */ 279 int desc; /* Index of active descriptor */
@@ -312,8 +311,6 @@ struct snd_dbri {
312 struct dbri_pipe pipes[DBRI_NO_PIPES]; /* DBRI's 32 data pipes */ 311 struct dbri_pipe pipes[DBRI_NO_PIPES]; /* DBRI's 32 data pipes */
313 int next_desc[DBRI_NO_DESCS]; /* Index of next desc, or -1 */ 312 int next_desc[DBRI_NO_DESCS]; /* Index of next desc, or -1 */
314 313
315 int chi_in_pipe;
316 int chi_out_pipe;
317 int chi_bpf; 314 int chi_bpf;
318 315
319 struct cs4215 mm; /* mmcodec special info */ 316 struct cs4215 mm; /* mmcodec special info */
@@ -827,92 +824,55 @@ static void setup_pipe(struct snd_dbri * dbri, int pipe, int sdp)
827 reset_pipe(dbri, pipe); 824 reset_pipe(dbri, pipe);
828} 825}
829 826
830/* FIXME: direction not needed */
831static void link_time_slot(struct snd_dbri * dbri, int pipe, 827static void link_time_slot(struct snd_dbri * dbri, int pipe,
832 enum in_or_out direction, int basepipe, 828 int prevpipe, int nextpipe,
833 int length, int cycle) 829 int length, int cycle)
834{ 830{
835 volatile s32 *cmd; 831 volatile s32 *cmd;
836 int val; 832 int val;
837 int prevpipe;
838 int nextpipe;
839 833
840 if (pipe < 0 || pipe > DBRI_MAX_PIPE || basepipe < 0 || basepipe > DBRI_MAX_PIPE) { 834 if (pipe < 0 || pipe > DBRI_MAX_PIPE
835 || prevpipe < 0 || prevpipe > DBRI_MAX_PIPE
836 || nextpipe < 0 || nextpipe > DBRI_MAX_PIPE) {
841 printk(KERN_ERR 837 printk(KERN_ERR
842 "DBRI: link_time_slot called with illegal pipe number\n"); 838 "DBRI: link_time_slot called with illegal pipe number\n");
843 return; 839 return;
844 } 840 }
845 841
846 if (dbri->pipes[pipe].sdp == 0 || dbri->pipes[basepipe].sdp == 0) { 842 if (dbri->pipes[pipe].sdp == 0
843 || dbri->pipes[prevpipe].sdp == 0
844 || dbri->pipes[nextpipe].sdp == 0) {
847 printk(KERN_ERR "DBRI: link_time_slot called on uninitialized pipe\n"); 845 printk(KERN_ERR "DBRI: link_time_slot called on uninitialized pipe\n");
848 return; 846 return;
849 } 847 }
850 848
851 /* Deal with CHI special case: 849 dbri->pipes[prevpipe].nextpipe = pipe;
852 * "If transmission on edges 0 or 1 is desired, then cycle n
853 * (where n = # of bit times per frame...) must be used."
854 * - DBRI data sheet, page 11
855 */
856 if (basepipe == 16 && direction == PIPEoutput && cycle == 0)
857 cycle = dbri->chi_bpf;
858
859 if (basepipe == pipe) {
860 prevpipe = pipe;
861 nextpipe = pipe;
862 } else {
863 /* We're not initializing a new linked list (basepipe != pipe),
864 * so run through the linked list and find where this pipe
865 * should be sloted in, based on its cycle. CHI confuses
866 * things a bit, since it has a single anchor for both its
867 * transmit and receive lists.
868 */
869 if (basepipe == 16) {
870 if (direction == PIPEinput) {
871 prevpipe = dbri->chi_in_pipe;
872 } else {
873 prevpipe = dbri->chi_out_pipe;
874 }
875 } else {
876 prevpipe = basepipe;
877 }
878
879 nextpipe = dbri->pipes[prevpipe].nextpipe;
880
881 while (dbri->pipes[nextpipe].cycle < cycle
882 && dbri->pipes[nextpipe].nextpipe != basepipe) {
883 prevpipe = nextpipe;
884 nextpipe = dbri->pipes[nextpipe].nextpipe;
885 }
886 }
887
888 if (prevpipe == 16) {
889 if (direction == PIPEinput) {
890 dbri->chi_in_pipe = pipe;
891 } else {
892 dbri->chi_out_pipe = pipe;
893 }
894 } else {
895 dbri->pipes[prevpipe].nextpipe = pipe;
896 }
897 850
898 dbri->pipes[pipe].nextpipe = nextpipe; 851 dbri->pipes[pipe].nextpipe = nextpipe;
899 dbri->pipes[pipe].cycle = cycle;
900 dbri->pipes[pipe].length = length; 852 dbri->pipes[pipe].length = length;
901 853
902 cmd = dbri_cmdlock(dbri, NoGetLock); 854 cmd = dbri_cmdlock(dbri, NoGetLock);
903 855
904 if (direction == PIPEinput) { 856 if (dbri->pipes[pipe].sdp & D_SDP_TO_SER) {
905 val = D_DTS_VI | D_DTS_INS | D_DTS_PRVIN(prevpipe) | pipe; 857 /* Deal with CHI special case:
858 * "If transmission on edges 0 or 1 is desired, then cycle n
859 * (where n = # of bit times per frame...) must be used."
860 * - DBRI data sheet, page 11
861 */
862 if (prevpipe == 16 && cycle == 0)
863 cycle = dbri->chi_bpf;
864
865 val = D_DTS_VO | D_DTS_INS | D_DTS_PRVOUT(prevpipe) | pipe;
906 *(cmd++) = DBRI_CMD(D_DTS, 0, val); 866 *(cmd++) = DBRI_CMD(D_DTS, 0, val);
867 *(cmd++) = 0;
907 *(cmd++) = 868 *(cmd++) =
908 D_TS_LEN(length) | D_TS_CYCLE(cycle) | D_TS_NEXT(nextpipe); 869 D_TS_LEN(length) | D_TS_CYCLE(cycle) | D_TS_NEXT(nextpipe);
909 *(cmd++) = 0;
910 } else { 870 } else {
911 val = D_DTS_VO | D_DTS_INS | D_DTS_PRVOUT(prevpipe) | pipe; 871 val = D_DTS_VI | D_DTS_INS | D_DTS_PRVIN(prevpipe) | pipe;
912 *(cmd++) = DBRI_CMD(D_DTS, 0, val); 872 *(cmd++) = DBRI_CMD(D_DTS, 0, val);
913 *(cmd++) = 0;
914 *(cmd++) = 873 *(cmd++) =
915 D_TS_LEN(length) | D_TS_CYCLE(cycle) | D_TS_NEXT(nextpipe); 874 D_TS_LEN(length) | D_TS_CYCLE(cycle) | D_TS_NEXT(nextpipe);
875 *(cmd++) = 0;
916 } 876 }
917 877
918 dbri_cmdsend(dbri, cmd); 878 dbri_cmdsend(dbri, cmd);
@@ -1192,21 +1152,18 @@ static void reset_chi(struct snd_dbri * dbri, enum master_or_slave master_or_sla
1192 } else { 1152 } else {
1193 int pipe; 1153 int pipe;
1194 1154
1195 for (pipe = dbri->chi_in_pipe; 1155 for (pipe = 0; pipe < DBRI_NO_PIPES; pipe++ )
1196 pipe != 16; pipe = dbri->pipes[pipe].nextpipe) { 1156 if ( pipe != 16 ) {
1197 unlink_time_slot(dbri, pipe, PIPEinput, 1157 if (dbri->pipes[pipe].sdp & D_SDP_TO_SER)
1198 16, dbri->pipes[pipe].nextpipe); 1158 unlink_time_slot(dbri, pipe, PIPEoutput,
1199 } 1159 16, dbri->pipes[pipe].nextpipe);
1200 for (pipe = dbri->chi_out_pipe; 1160 else
1201 pipe != 16; pipe = dbri->pipes[pipe].nextpipe) { 1161 unlink_time_slot(dbri, pipe, PIPEinput,
1202 unlink_time_slot(dbri, pipe, PIPEoutput, 1162 16, dbri->pipes[pipe].nextpipe);
1203 16, dbri->pipes[pipe].nextpipe); 1163 }
1204 } 1164
1205 1165 cmd = dbri_cmdlock(dbri, GetLock);
1206 cmd = dbri_cmdlock(dbri, GetLock);
1207 } 1166 }
1208 dbri->chi_in_pipe = 16;
1209 dbri->chi_out_pipe = 16;
1210 1167
1211 if (master_or_slave == CHIslave) { 1168 if (master_or_slave == CHIslave) {
1212 /* Setup DBRI for CHI Slave - receive clock, frame sync (FS) 1169 /* Setup DBRI for CHI Slave - receive clock, frame sync (FS)
@@ -1397,10 +1354,10 @@ static void cs4215_open(struct snd_dbri * dbri)
1397 */ 1354 */
1398 data_width = dbri->mm.channels * dbri->mm.precision; 1355 data_width = dbri->mm.channels * dbri->mm.precision;
1399 1356
1400 link_time_slot(dbri, 20, PIPEoutput, 16, 32, dbri->mm.offset + 32); 1357 link_time_slot(dbri, 4, 16, 16, data_width, dbri->mm.offset);
1401 link_time_slot(dbri, 4, PIPEoutput, 16, data_width, dbri->mm.offset); 1358 link_time_slot(dbri, 20, 4, 16, 32, dbri->mm.offset + 32);
1402 link_time_slot(dbri, 6, PIPEinput, 16, data_width, dbri->mm.offset); 1359 link_time_slot(dbri, 6, 16, 16, data_width, dbri->mm.offset);
1403 link_time_slot(dbri, 21, PIPEinput, 16, 16, dbri->mm.offset + 40); 1360 link_time_slot(dbri, 21, 6, 16, 16, dbri->mm.offset + 40);
1404 1361
1405 /* FIXME: enable CHI after _setdata? */ 1362 /* FIXME: enable CHI after _setdata? */
1406 tmp = sbus_readl(dbri->regs + REG0); 1363 tmp = sbus_readl(dbri->regs + REG0);
@@ -1466,9 +1423,9 @@ static int cs4215_setctrl(struct snd_dbri * dbri)
1466 * Pipe 19: Receive timeslot 7 (version). 1423 * Pipe 19: Receive timeslot 7 (version).
1467 */ 1424 */
1468 1425
1469 link_time_slot(dbri, 17, PIPEoutput, 16, 32, dbri->mm.offset); 1426 link_time_slot(dbri, 17, 16, 16, 32, dbri->mm.offset);
1470 link_time_slot(dbri, 18, PIPEinput, 16, 8, dbri->mm.offset); 1427 link_time_slot(dbri, 18, 16, 16, 8, dbri->mm.offset);
1471 link_time_slot(dbri, 19, PIPEinput, 16, 8, dbri->mm.offset + 48); 1428 link_time_slot(dbri, 19, 18, 16, 8, dbri->mm.offset + 48);
1472 1429
1473 /* Wait for the chip to echo back CLB (Control Latch Bit) as zero */ 1430 /* Wait for the chip to echo back CLB (Control Latch Bit) as zero */
1474 dbri->mm.ctrl[0] &= ~CS4215_CLB; 1431 dbri->mm.ctrl[0] &= ~CS4215_CLB;
@@ -2445,11 +2402,11 @@ static void dbri_debug_read(struct snd_info_entry * entry,
2445 struct dbri_pipe *pptr = &dbri->pipes[pipe]; 2402 struct dbri_pipe *pptr = &dbri->pipes[pipe];
2446 snd_iprintf(buffer, 2403 snd_iprintf(buffer,
2447 "Pipe %d: %s SDP=0x%x desc=%d, " 2404 "Pipe %d: %s SDP=0x%x desc=%d, "
2448 "len=%d @ %d next %d\n", 2405 "len=%d next %d\n",
2449 pipe, 2406 pipe,
2450 ((pptr->sdp & D_SDP_TO_SER) ? "output" : "input"), 2407 ((pptr->sdp & D_SDP_TO_SER) ? "output" : "input"),
2451 pptr->sdp, pptr->desc, 2408 pptr->sdp, pptr->desc,
2452 pptr->length, pptr->cycle, pptr->nextpipe); 2409 pptr->length, pptr->nextpipe);
2453 } 2410 }
2454 } 2411 }
2455} 2412}