sound/soc/rockchip/rockchip_i2s_tdm.c
Source file repositories/reference/linux-study-clean/sound/soc/rockchip/rockchip_i2s_tdm.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/rockchip/rockchip_i2s_tdm.c- Extension
.c- Size
- 37168 bytes
- Lines
- 1442
- 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/clk-provider.hlinux/delay.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/pm_runtime.hlinux/regmap.hlinux/reset.hlinux/spinlock.hsound/dmaengine_pcm.hsound/pcm_params.hrockchip_i2s_tdm.h
Detected Declarations
struct txrx_configstruct rk_i2s_soc_datastruct rk_i2s_tdm_devfunction to_ch_numfunction i2s_tdm_disable_unprepare_mclkfunction successfunction i2s_tdm_runtime_suspendfunction i2s_tdm_runtime_resumefunction rockchip_snd_xfer_sync_resetfunction rockchip_snd_resetfunction rockchip_snd_xfer_clearfunction rockchip_enable_tdefunction rockchip_disable_tdefunction rockchip_enable_rdefunction rockchip_disable_rdefunction rockchip_snd_txrxctrlfunction rockchip_snd_txctrlfunction rockchip_snd_rxctrlfunction rockchip_i2s_tdm_set_fmtfunction rockchip_i2s_tdm_xfer_pausefunction rockchip_i2s_tdm_xfer_resumefunction rockchip_i2s_io_multiplexfunction rockchip_i2s_trcm_modefunction rockchip_i2s_tdm_set_sysclkfunction rockchip_i2s_tdm_hw_paramsfunction rockchip_i2s_tdm_triggerfunction rockchip_i2s_tdm_dai_probefunction rockchip_dai_tdm_slotfunction rockchip_i2s_tdm_set_bclk_ratiofunction rockchip_i2s_tdm_wr_regfunction rockchip_i2s_tdm_rd_regfunction rockchip_i2s_tdm_volatile_regfunction rockchip_i2s_tdm_precious_regfunction common_soc_initfunction rockchip_i2s_tdm_init_daifunction of_property_for_each_stringfunction rockchip_i2s_tdm_path_checkfunction rockchip_i2s_tdm_tx_path_configfunction rockchip_i2s_tdm_rx_path_configfunction rockchip_i2s_tdm_path_configfunction rockchip_i2s_tdm_path_preparefunction rockchip_i2s_tdm_tx_path_preparefunction rockchip_i2s_tdm_rx_path_preparefunction rockchip_i2s_tdm_probefunction rockchip_i2s_tdm_removefunction rockchip_i2s_tdm_suspendfunction rockchip_i2s_tdm_resume
Annotated Snippet
struct txrx_config {
u32 addr;
u32 reg;
u32 txonly;
u32 rxonly;
};
struct rk_i2s_soc_data {
u32 softrst_offset;
u32 grf_reg_offset;
u32 grf_shift;
int config_count;
const struct txrx_config *configs;
int (*init)(struct device *dev, u32 addr);
};
struct rk_i2s_tdm_dev {
struct device *dev;
struct clk *hclk;
struct clk *mclk_tx;
struct clk *mclk_rx;
struct regmap *regmap;
struct regmap *grf;
struct snd_dmaengine_dai_dma_data capture_dma_data;
struct snd_dmaengine_dai_dma_data playback_dma_data;
struct reset_control *tx_reset;
struct reset_control *rx_reset;
const struct rk_i2s_soc_data *soc_data;
bool is_master_mode;
bool io_multiplex;
bool tdm_mode;
unsigned int frame_width;
unsigned int clk_trcm;
unsigned int i2s_sdis[CH_GRP_MAX];
unsigned int i2s_sdos[CH_GRP_MAX];
int refcount;
spinlock_t lock; /* xfer lock */
bool has_playback;
bool has_capture;
struct snd_soc_dai_driver *dai;
unsigned int mclk_rx_freq;
unsigned int mclk_tx_freq;
};
static int to_ch_num(unsigned int val)
{
switch (val) {
case I2S_CHN_4:
return 4;
case I2S_CHN_6:
return 6;
case I2S_CHN_8:
return 8;
default:
return 2;
}
}
static void i2s_tdm_disable_unprepare_mclk(struct rk_i2s_tdm_dev *i2s_tdm)
{
clk_disable_unprepare(i2s_tdm->mclk_tx);
clk_disable_unprepare(i2s_tdm->mclk_rx);
}
/**
* i2s_tdm_prepare_enable_mclk - prepare to enable all mclks, disable them on
* failure.
* @i2s_tdm: rk_i2s_tdm_dev struct
*
* This function attempts to enable all mclk clocks, but cleans up after
* itself on failure. Guarantees to balance its calls.
*
* Returns success (0) or negative errno.
*/
static int i2s_tdm_prepare_enable_mclk(struct rk_i2s_tdm_dev *i2s_tdm)
{
int ret = 0;
ret = clk_prepare_enable(i2s_tdm->mclk_tx);
if (ret)
goto err_mclk_tx;
ret = clk_prepare_enable(i2s_tdm->mclk_rx);
if (ret)
goto err_mclk_rx;
return 0;
err_mclk_rx:
clk_disable_unprepare(i2s_tdm->mclk_tx);
err_mclk_tx:
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clk-provider.h`, `linux/delay.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/pm_runtime.h`, `linux/regmap.h`.
- Detected declarations: `struct txrx_config`, `struct rk_i2s_soc_data`, `struct rk_i2s_tdm_dev`, `function to_ch_num`, `function i2s_tdm_disable_unprepare_mclk`, `function success`, `function i2s_tdm_runtime_suspend`, `function i2s_tdm_runtime_resume`, `function rockchip_snd_xfer_sync_reset`, `function rockchip_snd_reset`.
- 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.