Skip to content

Commit 71d2893

Browse files
Shenghao-Dingtiwai
authored andcommitted
ALSA: hda/tas2781: Fix the order of TAS2781 calibrated-data
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: 4fe2385 ("ALSA: hda/tas2781: Move and unified the calibrated-data getting function for SPI and I2C into the tas2781_hda lib") Signed-off-by: Shenghao Ding <shenghao-ding@ti.com> Link: https://patch.msgid.link/20250907222728.988-1-shenghao-ding@ti.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent ad64c07 commit 71d2893

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

sound/hda/codecs/side-codecs/tas2781_hda.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,23 @@ const efi_guid_t tasdev_fct_efi_guid[] = {
3333
};
3434
EXPORT_SYMBOL_NS_GPL(tasdev_fct_efi_guid, "SND_HDA_SCODEC_TAS2781");
3535

36+
/*
37+
* The order of calibrated-data writing function is a bit different from the
38+
* order in UEFI. Here is the conversion to match the order of calibrated-data
39+
* writing function.
40+
*/
41+
static void cali_cnv(unsigned char *data, unsigned int base, int offset)
42+
{
43+
struct cali_reg reg_data;
44+
45+
memcpy(&reg_data, &data[base], sizeof(reg_data));
46+
/* the data order has to be swapped between r0_low_reg and inv0_reg */
47+
swap(reg_data.r0_low_reg, reg_data.invr0_reg);
48+
49+
cpu_to_be32_array((__force __be32 *)(data + offset + 1),
50+
(u32 *)&reg_data, TASDEV_CALIB_N);
51+
}
52+
3653
static void tas2781_apply_calib(struct tasdevice_priv *p)
3754
{
3855
struct calidata *cali_data = &p->cali_data;
@@ -103,8 +120,7 @@ static void tas2781_apply_calib(struct tasdevice_priv *p)
103120

104121
data[l] = k;
105122
oft++;
106-
for (i = 0; i < TASDEV_CALIB_N * 4; i++)
107-
data[l + i + 1] = data[4 * oft + i];
123+
cali_cnv(data, 4 * oft, l);
108124
k++;
109125
}
110126
}
@@ -130,9 +146,8 @@ static void tas2781_apply_calib(struct tasdevice_priv *p)
130146

131147
for (j = p->ndev - 1; j >= 0; j--) {
132148
l = j * (cali_data->cali_dat_sz_per_dev + 1);
133-
for (i = TASDEV_CALIB_N * 4; i > 0 ; i--)
134-
data[l + i] = data[p->index * 5 + i];
135-
data[l+i] = j;
149+
cali_cnv(data, cali_data->cali_dat_sz_per_dev * j, l);
150+
data[l] = j;
136151
}
137152
}
138153

0 commit comments

Comments
 (0)