sound/soc/codecs/pcm3008.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/pcm3008.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/pcm3008.c- Extension
.c- Size
- 4367 bytes
- Lines
- 167
- 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/device.hlinux/gpio/consumer.hlinux/slab.hlinux/module.hsound/core.hsound/pcm.hsound/initval.hsound/soc.h
Detected Declarations
struct pcm3008function pcm3008_dac_evfunction pcm3008_adc_evfunction pcm3008_codec_probe
Annotated Snippet
struct pcm3008 {
struct gpio_desc *dem0_pin;
struct gpio_desc *dem1_pin;
struct gpio_desc *pdad_pin;
struct gpio_desc *pdda_pin;
};
static int pcm3008_dac_ev(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol,
int event)
{
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct pcm3008 *pcm = component->dev->platform_data;
gpiod_set_value_cansleep(pcm->pdda_pin,
SND_SOC_DAPM_EVENT_ON(event));
return 0;
}
static int pcm3008_adc_ev(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol,
int event)
{
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct pcm3008 *pcm = component->dev->platform_data;
gpiod_set_value_cansleep(pcm->pdad_pin,
SND_SOC_DAPM_EVENT_ON(event));
return 0;
}
static const struct snd_soc_dapm_widget pcm3008_dapm_widgets[] = {
SND_SOC_DAPM_INPUT("VINL"),
SND_SOC_DAPM_INPUT("VINR"),
SND_SOC_DAPM_DAC_E("DAC", NULL, SND_SOC_NOPM, 0, 0, pcm3008_dac_ev,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_ADC_E("ADC", NULL, SND_SOC_NOPM, 0, 0, pcm3008_adc_ev,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_OUTPUT("VOUTL"),
SND_SOC_DAPM_OUTPUT("VOUTR"),
};
static const struct snd_soc_dapm_route pcm3008_dapm_routes[] = {
{ "PCM3008 Capture", NULL, "ADC" },
{ "ADC", NULL, "VINL" },
{ "ADC", NULL, "VINR" },
{ "DAC", NULL, "PCM3008 Playback" },
{ "VOUTL", NULL, "DAC" },
{ "VOUTR", NULL, "DAC" },
};
#define PCM3008_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
SNDRV_PCM_RATE_48000)
static struct snd_soc_dai_driver pcm3008_dai = {
.name = "pcm3008-hifi",
.playback = {
.stream_name = "PCM3008 Playback",
.channels_min = 1,
.channels_max = 2,
.rates = PCM3008_RATES,
.formats = SNDRV_PCM_FMTBIT_S16_LE,
},
.capture = {
.stream_name = "PCM3008 Capture",
.channels_min = 1,
.channels_max = 2,
.rates = PCM3008_RATES,
.formats = SNDRV_PCM_FMTBIT_S16_LE,
},
};
static const struct snd_soc_component_driver soc_component_dev_pcm3008 = {
.dapm_widgets = pcm3008_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(pcm3008_dapm_widgets),
.dapm_routes = pcm3008_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(pcm3008_dapm_routes),
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
};
static int pcm3008_codec_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/device.h`, `linux/gpio/consumer.h`, `linux/slab.h`, `linux/module.h`, `sound/core.h`, `sound/pcm.h`.
- Detected declarations: `struct pcm3008`, `function pcm3008_dac_ev`, `function pcm3008_adc_ev`, `function pcm3008_codec_probe`.
- 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.