From: "feng.liu" <feng.liu@senarytech.com>
To: perex@perex.cz, tiwai@suse.com
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
"feng.liu" <feng.liu@senarytech.com>
Subject: [PATCH] correct boot value
Date: Mon, 9 Jun 2025 14:53:30 +0800 [thread overview]
Message-ID: <20250609065331.495109-1-feng.liu@senarytech.com> (raw)
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@senarytech.com>
---
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
next reply other threads:[~2025-06-09 8:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-09 6:53 feng.liu [this message]
2025-06-09 8:03 ` Takashi Iwai
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=20250609065331.495109-1-feng.liu@senarytech.com \
--to=feng.liu@senarytech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/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®