From nobody Sun Feb 8 13:10:59 2026 Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012070.outbound.protection.outlook.com [52.101.48.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87E1C21FF48 for ; Mon, 2 Feb 2026 10:28:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.48.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770028091; cv=fail; b=XPm6y09Ihry8W1oY3B+ALe0F+mvMi7zSMAJ4kc+/WvjZzLwG28hRCbar5GGhHBfPSObKQCwj8+zMFGs2v/RzDFzgWrm2vdNcAdcKaGgo1tS0QoDxmvxCdhHbV2qvuFoWcCoXvFIuc22fz7dNU8O0ABW0K4kkQju4haSbEd2EcLM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770028091; c=relaxed/simple; bh=hdCVmbuB4hP0qlt8j2ZXVJL3lFncLhgBU1xRJh2HukI=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=mvu9U7KkGjWJUUMlG5HhCPkYR1ZBCXXQ+db8OlJ/muubSW5gVyEP4XzKuZ28hCYcs+a4h3ndVHYpkyRGlApissv7Btos+UT5AheyBSNVCdwzKT3R7joFUjY+5C0oZUxgKv6OnoJCkuIKuLW3dSdbbMCAo44M/LZkcTO2vt2YZ0U= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=YGwW03rb; arc=fail smtp.client-ip=52.101.48.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="YGwW03rb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L6syleWqdVlKSclBqwMjAk3GZZE7ONT4qMaFU8gYymyWVYW7qX2EwN8uCOmx4Zrf6n17qKdj6OtXdT7R1NF93uCHKxl637lqV3BgQdkKFHBIXHqbdNZPXfdW1OR/3BVnrn9Mh2q4xtT9Q3alFWL/OfxBlgZN9RFL/RjMqi1iPqpotBcZ7IrFPcpbs4rmNOpywUur39oIyLrYtfyVLXAjh5yMkPsf1JM11ReX9foKEVVa22iQe7DOySfKorHV+UYjmGyF1QSJ9lXYd8HAhhIXTKjU1NquCuw8n776XO5Dkkq0XqyzTbyqhMX54Ln4Nat8Bqn7Ml3mwIhKEU3cgnJAYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VqsTeoxfQmyjJMcdwlS2ASf1cwPO/Ea2m1VD1Lu6JEo=; b=lHxLnwKEyH6FJOFC8SU4Tfr4aIoYHwwugshinNBuPayoXG5bTsW3R330j31BHH2CsqERDK2RX+qSS9WiPdVT3i84VxLVfsBaCwoXzRyP143okjjVJpj9lZlIZslloEFg9UztRaN0epMa/WIQZBWhGYZmem8COLd1UvS9nHL7ilx6DATNcUaOrj167z/PIXDXGB1KbxtFxPeVvKi/vLSg86d2RGeokpbLSMyUuoMjMlH42Qx1ZaoKIDJP7Rd8W6WN+cd3LTh6cd5CUnyf3nqO79ZG793C/0an9d5YX0PS2zfWFAgS+L/eByu1bqrIBU3q9EZirNoQs0yONanHZW4cHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=antheas.dev smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VqsTeoxfQmyjJMcdwlS2ASf1cwPO/Ea2m1VD1Lu6JEo=; b=YGwW03rbHM7+QB91xosf3qvIMcocxrJ1JNaMyL1WTXm38XITO0zwGiBsf50uwtJva69uE8GvWSMjb7bWH1qtt7pEbqafR82STpfOB/c0XGuTtNtjkxSSYym2wU4pnONvuU/dvtu323hSfPaWVUrljwPBSPX2lPezMwts7sk6HkI= Received: from BYAPR05CA0034.namprd05.prod.outlook.com (2603:10b6:a03:c0::47) by SJ2PR10MB7112.namprd10.prod.outlook.com (2603:10b6:a03:4c6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9564.16; Mon, 2 Feb 2026 10:28:07 +0000 Received: from SJ5PEPF000001F4.namprd05.prod.outlook.com (2603:10b6:a03:c0:cafe::b7) by BYAPR05CA0034.outlook.office365.com (2603:10b6:a03:c0::47) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9587.10 via Frontend Transport; Mon, 2 Feb 2026 10:28:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by SJ5PEPF000001F4.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9587.10 via Frontend Transport; Mon, 2 Feb 2026 10:28:07 +0000 Received: from DLEE214.ent.ti.com (157.170.170.117) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Mon, 2 Feb 2026 04:28:05 -0600 Received: from DLEE203.ent.ti.com (157.170.170.78) by DLEE214.ent.ti.com (157.170.170.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Mon, 2 Feb 2026 04:28:05 -0600 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE203.ent.ti.com (157.170.170.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Mon, 2 Feb 2026 04:28:05 -0600 Received: from LT5CG31242FY.dhcp.ti.com ([10.250.162.202]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 612AS1ak1560003; Mon, 2 Feb 2026 04:28:02 -0600 From: Shenghao Ding To: CC: , , , , , <13564923607@139.com>, <13916275206@139.com>, , , Shenghao Ding Subject: [PATCH v1] ASoC: tas2781: Put three different calibrated data solution into the same data structure Date: Mon, 2 Feb 2026 18:27:56 +0800 Message-ID: <20260202102757.532-1-shenghao-ding@ti.com> X-Mailer: git-send-email 2.33.0.windows.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001F4:EE_|SJ2PR10MB7112:EE_ X-MS-Office365-Filtering-Correlation-Id: d5ddd87c-7bbc-4666-6628-08de6245c1af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?jFTe8+YWG6pZhr9uYn9XvxKxdf/P8eIwnwp7LkuWqmGBQA96TL3YMPbJzHlk?= =?us-ascii?Q?lYMaDRykGKt1ko9tlQ7m791HEwBJd8eWLjBiL9tDG3XmfiaDzFPkbQDKgIcm?= =?us-ascii?Q?bsfzJmJwp/oTAU7AetTB1L9a7PNpwap1Nkcs6xQQmSxVb7xLxnoux/N+4XPA?= =?us-ascii?Q?tbWnNZK8f4FtnxFJaQAINKfpkWloA4htHlJ/r539svypG9WkjC+/oJLyzSJD?= =?us-ascii?Q?Ps8GupOeLDWp9ZnbkvIHSISIJz9j0SyZ9XRshMb5YeyoxXzERAJD7kraZ4wu?= =?us-ascii?Q?gXnc/mRLCZ55ILEU2I3ANa6R3JHwqKntNWixQ+Ti9kvQlR/Hmqhvqca3hBVq?= =?us-ascii?Q?7jnKlt+z2fGAEwzLynGXyKHcr/zue3D+qhMlHd19yC8+3kSFrGZWPKsEpyPx?= =?us-ascii?Q?K8afmk3KGsOeyj0YCxdG4ijDPL4L7eAYCIfT4gpZUMgnZRCt5TgwL5DMUbc3?= =?us-ascii?Q?/9FPutIPStvKyAjUwVn8wqXbafHCeihmnTtJrYcT74E30lNwhhaHmQRJ4efO?= =?us-ascii?Q?5IjT+x/hmpIX6xljXd/Ll8zBbe7t4N5HqpB6iPEtc3wn/48sGd6291KUH3sX?= =?us-ascii?Q?3aeJiyL07nscMm2NjJVkPv07CqqvvJ9/oUkgX59i3lB1b1EMRi9eBSTtSBoc?= =?us-ascii?Q?69kzgDY7KuQD4BUWNSixQt3XVOeUzwwj7RmTAWBwhUsUb7oxT4vUXYzCMTrr?= =?us-ascii?Q?3z1BwWt1afrOHtKxTzU5aUjUWeAJzCZfEHnAMqnrdQNCP3G566VTIXp1f874?= =?us-ascii?Q?AHqCoEQ/K1zpv72NNgWAkwpvdMir2co1qMW5JNxoffMnAqJgAX+rJoaObwYO?= =?us-ascii?Q?rRFNltC7nmd/nYFnjsvQq42fD7tumt8dltrPOV3EW3kwrK4uf3ZUV9HjmhOO?= =?us-ascii?Q?/XFKNOTwr/W8bESgiPYmVZSzgJiBcj/LtLiLJM5DgI1uOKcGORGN+YCza328?= =?us-ascii?Q?KR0XdAu+rYAkUzEUPN8Zyp4QqzST3Srvz1aHAjGia5d61rZdEtDejLTcML8C?= =?us-ascii?Q?FqsVq+nBUzwOwhWsz3ItH4t3WnCOxYHeoSWCvt8gJEoLonHH+Bl5hrzjx0lY?= =?us-ascii?Q?3+WbPCKNKGBV62qJXnacQl2Bh3aA2+LaFcGYi1crKAKof5yHvi+Qt1fGDUFl?= =?us-ascii?Q?X+nQ0am4ZyhA1xovTp6mDa6tszY0Vy9D/UR7/9iL/Sj+gaAX2F3uc6tI2Mpv?= =?us-ascii?Q?aIQAjwa1kBe25e9o3423i4U0HmugUX/FLlSIRREFX8VD8rBXp4Mh9ytuDfOO?= =?us-ascii?Q?JRT0ua6kr4XNrkGCfNKAqkX8ns1h0LINWEgYHtcUzhBz5Mik/fHhj6kqkaTV?= =?us-ascii?Q?oQcBTNAwWD/Uk3eZOBwT409YYoFme4FFuY0OmkWulihvitR56HT0IgUYE2DG?= =?us-ascii?Q?aUy69SaL2oRmz59ydYmP/hw/wjTh7bCTiY7EGk0oEocBtyVnyd7BKfmG+3C0?= =?us-ascii?Q?XN0w2dnZUbL5fTsttl2wrKrz6SU+siEYTU5EUo1zPqZig3m4IoDG3AcBOF4x?= =?us-ascii?Q?DskjRDPyYXHjJY8gEO556faXFEtz9n4GbMUTr/HYLnXRzakS6JGgfvTcSdL3?= =?us-ascii?Q?9axZZAoZvy0rWhfD78V+M2aClnKqxmAeB8uowdYntZpZkWtDMVqcIZQVECP2?= =?us-ascii?Q?Wg=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013)(13003099007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uDtUCxqCdFNnm8YdkGqyFGz+sTMTOYbO/+rvBvZXqq86/EN1VB40QECr6Ejx0/0HvouRAPP8YfFpdF17n0CMqI7NRKZYEj+pjr9TW//Rs7e7ayTOPxGFTQaFJuf9xZGxDwMeH/56bi2wp3BzNbD/62aLdGvwjvShTmKHr01K4muRkiAwd7k4nBnAPk4AH0x5oe28wQBe4/z5vOGYhvQO+mcmZuJH9a3qlOxAvFNXvbbVRhol+Q+s4aduyU2kXgUe7WVDqkFaxlfwTytWIMxGBkyMnj8/EIk4SrLFI+yWijrSuXSv5Dtj0rlPLaUzELkCQnHNi9IIoLbJPGgnFtr9HF2c3Mhzw9sq0Rljx0kFMOsinBl6sX7BLxWsPF25HVVOFLB7wzZ1TarfM+9aPuxVzk4Hsu0TCbh+36tuGf0kf/suKgF29TunCgVCFu24nVHf X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2026 10:28:07.3653 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d5ddd87c-7bbc-4666-6628-08de6245c1af X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001F4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR10MB7112 Content-Type: text/plain; charset="utf-8" TAS2781 driver supports three solutions of calibrated data. The first is from the driver itself: driver reads the calibrated files directly during probe; The second is from user space: during init of audio hal, the audio hal will pass the calibrated data via kcontrol interface. Driver will store this data in "struct calidata" for use. The third is from UEFI, mainly used in hda device. These three solutions save the calibrated data into different data structures. It is time to put them together into "struct calidata" for use. Signed-off-by: Shenghao Ding --- v1: - Drop is_user_space_calidata - Update the year of tas2781_hda.c, tas2781.h, tas2781-fmwlib.c, tas2781-i2c.c and tas2781_hda_i2c.c - Set to an invalid value before the calibrated data loading - Drop load_calib_data() - Add calbin_conversion() and call it after loading calibin file --- include/sound/tas2781.h | 3 +- sound/hda/codecs/side-codecs/tas2781_hda.c | 9 +- .../hda/codecs/side-codecs/tas2781_hda_i2c.c | 13 -- sound/soc/codecs/tas2781-fmwlib.c | 138 ++++++++++++++---- sound/soc/codecs/tas2781-i2c.c | 11 +- 5 files changed, 121 insertions(+), 53 deletions(-) diff --git a/include/sound/tas2781.h b/include/sound/tas2781.h index 9d3c54cb8223..7c03bdc951bb 100644 --- a/include/sound/tas2781.h +++ b/include/sound/tas2781.h @@ -2,7 +2,7 @@ // // ALSA SoC Texas Instruments TAS2563/TAS2781 Audio Smart Amplifier // -// Copyright (C) 2022 - 2025 Texas Instruments Incorporated +// Copyright (C) 2022 - 2026 Texas Instruments Incorporated // https://www.ti.com // // The TAS2563/TAS2781 driver implements a flexible and configurable @@ -233,7 +233,6 @@ struct tasdevice_priv { bool playback_started; bool isacpi; bool isspi; - bool is_user_space_calidata; unsigned int global_addr; =20 int (*fw_parse_variable_header)(struct tasdevice_priv *tas_priv, diff --git a/sound/hda/codecs/side-codecs/tas2781_hda.c b/sound/hda/codecs/= side-codecs/tas2781_hda.c index 96e6d82dc69e..30a1bae51663 100644 --- a/sound/hda/codecs/side-codecs/tas2781_hda.c +++ b/sound/hda/codecs/side-codecs/tas2781_hda.c @@ -2,7 +2,7 @@ // // TAS2781 HDA Shared Lib for I2C&SPI driver // -// Copyright 2025 Texas Instruments, Inc. +// Copyright 2025 - 2026 Texas Instruments, Inc. // // Author: Shenghao Ding =20 @@ -159,7 +159,6 @@ static void tas2781_apply_calib(struct tasdevice_priv *= p) r->tlimit_reg =3D cali_reg[4]; } =20 - p->is_user_space_calidata =3D true; cali_data->total_sz =3D p->ndev * (cali_data->cali_dat_sz_per_dev + 1); } =20 @@ -216,6 +215,12 @@ int tas2781_save_calibration(struct tas2781_hda *hda) status =3D -ENOMEM; continue; } + /* + * Set to an invalid value before the calibrated data + * is stored into it, for the default value is 0, which + * means the first device. + */ + data[0] =3D 0xff; /* Get variable contents into buffer */ status =3D efi.get_variable(efi_name[i], &efi_guid, &attr, &cali_data->total_sz, data); diff --git a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c b/sound/hda/cod= ecs/side-codecs/tas2781_hda_i2c.c index 49c80babb500..74c3cf1e45e1 100644 --- a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c +++ b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c @@ -393,19 +393,6 @@ static int tas2563_save_calibration(struct tas2781_hda= *h) r->pow_reg =3D TAS2563_CAL_POWER; r->tlimit_reg =3D TAS2563_CAL_TLIM; =20 - /* - * TAS2781_FMWLIB supports two solutions of calibrated data. One is - * from the driver itself: driver reads the calibrated files directly - * during probe; The other from user space: during init of audio hal, - * the audio hal will pass the calibrated data via kcontrol interface. - * Driver will store this data in "struct calidata" for use. For hda - * device, calibrated data are usunally saved into UEFI. So Hda side - * codec driver use the mixture of these two solutions, driver reads - * the data from UEFI, then store this data in "struct calidata" for - * use. - */ - p->is_user_space_calidata =3D true; - return 0; } =20 diff --git a/sound/soc/codecs/tas2781-fmwlib.c b/sound/soc/codecs/tas2781-f= mwlib.c index 78fd0a5dc6f2..0e084c3a162d 100644 --- a/sound/soc/codecs/tas2781-fmwlib.c +++ b/sound/soc/codecs/tas2781-fmwlib.c @@ -2,7 +2,7 @@ // // tas2781-fmwlib.c -- TASDEVICE firmware support // -// Copyright 2023 - 2025 Texas Instruments, Inc. +// Copyright 2023 - 2026 Texas Instruments, Inc. // // Author: Shenghao Ding // Author: Baojun Xu @@ -80,6 +80,14 @@ #define POST_SOFTWARE_RESET_DEVICE_C 0x47 #define POST_SOFTWARE_RESET_DEVICE_D 0x48 =20 +#define COPY_CAL_DATA(i) \ + do { \ + calbin_data[i + 1] =3D data[7]; \ + calbin_data[i + 2] =3D data[8]; \ + calbin_data[i + 3] =3D data[9]; \ + calbin_data[i + 4] =3D data[10]; \ + } while (0) + struct tas_crc { unsigned char offset; unsigned char len; @@ -1952,23 +1960,6 @@ static int dspfw_default_callback(struct tasdevice_p= riv *tas_priv, return rc; } =20 -static int load_calib_data(struct tasdevice_priv *tas_priv, - struct tasdevice_data *dev_data) -{ - struct tasdev_blk *block; - unsigned int i; - int ret =3D 0; - - for (i =3D 0; i < dev_data->nr_blk; i++) { - block =3D &(dev_data->dev_blks[i]); - ret =3D tasdevice_load_block(tas_priv, block); - if (ret < 0) - break; - } - - return ret; -} - static int fw_parse_header(struct tasdevice_priv *tas_priv, struct tasdevice_fw *tas_fmw, const struct firmware *fmw, int offset) { @@ -2029,6 +2020,103 @@ static int fw_parse_variable_hdr_cal(struct tasdevi= ce_priv *tas_priv, return offset; } =20 +static inline int check_cal_bin_data(struct device *dev, + const unsigned char *data, const char *name) +{ + if (data[2] !=3D 0x85 || data[1] !=3D 4) { + dev_err(dev, "Invalid cal bin file in %s\n", name); + return -1; + } + return 0; +} + +static void calbin_conversion(struct tasdevice_priv *priv, + struct tasdevice_fw *tas_fmw) +{ + struct calidata *cali_data =3D &priv->cali_data; + unsigned char *calbin_data =3D cali_data->data; + struct cali_reg *p =3D &cali_data->cali_reg_array; + struct tasdevice_calibration *calibration; + struct tasdevice_data *img_data; + struct tasdev_blk *blk; + unsigned char *data; + int chn, k; + + if (cali_data->total_sz !=3D priv->ndev * + (cali_data->cali_dat_sz_per_dev + 1)) { + dev_err(priv->dev, "%s: cali_data size err\n", + __func__); + return; + } + calibration =3D &(tas_fmw->calibrations[0]); + img_data =3D &(calibration->dev_data); + + if (img_data->nr_blk !=3D 1) { + dev_err(priv->dev, "%s: Invalid nr_blk, wrong cal bin\n", + __func__); + return; + } + + blk =3D &(img_data->dev_blks[0]); + if (blk->nr_cmds !=3D 15) { + dev_err(priv->dev, "%s: Invalid nr_cmds, wrong cal bin\n", + __func__); + return; + } + + switch (blk->type) { + case COEFF_DEVICE_A: + chn =3D 0; + break; + case COEFF_DEVICE_B: + chn =3D 1; + break; + case COEFF_DEVICE_C: + chn =3D 2; + break; + case COEFF_DEVICE_D: + chn =3D 3; + break; + default: + dev_err(priv->dev, "%s: Other Type =3D 0x%02x\n", + __func__, blk->type); + return; + } + k =3D chn * (cali_data->cali_dat_sz_per_dev + 1); + + data =3D blk->data; + if (check_cal_bin_data(priv->dev, data, "r0_reg") < 0) + return; + p->r0_reg =3D TASDEVICE_REG(data[4], data[5], data[6]); + COPY_CAL_DATA(k); + + data =3D blk->data + 12; + if (check_cal_bin_data(priv->dev, data, "r0_low_reg") < 0) + return; + p->r0_low_reg =3D TASDEVICE_REG(data[4], data[5], data[6]); + COPY_CAL_DATA(k + 4); + + data =3D blk->data + 24; + if (check_cal_bin_data(priv->dev, data, "invr0_reg") < 0) + return; + p->invr0_reg =3D TASDEVICE_REG(data[4], data[5], data[6]); + COPY_CAL_DATA(k + 8); + + data =3D blk->data + 36; + if (check_cal_bin_data(priv->dev, data, "pow_reg") < 0) + return; + p->pow_reg =3D TASDEVICE_REG(data[4], data[5], data[6]); + COPY_CAL_DATA(k + 12); + + data =3D blk->data + 48; + if (check_cal_bin_data(priv->dev, data, "tlimit_reg") < 0) + return; + p->tlimit_reg =3D TASDEVICE_REG(data[4], data[5], data[6]); + COPY_CAL_DATA(k + 16); + + calbin_data[k] =3D chn; +} + /* When calibrated data parsing error occurs, DSP can still work with defa= ult * calibrated data, memory resource related to calibrated data will be * released in the tasdevice_codec_remove. @@ -2086,6 +2174,7 @@ static int fw_parse_calibration_data(struct tasdevice= _priv *tas_priv, goto out; } =20 + calbin_conversion(tas_priv, tas_fmw); out: return offset; } @@ -2371,25 +2460,12 @@ static int tasdevice_load_data(struct tasdevice_pri= v *tas_priv, =20 static void tasdev_load_calibrated_data(struct tasdevice_priv *priv, int i) { - struct tasdevice_fw *cal_fmw =3D priv->tasdevice[i].cali_data_fmw; struct calidata *cali_data =3D &priv->cali_data; struct cali_reg *p =3D &cali_data->cali_reg_array; unsigned char *data =3D cali_data->data; - struct tasdevice_calibration *cal; int k =3D i * (cali_data->cali_dat_sz_per_dev + 1); int rc; =20 - /* Load the calibrated data from cal bin file */ - if (!priv->is_user_space_calidata && cal_fmw) { - cal =3D cal_fmw->calibrations; - - if (cal) - load_calib_data(priv, &cal->dev_data); - return; - } - if (!priv->is_user_space_calidata) - return; - /* load calibrated data from user space */ if (data[k] !=3D i) { dev_err(priv->dev, "%s: no cal-data for dev %d from usr-spc\n", __func__, i); diff --git a/sound/soc/codecs/tas2781-i2c.c b/sound/soc/codecs/tas2781-i2c.c index d1c76ab0144d..41b89fcc69c3 100644 --- a/sound/soc/codecs/tas2781-i2c.c +++ b/sound/soc/codecs/tas2781-i2c.c @@ -2,7 +2,7 @@ // // ALSA SoC Texas Instruments TAS2563/TAS2781 Audio Smart Amplifier // -// Copyright (C) 2022 - 2025 Texas Instruments Incorporated +// Copyright (C) 2022 - 2026 Texas Instruments Incorporated // https://www.ti.com // // The TAS2563/TAS2781 driver implements a flexible and configurable @@ -255,8 +255,6 @@ static int tasdev_cali_data_get(struct snd_kcontrol *kc= ontrol, int rc; =20 guard(mutex)(&priv->codec_lock); - if (!priv->is_user_space_calidata) - return -1; =20 if (!p->r0_reg) return -1; @@ -654,7 +652,6 @@ static int tasdev_cali_data_put(struct snd_kcontrol *kc= ontrol, } } i +=3D 2; - priv->is_user_space_calidata =3D true; =20 if (priv->dspbin_typ =3D=3D TASDEV_BASIC) { p->r0_reg =3D TASDEVICE_REG(src[i], src[i + 1], src[i + 2]); @@ -1444,7 +1441,11 @@ static int tasdevice_create_cali_ctrls(struct tasdev= ice_priv *priv) GFP_KERNEL); if (!cali_data->data) return -ENOMEM; - + /* + * Set to an invalid value before the calibrated data is stored into + * it, for the default value is 0, which means the first device. + */ + cali_data->data[0] =3D 0xff; if (priv->chip_id =3D=3D TAS2781) { struct soc_bytes_ext *ext_cali_start; char *cali_start_name; --=20 2.43.0