aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/cs5535audio
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-11-17 04:15:37 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:16:29 -0500
commit3e8731740e17f01ec1ecce556ccdc4c42279ce1b (patch)
treedada863f577ad8c00b152a9538a4cde36aa240d6 /sound/pci/cs5535audio
parent9b4ffa48ae855c8657a36014c5b0243ff69f4722 (diff)
[ALSA] Minor clean up and fixes for CS5535 audio driver
Modules: Documentation,CS5535 driver Minor clean up and fixes for CS5535 audio driver. Added an entry in ALSA-Configuration.txt, too. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/cs5535audio')
-rw-r--r--sound/pci/cs5535audio/cs5535audio.c34
-rw-r--r--sound/pci/cs5535audio/cs5535audio.h10
-rw-r--r--sound/pci/cs5535audio/cs5535audio_pcm.c57
3 files changed, 41 insertions, 60 deletions
diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c
index 920c857fc223..3f4379da4d26 100644
--- a/sound/pci/cs5535audio/cs5535audio.c
+++ b/sound/pci/cs5535audio/cs5535audio.c
@@ -55,7 +55,7 @@ MODULE_DEVICE_TABLE(pci, snd_cs5535audio_ids);
55 55
56static void wait_till_cmd_acked(cs5535audio_t *cs5535au, unsigned long timeout) 56static void wait_till_cmd_acked(cs5535audio_t *cs5535au, unsigned long timeout)
57{ 57{
58 unsigned long tmp; 58 unsigned int tmp;
59 do { 59 do {
60 tmp = cs_readl(cs5535au, ACC_CODEC_CNTL); 60 tmp = cs_readl(cs5535au, ACC_CODEC_CNTL);
61 if (!(tmp & CMD_NEW)) 61 if (!(tmp & CMD_NEW))
@@ -69,11 +69,11 @@ static void wait_till_cmd_acked(cs5535audio_t *cs5535au, unsigned long timeout)
69static unsigned short snd_cs5535audio_codec_read(cs5535audio_t *cs5535au, 69static unsigned short snd_cs5535audio_codec_read(cs5535audio_t *cs5535au,
70 unsigned short reg) 70 unsigned short reg)
71{ 71{
72 unsigned long regdata; 72 unsigned int regdata;
73 unsigned long timeout; 73 int timeout;
74 unsigned long val; 74 unsigned int val;
75 75
76 regdata = ((unsigned long) reg) << 24; 76 regdata = ((unsigned int) reg) << 24;
77 regdata |= ACC_CODEC_CNTL_RD_CMD; 77 regdata |= ACC_CODEC_CNTL_RD_CMD;
78 regdata |= CMD_NEW; 78 regdata |= CMD_NEW;
79 79
@@ -83,24 +83,23 @@ static unsigned short snd_cs5535audio_codec_read(cs5535audio_t *cs5535au,
83 timeout = 50; 83 timeout = 50;
84 do { 84 do {
85 val = cs_readl(cs5535au, ACC_CODEC_STATUS); 85 val = cs_readl(cs5535au, ACC_CODEC_STATUS);
86 if ( (val & STS_NEW) && 86 if ((val & STS_NEW) && reg == (val >> 24))
87 ((unsigned long) reg == ((0xFF000000 & val)>>24)) )
88 break; 87 break;
89 msleep(10); 88 msleep(10);
90 } while (--timeout); 89 } while (--timeout);
91 if (!timeout) 90 if (!timeout)
92 snd_printk(KERN_ERR "Failure reading cs5535 codec\n"); 91 snd_printk(KERN_ERR "Failure reading cs5535 codec\n");
93 92
94 return ((unsigned short) val); 93 return (unsigned short) val;
95} 94}
96 95
97static void snd_cs5535audio_codec_write(cs5535audio_t *cs5535au, 96static void snd_cs5535audio_codec_write(cs5535audio_t *cs5535au,
98 unsigned short reg, unsigned short val) 97 unsigned short reg, unsigned short val)
99{ 98{
100 unsigned long regdata; 99 unsigned int regdata;
101 100
102 regdata = ((unsigned long) reg) << 24; 101 regdata = ((unsigned int) reg) << 24;
103 regdata |= (unsigned long) val; 102 regdata |= val;
104 regdata &= CMD_MASK; 103 regdata &= CMD_MASK;
105 regdata |= CMD_NEW; 104 regdata |= CMD_NEW;
106 regdata &= ACC_CODEC_CNTL_WR_CMD; 105 regdata &= ACC_CODEC_CNTL_WR_CMD;
@@ -123,12 +122,6 @@ static unsigned short snd_cs5535audio_ac97_codec_read(ac97_t *ac97,
123 return snd_cs5535audio_codec_read(cs5535au, reg); 122 return snd_cs5535audio_codec_read(cs5535au, reg);
124} 123}
125 124
126static void snd_cs5535audio_mixer_free_ac97(ac97_t *ac97)
127{
128 cs5535audio_t *cs5535audio = ac97->private_data;
129 cs5535audio->ac97 = NULL;
130}
131
132static int snd_cs5535audio_mixer(cs5535audio_t *cs5535au) 125static int snd_cs5535audio_mixer(cs5535audio_t *cs5535au)
133{ 126{
134 snd_card_t *card = cs5535au->card; 127 snd_card_t *card = cs5535au->card;
@@ -147,10 +140,9 @@ static int snd_cs5535audio_mixer(cs5535audio_t *cs5535au)
147 ac97.scaps = AC97_SCAP_AUDIO|AC97_SCAP_SKIP_MODEM; 140 ac97.scaps = AC97_SCAP_AUDIO|AC97_SCAP_SKIP_MODEM;
148 ac97.private_data = cs5535au; 141 ac97.private_data = cs5535au;
149 ac97.pci = cs5535au->pci; 142 ac97.pci = cs5535au->pci;
150 ac97.private_free = snd_cs5535audio_mixer_free_ac97;
151 143
152 if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) { 144 if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) {
153 snd_printk("mixer failed\n"); 145 snd_printk(KERN_ERR "mixer failed\n");
154 return err; 146 return err;
155 } 147 }
156 148
@@ -201,8 +193,8 @@ static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id,
201 193
202 if (!acc_irq_stat) 194 if (!acc_irq_stat)
203 return IRQ_NONE; 195 return IRQ_NONE;
204 for (count=0; count < 10; count++) { 196 for (count = 0; count < 10; count++) {
205 if (acc_irq_stat & (1<<count)) { 197 if (acc_irq_stat & (1 << count)) {
206 switch (count) { 198 switch (count) {
207 case IRQ_STS: 199 case IRQ_STS:
208 cs_readl(cs5535au, ACC_GPIO_STATUS); 200 cs_readl(cs5535au, ACC_GPIO_STATUS);
diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h
index e28177fb0991..774185e026d4 100644
--- a/sound/pci/cs5535audio/cs5535audio.h
+++ b/sound/pci/cs5535audio/cs5535audio.h
@@ -1,11 +1,11 @@
1#ifndef __SOUND_CS5535AUDIO_H 1#ifndef __SOUND_CS5535AUDIO_H
2#define __SOUND_CS5535AUDIO_H 2#define __SOUND_CS5535AUDIO_H
3 3
4#define cs_writel(cs5535au, reg, val) outl(val, (int) cs5535au->port + reg) 4#define cs_writel(cs5535au, reg, val) outl(val, (cs5535au)->port + reg)
5#define cs_writeb(cs5535au, reg, val) outb(val, (int) cs5535au->port + reg) 5#define cs_writeb(cs5535au, reg, val) outb(val, (cs5535au)->port + reg)
6#define cs_readl(cs5535au, reg) inl((unsigned short) (cs5535au->port + reg)) 6#define cs_readl(cs5535au, reg) inl((cs5535au)->port + reg)
7#define cs_readw(cs5535au, reg) inw((unsigned short) (cs5535au->port + reg)) 7#define cs_readw(cs5535au, reg) inw((cs5535au)->port + reg)
8#define cs_readb(cs5535au, reg) inb((unsigned short) (cs5535au->port + reg)) 8#define cs_readb(cs5535au, reg) inb((cs5535au)->port + reg)
9 9
10#define CS5535AUDIO_MAX_DESCRIPTORS 128 10#define CS5535AUDIO_MAX_DESCRIPTORS 128
11 11
diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c
index 5802ed9d57be..d32b23f202cd 100644
--- a/sound/pci/cs5535audio/cs5535audio_pcm.c
+++ b/sound/pci/cs5535audio/cs5535audio_pcm.c
@@ -150,8 +150,8 @@ static int cs5535audio_build_dma_packets(cs5535audio_t *cs5535au,
150 cs5535audio_dma_desc_t *desc = 150 cs5535audio_dma_desc_t *desc =
151 &((cs5535audio_dma_desc_t *) dma->desc_buf.area)[i]; 151 &((cs5535audio_dma_desc_t *) dma->desc_buf.area)[i];
152 desc->addr = cpu_to_le32(addr); 152 desc->addr = cpu_to_le32(addr);
153 desc->size = period_bytes; 153 desc->size = cpu_to_le32(period_bytes);
154 desc->ctlreserved = PRD_EOP; 154 desc->ctlreserved = cpu_to_le32(PRD_EOP);
155 desc_addr += sizeof(cs5535audio_dma_desc_t); 155 desc_addr += sizeof(cs5535audio_dma_desc_t);
156 addr += period_bytes; 156 addr += period_bytes;
157 } 157 }
@@ -159,7 +159,7 @@ static int cs5535audio_build_dma_packets(cs5535audio_t *cs5535au,
159 lastdesc = &((cs5535audio_dma_desc_t *) dma->desc_buf.area)[periods]; 159 lastdesc = &((cs5535audio_dma_desc_t *) dma->desc_buf.area)[periods];
160 lastdesc->addr = cpu_to_le32((u32) dma->desc_buf.addr); 160 lastdesc->addr = cpu_to_le32((u32) dma->desc_buf.addr);
161 lastdesc->size = 0; 161 lastdesc->size = 0;
162 lastdesc->ctlreserved = PRD_JMP; 162 lastdesc->ctlreserved = cpu_to_le32(PRD_JMP);
163 jmpprd_addr = cpu_to_le32(lastdesc->addr + 163 jmpprd_addr = cpu_to_le32(lastdesc->addr +
164 (sizeof(cs5535audio_dma_desc_t)*periods)); 164 (sizeof(cs5535audio_dma_desc_t)*periods));
165 165
@@ -272,34 +272,29 @@ static int snd_cs5535audio_trigger(snd_pcm_substream_t *substream, int cmd)
272{ 272{
273 cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); 273 cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream);
274 cs5535audio_dma_t *dma = substream->runtime->private_data; 274 cs5535audio_dma_t *dma = substream->runtime->private_data;
275 int err = 0;
275 276
277 spin_lock(&cs5535au->reg_lock);
276 switch (cmd) { 278 switch (cmd) {
277 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 279 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
278 spin_lock_irq(&cs5535au->reg_lock); 280 dma->ops->pause_dma(cs5535au);
279 dma->ops->pause_dma(cs5535au); 281 break;
280 spin_unlock_irq(&cs5535au->reg_lock); 282 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
281 break; 283 dma->ops->enable_dma(cs5535au);
282 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 284 break;
283 spin_lock_irq(&cs5535au->reg_lock); 285 case SNDRV_PCM_TRIGGER_START:
284 dma->ops->enable_dma(cs5535au); 286 dma->ops->enable_dma(cs5535au);
285 spin_unlock_irq(&cs5535au->reg_lock); 287 break;
286 break; 288 case SNDRV_PCM_TRIGGER_STOP:
287 case SNDRV_PCM_TRIGGER_START: 289 dma->ops->disable_dma(cs5535au);
288 spin_lock_irq(&cs5535au->reg_lock); 290 break;
289 dma->ops->enable_dma(cs5535au); 291 default:
290 spin_unlock_irq(&cs5535au->reg_lock); 292 snd_printk(KERN_ERR "unhandled trigger\n");
291 break; 293 err = -EINVAL;
292 case SNDRV_PCM_TRIGGER_STOP: 294 break;
293 spin_lock_irq(&cs5535au->reg_lock);
294 dma->ops->disable_dma(cs5535au);
295 spin_unlock_irq(&cs5535au->reg_lock);
296 break;
297 default:
298 snd_printk(KERN_ERR "unhandled trigger\n");
299 return -EINVAL;
300 break;
301 } 295 }
302 return 0; 296 spin_unlock(&cs5535au->reg_lock);
297 return err;
303} 298}
304 299
305static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(snd_pcm_substream_t 300static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(snd_pcm_substream_t
@@ -375,11 +370,6 @@ static snd_pcm_ops_t snd_cs5535audio_capture_ops = {
375 .pointer = snd_cs5535audio_pcm_pointer, 370 .pointer = snd_cs5535audio_pcm_pointer,
376}; 371};
377 372
378static void snd_cs5535audio_pcm_free(snd_pcm_t *pcm)
379{
380 snd_pcm_lib_preallocate_free_for_all(pcm);
381}
382
383static cs5535audio_dma_ops_t snd_cs5535audio_playback_dma_ops = { 373static cs5535audio_dma_ops_t snd_cs5535audio_playback_dma_ops = {
384 .type = CS5535AUDIO_DMA_PLAYBACK, 374 .type = CS5535AUDIO_DMA_PLAYBACK,
385 .enable_dma = cs5535audio_playback_enable_dma, 375 .enable_dma = cs5535audio_playback_enable_dma,
@@ -417,7 +407,6 @@ int __devinit snd_cs5535audio_pcm(cs5535audio_t *cs5535au)
417 &snd_cs5535audio_capture_ops); 407 &snd_cs5535audio_capture_ops);
418 408
419 pcm->private_data = cs5535au; 409 pcm->private_data = cs5535au;
420 pcm->private_free = snd_cs5535audio_pcm_free;
421 pcm->info_flags = 0; 410 pcm->info_flags = 0;
422 strcpy(pcm->name, "CS5535 Audio"); 411 strcpy(pcm->name, "CS5535 Audio");
423 412