27 #include <linux/pci.h>
28 #include <linux/slab.h>
29 #include <linux/module.h>
40 #define DRIVER_NAME "cs5535audio"
77 static void wait_till_cmd_acked(
struct cs5535audio *cs5535au,
unsigned long timeout)
90 static unsigned short snd_cs5535audio_codec_read(
struct cs5535audio *cs5535au,
97 regdata = ((
unsigned int) reg) << 24;
102 wait_till_cmd_acked(cs5535au, 50);
107 if ((val &
STS_NEW) && reg == (val >> 24))
113 "Last value=0x%x\n", reg, val);
115 return (
unsigned short)
val;
118 static void snd_cs5535audio_codec_write(
struct cs5535audio *cs5535au,
119 unsigned short reg,
unsigned short val)
121 unsigned int regdata;
123 regdata = ((
unsigned int) reg) << 24;
130 wait_till_cmd_acked(cs5535au, 50);
133 static void snd_cs5535audio_ac97_codec_write(
struct snd_ac97 *ac97,
134 unsigned short reg,
unsigned short val)
137 snd_cs5535audio_codec_write(cs5535au, reg, val);
140 static unsigned short snd_cs5535audio_ac97_codec_read(
struct snd_ac97 *
ac97,
144 return snd_cs5535audio_codec_read(cs5535au, reg);
154 .write = snd_cs5535audio_ac97_codec_write,
155 .read = snd_cs5535audio_ac97_codec_read,
161 memset(&ac97, 0,
sizeof(ac97));
164 ac97.private_data = cs5535au;
186 static void process_bm0_irq(
struct cs5535audio *cs5535au)
202 static void process_bm1_irq(
struct cs5535audio *cs5535au)
221 if (cs5535au ==
NULL)
228 for (count = 0; count < 4; count++) {
229 if (acc_irq_stat & (1 << count)) {
238 process_bm0_irq(cs5535au);
241 process_bm1_irq(cs5535au);
245 "0x%x\n", acc_irq_stat);
253 static int snd_cs5535audio_free(
struct cs5535audio *cs5535au)
258 if (cs5535au->
irq >= 0)
270 return snd_cs5535audio_free(cs5535au);
281 .dev_free = snd_cs5535audio_dev_free,
289 pci_set_consistent_dma_mask(pci,
DMA_BIT_MASK(32)) < 0) {
295 cs5535au = kzalloc(
sizeof(*cs5535au),
GFP_KERNEL);
296 if (cs5535au ==
NULL) {
324 cs5535au, &ops)) < 0)
329 *rcs5535au = cs5535au;
333 snd_cs5535audio_free(cs5535au);
360 if ((err = snd_cs5535audio_create(card, pci, &cs5535au)) < 0)
365 if ((err = snd_cs5535audio_mixer(cs5535au)) < 0)
376 cs5535au->
port, cs5535au->
irq);
381 pci_set_drvdata(pci, card);
394 pci_set_drvdata(pci,
NULL);
397 static struct pci_driver cs5535audio_driver = {
398 .name = KBUILD_MODNAME,
399 .id_table = snd_cs5535audio_ids,
400 .probe = snd_cs5535audio_probe,
402 #ifdef CONFIG_PM_SLEEP