[PATCH] Correct boost volume

feng.liu posted 1 patch 6 months, 2 weeks ago
sound/pci/hda/patch_conexant.c | 46 ++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
[PATCH] Correct boost volume
Posted by feng.liu 6 months, 2 weeks ago
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. 

Signed-off-by: feng.liu <feng.liu@senarytech.com>

---
 sound/pci/hda/patch_conexant.c | 46 ++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 34874039ad4..77101363e06 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,48 @@ 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 int cxt_get_defaut_capture_gain_boost(struct hda_codec *codec)
+{
+	struct conexant_spec *spec = codec->spec;
+	int i;
+	unsigned int boost;
+
+	for (i = 0; i < HDA_MAX_NUM_INPUTS; i++) {
+		if (spec->gen.imux_pins[i] == 0)
+			continue;
+
+		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 +1289,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_defaut_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
Re: [PATCH] Correct boost volume
Posted by kernel test robot 6 months, 2 weeks ago
Hi feng.liu,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on tiwai-sound/for-linus linus/master v6.15 next-20250606]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/feng-liu/Correct-boost-volume/20250606-201348
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
patch link:    https://lore.kernel.org/r/20250606113349.129746-1-feng.liu%40senarytech.com
patch subject: [PATCH] Correct boost volume
config: i386-buildonly-randconfig-002-20250607 (https://download.01.org/0day-ci/archive/20250607/202506070421.thMBn9rY-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250607/202506070421.thMBn9rY-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202506070421.thMBn9rY-lkp@intel.com/

All warnings (new ones prefixed by >>):

   sound/pci/hda/patch_conexant.c: In function 'cxt_get_defaut_capture_gain_boost':
>> sound/pci/hda/patch_conexant.c:1223:1: warning: no return statement in function returning non-void [-Wreturn-type]
    1223 | }
         | ^


vim +1223 sound/pci/hda/patch_conexant.c

  1204	
  1205	static int cxt_get_defaut_capture_gain_boost(struct hda_codec *codec)
  1206	{
  1207		struct conexant_spec *spec = codec->spec;
  1208		int i;
  1209		unsigned int boost;
  1210	
  1211		for (i = 0; i < HDA_MAX_NUM_INPUTS; i++) {
  1212			if (spec->gen.imux_pins[i] == 0)
  1213				continue;
  1214	
  1215			boost = snd_hda_codec_read(codec, spec->gen.imux_pins[i],
  1216				0, AC_VERB_GET_AMP_GAIN_MUTE, 0);
  1217			spec->init_imux_boost_val[spec->gen.imux_pins[i]] = boost;
  1218			codec_info(codec, "%s, node_id = %x, mic_boost =%x", __func__,
  1219				spec->gen.imux_pins[i], boost);
  1220		}
  1221	
  1222		spec->gen.cap_sync_hook = cxt_cap_sync_hook;
> 1223	}
  1224	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki