sound/oss/dmasound/dmasound_core.c
Source file repositories/reference/linux-study-clean/sound/oss/dmasound/dmasound_core.c
File Facts
- System
- Linux kernel
- Corpus path
sound/oss/dmasound/dmasound_core.c- Extension
.c- Size
- 44928 bytes
- Lines
- 1562
- Domain
- Driver Families
- Bucket
- sound/oss
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/slab.hlinux/sound.hlinux/init.hlinux/soundcard.hlinux/poll.hlinux/mutex.hlinux/sched/signal.hlinux/uaccess.hdmasound.h
Detected Declarations
function sound_silencefunction sound_set_formatfunction sound_set_speedfunction sound_set_stereofunction sound_copy_translatefunction mixer_openfunction mixer_releasefunction mixer_ioctlfunction mixer_unlocked_ioctlfunction mixer_initfunction sq_allocate_buffersfunction sq_release_buffersfunction sq_setupfunction sizesfunction sq_playfunction sq_writefunction ioctlsfunction sq_pollfunction sq_init_waitqueuefunction sq_wake_upfunction sq_open2function sq_openfunction sq_reset_outputfunction sq_resetfunction sq_fsyncfunction sq_releasefunction shared_resources_are_minefunction queues_are_quiescentfunction set_queue_fragsfunction sq_ioctlfunction _ctx_xxxfunction sq_unlocked_ioctlfunction sq_initfunction openfunction state_openfunction state_releasefunction state_readfunction state_initfunction dmasound_initfunction dmasound_deinitfunction dmasound_setupexport dmasoundexport dmasound_initexport dmasound_deinitexport dmasound_write_sqexport dmasound_catchRadiusexport dmasound_ulaw2dma8export dmasound_alaw2dma8
Annotated Snippet
static const struct file_operations mixer_fops =
{
.owner = THIS_MODULE,
.unlocked_ioctl = mixer_unlocked_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = mixer_open,
.release = mixer_release,
};
static void mixer_init(void)
{
mixer_unit = register_sound_mixer(&mixer_fops, -1);
if (mixer_unit < 0)
return;
mixer.busy = 0;
dmasound.treble = 0;
dmasound.bass = 0;
if (dmasound.mach.mixer_init)
dmasound.mach.mixer_init();
}
/*
* Sound queue stuff, the heart of the driver
*/
struct sound_queue dmasound_write_sq;
static void sq_reset_output(void) ;
static int sq_allocate_buffers(struct sound_queue *sq, int num, int size)
{
int i;
if (sq->buffers)
return 0;
sq->numBufs = num;
sq->bufSize = size;
sq->buffers = kmalloc_array (num, sizeof(char *), GFP_KERNEL);
if (!sq->buffers)
return -ENOMEM;
for (i = 0; i < num; i++) {
sq->buffers[i] = dmasound.mach.dma_alloc(size, GFP_KERNEL);
if (!sq->buffers[i]) {
while (i--)
dmasound.mach.dma_free(sq->buffers[i], size);
kfree(sq->buffers);
sq->buffers = NULL;
return -ENOMEM;
}
}
return 0;
}
static void sq_release_buffers(struct sound_queue *sq)
{
int i;
if (sq->buffers) {
for (i = 0; i < sq->numBufs; i++)
dmasound.mach.dma_free(sq->buffers[i], sq->bufSize);
kfree(sq->buffers);
sq->buffers = NULL;
}
}
static int sq_setup(struct sound_queue *sq)
{
int (*setup_func)(void) = NULL;
int hard_frame ;
if (sq->locked) { /* are we already set? - and not changeable */
#ifdef DEBUG_DMASOUND
printk("dmasound_core: tried to sq_setup a locked queue\n") ;
#endif
return -EINVAL ;
}
sq->locked = 1 ; /* don't think we have a race prob. here _check_ */
/* make sure that the parameters are set up
This should have been done already...
*/
dmasound.mach.init();
/* OK. If the user has set fragment parameters explicitly, then we
should leave them alone... as long as they are valid.
Invalid user fragment params can occur if we allow the whole buffer
to be used when the user requests the fragments sizes (with no soft
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/sound.h`, `linux/init.h`, `linux/soundcard.h`, `linux/poll.h`, `linux/mutex.h`, `linux/sched/signal.h`.
- Detected declarations: `function sound_silence`, `function sound_set_format`, `function sound_set_speed`, `function sound_set_stereo`, `function sound_copy_translate`, `function mixer_open`, `function mixer_release`, `function mixer_ioctl`, `function mixer_unlocked_ioctl`, `function mixer_init`.
- Atlas domain: Driver Families / sound/oss.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.