From: Cezary Rojewski <cezary.rojewski@intel.com>
To: <wangdich9700@163.com>
Cc: <linux-kernel@vger.kernel.org>, <alsa-devel@alsa-project.org>,
<linux-arm-kernel@lists.infradead.org>,
wangdicheng <wangdicheng@kylinos.cn>, <lgirdwood@gmail.com>,
<broonie@kernel.org>, <perex@perex.cz>, <tiwai@suse.com>
Subject: Re: [PATCH v2] ALSA: hda/conexant: Fix pop noise on conexant codec
Date: Wed, 5 Nov 2025 16:45:00 +0100 [thread overview]
Message-ID: <d57548e1-3f23-4b9e-84c2-cfdc31e92e1e@intel.com> (raw)
In-Reply-To: <20251105022527.69770-1-wangdich9700@163.com>
On 2025-11-05 3:25 AM, wangdich9700@163.com wrote:
> From: wangdicheng <wangdich9700@163.com>
>
> Pop noise mitigation: When headphones are unplugged during playback,mute
> speaker DAC(0x17)immediately and restore after 20ms delay to avoid
> audible popping.
What's the device ID for the "conexant codec"? I doubt all of them share
the problem. Once obtained, mention the ID within the title.
Now, the problem you're aiming to address seem generic - addressing pop
noises during plug/unplug is a common subject in sound/ domain. I'd
check if sound/hda/codecs doesn't have something for such occasion
already. Takashi is more fluent in sound/hda, perhaps he could help here.
If such code exists, you could get rid of ugly:
codec->spec <-> spec->codec
relation which you're adding with:
struct hda_codec *conexant_codec;
>
> Signed-off-by: wangdicheng <wangdicheng@kylinos.cn>
> ---
> sound/hda/codecs/conexant.c | 65 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 65 insertions(+)
>
> diff --git a/sound/hda/codecs/conexant.c b/sound/hda/codecs/conexant.c
> index 5fcbc1312c69..2c16d1930a75 100644
> --- a/sound/hda/codecs/conexant.c
> +++ b/sound/hda/codecs/conexant.c
> @@ -43,6 +43,9 @@ struct conexant_spec {
> unsigned int gpio_mute_led_mask;
> unsigned int gpio_mic_led_mask;
> bool is_cx11880_sn6140;
> +
> + struct hda_codec *conexant_codec;
> + struct delayed_work change_pinctl_work;
Not fan of adding 'struct hda_codec *' as part of the spec. As stated
above, I'd first check if something pop noise -related doesn't exist in
sound/hda already. If it does, hook into it.
> };
>
>
> @@ -216,6 +219,63 @@ static void cx_remove(struct hda_codec *codec)
> snd_hda_gen_remove(codec);
> }
>
> +static void mute_unmute_speaker(struct hda_codec *codec, hda_nid_t nid, bool mute)
> +{
> + unsigned int conn_sel, dac, conn_list, gain_left, gain_right;
> +
> + conn_sel = snd_hda_codec_read(codec, nid, 0, 0xf01, 0x0);
> + conn_list = snd_hda_codec_read(codec, nid, 0, 0xf02, 0x0);
> +
> + dac = ((conn_list >> (conn_sel * 8)) & 0xff);
> + if (dac == 0)
> + return;
> +
> + gain_left = snd_hda_codec_read(codec, dac, 0, 0xba0, 0x0);
> + gain_right = snd_hda_codec_read(codec, dac, 0, 0xb80, 0x0);
> +
> + if (mute) {
> + gain_left |= 0x80;
> + gain_right |= 0x80;
> + } else {
> + gain_left &= (~(0x80));
> + gain_right &= (~(0x80));
> + }
> +
> + snd_hda_codec_write(codec, dac, 0, 0x3a0, gain_left);
> + snd_hda_codec_write(codec, dac, 0, 0x390, gain_right);
> +
> + if (mute) {
> + snd_hda_codec_write(codec, nid, 0, 0x707, 0);
> + codec_dbg(codec, "mute_speaker, set 0x%x PinCtrl to 0.\n", nid);
> + } else {
> + snd_hda_codec_write(codec, nid, 0, 0x707, 0x40);
> + codec_dbg(codec, "unmute_speaker, set 0x%x PinCtrl to 0x40.\n", nid);
> + }
> +}
> +
> +static void change_pinctl_worker(struct work_struct *work)
> +{
> + struct hda_codec *codec;
> + struct conexant_spec *spec;
> +
> + spec = container_of(work, struct conexant_spec, change_pinctl_work.work);
> + codec = spec->conexant_codec;
> +
> + return mute_unmute_speaker(codec, 0x17, false);
return-statement in void? The code won't compile. Was the patch tested
at all?
> +}
prev parent reply other threads:[~2025-11-05 15:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-05 2:25 wangdich9700
2025-11-05 15:45 ` Cezary Rojewski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d57548e1-3f23-4b9e-84c2-cfdc31e92e1e@intel.com \
--to=cezary.rojewski@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=wangdich9700@163.com \
--cc=wangdicheng@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®