sound/soc/codecs/mc13783.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/mc13783.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/mc13783.c- Extension
.c- Size
- 22873 bytes
- Lines
- 790
- 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/module.hlinux/device.hlinux/of.hlinux/mfd/mc13xxx.hlinux/slab.hsound/core.hsound/control.hsound/pcm.hsound/soc.hsound/initval.hsound/soc-dapm.hlinux/regmap.hmc13783.h
Detected Declarations
struct mc13783_privfunction mc13783_pcm_hw_params_dacfunction mc13783_pcm_hw_params_codecfunction mc13783_pcm_hw_params_syncfunction mc13783_set_fmtfunction mc13783_set_fmt_asyncfunction mc13783_set_fmt_syncfunction mc13783_set_sysclkfunction mc13783_set_sysclk_dacfunction mc13783_set_sysclk_codecfunction mc13783_set_sysclk_syncfunction mc13783_set_tdm_slot_dacfunction mc13783_set_tdm_slot_codecfunction mc13783_set_tdm_slot_syncfunction mc13783_probefunction mc13783_removefunction mc13783_codec_probe
Annotated Snippet
struct mc13783_priv {
struct mc13xxx *mc13xxx;
struct regmap *regmap;
enum mc13783_ssi_port adc_ssi_port;
enum mc13783_ssi_port dac_ssi_port;
};
/* Mapping between sample rates and register value */
static unsigned int mc13783_rates[] = {
8000, 11025, 12000, 16000,
22050, 24000, 32000, 44100,
48000, 64000, 96000
};
static int mc13783_pcm_hw_params_dac(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
unsigned int rate = params_rate(params);
int i;
for (i = 0; i < ARRAY_SIZE(mc13783_rates); i++) {
if (rate == mc13783_rates[i]) {
snd_soc_component_update_bits(component, MC13783_AUDIO_DAC,
0xf << 17, i << 17);
return 0;
}
}
return -EINVAL;
}
static int mc13783_pcm_hw_params_codec(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
unsigned int rate = params_rate(params);
unsigned int val;
switch (rate) {
case 8000:
val = 0;
break;
case 16000:
val = AUDIO_CODEC_CDCFS8K16K;
break;
default:
return -EINVAL;
}
snd_soc_component_update_bits(component, MC13783_AUDIO_CODEC, AUDIO_CODEC_CDCFS8K16K,
val);
return 0;
}
static int mc13783_pcm_hw_params_sync(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
return mc13783_pcm_hw_params_dac(substream, params, dai);
else
return mc13783_pcm_hw_params_codec(substream, params, dai);
}
static int mc13783_set_fmt(struct snd_soc_dai *dai, unsigned int fmt,
unsigned int reg)
{
struct snd_soc_component *component = dai->component;
unsigned int val = 0;
unsigned int mask = AUDIO_CFS(3) | AUDIO_BCL_INV | AUDIO_CFS_INV |
AUDIO_CSM | AUDIO_C_CLK_EN | AUDIO_C_RESET;
/* DAI mode */
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
val |= AUDIO_CFS(2);
break;
case SND_SOC_DAIFMT_DSP_A:
val |= AUDIO_CFS(1);
break;
default:
return -EINVAL;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/device.h`, `linux/of.h`, `linux/mfd/mc13xxx.h`, `linux/slab.h`, `sound/core.h`, `sound/control.h`, `sound/pcm.h`.
- Detected declarations: `struct mc13783_priv`, `function mc13783_pcm_hw_params_dac`, `function mc13783_pcm_hw_params_codec`, `function mc13783_pcm_hw_params_sync`, `function mc13783_set_fmt`, `function mc13783_set_fmt_async`, `function mc13783_set_fmt_sync`, `function mc13783_set_sysclk`, `function mc13783_set_sysclk_dac`, `function mc13783_set_sysclk_codec`.
- 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.