sound/oss/dmasound/dmasound_paula.c
Source file repositories/reference/linux-study-clean/sound/oss/dmasound/dmasound_paula.c
File Facts
- System
- Linux kernel
- Corpus path
sound/oss/dmasound/dmasound_paula.c- Extension
.c- Size
- 19453 bytes
- Lines
- 746
- Domain
- Driver Families
- Bucket
- sound/oss
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/module.hlinux/mm.hlinux/init.hlinux/ioport.hlinux/soundcard.hlinux/interrupt.hlinux/platform_device.hlinux/uaccess.hasm/setup.hasm/amigahw.hasm/amigaints.hasm/machdep.hdmasound.h
Detected Declarations
function disable_heartbeatfunction enable_heartbeatfunction ami_ct_s8function StopDMAfunction AmiFreefunction AmiIrqInitfunction AmiIrqCleanUpfunction AmiSilencefunction AmiInitfunction AmiSetFormatfunction AmiSetVolumefunction AmiSetTreblefunction AmiPlayNextFramefunction AmiPlayfunction AmiInterruptfunction AmiMixerInitfunction AmiMixerIoctlfunction AmiWriteSqSetupfunction AmiStateInfofunction amiga_audio_probefunction amiga_audio_remove
Annotated Snippet
while (count > 0) {
if (get_user(*left++, userPtr++)
|| get_user(*right++, userPtr++))
return -EFAULT;
count--;
}
}
*frameUsed += used;
return used;
}
/*
* Copy and convert 8 bit data
*/
#define GENERATE_AMI_CT8(funcname, convsample) \
static ssize_t funcname(const u_char __user *userPtr, size_t userCount, \
u_char frame[], ssize_t *frameUsed, \
ssize_t frameLeft) \
{ \
ssize_t count, used; \
\
if (!dmasound.soft.stereo) { \
u_char *p = &frame[*frameUsed]; \
count = min_t(size_t, userCount, frameLeft) & ~1; \
used = count; \
while (count > 0) { \
u_char data; \
if (get_user(data, userPtr++)) \
return -EFAULT; \
*p++ = convsample(data); \
count--; \
} \
} else { \
u_char *left = &frame[*frameUsed>>1]; \
u_char *right = left+write_sq_block_size_half; \
count = min_t(size_t, userCount, frameLeft)>>1 & ~1; \
used = count*2; \
while (count > 0) { \
u_char data; \
if (get_user(data, userPtr++)) \
return -EFAULT; \
*left++ = convsample(data); \
if (get_user(data, userPtr++)) \
return -EFAULT; \
*right++ = convsample(data); \
count--; \
} \
} \
*frameUsed += used; \
return used; \
}
#define AMI_CT_ULAW(x) (dmasound_ulaw2dma8[(x)])
#define AMI_CT_ALAW(x) (dmasound_alaw2dma8[(x)])
#define AMI_CT_U8(x) ((x) ^ 0x80)
GENERATE_AMI_CT8(ami_ct_ulaw, AMI_CT_ULAW)
GENERATE_AMI_CT8(ami_ct_alaw, AMI_CT_ALAW)
GENERATE_AMI_CT8(ami_ct_u8, AMI_CT_U8)
/*
* Copy and convert 16 bit data
*/
#define GENERATE_AMI_CT_16(funcname, convsample) \
static ssize_t funcname(const u_char __user *userPtr, size_t userCount, \
u_char frame[], ssize_t *frameUsed, \
ssize_t frameLeft) \
{ \
const u_short __user *ptr = (const u_short __user *)userPtr; \
ssize_t count, used; \
u_short data; \
\
if (!dmasound.soft.stereo) { \
u_char *high = &frame[*frameUsed>>1]; \
u_char *low = high+write_sq_block_size_half; \
count = min_t(size_t, userCount, frameLeft)>>1 & ~1; \
used = count*2; \
while (count > 0) { \
if (get_user(data, ptr++)) \
return -EFAULT; \
data = convsample(data); \
*high++ = data>>8; \
*low++ = (data>>2) & 0x3f; \
count--; \
} \
} else { \
Annotation
- Immediate include surface: `linux/module.h`, `linux/mm.h`, `linux/init.h`, `linux/ioport.h`, `linux/soundcard.h`, `linux/interrupt.h`, `linux/platform_device.h`, `linux/uaccess.h`.
- Detected declarations: `function disable_heartbeat`, `function enable_heartbeat`, `function ami_ct_s8`, `function StopDMA`, `function AmiFree`, `function AmiIrqInit`, `function AmiIrqCleanUp`, `function AmiSilence`, `function AmiInit`, `function AmiSetFormat`.
- Atlas domain: Driver Families / sound/oss.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.