/* Get real size of UEFI variable */
status = cs_amp_get_efi_variable(CS_AMP_CAL_NAME, &CS_AMP_CAL_GUID, &data_size, NULL); if (status != EFI_BUFFER_TOO_SMALL) return ERR_PTR(-ENOENT);
if (data_size < sizeof(*efi_data)) {
dev_err(dev, "EFI cal variable truncated\n"); return ERR_PTR(-EOVERFLOW);
}
/* Get variable contents into buffer */
data = kmalloc(data_size, GFP_KERNEL); if (!data) return ERR_PTR(-ENOMEM);
status = cs_amp_get_efi_variable(CS_AMP_CAL_NAME, &CS_AMP_CAL_GUID, &data_size, data); if (status != EFI_SUCCESS) {
ret = -EINVAL; goto err;
}
/* * Treat unpopulated cal_target as a wildcard. * If target_uid != 0 we can only get here if cal_target == 0 * or it didn't match any cal_target value. * If target_uid == 0 it is a wildcard.
*/ if ((cal_target == 0) || (target_uid == 0))
cal = &efi_data->data[amp_index]; else
dev_warn(dev, "Calibration entry %d does not match silicon ID", amp_index);
}
if (cal) {
memcpy(out_data, cal, sizeof(*out_data));
ret = 0;
} else {
dev_warn(dev, "No calibration for silicon ID %#llx\n", target_uid);
ret = -ENOENT;
}
kfree(efi_data);
return ret;
}
/** * cs_amp_get_efi_calibration_data - get an entry from calibration data in EFI. * @dev: struct device of the caller. * @target_uid: UID to match, or zero to ignore UID matching. * @amp_index: Entry index to use, or -1 to prevent lookup by index. * @out_data: struct cirrus_amp_cal_data where the entry will be copied. * * This function can perform 3 types of lookup: * * (target_uid > 0, amp_index >= 0) * UID search with fallback to using the array index. * Search the calibration data for a non-zero calTarget that matches * target_uid, and if found return that entry. Else, if the entry at * [amp_index] has calTarget == 0, return that entry. Else fail. * * (target_uid > 0, amp_index < 0) * UID search only. * Search the calibration data for a non-zero calTarget that matches * target_uid, and if found return that entry. Else fail. * * (target_uid == 0, amp_index >= 0) * Array index fetch only. * Return the entry at [amp_index]. * * An array lookup will be skipped if amp_index exceeds the number of * entries in the calibration array, and in this case the return will * be -ENOENT. An out-of-range amp_index does not prevent matching by * target_uid - it has the same effect as passing amp_index < 0. * * If the EFI data is too short to be a valid entry, or the entry count * in the EFI data overflows the actual length of the data, this function * returns -EOVERFLOW. * * Return: 0 if the entry was found, -ENOENT if no entry was found, * -EOVERFLOW if the EFI file is corrupt, else other error value.
*/ int cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid, int amp_index, struct cirrus_amp_cal_data *out_data)
{ if (IS_ENABLED(CONFIG_EFI) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST)) return _cs_amp_get_efi_calibration_data(dev, target_uid, amp_index, out_data); else return -ENOENT;
}
EXPORT_SYMBOL_NS_GPL(cs_amp_get_efi_calibration_data, "SND_SOC_CS_AMP_LIB");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.