Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1329317rdb; Wed, 6 Dec 2023 16:01:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyQvxGSOFJOEc33VQzbEZqEBIyEvXt4D826hOOBWU+Tgx6PFdcBdJVtH7cIDY5sxjnQ4ag X-Received: by 2002:a17:90a:d984:b0:286:6cc0:cad1 with SMTP id d4-20020a17090ad98400b002866cc0cad1mr1904540pjv.72.1701907270304; Wed, 06 Dec 2023 16:01:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701907270; cv=none; d=google.com; s=arc-20160816; b=Ks65nCDytewjJ+EmIi7ZQ8TCcuw9i5Q0oWC57a5c7bz3LvRuLEct9qq714ltbfF0RO qZmH66UHT55CZgTDU65Z7fX5AWK29MyP9HcjEEdw246cmrOeKaJC3jkLFj1ahS3v/mqr 4rcSTUoFGyrTBUskswMROkgNN2fqpyuyxYS3nzzsXJnGREEL5LMl8yvPFrgc6trQybCR yQrRceayQ6pNQltHRQvS2+5ZW3/2lNQjPkrbVjxzZdEmFtJIXhAW3ufzZ/kABNxK+phV lj/BIRew0qzjRfjzkVYiAL9TIjBI8c37xtxEWdVWbN6XHszFBL81YJtyfpm0y50boa48 6n2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=VVCKf57gXSVwSozDH4b7husebZfHwrzsmB69E4XfD4E=; fh=zySoyVfK/7ExaDz2MWyww8poQ40q3tZak5TTvfb/Ovc=; b=XyHcY2iwvjJ+olg57p4f0kTexUTi6VSud8l7RoXITJ5up5NZKlQ5EWu++wTprgMFnv 4ax2t48WQHEGA7shK1Ck/JS7LQj8TlGRMiIQ83WauhVE8WUKE35cLpdSZULd0FlQ90aH pXTIuIdtMbCC7HOkmxqgY7gvJbf+u3f88tJXq4KS6aZbVe1p7AD5TDKUB7O2QUGtdxVn cDGjLQeit/hl1UOddiHtr4MR4EwoINz8uGOTpBx43fnDUnufWGoYdZNmeJCaWn6EytAx bZwoPc8onwwH+EH0XmZNNOE04kdRe4pDC10Hc1iGimE8fLaGv3APMnxwSRuyLWauBR4d XDdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=irl.hu Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id x9-20020a17090a970900b0028865463406si42041pjo.51.2023.12.06.16.01.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 16:01:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=irl.hu Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 695D58083E69; Wed, 6 Dec 2023 16:00:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441877AbjLGAAR (ORCPT + 99 others); Wed, 6 Dec 2023 19:00:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1441822AbjLGAAB (ORCPT ); Wed, 6 Dec 2023 19:00:01 -0500 Received: from irl.hu (irl.hu [95.85.9.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D9D21A5 for ; Wed, 6 Dec 2023 16:00:07 -0800 (PST) Received: from fedori.lan (51b690cd.dsl.pool.telekom.hu [::ffff:81.182.144.205]) (AUTH: CRAM-MD5 soyer@irl.hu, ) by irl.hu with ESMTPSA id 00000000000716F0.0000000065710B04.00119059; Thu, 07 Dec 2023 01:00:04 +0100 From: Gergo Koteles To: Shenghao Ding , Kevin Lu , Baojun Xu , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Gergo Koteles Subject: [PATCH 06/16] ASoC: tas2781: add ptrs to calibration functions Date: Thu, 7 Dec 2023 00:59:47 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Mime-Autoconverted: from 8bit to 7bit by courier 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 06 Dec 2023 16:00:35 -0800 (PST) rename save_calibration to load_calibration Signed-off-by: Gergo Koteles --- 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