xonar_pcm179x.c (973dca93a3d46cca7e4743300f8a510b779906af) xonar_pcm179x.c (4852ad02476ab2bbc874f6f8fda9e677e0f09c87)
1/*
2 * card driver for models with PCM1796 DACs (Xonar D2/D2X/HDAV1.3/ST/STX)
3 *
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 *
6 *
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 2.

--- 251 unchanged lines hidden (view full) ---

260 for (i = 0; i < data->dacs; ++i) {
261 /* set ATLD before ATL/ATR */
262 pcm1796_write(chip, i, 18,
263 data->pcm1796_regs[0][18 - PCM1796_REG_BASE]);
264 pcm1796_write(chip, i, 16, chip->dac_volume[i * 2]
265 + gain_offset);
266 pcm1796_write(chip, i, 17, chip->dac_volume[i * 2 + 1]
267 + gain_offset);
1/*
2 * card driver for models with PCM1796 DACs (Xonar D2/D2X/HDAV1.3/ST/STX)
3 *
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 *
6 *
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 2.

--- 251 unchanged lines hidden (view full) ---

260 for (i = 0; i < data->dacs; ++i) {
261 /* set ATLD before ATL/ATR */
262 pcm1796_write(chip, i, 18,
263 data->pcm1796_regs[0][18 - PCM1796_REG_BASE]);
264 pcm1796_write(chip, i, 16, chip->dac_volume[i * 2]
265 + gain_offset);
266 pcm1796_write(chip, i, 17, chip->dac_volume[i * 2 + 1]
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 data->pcm1796_regs[0][20 - PCM1796_REG_BASE]);
271 pcm1796_write(chip, i, 21, 0);
272 }
273}
274
275static void pcm1796_init(struct oxygen *chip)
276{
277 struct xonar_pcm179x *data = chip->model_data;
278
279 data->pcm1796_regs[0][18 - PCM1796_REG_BASE] = PCM1796_MUTE |
280 PCM1796_DMF_DISABLED | PCM1796_FMT_24_LJUST | PCM1796_ATLD;
270 pcm1796_write(chip, i, 20,
271 data->pcm1796_regs[0][20 - PCM1796_REG_BASE]);
272 pcm1796_write(chip, i, 21, 0);
273 }
274}
275
276static void pcm1796_init(struct oxygen *chip)
277{
278 struct xonar_pcm179x *data = chip->model_data;
279
280 data->pcm1796_regs[0][18 - PCM1796_REG_BASE] = PCM1796_MUTE |
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;
282 pcm1796_registers_init(chip);
283 data->current_rate = 48000;
284}
285
286static void xonar_d2_init(struct oxygen *chip)
287{
288 struct xonar_pcm179x *data = chip->model_data;

--- 348 unchanged lines hidden (view full) ---

637 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
638 .name = "Analog Loopback Switch",
639 .info = snd_ctl_boolean_mono_info,
640 .get = xonar_gpio_bit_switch_get,
641 .put = xonar_gpio_bit_switch_put,
642 .private_value = GPIO_D2_ALT,
643};
644
284 data->pcm1796_regs[0][20 - PCM1796_REG_BASE] = PCM1796_OS_64;
285 pcm1796_registers_init(chip);
286 data->current_rate = 48000;
287}
288
289static void xonar_d2_init(struct oxygen *chip)
290{
291 struct xonar_pcm179x *data = chip->model_data;

--- 348 unchanged lines hidden (view full) ---

640 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
641 .name = "Analog Loopback Switch",
642 .info = snd_ctl_boolean_mono_info,
643 .get = xonar_gpio_bit_switch_get,
644 .put = xonar_gpio_bit_switch_put,
645 .private_value = GPIO_D2_ALT,
646};
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)
646{
647 static const char *const names[2] = { "64x", "128x" };
648
649 info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
650 info->count = 1;
651 info->value.enumerated.items = 2;
652 if (info->value.enumerated.item >= 2)

--- 200 unchanged lines hidden (view full) ---

853
854static int xonar_st_control_filter(struct snd_kcontrol_new *template)
855{
856 if (!strncmp(template->name, "CD Capture ", 11))
857 return 1; /* no CD input */
858 return 0;
859}
860
709static int os_128_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info)
710{
711 static const char *const names[2] = { "64x", "128x" };
712
713 info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
714 info->count = 1;
715 info->value.enumerated.items = 2;
716 if (info->value.enumerated.item >= 2)

--- 200 unchanged lines hidden (view full) ---

917
918static int xonar_st_control_filter(struct snd_kcontrol_new *template)
919{
920 if (!strncmp(template->name, "CD Capture ", 11))
921 return 1; /* no CD input */
922 return 0;
923}
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)
862{
863 int err;
864
865 err = snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip));
866 if (err < 0)
867 return err;
938static int xonar_d2_mixer_init(struct oxygen *chip)
939{
940 int err;
941
942 err = snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip));
943 if (err < 0)
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)
870 return err;
871 return 0;
872}
873
874static int xonar_hdav_mixer_init(struct oxygen *chip)
875{
946 if (err < 0)
947 return err;
948 return 0;
949}
950
951static int xonar_hdav_mixer_init(struct oxygen *chip)
952{
876 return snd_ctl_add(chip->card, snd_ctl_new1(&os_128_control, chip));
953 return add_pcm1796_controls(chip);
877}
878
879static int xonar_st_mixer_init(struct oxygen *chip)
880{
881 unsigned int i;
882 int err;
883
884 for (i = 0; i < ARRAY_SIZE(st_controls); ++i) {
885 err = snd_ctl_add(chip->card,
886 snd_ctl_new1(&st_controls[i], chip));
887 if (err < 0)
888 return err;
889 }
954}
955
956static int xonar_st_mixer_init(struct oxygen *chip)
957{
958 unsigned int i;
959 int err;
960
961 for (i = 0; i < ARRAY_SIZE(st_controls); ++i) {
962 err = snd_ctl_add(chip->card,
963 snd_ctl_new1(&st_controls[i], chip));
964 if (err < 0)
965 return err;
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)
892 return err;
893 return 0;
894}
895
896static const struct oxygen_model model_xonar_d2 = {
897 .longname = "Asus Virtuoso 200",
898 .chip = "AV200",

--- 140 unchanged lines hidden ---
968 if (err < 0)
969 return err;
970 return 0;
971}
972
973static const struct oxygen_model model_xonar_d2 = {
974 .longname = "Asus Virtuoso 200",
975 .chip = "AV200",

--- 140 unchanged lines hidden ---