Skip to contentSkip to conversation

ALSA: hda/senarytech: add senarytech codec support

PATCH In review bo liu 2 participants 2 messages Jun 6, 2024 – Jun 13, 2024 Sound

lore
Share & tools
lore

bo liu

author
#0 lore raw

PATCH v2 1/1 ALSA: hda/senarytech: add senarytech codec support

Add initial Senarytech codec support for SN6186. Note that this hda patch relies on the configuration default registers to be set correctly (normally by BIOS/firmware) in order for it to set up pin widgets properly.

---
 MAINTAINERS                      |   6 +
 sound/hda/hdac_device.c          |   1 +
 sound/pci/hda/Kconfig            |  11 ++
 sound/pci/hda/Makefile           |   2 +
 sound/pci/hda/patch_senarytech.c | 263 +++++++++++++++++++++++++++++++
 5 files changed, 283 insertions(+)
 create mode 100644 sound/pci/hda/patch_senarytech.c
MAINTAINERS +6 -0
index a6a011792167..82ea8c8f74c1 100644
@@ -24949,6 +24949,12 @@ F:	mm/zpool.c
 F:	mm/zswap.c
 F:	tools/testing/selftests/cgroup/test_zswap.c
 
+SENARYTECH AUDIO CODEC DRIVER
+M:	bo liu <[email protected]>
+S:	Maintained
+T:	git git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
+F:	sound/pci/hda/patch_senarytech.c
+
 THE REST
 M:	Linus Torvalds <[email protected]>
 L:	[email protected]
