sound/soc/img/img-spdif-in.c
Source file repositories/reference/linux-study-clean/sound/soc/img/img-spdif-in.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/img/img-spdif-in.c- Extension
.c- Size
- 21924 bytes
- Lines
- 849
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/init.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/reset.hsound/core.hsound/dmaengine_pcm.hsound/initval.hsound/pcm.hsound/pcm_params.hsound/soc.h
Detected Declarations
struct img_spdif_infunction img_spdif_in_runtime_suspendfunction img_spdif_in_runtime_resumefunction img_spdif_in_writelfunction img_spdif_in_readlfunction img_spdif_in_aclkgen_writelfunction img_spdif_in_check_max_ratefunction img_spdif_in_do_clkgen_calcfunction img_spdif_in_do_clkgen_singlefunction img_spdif_in_do_clkgen_multifunction img_spdif_in_iec958_infofunction img_spdif_in_get_status_maskfunction img_spdif_in_get_statusfunction img_spdif_in_info_multi_freqfunction img_spdif_in_get_multi_freqfunction img_spdif_in_set_multi_freqfunction img_spdif_in_info_lock_freqfunction img_spdif_in_get_lock_freqfunction img_spdif_in_info_trkfunction img_spdif_in_get_trkfunction img_spdif_in_set_trkfunction img_spdif_in_info_lockfunction img_spdif_in_get_lock_acquirefunction img_spdif_in_set_lock_acquirefunction img_spdif_in_get_lock_releasefunction img_spdif_in_set_lock_releasefunction img_spdif_in_triggerfunction img_spdif_in_hw_paramsfunction img_spdif_in_dai_probefunction img_spdif_in_probefunction img_spdif_in_dev_removefunction img_spdif_in_suspendfunction img_spdif_in_resume
Annotated Snippet
struct img_spdif_in {
spinlock_t lock;
void __iomem *base;
struct clk *clk_sys;
struct snd_dmaengine_dai_dma_data dma_data;
struct device *dev;
unsigned int trk;
bool multi_freq;
int lock_acquire;
int lock_release;
unsigned int single_freq;
unsigned int multi_freqs[IMG_SPDIF_IN_NUM_ACLKGEN];
bool active;
u32 suspend_clkgen;
u32 suspend_ctl;
/* Write-only registers */
unsigned int aclkgen_regs[IMG_SPDIF_IN_NUM_ACLKGEN];
};
static int img_spdif_in_runtime_suspend(struct device *dev)
{
struct img_spdif_in *spdif = dev_get_drvdata(dev);
clk_disable_unprepare(spdif->clk_sys);
return 0;
}
static int img_spdif_in_runtime_resume(struct device *dev)
{
struct img_spdif_in *spdif = dev_get_drvdata(dev);
int ret;
ret = clk_prepare_enable(spdif->clk_sys);
if (ret) {
dev_err(dev, "Unable to enable sys clock\n");
return ret;
}
return 0;
}
static inline void img_spdif_in_writel(struct img_spdif_in *spdif,
u32 val, u32 reg)
{
writel(val, spdif->base + reg);
}
static inline u32 img_spdif_in_readl(struct img_spdif_in *spdif, u32 reg)
{
return readl(spdif->base + reg);
}
static inline void img_spdif_in_aclkgen_writel(struct img_spdif_in *spdif,
u32 index)
{
img_spdif_in_writel(spdif, spdif->aclkgen_regs[index],
IMG_SPDIF_IN_ACLKGEN_START + (index * 0x4));
}
static int img_spdif_in_check_max_rate(struct img_spdif_in *spdif,
unsigned int sample_rate, unsigned long *actual_freq)
{
unsigned long min_freq, freq_t;
/* Clock rate must be at least 24x the bit rate */
min_freq = sample_rate * 2 * 32 * 24;
freq_t = clk_get_rate(spdif->clk_sys);
if (freq_t < min_freq)
return -EINVAL;
*actual_freq = freq_t;
return 0;
}
static int img_spdif_in_do_clkgen_calc(unsigned int rate, unsigned int *pnom,
unsigned int *phld, unsigned long clk_rate)
{
unsigned int ori, nom, hld;
/*
* Calculate oversampling ratio, nominal phase increment and hold
* increment for the given rate / frequency
*/
if (!rate)
Annotation
- Immediate include surface: `linux/clk.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `linux/reset.h`.
- Detected declarations: `struct img_spdif_in`, `function img_spdif_in_runtime_suspend`, `function img_spdif_in_runtime_resume`, `function img_spdif_in_writel`, `function img_spdif_in_readl`, `function img_spdif_in_aclkgen_writel`, `function img_spdif_in_check_max_rate`, `function img_spdif_in_do_clkgen_calc`, `function img_spdif_in_do_clkgen_single`, `function img_spdif_in_do_clkgen_multi`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.