sound/sh/sh_dac_audio.c
Source file repositories/reference/linux-study-clean/sound/sh/sh_dac_audio.c
File Facts
- System
- Linux kernel
- Corpus path
sound/sh/sh_dac_audio.c- Extension
.c- Size
- 9166 bytes
- Lines
- 391
- Domain
- Driver Families
- Bucket
- sound/sh
- 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/hrtimer.hlinux/interrupt.hlinux/io.hlinux/platform_device.hlinux/slab.hlinux/module.hsound/core.hsound/initval.hsound/pcm.hsound/sh_dac_audio.hasm/clock.hasm/hd64461.hmach/hp6xx.hcpu/dac.h
Detected Declarations
struct snd_sh_dacfunction dac_audio_start_timerfunction dac_audio_stop_timerfunction dac_audio_resetfunction dac_audio_set_ratefunction snd_sh_dac_pcm_openfunction snd_sh_dac_pcm_closefunction snd_sh_dac_pcm_preparefunction snd_sh_dac_pcm_triggerfunction snd_sh_dac_pcm_copyfunction snd_sh_dac_pcm_silencefunction snd_sh_dac_pcm_pointerfunction snd_sh_dac_pcmfunction snd_sh_dac_removefunction snd_sh_dac_freefunction snd_sh_dac_dev_freefunction sh_dac_audio_timerfunction snd_sh_dac_createfunction snd_sh_dac_probe
Annotated Snippet
struct snd_sh_dac {
struct snd_card *card;
struct snd_pcm_substream *substream;
struct hrtimer hrtimer;
ktime_t wakeups_per_second;
int rate;
int empty;
char *data_buffer, *buffer_begin, *buffer_end;
int processed; /* bytes proccesed, to compare with period_size */
int buffer_size;
struct dac_audio_pdata *pdata;
};
static void dac_audio_start_timer(struct snd_sh_dac *chip)
{
hrtimer_start(&chip->hrtimer, chip->wakeups_per_second,
HRTIMER_MODE_REL);
}
static void dac_audio_stop_timer(struct snd_sh_dac *chip)
{
hrtimer_cancel(&chip->hrtimer);
}
static void dac_audio_reset(struct snd_sh_dac *chip)
{
dac_audio_stop_timer(chip);
chip->buffer_begin = chip->buffer_end = chip->data_buffer;
chip->processed = 0;
chip->empty = 1;
}
static void dac_audio_set_rate(struct snd_sh_dac *chip)
{
chip->wakeups_per_second = 1000000000 / chip->rate;
}
/* PCM INTERFACE */
static const struct snd_pcm_hardware snd_sh_dac_pcm_hw = {
.info = (SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_HALF_DUPLEX),
.formats = SNDRV_PCM_FMTBIT_U8,
.rates = SNDRV_PCM_RATE_8000,
.rate_min = 8000,
.rate_max = 8000,
.channels_min = 1,
.channels_max = 1,
.buffer_bytes_max = (48*1024),
.period_bytes_min = 1,
.period_bytes_max = (48*1024),
.periods_min = 1,
.periods_max = 1024,
};
static int snd_sh_dac_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
runtime->hw = snd_sh_dac_pcm_hw;
chip->substream = substream;
chip->buffer_begin = chip->buffer_end = chip->data_buffer;
chip->processed = 0;
chip->empty = 1;
chip->pdata->start(chip->pdata);
return 0;
}
static int snd_sh_dac_pcm_close(struct snd_pcm_substream *substream)
{
struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
chip->substream = NULL;
dac_audio_stop_timer(chip);
chip->pdata->stop(chip->pdata);
return 0;
}
static int snd_sh_dac_pcm_prepare(struct snd_pcm_substream *substream)
Annotation
- Immediate include surface: `linux/hrtimer.h`, `linux/interrupt.h`, `linux/io.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/module.h`, `sound/core.h`, `sound/initval.h`.
- Detected declarations: `struct snd_sh_dac`, `function dac_audio_start_timer`, `function dac_audio_stop_timer`, `function dac_audio_reset`, `function dac_audio_set_rate`, `function snd_sh_dac_pcm_open`, `function snd_sh_dac_pcm_close`, `function snd_sh_dac_pcm_prepare`, `function snd_sh_dac_pcm_trigger`, `function snd_sh_dac_pcm_copy`.
- Atlas domain: Driver Families / sound/sh.
- 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.