sound/soc/qcom/sdw.c
Source file repositories/reference/linux-study-clean/sound/soc/qcom/sdw.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/qcom/sdw.c- Extension
.c- Size
- 5639 bytes
- Lines
- 217
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
dt-bindings/sound/qcom,lpass.hdt-bindings/sound/qcom,q6afe.hlinux/module.hsound/soc.hsdw.h
Detected Declarations
function qcom_snd_is_sdw_daifunction qcom_snd_sdw_startupfunction for_each_rtd_codec_daisfunction qcom_snd_sdw_preparefunction for_each_rtd_codec_daisfunction qcom_snd_sdw_shutdownfunction qcom_snd_sdw_hw_freeexport qcom_snd_sdw_startupexport qcom_snd_sdw_prepareexport qcom_snd_sdw_get_streamexport qcom_snd_sdw_shutdownexport qcom_snd_sdw_hw_free
Annotated Snippet
if (ret < 0 && ret != -ENOTSUPP) {
dev_err(rtd->dev, "Failed to set sdw stream on %s\n", codec_dai->name);
goto err_set_stream;
} else if (ret == -ENOTSUPP) {
/* Ignore unsupported */
continue;
}
ret = snd_soc_dai_get_channel_map(codec_dai, &tx_ch_cnt, tx_ch,
&rx_ch_cnt, rx_ch);
if (ret != 0 && ret != -ENOTSUPP) {
dev_err(rtd->dev, "Failed to get codec chan map %s\n", codec_dai->name);
goto err_set_stream;
} else if (ret == -ENOTSUPP) {
/* Ignore unsupported */
continue;
}
}
switch (cpu_dai->id) {
case RX_CODEC_DMA_RX_0:
case TX_CODEC_DMA_TX_3:
if (tx_ch_cnt || rx_ch_cnt) {
for_each_rtd_codec_dais(rtd, j, codec_dai) {
ret = snd_soc_dai_set_channel_map(codec_dai,
tx_ch_cnt, tx_ch,
rx_ch_cnt, rx_ch);
if (ret != 0 && ret != -ENOTSUPP)
goto err_set_stream;
}
}
}
return 0;
err_set_stream:
sdw_release_stream(sruntime);
return ret;
}
EXPORT_SYMBOL_GPL(qcom_snd_sdw_startup);
int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream,
bool *stream_prepared)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
struct sdw_stream_runtime *sruntime;
int ret;
if (!qcom_snd_is_sdw_dai(cpu_dai->id))
return 0;
sruntime = qcom_snd_sdw_get_stream(substream);
if (!sruntime)
return 0;
if (*stream_prepared)
return 0;
ret = sdw_prepare_stream(sruntime);
if (ret)
return ret;
/**
* NOTE: there is a strict hw requirement about the ordering of port
* enables and actual WSA881x PA enable. PA enable should only happen
* after soundwire ports are enabled if not DC on the line is
* accumulated resulting in Click/Pop Noise
* PA enable/mute are handled as part of codec DAPM and digital mute.
*/
ret = sdw_enable_stream(sruntime);
if (ret) {
sdw_deprepare_stream(sruntime);
return ret;
}
*stream_prepared = true;
return ret;
}
EXPORT_SYMBOL_GPL(qcom_snd_sdw_prepare);
struct sdw_stream_runtime *qcom_snd_sdw_get_stream(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_dai *codec_dai;
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
struct sdw_stream_runtime *sruntime;
Annotation
- Immediate include surface: `dt-bindings/sound/qcom,lpass.h`, `dt-bindings/sound/qcom,q6afe.h`, `linux/module.h`, `sound/soc.h`, `sdw.h`.
- Detected declarations: `function qcom_snd_is_sdw_dai`, `function qcom_snd_sdw_startup`, `function for_each_rtd_codec_dais`, `function qcom_snd_sdw_prepare`, `function for_each_rtd_codec_dais`, `function qcom_snd_sdw_shutdown`, `function qcom_snd_sdw_hw_free`, `export qcom_snd_sdw_startup`, `export qcom_snd_sdw_prepare`, `export qcom_snd_sdw_get_stream`.
- 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.