sound/soc/intel/avs/loader.c
Source file repositories/reference/linux-study-clean/sound/soc/intel/avs/loader.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/intel/avs/loader.c- Extension
.c- Size
- 19402 bytes
- Lines
- 751
- 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/firmware.hlinux/module.hlinux/slab.hlinux/string.hsound/hdaudio.hsound/hdaudio_ext.havs.hcldma.hmessages.hregisters.htopology.h
Detected Declarations
struct avs_fw_manifeststruct avs_fw_ext_manifestfunction avs_fw_ext_manifest_stripfunction avs_fw_manifest_offsetfunction avs_fw_manifest_strip_verifyfunction avs_cldma_load_basefwfunction avs_cldma_load_libraryfunction avs_cldma_load_modulefunction avs_cldma_transfer_modulesfunction avs_hda_init_romfunction avs_imr_load_basefwfunction avs_hda_load_basefwfunction avs_hda_load_libraryfunction avs_hda_transfer_modulesfunction avs_dsp_load_librariesfunction avs_dsp_load_basefwfunction avs_load_firmwarefunction avs_config_basefwfunction avs_dsp_boot_firmwarefunction avs_dsp_alloc_resourcesfunction avs_dsp_first_boot_firmware
Annotated Snippet
struct avs_fw_manifest {
u32 id;
u32 len;
char name[AVS_LIB_NAME_SIZE];
u32 preload_page_count;
u32 img_flags;
u32 feature_mask;
struct avs_fw_version version;
} __packed;
static_assert(sizeof(struct avs_fw_manifest) == 36);
struct avs_fw_ext_manifest {
u32 id;
u32 len;
u16 version_major;
u16 version_minor;
u32 entries;
} __packed;
static_assert(sizeof(struct avs_fw_ext_manifest) == 16);
static int avs_fw_ext_manifest_strip(struct firmware *fw)
{
struct avs_fw_ext_manifest *man;
if (fw->size < sizeof(*man))
return -EINVAL;
man = (struct avs_fw_ext_manifest *)fw->data;
if (man->id == AVS_EXT_MANIFEST_MAGIC) {
fw->data += man->len;
fw->size -= man->len;
}
return 0;
}
static int avs_fw_manifest_offset(struct firmware *fw)
{
/* Header type found in first DWORD of fw binary. */
u32 magic = *(u32 *)fw->data;
switch (magic) {
case SKL_MANIFEST_MAGIC:
return SKL_ADSPFW_OFFSET;
case APL_MANIFEST_MAGIC:
return APL_ADSPFW_OFFSET;
default:
return -EINVAL;
}
}
static int avs_fw_manifest_strip_verify(struct avs_dev *adev, struct firmware *fw,
const struct avs_fw_version *min)
{
struct avs_fw_manifest *man;
int offset, ret;
ret = avs_fw_ext_manifest_strip(fw);
if (ret)
return ret;
offset = avs_fw_manifest_offset(fw);
if (offset < 0)
return offset;
if (fw->size < offset + sizeof(*man))
return -EINVAL;
if (!min)
return 0;
man = (struct avs_fw_manifest *)(fw->data + offset);
if (man->version.major != min->major ||
man->version.minor != min->minor ||
man->version.hotfix != min->hotfix ||
man->version.build < min->build) {
dev_warn(adev->dev, "bad FW version %d.%d.%d.%d, expected %d.%d.%d.%d or newer\n",
man->version.major, man->version.minor,
man->version.hotfix, man->version.build,
min->major, min->minor, min->hotfix, min->build);
if (!debug_ignore_fw_version)
return -EINVAL;
}
return 0;
}
int avs_cldma_load_basefw(struct avs_dev *adev, struct firmware *fw)
{
struct hda_cldma *cl = &code_loader;
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/module.h`, `linux/slab.h`, `linux/string.h`, `sound/hdaudio.h`, `sound/hdaudio_ext.h`, `avs.h`, `cldma.h`.
- Detected declarations: `struct avs_fw_manifest`, `struct avs_fw_ext_manifest`, `function avs_fw_ext_manifest_strip`, `function avs_fw_manifest_offset`, `function avs_fw_manifest_strip_verify`, `function avs_cldma_load_basefw`, `function avs_cldma_load_library`, `function avs_cldma_load_module`, `function avs_cldma_transfer_modules`, `function avs_hda_init_rom`.
- 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.