Lines Matching +full:codec +full:- +full:analog +full:- +full:controls
1 // SPDX-License-Identifier: GPL-2.0-or-later
11 * - we reuse the struct snd_akm4xxx record for storing the wm8770 codec data.
13 * both controls in the future, once if wm codecs are reused in
16 * - DAC digital volumes are not implemented in the mixer.
17 * if they show better response than DAC analog volumes, we can use them
29 * working: analog output, mixer, headphone amplifier switch
58 #define WM_DAC_ATTEN 0x00 /* DAC1-8 analog attenuation */
59 #define WM_DAC_MASTER_ATTEN 0x08 /* DAC master analog attenuation */
60 #define WM_DAC_DIG_ATTEN 0x09 /* DAC1-8 digital attenuation */
64 #define WM_MUTE 0x14 /* mute controls */
65 #define WM_DAC_CTRL2 0x15 /* de-emphasis and zefo-flag */
68 #define WM_POWERDOWN 0x18 /* power-down controls */
91 * Aureon Universe additional controls using PCA9554
150 for (i = 7; i >= 0; i--) {
192 {"Internal Aux", "Wavetable", "Rear Line-In"};
201 struct aureon_spec *spec = ice->spec;
202 ucontrol->value.enumerated.item[0] = spec->pca9554_out;
210 struct aureon_spec *spec = ice->spec;
214 nval = ucontrol->value.enumerated.item[0];
216 return -EINVAL;
218 oval = spec->pca9554_out;
222 spec->pca9554_out = nval;
232 struct aureon_spec *spec = ice->spec;
246 /* Send low-order byte to XILINX chip */
258 /* Send high-order byte to XILINX chip */
280 spec->stac9744[(reg & 0x7F) >> 1] = val;
285 struct aureon_spec *spec = ice->spec;
286 return spec->stac9744[(reg & 0x7F) >> 1];
294 struct aureon_spec *spec = ice->spec;
315 (unsigned short)-1
332 memset(&spec->stac9744, 0, sizeof(spec->stac9744));
333 for (i = 0; ac97_defaults[i] != (unsigned short)-1; i += 2)
334 spec->stac9744[(ac97_defaults[i]) >> 1] = ac97_defaults[i+1];
336 /* Unmute AC'97 master volume permanently - muting is done by WM8770 */
345 * AC'97 volume controls
349 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
350 uinfo->count = kcontrol->private_value & AUREON_AC97_STEREO ? 2 : 1;
351 uinfo->value.integer.min = 0;
352 uinfo->value.integer.max = 31;
361 guard(mutex)(&ice->gpio_mutex);
363 vol = aureon_ac97_read(ice, kcontrol->private_value & 0x7F);
364 ucontrol->value.integer.value[0] = 0x1F - (vol & 0x1F);
365 if (kcontrol->private_value & AUREON_AC97_STEREO)
366 ucontrol->value.integer.value[1] = 0x1F - ((vol >> 8) & 0x1F);
379 ovol = aureon_ac97_read(ice, kcontrol->private_value & 0x7F);
380 nvol = (0x1F - ucontrol->value.integer.value[0]) & 0x001F;
381 if (kcontrol->private_value & AUREON_AC97_STEREO)
382 nvol |= ((0x1F - ucontrol->value.integer.value[1]) << 8) & 0x1F00;
387 aureon_ac97_write(ice, kcontrol->private_value & 0x7F, nvol);
395 * AC'97 mute controls
403 guard(mutex)(&ice->gpio_mutex);
405 ucontrol->value.integer.value[0] = aureon_ac97_read(ice,
406 kcontrol->private_value & 0x7F) & 0x8000 ? 0 : 1;
419 ovol = aureon_ac97_read(ice, kcontrol->private_value & 0x7F);
420 nvol = (ucontrol->value.integer.value[0] ? 0x0000 : 0x8000) | (ovol & ~0x8000);
424 aureon_ac97_write(ice, kcontrol->private_value & 0x7F, nvol);
432 * AC'97 mute controls
440 guard(mutex)(&ice->gpio_mutex);
442 ucontrol->value.integer.value[0] = aureon_ac97_read(ice, AC97_MIC) & 0x0020 ? 0 : 1;
456 nvol = (ucontrol->value.integer.value[0] ? 0x0000 : 0x0020) | (ovol & ~0x0020);
478 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT ||
479 ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT) {
496 for (i = bits - 1; i >= 0; i--) {
535 for (i = bits-1; i >= 0; i--) {
554 for (i = 7; i >= 0; i--) {
597 * get the current register value of WM codec
602 return ((unsigned short)ice->akm[0].images[reg] << 8) |
603 ice->akm[0].images[reg + 1];
607 * set the register value of WM codec
612 ((ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT ||
613 ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT) ?
619 * set the register value of WM codec and remember it
625 ice->akm[0].images[reg] = val >> 8;
626 ice->akm[0].images[reg + 1] = val;
634 * AC'97 master playback mute controls (Mute on WM8770 chip)
642 guard(mutex)(&ice->gpio_mutex);
644 ucontrol->value.integer.value[0] = (wm_get(ice, WM_OUT_MUX1) >> 1) & 0x01;
658 nvol = (ovol & ~0x02) | (ucontrol->value.integer.value[0] ? 0x02 : 0x00);
668 static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -10000, 100, 1);
669 static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1);
670 static const DECLARE_TLV_DB_SCALE(db_scale_wm_adc, -1200, 100, 0);
671 static const DECLARE_TLV_DB_SCALE(db_scale_ac97_master, -4650, 150, 0);
672 static const DECLARE_TLV_DB_SCALE(db_scale_ac97_gain, -3450, 150, 0);
675 #define WM_VOL_CNT 101 /* 0dB .. -100dB */
703 guard(mutex)(&ice->gpio_mutex);
704 ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 0 : 1;
716 nval = (oval & ~0x10) | (ucontrol->value.integer.value[0] ? 0 : 0x10);
730 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
731 uinfo->count = 2;
732 uinfo->value.integer.min = 0;
733 uinfo->value.integer.max = WM_VOL_MAX;
740 struct aureon_spec *spec = ice->spec;
743 ucontrol->value.integer.value[i] =
744 spec->master[i] & ~WM_VOL_MUTE;
751 struct aureon_spec *spec = ice->spec;
756 unsigned int vol = ucontrol->value.integer.value[ch];
759 vol |= spec->master[ch] & WM_VOL_MUTE;
760 if (vol != spec->master[ch]) {
762 spec->master[ch] = vol;
763 for (dac = 0; dac < ice->num_total_dacs; dac += 2)
765 spec->vol[dac + ch],
766 spec->master[ch]);
779 int voices = kcontrol->private_value >> 8;
780 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
781 uinfo->count = voices;
782 uinfo->value.integer.min = 0; /* mute (-101dB) */
783 uinfo->value.integer.max = WM_VOL_MAX; /* 0dB */
790 struct aureon_spec *spec = ice->spec;
793 voices = kcontrol->private_value >> 8;
794 ofs = kcontrol->private_value & 0xff;
796 ucontrol->value.integer.value[i] =
797 spec->vol[ofs+i] & ~WM_VOL_MUTE;
804 struct aureon_spec *spec = ice->spec;
808 voices = kcontrol->private_value >> 8;
809 ofs = kcontrol->private_value & 0xff;
812 unsigned int vol = ucontrol->value.integer.value[i];
815 vol |= spec->vol[ofs+i] & WM_VOL_MUTE;
816 if (vol != spec->vol[ofs+i]) {
817 spec->vol[ofs+i] = vol;
819 wm_set_vol(ice, idx, spec->vol[ofs + i],
820 spec->master[i]);
833 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
834 uinfo->count = kcontrol->private_value >> 8;
835 uinfo->value.integer.min = 0;
836 uinfo->value.integer.max = 1;
843 struct aureon_spec *spec = ice->spec;
846 voices = kcontrol->private_value >> 8;
847 ofs = kcontrol->private_value & 0xFF;
850 ucontrol->value.integer.value[i] =
851 (spec->vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1;
858 struct aureon_spec *spec = ice->spec;
861 voices = kcontrol->private_value >> 8;
862 ofs = kcontrol->private_value & 0xFF;
866 int val = (spec->vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1;
867 if (ucontrol->value.integer.value[i] != val) {
868 spec->vol[ofs + i] &= ~WM_VOL_MUTE;
869 spec->vol[ofs + i] |=
870 ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;
871 wm_set_vol(ice, ofs + i, spec->vol[ofs + i],
872 spec->master[i]);
889 struct aureon_spec *spec = ice->spec;
891 ucontrol->value.integer.value[0] =
892 (spec->master[0] & WM_VOL_MUTE) ? 0 : 1;
893 ucontrol->value.integer.value[1] =
894 (spec->master[1] & WM_VOL_MUTE) ? 0 : 1;
901 struct aureon_spec *spec = ice->spec;
906 int val = (spec->master[i] & WM_VOL_MUTE) ? 0 : 1;
907 if (ucontrol->value.integer.value[i] != val) {
909 spec->master[i] &= ~WM_VOL_MUTE;
910 spec->master[i] |=
911 ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;
912 for (dac = 0; dac < ice->num_total_dacs; dac += 2)
914 spec->vol[dac + i],
915 spec->master[i]);
926 #define PCM_RES 128 /* -64dB */
927 #define PCM_MIN (PCM_0dB - PCM_RES)
930 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
931 uinfo->count = 1;
932 uinfo->value.integer.min = 0; /* mute (-64dB) */
933 uinfo->value.integer.max = PCM_RES; /* 0dB */
942 guard(mutex)(&ice->gpio_mutex);
944 val = val > PCM_MIN ? (val - PCM_MIN) : 0;
945 ucontrol->value.integer.value[0] = val;
955 nvol = ucontrol->value.integer.value[0];
957 return -EINVAL;
981 guard(mutex)(&ice->gpio_mutex);
984 ucontrol->value.integer.value[i] = ~val>>5 & 0x1;
998 new = (~ucontrol->value.integer.value[i]<<5&0x20) | (old&~0x20);
1014 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1015 uinfo->count = 2;
1016 uinfo->value.integer.min = 0; /* -12dB */
1017 uinfo->value.integer.max = 0x1f; /* 19dB */
1027 guard(mutex)(&ice->gpio_mutex);
1031 ucontrol->value.integer.value[i] = vol;
1046 nvol = ucontrol->value.integer.value[i] & 0x1f;
1081 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON71_UNIVERSE)
1092 guard(mutex)(&ice->gpio_mutex);
1094 ucontrol->value.enumerated.item[0] = val & 7;
1095 ucontrol->value.enumerated.item[1] = (val >> 4) & 7;
1108 nval |= ucontrol->value.enumerated.item[0] & 7;
1109 nval |= (ucontrol->value.enumerated.item[1] & 7) << 4;
1131 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71)
1140 struct aureon_spec *spec = ice->spec;
1144 ucontrol->value.enumerated.item[0] = spec->cs8415_mux;
1152 struct aureon_spec *spec = ice->spec;
1159 nval |= ucontrol->value.enumerated.item[0] & 7;
1164 spec->cs8415_mux = ucontrol->value.enumerated.item[0];
1170 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1171 uinfo->count = 1;
1172 uinfo->value.integer.min = 0;
1173 uinfo->value.integer.max = 192000;
1182 ucontrol->value.integer.value[0] = (int)((unsigned int)ratio * 750);
1195 ucontrol->value.integer.value[0] = (aureon_cs8415_get(ice, CS8415_CTRL1) & 0x20) ? 0 : 1;
1207 if (ucontrol->value.integer.value[0])
1219 * CS8415A Q-Sub info
1223 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
1224 uinfo->count = 10;
1233 aureon_cs8415_read(ice, CS8415_QSUB, ucontrol->value.bytes.data, 10);
1241 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
1242 uinfo->count = 1;
1248 memset(ucontrol->value.iec958.status, 0xFF, 24);
1257 aureon_cs8415_read(ice, CS8415_C_BUFFER, ucontrol->value.iec958.status, 24);
1271 if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
1272 ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT)
1277 if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
1278 ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT)
1302 ucontrol->value.integer.value[0] = aureon_get_headphone_amp(ice);
1311 return aureon_set_headphone_amp(ice, ucontrol->value.integer.value[0]);
1323 ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) == 0xf;
1332 if (ucontrol->value.integer.value[0])
1356 ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) == 0x8;
1367 if (ucontrol->value.enumerated.item[0])
1818 .name = SNDRV_CTL_NAME_IEC958("Q-subcode ", CAPTURE, DEFAULT),
1852 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON51_SKY)
1853 counts -= 2; /* no side */
1855 err = snd_ctl_add(ice->card, snd_ctl_new1(&aureon_dac_controls[i], ice));
1861 err = snd_ctl_add(ice->card, snd_ctl_new1(&wm_controls[i], ice));
1866 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON71_UNIVERSE) {
1868 err = snd_ctl_add(ice->card, snd_ctl_new1(&universe_ac97_controls[i], ice));
1872 } else if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
1873 ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) {
1875 err = snd_ctl_add(ice->card, snd_ctl_new1(&ac97_controls[i], ice));
1881 if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
1882 ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) {
1888 dev_info(ice->card->dev,
1889 "No CS8415 chip. Skipping CS8415 controls.\n");
1895 kctl->id.device = ice->pcm->device;
1896 err = snd_ctl_add(ice->card, kctl);
1917 0x18, 0x000, /* All power-up */
1921 0x00, 0, /* DAC1 analog mute */
1922 0x01, 0, /* DAC2 analog mute */
1923 0x02, 0, /* DAC3 analog mute */
1924 0x03, 0, /* DAC4 analog mute */
1925 0x04, 0, /* DAC5 analog mute */
1926 0x05, 0, /* DAC6 analog mute */
1927 0x06, 0, /* DAC7 analog mute */
1928 0x07, 0, /* DAC8 analog mute */
1929 0x08, 0x100, /* master analog mute */
1943 0x19, 0x000, /* -12dB ADC/L */
1944 0x1a, 0x000, /* -12dB ADC/R */
1945 (unsigned short)-1
1954 0x18, 0x000, /* All power-up */
1956 0x16, 0x022, /* I2S, normal polarity, 24bit, high-pass on */
1959 0x00, 0, /* DAC1 analog mute */
1960 0x01, 0, /* DAC2 analog mute */
1961 0x02, 0, /* DAC3 analog mute */
1962 0x03, 0, /* DAC4 analog mute */
1963 0x04, 0, /* DAC5 analog mute */
1964 0x05, 0, /* DAC6 analog mute */
1965 0x06, 0, /* DAC7 analog mute */
1966 0x07, 0, /* DAC8 analog mute */
1967 0x08, 0x100, /* master analog mute */
1984 0x19, 0x000, /* -12dB ADC/L */
1985 0x1a, 0x000, /* -12dB ADC/R */
1986 (unsigned short)-1
1994 (unsigned short)-1
1999 struct aureon_spec *spec = ice->spec;
2007 /* reset the wm codec as the SPI mode */
2022 /* initialize WM8770 codec */
2023 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71 ||
2024 ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT ||
2025 ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT)
2029 for (; *p != (unsigned short)-1; p += 2)
2032 /* initialize CS8415A codec */
2033 if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
2034 ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) {
2035 for (p = cs_inits; *p != (unsigned short)-1; p++)
2037 spec->cs8415_mux = 1;
2056 struct aureon_spec *spec = ice->spec;
2065 for (i = 0; i < ice->num_total_dacs; i++)
2066 wm_set_vol(ice, i, spec->vol[i], spec->master[i % 2]);
2081 return -ENOMEM;
2082 ice->spec = spec;
2084 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON51_SKY) {
2085 ice->num_total_dacs = 6;
2086 ice->num_total_adcs = 2;
2089 ice->num_total_dacs = 8;
2090 ice->num_total_adcs = 2;
2094 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
2095 if (!ice->akm)
2096 return -ENOMEM;
2097 ice->akm_codecs = 1;
2103 spec->master[0] = WM_VOL_MUTE;
2104 spec->master[1] = WM_VOL_MUTE;
2105 for (i = 0; i < ice->num_total_dacs; i++) {
2106 spec->vol[i] = WM_VOL_MUTE;
2107 wm_set_vol(ice, i, spec->vol[i], spec->master[i % 2]);
2111 ice->pm_resume = aureon_resume;
2112 ice->pm_suspend_enabled = 1;
2125 [ICE_EEP2_SYSCONF] = 0x0a, /* clock 512, spdif-in/ADC, 3DACs */
2128 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
2141 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */
2144 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
2158 [ICE_EEP2_SYSCONF] = 0x2b, /* clock 512, mpu401, spdif-in/ADC,
2163 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
2176 [ICE_EEP2_SYSCONF] = 0x4b, /* clock 384, spdif-in/ADC, 4DACs */
2179 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
2196 .name = "Terratec Aureon 5.1-Sky",
2206 .name = "Terratec Aureon 7.1-Space",
2216 .name = "Terratec Aureon 7.1-Universe",