sound/atmel/ac97c.c
Source file repositories/reference/linux-study-clean/sound/atmel/ac97c.c
File Facts
- System
- Linux kernel
- Corpus path
sound/atmel/ac97c.c- Extension
.c- Size
- 22173 bytes
- Lines
- 866
- Domain
- Driver Families
- Bucket
- sound/atmel
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/delay.hlinux/bitmap.hlinux/device.hlinux/atmel_pdc.hlinux/gpio/consumer.hlinux/init.hlinux/interrupt.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/mutex.hlinux/string.hlinux/types.hlinux/io.hsound/core.hsound/initval.hsound/pcm.hsound/pcm_params.hsound/ac97_codec.hsound/memalloc.hac97c.h
Detected Declarations
struct atmel_ac97cfunction atmel_ac97c_playback_openfunction atmel_ac97c_capture_openfunction atmel_ac97c_playback_closefunction atmel_ac97c_capture_closefunction atmel_ac97c_playback_hw_paramsfunction atmel_ac97c_capture_hw_paramsfunction atmel_ac97c_playback_preparefunction atmel_ac97c_capture_preparefunction atmel_ac97c_playback_triggerfunction atmel_ac97c_capture_triggerfunction atmel_ac97c_playback_pointerfunction atmel_ac97c_capture_pointerfunction atmel_ac97c_interruptfunction atmel_ac97c_pcm_newfunction atmel_ac97c_mixer_newfunction atmel_ac97c_writefunction atmel_ac97c_readfunction atmel_ac97c_resetfunction atmel_ac97c_probefunction atmel_ac97c_suspendfunction atmel_ac97c_resumefunction atmel_ac97c_remove
Annotated Snippet
struct atmel_ac97c {
struct clk *pclk;
struct platform_device *pdev;
struct snd_pcm_substream *playback_substream;
struct snd_pcm_substream *capture_substream;
struct snd_card *card;
struct snd_pcm *pcm;
struct snd_ac97 *ac97;
struct snd_ac97_bus *ac97_bus;
u64 cur_format;
unsigned int cur_rate;
int playback_period, capture_period;
/* Serialize access to opened variable */
spinlock_t lock;
void __iomem *regs;
int irq;
int opened;
struct gpio_desc *reset_pin;
};
#define get_chip(card) ((struct atmel_ac97c *)(card)->private_data)
#define ac97c_writel(chip, reg, val) \
__raw_writel((val), (chip)->regs + AC97C_##reg)
#define ac97c_readl(chip, reg) \
__raw_readl((chip)->regs + AC97C_##reg)
static const struct snd_pcm_hardware atmel_ac97c_hw = {
.info = (SNDRV_PCM_INFO_MMAP
| SNDRV_PCM_INFO_MMAP_VALID
| SNDRV_PCM_INFO_INTERLEAVED
| SNDRV_PCM_INFO_BLOCK_TRANSFER
| SNDRV_PCM_INFO_JOINT_DUPLEX
| SNDRV_PCM_INFO_RESUME
| SNDRV_PCM_INFO_PAUSE),
.formats = (SNDRV_PCM_FMTBIT_S16_BE
| SNDRV_PCM_FMTBIT_S16_LE),
.rates = (SNDRV_PCM_RATE_CONTINUOUS),
.rate_min = 4000,
.rate_max = 48000,
.channels_min = 1,
.channels_max = 2,
.buffer_bytes_max = 2 * 2 * 64 * 2048,
.period_bytes_min = 4096,
.period_bytes_max = 4096,
.periods_min = 6,
.periods_max = 64,
};
static int atmel_ac97c_playback_open(struct snd_pcm_substream *substream)
{
struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
guard(mutex)(&opened_mutex);
chip->opened++;
runtime->hw = atmel_ac97c_hw;
if (chip->cur_rate) {
runtime->hw.rate_min = chip->cur_rate;
runtime->hw.rate_max = chip->cur_rate;
}
if (chip->cur_format)
runtime->hw.formats = pcm_format_to_bits(chip->cur_format);
chip->playback_substream = substream;
return 0;
}
static int atmel_ac97c_capture_open(struct snd_pcm_substream *substream)
{
struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
guard(mutex)(&opened_mutex);
chip->opened++;
runtime->hw = atmel_ac97c_hw;
if (chip->cur_rate) {
runtime->hw.rate_min = chip->cur_rate;
runtime->hw.rate_max = chip->cur_rate;
}
if (chip->cur_format)
runtime->hw.formats = pcm_format_to_bits(chip->cur_format);
chip->capture_substream = substream;
return 0;
}
static int atmel_ac97c_playback_close(struct snd_pcm_substream *substream)
{
struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/bitmap.h`, `linux/device.h`, `linux/atmel_pdc.h`, `linux/gpio/consumer.h`, `linux/init.h`, `linux/interrupt.h`.
- Detected declarations: `struct atmel_ac97c`, `function atmel_ac97c_playback_open`, `function atmel_ac97c_capture_open`, `function atmel_ac97c_playback_close`, `function atmel_ac97c_capture_close`, `function atmel_ac97c_playback_hw_params`, `function atmel_ac97c_capture_hw_params`, `function atmel_ac97c_playback_prepare`, `function atmel_ac97c_capture_prepare`, `function atmel_ac97c_playback_trigger`.
- Atlas domain: Driver Families / sound/atmel.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.