sound/soc/qcom/qdsp6/q6routing.c
Source file repositories/reference/linux-study-clean/sound/soc/qcom/qdsp6/q6routing.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/qcom/qdsp6/q6routing.c- Extension
.c- Size
- 47314 bytes
- Lines
- 1175
- 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/sound/qcom,q6asm.hdt-bindings/sound/qcom,q6afe.hlinux/init.hlinux/err.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/bitops.hlinux/mutex.hlinux/slab.hsound/core.hsound/soc.hsound/soc-dapm.hsound/pcm.hsound/control.hsound/asound.hsound/pcm_params.hq6afe.hq6asm.hq6adm.hq6routing.h
Detected Declarations
struct session_datastruct msm_routing_datafunction q6routing_stream_openfunction for_each_set_bitfunction q6routing_stream_closefunction for_each_set_bitfunction msm_routing_get_audio_mixerfunction msm_routing_put_audio_mixerfunction routing_hw_paramsfunction msm_routing_probefunction q6routing_reg_readfunction q6routing_reg_writefunction q6pcm_routing_probefunction q6pcm_routing_removeexport q6routing_stream_openexport q6routing_stream_close
Annotated Snippet
struct session_data {
int state;
int port_id;
int path_type;
int app_type;
int acdb_id;
int sample_rate;
int bits_per_sample;
int channels;
int perf_mode;
int numcopps;
int fedai_id;
unsigned long copp_map;
struct q6copp *copps[MAX_COPPS_PER_PORT];
};
struct msm_routing_data {
struct session_data sessions[MAX_SESSIONS];
struct session_data port_data[AFE_MAX_PORTS];
struct device *dev;
struct mutex lock;
};
static struct msm_routing_data *routing_data;
/**
* q6routing_stream_open() - Register a new stream for route setup
*
* @fedai_id: Frontend dai id.
* @perf_mode: Performance mode.
* @stream_id: ASM stream id to map.
* @stream_type: Direction of stream
*
* Return: Will be an negative on error or a zero on success.
*/
int q6routing_stream_open(int fedai_id, int perf_mode,
int stream_id, int stream_type)
{
int j, topology, num_copps = 0;
struct route_payload payload;
struct q6copp *copp;
int copp_idx;
struct session_data *session, *pdata;
if (!routing_data) {
pr_err("Routing driver not yet ready\n");
return -EINVAL;
}
session = &routing_data->sessions[stream_id - 1];
if (session->port_id < 0) {
dev_err(routing_data->dev, "Routing not setup for MultiMedia%d Session\n",
session->fedai_id);
return -EINVAL;
}
pdata = &routing_data->port_data[session->port_id];
mutex_lock(&routing_data->lock);
session->fedai_id = fedai_id;
session->path_type = pdata->path_type;
session->sample_rate = pdata->sample_rate;
session->channels = pdata->channels;
session->bits_per_sample = pdata->bits_per_sample;
payload.num_copps = 0; /* only RX needs to use payload */
topology = NULL_COPP_TOPOLOGY;
copp = q6adm_open(routing_data->dev, session->port_id,
session->path_type, session->sample_rate,
session->channels, topology, perf_mode,
session->bits_per_sample, 0, 0);
if (IS_ERR_OR_NULL(copp)) {
mutex_unlock(&routing_data->lock);
return -EINVAL;
}
copp_idx = q6adm_get_copp_id(copp);
set_bit(copp_idx, &session->copp_map);
session->copps[copp_idx] = copp;
for_each_set_bit(j, &session->copp_map, MAX_COPPS_PER_PORT) {
payload.port_id[num_copps] = session->port_id;
payload.copp_idx[num_copps] = j;
num_copps++;
}
if (num_copps) {
payload.num_copps = num_copps;
Annotation
- Immediate include surface: `dt-bindings/sound/qcom,q6asm.h`, `dt-bindings/sound/qcom,q6afe.h`, `linux/init.h`, `linux/err.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/bitops.h`.
- Detected declarations: `struct session_data`, `struct msm_routing_data`, `function q6routing_stream_open`, `function for_each_set_bit`, `function q6routing_stream_close`, `function for_each_set_bit`, `function msm_routing_get_audio_mixer`, `function msm_routing_put_audio_mixer`, `function routing_hw_params`, `function msm_routing_probe`.
- 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.