47 for (i = 0; i < chip->
model.dac_channels_mixer; ++
i)
62 for (i = 0; i < chip->
model.dac_channels_mixer; ++
i)
68 chip->
model.update_dac_volume(chip);
94 chip->
model.update_dac_mute(chip);
100 static unsigned int upmix_item_count(
struct oxygen *chip)
102 if (chip->
model.dac_channels_pcm < 8)
104 else if (chip->
model.update_center_lfe_mix)
112 static const char *
const names[5] = {
115 "Front+Surround+Back",
116 "Front+Surround+Center/LFE",
117 "Front+Surround+Center/LFE+Back",
120 unsigned int count = upmix_item_count(chip);
138 static const unsigned int reg_values[5] = {
166 unsigned int reg_value;
183 if (chip->
model.adjust_dac_routing)
184 reg_value = chip->
model.adjust_dac_routing(chip, reg_value);
190 if (chip->
model.update_center_lfe_mix)
197 unsigned int count = upmix_item_count(chip);
200 if (value->
value.enumerated.item[0] >= count)
223 static unsigned int oxygen_spdif_rate(
unsigned int oxygen_rate)
225 switch (oxygen_rate) {
247 u32 old_control, new_control;
248 u16 old_routing, new_routing;
249 unsigned int oxygen_rate;
271 new_routing = old_routing;
274 if (old_routing != new_routing) {
281 oxygen_spdif_rate(oxygen_rate) |
314 value->
value.iec958.status[0] =
317 value->
value.iec958.status[1] =
325 bits = value->
value.iec958.status[0] &
334 static inline void write_spdif_bits(
struct oxygen *chip,
u32 bits)
363 new_bits = iec958_to_oxygen(value);
369 write_spdif_bits(chip, new_bits);
380 value->
value.iec958.status[1] =
403 new_bits = iec958_to_oxygen(value);
409 write_spdif_bits(chip, new_bits);
415 static int spdif_input_mask_get(
struct snd_kcontrol *ctl,
418 value->
value.iec958.status[0] = 0xff;
419 value->
value.iec958.status[1] = 0xff;
420 value->
value.iec958.status[2] = 0xff;
421 value->
value.iec958.status[3] = 0xff;
425 static int spdif_input_default_get(
struct snd_kcontrol *ctl,
433 value->
value.iec958.status[1] = bits >> 8;
434 value->
value.iec958.status[2] = bits >> 16;
435 value->
value.iec958.status[3] = bits >> 24;
439 static int spdif_bit_switch_get(
struct snd_kcontrol *ctl,
445 value->
value.integer.value[0] =
450 static int spdif_bit_switch_put(
struct snd_kcontrol *ctl,
460 if (value->
value.integer.value[0])
461 newreg = oldreg |
bit;
463 newreg = oldreg & ~bit;
464 changed = newreg != oldreg;
471 static int monitor_volume_info(
struct snd_kcontrol *ctl,
488 value->
value.integer.value[0] =
504 if ((!!value->
value.integer.value[0] ^ !!invert) != 0)
505 newreg = oldreg |
bit;
507 newreg = oldreg & ~bit;
508 changed = newreg != oldreg;
528 if (!(reg & (1 << bitnr)) ^ !invert)
529 value->
value.integer.value[0] = 1;
531 value->
value.integer.value[0] = 0;
535 static void mute_ac97_ctl(
struct oxygen *chip,
unsigned int control)
537 unsigned int priv_idx;
544 if (!(value & 0x8000)) {
546 if (chip->
model.ac97_switch)
547 chip->
model.ac97_switch(chip, priv_idx, 0x8000);
567 if (!value->
value.integer.value[0] ^ !invert)
568 newreg |= 1 << bitnr;
570 newreg &= ~(1 << bitnr);
571 change = newreg != oldreg;
574 if (codec == 0 && chip->
model.ac97_switch)
575 chip->
model.ac97_switch(chip, index, newreg & 0x8000);
580 if (!(newreg & 0x8000)) {
587 bitnr == 15 && !(newreg & 0x8000)) {
603 info->
count = stereo ? 2 : 1;
622 value->
value.integer.value[0] = 31 - (reg & 0x1f);
624 value->
value.integer.value[0] = 31 - ((reg >> 8) & 0x1f);
625 value->
value.integer.value[1] = 31 - (reg & 0x1f);
643 newreg = oldreg & ~0x1f;
644 newreg |= 31 - (value->
value.integer.value[0] & 0x1f);
646 newreg = oldreg & ~0x1f1f;
647 newreg |= (31 - (value->
value.integer.value[0] & 0x1f)) << 8;
648 newreg |= 31 - (value->
value.integer.value[1] & 0x1f);
650 change = newreg != oldreg;
657 static int mic_fmic_source_info(
struct snd_kcontrol *ctl,
660 static const char *
const names[] = {
"Mic Jack",
"Front Panel" };
665 static int mic_fmic_source_get(
struct snd_kcontrol *ctl,
671 value->
value.enumerated.item[0] =
677 static int mic_fmic_source_put(
struct snd_kcontrol *ctl,
686 if (value->
value.enumerated.item[0])
690 change = newreg != oldreg;
697 static int ac97_fp_rec_volume_info(
struct snd_kcontrol *ctl,
707 static int ac97_fp_rec_volume_get(
struct snd_kcontrol *ctl,
716 value->
value.integer.value[0] = reg & 7;
717 value->
value.integer.value[1] = (reg >> 8) & 7;
721 static int ac97_fp_rec_volume_put(
struct snd_kcontrol *ctl,
730 newreg = oldreg & ~0x0707;
731 newreg = newreg | (value->
value.integer.value[0] & 7);
732 newreg = newreg | ((value->
value.integer.value[0] & 7) << 8);
733 change = newreg != oldreg;
740 #define AC97_SWITCH(xname, codec, index, bitnr, invert) { \
741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
743 .info = snd_ctl_boolean_mono_info, \
744 .get = ac97_switch_get, \
745 .put = ac97_switch_put, \
746 .private_value = ((codec) << 24) | ((invert) << 16) | \
747 ((bitnr) << 8) | (index), \
749 #define AC97_VOLUME(xname, codec, index, stereo) { \
750 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
752 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
753 SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
754 .info = ac97_volume_info, \
755 .get = ac97_volume_get, \
756 .put = ac97_volume_put, \
757 .tlv = { .p = ac97_db_scale, }, \
758 .private_value = ((codec) << 24) | ((stereo) << 16) | (index), \
768 .name =
"Master Playback Volume",
770 .info = dac_volume_info,
771 .get = dac_volume_get,
772 .put = dac_volume_put,
776 .name =
"Master Playback Switch",
783 .name =
"Stereo Upmixing",
792 .get = spdif_switch_get,
793 .put = spdif_switch_put,
800 .get = spdif_default_get,
801 .put = spdif_default_put,
809 .get = spdif_mask_get,
818 .get = spdif_pcm_get,
819 .put = spdif_pcm_put,
830 .get = spdif_input_mask_get,
838 .get = spdif_input_default_get,
844 .get = spdif_bit_switch_get,
845 .put = spdif_bit_switch_put,
852 .get = spdif_bit_switch_get,
853 .put = spdif_bit_switch_put,
858 static const struct {
861 } monitor_controls[] = {
867 .name =
"Analog Input Monitor Playback Switch",
875 .name =
"Analog Input Monitor Playback Volume",
878 .info = monitor_volume_info,
883 .
tlv = { .p = monitor_db_scale, },
892 .name =
"Analog Input Monitor Playback Switch",
900 .name =
"Analog Input Monitor Playback Volume",
903 .info = monitor_volume_info,
908 .
tlv = { .p = monitor_db_scale, },
917 .name =
"Analog Input Monitor Playback Switch",
926 .name =
"Analog Input Monitor Playback Volume",
930 .info = monitor_volume_info,
935 .
tlv = { .p = monitor_db_scale, },
944 .name =
"Digital Input Monitor Playback Switch",
952 .name =
"Digital Input Monitor Playback Volume",
955 .info = monitor_volume_info,
960 .
tlv = { .p = monitor_db_scale, },
972 .name =
"Mic Source Capture Enum",
973 .info = mic_fmic_source_info,
974 .get = mic_fmic_source_get,
975 .put = mic_fmic_source_put,
989 .name =
"Front Panel Capture Volume",
992 .info = ac97_fp_rec_volume_info,
993 .get = ac97_fp_rec_volume_get,
994 .put = ac97_fp_rec_volume_put,
995 .tlv = { .p = ac97_rec_db_scale, },
1000 static void oxygen_any_ctl_free(
struct snd_kcontrol *ctl)
1010 static int add_controls(
struct oxygen *chip,
1029 for (i = 0; i <
count; ++
i) {
1030 template = controls[
i];
1031 if (chip->
model.control_filter) {
1032 err = chip->
model.control_filter(&
template);
1038 if (!
strcmp(
template.
name,
"Stereo Upmixing") &&
1039 chip->
model.dac_channels_pcm == 2)
1041 if (!
strcmp(
template.
name,
"Mic Source Capture Enum") &&
1047 if (!
strcmp(
template.
name,
"Master Playback Volume") &&
1048 chip->
model.dac_tlv) {
1049 template.tlv.p = chip->
model.dac_tlv;
1059 if (!
strcmp(ctl->
id.name, known_ctl_names[j])) {
1072 err = add_controls(chip, controls,
ARRAY_SIZE(controls));
1076 err = add_controls(chip, spdif_input_controls,
1081 for (i = 0; i <
ARRAY_SIZE(monitor_controls); ++
i) {
1082 if (!(chip->
model.device_config & monitor_controls[i].pcm_dev))
1084 err = add_controls(chip, monitor_controls[i].controls,
1090 err = add_controls(chip, ac97_controls,
1096 err = add_controls(chip, ac97_fp_controls,
1101 return chip->
model.mixer_init ? chip->
model.mixer_init(chip) : 0;