sound/soc/jz4740/jz4740-i2s.c
Source file repositories/reference/linux-study-clean/sound/soc/jz4740/jz4740-i2s.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/jz4740/jz4740-i2s.c- Extension
.c- Size
- 16786 bytes
- Lines
- 604
- 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/bitfield.hlinux/clk.hlinux/delay.hlinux/dma-mapping.hlinux/init.hlinux/io.hlinux/kernel.hlinux/module.hlinux/mod_devicetable.hlinux/platform_device.hlinux/regmap.hlinux/slab.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/initval.hsound/dmaengine_pcm.h
Detected Declarations
struct i2s_soc_infostruct jz4740_i2sfunction jz4740_i2s_startupfunction jz4740_i2s_shutdownfunction jz4740_i2s_triggerfunction jz4740_i2s_set_fmtfunction jz4740_i2s_get_i2sdivfunction jz4740_i2s_hw_paramsfunction jz4740_i2s_dai_probefunction jz4740_i2s_suspendfunction jz4740_i2s_resumefunction jz4740_i2s_probefunction jz4740_i2s_removefunction jz4740_i2s_init_regmap_fieldsfunction jz4740_i2s_dev_probe
Annotated Snippet
struct i2s_soc_info {
struct snd_soc_dai_driver *dai;
struct reg_field field_rx_fifo_thresh;
struct reg_field field_tx_fifo_thresh;
struct reg_field field_i2sdiv_capture;
struct reg_field field_i2sdiv_playback;
bool shared_fifo_flush;
};
struct jz4740_i2s {
struct regmap *regmap;
struct regmap_field *field_rx_fifo_thresh;
struct regmap_field *field_tx_fifo_thresh;
struct regmap_field *field_i2sdiv_capture;
struct regmap_field *field_i2sdiv_playback;
struct clk *clk_aic;
struct clk *clk_i2s;
struct snd_dmaengine_dai_dma_data playback_dma_data;
struct snd_dmaengine_dai_dma_data capture_dma_data;
const struct i2s_soc_info *soc_info;
};
static int jz4740_i2s_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
int ret;
/*
* When we can flush FIFOs independently, only flush the FIFO
* that is starting up. We can do this when the DAI is active
* because it does not disturb other active substreams.
*/
if (!i2s->soc_info->shared_fifo_flush) {
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
regmap_set_bits(i2s->regmap, JZ_REG_AIC_CTRL, JZ_AIC_CTRL_TFLUSH);
else
regmap_set_bits(i2s->regmap, JZ_REG_AIC_CTRL, JZ_AIC_CTRL_RFLUSH);
}
if (snd_soc_dai_active(dai))
return 0;
/*
* When there is a shared flush bit for both FIFOs, the TFLUSH
* bit flushes both FIFOs. Flushing while the DAI is active would
* cause FIFO underruns in other active substreams so we have to
* guard this behind the snd_soc_dai_active() check.
*/
if (i2s->soc_info->shared_fifo_flush)
regmap_set_bits(i2s->regmap, JZ_REG_AIC_CTRL, JZ_AIC_CTRL_TFLUSH);
ret = clk_prepare_enable(i2s->clk_i2s);
if (ret)
return ret;
regmap_set_bits(i2s->regmap, JZ_REG_AIC_CONF, JZ_AIC_CONF_ENABLE);
return 0;
}
static void jz4740_i2s_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
if (snd_soc_dai_active(dai))
return;
regmap_clear_bits(i2s->regmap, JZ_REG_AIC_CONF, JZ_AIC_CONF_ENABLE);
clk_disable_unprepare(i2s->clk_i2s);
}
static int jz4740_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
struct snd_soc_dai *dai)
{
struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
uint32_t mask;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
mask = JZ_AIC_CTRL_ENABLE_PLAYBACK | JZ_AIC_CTRL_ENABLE_TX_DMA;
else
mask = JZ_AIC_CTRL_ENABLE_CAPTURE | JZ_AIC_CTRL_ENABLE_RX_DMA;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/init.h`, `linux/io.h`, `linux/kernel.h`, `linux/module.h`.
- Detected declarations: `struct i2s_soc_info`, `struct jz4740_i2s`, `function jz4740_i2s_startup`, `function jz4740_i2s_shutdown`, `function jz4740_i2s_trigger`, `function jz4740_i2s_set_fmt`, `function jz4740_i2s_get_i2sdiv`, `function jz4740_i2s_hw_params`, `function jz4740_i2s_dai_probe`, `function jz4740_i2s_suspend`.
- 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.