sound/hda/codecs/side-codecs/tas2781_hda.c
Source file repositories/reference/linux-study-clean/sound/hda/codecs/side-codecs/tas2781_hda.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/codecs/side-codecs/tas2781_hda.c- Extension
.c- Size
- 11944 bytes
- Lines
- 422
- Domain
- Driver Families
- Bucket
- sound/hda
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/component.hlinux/crc8.hlinux/crc32.hlinux/efi.hlinux/firmware.hlinux/i2c.hlinux/pm_runtime.hsound/soc.hsound/tas2781.htas2781_hda.h
Detected Declarations
function cali_cnvfunction tas2781_apply_calibfunction tas2781_save_calibrationfunction tas2781_hda_removefunction tasdevice_info_profilefunction tasdevice_info_programsfunction tasdevice_info_configfunction tasdevice_get_profile_idfunction tasdevice_set_profile_idfunction tasdevice_program_getfunction tasdevice_program_putfunction tasdevice_config_getfunction tasdevice_config_put
Annotated Snippet
if (crc != tmp_val[3 + tmp_val[1] * 6]) {
cali_data->total_sz = 0;
dev_err(p->dev, "%s: CRC error\n", __func__);
return;
}
node_num = tmp_val[1];
for (j = 0, k = 0; j < node_num; j++) {
oft = j * 6 + 3;
if (tmp_val[oft] == TASDEV_UEFI_CALI_REG_ADDR_FLG) {
for (i = 0; i < TASDEV_CALIB_N; i++) {
buf = &data[(oft + i + 1) * 4];
cali_reg[i] = TASDEVICE_REG(buf[1],
buf[2], buf[3]);
}
} else {
l = j * (cali_data->cali_dat_sz_per_dev + 1);
if (k >= p->ndev || l > oft * 4) {
dev_err(p->dev, "%s: dev sum error\n",
__func__);
cali_data->total_sz = 0;
return;
}
data[l] = k;
oft++;
cali_cnv(data, 4 * oft, l);
k++;
}
}
} else {
/*
* Calibration data is in V1 format.
* struct cali_data {
* char cali_data[20];
* }
*
* struct {
* struct cali_data cali_data[4];
* int TimeStamp of Calibration (4 bytes)
* int CRC (4 bytes)
* } ueft;
*/
crc = crc32(~0, data, 84) ^ ~0;
if (crc != tmp_val[21]) {
cali_data->total_sz = 0;
dev_err(p->dev, "%s: V1 CRC error\n", __func__);
return;
}
for (j = p->ndev - 1; j >= 0; j--) {
l = j * (cali_data->cali_dat_sz_per_dev + 1);
cali_cnv(data, cali_data->cali_dat_sz_per_dev * j, l);
data[l] = j;
}
}
if (p->dspbin_typ == TASDEV_BASIC) {
r->r0_reg = cali_reg[0];
r->invr0_reg = cali_reg[1];
r->r0_low_reg = cali_reg[2];
r->pow_reg = cali_reg[3];
r->tlimit_reg = cali_reg[4];
}
cali_data->total_sz = p->ndev * (cali_data->cali_dat_sz_per_dev + 1);
}
/*
* 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",
};
Annotation
- Immediate include surface: `linux/component.h`, `linux/crc8.h`, `linux/crc32.h`, `linux/efi.h`, `linux/firmware.h`, `linux/i2c.h`, `linux/pm_runtime.h`, `sound/soc.h`.
- Detected declarations: `function cali_cnv`, `function tas2781_apply_calib`, `function tas2781_save_calibration`, `function tas2781_hda_remove`, `function tasdevice_info_profile`, `function tasdevice_info_programs`, `function tasdevice_info_config`, `function tasdevice_get_profile_id`, `function tasdevice_set_profile_id`, `function tasdevice_program_get`.
- Atlas domain: Driver Families / sound/hda.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.