sound/soc/fsl/lpc3xxx-i2s.c
Source file repositories/reference/linux-study-clean/sound/soc/fsl/lpc3xxx-i2s.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/fsl/lpc3xxx-i2s.c- Extension
.c- Size
- 10561 bytes
- Lines
- 373
- 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/init.hlinux/module.hlinux/interrupt.hlinux/device.hlinux/delay.hlinux/clk.hlinux/io.hsound/core.hsound/pcm.hsound/pcm_params.hsound/dmaengine_pcm.hsound/initval.hsound/soc.hlpc3xxx-i2s.h
Detected Declarations
function __lpc3xxx_find_clkdivfunction lpc3xxx_i2s_startupfunction lpc3xxx_i2s_shutdownfunction lpc3xxx_i2s_set_dai_sysclkfunction lpc3xxx_i2s_set_dai_fmtfunction lpc3xxx_i2s_hw_paramsfunction lpc3xxx_i2s_triggerfunction lpc3xxx_i2s_dai_probefunction lpc32xx_i2s_probe
Annotated Snippet
if (abs(trate - i2srate) < diff) {
diff = abs(trate - i2srate);
*clkx = idxx;
*clky = idyy;
}
}
}
}
static int lpc3xxx_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai)
{
struct lpc3xxx_i2s_info *i2s_info_p = snd_soc_dai_get_drvdata(cpu_dai);
struct device *dev = i2s_info_p->dev;
u32 flag;
int ret = 0;
guard(mutex)(&i2s_info_p->lock);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
flag = I2S_PLAYBACK_FLAG;
else
flag = I2S_CAPTURE_FLAG;
if (flag & i2s_info_p->streams_in_use) {
dev_warn(dev, "I2S channel is busy\n");
ret = -EBUSY;
return ret;
}
if (i2s_info_p->streams_in_use == 0) {
ret = clk_prepare_enable(i2s_info_p->clk);
if (ret) {
dev_err(dev, "Can't enable clock, err=%d\n", ret);
return ret;
}
}
i2s_info_p->streams_in_use |= flag;
return 0;
}
static void lpc3xxx_i2s_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai)
{
struct lpc3xxx_i2s_info *i2s_info_p = snd_soc_dai_get_drvdata(cpu_dai);
struct regmap *regs = i2s_info_p->regs;
const u32 stop_bits = (LPC3XXX_I2S_RESET | LPC3XXX_I2S_STOP);
u32 flag;
guard(mutex)(&i2s_info_p->lock);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
flag = I2S_PLAYBACK_FLAG;
regmap_write(regs, LPC3XXX_REG_I2S_TX_RATE, 0);
regmap_update_bits(regs, LPC3XXX_REG_I2S_DAO, stop_bits, stop_bits);
} else {
flag = I2S_CAPTURE_FLAG;
regmap_write(regs, LPC3XXX_REG_I2S_RX_RATE, 0);
regmap_update_bits(regs, LPC3XXX_REG_I2S_DAI, stop_bits, stop_bits);
}
i2s_info_p->streams_in_use &= ~flag;
if (i2s_info_p->streams_in_use == 0)
clk_disable_unprepare(i2s_info_p->clk);
}
static int lpc3xxx_i2s_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
int clk_id, unsigned int freq, int dir)
{
struct lpc3xxx_i2s_info *i2s_info_p = snd_soc_dai_get_drvdata(cpu_dai);
/* Will use in HW params later */
i2s_info_p->freq = freq;
return 0;
}
static int lpc3xxx_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
{
struct lpc3xxx_i2s_info *i2s_info_p = snd_soc_dai_get_drvdata(cpu_dai);
struct device *dev = i2s_info_p->dev;
if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_I2S) {
dev_warn(dev, "unsupported bus format %d\n", fmt);
return -EINVAL;
}
if ((fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) != SND_SOC_DAIFMT_BP_FP) {
dev_warn(dev, "unsupported clock provider %d\n", fmt);
return -EINVAL;
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/interrupt.h`, `linux/device.h`, `linux/delay.h`, `linux/clk.h`, `linux/io.h`, `sound/core.h`.
- Detected declarations: `function __lpc3xxx_find_clkdiv`, `function lpc3xxx_i2s_startup`, `function lpc3xxx_i2s_shutdown`, `function lpc3xxx_i2s_set_dai_sysclk`, `function lpc3xxx_i2s_set_dai_fmt`, `function lpc3xxx_i2s_hw_params`, `function lpc3xxx_i2s_trigger`, `function lpc3xxx_i2s_dai_probe`, `function lpc32xx_i2s_probe`.
- 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.