Re: [PATCH] correct boot value
From: Takashi Iwai
Date: Mon Jun 09 2025 - 04:03:22 EST
On Mon, 09 Jun 2025 08:53:30 +0200,
feng.liu wrote:
>
> Read the Boost Level configured for input pins in the BIOS
> init verbs, and restore these settings during audio recording.
> This addresses issues of low recording volume or excessive
> background noise caused by incorrect boost configurations.
> Compare with the last commit:
> 1.Correct the function definition; cxt_get_default_capture_gain_boost
> does not require a return value.
> 2.Check array indices to prevent operations causing memory out-of-bounds
> access.
>
> Signed-off-by: feng.liu <feng.liu@xxxxxxxxxxxxxx>
Hm, this fix doesn't look right, unfortunately.
Aren't those boost values controlled via mixer elements? If so, they
are silently overridden.
If those controls are exposed to user-space but they shouldn't be
touched, we should rather drop exposing those and keep the original
values.
Last but not least, please adjust the subject line of your patch
mail. It should have a proper prefix (e.g. "ALSA: hda/conexant: ...")
Also, when you respin the patch, please put a new version prefix, too
(e.g. "[PATCH v2]"). Also, the subject text should be a bit more
descriptive, too (but shouldn't be too long, either).
Moreover, the diffs from the previous submission can be put after the
line "---", so that it won't be taken at applying.
thanks,
Takashi
> ---
> sound/pci/hda/patch_conexant.c | 49 ++++++++++++++++++++++++++++++++++
> 1 file changed, 49 insertions(+)
>
> diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
> index 34874039ad4..95c76bb8e3c 100644
> --- a/sound/pci/hda/patch_conexant.c
> +++ b/sound/pci/hda/patch_conexant.c
> @@ -43,6 +43,8 @@ struct conexant_spec {
> unsigned int gpio_mute_led_mask;
> unsigned int gpio_mic_led_mask;
> bool is_cx8070_sn6140;
> +
> + unsigned char init_imux_boost_val[HDA_MAX_NUM_INPUTS];
> };
>
>
> @@ -1178,6 +1180,51 @@ static void add_cx5051_fake_mutes(struct hda_codec *codec)
> spec->gen.dac_min_mute = true;
> }
>
> +static void cxt_fixed_mic_boost(struct hda_codec *codec,
> + unsigned char node_id,
> + unsigned char mic_boost)
> +{
> + unsigned char value = 0;
> +
> + value = snd_hda_codec_read(codec, node_id, 0, AC_VERB_GET_AMP_GAIN_MUTE, 0);
> + if (value != mic_boost)
> + snd_hda_codec_amp_stereo(codec, node_id, HDA_INPUT, 0, HDA_AMP_VOLMASK, mic_boost);
> +}
> +
> +static void cxt_cap_sync_hook(struct hda_codec *codec,
> + struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + struct conexant_spec *spec = codec->spec;
> + hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
> +
> + if (spec->init_imux_boost_val[mux_pin])
> + cxt_fixed_mic_boost(codec, mux_pin, spec->init_imux_boost_val[mux_pin]);
> +}
> +
> +static void cxt_get_default_capture_gain_boost(struct hda_codec *codec)
> +{
> + struct conexant_spec *spec = codec->spec;
> + int i;
> + unsigned int boost;
> +
> + spec->init_imux_boost_val[0] = 0;
> + for (i = 0; i < HDA_MAX_NUM_INPUTS; i++) {
> + if (spec->gen.imux_pins[i] == 0)
> + continue;
> +
> + if (spec->gen.imux_pins[i] < HDA_MAX_NUM_INPUTS) {
> + boost = snd_hda_codec_read(codec, spec->gen.imux_pins[i],
> + 0, AC_VERB_GET_AMP_GAIN_MUTE, 0);
> + spec->init_imux_boost_val[spec->gen.imux_pins[i]] = boost;
> + codec_info(codec, "%s, node_id = %x, mic_boost =%x", __func__,
> + spec->gen.imux_pins[i], boost);
> + }
> + }
> +
> + spec->gen.cap_sync_hook = cxt_cap_sync_hook;
> +}
> +
> static int patch_conexant_auto(struct hda_codec *codec)
> {
> struct conexant_spec *spec;
> @@ -1245,6 +1292,8 @@ static int patch_conexant_auto(struct hda_codec *codec)
> if (!spec->gen.vmaster_mute.hook && spec->dynamic_eapd)
> spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook;
>
> + cxt_get_default_capture_gain_boost(codec);
> +
> snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
>
> err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL,
> --
> 2.45.2
>