Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH v7] ALSA: hda/tas2781: Add speaker id check for ASUS projects
@ 2024-12-24  8:56 Baojun Xu
  2024-12-26 16:10 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Baojun Xu @ 2024-12-24  8:56 UTC (permalink / raw)
  To: tiwai
  Cc: robh+dt, andriy.shevchenko, lgirdwood, perex, shenghao-ding,
	navada, 13916275206, v-hampiholi, v-po, linux-sound, linux-kernel,
	liam.r.girdwood, yung-chuan.liao, baojun.xu, broonie, antheas.dk,
	stuart.a.hayhurst

Add speaker id check by gpio in ACPI for ASUS projects.
In other vendors, speaker id was checked by BIOS, and was applied in
last bit of subsys id, so we can load corresponding firmware binary file
for its speaker by subsys id.
But in ASUS project, the firmware binary name will be appended an extra
number to tell the speakers from different vendors. And this single digit
come from gpio level of speaker id in BIOS.

Signed-off-by: Baojun Xu <baojun.xu@ti.com>
---
v7:
 - Do not return with error if subsys id was not found,
   it will cause error on TAS2563 projects (have no subsys id).
v6:
 - Remove define for AUSU in tas2781.h.
 - Add include linux/pci_ids.h for use public ASUS id define.
 - Add subid for ASUS id save and check.
 - Change comments to /* */ from //.
 - Change next line indented to (.
 - Change ASUS check from string compare to u16 compare.
v5:
 - Change length in strncmp(), use strlen().
v4:
 - Change strncasecmp() to strncmp().
 - Add error debug message print for "add driver gpio".
 - Put error information (PTR_ERR) to ret for get gpio.
 - Change %01d to %d in snprintf().
v3:
 - Change strstr() to strncasecmp() for compare subsystem id.
 - Remove result check after devm_acpi_dev_add_driver_gpios().
 - Remove spk_id > 1 check, as result of gpiod_get_value(),
   must be 0 or 1, or negative if error happend.
 - Change scnprintf() to snprintf(), as didn't care the length.
 - Remove changes which not relative current patch.
v2:
 - Change ASUS id from 0x10430000 to "1043".
 - Move gpio setting to tas2781_read_acpi() from probe.
 - Remove interrupt gpio in acpi_gpio_mapping.
 - Add sub and physdev in tas2781_read_acpi() for subsys id read.
 - Add debug log for get acpi resource failed.
 - Return error if get resource or subsys id failed.
 - Return error if get gpio fail for speaker id with ASUS projects.
 - Change fixed buffer lengh to sizeof().
 - Change bits calculator to lower_16_bits().
 - Remove unnecessary empty line in tas2781_hda_i2c_probe().
---
 sound/pci/hda/tas2781_hda_i2c.c | 39 +++++++++++++++++----------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/sound/pci/hda/tas2781_hda_i2c.c b/sound/pci/hda/tas2781_hda_i2c.c
index 0af015806aba..f2576c53ad6e 100644
--- a/sound/pci/hda/tas2781_hda_i2c.c
+++ b/sound/pci/hda/tas2781_hda_i2c.c
@@ -140,28 +140,29 @@ static int tas2781_read_acpi(struct tasdevice_priv *p, const char *hid)
 		dev_err(p->dev, "Failed to get ACPI resource.\n");
 		goto err;
 	}
+	p->speaker_id = NULL;
 	sub = acpi_get_subsystem_id(ACPI_HANDLE(physdev));
 	if (IS_ERR(sub)) {
-		dev_err(p->dev, "Failed to get SUBSYS ID.\n");
-		ret = PTR_ERR(sub);
-		goto err;
-	}
-	/* Speaker id was needed for ASUS projects. */
-	ret = kstrtou32(sub, 16, &subid);
-	if (!ret && upper_16_bits(subid) == PCI_VENDOR_ID_ASUSTEK) {
-		ret = devm_acpi_dev_add_driver_gpios(p->dev,
-			tas2781_speaker_id_gpios);
-		if (ret < 0)
-			dev_err(p->dev, "Failed to add driver gpio %d.\n",
-				ret);
-		p->speaker_id = devm_gpiod_get(p->dev, "speakerid", GPIOD_IN);
-		if (IS_ERR(p->speaker_id)) {
-			dev_err(p->dev, "Failed to get Speaker id.\n");
-			ret = PTR_ERR(p->speaker_id);
-			goto err;
-		}
+		/* Project TAS2563 have no subsys id. */
+		dev_info(p->dev, "Failed %d to get SUBSYS ID.\n",
+			 PTR_ERR(sub));
 	} else {
-		p->speaker_id = NULL;
+		/* Speaker id was needed for ASUS projects. */
+		ret = kstrtou32(sub, 16, &subid);
+		if (!ret && upper_16_bits(subid) == PCI_VENDOR_ID_ASUSTEK) {
+			ret = devm_acpi_dev_add_driver_gpios(p->dev,
+				tas2781_speaker_id_gpios);
+			if (ret < 0)
+				dev_err(p->dev, "Failed to add gpio %d.\n",
+					ret);
+			p->speaker_id = devm_gpiod_get(p->dev, "speakerid",
+						       GPIOD_IN);
+			if (IS_ERR(p->speaker_id)) {
+				dev_err(p->dev, "Failed to get Speaker id.\n");
+				ret = PTR_ERR(p->speaker_id);
+				goto err;
+			}
+		}
 	}
 
 	acpi_dev_free_resource_list(&resources);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-12-26 16:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-24  8:56 [PATCH v7] ALSA: hda/tas2781: Add speaker id check for ASUS projects Baojun Xu
2024-12-26 16:10 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox