* [PATCH V4] Initialize the gain and boost values of the ADC in the SN6180 chip to achieve a better recording experience.
@ 2025-03-25 6:09 bo liu
2025-03-25 10:54 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: bo liu @ 2025-03-25 6:09 UTC (permalink / raw)
To: perex, tiwai; +Cc: linux-sound, bo liu
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH V4] Initialize the gain and boost values of the ADC in the SN6180 chip to achieve a better recording experience.
2025-03-25 6:09 [PATCH V4] Initialize the gain and boost values of the ADC in the SN6180 chip to achieve a better recording experience bo liu
@ 2025-03-25 10:54 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2025-03-25 10:54 UTC (permalink / raw)
To: bo liu; +Cc: perex, tiwai, linux-sound
On Tue, 25 Mar 2025 07:09:56 +0100,
bo liu wrote:
>
> Signed-off-by: bo liu <bo.liu@senarytech.com>
First off, could you use a proper subject line? It should be more
concise, and have a prefix such as "ALSA: hda/conexant:".
Then put more information in the patch description, instead of putting
to the subject line.
About the code change:
>
> +static void cxt_setup_capture_default_boost_gain(struct hda_codec *codec)
> +{
Better to give more comments about what this function actually does.
> + struct conexant_spec *spec = codec->spec;
> + struct hda_gen_spec *gen = &(spec->gen);
No need for parentheses.
> + hda_nid_t adc_id = 0, nid = 0;
Why initializing those?
> + int nids;
This should be either u32 or unsigned int.
> + size_t i = 0;
It's superfluous initialization.
> +
> + 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));
It's simpler and clearer to do right-shift at first, then mask.
> + 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);
Too cryptic. Use the defined verbs.
> + snd_hda_codec_write(codec, nid, 0, 0x370, 0x2);
Ditto.
> + }
> +}
> +
> +static void cxt_init_capture_boost_gain(struct hda_codec *codec)
> +{
> + cxt_setup_capture_default_boost_gain(codec);
> +}
Why nested calls...?
thanks,
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-25 10:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-25 6:09 [PATCH V4] Initialize the gain and boost values of the ADC in the SN6180 chip to achieve a better recording experience bo liu
2025-03-25 10:54 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox