From: Shenghao Ding <shenghao-ding@ti.com>
To: <tiwai@suse.de>
Cc: <broonie@kernel.org>, <andriy.shevchenko@linux.intel.com>,
<13564923607@139.com>, <13916275206@139.com>,
<alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>,
<baojun.xu@ti.com>, <Baojun.Xu@fpt.com>, <jesse-ji@ti.com>,
Shenghao Ding <shenghao-ding@ti.com>
Subject: [PATCH v1] ALSA: hda/tas2781: Support L"SmartAmpCalibrationData" to save calibrated data
Date: Tue, 5 Aug 2025 15:09:45 +0800 [thread overview]
Message-ID: <20250805070945.524-1-shenghao-ding@ti.com> (raw)
Some devices save the calibrated data into L"CALI_DATA", and others into
L"SmartAmpCalibrationData". Driver code will support both.
Signed-off-by: Shenghao Ding <shenghao-ding@ti.com>
---
sound/hda/codecs/side-codecs/tas2781_hda.c | 47 +++++++++++++++-------
sound/hda/codecs/side-codecs/tas2781_hda.h | 2 +-
2 files changed, 33 insertions(+), 16 deletions(-)
diff --git a/sound/hda/codecs/side-codecs/tas2781_hda.c b/sound/hda/codecs/side-codecs/tas2781_hda.c
index 34217ce9f28e..f46d2e06c64f 100644
--- a/sound/hda/codecs/side-codecs/tas2781_hda.c
+++ b/sound/hda/codecs/side-codecs/tas2781_hda.c
@@ -18,6 +18,8 @@
#include "tas2781_hda.h"
+#define CALIBRATION_DATA_AREA_NUM 2
+
const efi_guid_t tasdev_fct_efi_guid[] = {
/* DELL */
EFI_GUID(0xcc92382d, 0x6337, 0x41cb, 0xa8, 0x8b, 0x8e, 0xce, 0x74,
@@ -160,36 +162,51 @@ int tas2781_save_calibration(struct tas2781_hda *hda)
* manufactory.
*/
efi_guid_t efi_guid = tasdev_fct_efi_guid[LENOVO];
- static efi_char16_t efi_name[] = TASDEVICE_CALIBRATION_DATA_NAME;
+ /*
+ * Some devices save the calibrated data into L"CALI_DATA",
+ * and others into L"SmartAmpCalibrationData".
+ */
+ static efi_char16_t *efi_name[CALIBRATION_DATA_AREA_NUM] = {
+ L"CALI_DATA",
+ L"SmartAmpCalibrationData",
+ };
struct tasdevice_priv *p = hda->priv;
struct calidata *cali_data = &p->cali_data;
unsigned long total_sz = 0;
unsigned int attr, size;
unsigned char *data;
efi_status_t status;
+ int i;
if (hda->catlog_id < LENOVO)
efi_guid = tasdev_fct_efi_guid[hda->catlog_id];
cali_data->cali_dat_sz_per_dev = 20;
size = p->ndev * (cali_data->cali_dat_sz_per_dev + 1);
- /* Get real size of UEFI variable */
- status = efi.get_variable(efi_name, &efi_guid, &attr, &total_sz, NULL);
- cali_data->total_sz = total_sz > size ? total_sz : size;
- if (status == EFI_BUFFER_TOO_SMALL) {
- /* Allocate data buffer of data_size bytes */
- data = p->cali_data.data = devm_kzalloc(p->dev,
- p->cali_data.total_sz, GFP_KERNEL);
- if (!data) {
- p->cali_data.total_sz = 0;
- return -ENOMEM;
+ for (i = 0; i < CALIBRATION_DATA_AREA_NUM; i++) {
+ /* Get real size of UEFI variable */
+ status = efi.get_variable(efi_name[i], &efi_guid, &attr,
+ &total_sz, NULL);
+ cali_data->total_sz = total_sz > size ? total_sz : size;
+ if (status == EFI_BUFFER_TOO_SMALL) {
+ /* Allocate data buffer of data_size bytes */
+ data = cali_data->data = devm_kzalloc(p->dev,
+ cali_data->total_sz, GFP_KERNEL);
+ if (!data) {
+ status = -ENOMEM;
+ continue;
+ }
+ /* Get variable contents into buffer */
+ status = efi.get_variable(efi_name[i], &efi_guid,
+ &attr, &cali_data->total_sz, data);
}
- /* Get variable contents into buffer */
- status = efi.get_variable(efi_name, &efi_guid, &attr,
- &p->cali_data.total_sz, data);
+ /* Check whether get the calibrated data */
+ if (status == EFI_SUCCESS)
+ break;
}
+
if (status != EFI_SUCCESS) {
- p->cali_data.total_sz = 0;
+ cali_data->total_sz = 0;
return status;
}
diff --git a/sound/hda/codecs/side-codecs/tas2781_hda.h b/sound/hda/codecs/side-codecs/tas2781_hda.h
index 575a701c8dfb..66188909a0bb 100644
--- a/sound/hda/codecs/side-codecs/tas2781_hda.h
+++ b/sound/hda/codecs/side-codecs/tas2781_hda.h
@@ -11,7 +11,7 @@
/* Flag of calibration registers address. */
#define TASDEV_UEFI_CALI_REG_ADDR_FLG BIT(7)
-#define TASDEVICE_CALIBRATION_DATA_NAME L"CALI_DATA"
+
#define TASDEV_CALIB_N 5
/*
--
2.43.0
next reply other threads:[~2025-08-05 7:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 7:09 Shenghao Ding [this message]
2025-08-06 6:07 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250805070945.524-1-shenghao-ding@ti.com \
--to=shenghao-ding@ti.com \
--cc=13564923607@139.com \
--cc=13916275206@139.com \
--cc=Baojun.Xu@fpt.com \
--cc=alsa-devel@alsa-project.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=baojun.xu@ti.com \
--cc=broonie@kernel.org \
--cc=jesse-ji@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®