mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gergo Koteles <soyer@irl.hu>
To: Shenghao Ding <shenghao-ding@ti.com>, Kevin Lu <kevin-lu@ti.com>,
	Baojun Xu <baojun.xu@ti.com>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org,
	Gergo Koteles <soyer@irl.hu>
Subject: [PATCH 06/16] ASoC: tas2781: add ptrs to calibration functions
Date: Thu,  7 Dec 2023 00:59:47 +0100	[thread overview]
Message-ID: <e069d578aebb8d5aa1c09abae2a0f240b3dedec2.1701906455.git.soyer@irl.hu> (raw)
In-Reply-To: <cover.1701906455.git.soyer@irl.hu>

rename save_calibration to load_calibration

Signed-off-by: Gergo Koteles <soyer@irl.hu>
---
 include/sound/tas2781.h           |  5 +++++
 sound/pci/hda/tas2781_hda_i2c.c   | 28 ++++++++++++----------------
 sound/soc/codecs/tas2781-comlib.c | 15 +++++++++++++++
 3 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/include/sound/tas2781.h b/include/sound/tas2781.h
index a6c808b22318..1d3c71d7e68d 100644
--- a/include/sound/tas2781.h
+++ b/include/sound/tas2781.h
@@ -131,6 +131,9 @@ struct tasdevice_priv {
 		const struct firmware *fmw, int offset);
 	int (*tasdevice_load_block)(struct tasdevice_priv *tas_priv,
 		struct tasdev_blk *block);
+
+	int (*load_calibration)(struct tasdevice_priv *tas_priv);
+	void (*apply_calibration)(struct tasdevice_priv *tas_priv);
 };
 
 void tas2781_reset(struct tasdevice_priv *tas_dev);
