2 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
3 * Routines for control of AD1848/AD1847/CS4248
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #define SNDRV_MAIN_OBJECT_FILE
23 #include <sound/driver.h>
24 #include <linux/delay.h>
25 #include <linux/init.h>
26 #include <linux/interrupt.h>
27 #include <linux/slab.h>
28 #include <linux/ioport.h>
29 #include <sound/core.h>
30 #include <sound/ad1848.h>
31 #include <sound/pcm_params.h>
36 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
37 MODULE_DESCRIPTION("Routines for control of AD1848/AD1847/CS4248");
38 MODULE_LICENSE("GPL");
40 #define chip_t ad1848_t
43 #define SNDRV_DEBUG_MCE
50 static unsigned char freq_bits
[14] = {
51 /* 5510 */ 0x00 | AD1848_XTAL2
,
52 /* 6620 */ 0x0E | AD1848_XTAL2
,
53 /* 8000 */ 0x00 | AD1848_XTAL1
,
54 /* 9600 */ 0x0E | AD1848_XTAL1
,
55 /* 11025 */ 0x02 | AD1848_XTAL2
,
56 /* 16000 */ 0x02 | AD1848_XTAL1
,
57 /* 18900 */ 0x04 | AD1848_XTAL2
,
58 /* 22050 */ 0x06 | AD1848_XTAL2
,
59 /* 27042 */ 0x04 | AD1848_XTAL1
,
60 /* 32000 */ 0x06 | AD1848_XTAL1
,
61 /* 33075 */ 0x0C | AD1848_XTAL2
,
62 /* 37800 */ 0x08 | AD1848_XTAL2
,
63 /* 44100 */ 0x0A | AD1848_XTAL2
,
64 /* 48000 */ 0x0C | AD1848_XTAL1
67 static unsigned int rates
[14] = {
68 5510, 6620, 8000, 9600, 11025, 16000, 18900, 22050,
69 27042, 32000, 33075, 37800, 44100, 48000
72 static snd_pcm_hw_constraint_list_t hw_constraints_rates
= {
78 static unsigned char snd_ad1848_original_image
[16] =
82 0x9f, /* 02 - la1ic */
83 0x9f, /* 03 - ra1ic */
84 0x9f, /* 04 - la2ic */
85 0x9f, /* 05 - ra2ic */
89 AD1848_AUTOCALIB
, /* 09 - ic */
102 void snd_ad1848_out(ad1848_t
*chip
,
108 for (timeout
= 250; timeout
> 0 && (inb(AD1848P(chip
, REGSEL
)) & AD1848_INIT
); timeout
--)
110 #ifdef CONFIG_SND_DEBUG
111 if (inb(AD1848P(chip
, REGSEL
)) & AD1848_INIT
)
112 snd_printk("auto calibration time out - reg = 0x%x, value = 0x%x\n", reg
, value
);
114 outb(chip
->mce_bit
| reg
, AD1848P(chip
, REGSEL
));
115 outb(chip
->image
[reg
] = value
, AD1848P(chip
, REG
));
118 printk("codec out - reg 0x%x = 0x%x\n", chip
->mce_bit
| reg
, value
);
122 void snd_ad1848_dout(ad1848_t
*chip
,
128 for (timeout
= 250; timeout
> 0 && (inb(AD1848P(chip
, REGSEL
)) & AD1848_INIT
); timeout
--)
130 outb(chip
->mce_bit
| reg
, AD1848P(chip
, REGSEL
));
131 outb(value
, AD1848P(chip
, REG
));
135 unsigned char snd_ad1848_in(ad1848_t
*chip
, unsigned char reg
)
139 for (timeout
= 250; timeout
> 0 && (inb(AD1848P(chip
, REGSEL
)) & AD1848_INIT
); timeout
--)
141 #ifdef CONFIG_SND_DEBUG
142 if (inb(AD1848P(chip
, REGSEL
)) & AD1848_INIT
)
143 snd_printk("auto calibration time out - reg = 0x%x\n", reg
);
145 outb(chip
->mce_bit
| reg
, AD1848P(chip
, REGSEL
));
147 return inb(AD1848P(chip
, REG
));
150 #ifdef CONFIG_SND_DEBUG
152 void snd_ad1848_debug(ad1848_t
*chip
)
154 printk("AD1848 REGS: INDEX = 0x%02x ", inb(AD1848P(chip
, REGSEL
)));
155 printk(" STATUS = 0x%02x\n", inb(AD1848P(chip
, STATUS
)));
156 printk(" 0x00: left input = 0x%02x ", snd_ad1848_in(chip
, 0x00));
157 printk(" 0x08: playback format = 0x%02x\n", snd_ad1848_in(chip
, 0x08));
158 printk(" 0x01: right input = 0x%02x ", snd_ad1848_in(chip
, 0x01));
159 printk(" 0x09: iface (CFIG 1) = 0x%02x\n", snd_ad1848_in(chip
, 0x09));
160 printk(" 0x02: AUXA left = 0x%02x ", snd_ad1848_in(chip
, 0x02));
161 printk(" 0x0a: pin control = 0x%02x\n", snd_ad1848_in(chip
, 0x0a));
162 printk(" 0x03: AUXA right = 0x%02x ", snd_ad1848_in(chip
, 0x03));
163 printk(" 0x0b: init & status = 0x%02x\n", snd_ad1848_in(chip
, 0x0b));
164 printk(" 0x04: AUXB left = 0x%02x ", snd_ad1848_in(chip
, 0x04));
165 printk(" 0x0c: revision & mode = 0x%02x\n", snd_ad1848_in(chip
, 0x0c));
166 printk(" 0x05: AUXB right = 0x%02x ", snd_ad1848_in(chip
, 0x05));
167 printk(" 0x0d: loopback = 0x%02x\n", snd_ad1848_in(chip
, 0x0d));
168 printk(" 0x06: left output = 0x%02x ", snd_ad1848_in(chip
, 0x06));
169 printk(" 0x0e: data upr count = 0x%02x\n", snd_ad1848_in(chip
, 0x0e));
170 printk(" 0x07: right output = 0x%02x ", snd_ad1848_in(chip
, 0x07));
171 printk(" 0x0f: data lwr count = 0x%02x\n", snd_ad1848_in(chip
, 0x0f));
177 * AD1848 detection / MCE routines
180 void snd_ad1848_mce_up(ad1848_t
*chip
)
185 for (timeout
= 250; timeout
> 0 && (inb(AD1848P(chip
, REGSEL
)) & AD1848_INIT
); timeout
--)
187 #ifdef CONFIG_SND_DEBUG
188 if (inb(AD1848P(chip
, REGSEL
)) & AD1848_INIT
)
189 snd_printk("mce_up - auto calibration time out (0)\n");
191 spin_lock_irqsave(&chip
->reg_lock
, flags
);
192 chip
->mce_bit
|= AD1848_MCE
;
193 timeout
= inb(AD1848P(chip
, REGSEL
));
195 snd_printk("mce_up [0x%lx]: serious init problem - codec still busy\n", chip
->port
);
196 if (!(timeout
& AD1848_MCE
))
197 outb(chip
->mce_bit
| (timeout
& 0x1f), AD1848P(chip
, REGSEL
));
198 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
201 void snd_ad1848_mce_down(ad1848_t
*chip
)
207 spin_lock_irqsave(&chip
->reg_lock
, flags
);
208 for (timeout
= 5; timeout
> 0; timeout
--)
209 inb(AD1848P(chip
, REGSEL
));
210 /* end of cleanup sequence */
211 for (timeout
= 12000; timeout
> 0 && (inb(AD1848P(chip
, REGSEL
)) & AD1848_INIT
); timeout
--)
214 printk("(1) timeout = %i\n", timeout
);
216 #ifdef CONFIG_SND_DEBUG
217 if (inb(AD1848P(chip
, REGSEL
)) & AD1848_INIT
)
218 snd_printk("mce_down [0x%lx] - auto calibration time out (0)\n", AD1848P(chip
, REGSEL
));
220 chip
->mce_bit
&= ~AD1848_MCE
;
221 timeout
= inb(AD1848P(chip
, REGSEL
));
222 outb(chip
->mce_bit
| (timeout
& 0x1f), AD1848P(chip
, REGSEL
));
224 snd_printk("mce_down [0x%lx]: serious init problem - codec still busy\n", chip
->port
);
225 if ((timeout
& AD1848_MCE
) == 0) {
226 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
229 /* calibration process */
231 for (timeout
= 500; timeout
> 0 && (snd_ad1848_in(chip
, AD1848_TEST_INIT
) & AD1848_CALIB_IN_PROGRESS
) == 0; timeout
--);
232 if ((snd_ad1848_in(chip
, AD1848_TEST_INIT
) & AD1848_CALIB_IN_PROGRESS
) == 0) {
233 snd_printd("mce_down - auto calibration time out (1)\n");
234 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
238 printk("(2) timeout = %i, jiffies = %li\n", timeout
, jiffies
);
241 while (snd_ad1848_in(chip
, AD1848_TEST_INIT
) & AD1848_CALIB_IN_PROGRESS
) {
242 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
244 snd_printk("mce_down - auto calibration time out (2)\n");
247 set_current_state(TASK_INTERRUPTIBLE
);
248 time
= schedule_timeout(time
);
249 spin_lock_irqsave(&chip
->reg_lock
, flags
);
252 printk("(3) jiffies = %li\n", jiffies
);
255 while (inb(AD1848P(chip
, REGSEL
)) & AD1848_INIT
) {
256 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
258 snd_printk("mce_down - auto calibration time out (3)\n");
261 set_current_state(TASK_INTERRUPTIBLE
);
262 time
= schedule_timeout(time
);
263 spin_lock_irqsave(&chip
->reg_lock
, flags
);
265 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
267 printk("(4) jiffies = %li\n", jiffies
);
268 snd_printk("mce_down - exit = 0x%x\n", inb(AD1848P(chip
, REGSEL
)));
272 static unsigned int snd_ad1848_get_count(unsigned char format
,
275 switch (format
& 0xe0) {
276 case AD1848_LINEAR_16
:
280 if (format
& AD1848_STEREO
)
285 static int snd_ad1848_trigger(ad1848_t
*chip
, unsigned char what
,
286 int channel
, int cmd
)
291 printk("codec trigger!!! - what = %i, enable = %i, status = 0x%x\n", what
, enable
, inb(AD1848P(card
, STATUS
)));
293 spin_lock(&chip
->reg_lock
);
294 if (cmd
== SNDRV_PCM_TRIGGER_START
) {
295 if (chip
->image
[AD1848_IFACE_CTRL
] & what
) {
296 spin_unlock(&chip
->reg_lock
);
299 snd_ad1848_out(chip
, AD1848_IFACE_CTRL
, chip
->image
[AD1848_IFACE_CTRL
] |= what
);
300 chip
->mode
|= AD1848_MODE_RUNNING
;
301 } else if (cmd
== SNDRV_PCM_TRIGGER_STOP
) {
302 if (!(chip
->image
[AD1848_IFACE_CTRL
] & what
)) {
303 spin_unlock(&chip
->reg_lock
);
306 snd_ad1848_out(chip
, AD1848_IFACE_CTRL
, chip
->image
[AD1848_IFACE_CTRL
] &= ~what
);
307 chip
->mode
&= ~AD1848_MODE_RUNNING
;
311 spin_unlock(&chip
->reg_lock
);
319 static unsigned char snd_ad1848_get_rate(unsigned int rate
)
323 for (i
= 0; i
< 14; i
++)
324 if (rate
== rates
[i
])
327 return freq_bits
[13];
330 static int snd_ad1848_ioctl(snd_pcm_substream_t
* substream
,
331 unsigned int cmd
, void *arg
)
333 return snd_pcm_lib_ioctl(substream
, cmd
, arg
);
336 static unsigned char snd_ad1848_get_format(int format
, int channels
)
338 unsigned char rformat
;
340 rformat
= AD1848_LINEAR_8
;
342 case SNDRV_PCM_FORMAT_A_LAW
: rformat
= AD1848_ALAW_8
; break;
343 case SNDRV_PCM_FORMAT_MU_LAW
: rformat
= AD1848_ULAW_8
; break;
344 case SNDRV_PCM_FORMAT_S16_LE
: rformat
= AD1848_LINEAR_16
; break;
347 rformat
|= AD1848_STEREO
;
349 snd_printk("get_format: 0x%x (mode=0x%x)\n", format
, mode
);
354 static void snd_ad1848_calibrate_mute(ad1848_t
*chip
, int mute
)
359 spin_lock_irqsave(&chip
->reg_lock
, flags
);
360 if (chip
->calibrate_mute
== mute
) {
361 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
365 snd_ad1848_dout(chip
, AD1848_LEFT_INPUT
, chip
->image
[AD1848_LEFT_INPUT
]);
366 snd_ad1848_dout(chip
, AD1848_RIGHT_INPUT
, chip
->image
[AD1848_RIGHT_INPUT
]);
368 snd_ad1848_dout(chip
, AD1848_AUX1_LEFT_INPUT
, mute
? 0x80 : chip
->image
[AD1848_AUX1_LEFT_INPUT
]);
369 snd_ad1848_dout(chip
, AD1848_AUX1_RIGHT_INPUT
, mute
? 0x80 : chip
->image
[AD1848_AUX1_RIGHT_INPUT
]);
370 snd_ad1848_dout(chip
, AD1848_AUX2_LEFT_INPUT
, mute
? 0x80 : chip
->image
[AD1848_AUX2_LEFT_INPUT
]);
371 snd_ad1848_dout(chip
, AD1848_AUX2_RIGHT_INPUT
, mute
? 0x80 : chip
->image
[AD1848_AUX2_RIGHT_INPUT
]);
372 snd_ad1848_dout(chip
, AD1848_LEFT_OUTPUT
, mute
? 0x80 : chip
->image
[AD1848_LEFT_OUTPUT
]);
373 snd_ad1848_dout(chip
, AD1848_RIGHT_OUTPUT
, mute
? 0x80 : chip
->image
[AD1848_RIGHT_OUTPUT
]);
374 chip
->calibrate_mute
= mute
;
375 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
378 static void snd_ad1848_set_data_format(ad1848_t
*chip
, snd_pcm_hw_params_t
*hw_params
)
380 if (hw_params
== NULL
) {
381 chip
->image
[AD1848_DATA_FORMAT
] = 0x20;
383 chip
->image
[AD1848_DATA_FORMAT
] =
384 snd_ad1848_get_format(params_format(hw_params
), params_channels(hw_params
)) |
385 snd_ad1848_get_rate(params_rate(hw_params
));
387 // snd_printk(">>> pmode = 0x%x, dfr = 0x%x\n", pstr->mode, chip->image[AD1848_DATA_FORMAT]);
390 static int snd_ad1848_open(ad1848_t
*chip
, unsigned int mode
)
394 down(&chip
->open_mutex
);
395 if (chip
->mode
& AD1848_MODE_OPEN
) {
396 up(&chip
->open_mutex
);
399 snd_ad1848_mce_down(chip
);
401 #ifdef SNDRV_DEBUG_MCE
402 snd_printk("open: (1)\n");
404 snd_ad1848_mce_up(chip
);
405 spin_lock_irqsave(&chip
->reg_lock
, flags
);
406 chip
->image
[AD1848_IFACE_CTRL
] &= ~(AD1848_PLAYBACK_ENABLE
| AD1848_PLAYBACK_PIO
|
407 AD1848_CAPTURE_ENABLE
| AD1848_CAPTURE_PIO
|
409 chip
->image
[AD1848_IFACE_CTRL
] |= AD1848_AUTOCALIB
;
410 snd_ad1848_out(chip
, AD1848_IFACE_CTRL
, chip
->image
[AD1848_IFACE_CTRL
]);
411 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
412 snd_ad1848_mce_down(chip
);
414 #ifdef SNDRV_DEBUG_MCE
415 snd_printk("open: (2)\n");
418 snd_ad1848_set_data_format(chip
, NULL
);
420 snd_ad1848_mce_up(chip
);
421 spin_lock_irqsave(&chip
->reg_lock
, flags
);
422 snd_ad1848_out(chip
, AD1848_DATA_FORMAT
, chip
->image
[AD1848_DATA_FORMAT
]);
423 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
424 snd_ad1848_mce_down(chip
);
426 #ifdef SNDRV_DEBUG_MCE
427 snd_printk("open: (3)\n");
430 /* ok. now enable and ack CODEC IRQ */
431 spin_lock_irqsave(&chip
->reg_lock
, flags
);
432 outb(0, AD1848P(chip
, STATUS
)); /* clear IRQ */
433 outb(0, AD1848P(chip
, STATUS
)); /* clear IRQ */
434 chip
->image
[AD1848_PIN_CTRL
] |= AD1848_IRQ_ENABLE
;
435 snd_ad1848_out(chip
, AD1848_PIN_CTRL
, chip
->image
[AD1848_PIN_CTRL
]);
436 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
439 up(&chip
->open_mutex
);
444 static void snd_ad1848_close(ad1848_t
*chip
)
448 down(&chip
->open_mutex
);
450 up(&chip
->open_mutex
);
454 spin_lock_irqsave(&chip
->reg_lock
, flags
);
455 outb(0, AD1848P(chip
, STATUS
)); /* clear IRQ */
456 outb(0, AD1848P(chip
, STATUS
)); /* clear IRQ */
457 chip
->image
[AD1848_PIN_CTRL
] &= ~AD1848_IRQ_ENABLE
;
458 snd_ad1848_out(chip
, AD1848_PIN_CTRL
, chip
->image
[AD1848_PIN_CTRL
]);
459 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
461 /* now disable capture & playback */
463 snd_ad1848_mce_up(chip
);
464 spin_lock_irqsave(&chip
->reg_lock
, flags
);
465 chip
->image
[AD1848_IFACE_CTRL
] &= ~(AD1848_PLAYBACK_ENABLE
| AD1848_PLAYBACK_PIO
|
466 AD1848_CAPTURE_ENABLE
| AD1848_CAPTURE_PIO
);
467 snd_ad1848_out(chip
, AD1848_IFACE_CTRL
, chip
->image
[AD1848_IFACE_CTRL
]);
468 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
469 snd_ad1848_mce_down(chip
);
471 /* clear IRQ again */
472 spin_lock_irqsave(&chip
->reg_lock
, flags
);
473 outb(0, AD1848P(chip
, STATUS
)); /* clear IRQ */
474 outb(0, AD1848P(chip
, STATUS
)); /* clear IRQ */
475 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
478 up(&chip
->open_mutex
);
482 * ok.. exported functions..
485 static int snd_ad1848_playback_trigger(snd_pcm_substream_t
* substream
,
488 ad1848_t
*chip
= snd_pcm_substream_chip(substream
);
489 return snd_ad1848_trigger(chip
, AD1848_PLAYBACK_ENABLE
, SNDRV_PCM_STREAM_PLAYBACK
, cmd
);
492 static int snd_ad1848_capture_trigger(snd_pcm_substream_t
* substream
,
495 ad1848_t
*chip
= snd_pcm_substream_chip(substream
);
496 return snd_ad1848_trigger(chip
, AD1848_CAPTURE_ENABLE
, SNDRV_PCM_STREAM_CAPTURE
, cmd
);
499 static int snd_ad1848_playback_hw_params(snd_pcm_substream_t
* substream
,
500 snd_pcm_hw_params_t
* hw_params
)
502 ad1848_t
*chip
= snd_pcm_substream_chip(substream
);
506 if ((err
= snd_pcm_lib_malloc_pages(substream
, params_buffer_bytes(hw_params
))) < 0)
508 snd_ad1848_calibrate_mute(chip
, 1);
509 snd_ad1848_set_data_format(chip
, hw_params
);
510 snd_ad1848_mce_up(chip
);
511 spin_lock_irqsave(&chip
->reg_lock
, flags
);
512 snd_ad1848_out(chip
, AD1848_DATA_FORMAT
, chip
->image
[AD1848_DATA_FORMAT
]);
513 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
514 snd_ad1848_mce_down(chip
);
515 snd_ad1848_calibrate_mute(chip
, 0);
519 static int snd_ad1848_playback_hw_free(snd_pcm_substream_t
* substream
)
521 return snd_pcm_lib_free_pages(substream
);
524 static int snd_ad1848_playback_prepare(snd_pcm_substream_t
* substream
)
526 ad1848_t
*chip
= snd_pcm_substream_chip(substream
);
527 snd_pcm_runtime_t
*runtime
= substream
->runtime
;
529 unsigned int size
= snd_pcm_lib_buffer_bytes(substream
);
530 unsigned int count
= snd_pcm_lib_period_bytes(substream
);
532 chip
->dma_size
= size
;
533 chip
->image
[AD1848_IFACE_CTRL
] &= ~(AD1848_PLAYBACK_ENABLE
| AD1848_PLAYBACK_PIO
);
534 snd_dma_program(chip
->dma
, runtime
->dma_addr
, size
, DMA_MODE_WRITE
| DMA_AUTOINIT
);
535 count
= snd_ad1848_get_count(chip
->image
[AD1848_DATA_FORMAT
], count
) - 1;
536 spin_lock_irqsave(&chip
->reg_lock
, flags
);
537 snd_ad1848_out(chip
, AD1848_DATA_LWR_CNT
, (unsigned char) count
);
538 snd_ad1848_out(chip
, AD1848_DATA_UPR_CNT
, (unsigned char) (count
>> 8));
539 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
543 static int snd_ad1848_capture_hw_params(snd_pcm_substream_t
* substream
,
544 snd_pcm_hw_params_t
* hw_params
)
546 ad1848_t
*chip
= snd_pcm_substream_chip(substream
);
550 if ((err
= snd_pcm_lib_malloc_pages(substream
, params_buffer_bytes(hw_params
))) < 0)
552 snd_ad1848_calibrate_mute(chip
, 1);
553 snd_ad1848_set_data_format(chip
, hw_params
);
554 snd_ad1848_mce_up(chip
);
555 spin_lock_irqsave(&chip
->reg_lock
, flags
);
556 snd_ad1848_out(chip
, AD1848_DATA_FORMAT
, chip
->image
[AD1848_DATA_FORMAT
]);
557 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
558 snd_ad1848_mce_down(chip
);
559 snd_ad1848_calibrate_mute(chip
, 0);
563 static int snd_ad1848_capture_hw_free(snd_pcm_substream_t
* substream
)
565 return snd_pcm_lib_free_pages(substream
);
568 static int snd_ad1848_capture_prepare(snd_pcm_substream_t
* substream
)
570 ad1848_t
*chip
= snd_pcm_substream_chip(substream
);
571 snd_pcm_runtime_t
*runtime
= substream
->runtime
;
573 unsigned int size
= snd_pcm_lib_buffer_bytes(substream
);
574 unsigned int count
= snd_pcm_lib_period_bytes(substream
);
576 chip
->dma_size
= size
;
577 chip
->image
[AD1848_IFACE_CTRL
] &= ~(AD1848_CAPTURE_ENABLE
| AD1848_CAPTURE_PIO
);
578 snd_dma_program(chip
->dma
, runtime
->dma_addr
, size
, DMA_MODE_READ
| DMA_AUTOINIT
);
579 count
= snd_ad1848_get_count(chip
->image
[AD1848_DATA_FORMAT
], count
) - 1;
580 spin_lock_irqsave(&chip
->reg_lock
, flags
);
581 snd_ad1848_out(chip
, AD1848_DATA_LWR_CNT
, (unsigned char) count
);
582 snd_ad1848_out(chip
, AD1848_DATA_UPR_CNT
, (unsigned char) (count
>> 8));
583 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
587 void snd_ad1848_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
)
589 ad1848_t
*chip
= snd_magic_cast(ad1848_t
, dev_id
, return);
591 if ((chip
->mode
& AD1848_MODE_PLAY
) && chip
->playback_substream
&&
592 (chip
->mode
& AD1848_MODE_RUNNING
))
593 snd_pcm_period_elapsed(chip
->playback_substream
);
594 if ((chip
->mode
& AD1848_MODE_CAPTURE
) && chip
->capture_substream
&&
595 (chip
->mode
& AD1848_MODE_RUNNING
))
596 snd_pcm_period_elapsed(chip
->capture_substream
);
597 outb(0, AD1848P(chip
, STATUS
)); /* clear global interrupt bit */
600 static snd_pcm_uframes_t
snd_ad1848_playback_pointer(snd_pcm_substream_t
* substream
)
602 ad1848_t
*chip
= snd_pcm_substream_chip(substream
);
605 if (!(chip
->image
[AD1848_IFACE_CTRL
] & AD1848_PLAYBACK_ENABLE
))
607 ptr
= chip
->dma_size
- snd_dma_residue(chip
->dma
);
608 return bytes_to_frames(substream
->runtime
, ptr
);
611 static snd_pcm_uframes_t
snd_ad1848_capture_pointer(snd_pcm_substream_t
* substream
)
613 ad1848_t
*chip
= snd_pcm_substream_chip(substream
);
616 if (!(chip
->image
[AD1848_IFACE_CTRL
] & AD1848_CAPTURE_ENABLE
))
618 ptr
= chip
->dma_size
- snd_dma_residue(chip
->dma
);
619 return bytes_to_frames(substream
->runtime
, ptr
);
626 static int snd_ad1848_probe(ad1848_t
* chip
)
629 int i
, id
, rev
, ad1847
;
633 snd_ad1848_debug(chip
);
636 for (i
= 0; i
< 1000; i
++) {
638 if (inb(AD1848P(chip
, REGSEL
)) & AD1848_INIT
)
641 spin_lock_irqsave(&chip
->reg_lock
, flags
);
642 snd_ad1848_out(chip
, AD1848_MISC_INFO
, 0x00);
643 snd_ad1848_out(chip
, AD1848_LEFT_INPUT
, 0xaa);
644 snd_ad1848_out(chip
, AD1848_RIGHT_INPUT
, 0x45);
645 rev
= snd_ad1848_in(chip
, AD1848_RIGHT_INPUT
);
651 if (snd_ad1848_in(chip
, AD1848_LEFT_INPUT
) == 0xaa && rev
== 0x45) {
655 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
659 return -ENODEV
; /* no valid device found */
660 if (chip
->hardware
== AD1848_HW_DETECT
) {
662 chip
->hardware
= AD1848_HW_AD1847
;
664 chip
->hardware
= AD1848_HW_AD1848
;
665 rev
= snd_ad1848_in(chip
, AD1848_MISC_INFO
);
667 chip
->hardware
= AD1848_HW_CS4248
;
668 } else if ((rev
& 0x0f) == 0x0a) {
669 snd_ad1848_out(chip
, AD1848_MISC_INFO
, 0x40);
670 for (i
= 0; i
< 16; ++i
) {
671 if (snd_ad1848_in(chip
, i
) != snd_ad1848_in(chip
, i
+ 16)) {
672 chip
->hardware
= AD1848_HW_CMI8330
;
676 snd_ad1848_out(chip
, AD1848_MISC_INFO
, 0x00);
680 spin_lock_irqsave(&chip
->reg_lock
, flags
);
681 inb(AD1848P(chip
, STATUS
)); /* clear any pendings IRQ */
682 outb(0, AD1848P(chip
, STATUS
));
684 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
686 chip
->image
[AD1848_MISC_INFO
] = 0x00;
687 chip
->image
[AD1848_IFACE_CTRL
] =
688 (chip
->image
[AD1848_IFACE_CTRL
] & ~AD1848_SINGLE_DMA
) | AD1848_SINGLE_DMA
;
689 ptr
= (unsigned char *) &chip
->image
;
690 snd_ad1848_mce_down(chip
);
691 spin_lock_irqsave(&chip
->reg_lock
, flags
);
692 for (i
= 0; i
< 16; i
++) /* ok.. fill all AD1848 registers */
693 snd_ad1848_out(chip
, i
, *ptr
++);
694 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
695 snd_ad1848_mce_up(chip
);
696 snd_ad1848_mce_down(chip
);
697 return 0; /* all things are ok.. */
704 static snd_pcm_hardware_t snd_ad1848_playback
=
706 .info
= (SNDRV_PCM_INFO_MMAP
| SNDRV_PCM_INFO_INTERLEAVED
|
707 SNDRV_PCM_INFO_MMAP_VALID
),
708 .formats
= (SNDRV_PCM_FMTBIT_MU_LAW
| SNDRV_PCM_FMTBIT_A_LAW
|
709 SNDRV_PCM_FMTBIT_U8
| SNDRV_PCM_FMTBIT_S16_LE
),
710 .rates
= SNDRV_PCM_RATE_KNOT
| SNDRV_PCM_RATE_8000_48000
,
715 .buffer_bytes_max
= (128*1024),
716 .period_bytes_min
= 64,
717 .period_bytes_max
= (128*1024),
723 static snd_pcm_hardware_t snd_ad1848_capture
=
725 .info
= (SNDRV_PCM_INFO_MMAP
| SNDRV_PCM_INFO_INTERLEAVED
|
726 SNDRV_PCM_INFO_MMAP_VALID
),
727 .formats
= (SNDRV_PCM_FMTBIT_MU_LAW
| SNDRV_PCM_FMTBIT_A_LAW
|
728 SNDRV_PCM_FMTBIT_U8
| SNDRV_PCM_FMTBIT_S16_LE
),
729 .rates
= SNDRV_PCM_RATE_KNOT
| SNDRV_PCM_RATE_8000_48000
,
734 .buffer_bytes_max
= (128*1024),
735 .period_bytes_min
= 64,
736 .period_bytes_max
= (128*1024),
746 static int snd_ad1848_playback_open(snd_pcm_substream_t
* substream
)
748 ad1848_t
*chip
= snd_pcm_substream_chip(substream
);
749 snd_pcm_runtime_t
*runtime
= substream
->runtime
;
752 if ((err
= snd_ad1848_open(chip
, AD1848_MODE_PLAY
)) < 0)
754 chip
->playback_substream
= substream
;
755 runtime
->hw
= snd_ad1848_playback
;
756 snd_pcm_limit_isa_dma_size(chip
->dma
, &runtime
->hw
.buffer_bytes_max
);
757 snd_pcm_limit_isa_dma_size(chip
->dma
, &runtime
->hw
.period_bytes_max
);
758 snd_pcm_hw_constraint_list(runtime
, 0, SNDRV_PCM_HW_PARAM_RATE
, &hw_constraints_rates
);
762 static int snd_ad1848_capture_open(snd_pcm_substream_t
* substream
)
764 ad1848_t
*chip
= snd_pcm_substream_chip(substream
);
765 snd_pcm_runtime_t
*runtime
= substream
->runtime
;
768 if ((err
= snd_ad1848_open(chip
, AD1848_MODE_CAPTURE
)) < 0)
770 chip
->capture_substream
= substream
;
771 runtime
->hw
= snd_ad1848_capture
;
772 snd_pcm_limit_isa_dma_size(chip
->dma
, &runtime
->hw
.buffer_bytes_max
);
773 snd_pcm_limit_isa_dma_size(chip
->dma
, &runtime
->hw
.period_bytes_max
);
774 snd_pcm_hw_constraint_list(runtime
, 0, SNDRV_PCM_HW_PARAM_RATE
, &hw_constraints_rates
);
778 static int snd_ad1848_playback_close(snd_pcm_substream_t
* substream
)
780 ad1848_t
*chip
= snd_pcm_substream_chip(substream
);
782 chip
->mode
&= ~AD1848_MODE_PLAY
;
783 chip
->playback_substream
= NULL
;
784 snd_ad1848_close(chip
);
788 static int snd_ad1848_capture_close(snd_pcm_substream_t
* substream
)
790 ad1848_t
*chip
= snd_pcm_substream_chip(substream
);
792 chip
->mode
&= ~AD1848_MODE_CAPTURE
;
793 chip
->capture_substream
= NULL
;
794 snd_ad1848_close(chip
);
798 static int snd_ad1848_free(ad1848_t
*chip
)
800 if (chip
->res_port
) {
801 release_resource(chip
->res_port
);
802 kfree_nocheck(chip
->res_port
);
805 free_irq(chip
->irq
, (void *) chip
);
806 if (chip
->dma
>= 0) {
807 snd_dma_disable(chip
->dma
);
810 snd_magic_kfree(chip
);
814 static int snd_ad1848_dev_free(snd_device_t
*device
)
816 ad1848_t
*chip
= snd_magic_cast(ad1848_t
, device
->device_data
, return -ENXIO
);
817 return snd_ad1848_free(chip
);
820 static const char *snd_ad1848_chip_id(ad1848_t
*chip
)
822 switch (chip
->hardware
) {
823 case AD1848_HW_AD1847
: return "AD1847";
824 case AD1848_HW_AD1848
: return "AD1848";
825 case AD1848_HW_CS4248
: return "CS4248";
826 case AD1848_HW_CMI8330
: return "CMI8330/C3D";
827 default: return "???";
831 int snd_ad1848_create(snd_card_t
* card
,
834 unsigned short hardware
,
837 static snd_device_ops_t ops
= {
838 .dev_free
= snd_ad1848_dev_free
,
844 chip
= snd_magic_kcalloc(ad1848_t
, 0, GFP_KERNEL
);
847 spin_lock_init(&chip
->reg_lock
);
848 init_MUTEX(&chip
->open_mutex
);
853 chip
->hardware
= hardware
;
854 memcpy(&chip
->image
, &snd_ad1848_original_image
, sizeof(snd_ad1848_original_image
));
856 if ((chip
->res_port
= request_region(port
, 4, "AD1848")) == NULL
) {
857 snd_ad1848_free(chip
);
860 if (request_irq(irq
, snd_ad1848_interrupt
, SA_INTERRUPT
, "AD1848", (void *) chip
)) {
861 snd_ad1848_free(chip
);
865 if (request_dma(dma
, "AD1848")) {
866 snd_ad1848_free(chip
);
871 if (snd_ad1848_probe(chip
) < 0) {
872 snd_ad1848_free(chip
);
876 /* Register device */
877 if ((err
= snd_device_new(card
, SNDRV_DEV_LOWLEVEL
, chip
, &ops
)) < 0) {
878 snd_ad1848_free(chip
);
886 static snd_pcm_ops_t snd_ad1848_playback_ops
= {
887 .open
= snd_ad1848_playback_open
,
888 .close
= snd_ad1848_playback_close
,
889 .ioctl
= snd_ad1848_ioctl
,
890 .hw_params
= snd_ad1848_playback_hw_params
,
891 .hw_free
= snd_ad1848_playback_hw_free
,
892 .prepare
= snd_ad1848_playback_prepare
,
893 .trigger
= snd_ad1848_playback_trigger
,
894 .pointer
= snd_ad1848_playback_pointer
,
897 static snd_pcm_ops_t snd_ad1848_capture_ops
= {
898 .open
= snd_ad1848_capture_open
,
899 .close
= snd_ad1848_capture_close
,
900 .ioctl
= snd_ad1848_ioctl
,
901 .hw_params
= snd_ad1848_capture_hw_params
,
902 .hw_free
= snd_ad1848_capture_hw_free
,
903 .prepare
= snd_ad1848_capture_prepare
,
904 .trigger
= snd_ad1848_capture_trigger
,
905 .pointer
= snd_ad1848_capture_pointer
,
908 static void snd_ad1848_pcm_free(snd_pcm_t
*pcm
)
910 ad1848_t
*chip
= snd_magic_cast(ad1848_t
, pcm
->private_data
, return);
912 snd_pcm_lib_preallocate_free_for_all(pcm
);
915 int snd_ad1848_pcm(ad1848_t
*chip
, int device
, snd_pcm_t
**rpcm
)
920 if ((err
= snd_pcm_new(chip
->card
, "AD1848", device
, 1, 1, &pcm
)) < 0)
923 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
, &snd_ad1848_playback_ops
);
924 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
, &snd_ad1848_capture_ops
);
926 pcm
->private_free
= snd_ad1848_pcm_free
;
927 pcm
->private_data
= chip
;
928 pcm
->info_flags
= SNDRV_PCM_INFO_HALF_DUPLEX
;
929 strcpy(pcm
->name
, snd_ad1848_chip_id(chip
));
931 snd_pcm_lib_preallocate_isa_pages_for_all(pcm
, 64*1024, chip
->dma
> 3 ? 128*1024 : 64*1024);
943 static int snd_ad1848_info_mux(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_info_t
* uinfo
)
945 static char *texts
[4] = {
946 "Line", "Aux", "Mic", "Mix"
949 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
951 uinfo
->value
.enumerated
.items
= 4;
952 if (uinfo
->value
.enumerated
.item
> 3)
953 uinfo
->value
.enumerated
.item
= 3;
954 strcpy(uinfo
->value
.enumerated
.name
, texts
[uinfo
->value
.enumerated
.item
]);
958 static int snd_ad1848_get_mux(snd_kcontrol_t
* kcontrol
, snd_ctl_elem_value_t
* ucontrol
)
960 ad1848_t
*chip
= snd_kcontrol_chip(kcontrol
);
963 spin_lock_irqsave(&chip
->reg_lock
, flags
);
964 ucontrol
->value
.enumerated
.item
[0] = (chip
->image
[AD1848_LEFT_INPUT
] & AD1848_MIXS_ALL
) >> 6;
965 ucontrol
->value
.enumerated
.item
[1] = (chip
->image
[AD1848_RIGHT_INPUT
] & AD1848_MIXS_ALL
) >> 6;
966 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
970 static int snd_ad1848_put_mux(snd_kcontrol_t
* kcontrol
, snd_ctl_elem_value_t
* ucontrol
)
972 ad1848_t
*chip
= snd_kcontrol_chip(kcontrol
);
974 unsigned short left
, right
;
977 if (ucontrol
->value
.enumerated
.item
[0] > 3 ||
978 ucontrol
->value
.enumerated
.item
[1] > 3)
980 left
= ucontrol
->value
.enumerated
.item
[0] << 6;
981 right
= ucontrol
->value
.enumerated
.item
[1] << 6;
982 spin_lock_irqsave(&chip
->reg_lock
, flags
);
983 left
= (chip
->image
[AD1848_LEFT_INPUT
] & ~AD1848_MIXS_ALL
) | left
;
984 right
= (chip
->image
[AD1848_RIGHT_INPUT
] & ~AD1848_MIXS_ALL
) | right
;
985 change
= left
!= chip
->image
[AD1848_LEFT_INPUT
] ||
986 right
!= chip
->image
[AD1848_RIGHT_INPUT
];
987 snd_ad1848_out(chip
, AD1848_LEFT_INPUT
, left
);
988 snd_ad1848_out(chip
, AD1848_RIGHT_INPUT
, right
);
989 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
993 int snd_ad1848_info_single(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_info_t
* uinfo
)
995 int mask
= (kcontrol
->private_value
>> 16) & 0xff;
997 uinfo
->type
= mask
== 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN
: SNDRV_CTL_ELEM_TYPE_INTEGER
;
999 uinfo
->value
.integer
.min
= 0;
1000 uinfo
->value
.integer
.max
= mask
;
1004 int snd_ad1848_get_single(snd_kcontrol_t
* kcontrol
, snd_ctl_elem_value_t
* ucontrol
)
1006 ad1848_t
*chip
= snd_kcontrol_chip(kcontrol
);
1007 unsigned long flags
;
1008 int reg
= kcontrol
->private_value
& 0xff;
1009 int shift
= (kcontrol
->private_value
>> 8) & 0xff;
1010 int mask
= (kcontrol
->private_value
>> 16) & 0xff;
1011 int invert
= (kcontrol
->private_value
>> 24) & 0xff;
1013 spin_lock_irqsave(&chip
->reg_lock
, flags
);
1014 ucontrol
->value
.integer
.value
[0] = (chip
->image
[reg
] >> shift
) & mask
;
1015 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
1017 ucontrol
->value
.integer
.value
[0] = mask
- ucontrol
->value
.integer
.value
[0];
1021 int snd_ad1848_put_single(snd_kcontrol_t
* kcontrol
, snd_ctl_elem_value_t
* ucontrol
)
1023 ad1848_t
*chip
= snd_kcontrol_chip(kcontrol
);
1024 unsigned long flags
;
1025 int reg
= kcontrol
->private_value
& 0xff;
1026 int shift
= (kcontrol
->private_value
>> 8) & 0xff;
1027 int mask
= (kcontrol
->private_value
>> 16) & 0xff;
1028 int invert
= (kcontrol
->private_value
>> 24) & 0xff;
1032 val
= (ucontrol
->value
.integer
.value
[0] & mask
);
1036 spin_lock_irqsave(&chip
->reg_lock
, flags
);
1037 val
= (chip
->image
[reg
] & ~(mask
<< shift
)) | val
;
1038 change
= val
!= chip
->image
[reg
];
1039 snd_ad1848_out(chip
, reg
, val
);
1040 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
1044 int snd_ad1848_info_double(snd_kcontrol_t
*kcontrol
, snd_ctl_elem_info_t
* uinfo
)
1046 int mask
= (kcontrol
->private_value
>> 24) & 0xff;
1048 uinfo
->type
= mask
== 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN
: SNDRV_CTL_ELEM_TYPE_INTEGER
;
1050 uinfo
->value
.integer
.min
= 0;
1051 uinfo
->value
.integer
.max
= mask
;
1055 int snd_ad1848_get_double(snd_kcontrol_t
* kcontrol
, snd_ctl_elem_value_t
* ucontrol
)
1057 ad1848_t
*chip
= snd_kcontrol_chip(kcontrol
);
1058 unsigned long flags
;
1059 int left_reg
= kcontrol
->private_value
& 0xff;
1060 int right_reg
= (kcontrol
->private_value
>> 8) & 0xff;
1061 int shift_left
= (kcontrol
->private_value
>> 16) & 0x07;
1062 int shift_right
= (kcontrol
->private_value
>> 19) & 0x07;
1063 int mask
= (kcontrol
->private_value
>> 24) & 0xff;
1064 int invert
= (kcontrol
->private_value
>> 22) & 1;
1066 spin_lock_irqsave(&chip
->reg_lock
, flags
);
1067 ucontrol
->value
.integer
.value
[0] = (chip
->image
[left_reg
] >> shift_left
) & mask
;
1068 ucontrol
->value
.integer
.value
[1] = (chip
->image
[right_reg
] >> shift_right
) & mask
;
1069 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
1071 ucontrol
->value
.integer
.value
[0] = mask
- ucontrol
->value
.integer
.value
[0];
1072 ucontrol
->value
.integer
.value
[1] = mask
- ucontrol
->value
.integer
.value
[1];
1077 int snd_ad1848_put_double(snd_kcontrol_t
* kcontrol
, snd_ctl_elem_value_t
* ucontrol
)
1079 ad1848_t
*chip
= snd_kcontrol_chip(kcontrol
);
1080 unsigned long flags
;
1081 int left_reg
= kcontrol
->private_value
& 0xff;
1082 int right_reg
= (kcontrol
->private_value
>> 8) & 0xff;
1083 int shift_left
= (kcontrol
->private_value
>> 16) & 0x07;
1084 int shift_right
= (kcontrol
->private_value
>> 19) & 0x07;
1085 int mask
= (kcontrol
->private_value
>> 24) & 0xff;
1086 int invert
= (kcontrol
->private_value
>> 22) & 1;
1088 unsigned short val1
, val2
;
1090 val1
= ucontrol
->value
.integer
.value
[0] & mask
;
1091 val2
= ucontrol
->value
.integer
.value
[1] & mask
;
1096 val1
<<= shift_left
;
1097 val2
<<= shift_right
;
1098 spin_lock_irqsave(&chip
->reg_lock
, flags
);
1099 if (left_reg
!= right_reg
) {
1100 val1
= (chip
->image
[left_reg
] & ~(mask
<< shift_left
)) | val1
;
1101 val2
= (chip
->image
[right_reg
] & ~(mask
<< shift_right
)) | val2
;
1102 change
= val1
!= chip
->image
[left_reg
] || val2
!= chip
->image
[right_reg
];
1103 snd_ad1848_out(chip
, left_reg
, val1
);
1104 snd_ad1848_out(chip
, right_reg
, val2
);
1106 val1
= (chip
->image
[left_reg
] & ~((mask
<< shift_left
) | (mask
<< shift_right
))) | val1
| val2
;
1107 change
= val1
!= chip
->image
[left_reg
];
1108 snd_ad1848_out(chip
, left_reg
, val1
);
1110 spin_unlock_irqrestore(&chip
->reg_lock
, flags
);
1114 #define AD1848_CONTROLS (sizeof(snd_ad1848_controls)/sizeof(snd_kcontrol_new_t))
1116 static snd_kcontrol_new_t snd_ad1848_controls
[] = {
1117 AD1848_DOUBLE("PCM Playback Switch", 0, AD1848_LEFT_OUTPUT
, AD1848_RIGHT_OUTPUT
, 7, 7, 1, 1),
1118 AD1848_DOUBLE("PCM Playback Volume", 0, AD1848_LEFT_OUTPUT
, AD1848_RIGHT_OUTPUT
, 0, 0, 63, 1),
1119 AD1848_DOUBLE("Aux Playback Switch", 0, AD1848_AUX1_LEFT_INPUT
, AD1848_AUX1_RIGHT_INPUT
, 7, 7, 1, 1),
1120 AD1848_DOUBLE("Aux Playback Volume", 0, AD1848_AUX1_LEFT_INPUT
, AD1848_AUX1_RIGHT_INPUT
, 0, 0, 31, 1),
1121 AD1848_DOUBLE("Aux Playback Switch", 1, AD1848_AUX2_LEFT_INPUT
, AD1848_AUX2_RIGHT_INPUT
, 7, 7, 1, 1),
1122 AD1848_DOUBLE("Aux Playback Volume", 1, AD1848_AUX2_LEFT_INPUT
, AD1848_AUX2_RIGHT_INPUT
, 0, 0, 31, 1),
1123 AD1848_DOUBLE("Capture Volume", 0, AD1848_LEFT_INPUT
, AD1848_RIGHT_INPUT
, 0, 0, 15, 0),
1125 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1126 .name
= "Capture Source",
1127 .info
= snd_ad1848_info_mux
,
1128 .get
= snd_ad1848_get_mux
,
1129 .put
= snd_ad1848_put_mux
,
1131 AD1848_SINGLE("Loopback Capture Switch", 0, AD1848_LOOPBACK
, 0, 1, 0),
1132 AD1848_SINGLE("Loopback Capture Volume", 0, AD1848_LOOPBACK
, 1, 63, 0)
1135 int snd_ad1848_mixer(ad1848_t
*chip
)
1141 snd_assert(chip
!= NULL
&& chip
->pcm
!= NULL
, return -EINVAL
);
1146 strcpy(card
->mixername
, pcm
->name
);
1148 for (idx
= 0; idx
< AD1848_CONTROLS
; idx
++) {
1149 if ((err
= snd_ctl_add(card
, snd_ctl_new1(&snd_ad1848_controls
[idx
], chip
))) < 0)
1155 EXPORT_SYMBOL(snd_ad1848_in
);
1156 EXPORT_SYMBOL(snd_ad1848_out
);
1157 EXPORT_SYMBOL(snd_ad1848_dout
);
1158 EXPORT_SYMBOL(snd_ad1848_mce_up
);
1159 EXPORT_SYMBOL(snd_ad1848_mce_down
);
1160 EXPORT_SYMBOL(snd_ad1848_interrupt
);
1161 EXPORT_SYMBOL(snd_ad1848_create
);
1162 EXPORT_SYMBOL(snd_ad1848_pcm
);
1163 EXPORT_SYMBOL(snd_ad1848_mixer
);
1164 EXPORT_SYMBOL(snd_ad1848_info_single
);
1165 EXPORT_SYMBOL(snd_ad1848_get_single
);
1166 EXPORT_SYMBOL(snd_ad1848_put_single
);
1167 EXPORT_SYMBOL(snd_ad1848_info_double
);
1168 EXPORT_SYMBOL(snd_ad1848_get_double
);
1169 EXPORT_SYMBOL(snd_ad1848_put_double
);
1175 static int __init
alsa_ad1848_init(void)
1180 static void __exit
alsa_ad1848_exit(void)
1184 module_init(alsa_ad1848_init
)
1185 module_exit(alsa_ad1848_exit
)