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>
28 #include <linux/slab.h>
29 #include <linux/ioport.h>
30 #include <sound/core.h>
31 #include <sound/ad1848.h>
32 #include <sound/control.h>
33 #include <sound/pcm_params.h>
38 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
39 MODULE_DESCRIPTION("Routines for control of AD1848/AD1847/CS4248");
40 MODULE_LICENSE("GPL");
42 #define chip_t ad1848_t
45 #define SNDRV_DEBUG_MCE
52 static unsigned char freq_bits[14] = {
53 /* 5510 */ 0x00 | AD1848_XTAL2,
54 /* 6620 */ 0x0E | AD1848_XTAL2,
55 /* 8000 */ 0x00 | AD1848_XTAL1,
56 /* 9600 */ 0x0E | AD1848_XTAL1,
57 /* 11025 */ 0x02 | AD1848_XTAL2,
58 /* 16000 */ 0x02 | AD1848_XTAL1,
59 /* 18900 */ 0x04 | AD1848_XTAL2,
60 /* 22050 */ 0x06 | AD1848_XTAL2,
61 /* 27042 */ 0x04 | AD1848_XTAL1,
62 /* 32000 */ 0x06 | AD1848_XTAL1,
63 /* 33075 */ 0x0C | AD1848_XTAL2,
64 /* 37800 */ 0x08 | AD1848_XTAL2,
65 /* 44100 */ 0x0A | AD1848_XTAL2,
66 /* 48000 */ 0x0C | AD1848_XTAL1
69 static unsigned int rates[14] = {
70 5510, 6620, 8000, 9600, 11025, 16000, 18900, 22050,
71 27042, 32000, 33075, 37800, 44100, 48000
74 static snd_pcm_hw_constraint_list_t hw_constraints_rates = {
80 static unsigned char snd_ad1848_original_image[16] =
84 0x9f, /* 02 - la1ic */
85 0x9f, /* 03 - ra1ic */
86 0x9f, /* 04 - la2ic */
87 0x9f, /* 05 - ra2ic */
91 AD1848_AUTOCALIB, /* 09 - ic */
101 * Basic I/O functions
104 void snd_ad1848_out(ad1848_t *chip,
110 for (timeout = 250; timeout > 0 && (inb(AD1848P(chip, REGSEL)) & AD1848_INIT); timeout--)
112 #ifdef CONFIG_SND_DEBUG
113 if (inb(AD1848P(chip, REGSEL)) & AD1848_INIT)
114 snd_printk("auto calibration time out - reg = 0x%x, value = 0x%x\n", reg, value);
116 outb(chip->mce_bit | reg, AD1848P(chip, REGSEL));
117 outb(chip->image[reg] = value, AD1848P(chip, REG));
120 printk("codec out - reg 0x%x = 0x%x\n", chip->mce_bit | reg, value);
124 void snd_ad1848_dout(ad1848_t *chip,
130 for (timeout = 250; timeout > 0 && (inb(AD1848P(chip, REGSEL)) & AD1848_INIT); timeout--)
132 outb(chip->mce_bit | reg, AD1848P(chip, REGSEL));
133 outb(value, AD1848P(chip, REG));
137 unsigned char snd_ad1848_in(ad1848_t *chip, unsigned char reg)
141 for (timeout = 250; timeout > 0 && (inb(AD1848P(chip, REGSEL)) & AD1848_INIT); timeout--)
143 #ifdef CONFIG_SND_DEBUG
144 if (inb(AD1848P(chip, REGSEL)) & AD1848_INIT)
145 snd_printk("auto calibration time out - reg = 0x%x\n", reg);
147 outb(chip->mce_bit | reg, AD1848P(chip, REGSEL));
149 return inb(AD1848P(chip, REG));
152 #ifdef CONFIG_SND_DEBUG
154 void snd_ad1848_debug(ad1848_t *chip)
156 printk("AD1848 REGS: INDEX = 0x%02x ", inb(AD1848P(chip, REGSEL)));
157 printk(" STATUS = 0x%02x\n", inb(AD1848P(chip, STATUS)));
158 printk(" 0x00: left input = 0x%02x ", snd_ad1848_in(chip, 0x00));
159 printk(" 0x08: playback format = 0x%02x\n", snd_ad1848_in(chip, 0x08));
160 printk(" 0x01: right input = 0x%02x ", snd_ad1848_in(chip, 0x01));
161 printk(" 0x09: iface (CFIG 1) = 0x%02x\n", snd_ad1848_in(chip, 0x09));
162 printk(" 0x02: AUXA left = 0x%02x ", snd_ad1848_in(chip, 0x02));
163 printk(" 0x0a: pin control = 0x%02x\n", snd_ad1848_in(chip, 0x0a));
164 printk(" 0x03: AUXA right = 0x%02x ", snd_ad1848_in(chip, 0x03));
165 printk(" 0x0b: init & status = 0x%02x\n", snd_ad1848_in(chip, 0x0b));
166 printk(" 0x04: AUXB left = 0x%02x ", snd_ad1848_in(chip, 0x04));
167 printk(" 0x0c: revision & mode = 0x%02x\n", snd_ad1848_in(chip, 0x0c));
168 printk(" 0x05: AUXB right = 0x%02x ", snd_ad1848_in(chip, 0x05));
169 printk(" 0x0d: loopback = 0x%02x\n", snd_ad1848_in(chip, 0x0d));
170 printk(" 0x06: left output = 0x%02x ", snd_ad1848_in(chip, 0x06));
171 printk(" 0x0e: data upr count = 0x%02x\n", snd_ad1848_in(chip, 0x0e));
172 printk(" 0x07: right output = 0x%02x ", snd_ad1848_in(chip, 0x07));
173 printk(" 0x0f: data lwr count = 0x%02x\n", snd_ad1848_in(chip, 0x0f));
179 * AD1848 detection / MCE routines
182 void snd_ad1848_mce_up(ad1848_t *chip)
187 for (timeout = 250; timeout > 0 && (inb(AD1848P(chip, REGSEL)) & AD1848_INIT); timeout--)
189 #ifdef CONFIG_SND_DEBUG
190 if (inb(AD1848P(chip, REGSEL)) & AD1848_INIT)
191 snd_printk("mce_up - auto calibration time out (0)\n");
193 spin_lock_irqsave(&chip->reg_lock, flags);
194 chip->mce_bit |= AD1848_MCE;
195 timeout = inb(AD1848P(chip, REGSEL));
197 snd_printk("mce_up [0x%lx]: serious init problem - codec still busy\n", chip->port);
198 if (!(timeout & AD1848_MCE))
199 outb(chip->mce_bit | (timeout & 0x1f), AD1848P(chip, REGSEL));
200 spin_unlock_irqrestore(&chip->reg_lock, flags);
203 void snd_ad1848_mce_down(ad1848_t *chip)
209 spin_lock_irqsave(&chip->reg_lock, flags);
210 for (timeout = 5; timeout > 0; timeout--)
211 inb(AD1848P(chip, REGSEL));
212 /* end of cleanup sequence */
213 for (timeout = 12000; timeout > 0 && (inb(AD1848P(chip, REGSEL)) & AD1848_INIT); timeout--)
216 printk("(1) timeout = %i\n", timeout);
218 #ifdef CONFIG_SND_DEBUG
219 if (inb(AD1848P(chip, REGSEL)) & AD1848_INIT)
220 snd_printk("mce_down [0x%lx] - auto calibration time out (0)\n", AD1848P(chip, REGSEL));
222 chip->mce_bit &= ~AD1848_MCE;
223 timeout = inb(AD1848P(chip, REGSEL));
224 outb(chip->mce_bit | (timeout & 0x1f), AD1848P(chip, REGSEL));
226 snd_printk("mce_down [0x%lx]: serious init problem - codec still busy\n", chip->port);
227 if ((timeout & AD1848_MCE) == 0) {
228 spin_unlock_irqrestore(&chip->reg_lock, flags);
231 /* calibration process */
233 for (timeout = 500; timeout > 0 && (snd_ad1848_in(chip, AD1848_TEST_INIT) & AD1848_CALIB_IN_PROGRESS) == 0; timeout--);
234 if ((snd_ad1848_in(chip, AD1848_TEST_INIT) & AD1848_CALIB_IN_PROGRESS) == 0) {
235 snd_printd("mce_down - auto calibration time out (1)\n");
236 spin_unlock_irqrestore(&chip->reg_lock, flags);
240 printk("(2) timeout = %i, jiffies = %li\n", timeout, jiffies);
243 while (snd_ad1848_in(chip, AD1848_TEST_INIT) & AD1848_CALIB_IN_PROGRESS) {
244 spin_unlock_irqrestore(&chip->reg_lock, flags);
246 snd_printk("mce_down - auto calibration time out (2)\n");
249 set_current_state(TASK_INTERRUPTIBLE);
250 time = schedule_timeout(time);
251 spin_lock_irqsave(&chip->reg_lock, flags);
254 printk("(3) jiffies = %li\n", jiffies);
257 while (inb(AD1848P(chip, REGSEL)) & AD1848_INIT) {
258 spin_unlock_irqrestore(&chip->reg_lock, flags);
260 snd_printk("mce_down - auto calibration time out (3)\n");
263 set_current_state(TASK_INTERRUPTIBLE);
264 time = schedule_timeout(time);
265 spin_lock_irqsave(&chip->reg_lock, flags);
267 spin_unlock_irqrestore(&chip->reg_lock, flags);
269 printk("(4) jiffies = %li\n", jiffies);
270 snd_printk("mce_down - exit = 0x%x\n", inb(AD1848P(chip, REGSEL)));
274 static unsigned int snd_ad1848_get_count(unsigned char format,
277 switch (format & 0xe0) {
278 case AD1848_LINEAR_16:
282 if (format & AD1848_STEREO)
287 static int snd_ad1848_trigger(ad1848_t *chip, unsigned char what,
288 int channel, int cmd)
293 printk("codec trigger!!! - what = %i, enable = %i, status = 0x%x\n", what, enable, inb(AD1848P(card, STATUS)));
295 spin_lock(&chip->reg_lock);
296 if (cmd == SNDRV_PCM_TRIGGER_START) {
297 if (chip->image[AD1848_IFACE_CTRL] & what) {
298 spin_unlock(&chip->reg_lock);
301 snd_ad1848_out(chip, AD1848_IFACE_CTRL, chip->image[AD1848_IFACE_CTRL] |= what);
302 chip->mode |= AD1848_MODE_RUNNING;
303 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
304 if (!(chip->image[AD1848_IFACE_CTRL] & what)) {
305 spin_unlock(&chip->reg_lock);
308 snd_ad1848_out(chip, AD1848_IFACE_CTRL, chip->image[AD1848_IFACE_CTRL] &= ~what);
309 chip->mode &= ~AD1848_MODE_RUNNING;
313 spin_unlock(&chip->reg_lock);
321 static unsigned char snd_ad1848_get_rate(unsigned int rate)
325 for (i = 0; i < 14; i++)
326 if (rate == rates[i])
329 return freq_bits[13];
332 static int snd_ad1848_ioctl(snd_pcm_substream_t * substream,
333 unsigned int cmd, void *arg)
335 return snd_pcm_lib_ioctl(substream, cmd, arg);
338 static unsigned char snd_ad1848_get_format(int format, int channels)
340 unsigned char rformat;
342 rformat = AD1848_LINEAR_8;
344 case SNDRV_PCM_FORMAT_A_LAW: rformat = AD1848_ALAW_8; break;
345 case SNDRV_PCM_FORMAT_MU_LAW: rformat = AD1848_ULAW_8; break;
346 case SNDRV_PCM_FORMAT_S16_LE: rformat = AD1848_LINEAR_16; break;
349 rformat |= AD1848_STEREO;
351 snd_printk("get_format: 0x%x (mode=0x%x)\n", format, mode);
356 static void snd_ad1848_calibrate_mute(ad1848_t *chip, int mute)
361 spin_lock_irqsave(&chip->reg_lock, flags);
362 if (chip->calibrate_mute == mute) {
363 spin_unlock_irqrestore(&chip->reg_lock, flags);
367 snd_ad1848_dout(chip, AD1848_LEFT_INPUT, chip->image[AD1848_LEFT_INPUT]);
368 snd_ad1848_dout(chip, AD1848_RIGHT_INPUT, chip->image[AD1848_RIGHT_INPUT]);
370 snd_ad1848_dout(chip, AD1848_AUX1_LEFT_INPUT, mute ? 0x80 : chip->image[AD1848_AUX1_LEFT_INPUT]);
371 snd_ad1848_dout(chip, AD1848_AUX1_RIGHT_INPUT, mute ? 0x80 : chip->image[AD1848_AUX1_RIGHT_INPUT]);
372 snd_ad1848_dout(chip, AD1848_AUX2_LEFT_INPUT, mute ? 0x80 : chip->image[AD1848_AUX2_LEFT_INPUT]);
373 snd_ad1848_dout(chip, AD1848_AUX2_RIGHT_INPUT, mute ? 0x80 : chip->image[AD1848_AUX2_RIGHT_INPUT]);
374 snd_ad1848_dout(chip, AD1848_LEFT_OUTPUT, mute ? 0x80 : chip->image[AD1848_LEFT_OUTPUT]);
375 snd_ad1848_dout(chip, AD1848_RIGHT_OUTPUT, mute ? 0x80 : chip->image[AD1848_RIGHT_OUTPUT]);
376 chip->calibrate_mute = mute;
377 spin_unlock_irqrestore(&chip->reg_lock, flags);
380 static void snd_ad1848_set_data_format(ad1848_t *chip, snd_pcm_hw_params_t *hw_params)
382 if (hw_params == NULL) {
383 chip->image[AD1848_DATA_FORMAT] = 0x20;
385 chip->image[AD1848_DATA_FORMAT] =
386 snd_ad1848_get_format(params_format(hw_params), params_channels(hw_params)) |
387 snd_ad1848_get_rate(params_rate(hw_params));
389 // snd_printk(">>> pmode = 0x%x, dfr = 0x%x\n", pstr->mode, chip->image[AD1848_DATA_FORMAT]);
392 static int snd_ad1848_open(ad1848_t *chip, unsigned int mode)
396 down(&chip->open_mutex);
397 if (chip->mode & AD1848_MODE_OPEN) {
398 up(&chip->open_mutex);
401 snd_ad1848_mce_down(chip);
403 #ifdef SNDRV_DEBUG_MCE
404 snd_printk("open: (1)\n");
406 snd_ad1848_mce_up(chip);
407 spin_lock_irqsave(&chip->reg_lock, flags);
408 chip->image[AD1848_IFACE_CTRL] &= ~(AD1848_PLAYBACK_ENABLE | AD1848_PLAYBACK_PIO |
409 AD1848_CAPTURE_ENABLE | AD1848_CAPTURE_PIO |
411 chip->image[AD1848_IFACE_CTRL] |= AD1848_AUTOCALIB;
412 snd_ad1848_out(chip, AD1848_IFACE_CTRL, chip->image[AD1848_IFACE_CTRL]);
413 spin_unlock_irqrestore(&chip->reg_lock, flags);
414 snd_ad1848_mce_down(chip);
416 #ifdef SNDRV_DEBUG_MCE
417 snd_printk("open: (2)\n");
420 snd_ad1848_set_data_format(chip, NULL);
422 snd_ad1848_mce_up(chip);
423 spin_lock_irqsave(&chip->reg_lock, flags);
424 snd_ad1848_out(chip, AD1848_DATA_FORMAT, chip->image[AD1848_DATA_FORMAT]);
425 spin_unlock_irqrestore(&chip->reg_lock, flags);
426 snd_ad1848_mce_down(chip);
428 #ifdef SNDRV_DEBUG_MCE
429 snd_printk("open: (3)\n");
432 /* ok. now enable and ack CODEC IRQ */
433 spin_lock_irqsave(&chip->reg_lock, flags);
434 outb(0, AD1848P(chip, STATUS)); /* clear IRQ */
435 outb(0, AD1848P(chip, STATUS)); /* clear IRQ */
436 chip->image[AD1848_PIN_CTRL] |= AD1848_IRQ_ENABLE;
437 snd_ad1848_out(chip, AD1848_PIN_CTRL, chip->image[AD1848_PIN_CTRL]);
438 spin_unlock_irqrestore(&chip->reg_lock, flags);
441 up(&chip->open_mutex);
446 static void snd_ad1848_close(ad1848_t *chip)
450 down(&chip->open_mutex);
452 up(&chip->open_mutex);
456 spin_lock_irqsave(&chip->reg_lock, flags);
457 outb(0, AD1848P(chip, STATUS)); /* clear IRQ */
458 outb(0, AD1848P(chip, STATUS)); /* clear IRQ */
459 chip->image[AD1848_PIN_CTRL] &= ~AD1848_IRQ_ENABLE;
460 snd_ad1848_out(chip, AD1848_PIN_CTRL, chip->image[AD1848_PIN_CTRL]);
461 spin_unlock_irqrestore(&chip->reg_lock, flags);
463 /* now disable capture & playback */
465 snd_ad1848_mce_up(chip);
466 spin_lock_irqsave(&chip->reg_lock, flags);
467 chip->image[AD1848_IFACE_CTRL] &= ~(AD1848_PLAYBACK_ENABLE | AD1848_PLAYBACK_PIO |
468 AD1848_CAPTURE_ENABLE | AD1848_CAPTURE_PIO);
469 snd_ad1848_out(chip, AD1848_IFACE_CTRL, chip->image[AD1848_IFACE_CTRL]);
470 spin_unlock_irqrestore(&chip->reg_lock, flags);
471 snd_ad1848_mce_down(chip);
473 /* clear IRQ again */
474 spin_lock_irqsave(&chip->reg_lock, flags);
475 outb(0, AD1848P(chip, STATUS)); /* clear IRQ */
476 outb(0, AD1848P(chip, STATUS)); /* clear IRQ */
477 spin_unlock_irqrestore(&chip->reg_lock, flags);
480 up(&chip->open_mutex);
484 * ok.. exported functions..
487 static int snd_ad1848_playback_trigger(snd_pcm_substream_t * substream,
490 ad1848_t *chip = snd_pcm_substream_chip(substream);
491 return snd_ad1848_trigger(chip, AD1848_PLAYBACK_ENABLE, SNDRV_PCM_STREAM_PLAYBACK, cmd);
494 static int snd_ad1848_capture_trigger(snd_pcm_substream_t * substream,
497 ad1848_t *chip = snd_pcm_substream_chip(substream);
498 return snd_ad1848_trigger(chip, AD1848_CAPTURE_ENABLE, SNDRV_PCM_STREAM_CAPTURE, cmd);
501 static int snd_ad1848_playback_hw_params(snd_pcm_substream_t * substream,
502 snd_pcm_hw_params_t * hw_params)
504 ad1848_t *chip = snd_pcm_substream_chip(substream);
508 if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
510 snd_ad1848_calibrate_mute(chip, 1);
511 snd_ad1848_set_data_format(chip, hw_params);
512 snd_ad1848_mce_up(chip);
513 spin_lock_irqsave(&chip->reg_lock, flags);
514 snd_ad1848_out(chip, AD1848_DATA_FORMAT, chip->image[AD1848_DATA_FORMAT]);
515 spin_unlock_irqrestore(&chip->reg_lock, flags);
516 snd_ad1848_mce_down(chip);
517 snd_ad1848_calibrate_mute(chip, 0);
521 static int snd_ad1848_playback_hw_free(snd_pcm_substream_t * substream)
523 return snd_pcm_lib_free_pages(substream);
526 static int snd_ad1848_playback_prepare(snd_pcm_substream_t * substream)
528 ad1848_t *chip = snd_pcm_substream_chip(substream);
529 snd_pcm_runtime_t *runtime = substream->runtime;
531 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
532 unsigned int count = snd_pcm_lib_period_bytes(substream);
534 chip->dma_size = size;
535 chip->image[AD1848_IFACE_CTRL] &= ~(AD1848_PLAYBACK_ENABLE | AD1848_PLAYBACK_PIO);
536 snd_dma_program(chip->dma, runtime->dma_addr, size, DMA_MODE_WRITE | DMA_AUTOINIT);
537 count = snd_ad1848_get_count(chip->image[AD1848_DATA_FORMAT], count) - 1;
538 spin_lock_irqsave(&chip->reg_lock, flags);
539 snd_ad1848_out(chip, AD1848_DATA_LWR_CNT, (unsigned char) count);
540 snd_ad1848_out(chip, AD1848_DATA_UPR_CNT, (unsigned char) (count >> 8));
541 spin_unlock_irqrestore(&chip->reg_lock, flags);
545 static int snd_ad1848_capture_hw_params(snd_pcm_substream_t * substream,
546 snd_pcm_hw_params_t * hw_params)
548 ad1848_t *chip = snd_pcm_substream_chip(substream);
552 if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
554 snd_ad1848_calibrate_mute(chip, 1);
555 snd_ad1848_set_data_format(chip, hw_params);
556 snd_ad1848_mce_up(chip);
557 spin_lock_irqsave(&chip->reg_lock, flags);
558 snd_ad1848_out(chip, AD1848_DATA_FORMAT, chip->image[AD1848_DATA_FORMAT]);
559 spin_unlock_irqrestore(&chip->reg_lock, flags);
560 snd_ad1848_mce_down(chip);
561 snd_ad1848_calibrate_mute(chip, 0);
565 static int snd_ad1848_capture_hw_free(snd_pcm_substream_t * substream)
567 return snd_pcm_lib_free_pages(substream);
570 static int snd_ad1848_capture_prepare(snd_pcm_substream_t * substream)
572 ad1848_t *chip = snd_pcm_substream_chip(substream);
573 snd_pcm_runtime_t *runtime = substream->runtime;
575 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
576 unsigned int count = snd_pcm_lib_period_bytes(substream);
578 chip->dma_size = size;
579 chip->image[AD1848_IFACE_CTRL] &= ~(AD1848_CAPTURE_ENABLE | AD1848_CAPTURE_PIO);
580 snd_dma_program(chip->dma, runtime->dma_addr, size, DMA_MODE_READ | DMA_AUTOINIT);
581 count = snd_ad1848_get_count(chip->image[AD1848_DATA_FORMAT], count) - 1;
582 spin_lock_irqsave(&chip->reg_lock, flags);
583 snd_ad1848_out(chip, AD1848_DATA_LWR_CNT, (unsigned char) count);
584 snd_ad1848_out(chip, AD1848_DATA_UPR_CNT, (unsigned char) (count >> 8));
585 spin_unlock_irqrestore(&chip->reg_lock, flags);
589 irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs)
591 ad1848_t *chip = snd_magic_cast(ad1848_t, dev_id, return IRQ_NONE);
593 if ((chip->mode & AD1848_MODE_PLAY) && chip->playback_substream &&
594 (chip->mode & AD1848_MODE_RUNNING))
595 snd_pcm_period_elapsed(chip->playback_substream);
596 if ((chip->mode & AD1848_MODE_CAPTURE) && chip->capture_substream &&
597 (chip->mode & AD1848_MODE_RUNNING))
598 snd_pcm_period_elapsed(chip->capture_substream);
599 outb(0, AD1848P(chip, STATUS)); /* clear global interrupt bit */
603 static snd_pcm_uframes_t snd_ad1848_playback_pointer(snd_pcm_substream_t * substream)
605 ad1848_t *chip = snd_pcm_substream_chip(substream);
608 if (!(chip->image[AD1848_IFACE_CTRL] & AD1848_PLAYBACK_ENABLE))
610 ptr = snd_dma_pointer(chip->dma, chip->dma_size);
611 return bytes_to_frames(substream->runtime, ptr);
614 static snd_pcm_uframes_t snd_ad1848_capture_pointer(snd_pcm_substream_t * substream)
616 ad1848_t *chip = snd_pcm_substream_chip(substream);
619 if (!(chip->image[AD1848_IFACE_CTRL] & AD1848_CAPTURE_ENABLE))
621 ptr = snd_dma_pointer(chip->dma, chip->dma_size);
622 return bytes_to_frames(substream->runtime, ptr);
629 static void snd_ad1848_thinkpad_twiddle(ad1848_t *chip, int on) {
633 if (!chip->thinkpad_flag) return;
635 outb(0x1c, AD1848_THINKPAD_CTL_PORT1);
636 tmp = inb(AD1848_THINKPAD_CTL_PORT2);
640 tmp |= AD1848_THINKPAD_CS4248_ENABLE_BIT;
643 tmp &= ~AD1848_THINKPAD_CS4248_ENABLE_BIT;
645 outb(tmp, AD1848_THINKPAD_CTL_PORT2);
650 static int snd_ad1848_suspend(snd_card_t *card, unsigned int state)
652 ad1848_t *chip = snd_magic_cast(ad1848_t, card->pm_private_data, return -EINVAL);
654 if (card->power_state == SNDRV_CTL_POWER_D3hot)
657 snd_pcm_suspend_all(chip->pcm);
658 /* FIXME: save registers? */
660 if (chip->thinkpad_flag)
661 snd_ad1848_thinkpad_twiddle(chip, 0);
663 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
667 static int snd_ad1848_resume(snd_card_t *card, unsigned int state)
669 ad1848_t *chip = snd_magic_cast(ad1848_t, card->pm_private_data, return -EINVAL);
671 if (card->power_state == SNDRV_CTL_POWER_D0)
674 if (chip->thinkpad_flag)
675 snd_ad1848_thinkpad_twiddle(chip, 1);
677 /* FIXME: restore registers? */
679 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
682 #endif /* CONFIG_PM */
684 static int snd_ad1848_probe(ad1848_t * chip)
687 int i, id, rev, ad1847;
691 snd_ad1848_debug(chip);
694 for (i = 0; i < 1000; i++) {
696 if (inb(AD1848P(chip, REGSEL)) & AD1848_INIT)
699 spin_lock_irqsave(&chip->reg_lock, flags);
700 snd_ad1848_out(chip, AD1848_MISC_INFO, 0x00);
701 snd_ad1848_out(chip, AD1848_LEFT_INPUT, 0xaa);
702 snd_ad1848_out(chip, AD1848_RIGHT_INPUT, 0x45);
703 rev = snd_ad1848_in(chip, AD1848_RIGHT_INPUT);
705 spin_unlock_irqrestore(&chip->reg_lock, flags);
710 if (snd_ad1848_in(chip, AD1848_LEFT_INPUT) == 0xaa && rev == 0x45) {
711 spin_unlock_irqrestore(&chip->reg_lock, flags);
715 spin_unlock_irqrestore(&chip->reg_lock, flags);
719 return -ENODEV; /* no valid device found */
720 if (chip->hardware == AD1848_HW_DETECT) {
722 chip->hardware = AD1848_HW_AD1847;
724 chip->hardware = AD1848_HW_AD1848;
725 rev = snd_ad1848_in(chip, AD1848_MISC_INFO);
727 chip->hardware = AD1848_HW_CS4248;
728 } else if ((rev & 0x0f) == 0x0a) {
729 snd_ad1848_out(chip, AD1848_MISC_INFO, 0x40);
730 for (i = 0; i < 16; ++i) {
731 if (snd_ad1848_in(chip, i) != snd_ad1848_in(chip, i + 16)) {
732 chip->hardware = AD1848_HW_CMI8330;
736 snd_ad1848_out(chip, AD1848_MISC_INFO, 0x00);
740 spin_lock_irqsave(&chip->reg_lock, flags);
741 inb(AD1848P(chip, STATUS)); /* clear any pendings IRQ */
742 outb(0, AD1848P(chip, STATUS));
744 spin_unlock_irqrestore(&chip->reg_lock, flags);
746 chip->image[AD1848_MISC_INFO] = 0x00;
747 chip->image[AD1848_IFACE_CTRL] =
748 (chip->image[AD1848_IFACE_CTRL] & ~AD1848_SINGLE_DMA) | AD1848_SINGLE_DMA;
749 ptr = (unsigned char *) &chip->image;
750 snd_ad1848_mce_down(chip);
751 spin_lock_irqsave(&chip->reg_lock, flags);
752 for (i = 0; i < 16; i++) /* ok.. fill all AD1848 registers */
753 snd_ad1848_out(chip, i, *ptr++);
754 spin_unlock_irqrestore(&chip->reg_lock, flags);
755 snd_ad1848_mce_up(chip);
756 snd_ad1848_mce_down(chip);
757 return 0; /* all things are ok.. */
764 static snd_pcm_hardware_t snd_ad1848_playback =
766 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
767 SNDRV_PCM_INFO_MMAP_VALID),
768 .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW |
769 SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE),
770 .rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000,
775 .buffer_bytes_max = (128*1024),
776 .period_bytes_min = 64,
777 .period_bytes_max = (128*1024),
783 static snd_pcm_hardware_t snd_ad1848_capture =
785 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
786 SNDRV_PCM_INFO_MMAP_VALID),
787 .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW |
788 SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE),
789 .rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000,
794 .buffer_bytes_max = (128*1024),
795 .period_bytes_min = 64,
796 .period_bytes_max = (128*1024),
806 static int snd_ad1848_playback_open(snd_pcm_substream_t * substream)
808 ad1848_t *chip = snd_pcm_substream_chip(substream);
809 snd_pcm_runtime_t *runtime = substream->runtime;
812 if ((err = snd_ad1848_open(chip, AD1848_MODE_PLAY)) < 0)
814 chip->playback_substream = substream;
815 runtime->hw = snd_ad1848_playback;
816 snd_pcm_limit_isa_dma_size(chip->dma, &runtime->hw.buffer_bytes_max);
817 snd_pcm_limit_isa_dma_size(chip->dma, &runtime->hw.period_bytes_max);
818 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
822 static int snd_ad1848_capture_open(snd_pcm_substream_t * substream)
824 ad1848_t *chip = snd_pcm_substream_chip(substream);
825 snd_pcm_runtime_t *runtime = substream->runtime;
828 if ((err = snd_ad1848_open(chip, AD1848_MODE_CAPTURE)) < 0)
830 chip->capture_substream = substream;
831 runtime->hw = snd_ad1848_capture;
832 snd_pcm_limit_isa_dma_size(chip->dma, &runtime->hw.buffer_bytes_max);
833 snd_pcm_limit_isa_dma_size(chip->dma, &runtime->hw.period_bytes_max);
834 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
838 static int snd_ad1848_playback_close(snd_pcm_substream_t * substream)
840 ad1848_t *chip = snd_pcm_substream_chip(substream);
842 chip->mode &= ~AD1848_MODE_PLAY;
843 chip->playback_substream = NULL;
844 snd_ad1848_close(chip);
848 static int snd_ad1848_capture_close(snd_pcm_substream_t * substream)
850 ad1848_t *chip = snd_pcm_substream_chip(substream);
852 chip->mode &= ~AD1848_MODE_CAPTURE;
853 chip->capture_substream = NULL;
854 snd_ad1848_close(chip);
858 static int snd_ad1848_free(ad1848_t *chip)
860 if (chip->res_port) {
861 release_resource(chip->res_port);
862 kfree_nocheck(chip->res_port);
865 free_irq(chip->irq, (void *) chip);
866 if (chip->dma >= 0) {
867 snd_dma_disable(chip->dma);
870 snd_magic_kfree(chip);
874 static int snd_ad1848_dev_free(snd_device_t *device)
876 ad1848_t *chip = snd_magic_cast(ad1848_t, device->device_data, return -ENXIO);
877 return snd_ad1848_free(chip);
880 static const char *snd_ad1848_chip_id(ad1848_t *chip)
882 switch (chip->hardware) {
883 case AD1848_HW_AD1847: return "AD1847";
884 case AD1848_HW_AD1848: return "AD1848";
885 case AD1848_HW_CS4248: return "CS4248";
886 case AD1848_HW_CMI8330: return "CMI8330/C3D";
887 default: return "???";
891 int snd_ad1848_create(snd_card_t * card,
894 unsigned short hardware,
897 static snd_device_ops_t ops = {
898 .dev_free = snd_ad1848_dev_free,
904 chip = snd_magic_kcalloc(ad1848_t, 0, GFP_KERNEL);
907 spin_lock_init(&chip->reg_lock);
908 init_MUTEX(&chip->open_mutex);
913 chip->hardware = hardware;
914 memcpy(&chip->image, &snd_ad1848_original_image, sizeof(snd_ad1848_original_image));
916 if ((chip->res_port = request_region(port, 4, "AD1848")) == NULL) {
917 snd_printk(KERN_ERR "ad1848: can't grab port 0x%lx\n", port);
918 snd_ad1848_free(chip);
921 if (request_irq(irq, snd_ad1848_interrupt, SA_INTERRUPT, "AD1848", (void *) chip)) {
922 snd_printk(KERN_ERR "ad1848: can't grab IRQ %d\n", irq);
923 snd_ad1848_free(chip);
927 if (request_dma(dma, "AD1848")) {
928 snd_printk(KERN_ERR "ad1848: can't grab DMA %d\n", dma);
929 snd_ad1848_free(chip);
934 if (hardware == AD1848_HW_THINKPAD) {
935 chip->thinkpad_flag = 1;
936 chip->hardware = AD1848_HW_DETECT; /* reset */
937 snd_ad1848_thinkpad_twiddle(chip, 1);
938 snd_card_set_isa_pm_callback(card, snd_ad1848_suspend, snd_ad1848_resume, chip);
941 if (snd_ad1848_probe(chip) < 0) {
942 snd_ad1848_free(chip);
946 /* Register device */
947 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
948 snd_ad1848_free(chip);
956 static snd_pcm_ops_t snd_ad1848_playback_ops = {
957 .open = snd_ad1848_playback_open,
958 .close = snd_ad1848_playback_close,
959 .ioctl = snd_ad1848_ioctl,
960 .hw_params = snd_ad1848_playback_hw_params,
961 .hw_free = snd_ad1848_playback_hw_free,
962 .prepare = snd_ad1848_playback_prepare,
963 .trigger = snd_ad1848_playback_trigger,
964 .pointer = snd_ad1848_playback_pointer,
967 static snd_pcm_ops_t snd_ad1848_capture_ops = {
968 .open = snd_ad1848_capture_open,
969 .close = snd_ad1848_capture_close,
970 .ioctl = snd_ad1848_ioctl,
971 .hw_params = snd_ad1848_capture_hw_params,
972 .hw_free = snd_ad1848_capture_hw_free,
973 .prepare = snd_ad1848_capture_prepare,
974 .trigger = snd_ad1848_capture_trigger,
975 .pointer = snd_ad1848_capture_pointer,
978 static void snd_ad1848_pcm_free(snd_pcm_t *pcm)
980 ad1848_t *chip = snd_magic_cast(ad1848_t, pcm->private_data, return);
982 snd_pcm_lib_preallocate_free_for_all(pcm);
985 int snd_ad1848_pcm(ad1848_t *chip, int device, snd_pcm_t **rpcm)
990 if ((err = snd_pcm_new(chip->card, "AD1848", device, 1, 1, &pcm)) < 0)
993 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ad1848_playback_ops);
994 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ad1848_capture_ops);
996 pcm->private_free = snd_ad1848_pcm_free;
997 pcm->private_data = chip;
998 pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;
999 strcpy(pcm->name, snd_ad1848_chip_id(chip));
1001 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1003 64*1024, chip->dma > 3 ? 128*1024 : 64*1024);
1011 const snd_pcm_ops_t *snd_ad1848_get_pcm_ops(int direction)
1013 return direction == SNDRV_PCM_STREAM_PLAYBACK ?
1014 &snd_ad1848_playback_ops : &snd_ad1848_capture_ops;
1021 static int snd_ad1848_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
1023 static char *texts[4] = {
1024 "Line", "Aux", "Mic", "Mix"
1027 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1029 uinfo->value.enumerated.items = 4;
1030 if (uinfo->value.enumerated.item > 3)
1031 uinfo->value.enumerated.item = 3;
1032 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1036 static int snd_ad1848_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
1038 ad1848_t *chip = snd_kcontrol_chip(kcontrol);
1039 unsigned long flags;
1041 spin_lock_irqsave(&chip->reg_lock, flags);
1042 ucontrol->value.enumerated.item[0] = (chip->image[AD1848_LEFT_INPUT] & AD1848_MIXS_ALL) >> 6;
1043 ucontrol->value.enumerated.item[1] = (chip->image[AD1848_RIGHT_INPUT] & AD1848_MIXS_ALL) >> 6;
1044 spin_unlock_irqrestore(&chip->reg_lock, flags);
1048 static int snd_ad1848_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
1050 ad1848_t *chip = snd_kcontrol_chip(kcontrol);
1051 unsigned long flags;
1052 unsigned short left, right;
1055 if (ucontrol->value.enumerated.item[0] > 3 ||
1056 ucontrol->value.enumerated.item[1] > 3)
1058 left = ucontrol->value.enumerated.item[0] << 6;
1059 right = ucontrol->value.enumerated.item[1] << 6;
1060 spin_lock_irqsave(&chip->reg_lock, flags);
1061 left = (chip->image[AD1848_LEFT_INPUT] & ~AD1848_MIXS_ALL) | left;
1062 right = (chip->image[AD1848_RIGHT_INPUT] & ~AD1848_MIXS_ALL) | right;
1063 change = left != chip->image[AD1848_LEFT_INPUT] ||
1064 right != chip->image[AD1848_RIGHT_INPUT];
1065 snd_ad1848_out(chip, AD1848_LEFT_INPUT, left);
1066 snd_ad1848_out(chip, AD1848_RIGHT_INPUT, right);
1067 spin_unlock_irqrestore(&chip->reg_lock, flags);
1071 static int snd_ad1848_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
1073 int mask = (kcontrol->private_value >> 16) & 0xff;
1075 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
1077 uinfo->value.integer.min = 0;
1078 uinfo->value.integer.max = mask;
1082 static int snd_ad1848_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
1084 ad1848_t *chip = snd_kcontrol_chip(kcontrol);
1085 unsigned long flags;
1086 int reg = kcontrol->private_value & 0xff;
1087 int shift = (kcontrol->private_value >> 8) & 0xff;
1088 int mask = (kcontrol->private_value >> 16) & 0xff;
1089 int invert = (kcontrol->private_value >> 24) & 0xff;
1091 spin_lock_irqsave(&chip->reg_lock, flags);
1092 ucontrol->value.integer.value[0] = (chip->image[reg] >> shift) & mask;
1093 spin_unlock_irqrestore(&chip->reg_lock, flags);
1095 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
1099 static int snd_ad1848_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
1101 ad1848_t *chip = snd_kcontrol_chip(kcontrol);
1102 unsigned long flags;
1103 int reg = kcontrol->private_value & 0xff;
1104 int shift = (kcontrol->private_value >> 8) & 0xff;
1105 int mask = (kcontrol->private_value >> 16) & 0xff;
1106 int invert = (kcontrol->private_value >> 24) & 0xff;
1110 val = (ucontrol->value.integer.value[0] & mask);
1114 spin_lock_irqsave(&chip->reg_lock, flags);
1115 val = (chip->image[reg] & ~(mask << shift)) | val;
1116 change = val != chip->image[reg];
1117 snd_ad1848_out(chip, reg, val);
1118 spin_unlock_irqrestore(&chip->reg_lock, flags);
1122 static int snd_ad1848_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
1124 int mask = (kcontrol->private_value >> 24) & 0xff;
1126 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
1128 uinfo->value.integer.min = 0;
1129 uinfo->value.integer.max = mask;
1133 static int snd_ad1848_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
1135 ad1848_t *chip = snd_kcontrol_chip(kcontrol);
1136 unsigned long flags;
1137 int left_reg = kcontrol->private_value & 0xff;
1138 int right_reg = (kcontrol->private_value >> 8) & 0xff;
1139 int shift_left = (kcontrol->private_value >> 16) & 0x07;
1140 int shift_right = (kcontrol->private_value >> 19) & 0x07;
1141 int mask = (kcontrol->private_value >> 24) & 0xff;
1142 int invert = (kcontrol->private_value >> 22) & 1;
1144 spin_lock_irqsave(&chip->reg_lock, flags);
1145 ucontrol->value.integer.value[0] = (chip->image[left_reg] >> shift_left) & mask;
1146 ucontrol->value.integer.value[1] = (chip->image[right_reg] >> shift_right) & mask;
1147 spin_unlock_irqrestore(&chip->reg_lock, flags);
1149 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
1150 ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1];
1155 static int snd_ad1848_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
1157 ad1848_t *chip = snd_kcontrol_chip(kcontrol);
1158 unsigned long flags;
1159 int left_reg = kcontrol->private_value & 0xff;
1160 int right_reg = (kcontrol->private_value >> 8) & 0xff;
1161 int shift_left = (kcontrol->private_value >> 16) & 0x07;
1162 int shift_right = (kcontrol->private_value >> 19) & 0x07;
1163 int mask = (kcontrol->private_value >> 24) & 0xff;
1164 int invert = (kcontrol->private_value >> 22) & 1;
1166 unsigned short val1, val2;
1168 val1 = ucontrol->value.integer.value[0] & mask;
1169 val2 = ucontrol->value.integer.value[1] & mask;
1174 val1 <<= shift_left;
1175 val2 <<= shift_right;
1176 spin_lock_irqsave(&chip->reg_lock, flags);
1177 if (left_reg != right_reg) {
1178 val1 = (chip->image[left_reg] & ~(mask << shift_left)) | val1;
1179 val2 = (chip->image[right_reg] & ~(mask << shift_right)) | val2;
1180 change = val1 != chip->image[left_reg] || val2 != chip->image[right_reg];
1181 snd_ad1848_out(chip, left_reg, val1);
1182 snd_ad1848_out(chip, right_reg, val2);
1184 val1 = (chip->image[left_reg] & ~((mask << shift_left) | (mask << shift_right))) | val1 | val2;
1185 change = val1 != chip->image[left_reg];
1186 snd_ad1848_out(chip, left_reg, val1);
1188 spin_unlock_irqrestore(&chip->reg_lock, flags);
1194 int snd_ad1848_add_ctl(ad1848_t *chip, const char *name, int index, int type, unsigned long value)
1196 static snd_kcontrol_new_t newctls[] = {
1197 [AD1848_MIX_SINGLE] = {
1198 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1199 .info = snd_ad1848_info_single,
1200 .get = snd_ad1848_get_single,
1201 .put = snd_ad1848_put_single,
1203 [AD1848_MIX_DOUBLE] = {
1204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1205 .info = snd_ad1848_info_double,
1206 .get = snd_ad1848_get_double,
1207 .put = snd_ad1848_put_double,
1209 [AD1848_MIX_CAPTURE] = {
1210 .info = snd_ad1848_info_mux,
1211 .get = snd_ad1848_get_mux,
1212 .put = snd_ad1848_put_mux,
1215 snd_kcontrol_t *ctl;
1218 ctl = snd_ctl_new1(&newctls[type], chip);
1221 strlcpy(ctl->id.name, name, sizeof(ctl->id.name));
1222 ctl->id.index = index;
1223 ctl->private_value = value;
1224 if ((err = snd_ctl_add(chip->card, ctl)) < 0) {
1225 snd_ctl_free_one(ctl);
1232 static struct ad1848_mix_elem snd_ad1848_controls[] = {
1233 AD1848_DOUBLE("PCM Playback Switch", 0, AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 7, 7, 1, 1),
1234 AD1848_DOUBLE("PCM Playback Volume", 0, AD1848_LEFT_OUTPUT, AD1848_RIGHT_OUTPUT, 0, 0, 63, 1),
1235 AD1848_DOUBLE("Aux Playback Switch", 0, AD1848_AUX1_LEFT_INPUT, AD1848_AUX1_RIGHT_INPUT, 7, 7, 1, 1),
1236 AD1848_DOUBLE("Aux Playback Volume", 0, AD1848_AUX1_LEFT_INPUT, AD1848_AUX1_RIGHT_INPUT, 0, 0, 31, 1),
1237 AD1848_DOUBLE("Aux Playback Switch", 1, AD1848_AUX2_LEFT_INPUT, AD1848_AUX2_RIGHT_INPUT, 7, 7, 1, 1),
1238 AD1848_DOUBLE("Aux Playback Volume", 1, AD1848_AUX2_LEFT_INPUT, AD1848_AUX2_RIGHT_INPUT, 0, 0, 31, 1),
1239 AD1848_DOUBLE("Capture Volume", 0, AD1848_LEFT_INPUT, AD1848_RIGHT_INPUT, 0, 0, 15, 0),
1241 .name = "Capture Source",
1242 .type = AD1848_MIX_CAPTURE,
1244 AD1848_SINGLE("Loopback Capture Switch", 0, AD1848_LOOPBACK, 0, 1, 0),
1245 AD1848_SINGLE("Loopback Capture Volume", 0, AD1848_LOOPBACK, 1, 63, 0)
1248 int snd_ad1848_mixer(ad1848_t *chip)
1255 snd_assert(chip != NULL && chip->pcm != NULL, return -EINVAL);
1260 strcpy(card->mixername, pcm->name);
1262 for (idx = 0; idx < ARRAY_SIZE(snd_ad1848_controls); idx++)
1263 if ((err = snd_ad1848_add_ctl_elem(chip, &snd_ad1848_controls[idx])) < 0)
1269 EXPORT_SYMBOL(snd_ad1848_in);
1270 EXPORT_SYMBOL(snd_ad1848_out);
1271 EXPORT_SYMBOL(snd_ad1848_dout);
1272 EXPORT_SYMBOL(snd_ad1848_mce_up);
1273 EXPORT_SYMBOL(snd_ad1848_mce_down);
1274 EXPORT_SYMBOL(snd_ad1848_interrupt);
1275 EXPORT_SYMBOL(snd_ad1848_create);
1276 EXPORT_SYMBOL(snd_ad1848_pcm);
1277 EXPORT_SYMBOL(snd_ad1848_get_pcm_ops);
1278 EXPORT_SYMBOL(snd_ad1848_mixer);
1279 EXPORT_SYMBOL(snd_ad1848_add_ctl);
1285 static int __init alsa_ad1848_init(void)
1290 static void __exit alsa_ad1848_exit(void)
1294 module_init(alsa_ad1848_init)
1295 module_exit(alsa_ad1848_exit)