sound/soc/soc-topology.c
Source file repositories/reference/linux-study-clean/sound/soc/soc-topology.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/soc-topology.c- Extension
.c- Size
- 61625 bytes
- Lines
- 2248
- Domain
- Driver Families
- Bucket
- sound/soc
- 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/kernel.hlinux/export.hlinux/list.hlinux/firmware.hlinux/slab.hsound/soc.hsound/soc-dapm.hsound/soc-topology.hsound/tlv.h
Detected Declarations
struct soc_tplgstruct soc_tplg_mapfunction soc_tplg_check_elem_countfunction soc_tplg_is_eoffunction soc_tplg_get_hdr_offsetfunction soc_tplg_get_offsetfunction tplg_chan_get_regfunction tplg_chan_get_shiftfunction get_widget_idfunction soc_control_errfunction soc_tplg_vendor_loadfunction soc_tplg_widget_loadfunction soc_tplg_widget_readyfunction soc_tplg_dai_loadfunction soc_tplg_dai_link_loadfunction soc_tplg_completefunction soc_tplg_add_dcontrolfunction soc_tplg_add_kcontrolfunction soc_tplg_remove_kcontrolfunction soc_tplg_remove_routefunction soc_tplg_remove_widgetfunction soc_tplg_remove_daifunction soc_tplg_remove_linkfunction remove_backend_linkfunction soc_tplg_kcontrol_bind_iofunction snd_soc_tplg_widget_bind_eventfunction soc_tplg_control_loadfunction soc_tplg_create_tlv_db_scalefunction soc_tplg_create_tlvfunction soc_tplg_control_dmixer_createfunction soc_tplg_denum_create_textsfunction soc_tplg_denum_create_valuesfunction soc_tplg_control_denum_createfunction soc_tplg_control_dbytes_createfunction soc_tplg_dbytes_createfunction soc_tplg_dmixer_createfunction soc_tplg_denum_createfunction soc_tplg_kcontrol_elems_loadfunction soc_tplg_add_routefunction soc_tplg_dapm_graph_elems_loadfunction soc_tplg_dapm_widget_createfunction soc_tplg_dapm_widget_elems_loadfunction yetfunction soc_tplg_dapm_completefunction soc_tplg_check_namefunction set_stream_infofunction set_dai_flagsfunction soc_tplg_dai_create
Annotated Snippet
struct soc_tplg {
const struct firmware *fw;
/* runtime FW parsing */
const u8 *pos; /* read position */
const u8 *hdr_pos; /* header position */
unsigned int pass; /* pass number */
/* component caller */
struct device *dev;
struct snd_soc_component *comp;
u32 index; /* current block index */
/* vendor specific kcontrol operations */
const struct snd_soc_tplg_kcontrol_ops *io_ops;
int io_ops_count;
/* vendor specific bytes ext handlers, for TLV bytes controls */
const struct snd_soc_tplg_bytes_ext_ops *bytes_ext_ops;
int bytes_ext_ops_count;
/* optional fw loading callbacks to component drivers */
const struct snd_soc_tplg_ops *ops;
};
/* check we dont overflow the data for this control chunk */
static int soc_tplg_check_elem_count(struct soc_tplg *tplg, size_t elem_size,
unsigned int count, size_t bytes, const char *elem_type)
{
const u8 *end = tplg->pos + elem_size * count;
if (end > tplg->fw->data + tplg->fw->size) {
dev_err(tplg->dev, "ASoC: %s overflow end of data\n",
elem_type);
return -EINVAL;
}
/* check there is enough room in chunk for control.
extra bytes at the end of control are for vendor data here */
if (elem_size * count > bytes) {
dev_err(tplg->dev,
"ASoC: %s count %d of size %zu is bigger than chunk %zu\n",
elem_type, count, elem_size, bytes);
return -EINVAL;
}
return 0;
}
static inline bool soc_tplg_is_eof(struct soc_tplg *tplg)
{
const u8 *end = tplg->hdr_pos;
if (end >= tplg->fw->data + tplg->fw->size)
return true;
return false;
}
static inline unsigned long soc_tplg_get_hdr_offset(struct soc_tplg *tplg)
{
return (unsigned long)(tplg->hdr_pos - tplg->fw->data);
}
static inline unsigned long soc_tplg_get_offset(struct soc_tplg *tplg)
{
return (unsigned long)(tplg->pos - tplg->fw->data);
}
/* mapping of Kcontrol types and associated operations. */
static const struct snd_soc_tplg_kcontrol_ops io_ops[] = {
{SND_SOC_TPLG_CTL_VOLSW, snd_soc_get_volsw,
snd_soc_put_volsw, snd_soc_info_volsw},
{SND_SOC_TPLG_CTL_VOLSW_SX, snd_soc_get_volsw_sx,
snd_soc_put_volsw_sx, NULL},
{SND_SOC_TPLG_CTL_ENUM, snd_soc_get_enum_double,
snd_soc_put_enum_double, snd_soc_info_enum_double},
{SND_SOC_TPLG_CTL_ENUM_VALUE, snd_soc_get_enum_double,
snd_soc_put_enum_double, NULL},
{SND_SOC_TPLG_CTL_BYTES, snd_soc_bytes_get,
snd_soc_bytes_put, snd_soc_bytes_info},
{SND_SOC_TPLG_CTL_RANGE, snd_soc_get_volsw,
snd_soc_put_volsw, snd_soc_info_volsw},
{SND_SOC_TPLG_CTL_VOLSW_XR_SX, snd_soc_get_xr_sx,
snd_soc_put_xr_sx, snd_soc_info_xr_sx},
{SND_SOC_TPLG_CTL_STROBE, snd_soc_get_strobe,
snd_soc_put_strobe, NULL},
{SND_SOC_TPLG_DAPM_CTL_VOLSW, snd_soc_dapm_get_volsw,
snd_soc_dapm_put_volsw, snd_soc_info_volsw},
{SND_SOC_TPLG_DAPM_CTL_ENUM_DOUBLE, snd_soc_dapm_get_enum_double,
snd_soc_dapm_put_enum_double, snd_soc_info_enum_double},
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/export.h`, `linux/list.h`, `linux/firmware.h`, `linux/slab.h`, `sound/soc.h`, `sound/soc-dapm.h`, `sound/soc-topology.h`.
- Detected declarations: `struct soc_tplg`, `struct soc_tplg_map`, `function soc_tplg_check_elem_count`, `function soc_tplg_is_eof`, `function soc_tplg_get_hdr_offset`, `function soc_tplg_get_offset`, `function tplg_chan_get_reg`, `function tplg_chan_get_shift`, `function get_widget_id`, `function soc_control_err`.
- Atlas domain: Driver Families / sound/soc.
- 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.