sound/soc/spear/spdif_out.c
Source file repositories/reference/linux-study-clean/sound/soc/spear/spdif_out.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/spear/spdif_out.c- Extension
.c- Size
- 8895 bytes
- Lines
- 365
- 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/clk.hlinux/delay.hlinux/device.hlinux/kernel.hlinux/init.hlinux/io.hlinux/ioport.hlinux/module.hlinux/platform_device.hsound/dmaengine_pcm.hsound/soc.hsound/spear_dma.hsound/spear_spdif.hspdif_out_regs.hspear_pcm.h
Detected Declarations
struct spdif_out_paramsstruct spdif_out_devfunction spdif_out_configurefunction spdif_out_startupfunction spdif_out_shutdownfunction spdif_out_clockfunction spdif_out_hw_paramsfunction spdif_out_triggerfunction spdif_mutefunction spdif_mute_getfunction spdif_mute_putfunction spdif_soc_dai_probefunction spdif_out_probefunction spdif_out_suspendfunction spdif_out_resume
Annotated Snippet
struct spdif_out_params {
u32 rate;
u32 core_freq;
u32 mute;
};
struct spdif_out_dev {
struct clk *clk;
struct spear_dma_data dma_params;
struct spdif_out_params saved_params;
u32 running;
void __iomem *io_base;
struct snd_dmaengine_dai_dma_data dma_params_tx;
struct snd_dmaengine_pcm_config config;
};
static void spdif_out_configure(struct spdif_out_dev *host)
{
writel(SPDIF_OUT_RESET, host->io_base + SPDIF_OUT_SOFT_RST);
mdelay(1);
writel(readl(host->io_base + SPDIF_OUT_SOFT_RST) & ~SPDIF_OUT_RESET,
host->io_base + SPDIF_OUT_SOFT_RST);
writel(SPDIF_OUT_FDMA_TRIG_16 | SPDIF_OUT_MEMFMT_16_16 |
SPDIF_OUT_VALID_HW | SPDIF_OUT_USER_HW |
SPDIF_OUT_CHNLSTA_HW | SPDIF_OUT_PARITY_HW,
host->io_base + SPDIF_OUT_CFG);
writel(0x7F, host->io_base + SPDIF_OUT_INT_STA_CLR);
writel(0x7F, host->io_base + SPDIF_OUT_INT_EN_CLR);
}
static int spdif_out_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai)
{
struct spdif_out_dev *host = snd_soc_dai_get_drvdata(cpu_dai);
int ret;
if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
return -EINVAL;
ret = clk_enable(host->clk);
if (ret)
return ret;
host->running = true;
spdif_out_configure(host);
return 0;
}
static void spdif_out_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct spdif_out_dev *host = snd_soc_dai_get_drvdata(dai);
if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
return;
clk_disable(host->clk);
host->running = false;
}
static void spdif_out_clock(struct spdif_out_dev *host, u32 core_freq,
u32 rate)
{
u32 divider, ctrl;
clk_set_rate(host->clk, core_freq);
divider = DIV_ROUND_CLOSEST(clk_get_rate(host->clk), (rate * 128));
ctrl = readl(host->io_base + SPDIF_OUT_CTRL);
ctrl &= ~SPDIF_DIVIDER_MASK;
ctrl |= (divider << SPDIF_DIVIDER_SHIFT) & SPDIF_DIVIDER_MASK;
writel(ctrl, host->io_base + SPDIF_OUT_CTRL);
}
static int spdif_out_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct spdif_out_dev *host = snd_soc_dai_get_drvdata(dai);
u32 rate, core_freq;
if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
return -EINVAL;
rate = params_rate(params);
switch (rate) {
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/device.h`, `linux/kernel.h`, `linux/init.h`, `linux/io.h`, `linux/ioport.h`, `linux/module.h`.
- Detected declarations: `struct spdif_out_params`, `struct spdif_out_dev`, `function spdif_out_configure`, `function spdif_out_startup`, `function spdif_out_shutdown`, `function spdif_out_clock`, `function spdif_out_hw_params`, `function spdif_out_trigger`, `function spdif_mute`, `function spdif_mute_get`.
- 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.