sound/soc/qcom/qdsp6/q6apm.c
Source file repositories/reference/linux-study-clean/sound/soc/qcom/qdsp6/q6apm.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/qcom/qdsp6/q6apm.c- Extension
.c- Size
- 26279 bytes
- Lines
- 1006
- 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.
- 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
dt-bindings/soc/qcom,gpr.hlinux/delay.hlinux/jiffies.hlinux/kernel.hlinux/module.hlinux/of.hlinux/of_platform.hlinux/sched.hlinux/slab.hlinux/soc/qcom/apr.hlinux/wait.hsound/soc.hsound/soc-dapm.hsound/pcm.haudioreach.hq6apm.h
Detected Declarations
struct apm_graph_mgmt_cmdfunction q6apm_send_cmd_syncfunction audioreach_graph_mgmt_cmdfunction q6apm_put_audioreach_graphfunction q6apm_get_apm_statefunction q6apm_is_adsp_readyfunction list_for_each_entryfunction q6apm_graph_media_format_shmemfunction __q6apm_map_memory_fixed_regionfunction q6apm_map_pos_bufferfunction q6apm_map_memory_fixed_regionfunction q6apm_alloc_fragmentsfunction __q6apm_unmap_memory_fixed_regionfunction q6apm_unmap_memory_fixed_regionfunction q6apm_unmap_pos_bufferfunction q6apm_free_fragmentsfunction q6apm_remove_initial_silencefunction q6apm_remove_trailing_silencefunction q6apm_enable_compress_modulefunction q6apm_set_real_module_idfunction q6apm_graph_media_format_pcmfunction list_for_each_entryfunction q6apm_write_asyncfunction q6apm_readfunction q6apm_get_hw_pointerfunction graph_callbackfunction q6apm_register_watermark_eventfunction q6apm_push_pull_configfunction q6apm_is_graph_in_push_pull_mode_from_idfunction q6apm_is_graph_in_push_pull_modefunction q6apm_graph_get_module_iidfunction q6apm_graph_closefunction q6apm_graph_preparefunction q6apm_graph_startfunction q6apm_graph_stopfunction q6apm_graph_flushfunction q6apm_audio_probefunction q6apm_audio_removefunction apm_probefunction apm_removefunction apm_callbackexport q6apm_is_adsp_readyexport q6apm_graph_media_format_shmemexport q6apm_map_pos_bufferexport q6apm_map_memory_fixed_regionexport q6apm_alloc_fragmentsexport q6apm_unmap_memory_fixed_regionexport q6apm_unmap_pos_buffer
Annotated Snippet
struct apm_graph_mgmt_cmd {
struct apm_module_param_data param_data;
uint32_t num_sub_graphs;
uint32_t sub_graph_id_list[];
} __packed;
#define APM_GRAPH_MGMT_PSIZE(p, n) ALIGN(struct_size(p, sub_graph_id_list, n), 8)
static struct q6apm *g_apm;
int q6apm_send_cmd_sync(struct q6apm *apm, const struct gpr_pkt *pkt,
uint32_t rsp_opcode)
{
gpr_device_t *gdev = apm->gdev;
return audioreach_send_cmd_sync(&gdev->dev, gdev, &apm->result, &apm->lock,
NULL, &apm->wait, pkt, rsp_opcode);
}
static struct audioreach_graph *q6apm_get_audioreach_graph(struct q6apm *apm, uint32_t graph_id)
{
struct audioreach_graph_info *info;
struct audioreach_graph *graph;
int id;
mutex_lock(&apm->lock);
graph = idr_find(&apm->graph_idr, graph_id);
mutex_unlock(&apm->lock);
if (graph) {
kref_get(&graph->refcount);
return graph;
}
info = idr_find(&apm->graph_info_idr, graph_id);
if (!info)
return ERR_PTR(-ENODEV);
graph = kzalloc_obj(*graph);
if (!graph)
return ERR_PTR(-ENOMEM);
graph->apm = apm;
graph->info = info;
graph->id = graph_id;
graph->graph = audioreach_alloc_graph_pkt(apm, info);
if (IS_ERR(graph->graph)) {
void *err = graph->graph;
kfree(graph);
return ERR_CAST(err);
}
mutex_lock(&apm->lock);
id = idr_alloc(&apm->graph_idr, graph, graph_id, graph_id + 1, GFP_KERNEL);
if (id < 0) {
dev_err(apm->dev, "Unable to allocate graph id (%d)\n", graph_id);
kfree(graph->graph);
kfree(graph);
mutex_unlock(&apm->lock);
return ERR_PTR(id);
}
mutex_unlock(&apm->lock);
kref_init(&graph->refcount);
q6apm_send_cmd_sync(apm, graph->graph, 0);
return graph;
}
static int audioreach_graph_mgmt_cmd(struct audioreach_graph *graph, uint32_t opcode)
{
struct audioreach_graph_info *info = graph->info;
int num_sub_graphs = info->num_sub_graphs;
struct apm_module_param_data *param_data;
struct apm_graph_mgmt_cmd *mgmt_cmd;
struct audioreach_sub_graph *sg;
struct q6apm *apm = graph->apm;
int i = 0, payload_size = APM_GRAPH_MGMT_PSIZE(mgmt_cmd, num_sub_graphs);
struct gpr_pkt *pkt __free(kfree) = audioreach_alloc_apm_cmd_pkt(payload_size, opcode, 0);
if (IS_ERR(pkt))
return PTR_ERR(pkt);
mgmt_cmd = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE;
mgmt_cmd->num_sub_graphs = num_sub_graphs;
Annotation
- Immediate include surface: `dt-bindings/soc/qcom,gpr.h`, `linux/delay.h`, `linux/jiffies.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/of_platform.h`, `linux/sched.h`.
- Detected declarations: `struct apm_graph_mgmt_cmd`, `function q6apm_send_cmd_sync`, `function audioreach_graph_mgmt_cmd`, `function q6apm_put_audioreach_graph`, `function q6apm_get_apm_state`, `function q6apm_is_adsp_ready`, `function list_for_each_entry`, `function q6apm_graph_media_format_shmem`, `function __q6apm_map_memory_fixed_region`, `function q6apm_map_pos_buffer`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration 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.