sound/hda/hdac_device.c +1 -0
index 068c16e52dff..3fbb9793dcfc 100644
@@ -665,6 +665,7 @@ static const struct hda_vendor_id hda_vendor_ids[] = {
 	{ 0x19e5, "Huawei" },
 	{ 0x1aec, "Wolfson Microelectronics" },
 	{ 0x1af4, "QEMU" },
+	{ 0x1fa8, "Senarytech" },
 	{ 0x434d, "C-Media" },
 	{ 0x8086, "Intel" },
 	{ 0x8384, "SigmaTel" },
sound/pci/hda/Kconfig +11 -0
index 0da625533afc..1252632f0ffa 100644
@@ -292,6 +292,17 @@ config SND_HDA_CODEC_CONEXANT
 comment "Set to Y if you want auto-loading the codec driver"
 	depends on SND_HDA=y && SND_HDA_CODEC_CONEXANT=m
 
+config SND_HDA_CODEC_SENARYTECH
+	tristate "Build Senarytech HD-audio codec support"
+	select SND_HDA_GENERIC
+	select SND_HDA_GENERIC_LEDS
+	help
+	  Say Y or M here to include Senarytech HD-audio codec support in
+	  snd-hda-intel driver, such as SN6186.
+
+comment "Set to Y if you want auto-loading the codec driver"
+	depends on SND_HDA=y && SND_HDA_CODEC_SENARYTECH=m
+
 config SND_HDA_CODEC_CA0110
 	tristate "Build Creative CA0110-IBG codec support"
 	select SND_HDA_GENERIC
sound/pci/hda/Makefile +2 -0
index 058ca0a289e4..7ac2105c2e00 100644
@@ -24,6 +24,7 @@ snd-hda-codec-cs8409-y :=	patch_cs8409.o patch_cs8409-tables.o
 snd-hda-codec-ca0110-y :=	patch_ca0110.o
 snd-hda-codec-ca0132-y :=	patch_ca0132.o
 snd-hda-codec-conexant-y :=	patch_conexant.o
+snd-hda-codec-senarytech-objs :=patch_senarytech.o
 snd-hda-codec-via-y :=		patch_via.o
 snd-hda-codec-hdmi-y :=		patch_hdmi.o hda_eld.o
 
@@ -55,6 +56,7 @@ obj-$(CONFIG_SND_HDA_CODEC_CS8409) += snd-hda-codec-cs8409.o
 obj-$(CONFIG_SND_HDA_CODEC_CA0110) += snd-hda-codec-ca0110.o
 obj-$(CONFIG_SND_HDA_CODEC_CA0132) += snd-hda-codec-ca0132.o
 obj-$(CONFIG_SND_HDA_CODEC_CONEXANT) += snd-hda-codec-conexant.o
+obj-$(CONFIG_SND_HDA_CODEC_SENARYTECH) += snd-hda-codec-senarytech.o
 obj-$(CONFIG_SND_HDA_CODEC_VIA) += snd-hda-codec-via.o
 obj-$(CONFIG_SND_HDA_CODEC_HDMI) += snd-hda-codec-hdmi.o
 
sound/pci/hda/patch_senarytech.c new file +263 -0

263 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw
Quoted 7 lines · bo liu

Add initial Senarytech codec support for SN6186. Note that this hda patch relies on the configuration default registers to be set correctly (normally by BIOS/firmware) in order for it to set up pin widgets properly.

The code looks almost fine, just a few nitpicking:

sound/pci/hda/Makefile snd-hda-codec-cs8409-y := patch_cs8409.o patch_cs8409-tables.o · line 27

Quoted 7 lines
sound/pci/hda/Makefile +1 -0
@@ -24,6 +24,7 @@ snd-hda-codec-cs8409-y :=	patch_cs8409.o patch_cs8409-tables.o
 snd-hda-codec-ca0110-y :=	patch_ca0110.o
 snd-hda-codec-ca0132-y :=	patch_ca0132.o
 snd-hda-codec-conexant-y :=	patch_conexant.o
+snd-hda-codec-senarytech-objs :=patch_senarytech.o

Use *-y instead of *-objs. The other entries have been corrected recently.

Quoted 14 lines
sound/pci/hda/Makefile +14 -0
+/* parse EAPDs */
+static void senary_auto_parse_eapd(struct hda_codec *codec)
+{
+	struct senary_spec *spec = codec->spec;
+	hda_nid_t nid;
+
+	for_each_hda_codec_node(nid, codec) {
+		if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
+			continue;
+		if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD))
+			continue;
+		spec->eapds[spec->num_eapds++] = nid;
+		if (spec->num_eapds >= ARRAY_SIZE(spec->eapds))
+			break;

sound/pci/hda/Makefile snd-hda-codec-cs8409-y := patch_cs8409.o patch_cs8409-tables.o

Quoted 10 lines
sound/pci/hda/Makefile +10 -0
+	}
+
+	/* NOTE: below is a wild guess; if we have more than two EAPDs,
+	 * it's a new chip, where EAPDs are supposed to be associated to
+	 * pins, and we can control EAPD per pin.
+	 * OTOH, if only one or two EAPDs are found, it's an old chip,
+	 * thus it might control over all pins.
+	 */
+	if (spec->num_eapds > 2)
+		spec->dynamic_eapd = 1;

Do you still need to verify this? This is copied from Conexant driver, and they needed this workaround due to different handling per chip model. Unless needed, better to drop (or assuming always true) this condition for simplicity.

sound/pci/hda/Makefile

Quoted 7 lines
sound/pci/hda/Makefile +7 -0
+#ifdef CONFIG_PM
+static int senary_auto_suspend(struct hda_codec *codec)
+{
+	senary_auto_shutdown(codec);
+	return 0;
+}
+#endif

The latest code dropped the dependency on CONFIG_PM. Remove ifdef.

sound/pci/hda/Makefile

Quoted 10 lines
sound/pci/hda/Makefile +10 -0
+static const struct hda_codec_ops senary_auto_patch_ops = {
+	.build_controls = snd_hda_gen_build_controls,
+	.build_pcms = snd_hda_gen_build_pcms,
+	.init = senary_auto_init,
+	.free = senary_auto_free,
+	.unsol_event = snd_hda_jack_unsol_event,
+#ifdef CONFIG_PM
+	.suspend = senary_auto_suspend,
+	.check_power_status = snd_hda_gen_check_power_status,
+#endif

Ditto.

thanks,

Takashi