Lines Matching +full:codec +full:- +full:analog +full:- +full:controls

1 // SPDX-License-Identifier: GPL-2.0-only
3 * C-Media CMI8788 driver - mixer code
19 struct oxygen *chip = ctl->private_data;
21 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
22 info->count = chip->model.dac_channels_mixer;
23 info->value.integer.min = chip->model.dac_volume_min;
24 info->value.integer.max = chip->model.dac_volume_max;
31 struct oxygen *chip = ctl->private_data;
34 guard(mutex)(&chip->mutex);
35 for (i = 0; i < chip->model.dac_channels_mixer; ++i)
36 value->value.integer.value[i] = chip->dac_volume[i];
43 struct oxygen *chip = ctl->private_data;
48 guard(mutex)(&chip->mutex);
49 for (i = 0; i < chip->model.dac_channels_mixer; ++i)
50 if (value->value.integer.value[i] != chip->dac_volume[i]) {
51 chip->dac_volume[i] = value->value.integer.value[i];
55 chip->model.update_dac_volume(chip);
62 struct oxygen *chip = ctl->private_data;
64 guard(mutex)(&chip->mutex);
65 value->value.integer.value[0] = !chip->dac_mute;
72 struct oxygen *chip = ctl->private_data;
75 guard(mutex)(&chip->mutex);
76 changed = (!value->value.integer.value[0]) != chip->dac_mute;
78 chip->dac_mute = !value->value.integer.value[0];
79 chip->model.update_dac_mute(chip);
86 if (chip->model.dac_channels_pcm < 8)
88 else if (chip->model.update_center_lfe_mix)
103 struct oxygen *chip = ctl->private_data;
111 struct oxygen *chip = ctl->private_data;
113 guard(mutex)(&chip->mutex);
114 value->value.enumerated.item[0] = chip->dac_routing;
122 /* stereo -> front */
127 /* stereo -> front+surround */
132 /* stereo -> front+surround+back */
137 /* stereo -> front+surround+center/LFE */
142 /* stereo -> front+surround+center/LFE+back */
154 reg_value = reg_values[chip->dac_routing];
166 if (chip->model.adjust_dac_routing)
167 reg_value = chip->model.adjust_dac_routing(chip, reg_value);
173 if (chip->model.update_center_lfe_mix)
174 chip->model.update_center_lfe_mix(chip, chip->dac_routing > 2);
180 struct oxygen *chip = ctl->private_data;
184 if (value->value.enumerated.item[0] >= count)
185 return -EINVAL;
186 guard(mutex)(&chip->mutex);
187 changed = value->value.enumerated.item[0] != chip->dac_routing;
189 chip->dac_routing = value->value.enumerated.item[0];
198 struct oxygen *chip = ctl->private_data;
200 guard(mutex)(&chip->mutex);
201 value->value.integer.value[0] = chip->spdif_playback_enable;
235 if (chip->pcm_active & (1 << PCM_SPDIF)) {
242 } else if ((chip->pcm_active & (1 << PCM_MULTICH)) &&
243 chip->spdif_playback_enable) {
264 ((chip->pcm_active & (1 << PCM_SPDIF)) ?
265 chip->spdif_pcm_bits : chip->spdif_bits));
272 struct oxygen *chip = ctl->private_data;
275 guard(mutex)(&chip->mutex);
276 changed = value->value.integer.value[0] != chip->spdif_playback_enable;
278 chip->spdif_playback_enable = !!value->value.integer.value[0];
279 spin_lock_irq(&chip->reg_lock);
281 spin_unlock_irq(&chip->reg_lock);
288 info->type = SNDRV_CTL_ELEM_TYPE_IEC958;
289 info->count = 1;
295 value->value.iec958.status[0] =
298 value->value.iec958.status[1] = /* category and original */
306 bits = value->value.iec958.status[0] &
309 bits |= value->value.iec958.status[1] << OXYGEN_SPDIF_CATEGORY_SHIFT;
329 struct oxygen *chip = ctl->private_data;
331 guard(mutex)(&chip->mutex);
332 oxygen_to_iec958(chip->spdif_bits, value);
339 struct oxygen *chip = ctl->private_data;
344 guard(mutex)(&chip->mutex);
345 changed = new_bits != chip->spdif_bits;
347 chip->spdif_bits = new_bits;
348 if (!(chip->pcm_active & (1 << PCM_SPDIF)))
357 value->value.iec958.status[0] = IEC958_AES0_NONAUDIO |
359 value->value.iec958.status[1] =
367 struct oxygen *chip = ctl->private_data;
369 guard(mutex)(&chip->mutex);
370 oxygen_to_iec958(chip->spdif_pcm_bits, value);
377 struct oxygen *chip = ctl->private_data;
382 guard(mutex)(&chip->mutex);
383 changed = new_bits != chip->spdif_pcm_bits;
385 chip->spdif_pcm_bits = new_bits;
386 if (chip->pcm_active & (1 << PCM_SPDIF))
395 value->value.iec958.status[0] = 0xff;
396 value->value.iec958.status[1] = 0xff;
397 value->value.iec958.status[2] = 0xff;
398 value->value.iec958.status[3] = 0xff;
405 struct oxygen *chip = ctl->private_data;
409 value->value.iec958.status[0] = bits;
410 value->value.iec958.status[1] = bits >> 8;
411 value->value.iec958.status[2] = bits >> 16;
412 value->value.iec958.status[3] = bits >> 24;
419 struct oxygen *chip = ctl->private_data;
420 u32 bit = ctl->private_value;
422 value->value.integer.value[0] =
430 struct oxygen *chip = ctl->private_data;
431 u32 bit = ctl->private_value;
435 guard(spinlock_irq)(&chip->reg_lock);
437 if (value->value.integer.value[0])
450 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
451 info->count = 1;
452 info->value.integer.min = 0;
453 info->value.integer.max = 1;
460 struct oxygen *chip = ctl->private_data;
461 u8 bit = ctl->private_value;
462 int invert = ctl->private_value & (1 << 8);
464 value->value.integer.value[0] =
472 struct oxygen *chip = ctl->private_data;
473 u8 bit = ctl->private_value;
474 int invert = ctl->private_value & (1 << 8);
478 guard(spinlock_irq)(&chip->reg_lock);
480 if ((!!value->value.integer.value[0] ^ !!invert) != 0)
493 struct oxygen *chip = ctl->private_data;
494 unsigned int codec = (ctl->private_value >> 24) & 1;
495 unsigned int index = ctl->private_value & 0xff;
496 unsigned int bitnr = (ctl->private_value >> 8) & 0xff;
497 int invert = ctl->private_value & (1 << 16);
500 guard(mutex)(&chip->mutex);
501 reg = oxygen_read_ac97(chip, codec, index);
503 value->value.integer.value[0] = 1;
505 value->value.integer.value[0] = 0;
514 if (!chip->controls[control])
516 priv_idx = chip->controls[control]->private_value & 0xff;
520 if (chip->model.ac97_switch)
521 chip->model.ac97_switch(chip, priv_idx, 0x8000);
522 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
523 &chip->controls[control]->id);
530 struct oxygen *chip = ctl->private_data;
531 unsigned int codec = (ctl->private_value >> 24) & 1;
532 unsigned int index = ctl->private_value & 0xff;
533 unsigned int bitnr = (ctl->private_value >> 8) & 0xff;
534 int invert = ctl->private_value & (1 << 16);
538 guard(mutex)(&chip->mutex);
539 oldreg = oxygen_read_ac97(chip, codec, index);
541 if (!value->value.integer.value[0] ^ !invert)
547 oxygen_write_ac97(chip, codec, index, newreg);
548 if (codec == 0 && chip->model.ac97_switch)
549 chip->model.ac97_switch(chip, index, newreg & 0x8000);
573 int stereo = (ctl->private_value >> 16) & 1;
575 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
576 info->count = stereo ? 2 : 1;
577 info->value.integer.min = 0;
578 info->value.integer.max = 0x1f;
585 struct oxygen *chip = ctl->private_data;
586 unsigned int codec = (ctl->private_value >> 24) & 1;
587 int stereo = (ctl->private_value >> 16) & 1;
588 unsigned int index = ctl->private_value & 0xff;
591 guard(mutex)(&chip->mutex);
592 reg = oxygen_read_ac97(chip, codec, index);
594 value->value.integer.value[0] = 31 - (reg & 0x1f);
596 value->value.integer.value[0] = 31 - ((reg >> 8) & 0x1f);
597 value->value.integer.value[1] = 31 - (reg & 0x1f);
605 struct oxygen *chip = ctl->private_data;
606 unsigned int codec = (ctl->private_value >> 24) & 1;
607 int stereo = (ctl->private_value >> 16) & 1;
608 unsigned int index = ctl->private_value & 0xff;
612 guard(mutex)(&chip->mutex);
613 oldreg = oxygen_read_ac97(chip, codec, index);
616 newreg |= 31 - (value->value.integer.value[0] & 0x1f);
619 newreg |= (31 - (value->value.integer.value[0] & 0x1f)) << 8;
620 newreg |= 31 - (value->value.integer.value[1] & 0x1f);
624 oxygen_write_ac97(chip, codec, index, newreg);
639 struct oxygen *chip = ctl->private_data;
641 guard(mutex)(&chip->mutex);
642 value->value.enumerated.item[0] =
650 struct oxygen *chip = ctl->private_data;
654 guard(mutex)(&chip->mutex);
656 if (value->value.enumerated.item[0])
669 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
670 info->count = 2;
671 info->value.integer.min = 0;
672 info->value.integer.max = 7;
679 struct oxygen *chip = ctl->private_data;
682 guard(mutex)(&chip->mutex);
684 value->value.integer.value[0] = reg & 7;
685 value->value.integer.value[1] = (reg >> 8) & 7;
692 struct oxygen *chip = ctl->private_data;
696 guard(mutex)(&chip->mutex);
699 newreg = newreg | (value->value.integer.value[0] & 7);
700 newreg = newreg | ((value->value.integer.value[1] & 7) << 8);
707 #define AC97_SWITCH(xname, codec, index, bitnr, invert) { \
713 .private_value = ((codec) << 24) | ((invert) << 16) | \
716 #define AC97_VOLUME(xname, codec, index, stereo) { \
725 .private_value = ((codec) << 24) | ((stereo) << 16) | (index), \
728 static DECLARE_TLV_DB_SCALE(monitor_db_scale, -600, 600, 0);
729 static DECLARE_TLV_DB_SCALE(ac97_db_scale, -3450, 150, 0);
732 static const struct snd_kcontrol_new controls[] = {
830 struct snd_kcontrol_new controls[2];
834 .controls = {
837 .name = "Analog Input Monitor Playback Switch",
845 .name = "Analog Input Monitor Playback Volume",
859 .controls = {
862 .name = "Analog Input Monitor Playback Switch",
870 .name = "Analog Input Monitor Playback Volume",
884 .controls = {
887 .name = "Analog Input Monitor Playback Switch",
896 .name = "Analog Input Monitor Playback Volume",
911 .controls = {
914 .name = "Analog Input Monitor Playback Switch",
923 .name = "Analog Input Monitor Playback Volume",
938 .controls = {
999 struct oxygen *chip = ctl->private_data;
1002 /* I'm too lazy to write a function for each control :-) */
1003 for (i = 0; i < ARRAY_SIZE(chip->controls); ++i)
1004 chip->controls[i] = NULL;
1008 const struct snd_kcontrol_new controls[],
1027 template = controls[i];
1028 if (chip->model.control_filter) {
1029 err = chip->model.control_filter(&template);
1036 chip->model.dac_channels_pcm == 2)
1039 !(chip->model.device_config & AC97_FMIC_SWITCH))
1042 !(chip->model.device_config & AC97_CD_INPUT))
1045 chip->model.dac_tlv) {
1046 template.tlv.p = chip->model.dac_tlv;
1051 return -ENOMEM;
1052 err = snd_ctl_add(chip->card, ctl);
1055 j = match_string(known_ctl_names, CONTROL_COUNT, ctl->id.name);
1057 chip->controls[j] = ctl;
1058 ctl->private_free = oxygen_any_ctl_free;
1069 err = add_controls(chip, controls, ARRAY_SIZE(controls));
1072 if (chip->model.device_config & PLAYBACK_1_TO_SPDIF) {
1078 if (chip->model.device_config & CAPTURE_1_FROM_SPDIF) {
1085 if (!(chip->model.device_config & monitor_controls[i].pcm_dev))
1087 err = add_controls(chip, monitor_controls[i].controls,
1088 ARRAY_SIZE(monitor_controls[i].controls));
1092 if (chip->has_ac97_0) {
1098 if (chip->has_ac97_1) {
1104 return chip->model.mixer_init ? chip->model.mixer_init(chip) : 0;