diff options
| author | Igor Prusov <ivprusov@salutedevices.com> | 2025-02-18 18:08:22 +0300 |
|---|---|---|
| committer | Dmitry Rokosov <rockosov@rulkc.org> | 2026-08-13 14:41:33 +0300 |
| commit | 987407aaf00b594cef3e6c08b430bc5ec7c44bbe (patch) | |
| tree | a50425fe20921f720b1e9b3c918acc974dbab56d | |
| parent | 94c85c9f26b467454a0e30a4f343f6434f11a906 (diff) | |
| download | linux-987407aaf00b594cef3e6c08b430bc5ec7c44bbe.tar.gz linux-987407aaf00b594cef3e6c08b430bc5ec7c44bbe.zip | |
ASoC: codecs: add ntp8835_mute function
Implement mute_stream callback to fix pop noise when amplifier device is
opened or closed. Also use PWM mask registers for Playback Switch
control to avoid conflicts with mute_stream.
Signed-off-by: Igor Prusov <ivprusov@salutedevices.com>
Signed-off-by: Dmitry Rokosov <rockosov@rulkc.org>
| -rw-r--r-- | sound/soc/codecs/ntp8835.c | 44 |
1 files changed, 11 insertions, 33 deletions
diff --git a/sound/soc/codecs/ntp8835.c b/sound/soc/codecs/ntp8835.c index 2b93bea11752..24082626e652 100644 --- a/sound/soc/codecs/ntp8835.c +++ b/sound/soc/codecs/ntp8835.c @@ -89,42 +89,10 @@ static int ntp8835_mute_info(struct snd_kcontrol *kcontrol, return 0; } -static int ntp8835_mute_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); - unsigned int val; - - val = snd_soc_component_read(component, NTP8835_SOFT_MUTE); - - ucontrol->value.integer.value[0] = val ? 0 : 1; - return 0; -} - -static int ntp8835_mute_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); - unsigned int val; - - val = ucontrol->value.integer.value[0] ? 0 : 7; - - snd_soc_component_write(component, NTP8835_SOFT_MUTE, val); - - return 0; -} - static const struct snd_kcontrol_new ntp8835_vol_control[] = { SOC_SINGLE_TLV("Playback Volume", NTP8835_MASTER_VOL, 0, 0xff, 0, ntp8835_vol_scale), - { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Playback Switch", - .info = ntp8835_mute_info, - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE, - .get = ntp8835_mute_get, - .put = ntp8835_mute_put, - }, + SOC_SINGLE("Playback Switch", NTP8835_PWM_MASK_CTRL0, 1, 1, 1), }; static void ntp8835_reset_gpio(struct ntp8835_priv *ntp8835) @@ -385,9 +353,19 @@ static int ntp8835_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return 0; }; +static int ntp8835_mute(struct snd_soc_dai *dai, int mute, int stream) +{ + unsigned int mute_mask = NTP8835_SOFT_MUTE_SM1 | + NTP8835_SOFT_MUTE_SM2 | + NTP8835_SOFT_MUTE_SM3; + return snd_soc_component_update_bits(dai->component, NTP8835_SOFT_MUTE, + mute_mask, mute ? mute_mask : 0); +} + static const struct snd_soc_dai_ops ntp8835_dai_ops = { .hw_params = ntp8835_hw_params, .set_fmt = ntp8835_set_fmt, + .mute_stream = ntp8835_mute, }; static struct snd_soc_dai_driver ntp8835_dai = { |
