/* * The order of calibrated-data writing function is a bit different from the * order in UEFI. Here is the conversion to match the order of calibrated-data * writing function.
*/ staticvoid cali_cnv(unsignedchar *data, unsignedint 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);
if (tmp_val[0] == 2781) { /* * New features were added in calibrated Data V3: * 1. Added calibration registers address define in * a node, marked as Device id == 0x80. * New features were added in calibrated Data V2: * 1. Added some the fields to store the link_id and * uniqie_id for multi-link solutions * 2. Support flexible number of devices instead of * fixed one in V1. * Layout of calibrated data V2 in UEFI(total 256 bytes): * ChipID (2781, 4 bytes) * Data-Group-Sum (4 bytes) * TimeStamp of Calibration (4 bytes) * for (i = 0; i < Data-Group-Sum; i++) { * if (Data type != 0x80) (4 bytes) * Calibrated Data of Device #i (20 bytes) * else * Calibration registers address (5*4 = 20 bytes) * # V2: No reg addr in data grp section. * # V3: Normally the last grp is the reg addr. * } * CRC (4 bytes) * Reserved (the rest)
*/
crc = crc32(~0, data, (3 + tmp_val[1] * 6) * 4) ^ ~0;
/* * Update the calibration data, including speaker impedance, f0, etc, * into algo. Calibrate data is done by manufacturer in the factory. * The data is used by Algo for calculating the speaker temperature, * speaker membrane excursion and f0 in real time during playback. * Calibration data format in EFI is V2, since 2024.
*/ int tas2781_save_calibration(struct tas2781_hda *hda)
{ /* * GUID was used for data access in BIOS, it was provided by board * manufactory.
*/
efi_guid_t efi_guid = tasdev_fct_efi_guid[LENOVO]; /* * Some devices save the calibrated data into L"CALI_DATA", * and others into L"SmartAmpCalibrationData".
*/ static efi_char16_t *efi_name[CALIBRATION_DATA_AREA_NUM] = {
L"CALI_DATA",
L"SmartAmpCalibrationData",
}; struct tasdevice_priv *p = hda->priv; struct calidata *cali_data = &p->cali_data; unsignedlong total_sz = 0; unsignedint attr, size; unsignedchar *data;
efi_status_t status; int i;
if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE)) {
dev_err(p->dev, "%s: NO EFI FOUND!\n", __func__); return -EINVAL;
}
if (hda->catlog_id < LENOVO)
efi_guid = tasdev_fct_efi_guid[hda->catlog_id];
cali_data->cali_dat_sz_per_dev = 20;
size = p->ndev * (cali_data->cali_dat_sz_per_dev + 1); for (i = 0; i < CALIBRATION_DATA_AREA_NUM; i++) { /* Get real size of UEFI variable */
status = efi.get_variable(efi_name[i], &efi_guid, &attr,
&total_sz, NULL);
cali_data->total_sz = total_sz > size ? total_sz : size; if (status == EFI_BUFFER_TOO_SMALL) { /* Allocate data buffer of data_size bytes */
data = cali_data->data = devm_kzalloc(p->dev,
cali_data->total_sz, GFP_KERNEL); if (!data) {
status = -ENOMEM; continue;
} /* Get variable contents into buffer */
status = efi.get_variable(efi_name[i], &efi_guid,
&attr, &cali_data->total_sz, data);
} /* Check whether get the calibrated data */ if (status == EFI_SUCCESS) break;
}
int tasdevice_set_profile_id(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{ struct tasdevice_priv *tas_priv = snd_kcontrol_chip(kcontrol); int profile_id = ucontrol->value.integer.value[0]; int max = tas_priv->rcabin.ncfgs - 1; int val, ret = 0;
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.