Linux Sound subsystem development
 help / color / mirror / Atom feed
From: bo liu <bo.liu@senarytech.com>
To: perex@perex.cz, tiwai@suse.com
Cc: linux-sound@vger.kernel.org, bo liu <bo.liu@senarytech.com>
Subject: [PATCH V4] Initialize the gain and boost values of the ADC in the SN6180 chip to achieve a better recording experience.
Date: Tue, 25 Mar 2025 14:09:56 +0800	[thread overview]
Message-ID: <20250325060956.1139955-1-bo.liu@senarytech.com> (raw)

Signed-off-by: bo liu <bo.liu@senarytech.com>
---
 sound/pci/hda/patch_conexant.c | 37 ++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 34874039ad45..7017db4a0fee 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -185,6 +185,40 @@ static void cx_fixup_headset_recog(struct hda_codec *codec)
 		snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20);
 }
 
+static void cxt_setup_capture_default_boost_gain(struct hda_codec *codec)
+{
+	struct conexant_spec *spec = codec->spec;
+	struct hda_gen_spec *gen = &(spec->gen);
+	hda_nid_t adc_id = 0, nid = 0;
+	int nids;
+	size_t i = 0;
+
+	for (i = 0; i < gen->num_all_adcs; i++) {
+		int index;
+
+		adc_id = gen->all_adcs[i];
+
+		index = snd_hda_codec_read(codec, adc_id, 0, AC_VERB_GET_CONNECT_SEL, 0);
+		nids = snd_hda_codec_read(codec, adc_id, 0, AC_VERB_GET_CONNECT_LIST, 0);
+		nid = ((nids & (0xFF << (8*index))) >> (8*index));
+
+		if (nid < codec->core.start_nid || nid > codec->core.end_nid) {
+			codec_err(codec, "Error, invalid nid 0x%02x.\n", nid);
+			continue;
+		}
+
+		snd_hda_codec_write(codec, adc_id, 0, (0x370|(index&0xF)), 0x4A);
+		snd_hda_codec_write(codec, nid, 0, 0x370, 0x2);
+		codec_dbg(codec, "ADC 0x%02x, nid=0x%02x are set. Boost=2, gain=0x4A.\n",
+			adc_id, nid);
+	}
+}
+
+static void cxt_init_capture_boost_gain(struct hda_codec *codec)
+{
+	cxt_setup_capture_default_boost_gain(codec);
+}
+
 static int cx_auto_init(struct hda_codec *codec)
 {
 	struct conexant_spec *spec = codec->spec;
@@ -198,6 +232,9 @@ static int cx_auto_init(struct hda_codec *codec)
 	if (spec->is_cx8070_sn6140)
 		cx_fixup_headset_recog(codec);
 
+	if (codec->core.vendor_id == 0x14f120d1) //SN6180
+		cxt_init_capture_boost_gain(codec);
+
 	return 0;
 }
 
-- 
2.34.1


             reply	other threads:[~2025-03-25  6:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-25  6:09 bo liu [this message]
2025-03-25 10:54 ` [PATCH V4] Initialize the gain and boost values of the ADC in the SN6180 chip to achieve a better recording experience 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=20250325060956.1139955-1-bo.liu@senarytech.com \
    --to=bo.liu@senarytech.com \
    --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