sound/soc/qcom/sdm845.c
Source file repositories/reference/linux-study-clean/sound/soc/qcom/sdm845.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/qcom/sdm845.c- Extension
.c- Size
- 16267 bytes
- Lines
- 594
- 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.
- 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,q6afe.hlinux/module.hlinux/platform_device.hsound/core.hsound/pcm.hsound/pcm_params.hsound/jack.hsound/soc.hlinux/soundwire/sdw.huapi/linux/input-event-codes.hcommon.hqdsp6/q6afe.hsdw.h../codecs/rt5663.h
Detected Declarations
struct sdm845_snd_datafunction sdm845_slim_snd_hw_paramsfunction for_each_rtd_codec_daisfunction sdm845_tdm_snd_hw_paramsfunction for_each_rtd_codec_daisfunction sdm845_snd_hw_paramsfunction sdm845_jack_freefunction sdm845_dai_initfunction for_each_rtd_codec_daisfunction sdm845_snd_startupfunction for_each_rtd_codec_daisfunction sdm845_snd_shutdownfunction sdm845_snd_preparefunction sdm845_snd_hw_freefunction sdm845_be_hw_params_fixupfunction sdm845_add_opsfunction for_each_card_prelinksfunction sdm845_snd_platform_probe
Annotated Snippet
struct sdm845_snd_data {
struct snd_soc_jack jack;
bool jack_setup;
bool slim_port_setup;
bool stream_prepared[AFE_PORT_MAX];
struct snd_soc_card *card;
uint32_t pri_mi2s_clk_count;
uint32_t sec_mi2s_clk_count;
uint32_t quat_tdm_clk_count;
};
static struct snd_soc_jack_pin sdm845_jack_pins[] = {
{
.pin = "Headphone Jack",
.mask = SND_JACK_HEADPHONE,
},
{
.pin = "Headset Mic",
.mask = SND_JACK_MICROPHONE,
},
};
static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
static int sdm845_slim_snd_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
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 snd_soc_dai *codec_dai;
u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
int ret = 0, i;
for_each_rtd_codec_dais(rtd, i, codec_dai) {
ret = snd_soc_dai_get_channel_map(codec_dai,
&tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
if (ret != 0 && ret != -ENOTSUPP) {
pr_err("failed to get codec chan map, err:%d\n", ret);
return ret;
} else if (ret == -ENOTSUPP) {
/* Ignore unsupported */
continue;
}
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL,
rx_ch_cnt, rx_ch);
else
ret = snd_soc_dai_set_channel_map(cpu_dai, tx_ch_cnt,
tx_ch, 0, NULL);
if (ret != 0 && ret != -ENOTSUPP) {
dev_err(rtd->dev, "failed to set cpu chan map, err:%d\n", ret);
return ret;
}
}
return 0;
}
static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
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 snd_soc_dai *codec_dai;
int ret = 0, j;
int channels, slot_width;
switch (params_format(params)) {
case SNDRV_PCM_FORMAT_S16_LE:
slot_width = 16;
break;
default:
dev_err(rtd->dev, "%s: invalid param format 0x%x\n",
__func__, params_format(params));
return -EINVAL;
}
channels = params_channels(params);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, 0x3,
8, slot_width);
if (ret < 0) {
dev_err(rtd->dev, "%s: failed to set tdm slot, err:%d\n",
__func__, ret);
goto end;
}
Annotation
- Immediate include surface: `dt-bindings/sound/qcom,q6afe.h`, `linux/module.h`, `linux/platform_device.h`, `sound/core.h`, `sound/pcm.h`, `sound/pcm_params.h`, `sound/jack.h`, `sound/soc.h`.
- Detected declarations: `struct sdm845_snd_data`, `function sdm845_slim_snd_hw_params`, `function for_each_rtd_codec_dais`, `function sdm845_tdm_snd_hw_params`, `function for_each_rtd_codec_dais`, `function sdm845_snd_hw_params`, `function sdm845_jack_free`, `function sdm845_dai_init`, `function for_each_rtd_codec_dais`, `function sdm845_snd_startup`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source 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.