Lines Matching +full:codec +full:- +full:gpio8

1 // SPDX-License-Identifier: GPL-2.0-or-later
63 /* Analog Recording Source :- Mic, LineIn, CD/Video, */
75 #define WM8766_SPI_MD (1<<16) /* DATA VT1724 -> WM8766, Pin96 */
98 #define AK4396_CSN (1 << 8) /* CSN->GPIO8, pin 75 */
99 #define AK4396_CCLK (1 << 9) /* CCLK->GPIO9, pin 76 */
100 #define AK4396_CDTI (1 << 10) /* CDTI->GPIO10, pin 77 */
111 * get the current register value of WM codec
116 return ((unsigned short)ice->akm[0].images[reg] << 8) | in wm_get()
117 ice->akm[0].images[reg + 1]; in wm_get()
121 * set the register value of WM codec and remember it
134 ice->akm[0].images[reg] = val >> 8; in wm_put()
135 ice->akm[0].images[reg + 1] = val; in wm_put()
153 * SPI implementation for WM8766 codec - only writing supported, no readback
187 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask); in wm8766_spi_write()
188 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction); in wm8766_spi_write()
193 * serial interface for ak4396 - only writing supported, no readback
226 snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask); in ak4396_write()
227 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction); in ak4396_write()
238 * DAC volume attenuation mixer control (-64dB to 0dB)
244 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in ak4396_dac_vol_info()
245 uinfo->count = 2; in ak4396_dac_vol_info()
246 uinfo->value.integer.min = 0; /* mute */ in ak4396_dac_vol_info()
247 uinfo->value.integer.max = 0xFF; /* linear */ in ak4396_dac_vol_info()
255 struct prodigy_hifi_spec *spec = ice->spec; in ak4396_dac_vol_get()
259 ucontrol->value.integer.value[i] = spec->vol[i]; in ak4396_dac_vol_get()
267 struct prodigy_hifi_spec *spec = ice->spec; in ak4396_dac_vol_put()
271 mutex_lock(&ice->gpio_mutex); in ak4396_dac_vol_put()
273 if (ucontrol->value.integer.value[i] != spec->vol[i]) { in ak4396_dac_vol_put()
274 spec->vol[i] = ucontrol->value.integer.value[i]; in ak4396_dac_vol_put()
276 spec->vol[i] & 0xff); in ak4396_dac_vol_put()
280 mutex_unlock(&ice->gpio_mutex); in ak4396_dac_vol_put()
284 static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1);
301 /* --------------- */
309 #define DAC_MIN (DAC_0dB - DAC_RES)
347 * DAC volume attenuation mixer control (-64dB to 0dB)
353 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in wm_dac_vol_info()
354 uinfo->count = 2; in wm_dac_vol_info()
355 uinfo->value.integer.min = 0; /* mute */ in wm_dac_vol_info()
356 uinfo->value.integer.max = DAC_RES; /* 0dB, 0.5dB step */ in wm_dac_vol_info()
364 struct prodigy_hifi_spec *spec = ice->spec; in wm_dac_vol_get()
368 ucontrol->value.integer.value[i] = in wm_dac_vol_get()
369 spec->vol[2 + i] & ~WM_VOL_MUTE; in wm_dac_vol_get()
376 struct prodigy_hifi_spec *spec = ice->spec; in wm_dac_vol_put()
379 mutex_lock(&ice->gpio_mutex); in wm_dac_vol_put()
381 if (ucontrol->value.integer.value[i] != spec->vol[2 + i]) { in wm_dac_vol_put()
383 spec->vol[2 + i] &= WM_VOL_MUTE; in wm_dac_vol_put()
384 spec->vol[2 + i] |= ucontrol->value.integer.value[i]; in wm_dac_vol_put()
385 wm_set_vol(ice, idx, spec->vol[2 + i], spec->master[i]); in wm_dac_vol_put()
389 mutex_unlock(&ice->gpio_mutex); in wm_dac_vol_put()
400 int voices = kcontrol->private_value >> 8; in wm8766_vol_info()
401 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in wm8766_vol_info()
402 uinfo->count = voices; in wm8766_vol_info()
403 uinfo->value.integer.min = 0; /* mute */ in wm8766_vol_info()
404 uinfo->value.integer.max = DAC_RES; /* 0dB */ in wm8766_vol_info()
412 struct prodigy_hifi_spec *spec = ice->spec; in wm8766_vol_get()
415 voices = kcontrol->private_value >> 8; in wm8766_vol_get()
416 ofs = kcontrol->private_value & 0xff; in wm8766_vol_get()
418 ucontrol->value.integer.value[i] = spec->vol[ofs + i]; in wm8766_vol_get()
425 struct prodigy_hifi_spec *spec = ice->spec; in wm8766_vol_put()
429 voices = kcontrol->private_value >> 8; in wm8766_vol_put()
430 ofs = kcontrol->private_value & 0xff; in wm8766_vol_put()
431 mutex_lock(&ice->gpio_mutex); in wm8766_vol_put()
433 if (ucontrol->value.integer.value[i] != spec->vol[ofs + i]) { in wm8766_vol_put()
435 spec->vol[ofs + i] &= WM_VOL_MUTE; in wm8766_vol_put()
436 spec->vol[ofs + i] |= ucontrol->value.integer.value[i]; in wm8766_vol_put()
438 spec->vol[ofs + i], spec->master[i]); in wm8766_vol_put()
442 mutex_unlock(&ice->gpio_mutex); in wm8766_vol_put()
452 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in wm_master_vol_info()
453 uinfo->count = 2; in wm_master_vol_info()
454 uinfo->value.integer.min = 0; in wm_master_vol_info()
455 uinfo->value.integer.max = DAC_RES; in wm_master_vol_info()
463 struct prodigy_hifi_spec *spec = ice->spec; in wm_master_vol_get()
466 ucontrol->value.integer.value[i] = spec->master[i]; in wm_master_vol_get()
474 struct prodigy_hifi_spec *spec = ice->spec; in wm_master_vol_put()
477 mutex_lock(&ice->gpio_mutex); in wm_master_vol_put()
479 if (ucontrol->value.integer.value[ch] != spec->master[ch]) { in wm_master_vol_put()
480 spec->master[ch] = ucontrol->value.integer.value[ch]; in wm_master_vol_put()
484 spec->vol[2 + ch], spec->master[ch]); in wm_master_vol_put()
487 spec->vol[0 + ch], spec->master[ch]); in wm_master_vol_put()
490 spec->vol[4 + ch], spec->master[ch]); in wm_master_vol_put()
493 spec->vol[6 + ch], spec->master[ch]); in wm_master_vol_put()
497 mutex_unlock(&ice->gpio_mutex); in wm_master_vol_put()
538 mutex_lock(&ice->gpio_mutex); in wm_adc_mux_enum_get()
539 ucontrol->value.enumerated.item[0] = wm_get(ice, WM_ADC_MUX) & 0x1f; in wm_adc_mux_enum_get()
540 mutex_unlock(&ice->gpio_mutex); in wm_adc_mux_enum_get()
551 mutex_lock(&ice->gpio_mutex); in wm_adc_mux_enum_put()
553 nval = (oval & 0xe0) | ucontrol->value.enumerated.item[0]; in wm_adc_mux_enum_put()
558 mutex_unlock(&ice->gpio_mutex); in wm_adc_mux_enum_put()
565 * ADC gain mixer control (-64dB to 0dB)
570 #define ADC_MIN (ADC_0dB - ADC_RES)
575 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in wm_adc_vol_info()
576 uinfo->count = 2; in wm_adc_vol_info()
577 uinfo->value.integer.min = 0; /* mute (-64dB) */ in wm_adc_vol_info()
578 uinfo->value.integer.max = ADC_RES; /* 0dB, 0.5dB step */ in wm_adc_vol_info()
589 mutex_lock(&ice->gpio_mutex); in wm_adc_vol_get()
592 val = val > ADC_MIN ? (val - ADC_MIN) : 0; in wm_adc_vol_get()
593 ucontrol->value.integer.value[i] = val; in wm_adc_vol_get()
595 mutex_unlock(&ice->gpio_mutex); in wm_adc_vol_get()
606 mutex_lock(&ice->gpio_mutex); in wm_adc_vol_put()
608 nvol = ucontrol->value.integer.value[i]; in wm_adc_vol_put()
617 mutex_unlock(&ice->gpio_mutex); in wm_adc_vol_put()
630 int bit = kcontrol->private_value; in wm_adc_mux_get()
632 mutex_lock(&ice->gpio_mutex); in wm_adc_mux_get()
633 ucontrol->value.integer.value[0] = in wm_adc_mux_get()
635 mutex_unlock(&ice->gpio_mutex); in wm_adc_mux_get()
643 int bit = kcontrol->private_value; in wm_adc_mux_put()
647 mutex_lock(&ice->gpio_mutex); in wm_adc_mux_put()
649 if (ucontrol->value.integer.value[0]) in wm_adc_mux_put()
657 mutex_unlock(&ice->gpio_mutex); in wm_adc_mux_put()
662 * Analog bypass (In -> Out)
671 mutex_lock(&ice->gpio_mutex); in wm_bypass_get()
672 ucontrol->value.integer.value[0] = in wm_bypass_get()
674 mutex_unlock(&ice->gpio_mutex); in wm_bypass_get()
685 mutex_lock(&ice->gpio_mutex); in wm_bypass_put()
687 if (ucontrol->value.integer.value[0]) in wm_bypass_put()
695 mutex_unlock(&ice->gpio_mutex); in wm_bypass_put()
709 mutex_lock(&ice->gpio_mutex); in wm_chswap_get()
710 ucontrol->value.integer.value[0] = in wm_chswap_get()
712 mutex_unlock(&ice->gpio_mutex); in wm_chswap_get()
723 mutex_lock(&ice->gpio_mutex); in wm_chswap_put()
726 if (ucontrol->value.integer.value[0]) in wm_chswap_put()
735 mutex_unlock(&ice->gpio_mutex); in wm_chswap_put()
859 * WM codec registers
864 struct snd_ice1712 *ice = entry->private_data; in wm_proc_regs_write()
867 mutex_lock(&ice->gpio_mutex); in wm_proc_regs_write()
874 mutex_unlock(&ice->gpio_mutex); in wm_proc_regs_write()
880 struct snd_ice1712 *ice = entry->private_data; in wm_proc_regs_read()
883 mutex_lock(&ice->gpio_mutex); in wm_proc_regs_read()
888 mutex_unlock(&ice->gpio_mutex); in wm_proc_regs_read()
893 snd_card_rw_proc_new(ice->card, "wm_codec", ice, wm_proc_regs_read, in wm_proc_init()
903 err = snd_ctl_add(ice->card, in prodigy_hifi_add_controls()
920 err = snd_ctl_add(ice->card, in prodigy_hd2_add_controls()
964 WM_POWERDOWN, 0x0008, /* All power-up except HP */ in wm8776_init()
994 struct prodigy_hifi_spec *spec = ice->spec; in prodigy_hifi_resume()
997 mutex_lock(&ice->gpio_mutex); in prodigy_hifi_resume()
999 /* reinitialize WM8776 and re-apply old register values */ in prodigy_hifi_resume()
1006 /* reinitialize WM8766 and re-apply volumes for all DACs */ in prodigy_hifi_resume()
1010 spec->vol[2 + ch], spec->master[ch]); in prodigy_hifi_resume()
1013 spec->vol[0 + ch], spec->master[ch]); in prodigy_hifi_resume()
1016 spec->vol[4 + ch], spec->master[ch]); in prodigy_hifi_resume()
1019 spec->vol[6 + ch], spec->master[ch]); in prodigy_hifi_resume()
1026 mutex_unlock(&ice->gpio_mutex); in prodigy_hifi_resume()
1067 ice->vt1720 = 0; in prodigy_hifi_init()
1068 ice->vt1724 = 1; in prodigy_hifi_init()
1070 ice->num_total_dacs = 8; in prodigy_hifi_init()
1071 ice->num_total_adcs = 1; in prodigy_hifi_init()
1073 /* HACK - use this as the SPDIF source. in prodigy_hifi_init()
1076 ice->gpio.saved[0] = 0; in prodigy_hifi_init()
1079 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); in prodigy_hifi_init()
1080 if (! ice->akm) in prodigy_hifi_init()
1081 return -ENOMEM; in prodigy_hifi_init()
1082 ice->akm_codecs = 1; in prodigy_hifi_init()
1086 return -ENOMEM; in prodigy_hifi_init()
1087 ice->spec = spec; in prodigy_hifi_init()
1089 /* initialize WM8776 codec */ in prodigy_hifi_init()
1098 ice->pm_resume = &prodigy_hifi_resume; in prodigy_hifi_init()
1099 ice->pm_suspend_enabled = 1; in prodigy_hifi_init()
1121 /* initialize ak4396 codec */ in ak4396_init()
1122 /* reset codec */ in ak4396_init()
1134 /* initialize ak4396 codec and restore previous mixer volumes */ in prodigy_hd2_resume()
1135 struct prodigy_hifi_spec *spec = ice->spec; in prodigy_hd2_resume()
1137 mutex_lock(&ice->gpio_mutex); in prodigy_hd2_resume()
1140 ak4396_write(ice, AK4396_LCH_ATT + i, spec->vol[i] & 0xff); in prodigy_hd2_resume()
1141 mutex_unlock(&ice->gpio_mutex); in prodigy_hd2_resume()
1150 ice->vt1720 = 0; in prodigy_hd2_init()
1151 ice->vt1724 = 1; in prodigy_hd2_init()
1153 ice->num_total_dacs = 1; in prodigy_hd2_init()
1154 ice->num_total_adcs = 1; in prodigy_hd2_init()
1156 /* HACK - use this as the SPDIF source. in prodigy_hd2_init()
1159 ice->gpio.saved[0] = 0; in prodigy_hd2_init()
1162 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); in prodigy_hd2_init()
1163 if (! ice->akm) in prodigy_hd2_init()
1164 return -ENOMEM; in prodigy_hd2_init()
1165 ice->akm_codecs = 1; in prodigy_hd2_init()
1169 return -ENOMEM; in prodigy_hd2_init()
1170 ice->spec = spec; in prodigy_hd2_init()
1173 ice->pm_resume = &prodigy_hd2_resume; in prodigy_hd2_init()
1174 ice->pm_suspend_enabled = 1; in prodigy_hd2_init()
1184 0x4b, /* SYSCONF: clock 512, spdif-in/ADC, 4DACs */
1187 0xc3, /* SPDIF: out-en, out-int, spdif-in */
1200 0x4b, /* SYSCONF: clock 512, spdif-in/ADC, 4DACs */
1203 0xc3, /* SPDIF: out-en, out-int, spdif-in */
1219 0xc1, /* SPDIF: out-en, out-int */