sound/soc/rockchip/rockchip_i2s.c
Source file repositories/reference/linux-study-clean/sound/soc/rockchip/rockchip_i2s.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/rockchip/rockchip_i2s.c- Extension
.c- Size
- 20510 bytes
- Lines
- 866
- 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/module.hlinux/mfd/syscon.hlinux/delay.hlinux/of.hlinux/clk.hlinux/pinctrl/consumer.hlinux/pm_runtime.hlinux/regmap.hlinux/spinlock.hsound/pcm_params.hsound/dmaengine_pcm.hrockchip_i2s.h
Detected Declarations
struct rk_i2s_pinsstruct rk_i2s_devfunction i2s_pinctrl_select_bclk_onfunction i2s_pinctrl_select_bclk_offfunction i2s_runtime_suspendfunction i2s_runtime_resumefunction rockchip_snd_txctrlfunction scoped_guardfunction rockchip_snd_rxctrlfunction scoped_guardfunction rockchip_i2s_set_fmtfunction rockchip_i2s_hw_paramsfunction rockchip_i2s_triggerfunction rockchip_i2s_set_bclk_ratiofunction rockchip_i2s_set_sysclkfunction rockchip_i2s_dai_probefunction rockchip_i2s_wr_regfunction rockchip_i2s_rd_regfunction rockchip_i2s_volatile_regfunction rockchip_i2s_precious_regfunction rockchip_i2s_suspendfunction rockchip_i2s_init_daifunction of_property_for_each_stringfunction rockchip_i2s_probe
Annotated Snippet
struct rk_i2s_pins {
u32 reg_offset;
u32 shift;
};
struct rk_i2s_dev {
struct device *dev;
struct clk *hclk;
struct clk *mclk;
struct snd_dmaengine_dai_dma_data capture_dma_data;
struct snd_dmaengine_dai_dma_data playback_dma_data;
struct regmap *regmap;
struct regmap *grf;
bool has_capture;
bool has_playback;
/*
* Used to indicate the tx/rx status.
* I2S controller hopes to start the tx and rx together,
* also to stop them when they are both try to stop.
*/
bool tx_start;
bool rx_start;
bool is_master_mode;
const struct rk_i2s_pins *pins;
unsigned int bclk_ratio;
spinlock_t lock; /* tx/rx lock */
struct pinctrl *pinctrl;
struct pinctrl_state *bclk_on;
struct pinctrl_state *bclk_off;
};
static int i2s_pinctrl_select_bclk_on(struct rk_i2s_dev *i2s)
{
int ret = 0;
if (!IS_ERR(i2s->pinctrl) && !IS_ERR_OR_NULL(i2s->bclk_on))
ret = pinctrl_select_state(i2s->pinctrl, i2s->bclk_on);
if (ret)
dev_err(i2s->dev, "bclk enable failed %d\n", ret);
return ret;
}
static int i2s_pinctrl_select_bclk_off(struct rk_i2s_dev *i2s)
{
int ret = 0;
if (!IS_ERR(i2s->pinctrl) && !IS_ERR_OR_NULL(i2s->bclk_off))
ret = pinctrl_select_state(i2s->pinctrl, i2s->bclk_off);
if (ret)
dev_err(i2s->dev, "bclk disable failed %d\n", ret);
return ret;
}
static int i2s_runtime_suspend(struct device *dev)
{
struct rk_i2s_dev *i2s = dev_get_drvdata(dev);
regcache_cache_only(i2s->regmap, true);
clk_disable_unprepare(i2s->mclk);
return 0;
}
static int i2s_runtime_resume(struct device *dev)
{
struct rk_i2s_dev *i2s = dev_get_drvdata(dev);
int ret;
ret = clk_prepare_enable(i2s->mclk);
if (ret) {
dev_err(i2s->dev, "clock enable failed %d\n", ret);
return ret;
}
regcache_cache_only(i2s->regmap, false);
regcache_mark_dirty(i2s->regmap);
ret = regcache_sync(i2s->regmap);
if (ret)
clk_disable_unprepare(i2s->mclk);
Annotation
- Immediate include surface: `linux/module.h`, `linux/mfd/syscon.h`, `linux/delay.h`, `linux/of.h`, `linux/clk.h`, `linux/pinctrl/consumer.h`, `linux/pm_runtime.h`, `linux/regmap.h`.
- Detected declarations: `struct rk_i2s_pins`, `struct rk_i2s_dev`, `function i2s_pinctrl_select_bclk_on`, `function i2s_pinctrl_select_bclk_off`, `function i2s_runtime_suspend`, `function i2s_runtime_resume`, `function rockchip_snd_txctrl`, `function scoped_guard`, `function rockchip_snd_rxctrl`, `function scoped_guard`.
- 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.