@@ -139,6 +142,8 @@ int tascodec_init(struct tasdevice_priv *tas_priv, void *codec,
 struct tasdevice_priv *tasdevice_kzalloc(struct i2c_client *i2c);
 int tasdevice_init(struct tasdevice_priv *tas_priv);
 void tasdevice_remove(struct tasdevice_priv *tas_priv);
+int tasdevice_load_calibration(struct tasdevice_priv *tas_priv);
+void tasdevice_apply_calibration(struct tasdevice_priv *tas_priv);
 int tasdevice_dev_read(struct tasdevice_priv *tas_priv,
 	unsigned short chn, unsigned int reg, unsigned int *value);
 int tasdevice_dev_write(struct tasdevice_priv *tas_priv,
diff --git a/sound/pci/hda/tas2781_hda_i2c.c b/sound/pci/hda/tas2781_hda_i2c.c
index 70085177230e..2b5031e4dda3 100644
--- a/sound/pci/hda/tas2781_hda_i2c.c
+++ b/sound/pci/hda/tas2781_hda_i2c.c
@@ -395,7 +395,7 @@ static const struct snd_kcontrol_new tas2781_dsp_conf_ctrl = {
 	.put = tasdevice_config_put,
 };
 
-static void tas2781_apply_calib(struct tasdevice_priv *tas_priv)
+static void tas2781_apply_calibration(struct tasdevice_priv *tas_priv)
 {
 	static const unsigned char page_array[CALIB_MAX] = {
 		0x17, 0x18, 0x18, 0x0d, 0x18
@@ -426,7 +426,7 @@ static void tas2781_apply_calib(struct tasdevice_priv *tas_priv)
  * by Algo for calcucating the speaker temperature, speaker membrane excursion
  * and f0 in real time during playback.
  */
-static int tas2781_save_calibration(struct tasdevice_priv *tas_priv)
+static int load_calibration_efi_1(struct tasdevice_priv *tas_priv)
 {
 	efi_guid_t efi_guid = EFI_GUID(0x02f9af02, 0x7734, 0x4233, 0xb4, 0x3d,
 		0x93, 0xfe, 0x5a, 0xa3, 0x5d, 0xb3);
@@ -547,7 +547,7 @@ static void tasdev_fw_ready(const struct firmware *fmw, void *context)
 	/* If calibrated data occurs error, dsp will still works with default
 	 * calibrated data inside algo.
 	 */
-	tas2781_save_calibration(tas_priv);
+	tasdevice_load_calibration(tas_priv);
 
 out:
 	if (tas_priv->fw_state == TASDEVICE_DSP_FW_FAIL) {
@@ -650,15 +650,17 @@ static int tas2781_hda_i2c_probe(struct i2c_client *clt)
 	const char *device_name;
 	int ret;
 
-	if (strstr(dev_name(&clt->dev), "TIAS2781"))
-		device_name = "TIAS2781";
-	else
-		return -ENODEV;
-
 	tas_priv = tasdevice_kzalloc(clt);
 	if (!tas_priv)
 		return -ENOMEM;
 
+	if (strstr(dev_name(&clt->dev), "TIAS2781")) {
+		device_name = "TIAS2781";
+		tas_priv->load_calibration = load_calibration_efi_1;
+		tas_priv->apply_calibration = tas2781_apply_calibration;
+	} else
+		return -ENODEV;
+
 	tas_priv->irq_info.irq = clt->irq;
 	ret = tas2781_read_acpi(tas_priv, device_name);
 	if (ret)
@@ -726,8 +728,6 @@ static int tas2781_runtime_suspend(struct device *dev)
 static int tas2781_runtime_resume(struct device *dev)
 {
 	struct tasdevice_priv *tas_priv = dev_get_drvdata(dev);
-	unsigned long calib_data_sz =
-		tas_priv->ndev * TASDEVICE_SPEAKER_CALIBRATION_SIZE;
 
 	dev_dbg(tas_priv->dev, "Runtime Resume\n");
 
@@ -738,8 +738,7 @@ static int tas2781_runtime_resume(struct device *dev)
 	/* If calibrated data occurs error, dsp will still works with default
 	 * calibrated data inside algo.
 	 */
-	if (tas_priv->cali_data.total_sz > calib_data_sz)
-		tas2781_apply_calib(tas_priv);
+	tasdevice_apply_calibration(tas_priv);
 
 	mutex_unlock(&tas_priv->codec_lock);
 
@@ -770,8 +769,6 @@ static int tas2781_system_suspend(struct device *dev)
 static int tas2781_system_resume(struct device *dev)
 {
 	struct tasdevice_priv *tas_priv = dev_get_drvdata(dev);
-	unsigned long calib_data_sz =
-		tas_priv->ndev * TASDEVICE_SPEAKER_CALIBRATION_SIZE;
 	int i, ret;
 
 	dev_dbg(tas_priv->dev, "System Resume\n");
@@ -793,8 +790,7 @@ static int tas2781_system_resume(struct device *dev)
 	/* If calibrated data occurs error, dsp will still work with default
 	 * calibrated data inside algo.
 	 */
-	if (tas_priv->cali_data.total_sz > calib_data_sz)
-		tas2781_apply_calib(tas_priv);
+	tasdevice_apply_calibration(tas_priv);
 	mutex_unlock(&tas_priv->codec_lock);
 
 	return 0;
diff --git a/sound/soc/codecs/tas2781-comlib.c b/sound/soc/codecs/tas2781-comlib.c
index 933cd008e9f5..f914123c7284 100644
--- a/sound/soc/codecs/tas2781-comlib.c
+++ b/sound/soc/codecs/tas2781-comlib.c
@@ -414,6 +414,21 @@ void tasdevice_remove(struct tasdevice_priv *tas_priv)
 }
 EXPORT_SYMBOL_GPL(tasdevice_remove);
 
+int tasdevice_load_calibration(struct tasdevice_priv *tas_priv)
+{
+	if (tas_priv->load_calibration)
+		return tas_priv->load_calibration(tas_priv);
+	return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(tasdevice_load_calibration);
+
+void tasdevice_apply_calibration(struct tasdevice_priv *tas_priv)
+{
+	if (tas_priv->apply_calibration && tas_priv->cali_data.total_sz)
+		tas_priv->apply_calibration(tas_priv);
+}
+EXPORT_SYMBOL_GPL(tasdevice_apply_calibration);
+
 static int tasdevice_clamp(int val, int max, unsigned int invert)
 {
 	if (val > max)
-- 
2.43.0


  parent reply	other threads:[~2023-12-07  0:00 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07  0:58 [PATCH 00/16] ALSA: hda/tas2781: Add tas2563 support Gergo Koteles
2023-12-06 23:59 ` [PATCH 01/16] ASoC: tas2781: add support for fw version 0x0503 Gergo Koteles
2023-12-06 23:59 ` [PATCH 02/16] ALSA: hda/tas2781: leave hda_component in usable state Gergo Koteles
2023-12-06 23:59 ` [PATCH 03/16] ASoC: tas2781: disable regmap regcache Gergo Koteles
2023-12-07 18:20   ` Mark Brown
2023-12-07 20:19     ` Gergo Koteles
2023-12-07 20:36       ` Mark Brown
2023-12-07 21:12         ` Gergo Koteles
2023-12-07 22:39           ` Mark Brown
2023-12-15  1:17             ` Gergo Koteles
2023-12-15 12:55               ` Mark Brown
2023-12-15 14:42                 ` Gergo Koteles
2023-12-15 15:02                   ` Mark Brown
2023-12-06 23:59 ` [PATCH 04/16] ALSA: hda/tas2781: handle missing calibration data Gergo Koteles
2023-12-06 23:59 ` [PATCH 05/16] ALSA: hda/tas2781: fix typos in comment Gergo Koteles
2023-12-06 23:59 ` Gergo Koteles [this message]
2023-12-07 18:22   ` [PATCH 06/16] ASoC: tas2781: add ptrs to calibration functions Mark Brown
2023-12-06 23:59 ` [PATCH 07/16] ALSA: hda/tas2781: load_calibration just load Gergo Koteles
2023-12-06 23:59 ` [PATCH 08/16] ASoC: tas2781: add configurable global_addr Gergo Koteles
2023-12-06 23:59 ` [PATCH 09/16] ALSA: hda/tas2781: add TAS2563 support for 14ARB7 Gergo Koteles
2023-12-07  0:04 ` [PATCH 10/16] ASoC: tas2781: check negative indexes Gergo Koteles
2023-12-07  0:04 ` [PATCH 11/16] ASoC: tas2781: use 0 as default prog/conf index Gergo Koteles
2023-12-07 18:28   ` Mark Brown
2023-12-09 18:20     ` Gergo Koteles
2023-12-07  0:04 ` [PATCH 12/16] ASoC: tas2781: move set_drv_data outside tasdevice_init Gergo Koteles
2023-12-07  0:04 ` [PATCH 13/16] ALSA: hda/tas2781: remove sound controls in unbind Gergo Koteles
2023-12-07 12:21   ` kernel test robot
2023-12-07 16:00   ` kernel test robot
2023-12-07  0:04 ` [PATCH 14/16] ALSA: hda/tas2781: call cleaner functions only once Gergo Koteles
2023-12-07  0:04 ` [PATCH 15/16] ALSA: hda/tas2781: reset the amp before component_add Gergo Koteles
2023-12-07  0:04 ` [PATCH 16/16] ALSA: hda/tas2781: configure the amp after firmware load Gergo Koteles
2023-12-07 13:55 ` [PATCH 00/16] ALSA: hda/tas2781: Add tas2563 support Mark Brown
2023-12-07 14:38   ` Takashi Iwai
2023-12-30  0:09 ` [PATCH v2 0/4] " Gergo Koteles
2023-12-30  0:09   ` [PATCH v2 1/4] ALSA: hda/tas2781: add ptrs to calibration functions Gergo Koteles
2023-12-30  0:09   ` [PATCH v2 2/4] ALSA: hda/tas2781: add configurable global i2c address Gergo Koteles
2023-12-30  0:09   ` [PATCH v2 3/4] ALSA: hda/tas2781: add TAS2563 support for 14ARB7 Gergo Koteles
2023-12-30  0:09   ` [PATCH v2 4/4] ALSA: hda/tas2781: add fixup for Lenovo 14ARB7 Gergo Koteles
2023-12-30 16:59   ` [PATCH v2 0/4] ALSA: hda/tas2781: Add tas2563 support Takashi Iwai
2023-12-30 20:18     ` Gergo Koteles
2023-12-31  8:33       ` Takashi Iwai
2024-01-02 15:37   ` 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=e069d578aebb8d5aa1c09abae2a0f240b3dedec2.1701906455.git.soyer@irl.hu \
    --to=soyer@irl.hu \
    --cc=alsa-devel@alsa-project.org \
    --cc=baojun.xu@ti.com \
    --cc=broonie@kernel.org \
    --cc=kevin-lu@ti.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=shenghao-ding@ti.com \
    --cc=tiwai@suse.com \
    /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®