Lines Matching +full:t +full:- +full:calibration +full:- +full:data
1 // SPDX-License-Identifier: GPL-2.0-only
17 #include <sound/cs-amp-lib.h>
60 mutex_lock(&dsp->pwr_lock);
61 cs_ctl = cs_dsp_get_ctl(dsp, ctl_name, controls->mem_region, controls->alg_id);
63 mutex_unlock(&dsp->pwr_lock);
66 dev_err(dsp->dev, "Failed to write to '%s': %d\n", ctl_name, ret);
73 return -ENODEV;
78 const struct cirrus_amp_cal_data *data)
82 dev_dbg(dsp->dev, "Calibration: Ambient=%#x, Status=%#x, CalR=%d\n",
83 data->calAmbient, data->calStatus, data->calR);
85 if (list_empty(&dsp->ctl_list)) {
86 dev_info(dsp->dev, "Calibration disabled due to missing firmware controls\n");
87 return -ENOENT;
90 ret = cs_amp_write_cal_coeff(dsp, controls, controls->ambient, data->calAmbient);
94 ret = cs_amp_write_cal_coeff(dsp, controls, controls->calr, data->calR);
98 ret = cs_amp_write_cal_coeff(dsp, controls, controls->status, data->calStatus);
102 ret = cs_amp_write_cal_coeff(dsp, controls, controls->checksum, data->calR + 1);
110 * cs_amp_write_cal_coeffs - Write calibration data to firmware controls.
113 * @data: Pointer to calibration data.
119 const struct cirrus_amp_cal_data *data)
122 return _cs_amp_write_cal_coeffs(dsp, controls, data);
124 return -ENODEV;
149 return -ENOENT;
151 return -EFBIG;
155 return -EACCES;
157 return -EIO;
165 u8 *data;
179 return ERR_PTR(-ENOENT);
183 return ERR_PTR(-EOVERFLOW);
187 data = kmalloc(data_size, GFP_KERNEL);
188 if (!data)
189 return ERR_PTR(-ENOMEM);
193 &data_size, data);
195 ret = -EINVAL;
199 efi_data = (struct cirrus_amp_efi_data *)data;
200 dev_dbg(dev, "Calibration: Size=%d, Amp Count=%d\n", efi_data->size, efi_data->count);
202 if ((efi_data->count > 128) ||
203 struct_size(efi_data, data, efi_data->count) > data_size) {
205 ret = -EOVERFLOW;
212 kfree(data);
213 dev_err(dev, "Failed to read calibration data from EFI: %d\n", ret);
218 static u64 cs_amp_cal_target_u64(const struct cirrus_amp_cal_data *data)
220 return ((u64)data->calTarget[1] << 32) | data->calTarget[0];
235 for (i = 0; i < efi_data->count; ++i) {
236 u64 cal_target = cs_amp_cal_target_u64(&efi_data->data[i]);
239 if (!efi_data->data[i].calTime[0] && !efi_data->data[i].calTime[1])
247 cal = &efi_data->data[i];
253 if (!cal && (amp_index >= 0) && (amp_index < efi_data->count) &&
254 (efi_data->data[amp_index].calTime[0] || efi_data->data[amp_index].calTime[1])) {
255 u64 cal_target = cs_amp_cal_target_u64(&efi_data->data[amp_index]);
260 * or it didn't match any cal_target value.
264 cal = &efi_data->data[amp_index];
266 dev_warn(dev, "Calibration entry %d does not match silicon ID", amp_index);
273 dev_warn(dev, "No calibration for silicon ID %#llx\n", target_uid);
274 ret = -ENOENT;
283 * cs_amp_get_efi_calibration_data - get an entry from calibration data in EFI.
286 * @amp_index: Entry index to use, or -1 to prevent lookup by index.
293 * Search the calibration data for a non-zero calTarget that matches
299 * Search the calibration data for a non-zero calTarget that matches
307 * entries in the calibration array, and in this case the return will
308 * be -ENOENT. An out-of-range amp_index does not prevent matching by
309 * target_uid - it has the same effect as passing amp_index < 0.
311 * If the EFI data is too short to be a valid entry, or the entry count
312 * in the EFI data overflows the actual length of the data, this function
313 * returns -EOVERFLOW.
315 * Return: 0 if the entry was found, -ENOENT if no entry was found,
316 * -EOVERFLOW if the EFI file is corrupt, else other error value.
324 return -ENOENT;
342 status = cs_amp_get_efi_variable(info->name, info->guid, &size, &spkid);
348 return -ENOENT;
350 for (i = 0; i < ARRAY_SIZE(info->values); i++) {
351 if (info->values[i] == spkid)
357 return -EINVAL;
374 * cs_amp_get_vendor_spkid - get a speaker ID from vendor-specific storage
377 * Known vendor-specific methods of speaker ID are checked and if one is
380 * Return: >=0 is a valid speaker ID. -ENOENT if a vendor-specific method
381 * was not found. -EACCES if the vendor-specific storage could not
382 * be read. Other error values indicate that the data from the
383 * vendor-specific storage was found but could not be understood.
391 return -ENOENT;
395 if (ret != -ENOENT)
399 return -ENOENT;