aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ca0106
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-25 11:32:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-25 11:32:05 -0400
commit33081adf8b89d5a716d7e1c60171768d39795b39 (patch)
tree275de58bbbb5f7ddffcdc087844cfc7fbe4315be /sound/pci/ca0106
parentc55960499f810357a29659b32d6ea594abee9237 (diff)
parent506ecbca71d07fa327dd986be1682e90885678ee (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6: (365 commits) ALSA: hda - Disable sticky PCM stream assignment for AD codecs ALSA: usb - Creative USB X-Fi volume knob support ALSA: ca0106: Use card specific dac id for mute controls. ALSA: ca0106: Allow different sound cards to use different SPI channel mappings. ALSA: ca0106: Create a nice spot for mapping channels to dacs. ALSA: ca0106: Move enabling of front dac out of hardcoded setup sequence. ALSA: ca0106: Pull out dac powering routine into separate function. ALSA: ca0106 - add Sound Blaster 5.1vx info. ASoC: tlv320dac33: Use usleep_range for delays ALSA: usb-audio: add Novation Launchpad support ALSA: hda - Add workarounds for CT-IBG controllers ALSA: hda - Fix wrong TLV mute bit for STAC/IDT codecs ASoC: tpa6130a2: Error handling for broken chip ASoC: max98088: Staticise m98088_eq_band ASoC: soc-core: Fix codec->name memory leak ALSA: hda - Apply ideapad quirk to Acer laptops with Cxt5066 ALSA: hda - Add some workarounds for Creative IBG ALSA: hda - Fix wrong SPDIF NID assignment for CA0110 ALSA: hda - Fix codec rename rules for ALC662-compatible codecs ALSA: hda - Add alc_init_jacks() call to other codecs ...
Diffstat (limited to 'sound/pci/ca0106')
-rw-r--r--sound/pci/ca0106/ca0106.h5
-rw-r--r--sound/pci/ca0106/ca0106_main.c136
-rw-r--r--sound/pci/ca0106/ca0106_mixer.c93
3 files changed, 166 insertions, 68 deletions
diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h
index 14b8d9a91aae..f19c11077255 100644
--- a/sound/pci/ca0106/ca0106.h
+++ b/sound/pci/ca0106/ca0106.h
@@ -670,8 +670,9 @@ struct snd_ca0106_details {
670 gpio_type = 2 -> shared side-out/line-in. */ 670 gpio_type = 2 -> shared side-out/line-in. */
671 int i2c_adc; /* with i2c_adc=1, the driver adds some capture volume 671 int i2c_adc; /* with i2c_adc=1, the driver adds some capture volume
672 controls, phone, mic, line-in and aux. */ 672 controls, phone, mic, line-in and aux. */
673 int spi_dac; /* spi_dac=1 adds the mute switch for each analog 673 u16 spi_dac; /* spi_dac = 0 -> no spi interface for DACs
674 output, front, rear, etc. */ 674 spi_dac = 0x<front><rear><center-lfe><side>
675 -> specifies DAC id for each channel pair. */
675}; 676};
676 677
677// definition of the chip-specific record 678// definition of the chip-specific record
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 0a3d3d6e77b4..d2d12c08f937 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -227,7 +227,7 @@ static struct snd_ca0106_details ca0106_chip_details[] = {
227 .name = "Audigy SE [SB0570]", 227 .name = "Audigy SE [SB0570]",
228 .gpio_type = 1, 228 .gpio_type = 1,
229 .i2c_adc = 1, 229 .i2c_adc = 1,
230 .spi_dac = 1 } , 230 .spi_dac = 0x4021 } ,
231 /* New Audigy LS. Has a different DAC. */ 231 /* New Audigy LS. Has a different DAC. */
232 /* SB0570: 232 /* SB0570:
233 * CTRL:CA0106-DAT 233 * CTRL:CA0106-DAT
@@ -238,7 +238,17 @@ static struct snd_ca0106_details ca0106_chip_details[] = {
238 .name = "Audigy SE OEM [SB0570a]", 238 .name = "Audigy SE OEM [SB0570a]",
239 .gpio_type = 1, 239 .gpio_type = 1,
240 .i2c_adc = 1, 240 .i2c_adc = 1,
241 .spi_dac = 1 } , 241 .spi_dac = 0x4021 } ,
242 /* Sound Blaster 5.1vx
243 * Tested: Playback on front, rear, center/lfe speakers
244 * Not-Tested: Capture
245 */
246 { .serial = 0x10041102,
247 .name = "Sound Blaster 5.1vx [SB1070]",
248 .gpio_type = 1,
249 .i2c_adc = 0,
250 .spi_dac = 0x0124
251 } ,
242 /* MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97 */ 252 /* MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97 */
243 /* SB0438 253 /* SB0438
244 * CTRL:CA0106-DAT 254 * CTRL:CA0106-DAT
@@ -254,7 +264,7 @@ static struct snd_ca0106_details ca0106_chip_details[] = {
254 .name = "MSI K8N Diamond MB", 264 .name = "MSI K8N Diamond MB",
255 .gpio_type = 2, 265 .gpio_type = 2,
256 .i2c_adc = 1, 266 .i2c_adc = 1,
257 .spi_dac = 1 } , 267 .spi_dac = 0x4021 } ,
258 /* Giga-byte GA-G1975X mobo 268 /* Giga-byte GA-G1975X mobo
259 * Novell bnc#395807 269 * Novell bnc#395807
260 */ 270 */
@@ -483,16 +493,18 @@ static void snd_ca0106_pcm_free_substream(struct snd_pcm_runtime *runtime)
483} 493}
484 494
485static const int spi_dacd_reg[] = { 495static const int spi_dacd_reg[] = {
486 [PCM_FRONT_CHANNEL] = SPI_DACD4_REG, 496 SPI_DACD0_REG,
487 [PCM_REAR_CHANNEL] = SPI_DACD0_REG, 497 SPI_DACD1_REG,
488 [PCM_CENTER_LFE_CHANNEL]= SPI_DACD2_REG, 498 SPI_DACD2_REG,
489 [PCM_UNKNOWN_CHANNEL] = SPI_DACD1_REG, 499 0,
500 SPI_DACD4_REG,
490}; 501};
491static const int spi_dacd_bit[] = { 502static const int spi_dacd_bit[] = {
492 [PCM_FRONT_CHANNEL] = SPI_DACD4_BIT, 503 SPI_DACD0_BIT,
493 [PCM_REAR_CHANNEL] = SPI_DACD0_BIT, 504 SPI_DACD1_BIT,
494 [PCM_CENTER_LFE_CHANNEL]= SPI_DACD2_BIT, 505 SPI_DACD2_BIT,
495 [PCM_UNKNOWN_CHANNEL] = SPI_DACD1_BIT, 506 0,
507 SPI_DACD4_BIT,
496}; 508};
497 509
498static void restore_spdif_bits(struct snd_ca0106 *chip, int idx) 510static void restore_spdif_bits(struct snd_ca0106 *chip, int idx)
@@ -504,6 +516,45 @@ static void restore_spdif_bits(struct snd_ca0106 *chip, int idx)
504 } 516 }
505} 517}
506 518
519static int snd_ca0106_channel_dac(struct snd_ca0106_details *details,
520 int channel_id)
521{
522 switch (channel_id) {
523 case PCM_FRONT_CHANNEL:
524 return (details->spi_dac & 0xf000) >> (4 * 3);
525 case PCM_REAR_CHANNEL:
526 return (details->spi_dac & 0x0f00) >> (4 * 2);
527 case PCM_CENTER_LFE_CHANNEL:
528 return (details->spi_dac & 0x00f0) >> (4 * 1);
529 case PCM_UNKNOWN_CHANNEL:
530 return (details->spi_dac & 0x000f) >> (4 * 0);
531 default:
532 snd_printk(KERN_DEBUG "ca0106: unknown channel_id %d\n",
533 channel_id);
534 }
535 return 0;
536}
537
538static int snd_ca0106_pcm_power_dac(struct snd_ca0106 *chip, int channel_id,
539 int power)
540{
541 if (chip->details->spi_dac) {
542 const int dac = snd_ca0106_channel_dac(chip->details,
543 channel_id);
544 const int reg = spi_dacd_reg[dac];
545 const int bit = spi_dacd_bit[dac];
546
547 if (power)
548 /* Power up */
549 chip->spi_dac_reg[reg] &= ~bit;
550 else
551 /* Power down */
552 chip->spi_dac_reg[reg] |= bit;
553 return snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]);
554 }
555 return 0;
556}
557
507/* open_playback callback */ 558/* open_playback callback */
508static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substream, 559static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substream,
509 int channel_id) 560 int channel_id)
@@ -543,12 +594,9 @@ static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substr
543 return err; 594 return err;
544 snd_pcm_set_sync(substream); 595 snd_pcm_set_sync(substream);
545 596
546 if (chip->details->spi_dac && channel_id != PCM_FRONT_CHANNEL) { 597 /* Front channel dac should already be on */
547 const int reg = spi_dacd_reg[channel_id]; 598 if (channel_id != PCM_FRONT_CHANNEL) {
548 599 err = snd_ca0106_pcm_power_dac(chip, channel_id, 1);
549 /* Power up dac */
550 chip->spi_dac_reg[reg] &= ~spi_dacd_bit[channel_id];
551 err = snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]);
552 if (err < 0) 600 if (err < 0)
553 return err; 601 return err;
554 } 602 }
@@ -568,13 +616,14 @@ static int snd_ca0106_pcm_close_playback(struct snd_pcm_substream *substream)
568 616
569 restore_spdif_bits(chip, epcm->channel_id); 617 restore_spdif_bits(chip, epcm->channel_id);
570 618
571 if (chip->details->spi_dac && epcm->channel_id != PCM_FRONT_CHANNEL) { 619 /* Front channel dac should stay on */
572 const int reg = spi_dacd_reg[epcm->channel_id]; 620 if (epcm->channel_id != PCM_FRONT_CHANNEL) {
573 621 int err;
574 /* Power down DAC */ 622 err = snd_ca0106_pcm_power_dac(chip, epcm->channel_id, 0);
575 chip->spi_dac_reg[reg] |= spi_dacd_bit[epcm->channel_id]; 623 if (err < 0)
576 snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]); 624 return err;
577 } 625 }
626
578 /* FIXME: maybe zero others */ 627 /* FIXME: maybe zero others */
579 return 0; 628 return 0;
580} 629}
@@ -1002,29 +1051,27 @@ snd_ca0106_pcm_pointer_playback(struct snd_pcm_substream *substream)
1002 struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); 1051 struct snd_ca0106 *emu = snd_pcm_substream_chip(substream);
1003 struct snd_pcm_runtime *runtime = substream->runtime; 1052 struct snd_pcm_runtime *runtime = substream->runtime;
1004 struct snd_ca0106_pcm *epcm = runtime->private_data; 1053 struct snd_ca0106_pcm *epcm = runtime->private_data;
1005 snd_pcm_uframes_t ptr, ptr1, ptr2,ptr3,ptr4 = 0; 1054 unsigned int ptr, prev_ptr;
1006 int channel = epcm->channel_id; 1055 int channel = epcm->channel_id;
1056 int timeout = 10;
1007 1057
1008 if (!epcm->running) 1058 if (!epcm->running)
1009 return 0; 1059 return 0;
1010 1060
1011 ptr3 = snd_ca0106_ptr_read(emu, PLAYBACK_LIST_PTR, channel); 1061 prev_ptr = -1;
1012 ptr1 = snd_ca0106_ptr_read(emu, PLAYBACK_POINTER, channel); 1062 do {
1013 ptr4 = snd_ca0106_ptr_read(emu, PLAYBACK_LIST_PTR, channel); 1063 ptr = snd_ca0106_ptr_read(emu, PLAYBACK_LIST_PTR, channel);
1014 if (ptr3 != ptr4) ptr1 = snd_ca0106_ptr_read(emu, PLAYBACK_POINTER, channel); 1064 ptr = (ptr >> 3) * runtime->period_size;
1015 ptr2 = bytes_to_frames(runtime, ptr1); 1065 ptr += bytes_to_frames(runtime,
1016 ptr2+= (ptr4 >> 3) * runtime->period_size; 1066 snd_ca0106_ptr_read(emu, PLAYBACK_POINTER, channel));
1017 ptr=ptr2; 1067 if (ptr >= runtime->buffer_size)
1018 if (ptr >= runtime->buffer_size) 1068 ptr -= runtime->buffer_size;
1019 ptr -= runtime->buffer_size; 1069 if (prev_ptr == ptr)
1020 /* 1070 return ptr;
1021 printk(KERN_DEBUG "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, " 1071 prev_ptr = ptr;
1022 "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", 1072 } while (--timeout);
1023 ptr1, ptr2, ptr, (int)runtime->buffer_size, 1073 snd_printk(KERN_WARNING "ca0106: unstable DMA pointer!\n");
1024 (int)runtime->period_size, (int)runtime->frame_bits, 1074 return 0;
1025 (int)runtime->rate);
1026 */
1027 return ptr;
1028} 1075}
1029 1076
1030/* pointer_capture callback */ 1077/* pointer_capture callback */
@@ -1362,7 +1409,7 @@ static unsigned int spi_dac_init[] = {
1362 SPI_REG(12, 0x00), 1409 SPI_REG(12, 0x00),
1363 SPI_REG(SPI_LDA4_REG, SPI_DA_BIT_0dB), 1410 SPI_REG(SPI_LDA4_REG, SPI_DA_BIT_0dB),
1364 SPI_REG(SPI_RDA4_REG, SPI_DA_BIT_0dB | SPI_DA_BIT_UPDATE), 1411 SPI_REG(SPI_RDA4_REG, SPI_DA_BIT_0dB | SPI_DA_BIT_UPDATE),
1365 SPI_REG(SPI_DACD4_REG, 0x00), 1412 SPI_REG(SPI_DACD4_REG, SPI_DACD4_BIT),
1366}; 1413};
1367 1414
1368static unsigned int i2c_adc_init[][2] = { 1415static unsigned int i2c_adc_init[][2] = {
@@ -1541,7 +1588,7 @@ static void ca0106_init_chip(struct snd_ca0106 *chip, int resume)
1541 /* snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); */ 1588 /* snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); */
1542 } 1589 }
1543 1590
1544 if (chip->details->spi_dac == 1) { 1591 if (chip->details->spi_dac) {
1545 /* The SB0570 use SPI to control DAC. */ 1592 /* The SB0570 use SPI to control DAC. */
1546 int size, n; 1593 int size, n;
1547 1594
@@ -1553,6 +1600,9 @@ static void ca0106_init_chip(struct snd_ca0106 *chip, int resume)
1553 if (reg < ARRAY_SIZE(chip->spi_dac_reg)) 1600 if (reg < ARRAY_SIZE(chip->spi_dac_reg))
1554 chip->spi_dac_reg[reg] = spi_dac_init[n]; 1601 chip->spi_dac_reg[reg] = spi_dac_init[n];
1555 } 1602 }
1603
1604 /* Enable front dac only */
1605 snd_ca0106_pcm_power_dac(chip, PCM_FRONT_CHANNEL, 1);
1556 } 1606 }
1557} 1607}
1558 1608
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c
index 85fd315d9999..630aa4998189 100644
--- a/sound/pci/ca0106/ca0106_mixer.c
+++ b/sound/pci/ca0106/ca0106_mixer.c
@@ -676,28 +676,65 @@ static struct snd_kcontrol_new snd_ca0106_volume_i2c_adc_ctls[] __devinitdata =
676 I2C_VOLUME("Aux Capture Volume", 3), 676 I2C_VOLUME("Aux Capture Volume", 3),
677}; 677};
678 678
679#define SPI_SWITCH(xname,reg,bit) \ 679static const int spi_dmute_reg[] = {
680{ \ 680 SPI_DMUTE0_REG,
681 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 681 SPI_DMUTE1_REG,
682 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ 682 SPI_DMUTE2_REG,
683 .info = spi_mute_info, \ 683 0,
684 .get = spi_mute_get, \ 684 SPI_DMUTE4_REG,
685 .put = spi_mute_put, \ 685};
686 .private_value = (reg<<SPI_REG_SHIFT) | (bit) \ 686static const int spi_dmute_bit[] = {
687} 687 SPI_DMUTE0_BIT,
688 688 SPI_DMUTE1_BIT,
689static struct snd_kcontrol_new snd_ca0106_volume_spi_dac_ctls[] 689 SPI_DMUTE2_BIT,
690__devinitdata = { 690 0,
691 SPI_SWITCH("Analog Front Playback Switch", 691 SPI_DMUTE4_BIT,
692 SPI_DMUTE4_REG, SPI_DMUTE4_BIT),
693 SPI_SWITCH("Analog Rear Playback Switch",
694 SPI_DMUTE0_REG, SPI_DMUTE0_BIT),
695 SPI_SWITCH("Analog Center/LFE Playback Switch",
696 SPI_DMUTE2_REG, SPI_DMUTE2_BIT),
697 SPI_SWITCH("Analog Side Playback Switch",
698 SPI_DMUTE1_REG, SPI_DMUTE1_BIT),
699}; 692};
700 693
694static struct snd_kcontrol_new __devinit
695snd_ca0106_volume_spi_dac_ctl(struct snd_ca0106_details *details,
696 int channel_id)
697{
698 struct snd_kcontrol_new spi_switch = {0};
699 int reg, bit;
700 int dac_id;
701
702 spi_switch.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
703 spi_switch.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
704 spi_switch.info = spi_mute_info;
705 spi_switch.get = spi_mute_get;
706 spi_switch.put = spi_mute_put;
707
708 switch (channel_id) {
709 case PCM_FRONT_CHANNEL:
710 spi_switch.name = "Analog Front Playback Switch";
711 dac_id = (details->spi_dac & 0xf000) >> (4 * 3);
712 break;
713 case PCM_REAR_CHANNEL:
714 spi_switch.name = "Analog Rear Playback Switch";
715 dac_id = (details->spi_dac & 0x0f00) >> (4 * 2);
716 break;
717 case PCM_CENTER_LFE_CHANNEL:
718 spi_switch.name = "Analog Center/LFE Playback Switch";
719 dac_id = (details->spi_dac & 0x00f0) >> (4 * 1);
720 break;
721 case PCM_UNKNOWN_CHANNEL:
722 spi_switch.name = "Analog Side Playback Switch";
723 dac_id = (details->spi_dac & 0x000f) >> (4 * 0);
724 break;
725 default:
726 /* Unused channel */
727 spi_switch.name = NULL;
728 dac_id = 0;
729 }
730 reg = spi_dmute_reg[dac_id];
731 bit = spi_dmute_bit[dac_id];
732
733 spi_switch.private_value = (reg << SPI_REG_SHIFT) | bit;
734
735 return spi_switch;
736}
737
701static int __devinit remove_ctl(struct snd_card *card, const char *name) 738static int __devinit remove_ctl(struct snd_card *card, const char *name)
702{ 739{
703 struct snd_ctl_elem_id id; 740 struct snd_ctl_elem_id id;
@@ -832,8 +869,18 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
832 if (err < 0) 869 if (err < 0)
833 return err; 870 return err;
834 } 871 }
835 if (emu->details->spi_dac == 1) 872 if (emu->details->spi_dac) {
836 ADD_CTLS(emu, snd_ca0106_volume_spi_dac_ctls); 873 int i;
874 for (i = 0;; i++) {
875 struct snd_kcontrol_new ctl;
876 ctl = snd_ca0106_volume_spi_dac_ctl(emu->details, i);
877 if (!ctl.name)
878 break;
879 err = snd_ctl_add(card, snd_ctl_new1(&ctl, emu));
880 if (err < 0)
881 return err;
882 }
883 }
837 884
838 /* Create virtual master controls */ 885 /* Create virtual master controls */
839 vmaster = snd_ctl_make_virtual_master("Master Playback Volume", 886 vmaster = snd_ctl_make_virtual_master("Master Playback Volume",
@@ -845,7 +892,7 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
845 return err; 892 return err;
846 add_slaves(card, vmaster, slave_vols); 893 add_slaves(card, vmaster, slave_vols);
847 894
848 if (emu->details->spi_dac == 1) { 895 if (emu->details->spi_dac) {
849 vmaster = snd_ctl_make_virtual_master("Master Playback Switch", 896 vmaster = snd_ctl_make_virtual_master("Master Playback Switch",
850 NULL); 897 NULL);
851 if (!vmaster) 898 if (!vmaster)