Skip to content

Commit 85e323b

Browse files
jimxbj-dottiwai
authored andcommitted
ALSA: hda/tas2781: Fix calibration data parser issue
We will copy calibration data from position behind to front. We have created a variable (tmp_val) point on top of calibration data buffer, and tmp_val[1] is max of node number in original calibration data structure, it will be overwritten after first data copy, so can't be used as max node number check in for loop. So we create a new variable to save max of node number (tmp_val[1]), used to check if max node number was reached in for loop. And a point need to be increased to point at calibration data in node. Data saved position also need to be increased one byte. 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: Baojun Xu <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 4f5b1aa commit 85e323b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sound/pci/hda/tas2781_hda.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static void tas2781_apply_calib(struct tasdevice_priv *p)
4444
TASDEVICE_REG(0, 0x13, 0x70),
4545
TASDEVICE_REG(0, 0x18, 0x7c),
4646
};
47-
unsigned int crc, oft;
47+
unsigned int crc, oft, node_num;
4848
unsigned char *buf;
4949
int i, j, k, l;
5050

@@ -80,8 +80,9 @@ static void tas2781_apply_calib(struct tasdevice_priv *p)
8080
dev_err(p->dev, "%s: CRC error\n", __func__);
8181
return;
8282
}
83+
node_num = tmp_val[1];
8384

84-
for (j = 0, k = 0; j < tmp_val[1]; j++) {
85+
for (j = 0, k = 0; j < node_num; j++) {
8586
oft = j * 6 + 3;
8687
if (tmp_val[oft] == TASDEV_UEFI_CALI_REG_ADDR_FLG) {
8788
for (i = 0; i < TASDEV_CALIB_N; i++) {
@@ -99,8 +100,9 @@ static void tas2781_apply_calib(struct tasdevice_priv *p)
99100
}
100101

101102
data[l] = k;
103+
oft++;
102104
for (i = 0; i < TASDEV_CALIB_N * 4; i++)
103-
data[l + i] = data[4 * oft + i];
105+
data[l + i + 1] = data[4 * oft + i];
104106
k++;
105107
}
106108
}

0 commit comments

Comments
 (0)