From nobody Tue Sep 9 16:20:05 2025 Received: from lelvem-ot01.ext.ti.com (lelvem-ot01.ext.ti.com [198.47.23.234]) (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 601EE20F08E for ; Sun, 7 Sep 2025 22:28:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.234 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757284123; cv=none; b=avFfI1U6XcysUXvlc3PwunCC3VTn2ZXDUeoBwkvLGrfcH2CgSCpzC+VZnIEKTmzI+xuXVJtH92Rko0Tr8tzkQOymTafrH/8DZDetjHg6++AcZxeFw9XDxd4jKWX1zIw7ousDPD/ZZ3AbdT5Gh2/yavXVPzQlxucflN+dqz4skGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757284123; c=relaxed/simple; bh=4MPBud9tVUqifZN583Fp4NLbvT6urspuOu1Pb90NyIQ=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=e0t/SQviXjB4zU4ZL/ONw9DgTZxbFZSQspCUVjIwpsKnrREQ9F5VVG3nj57RZdND1TNXxNVY/Xv9l7PioiwCctZe7LJYXQB1xb41dIL+vBVCBuUFw5yEPxOnNO/OQ+OsWBRuW+60jtV1QejuYAAZ1yNNiYwAPVEeepggGyiPQ9Y= ARC-Authentication-Results: i=1; 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=jV5cJsy1; arc=none smtp.client-ip=198.47.23.234 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="jV5cJsy1" Received: from fllvem-sh03.itg.ti.com ([10.64.41.86]) by lelvem-ot01.ext.ti.com (8.15.2/8.15.2) with ESMTP id 587MRaoJ3729158; Sun, 7 Sep 2025 17:27:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1757284056; bh=gypNAM4Hpg7PEPlRPUtvsQ+DMkDWUbUx77nQpfzw5a0=; h=From:To:CC:Subject:Date; b=jV5cJsy1HYuzPZBs7cHFC2O06MHZydDrJ2CLbkPJC8Y7qYS48FNXxbKxcEHsiwFu2 qnmvVzmekOkJwpb5ZwW/MSWNbNxtqzFh37hRHimmftXo+CjWOTKMugQh8oKRvVa4/1 YK8iproN7SkxmU5Uyl12r1y9CdnYjM5AhYElhRRQ= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by fllvem-sh03.itg.ti.com (8.18.1/8.18.1) with ESMTPS id 587MRZ5H2543997 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA256 bits=128 verify=FAIL); Sun, 7 Sep 2025 17:27:35 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.55; Sun, 7 Sep 2025 17:27:34 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.55 via Frontend Transport; Sun, 7 Sep 2025 17:27:35 -0500 Received: from LT5CG31242FY.dhcp.ti.com ([10.250.161.79]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 587MRVGH4072722; Sun, 7 Sep 2025 17:27:32 -0500 From: Shenghao Ding To: CC: , , <13564923607@139.com>, <13916275206@139.com>, , , , , Shenghao Ding Subject: [PATCH v4] ALSA: hda/tas2781: Fix the order of TAS2781 calibrated-data Date: Mon, 8 Sep 2025 06:27:27 +0800 Message-ID: <20250907222728.988-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 Content-Type: text/plain; charset="utf-8" A bug reported by one of my customers that the order of TAS2781 calibrated-data is incorrect, the correct way is to move R0_Low and insert it between R0 and InvR0. Fixes: 4fe238513407 ("ALSA: hda/tas2781: Move and unified the calibrated-da= ta getting function for SPI and I2C into the tas2781_hda lib") Signed-off-by: Shenghao Ding --- v4: - Add missing base into cali_cnv(). v3: - Take Tiwai's advice on cali_cnv() to make it more simpler. v2: - Submit to the sound branch maintained by Tiwai instead of linux-next branch - Drop other fix --- sound/hda/codecs/side-codecs/tas2781_hda.c | 25 +++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/sound/hda/codecs/side-codecs/tas2781_hda.c b/sound/hda/codecs/= side-codecs/tas2781_hda.c index f46d2e06c64f..536940c78f00 100644 --- a/sound/hda/codecs/side-codecs/tas2781_hda.c +++ b/sound/hda/codecs/side-codecs/tas2781_hda.c @@ -33,6 +33,23 @@ const efi_guid_t tasdev_fct_efi_guid[] =3D { }; EXPORT_SYMBOL_NS_GPL(tasdev_fct_efi_guid, "SND_HDA_SCODEC_TAS2781"); =20 +/* + * The order of calibrated-data writing function is a bit different from t= he + * order in UEFI. Here is the conversion to match the order of calibrated-= data + * writing function. + */ +static void cali_cnv(unsigned char *data, unsigned int base, int offset) +{ + struct cali_reg reg_data; + + memcpy(®_data, &data[base], sizeof(reg_data)); + /* the data order has to be swapped between r0_low_reg and inv0_reg */ + swap(reg_data.r0_low_reg, reg_data.invr0_reg); + + cpu_to_be32_array((__force __be32 *)(data + offset + 1), + (u32 *)®_data, TASDEV_CALIB_N); +} + static void tas2781_apply_calib(struct tasdevice_priv *p) { struct calidata *cali_data =3D &p->cali_data; @@ -103,8 +120,7 @@ static void tas2781_apply_calib(struct tasdevice_priv *= p) =20 data[l] =3D k; oft++; - for (i =3D 0; i < TASDEV_CALIB_N * 4; i++) - data[l + i + 1] =3D data[4 * oft + i]; + cali_cnv(data, 4 * oft, l); k++; } } @@ -130,9 +146,8 @@ static void tas2781_apply_calib(struct tasdevice_priv *= p) =20 for (j =3D p->ndev - 1; j >=3D 0; j--) { l =3D j * (cali_data->cali_dat_sz_per_dev + 1); - for (i =3D TASDEV_CALIB_N * 4; i > 0 ; i--) - data[l + i] =3D data[p->index * 5 + i]; - data[l+i] =3D j; + cali_cnv(data, cali_data->cali_dat_sz_per_dev * j, l); + data[l] =3D j; } } =20 --=20 2.43.0