sound/soc/codecs/rt5677-spi.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rt5677-spi.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rt5677-spi.c- Extension
.c- Size
- 18457 bytes
- Lines
- 646
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/input.hlinux/spi/spi.hlinux/device.hlinux/init.hlinux/delay.hlinux/interrupt.hlinux/irq.hlinux/slab.hlinux/sched.hlinux/uaccess.hlinux/regulator/consumer.hlinux/pm_qos.hlinux/sysfs.hlinux/clk.hlinux/firmware.hlinux/acpi.hsound/soc.hrt5677.hrt5677-spi.h
Detected Declarations
struct rt5677_dspfunction rt5677_spi_pcm_openfunction rt5677_spi_pcm_closefunction rt5677_spi_hw_paramsfunction rt5677_spi_hw_freefunction rt5677_spi_preparefunction rt5677_spi_pcm_pointerfunction rt5677_spi_mic_write_offsetfunction rt5677_spi_copy_blockfunction rt5677_spi_copyfunction rt5677_spi_copy_workfunction rt5677_spi_pcm_newfunction rt5677_spi_pcm_probefunction rt5677_spi_select_cmdfunction rt5677_spi_reversefunction rt5677_spi_readfunction rt5677_spi_writefunction rt5677_spi_write_firmwarefunction rt5677_spi_hotword_detectedfunction rt5677_spi_probeexport rt5677_spi_readexport rt5677_spi_writeexport rt5677_spi_write_firmwareexport rt5677_spi_hotword_detected
Annotated Snippet
struct rt5677_dsp {
struct device *dev;
struct delayed_work copy_work;
struct mutex dma_lock;
struct snd_pcm_substream *substream;
size_t dma_offset; /* zero-based offset into runtime->dma_area */
size_t avail_bytes; /* number of new bytes since last period */
u32 mic_read_offset; /* zero-based offset into DSP's mic buffer */
bool new_hotword; /* a new hotword is fired */
};
static const struct snd_pcm_hardware rt5677_spi_pcm_hardware = {
.info = SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_INTERLEAVED,
.formats = SNDRV_PCM_FMTBIT_S16_LE,
.period_bytes_min = PAGE_SIZE,
.period_bytes_max = RT5677_BUF_BYTES_TOTAL / 8,
.periods_min = 8,
.periods_max = 8,
.channels_min = 1,
.channels_max = 1,
.buffer_bytes_max = RT5677_BUF_BYTES_TOTAL,
};
static struct snd_soc_dai_driver rt5677_spi_dai = {
/* The DAI name "rt5677-dsp-cpu-dai" is not used. The actual DAI name
* registered with ASoC is the name of the device "spi-RT5677AA:00",
* because we only have one DAI. See snd_soc_register_dais().
*/
.name = "rt5677-dsp-cpu-dai",
.id = 0,
.capture = {
.stream_name = "DSP Capture",
.channels_min = 1,
.channels_max = 1,
.rates = SNDRV_PCM_RATE_16000,
.formats = SNDRV_PCM_FMTBIT_S16_LE,
},
};
/* PCM for streaming audio from the DSP buffer */
static int rt5677_spi_pcm_open(
struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
snd_soc_set_runtime_hwparams(substream, &rt5677_spi_pcm_hardware);
return 0;
}
static int rt5677_spi_pcm_close(
struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_component *codec_component =
snd_soc_rtdcom_lookup(rtd, "rt5677");
struct rt5677_priv *rt5677 =
snd_soc_component_get_drvdata(codec_component);
struct rt5677_dsp *rt5677_dsp =
snd_soc_component_get_drvdata(component);
cancel_delayed_work_sync(&rt5677_dsp->copy_work);
rt5677->set_dsp_vad(codec_component, false);
return 0;
}
static int rt5677_spi_hw_params(
struct snd_soc_component *component,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params)
{
struct rt5677_dsp *rt5677_dsp =
snd_soc_component_get_drvdata(component);
mutex_lock(&rt5677_dsp->dma_lock);
rt5677_dsp->substream = substream;
mutex_unlock(&rt5677_dsp->dma_lock);
return 0;
}
static int rt5677_spi_hw_free(
struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
struct rt5677_dsp *rt5677_dsp =
snd_soc_component_get_drvdata(component);
mutex_lock(&rt5677_dsp->dma_lock);
Annotation
- Immediate include surface: `linux/module.h`, `linux/input.h`, `linux/spi/spi.h`, `linux/device.h`, `linux/init.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/irq.h`.
- Detected declarations: `struct rt5677_dsp`, `function rt5677_spi_pcm_open`, `function rt5677_spi_pcm_close`, `function rt5677_spi_hw_params`, `function rt5677_spi_hw_free`, `function rt5677_spi_prepare`, `function rt5677_spi_pcm_pointer`, `function rt5677_spi_mic_write_offset`, `function rt5677_spi_copy_block`, `function rt5677_spi_copy`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration 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.