aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/oxygen/xonar_pcm179x.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/oxygen/xonar_pcm179x.c')
-rw-r--r--sound/pci/oxygen/xonar_pcm179x.c85
1 files changed, 81 insertions, 4 deletions
diff --git a/sound/pci/oxygen/xonar_pcm179x.c b/sound/pci/oxygen/xonar_pcm179x.c
index 7f153fb1848d..ba18fb546b4f 100644
--- a/sound/pci/oxygen/xonar_pcm179x.c
+++ b/sound/pci/oxygen/xonar_pcm179x.c
@@ -265,7 +265,8 @@ static void pcm1796_registers_init(struct oxygen *chip)
265 + gain_offset); 265 + gain_offset);
266 pcm1796_write(chip, i, 17, chip->dac_volume[i * 2 + 1] 266 pcm1796_write(chip, i, 17, chip->dac_volume[i * 2 + 1]
267 + gain_offset); 267 + gain_offset);
268 pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1); 268 pcm1796_write(chip, i, 19,
269 data->pcm1796_regs[0][19 - PCM1796_REG_BASE]);
269 pcm1796_write(chip, i, 20, 270 pcm1796_write(chip, i, 20,
270 data->pcm1796_regs[0][20 - PCM1796_REG_BASE]); 271 data->pcm1796_regs[0][20 - PCM1796_REG_BASE]);
271 pcm1796_write(chip, i, 21, 0); 272 pcm1796_write(chip, i, 21, 0);
@@ -278,6 +279,8 @@ static void pcm1796_init(struct oxygen *chip)
278 279
279 data->pcm1796_regs[0][18 - PCM1796_REG_BASE] = PCM1796_MUTE | 280 data->pcm1796_regs[0][18 - PCM1796_REG_BASE] = PCM1796_MUTE |
280 PCM1796_DMF_DISABLED | PCM1796_FMT_24_LJUST | PCM1796_ATLD; 281 PCM1796_DMF_DISABLED | PCM1796_FMT_24_LJUST | PCM1796_ATLD;
282 data->pcm1796_regs[0][19 - PCM1796_REG_BASE] =
283 PCM1796_FLT_SHARP | PCM1796_ATS_1;
281 data->pcm1796_regs[0][20 - PCM1796_REG_BASE] = PCM1796_OS_64; 284 data->pcm1796_regs[0][20 - PCM1796_REG_BASE] = PCM1796_OS_64;
282 pcm1796_registers_init(chip); 285 pcm1796_registers_init(chip);
283 data->current_rate = 48000; 286 data->current_rate = 48000;
@@ -642,6 +645,67 @@ static const struct snd_kcontrol_new alt_switch = {
642 .private_value = GPIO_D2_ALT, 645 .private_value = GPIO_D2_ALT,
643}; 646};
644 647
648static int rolloff_info(struct snd_kcontrol *ctl,
649 struct snd_ctl_elem_info *info)
650{
651 static const char *const names[2] = {
652 "Sharp Roll-off", "Slow Roll-off"
653 };
654
655 info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
656 info->count = 1;
657 info->value.enumerated.items = 2;
658 if (info->value.enumerated.item >= 2)
659 info->value.enumerated.item = 1;
660 strcpy(info->value.enumerated.name, names[info->value.enumerated.item]);
661 return 0;
662}
663
664static int rolloff_get(struct snd_kcontrol *ctl,
665 struct snd_ctl_elem_value *value)
666{
667 struct oxygen *chip = ctl->private_data;
668 struct xonar_pcm179x *data = chip->model_data;
669
670 value->value.enumerated.item[0] =
671 (data->pcm1796_regs[0][19 - PCM1796_REG_BASE] &
672 PCM1796_FLT_MASK) != PCM1796_FLT_SHARP;
673 return 0;
674}
675
676static int rolloff_put(struct snd_kcontrol *ctl,
677 struct snd_ctl_elem_value *value)
678{
679 struct oxygen *chip = ctl->private_data;
680 struct xonar_pcm179x *data = chip->model_data;
681 unsigned int i;
682 int changed;
683 u8 reg;
684
685 mutex_lock(&chip->mutex);
686 reg = data->pcm1796_regs[0][19 - PCM1796_REG_BASE];
687 reg &= ~PCM1796_FLT_MASK;
688 if (!value->value.enumerated.item[0])
689 reg |= PCM1796_FLT_SHARP;
690 else
691 reg |= PCM1796_FLT_SLOW;
692 changed = reg != data->pcm1796_regs[0][19 - PCM1796_REG_BASE];
693 if (changed) {
694 for (i = 0; i < data->dacs; ++i)
695 pcm1796_write(chip, i, 19, reg);
696 }
697 mutex_unlock(&chip->mutex);
698 return changed;
699}
700
701static const struct snd_kcontrol_new rolloff_control = {
702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
703 .name = "DAC Filter Playback Enum",
704 .info = rolloff_info,
705 .get = rolloff_get,
706 .put = rolloff_put,
707};
708
645static int os_128_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info) 709static int os_128_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info)
646{ 710{
647 static const char *const names[2] = { "64x", "128x" }; 711 static const char *const names[2] = { "64x", "128x" };
@@ -858,6 +922,19 @@ static int xonar_st_control_filter(struct snd_kcontrol_new *template)
858 return 0; 922 return 0;
859} 923}
860 924
925static int add_pcm1796_controls(struct oxygen *chip)
926{
927 int err;
928
929 err = snd_ctl_add(chip->card, snd_ctl_new1(&rolloff_control, chip));
930 if (err < 0)
931 return err;
932 err = snd_ctl_add(chip->card, snd_ctl_new1(&os_128_control, chip));
933 if (err < 0)
934 return err;
935 return 0;
936}
937
861static int xonar_d2_mixer_init(struct oxygen *chip) 938static int xonar_d2_mixer_init(struct oxygen *chip)
862{ 939{
863 int err; 940 int err;
@@ -865,7 +942,7 @@ static int xonar_d2_mixer_init(struct oxygen *chip)
865 err = snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip)); 942 err = snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip));
866 if (err < 0) 943 if (err < 0)
867 return err; 944 return err;
868 err = snd_ctl_add(chip->card, snd_ctl_new1(&os_128_control, chip)); 945 err = add_pcm1796_controls(chip);
869 if (err < 0) 946 if (err < 0)
870 return err; 947 return err;
871 return 0; 948 return 0;
@@ -873,7 +950,7 @@ static int xonar_d2_mixer_init(struct oxygen *chip)
873 950
874static int xonar_hdav_mixer_init(struct oxygen *chip) 951static int xonar_hdav_mixer_init(struct oxygen *chip)
875{ 952{
876 return snd_ctl_add(chip->card, snd_ctl_new1(&os_128_control, chip)); 953 return add_pcm1796_controls(chip);
877} 954}
878 955
879static int xonar_st_mixer_init(struct oxygen *chip) 956static int xonar_st_mixer_init(struct oxygen *chip)
@@ -887,7 +964,7 @@ static int xonar_st_mixer_init(struct oxygen *chip)
887 if (err < 0) 964 if (err < 0)
888 return err; 965 return err;
889 } 966 }
890 err = snd_ctl_add(chip->card, snd_ctl_new1(&os_128_control, chip)); 967 err = add_pcm1796_controls(chip);
891 if (err < 0) 968 if (err < 0)
892 return err; 969 return err;
893 return 0; 970 return 0;