sound/soc/mediatek/mt8365/mt8365-dai-pcm.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt8365/mt8365-dai-pcm.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/mt8365/mt8365-dai-pcm.c- Extension
.c- Size
- 7150 bytes
- Lines
- 294
- 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
linux/bitops.hlinux/regmap.hsound/pcm_params.hmt8365-afe-clk.hmt8365-afe-common.h
Detected Declarations
struct mt8365_pcm_intf_datafunction mt8365_dai_enable_pcm1function mt8365_dai_disable_pcm1function mt8365_dai_configure_pcm1function mt8365_dai_pcm1_startupfunction mt8365_dai_pcm1_shutdownfunction mt8365_dai_pcm1_preparefunction mt8365_dai_pcm1_set_fmtfunction init_pcmif_priv_datafunction mt8365_dai_pcm_register
Annotated Snippet
struct mt8365_pcm_intf_data {
bool slave_mode;
bool lrck_inv;
bool bck_inv;
unsigned int format;
};
/* DAI Drivers */
static void mt8365_dai_enable_pcm1(struct mtk_base_afe *afe)
{
regmap_update_bits(afe->regmap, PCM_INTF_CON1,
PCM_INTF_CON1_EN, PCM_INTF_CON1_EN);
}
static void mt8365_dai_disable_pcm1(struct mtk_base_afe *afe)
{
regmap_update_bits(afe->regmap, PCM_INTF_CON1,
PCM_INTF_CON1_EN, 0x0);
}
static int mt8365_dai_configure_pcm1(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
struct mt8365_afe_private *afe_priv = afe->platform_priv;
struct mt8365_pcm_intf_data *pcm_priv = afe_priv->dai_priv[MT8365_AFE_IO_PCM1];
bool slave_mode = pcm_priv->slave_mode;
bool lrck_inv = pcm_priv->lrck_inv;
bool bck_inv = pcm_priv->bck_inv;
unsigned int fmt = pcm_priv->format;
unsigned int bit_width = dai->symmetric_sample_bits;
unsigned int val = 0;
if (!slave_mode) {
val |= PCM_INTF_CON1_MASTER_MODE |
PCM_INTF_CON1_BYPASS_ASRC;
if (lrck_inv)
val |= PCM_INTF_CON1_SYNC_OUT_INV;
if (bck_inv)
val |= PCM_INTF_CON1_BCLK_OUT_INV;
} else {
val |= PCM_INTF_CON1_SLAVE_MODE;
if (lrck_inv)
val |= PCM_INTF_CON1_SYNC_IN_INV;
if (bck_inv)
val |= PCM_INTF_CON1_BCLK_IN_INV;
/* TODO: add asrc setting */
}
val |= FIELD_PREP(PCM_INTF_CON1_FORMAT_MASK, fmt);
if (fmt == MT8365_PCM_FORMAT_PCMA ||
fmt == MT8365_PCM_FORMAT_PCMB)
val |= PCM_INTF_CON1_SYNC_LEN(1);
else
val |= PCM_INTF_CON1_SYNC_LEN(bit_width);
switch (substream->runtime->rate) {
case 48000:
val |= PCM_INTF_CON1_FS_48K;
break;
case 32000:
val |= PCM_INTF_CON1_FS_32K;
break;
case 16000:
val |= PCM_INTF_CON1_FS_16K;
break;
case 8000:
val |= PCM_INTF_CON1_FS_8K;
break;
default:
return -EINVAL;
}
if (bit_width > 16)
val |= PCM_INTF_CON1_24BIT | PCM_INTF_CON1_64BCK;
else
val |= PCM_INTF_CON1_16BIT | PCM_INTF_CON1_32BCK;
val |= PCM_INTF_CON1_EXT_MODEM;
regmap_update_bits(afe->regmap, PCM_INTF_CON1,
PCM_INTF_CON1_CONFIG_MASK, val);
return 0;
}
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/regmap.h`, `sound/pcm_params.h`, `mt8365-afe-clk.h`, `mt8365-afe-common.h`.
- Detected declarations: `struct mt8365_pcm_intf_data`, `function mt8365_dai_enable_pcm1`, `function mt8365_dai_disable_pcm1`, `function mt8365_dai_configure_pcm1`, `function mt8365_dai_pcm1_startup`, `function mt8365_dai_pcm1_shutdown`, `function mt8365_dai_pcm1_prepare`, `function mt8365_dai_pcm1_set_fmt`, `function init_pcmif_priv_data`, `function mt8365_dai_pcm_register`.
- 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.