aboutsummaryrefslogtreecommitdiffstats
path: root/sound/sparc
diff options
context:
space:
mode:
authorKrzysztof Helt <krzysztof.h1@wp.pl>2006-08-21 13:28:16 -0400
committerJaroslav Kysela <perex@suse.cz>2006-09-23 04:42:19 -0400
commit470f1f1a1c2597fab98339ab0966dbf602d604f0 (patch)
tree71c4f21207c373cfa1e99df79728f00ddba7a720 /sound/sparc
parentc27354460b1e0cbcd9dfc9232a76bd56c46dce89 (diff)
[ALSA] sparc dbri: more driver cleanup
A general clean up and redudant code removal. 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')
-rw-r--r--sound/sparc/dbri.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c
index 0b8545ad3e9a..6fc37c9cb4fc 100644
--- a/sound/sparc/dbri.c
+++ b/sound/sparc/dbri.c
@@ -241,9 +241,7 @@ static struct {
241#define DBRI_INT_BLK 64 241#define DBRI_INT_BLK 64
242#define DBRI_NO_DESCS 64 242#define DBRI_NO_DESCS 64
243#define DBRI_NO_PIPES 32 243#define DBRI_NO_PIPES 32
244 244#define DBRI_MAX_PIPE (DBRI_NO_PIPES - 1)
245#define DBRI_MM_ONB 1
246#define DBRI_MM_SB 2
247 245
248#define DBRI_REC 0 246#define DBRI_REC 0
249#define DBRI_PLAY 1 247#define DBRI_PLAY 1
@@ -650,10 +648,6 @@ static volatile s32 *dbri_cmdlock(struct snd_dbri * dbri, enum dbri_lock get)
650 /* Delay if previous commands are still being processed */ 648 /* Delay if previous commands are still being processed */
651 while ((--maxloops) > 0 && (dbri->wait_send != dbri->wait_ackd)) { 649 while ((--maxloops) > 0 && (dbri->wait_send != dbri->wait_ackd)) {
652 msleep_interruptible(1); 650 msleep_interruptible(1);
653 /* If dbri_cmdlock() got called from inside the
654 * interrupt handler, this will do the processing.
655 */
656 dbri_process_interrupt_buffer(dbri);
657 } 651 }
658 if (maxloops == 0) { 652 if (maxloops == 0) {
659 printk(KERN_ERR "DBRI: Chip never completed command buffer %d\n", 653 printk(KERN_ERR "DBRI: Chip never completed command buffer %d\n",
@@ -780,7 +774,7 @@ static void reset_pipe(struct snd_dbri * dbri, int pipe)
780 int desc; 774 int desc;
781 volatile int *cmd; 775 volatile int *cmd;
782 776
783 if (pipe < 0 || pipe > 31) { 777 if (pipe < 0 || pipe > DBRI_MAX_PIPE) {
784 printk(KERN_ERR "DBRI: reset_pipe called with illegal pipe number\n"); 778 printk(KERN_ERR "DBRI: reset_pipe called with illegal pipe number\n");
785 return; 779 return;
786 } 780 }
@@ -806,10 +800,9 @@ static void reset_pipe(struct snd_dbri * dbri, int pipe)
806 dbri->pipes[pipe].first_desc = -1; 800 dbri->pipes[pipe].first_desc = -1;
807} 801}
808 802
809/* FIXME: direction as an argument? */
810static void setup_pipe(struct snd_dbri * dbri, int pipe, int sdp) 803static void setup_pipe(struct snd_dbri * dbri, int pipe, int sdp)
811{ 804{
812 if (pipe < 0 || pipe > 31) { 805 if (pipe < 0 || pipe > DBRI_MAX_PIPE) {
813 printk(KERN_ERR "DBRI: setup_pipe called with illegal pipe number\n"); 806 printk(KERN_ERR "DBRI: setup_pipe called with illegal pipe number\n");
814 return; 807 return;
815 } 808 }
@@ -843,7 +836,7 @@ static void link_time_slot(struct snd_dbri * dbri, int pipe,
843 int prevpipe; 836 int prevpipe;
844 int nextpipe; 837 int nextpipe;
845 838
846 if (pipe < 0 || pipe > 31 || basepipe < 0 || basepipe > 31) { 839 if (pipe < 0 || pipe > DBRI_MAX_PIPE || basepipe < 0 || basepipe > DBRI_MAX_PIPE) {
847 printk(KERN_ERR 840 printk(KERN_ERR
848 "DBRI: link_time_slot called with illegal pipe number\n"); 841 "DBRI: link_time_slot called with illegal pipe number\n");
849 return; 842 return;
@@ -931,7 +924,8 @@ static void unlink_time_slot(struct snd_dbri * dbri, int pipe,
931 volatile s32 *cmd; 924 volatile s32 *cmd;
932 int val; 925 int val;
933 926
934 if (pipe < 0 || pipe > 31 || prevpipe < 0 || prevpipe > 31) { 927 if (pipe < 0 || pipe > DBRI_MAX_PIPE
928 || prevpipe < 0 || prevpipe > DBRI_MAX_PIPE) {
935 printk(KERN_ERR 929 printk(KERN_ERR
936 "DBRI: unlink_time_slot called with illegal pipe number\n"); 930 "DBRI: unlink_time_slot called with illegal pipe number\n");
937 return; 931 return;
@@ -972,7 +966,7 @@ static void xmit_fixed(struct snd_dbri * dbri, int pipe, unsigned int data)
972{ 966{
973 volatile s32 *cmd; 967 volatile s32 *cmd;
974 968
975 if (pipe < 16 || pipe > 31) { 969 if (pipe < 16 || pipe > DBRI_MAX_PIPE) {
976 printk(KERN_ERR "DBRI: xmit_fixed: Illegal pipe number\n"); 970 printk(KERN_ERR "DBRI: xmit_fixed: Illegal pipe number\n");
977 return; 971 return;
978 } 972 }
@@ -1007,7 +1001,7 @@ static void xmit_fixed(struct snd_dbri * dbri, int pipe, unsigned int data)
1007 1001
1008static void recv_fixed(struct snd_dbri * dbri, int pipe, volatile __u32 * ptr) 1002static void recv_fixed(struct snd_dbri * dbri, int pipe, volatile __u32 * ptr)
1009{ 1003{
1010 if (pipe < 16 || pipe > 31) { 1004 if (pipe < 16 || pipe > DBRI_MAX_PIPE) {
1011 printk(KERN_ERR "DBRI: recv_fixed called with illegal pipe number\n"); 1005 printk(KERN_ERR "DBRI: recv_fixed called with illegal pipe number\n");
1012 return; 1006 return;
1013 } 1007 }
@@ -1182,20 +1176,14 @@ static void reset_chi(struct snd_dbri * dbri, enum master_or_slave master_or_sla
1182 1176
1183 /* Set CHI Anchor: Pipe 16 */ 1177 /* Set CHI Anchor: Pipe 16 */
1184 1178
1185 val = D_DTS_VI | D_DTS_INS | D_DTS_PRVIN(16) | D_PIPE(16); 1179 val = D_DTS_VO | D_DTS_VI | D_DTS_INS
1180 | D_DTS_PRVIN(16) | D_PIPE(16) | D_DTS_PRVOUT(16);
1186 *(cmd++) = DBRI_CMD(D_DTS, 0, val); 1181 *(cmd++) = DBRI_CMD(D_DTS, 0, val);
1187 *(cmd++) = D_TS_ANCHOR | D_TS_NEXT(16); 1182 *(cmd++) = D_TS_ANCHOR | D_TS_NEXT(16);
1188 *(cmd++) = 0;
1189
1190 val = D_DTS_VO | D_DTS_INS | D_DTS_PRVOUT(16) | D_PIPE(16);
1191 *(cmd++) = DBRI_CMD(D_DTS, 0, val);
1192 *(cmd++) = 0;
1193 *(cmd++) = D_TS_ANCHOR | D_TS_NEXT(16); 1183 *(cmd++) = D_TS_ANCHOR | D_TS_NEXT(16);
1194 1184
1195 dbri->pipes[16].sdp = 1; 1185 dbri->pipes[16].sdp = 1;
1196 dbri->pipes[16].nextpipe = 16; 1186 dbri->pipes[16].nextpipe = 16;
1197 dbri->chi_in_pipe = 16;
1198 dbri->chi_out_pipe = 16;
1199 1187
1200#if 0 1188#if 0
1201 chi_initialized++; 1189 chi_initialized++;
@@ -1214,11 +1202,10 @@ static void reset_chi(struct snd_dbri * dbri, enum master_or_slave master_or_sla
1214 16, dbri->pipes[pipe].nextpipe); 1202 16, dbri->pipes[pipe].nextpipe);
1215 } 1203 }
1216 1204
1217 dbri->chi_in_pipe = 16;
1218 dbri->chi_out_pipe = 16;
1219
1220 cmd = dbri_cmdlock(dbri, GetLock); 1205 cmd = dbri_cmdlock(dbri, GetLock);
1221 } 1206 }
1207 dbri->chi_in_pipe = 16;
1208 dbri->chi_out_pipe = 16;
1222 1209
1223 if (master_or_slave == CHIslave) { 1210 if (master_or_slave == CHIslave) {
1224 /* Setup DBRI for CHI Slave - receive clock, frame sync (FS) 1211 /* Setup DBRI for CHI Slave - receive clock, frame sync (FS)
@@ -1341,8 +1328,8 @@ static void cs4215_setdata(struct snd_dbri * dbri, int muted)
1341 } else { 1328 } else {
1342 /* Start by setting the playback attenuation. */ 1329 /* Start by setting the playback attenuation. */
1343 struct dbri_streaminfo *info = &dbri->stream_info[DBRI_PLAY]; 1330 struct dbri_streaminfo *info = &dbri->stream_info[DBRI_PLAY];
1344 int left_gain = info->left_gain % 64; 1331 int left_gain = info->left_gain & 0x3f;
1345 int right_gain = info->right_gain % 64; 1332 int right_gain = info->right_gain & 0x3f;
1346 1333
1347 dbri->mm.data[0] &= ~0x3f; /* Reset the volume bits */ 1334 dbri->mm.data[0] &= ~0x3f; /* Reset the volume bits */
1348 dbri->mm.data[1] &= ~0x3f; 1335 dbri->mm.data[1] &= ~0x3f;
@@ -1351,8 +1338,8 @@ static void cs4215_setdata(struct snd_dbri * dbri, int muted)
1351 1338
1352 /* Now set the recording gain. */ 1339 /* Now set the recording gain. */
1353 info = &dbri->stream_info[DBRI_REC]; 1340 info = &dbri->stream_info[DBRI_REC];
1354 left_gain = info->left_gain % 16; 1341 left_gain = info->left_gain & 0xf;
1355 right_gain = info->right_gain % 16; 1342 right_gain = info->right_gain & 0xf;
1356 dbri->mm.data[2] |= CS4215_LG(left_gain); 1343 dbri->mm.data[2] |= CS4215_LG(left_gain);
1357 dbri->mm.data[3] |= CS4215_RG(right_gain); 1344 dbri->mm.data[3] |= CS4215_RG(right_gain);
1358 } 1345 }