lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250609065331.495109-1-feng.liu@senarytech.com>
Date: Mon,  9 Jun 2025 14:53:30 +0800
From: "feng.liu" <feng.liu@...arytech.com>
To: perex@...ex.cz,
	tiwai@...e.com
Cc: linux-sound@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	"feng.liu" <feng.liu@...arytech.com>
Subject: [PATCH] correct boot value

  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@...arytech.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