ALSA: hda/tas2781: Add speaker id check for ASUS projects
Subsystems (2)
Baojun Xu
maintainerPATCH v4 1/1 ALSA: hda/tas2781: Add speaker id check for ASUS projects
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.
---
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().
--- include/sound/tas2781.h | 3 ++ sound/pci/hda/tas2781_hda_i2c.c | 64 +++++++++++++++++++++++++++++---- 2 files changed, 61 insertions(+), 6 deletions(-)
include/sound/tas2781.h +3 -0
@@ -107,6 +107,8 @@#define TASDEVICE_CMD_DELAY 0x3#define TASDEVICE_CMD_FIELD_W 0x4 +#define TAS2781_ASUS_ID "1043" +enum audio_device {TAS2563 ,TAS2781 ,
@@ -156,6 +158,7 @@ struct tasdevice_priv {struct tasdevice_rca rcabin;struct calidata cali_data;struct tasdevice_fw *fmw; +struct gpio_desc *speaker_id;struct gpio_desc *reset;struct mutex codec_lock;struct regmap *regmap;
sound/pci/hda/tas2781_hda_i2c.c +58 -6
101 lines not on this page · raw message
Signature · 1 line
2.43.0
sound/pci/hda/tas2781_hda_i2c.c static int tas2781_read_acpi(struct tasdevice_priv *p, const char *hid) · line 147
Quoted 2 lines · Baojun Xu
sound/pci/hda/tas2781_hda_i2c.c +2
-0+// Speaker id was needed for ASUS projects. +if (!strncmp (sub,TAS2781_ASUS_ID ,sizeof (TAS2781_ASUS_ID ))) {
Is this really correct? The sizeof(TAS2781_ASUS_ID) is 5, including the terminating NUL. So this becomes equivalent with strcmp(), and it doesn't check the sub-string.
thanks,
Takashi
Quoted 8 lines · Takashi Iwai
sound/pci/hda/tas2781_hda_i2c.c static int tas2781_read_acpi(struct tasdevice_priv *p, const char *hid) · line 147
Quoted 2 lines · Baojun Xu
sound/pci/hda/tas2781_hda_i2c.c +2
-0+// Speaker id was needed for ASUS projects. +if (!strncmp (sub,TAS2781_ASUS_ID ,sizeof (TAS2781_ASUS_ID ))) {Is this really correct? The
sizeof(TAS2781_ASUS_ID)is 5, including the terminating NUL. So this becomes equivalent withstrcmp(), and it doesn't check the sub-string.
It all depends to what that method returns. If it returns the exact string then strcmp() is fine, if not, we should understand what it returns then.
Signature · 2 lines
With Best Regards, Andy Shevchenko