Skip to content

Commit

Permalink
ASoC: cs-amp-lib: Ignore empty UEFI calibration entries
Browse files Browse the repository at this point in the history
If the timestamp of a calibration entry is 0 it is an unused entry and
must be ignored.

Some end-products reserve EFI space for calibration entries by shipping
with a zero-filled EFI file. When searching the file for calibration
data the driver must skip the empty entries. The timestamp of a valid
entry is always non-zero.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 1cad872 ("ASoC: cs-amp-lib: Add helpers for factory calibration data")
Link: https://patch.msgid.link/20240822133544.304421-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
rfvirgil authored and broonie committed Aug 22, 2024
1 parent bff980d commit bb44855
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sound/soc/codecs/cs-amp-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ static int _cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid,
for (i = 0; i < efi_data->count; ++i) {
u64 cal_target = cs_amp_cal_target_u64(&efi_data->data[i]);

/* Skip empty entries */
if (!efi_data->data[i].calTime[0] && !efi_data->data[i].calTime[1])
continue;

/* Skip entries with unpopulated silicon ID */
if (cal_target == 0)
continue;
Expand All @@ -193,7 +197,8 @@ static int _cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid,
}
}

if (!cal && (amp_index >= 0) && (amp_index < efi_data->count)) {
if (!cal && (amp_index >= 0) && (amp_index < efi_data->count) &&
(efi_data->data[amp_index].calTime[0] || efi_data->data[amp_index].calTime[1])) {
u64 cal_target = cs_amp_cal_target_u64(&efi_data->data[amp_index]);

/*
Expand Down

0 comments on commit bb44855

Please sign in to comment.