sound/soc/codecs/rt1320-sdw.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rt1320-sdw.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rt1320-sdw.c- Extension
.c- Size
- 92676 bytes
- Lines
- 3092
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/delay.hlinux/device.hlinux/pm_runtime.hlinux/mod_devicetable.hlinux/module.hlinux/regmap.hlinux/dmi.hlinux/firmware.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc-dapm.hsound/initval.hsound/tlv.hsound/sdw.hrt1320-sdw.hrt-sdw-common.h
Detected Declarations
struct rt1320_imageinfostruct rt1320_dspfwheaderfunction rt1320_readable_registerfunction rt1320_volatile_registerfunction rt1320_mbq_readable_registerfunction rt1320_read_propfunction rt1320_pde_transition_delayfunction rt1320_data_rwfunction rt1320_rsgain_to_rsratiofunction rt1320_pr_readfunction rt1320_check_fw_readyfunction rt1320_check_power_state_readyfunction rt1320_process_fw_paramfunction rt1320_fw_param_protocolfunction rt1320_set_advancemodefunction rt1320_invrs_loadfunction rt1320_calc_r0function rt1320_calibratefunction rt1320_r0_cali_getfunction rt1320_r0_cali_putfunction rt1320_load_mcu_patchfunction rt1320_vab_presetfunction rt1320_t0_loadfunction rt1320_rae_loadfunction rt1320_dspfw_load_codefunction rt1320_load_dspfw_workfunction rt1320_vc_presetfunction rt1321_presetfunction rt1320_io_initfunction rt1320_update_statusfunction rt1320_pde11_eventfunction rt1320_pde23_eventfunction rt1320_set_gain_putfunction rt1320_set_gain_getfunction rt1320_set_fu_capture_ctlfunction rt1320_dmic_fu_capture_getfunction rt1320_dmic_fu_capture_putfunction rt1320_dmic_fu_infofunction rt1320_dmic_fu_eventfunction rt1320_r0_loadfunction rt1320_r0_load_mode_getfunction rt1320_r0_load_mode_putfunction rt1320_t0_r0_load_infofunction rt1320_dspfw_load_getfunction rt1320_dspfw_load_putfunction rt1320_rae_update_getfunction rt1320_rae_update_putfunction rt1320_brown_out_put
Annotated Snippet
struct rt1320_imageinfo {
unsigned int addr;
unsigned int size;
};
struct rt1320_dspfwheader {
unsigned int sync;
short num;
short crc;
};
struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(rt1320->component);
struct device *dev = &rt1320->sdw_slave->dev;
unsigned int val, i, fw_offset, fw_ready;
unsigned int fw_status_addr;
struct rt1320_dspfwheader *fwheader;
struct rt1320_imageinfo *ptr_img;
struct sdw_bpt_section sec[10];
const struct firmware *fw = NULL;
unsigned char *fw_data;
bool dev_fw_match = false;
static const char hdr_sig[] = "AFX";
unsigned int hdr_size = 0;
const char *dmi_vendor, *dmi_product, *dmi_sku;
int len_vendor, len_product, len_sku;
char filename[512];
switch (rt1320->dev_id) {
case RT1320_DEV_ID:
fw_status_addr = RT1320_DSPFW_STATUS_ADDR;
break;
case RT1321_DEV_ID:
fw_status_addr = RT1321_DSPFW_STATUS_ADDR;
break;
default:
dev_err(dev, "%s: Unknown device ID %d\n", __func__, rt1320->dev_id);
return;
}
dmi_vendor = dmi_get_system_info(DMI_SYS_VENDOR);
dmi_product = dmi_get_system_info(DMI_PRODUCT_NAME);
dmi_sku = dmi_get_system_info(DMI_PRODUCT_SKU);
if (dmi_vendor && dmi_product && dmi_sku) {
len_vendor = strchrnul(dmi_vendor, ' ') - dmi_vendor;
len_product = strchrnul(dmi_product, ' ') - dmi_product;
len_sku = strchrnul(dmi_sku, ' ') - dmi_sku;
snprintf(filename, sizeof(filename),
"realtek/rt1320/rt1320_%.*s_%.*s_%.*s.dat",
len_vendor, dmi_vendor, len_product, dmi_product, len_sku, dmi_sku);
dev_dbg(dev, "%s: try to load FW file %s\n", __func__, filename);
} else if (rt1320->dspfw_name) {
snprintf(filename, sizeof(filename), "rt1320_%s.dat",
rt1320->dspfw_name);
dev_dbg(dev, "%s: try to load FW file %s\n", __func__, filename);
} else {
dev_warn(dev, "%s: Can't find proper FW file name\n", __func__);
return;
}
snd_soc_dapm_mutex_lock(dapm);
regmap_write(rt1320->regmap,
SDW_SDCA_CTL(FUNC_NUM_AMP, RT1320_SDCA_ENT_PDE23,
RT1320_SDCA_CTL_REQ_POWER_STATE, 0), 0x00);
rt1320_pde_transition_delay(rt1320, FUNC_NUM_AMP, RT1320_SDCA_ENT_PDE23, 0x00);
regmap_read(rt1320->regmap, fw_status_addr, &fw_ready);
fw_ready &= 0x1;
if (fw_ready) {
dev_dbg(dev, "%s, DSP FW was already\n", __func__);
rt1320->fw_load_done = true;
goto _exit_;
}
/* change to IRAM */
regmap_update_bits(rt1320->regmap, 0xf01e, 0x80, 0x00);
request_firmware(&fw, filename, dev);
if (fw) {
fwheader = (struct rt1320_dspfwheader *)fw->data;
dev_dbg(dev, "%s, fw sync = 0x%x, num=%d, crc=0x%x\n", __func__,
fwheader->sync, fwheader->num, fwheader->crc);
if (fwheader->sync != 0x0a1c5679) {
dev_err(dev, "%s: FW sync error\n", __func__);
release_firmware(fw);
goto _exit_;
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/device.h`, `linux/pm_runtime.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/regmap.h`, `linux/dmi.h`, `linux/firmware.h`.
- Detected declarations: `struct rt1320_imageinfo`, `struct rt1320_dspfwheader`, `function rt1320_readable_register`, `function rt1320_volatile_register`, `function rt1320_mbq_readable_register`, `function rt1320_read_prop`, `function rt1320_pde_transition_delay`, `function rt1320_data_rw`, `function rt1320_rsgain_to_rsratio`, `function rt1320_pr_read`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.