This source file includes following definitions.
- snd_aw2_dev_free
- snd_aw2_create
- snd_aw2_probe
- snd_aw2_remove
- snd_aw2_pcm_playback_open
- snd_aw2_pcm_playback_close
- snd_aw2_pcm_capture_open
- snd_aw2_pcm_capture_close
- snd_aw2_pcm_hw_params
- snd_aw2_pcm_hw_free
- snd_aw2_pcm_prepare_playback
- snd_aw2_pcm_prepare_capture
- snd_aw2_pcm_trigger_playback
- snd_aw2_pcm_trigger_capture
- snd_aw2_pcm_pointer_playback
- snd_aw2_pcm_pointer_capture
- snd_aw2_new_pcm
- snd_aw2_control_switch_capture_info
- snd_aw2_control_switch_capture_get
- snd_aw2_control_switch_capture_put
1
2
3
4
5
6
7
8
9
10 #include <linux/init.h>
11 #include <linux/pci.h>
12 #include <linux/dma-mapping.h>
13 #include <linux/slab.h>
14 #include <linux/interrupt.h>
15 #include <linux/delay.h>
16 #include <linux/io.h>
17 #include <linux/module.h>
18 #include <sound/core.h>
19 #include <sound/initval.h>
20 #include <sound/pcm.h>
21 #include <sound/pcm_params.h>
22 #include <sound/control.h>
23
24 #include "saa7146.h"
25 #include "aw2-saa7146.h"
26
27 MODULE_AUTHOR("Cedric Bregardis <cedric.bregardis@free.fr>, "
28 "Jean-Christian Hassler <jhassler@free.fr>");
29 MODULE_DESCRIPTION("Emagic Audiowerk 2 sound driver");
30 MODULE_LICENSE("GPL");
31
32
33
34
35 #define CTL_ROUTE_ANALOG 0
36 #define CTL_ROUTE_DIGITAL 1
37
38
39
40
41
42 static const struct snd_pcm_hardware snd_aw2_playback_hw = {
43 .info = (SNDRV_PCM_INFO_MMAP |
44 SNDRV_PCM_INFO_INTERLEAVED |
45 SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID),
46 .formats = SNDRV_PCM_FMTBIT_S16_LE,
47 .rates = SNDRV_PCM_RATE_44100,
48 .rate_min = 44100,
49 .rate_max = 44100,
50 .channels_min = 2,
51 .channels_max = 4,
52 .buffer_bytes_max = 32768,
53 .period_bytes_min = 4096,
54 .period_bytes_max = 32768,
55 .periods_min = 1,
56 .periods_max = 1024,
57 };
58
59 static const struct snd_pcm_hardware snd_aw2_capture_hw = {
60 .info = (SNDRV_PCM_INFO_MMAP |
61 SNDRV_PCM_INFO_INTERLEAVED |
62 SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID),
63 .formats = SNDRV_PCM_FMTBIT_S16_LE,
64 .rates = SNDRV_PCM_RATE_44100,
65 .rate_min = 44100,
66 .rate_max = 44100,
67 .channels_min = 2,
68 .channels_max = 2,
69 .buffer_bytes_max = 32768,
70 .period_bytes_min = 4096,
71 .period_bytes_max = 32768,
72 .periods_min = 1,
73 .periods_max = 1024,
74 };
75
76 struct aw2_pcm_device {
77 struct snd_pcm *pcm;
78 unsigned int stream_number;
79 struct aw2 *chip;
80 };
81
82 struct aw2 {
83 struct snd_aw2_saa7146 saa7146;
84
85 struct pci_dev *pci;
86 int irq;
87 spinlock_t reg_lock;
88 struct mutex mtx;
89
90 unsigned long iobase_phys;
91 void __iomem *iobase_virt;
92
93 struct snd_card *card;
94
95 struct aw2_pcm_device device_playback[NB_STREAM_PLAYBACK];
96 struct aw2_pcm_device device_capture[NB_STREAM_CAPTURE];
97 };
98
99
100
101
102 static int snd_aw2_dev_free(struct snd_device *device);
103 static int snd_aw2_create(struct snd_card *card,
104 struct pci_dev *pci, struct aw2 **rchip);
105 static int snd_aw2_probe(struct pci_dev *pci,
106 const struct pci_device_id *pci_id);
107 static void snd_aw2_remove(struct pci_dev *pci);
108 static int snd_aw2_pcm_playback_open(struct snd_pcm_substream *substream);
109 static int snd_aw2_pcm_playback_close(struct snd_pcm_substream *substream);
110 static int snd_aw2_pcm_capture_open(struct snd_pcm_substream *substream);
111 static int snd_aw2_pcm_capture_close(struct snd_pcm_substream *substream);
112 static int snd_aw2_pcm_hw_params(struct snd_pcm_substream *substream,
113 struct snd_pcm_hw_params *hw_params);
114 static int snd_aw2_pcm_hw_free(struct snd_pcm_substream *substream);
115 static int snd_aw2_pcm_prepare_playback(struct snd_pcm_substream *substream);
116 static int snd_aw2_pcm_prepare_capture(struct snd_pcm_substream *substream);
117 static int snd_aw2_pcm_trigger_playback(struct snd_pcm_substream *substream,
118 int cmd);
119 static int snd_aw2_pcm_trigger_capture(struct snd_pcm_substream *substream,
120 int cmd);
121 static snd_pcm_uframes_t snd_aw2_pcm_pointer_playback(struct snd_pcm_substream
122 *substream);
123 static snd_pcm_uframes_t snd_aw2_pcm_pointer_capture(struct snd_pcm_substream
124 *substream);
125 static int snd_aw2_new_pcm(struct aw2 *chip);
126
127 static int snd_aw2_control_switch_capture_info(struct snd_kcontrol *kcontrol,
128 struct snd_ctl_elem_info *uinfo);
129 static int snd_aw2_control_switch_capture_get(struct snd_kcontrol *kcontrol,
130 struct snd_ctl_elem_value
131 *ucontrol);
132 static int snd_aw2_control_switch_capture_put(struct snd_kcontrol *kcontrol,
133 struct snd_ctl_elem_value
134 *ucontrol);
135
136
137
138
139 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
140 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
141 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
142
143 module_param_array(index, int, NULL, 0444);
144 MODULE_PARM_DESC(index, "Index value for Audiowerk2 soundcard.");
145 module_param_array(id, charp, NULL, 0444);
146 MODULE_PARM_DESC(id, "ID string for the Audiowerk2 soundcard.");
147 module_param_array(enable, bool, NULL, 0444);
148 MODULE_PARM_DESC(enable, "Enable Audiowerk2 soundcard.");
149
150 static const struct pci_device_id snd_aw2_ids[] = {
151 {PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA7146, 0, 0,
152 0, 0, 0},
153 {0}
154 };
155
156 MODULE_DEVICE_TABLE(pci, snd_aw2_ids);
157
158
159 static struct pci_driver aw2_driver = {
160 .name = KBUILD_MODNAME,
161 .id_table = snd_aw2_ids,
162 .probe = snd_aw2_probe,
163 .remove = snd_aw2_remove,
164 };
165
166 module_pci_driver(aw2_driver);
167
168
169 static const struct snd_pcm_ops snd_aw2_playback_ops = {
170 .open = snd_aw2_pcm_playback_open,
171 .close = snd_aw2_pcm_playback_close,
172 .ioctl = snd_pcm_lib_ioctl,
173 .hw_params = snd_aw2_pcm_hw_params,
174 .hw_free = snd_aw2_pcm_hw_free,
175 .prepare = snd_aw2_pcm_prepare_playback,
176 .trigger = snd_aw2_pcm_trigger_playback,
177 .pointer = snd_aw2_pcm_pointer_playback,
178 };
179
180
181 static const struct snd_pcm_ops snd_aw2_capture_ops = {
182 .open = snd_aw2_pcm_capture_open,
183 .close = snd_aw2_pcm_capture_close,
184 .ioctl = snd_pcm_lib_ioctl,
185 .hw_params = snd_aw2_pcm_hw_params,
186 .hw_free = snd_aw2_pcm_hw_free,
187 .prepare = snd_aw2_pcm_prepare_capture,
188 .trigger = snd_aw2_pcm_trigger_capture,
189 .pointer = snd_aw2_pcm_pointer_capture,
190 };
191
192 static const struct snd_kcontrol_new aw2_control = {
193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
194 .name = "PCM Capture Route",
195 .index = 0,
196 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
197 .private_value = 0xffff,
198 .info = snd_aw2_control_switch_capture_info,
199 .get = snd_aw2_control_switch_capture_get,
200 .put = snd_aw2_control_switch_capture_put
201 };
202
203
204
205
206
207
208 static int snd_aw2_dev_free(struct snd_device *device)
209 {
210 struct aw2 *chip = device->device_data;
211
212
213 snd_aw2_saa7146_free(&chip->saa7146);
214
215
216 if (chip->irq >= 0)
217 free_irq(chip->irq, (void *)chip);
218
219 iounmap(chip->iobase_virt);
220 pci_release_regions(chip->pci);
221
222 pci_disable_device(chip->pci);
223
224 kfree(chip);
225
226 return 0;
227 }
228
229
230 static int snd_aw2_create(struct snd_card *card,
231 struct pci_dev *pci, struct aw2 **rchip)
232 {
233 struct aw2 *chip;
234 int err;
235 static struct snd_device_ops ops = {
236 .dev_free = snd_aw2_dev_free,
237 };
238
239 *rchip = NULL;
240
241
242 err = pci_enable_device(pci);
243 if (err < 0)
244 return err;
245 pci_set_master(pci);
246
247
248 if ((dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) ||
249 (dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0)) {
250 dev_err(card->dev, "Impossible to set 32bit mask DMA\n");
251 pci_disable_device(pci);
252 return -ENXIO;
253 }
254 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
255 if (chip == NULL) {
256 pci_disable_device(pci);
257 return -ENOMEM;
258 }
259
260
261 chip->card = card;
262 chip->pci = pci;
263 chip->irq = -1;
264
265
266 err = pci_request_regions(pci, "Audiowerk2");
267 if (err < 0) {
268 pci_disable_device(pci);
269 kfree(chip);
270 return err;
271 }
272 chip->iobase_phys = pci_resource_start(pci, 0);
273 chip->iobase_virt =
274 ioremap_nocache(chip->iobase_phys,
275 pci_resource_len(pci, 0));
276
277 if (chip->iobase_virt == NULL) {
278 dev_err(card->dev, "unable to remap memory region");
279 pci_release_regions(pci);
280 pci_disable_device(pci);
281 kfree(chip);
282 return -ENOMEM;
283 }
284
285
286 snd_aw2_saa7146_setup(&chip->saa7146, chip->iobase_virt);
287
288 if (request_irq(pci->irq, snd_aw2_saa7146_interrupt,
289 IRQF_SHARED, KBUILD_MODNAME, chip)) {
290 dev_err(card->dev, "Cannot grab irq %d\n", pci->irq);
291
292 iounmap(chip->iobase_virt);
293 pci_release_regions(chip->pci);
294 pci_disable_device(chip->pci);
295 kfree(chip);
296 return -EBUSY;
297 }
298 chip->irq = pci->irq;
299
300 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
301 if (err < 0) {
302 free_irq(chip->irq, (void *)chip);
303 iounmap(chip->iobase_virt);
304 pci_release_regions(chip->pci);
305 pci_disable_device(chip->pci);
306 kfree(chip);
307 return err;
308 }
309
310 *rchip = chip;
311
312 dev_info(card->dev,
313 "Audiowerk 2 sound card (saa7146 chipset) detected and managed\n");
314 return 0;
315 }
316
317
318 static int snd_aw2_probe(struct pci_dev *pci,
319 const struct pci_device_id *pci_id)
320 {
321 static int dev;
322 struct snd_card *card;
323 struct aw2 *chip;
324 int err;
325
326
327 if (dev >= SNDRV_CARDS)
328 return -ENODEV;
329 if (!enable[dev]) {
330 dev++;
331 return -ENOENT;
332 }
333
334
335 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
336 0, &card);
337 if (err < 0)
338 return err;
339
340
341 err = snd_aw2_create(card, pci, &chip);
342 if (err < 0) {
343 snd_card_free(card);
344 return err;
345 }
346
347
348 mutex_init(&chip->mtx);
349
350 spin_lock_init(&chip->reg_lock);
351
352 strcpy(card->driver, "aw2");
353 strcpy(card->shortname, "Audiowerk2");
354
355 sprintf(card->longname, "%s with SAA7146 irq %i",
356 card->shortname, chip->irq);
357
358
359 snd_aw2_new_pcm(chip);
360
361
362 err = snd_card_register(card);
363 if (err < 0) {
364 snd_card_free(card);
365 return err;
366 }
367
368
369 pci_set_drvdata(pci, card);
370
371 dev++;
372 return 0;
373 }
374
375
376 static void snd_aw2_remove(struct pci_dev *pci)
377 {
378 snd_card_free(pci_get_drvdata(pci));
379 }
380
381
382 static int snd_aw2_pcm_playback_open(struct snd_pcm_substream *substream)
383 {
384 struct snd_pcm_runtime *runtime = substream->runtime;
385
386 dev_dbg(substream->pcm->card->dev, "Playback_open\n");
387 runtime->hw = snd_aw2_playback_hw;
388 return 0;
389 }
390
391
392 static int snd_aw2_pcm_playback_close(struct snd_pcm_substream *substream)
393 {
394 return 0;
395
396 }
397
398 static int snd_aw2_pcm_capture_open(struct snd_pcm_substream *substream)
399 {
400 struct snd_pcm_runtime *runtime = substream->runtime;
401
402 dev_dbg(substream->pcm->card->dev, "Capture_open\n");
403 runtime->hw = snd_aw2_capture_hw;
404 return 0;
405 }
406
407
408 static int snd_aw2_pcm_capture_close(struct snd_pcm_substream *substream)
409 {
410
411 return 0;
412 }
413
414
415 static int snd_aw2_pcm_hw_params(struct snd_pcm_substream *substream,
416 struct snd_pcm_hw_params *hw_params)
417 {
418 return snd_pcm_lib_malloc_pages(substream,
419 params_buffer_bytes(hw_params));
420 }
421
422
423 static int snd_aw2_pcm_hw_free(struct snd_pcm_substream *substream)
424 {
425 return snd_pcm_lib_free_pages(substream);
426 }
427
428
429 static int snd_aw2_pcm_prepare_playback(struct snd_pcm_substream *substream)
430 {
431 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
432 struct aw2 *chip = pcm_device->chip;
433 struct snd_pcm_runtime *runtime = substream->runtime;
434 unsigned long period_size, buffer_size;
435
436 mutex_lock(&chip->mtx);
437
438 period_size = snd_pcm_lib_period_bytes(substream);
439 buffer_size = snd_pcm_lib_buffer_bytes(substream);
440
441 snd_aw2_saa7146_pcm_init_playback(&chip->saa7146,
442 pcm_device->stream_number,
443 runtime->dma_addr, period_size,
444 buffer_size);
445
446
447 snd_aw2_saa7146_define_it_playback_callback(pcm_device->stream_number,
448 (snd_aw2_saa7146_it_cb)
449 snd_pcm_period_elapsed,
450 (void *)substream);
451
452 mutex_unlock(&chip->mtx);
453
454 return 0;
455 }
456
457
458 static int snd_aw2_pcm_prepare_capture(struct snd_pcm_substream *substream)
459 {
460 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
461 struct aw2 *chip = pcm_device->chip;
462 struct snd_pcm_runtime *runtime = substream->runtime;
463 unsigned long period_size, buffer_size;
464
465 mutex_lock(&chip->mtx);
466
467 period_size = snd_pcm_lib_period_bytes(substream);
468 buffer_size = snd_pcm_lib_buffer_bytes(substream);
469
470 snd_aw2_saa7146_pcm_init_capture(&chip->saa7146,
471 pcm_device->stream_number,
472 runtime->dma_addr, period_size,
473 buffer_size);
474
475
476 snd_aw2_saa7146_define_it_capture_callback(pcm_device->stream_number,
477 (snd_aw2_saa7146_it_cb)
478 snd_pcm_period_elapsed,
479 (void *)substream);
480
481 mutex_unlock(&chip->mtx);
482
483 return 0;
484 }
485
486
487 static int snd_aw2_pcm_trigger_playback(struct snd_pcm_substream *substream,
488 int cmd)
489 {
490 int status = 0;
491 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
492 struct aw2 *chip = pcm_device->chip;
493 spin_lock(&chip->reg_lock);
494 switch (cmd) {
495 case SNDRV_PCM_TRIGGER_START:
496 snd_aw2_saa7146_pcm_trigger_start_playback(&chip->saa7146,
497 pcm_device->
498 stream_number);
499 break;
500 case SNDRV_PCM_TRIGGER_STOP:
501 snd_aw2_saa7146_pcm_trigger_stop_playback(&chip->saa7146,
502 pcm_device->
503 stream_number);
504 break;
505 default:
506 status = -EINVAL;
507 }
508 spin_unlock(&chip->reg_lock);
509 return status;
510 }
511
512
513 static int snd_aw2_pcm_trigger_capture(struct snd_pcm_substream *substream,
514 int cmd)
515 {
516 int status = 0;
517 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
518 struct aw2 *chip = pcm_device->chip;
519 spin_lock(&chip->reg_lock);
520 switch (cmd) {
521 case SNDRV_PCM_TRIGGER_START:
522 snd_aw2_saa7146_pcm_trigger_start_capture(&chip->saa7146,
523 pcm_device->
524 stream_number);
525 break;
526 case SNDRV_PCM_TRIGGER_STOP:
527 snd_aw2_saa7146_pcm_trigger_stop_capture(&chip->saa7146,
528 pcm_device->
529 stream_number);
530 break;
531 default:
532 status = -EINVAL;
533 }
534 spin_unlock(&chip->reg_lock);
535 return status;
536 }
537
538
539 static snd_pcm_uframes_t snd_aw2_pcm_pointer_playback(struct snd_pcm_substream
540 *substream)
541 {
542 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
543 struct aw2 *chip = pcm_device->chip;
544 unsigned int current_ptr;
545
546
547 struct snd_pcm_runtime *runtime = substream->runtime;
548 current_ptr =
549 snd_aw2_saa7146_get_hw_ptr_playback(&chip->saa7146,
550 pcm_device->stream_number,
551 runtime->dma_area,
552 runtime->buffer_size);
553
554 return bytes_to_frames(substream->runtime, current_ptr);
555 }
556
557
558 static snd_pcm_uframes_t snd_aw2_pcm_pointer_capture(struct snd_pcm_substream
559 *substream)
560 {
561 struct aw2_pcm_device *pcm_device = snd_pcm_substream_chip(substream);
562 struct aw2 *chip = pcm_device->chip;
563 unsigned int current_ptr;
564
565
566 struct snd_pcm_runtime *runtime = substream->runtime;
567 current_ptr =
568 snd_aw2_saa7146_get_hw_ptr_capture(&chip->saa7146,
569 pcm_device->stream_number,
570 runtime->dma_area,
571 runtime->buffer_size);
572
573 return bytes_to_frames(substream->runtime, current_ptr);
574 }
575
576
577 static int snd_aw2_new_pcm(struct aw2 *chip)
578 {
579 struct snd_pcm *pcm_playback_ana;
580 struct snd_pcm *pcm_playback_num;
581 struct snd_pcm *pcm_capture;
582 struct aw2_pcm_device *pcm_device;
583 int err = 0;
584
585
586
587 err = snd_pcm_new(chip->card, "Audiowerk2 analog playback", 0, 1, 0,
588 &pcm_playback_ana);
589 if (err < 0) {
590 dev_err(chip->card->dev, "snd_pcm_new error (0x%X)\n", err);
591 return err;
592 }
593
594
595 pcm_device = &chip->device_playback[NUM_STREAM_PLAYBACK_ANA];
596
597
598 strcpy(pcm_playback_ana->name, "Analog playback");
599
600 pcm_playback_ana->private_data = pcm_device;
601
602 snd_pcm_set_ops(pcm_playback_ana, SNDRV_PCM_STREAM_PLAYBACK,
603 &snd_aw2_playback_ops);
604
605 pcm_device->pcm = pcm_playback_ana;
606
607
608 pcm_device->chip = chip;
609
610 pcm_device->stream_number = NUM_STREAM_PLAYBACK_ANA;
611
612
613
614 snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana,
615 SNDRV_DMA_TYPE_DEV,
616 snd_dma_pci_data(chip->pci),
617 64 * 1024, 64 * 1024);
618
619 err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0,
620 &pcm_playback_num);
621
622 if (err < 0) {
623 dev_err(chip->card->dev, "snd_pcm_new error (0x%X)\n", err);
624 return err;
625 }
626
627 pcm_device = &chip->device_playback[NUM_STREAM_PLAYBACK_DIG];
628
629
630 strcpy(pcm_playback_num->name, "Digital playback");
631
632 pcm_playback_num->private_data = pcm_device;
633
634 snd_pcm_set_ops(pcm_playback_num, SNDRV_PCM_STREAM_PLAYBACK,
635 &snd_aw2_playback_ops);
636
637 pcm_device->pcm = pcm_playback_num;
638
639
640 pcm_device->chip = chip;
641
642 pcm_device->stream_number = NUM_STREAM_PLAYBACK_DIG;
643
644
645
646 snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num,
647 SNDRV_DMA_TYPE_DEV,
648 snd_dma_pci_data(chip->pci),
649 64 * 1024, 64 * 1024);
650
651 err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1,
652 &pcm_capture);
653
654 if (err < 0) {
655 dev_err(chip->card->dev, "snd_pcm_new error (0x%X)\n", err);
656 return err;
657 }
658
659
660 pcm_device = &chip->device_capture[NUM_STREAM_CAPTURE_ANA];
661
662
663 strcpy(pcm_capture->name, "Capture");
664
665 pcm_capture->private_data = pcm_device;
666
667 snd_pcm_set_ops(pcm_capture, SNDRV_PCM_STREAM_CAPTURE,
668 &snd_aw2_capture_ops);
669
670 pcm_device->pcm = pcm_capture;
671
672
673 pcm_device->chip = chip;
674
675 pcm_device->stream_number = NUM_STREAM_CAPTURE_ANA;
676
677
678
679 snd_pcm_lib_preallocate_pages_for_all(pcm_capture,
680 SNDRV_DMA_TYPE_DEV,
681 snd_dma_pci_data(chip->pci),
682 64 * 1024, 64 * 1024);
683
684
685 err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip));
686 if (err < 0) {
687 dev_err(chip->card->dev, "snd_ctl_add error (0x%X)\n", err);
688 return err;
689 }
690
691 return 0;
692 }
693
694 static int snd_aw2_control_switch_capture_info(struct snd_kcontrol *kcontrol,
695 struct snd_ctl_elem_info *uinfo)
696 {
697 static const char * const texts[2] = {
698 "Analog", "Digital"
699 };
700 return snd_ctl_enum_info(uinfo, 1, 2, texts);
701 }
702
703 static int snd_aw2_control_switch_capture_get(struct snd_kcontrol *kcontrol,
704 struct snd_ctl_elem_value
705 *ucontrol)
706 {
707 struct aw2 *chip = snd_kcontrol_chip(kcontrol);
708 if (snd_aw2_saa7146_is_using_digital_input(&chip->saa7146))
709 ucontrol->value.enumerated.item[0] = CTL_ROUTE_DIGITAL;
710 else
711 ucontrol->value.enumerated.item[0] = CTL_ROUTE_ANALOG;
712 return 0;
713 }
714
715 static int snd_aw2_control_switch_capture_put(struct snd_kcontrol *kcontrol,
716 struct snd_ctl_elem_value
717 *ucontrol)
718 {
719 struct aw2 *chip = snd_kcontrol_chip(kcontrol);
720 int changed = 0;
721 int is_disgital =
722 snd_aw2_saa7146_is_using_digital_input(&chip->saa7146);
723
724 if (((ucontrol->value.integer.value[0] == CTL_ROUTE_DIGITAL)
725 && !is_disgital)
726 || ((ucontrol->value.integer.value[0] == CTL_ROUTE_ANALOG)
727 && is_disgital)) {
728 snd_aw2_saa7146_use_digital_input(&chip->saa7146, !is_disgital);
729 changed = 1;
730 }
731 return changed;
732 }