sound/soc/soc-dai.c
Source file repositories/reference/linux-study-clean/sound/soc/soc-dai.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/soc-dai.c- Extension
.c- Size
- 26487 bytes
- Lines
- 992
- 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
sound/soc.hsound/soc-dai.hsound/soc-link.h
Detected Declarations
function _soc_dai_retfunction masterfunction snd_soc_dai_set_clkdivfunction snd_soc_dai_set_pllfunction snd_soc_dai_set_bclk_ratiofunction BCLKfunction soc_dai_fmt_match_cntfunction soc_dai_auto_select_formatfunction soc_dai_convert_possiblefmt_to_daifmtfunction snd_soc_dai_auto_select_formatfunction snd_soc_dai_set_fmtfunction snd_soc_xlate_tdm_slot_maskfunction snd_soc_dai_set_tdm_slotfunction snd_soc_dai_set_tdm_idlefunction snd_soc_dai_set_channel_mapfunction snd_soc_dai_get_channel_mapfunction snd_soc_dai_set_tristatefunction snd_soc_dai_preparefunction snd_soc_dai_mute_is_ctrled_at_triggerfunction snd_soc_dai_digital_mutefunction snd_soc_dai_hw_paramsfunction snd_soc_dai_hw_freefunction snd_soc_dai_startupfunction snd_soc_dai_shutdownfunction snd_soc_dai_compress_newfunction snd_soc_dai_stream_validfunction snd_soc_dai_actionfunction snd_soc_dai_activefunction snd_soc_pcm_dai_probefunction for_each_rtd_daisfunction snd_soc_pcm_dai_removefunction for_each_rtd_daisfunction snd_soc_pcm_dai_newfunction for_each_rtd_daisfunction snd_soc_pcm_dai_preparefunction for_each_rtd_daisfunction soc_dai_triggerfunction snd_soc_pcm_dai_triggerfunction for_each_rtd_daisfunction snd_soc_pcm_dai_delayfunction snd_soc_dai_compr_startupfunction snd_soc_dai_compr_shutdownfunction snd_soc_dai_compr_triggerfunction snd_soc_dai_compr_set_paramsfunction snd_soc_dai_compr_get_paramsfunction snd_soc_dai_compr_ackfunction snd_soc_dai_compr_pointerfunction snd_soc_dai_compr_set_metadata
Annotated Snippet
if (idx + 1 >= max_idx) {
int cnt1 = soc_dai_fmt_match_cnt(*best_fmt);
int cnt2 = soc_dai_fmt_match_cnt(available_fmt);
if (cnt1 < cnt2)
*best_fmt = available_fmt;
}
/* parse with next DAI */
else {
soc_dai_auto_select_format(available_fmt, rtd, idx + 1, best_fmt);
}
}
}
static unsigned int soc_dai_convert_possiblefmt_to_daifmt(u64 possible_fmt, unsigned int configured_fmt)
{
unsigned int fmt = 0;
unsigned int mask = 0;
/*
* convert POSSIBLE_DAIFMT to DAIFMT
*
* Some basic/default settings on each is defined as 0.
* see
* SND_SOC_DAIFMT_NB_NF
* SND_SOC_DAIFMT_GATED
*
* SND_SOC_DAIFMT_xxx_MASK can't notice it if Sound Card specify
* these value, and will be overwrite to auto selected value.
*
* To avoid such issue, loop from 63 to 0 here.
* Small number of SND_SOC_POSSIBLE_xxx will be Hi priority.
* Basic/Default settings of each part and above are defined
* as Hi priority (= small number) of SND_SOC_POSSIBLE_xxx.
*/
for (int i = 63; i >= 0; i--) {
u64 pos = 1ULL << i;
switch (possible_fmt & pos) {
/*
* for format
*/
case SND_SOC_POSSIBLE_DAIFMT_I2S:
case SND_SOC_POSSIBLE_DAIFMT_RIGHT_J:
case SND_SOC_POSSIBLE_DAIFMT_LEFT_J:
case SND_SOC_POSSIBLE_DAIFMT_DSP_A:
case SND_SOC_POSSIBLE_DAIFMT_DSP_B:
case SND_SOC_POSSIBLE_DAIFMT_AC97:
case SND_SOC_POSSIBLE_DAIFMT_PDM:
fmt = (fmt & ~SND_SOC_DAIFMT_FORMAT_MASK) | i;
break;
/*
* for clock
*/
case SND_SOC_POSSIBLE_DAIFMT_CONT:
fmt = (fmt & ~SND_SOC_DAIFMT_CLOCK_MASK) | SND_SOC_DAIFMT_CONT;
break;
case SND_SOC_POSSIBLE_DAIFMT_GATED:
fmt = (fmt & ~SND_SOC_DAIFMT_CLOCK_MASK) | SND_SOC_DAIFMT_GATED;
break;
/*
* for clock invert
*/
case SND_SOC_POSSIBLE_DAIFMT_NB_NF:
fmt = (fmt & ~SND_SOC_DAIFMT_INV_MASK) | SND_SOC_DAIFMT_NB_NF;
break;
case SND_SOC_POSSIBLE_DAIFMT_NB_IF:
fmt = (fmt & ~SND_SOC_DAIFMT_INV_MASK) | SND_SOC_DAIFMT_NB_IF;
break;
case SND_SOC_POSSIBLE_DAIFMT_IB_NF:
fmt = (fmt & ~SND_SOC_DAIFMT_INV_MASK) | SND_SOC_DAIFMT_IB_NF;
break;
case SND_SOC_POSSIBLE_DAIFMT_IB_IF:
fmt = (fmt & ~SND_SOC_DAIFMT_INV_MASK) | SND_SOC_DAIFMT_IB_IF;
break;
}
}
/*
* Some driver might have very complex limitation.
* In such case, user want to auto-select non-limitation part,
* and want to manually specify complex part.
*
* Or for example, if both CPU and Codec can be clock provider,
* but because of its quality, user want to specify it manually.
*
* Ignore already configured format if exist
*/
if (!(configured_fmt & SND_SOC_DAIFMT_FORMAT_MASK))
mask |= SND_SOC_DAIFMT_FORMAT_MASK;
Annotation
- Immediate include surface: `sound/soc.h`, `sound/soc-dai.h`, `sound/soc-link.h`.
- Detected declarations: `function _soc_dai_ret`, `function master`, `function snd_soc_dai_set_clkdiv`, `function snd_soc_dai_set_pll`, `function snd_soc_dai_set_bclk_ratio`, `function BCLK`, `function soc_dai_fmt_match_cnt`, `function soc_dai_auto_select_format`, `function soc_dai_convert_possiblefmt_to_daifmt`, `function snd_soc_dai_auto_select_format`.
- 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.