sound/soc/codecs/uda1342.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/uda1342.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/uda1342.c- Extension
.c- Size
- 9144 bytes
- Lines
- 348
- 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/i2c.hsound/core.hsound/pcm.hsound/pcm_params.hlinux/pm_runtime.hsound/soc.hsound/tlv.huda1342.h
Detected Declarations
struct uda1342_privfunction uda1342_mutefunction uda1342_startupfunction uda1342_shutdownfunction uda1342_hw_paramsfunction uda1342_set_dai_sysclkfunction masterfunction uda1342_set_dai_fmtfunction uda1342_i2c_probefunction uda1342_suspendfunction uda1342_resume
Annotated Snippet
struct uda1342_priv {
int sysclk;
int dai_fmt;
struct snd_pcm_substream *provider_substream;
struct snd_pcm_substream *consumer_substream;
struct regmap *regmap;
struct i2c_client *i2c;
};
static const struct reg_default uda1342_reg_defaults[] = {
{ 0x00, 0x1042 },
{ 0x01, 0x0000 },
{ 0x10, 0x0088 },
{ 0x11, 0x0000 },
{ 0x12, 0x0000 },
{ 0x20, 0x0080 },
{ 0x21, 0x0080 },
};
static int uda1342_mute(struct snd_soc_dai *dai, int mute, int direction)
{
struct snd_soc_component *component = dai->component;
struct uda1342_priv *uda1342 = snd_soc_component_get_drvdata(component);
unsigned int mask;
unsigned int val = 0;
/* Master mute */
mask = BIT(5);
if (mute)
val = mask;
return regmap_update_bits(uda1342->regmap, 0x10, mask, val);
}
static int uda1342_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct uda1342_priv *uda1342 = snd_soc_component_get_drvdata(component);
struct snd_pcm_runtime *provider_runtime;
if (uda1342->provider_substream) {
provider_runtime = uda1342->provider_substream->runtime;
snd_pcm_hw_constraint_single(substream->runtime,
SNDRV_PCM_HW_PARAM_RATE, provider_runtime->rate);
snd_pcm_hw_constraint_single(substream->runtime,
SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
provider_runtime->sample_bits);
uda1342->consumer_substream = substream;
} else {
uda1342->provider_substream = substream;
}
return 0;
}
static void uda1342_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct uda1342_priv *uda1342 = snd_soc_component_get_drvdata(component);
if (uda1342->provider_substream == substream)
uda1342->provider_substream = uda1342->consumer_substream;
uda1342->consumer_substream = NULL;
}
static int uda1342_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct uda1342_priv *uda1342 = snd_soc_component_get_drvdata(component);
struct device *dev = &uda1342->i2c->dev;
unsigned int hw_params = 0;
if (substream == uda1342->consumer_substream)
return 0;
/* set SYSCLK / fs ratio */
switch (uda1342->sysclk / params_rate(params)) {
case 512:
break;
case 384:
hw_params |= BIT(4);
break;
Annotation
- Immediate include surface: `linux/module.h`, `linux/i2c.h`, `sound/core.h`, `sound/pcm.h`, `sound/pcm_params.h`, `linux/pm_runtime.h`, `sound/soc.h`, `sound/tlv.h`.
- Detected declarations: `struct uda1342_priv`, `function uda1342_mute`, `function uda1342_startup`, `function uda1342_shutdown`, `function uda1342_hw_params`, `function uda1342_set_dai_sysclk`, `function master`, `function uda1342_set_dai_fmt`, `function uda1342_i2c_probe`, `function uda1342_suspend`.
- 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.