sound/soc/atmel/atmel-classd.c
Source file repositories/reference/linux-study-clean/sound/soc/atmel/atmel-classd.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/atmel/atmel-classd.c- Extension
.c- Size
- 16860 bytes
- Lines
- 634
- 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/of.hlinux/clk.hlinux/module.hlinux/platform_device.hlinux/regmap.hlinux/bitfield.hlinux/string_choices.hsound/core.hsound/dmaengine_pcm.hsound/pcm_params.hsound/tlv.hatmel-classd.h
Detected Declarations
struct atmel_classd_pdatastruct atmel_classdfunction atmel_classd_dt_initfunction atmel_classd_cpu_dai_startupfunction atmel_classd_platform_configure_dmafunction atmel_classd_component_probefunction atmel_classd_component_resumefunction atmel_classd_cpu_dai_mute_streamfunction atmel_classd_cpu_dai_hw_paramsfunction atmel_classd_cpu_dai_shutdownfunction atmel_classd_cpu_dai_preparefunction atmel_classd_cpu_dai_triggerfunction atmel_classd_asoc_card_initfunction atmel_classd_probe
Annotated Snippet
struct atmel_classd_pdata {
bool non_overlap_enable;
int non_overlap_time;
int pwm_type;
const char *card_name;
};
struct atmel_classd {
dma_addr_t phy_base;
struct regmap *regmap;
struct clk *pclk;
struct clk *gclk;
struct device *dev;
int irq;
const struct atmel_classd_pdata *pdata;
};
#ifdef CONFIG_OF
static const struct of_device_id atmel_classd_of_match[] = {
{
.compatible = "atmel,sama5d2-classd",
}, {
/* sentinel */
}
};
MODULE_DEVICE_TABLE(of, atmel_classd_of_match);
static struct atmel_classd_pdata *atmel_classd_dt_init(struct device *dev)
{
struct device_node *np = dev->of_node;
struct atmel_classd_pdata *pdata;
const char *pwm_type_s;
int ret;
if (!np) {
dev_err(dev, "device node not found\n");
return ERR_PTR(-EINVAL);
}
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return ERR_PTR(-ENOMEM);
ret = of_property_read_string(np, "atmel,pwm-type", &pwm_type_s);
if ((ret == 0) && (strcmp(pwm_type_s, "diff") == 0))
pdata->pwm_type = CLASSD_MR_PWMTYP_DIFF;
else
pdata->pwm_type = CLASSD_MR_PWMTYP_SINGLE;
ret = of_property_read_u32(np,
"atmel,non-overlap-time", &pdata->non_overlap_time);
if (ret)
pdata->non_overlap_enable = false;
else
pdata->non_overlap_enable = true;
ret = of_property_read_string(np, "atmel,model", &pdata->card_name);
if (ret)
pdata->card_name = "CLASSD";
return pdata;
}
#else
static inline struct atmel_classd_pdata *
atmel_classd_dt_init(struct device *dev)
{
return ERR_PTR(-EINVAL);
}
#endif
#define ATMEL_CLASSD_RATES (SNDRV_PCM_RATE_8000 \
| SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 \
| SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 \
| SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 \
| SNDRV_PCM_RATE_96000)
static const struct snd_pcm_hardware atmel_classd_hw = {
.info = SNDRV_PCM_INFO_MMAP
| SNDRV_PCM_INFO_MMAP_VALID
| SNDRV_PCM_INFO_INTERLEAVED
| SNDRV_PCM_INFO_RESUME
| SNDRV_PCM_INFO_PAUSE,
.formats = (SNDRV_PCM_FMTBIT_S16_LE),
.rates = ATMEL_CLASSD_RATES,
.rate_min = 8000,
.rate_max = 96000,
.channels_min = 1,
.channels_max = 2,
.buffer_bytes_max = 64 * 1024,
.period_bytes_min = 256,
Annotation
- Immediate include surface: `linux/of.h`, `linux/clk.h`, `linux/module.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/bitfield.h`, `linux/string_choices.h`, `sound/core.h`.
- Detected declarations: `struct atmel_classd_pdata`, `struct atmel_classd`, `function atmel_classd_dt_init`, `function atmel_classd_cpu_dai_startup`, `function atmel_classd_platform_configure_dma`, `function atmel_classd_component_probe`, `function atmel_classd_component_resume`, `function atmel_classd_cpu_dai_mute_stream`, `function atmel_classd_cpu_dai_hw_params`, `function atmel_classd_cpu_dai_shutdown`.
- 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.