[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Zx9cbCq5jl3tOJAk@smile.fi.intel.com>
Date: Mon, 28 Oct 2024 11:42:04 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Baojun Xu <baojun.xu@...com>
Cc: tiwai@...e.de, robh+dt@...nel.org, lgirdwood@...il.com, perex@...ex.cz,
pierre-louis.bossart@...ux.intel.com, shenghao-ding@...com,
navada@...com, 13916275206@....com, v-hampiholi@...com, v-po@...com,
linux-sound@...r.kernel.org, linux-kernel@...r.kernel.org,
liam.r.girdwood@...el.com, yung-chuan.liao@...ux.intel.com,
broonie@...nel.org, antheas.dk@...il.com
Subject: Re: [PATCH v3] ALSA: hda/tas2781: Add speaker id check for ASUS
projects
On Sun, Oct 27, 2024 at 10:39:35PM +0800, Baojun Xu wrote:
> 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.
...
> + // Speaker id was needed for ASUS projects.
> + if (!strncasecmp(sub, TAS2781_ASUS_ID, sizeof(TAS2781_ASUS_ID))) {
Why "case"? Just use strcmp() since the second one is constant and you use it's
length.
> + devm_acpi_dev_add_driver_gpios(p->dev,
> + tas2781_speaker_id_gpios);
I don't know why you completely removed the check, I would leave a debug
message on the error path to give a clue to the user if it fails here.
See how other driver do with this.
Something like
ret = devm_acpi_dev_add_driver_gpios(p->dev, tas2781_speaker_id_gpios);
if (ret)
dev_dbg(...);
> + 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");
Wrong value in ret, right?
> + goto err;
> + }
> + } else {
> + p->speaker_id = NULL;
> + }
>
> acpi_dev_free_resource_list(&resources);
> strscpy(p->dev_name, hid, sizeof(p->dev_name));
> + put_device(physdev);
> acpi_dev_put(adev);
>
> return 0;
>
> err:
> dev_err(p->dev, "read acpi error, ret: %d\n", ret);
> + put_device(physdev);
> acpi_dev_put(adev);
>
> return ret;
...
> + if (tas_priv->speaker_id != NULL) {
> + // Speaker id need to be checked for ASUS only.
> + spk_id = gpiod_get_value(tas_priv->speaker_id);
> + if (spk_id < 0) {
> + // Speaker id is not valid, use default.
> + dev_dbg(tas_priv->dev, "Wrong spk_id = %d\n", spk_id);
> + spk_id = 0;
> + }
> + snprintf(tas_priv->coef_binaryname,
> + sizeof(tas_priv->coef_binaryname),
> + "TAS2XXX%04X%01d.bin",
%01d makes a little sense. Just use %d.
> + lower_16_bits(codec->core.subsystem_id),
> + spk_id);
> + } else {
> + snprintf(tas_priv->coef_binaryname,
> + sizeof(tas_priv->coef_binaryname),
> + "TAS2XXX%04X.bin",
> + lower_16_bits(codec->core.subsystem_id));
> + }
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists