sound/soc/sunxi/sun4i-codec.c
Source file repositories/reference/linux-study-clean/sound/soc/sunxi/sun4i-codec.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sunxi/sun4i-codec.c- Extension
.c- Size
- 80434 bytes
- Lines
- 2458
- 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/init.hlinux/kernel.hlinux/module.hlinux/platform_device.hlinux/delay.hlinux/slab.hlinux/clk.hlinux/regmap.hlinux/reset.hlinux/gpio/consumer.hsound/core.hsound/jack.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/tlv.hsound/initval.hsound/dmaengine_pcm.h
Detected Declarations
struct sun4i_codecstruct sun4i_codec_quirksfunction sun4i_codec_start_playbackfunction sun4i_codec_stop_playbackfunction sun4i_codec_start_capturefunction sun4i_codec_stop_capturefunction sun4i_codec_triggerfunction sun4i_codec_prepare_capturefunction of_device_is_compatiblefunction sun4i_codec_prepare_playbackfunction sun4i_codec_preparefunction sun4i_codec_get_mod_freqfunction sun4i_codec_get_hw_ratefunction sun4i_codec_hw_params_capturefunction sun4i_codec_hw_params_playbackfunction sun4i_codec_hw_paramsfunction sun4i_codec_startupfunction sun4i_codec_shutdownfunction sun4i_codec_dai_probefunction sun4i_codec_machine_initfunction sun4i_codec_spk_eventfunction sun4i_codec_probefunction sun4i_codec_remove
Annotated Snippet
struct sun4i_codec {
struct device *dev;
struct regmap *regmap;
struct clk *clk_apb;
struct clk *clk_module;
struct reset_control *rst;
struct gpio_desc *gpio_pa;
struct gpio_desc *gpio_hp;
/* ADC_FIFOC register is at different offset on different SoCs */
struct regmap_field *reg_adc_fifoc;
/* DAC_FIFOC register is at different offset on different SoCs */
struct regmap_field *reg_dac_fifoc;
struct snd_dmaengine_dai_dma_data capture_dma_data;
struct snd_dmaengine_dai_dma_data playback_dma_data;
};
static void sun4i_codec_start_playback(struct sun4i_codec *scodec)
{
/* Flush TX FIFO */
regmap_field_set_bits(scodec->reg_dac_fifoc,
BIT(SUN4I_CODEC_DAC_FIFOC_FIFO_FLUSH));
/* Enable DAC DRQ */
regmap_field_set_bits(scodec->reg_dac_fifoc,
BIT(SUN4I_CODEC_DAC_FIFOC_DAC_DRQ_EN));
}
static void sun4i_codec_stop_playback(struct sun4i_codec *scodec)
{
/* Disable DAC DRQ */
regmap_field_clear_bits(scodec->reg_dac_fifoc,
BIT(SUN4I_CODEC_DAC_FIFOC_DAC_DRQ_EN));
}
static void sun4i_codec_start_capture(struct sun4i_codec *scodec)
{
/* Enable ADC DRQ */
regmap_field_set_bits(scodec->reg_adc_fifoc,
BIT(SUN4I_CODEC_ADC_FIFOC_ADC_DRQ_EN));
}
static void sun4i_codec_stop_capture(struct sun4i_codec *scodec)
{
/* Disable ADC DRQ */
regmap_field_clear_bits(scodec->reg_adc_fifoc,
BIT(SUN4I_CODEC_ADC_FIFOC_ADC_DRQ_EN));
}
static int sun4i_codec_trigger(struct snd_pcm_substream *substream, int cmd,
struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card);
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
sun4i_codec_start_playback(scodec);
else
sun4i_codec_start_capture(scodec);
break;
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
sun4i_codec_stop_playback(scodec);
else
sun4i_codec_stop_capture(scodec);
break;
default:
return -EINVAL;
}
return 0;
}
static int sun4i_codec_prepare_capture(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card);
/* Flush RX FIFO */
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/platform_device.h`, `linux/delay.h`, `linux/slab.h`, `linux/clk.h`, `linux/regmap.h`.
- Detected declarations: `struct sun4i_codec`, `struct sun4i_codec_quirks`, `function sun4i_codec_start_playback`, `function sun4i_codec_stop_playback`, `function sun4i_codec_start_capture`, `function sun4i_codec_stop_capture`, `function sun4i_codec_trigger`, `function sun4i_codec_prepare_capture`, `function of_device_is_compatible`, `function sun4i_codec_prepare_playback`.
- 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.