sound/core/oss/mixer_oss.c
Source file repositories/reference/linux-study-clean/sound/core/oss/mixer_oss.c
File Facts
- System
- Linux kernel
- Corpus path
sound/core/oss/mixer_oss.c- Extension
.c- Size
- 40357 bytes
- Lines
- 1401
- Domain
- Driver Families
- Bucket
- sound/core
- 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.
- 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/init.hlinux/slab.hlinux/time.hlinux/string.hlinux/module.hlinux/compat.hsound/core.hsound/minors.hsound/control.hsound/info.hsound/mixer_oss.hlinux/soundcard.h
Detected Declarations
struct slotstruct snd_mixer_oss_assign_tablefunction snd_mixer_oss_openfunction snd_mixer_oss_releasefunction snd_mixer_oss_infofunction snd_mixer_oss_info_obsoletefunction snd_mixer_oss_capsfunction snd_mixer_oss_devmaskfunction snd_mixer_oss_stereodevsfunction snd_mixer_oss_recmaskfunction snd_mixer_oss_get_recsrcfunction snd_mixer_oss_set_recsrcfunction snd_mixer_oss_get_volumefunction snd_mixer_oss_set_volumefunction snd_mixer_oss_ioctl1function snd_mixer_oss_ioctlfunction snd_mixer_oss_ioctl_cardfunction snd_mixer_oss_ioctl_compatfunction snd_mixer_oss_convfunction snd_mixer_oss_conv1function snd_mixer_oss_conv2function snd_mixer_oss_recsrce_setfunction snd_mixer_oss_recsrce_getfunction snd_mixer_oss_get_volume1_volfunction snd_mixer_oss_get_volume1_swfunction snd_mixer_oss_get_volume1function snd_mixer_oss_put_volume1_volfunction snd_mixer_oss_put_volume1_swfunction snd_mixer_oss_put_volume1function snd_mixer_oss_get_recsrc1_swfunction snd_mixer_oss_get_recsrc1_routefunction snd_mixer_oss_put_recsrc1_swfunction snd_mixer_oss_put_recsrc1_routefunction snd_mixer_oss_get_recsrc2function snd_mixer_oss_put_recsrc2function snd_mixer_oss_build_testfunction snd_mixer_oss_slot_freefunction mixer_slot_clearfunction snd_mixer_oss_build_test_allfunction allocatedfunction snd_mixer_oss_proc_readfunction snd_mixer_oss_proc_writefunction scoped_guardfunction snd_mixer_oss_proc_initfunction snd_mixer_oss_proc_donefunction snd_mixer_oss_buildfunction snd_mixer_oss_free1function snd_mixer_oss_notify_handler
Annotated Snippet
static const struct file_operations snd_mixer_oss_f_ops =
{
.owner = THIS_MODULE,
.open = snd_mixer_oss_open,
.release = snd_mixer_oss_release,
.unlocked_ioctl = snd_mixer_oss_ioctl,
.compat_ioctl = snd_mixer_oss_ioctl_compat,
};
/*
* utilities
*/
static long snd_mixer_oss_conv(long val, long omin, long omax, long nmin, long nmax)
{
long orange = omax - omin, nrange = nmax - nmin;
if (orange == 0)
return 0;
return DIV_ROUND_CLOSEST(nrange * (val - omin), orange) + nmin;
}
/* convert from alsa native to oss values (0-100) */
static long snd_mixer_oss_conv1(long val, long min, long max, int *old)
{
if (val == snd_mixer_oss_conv(*old, 0, 100, min, max))
return *old;
return snd_mixer_oss_conv(val, min, max, 0, 100);
}
/* convert from oss to alsa native values */
static long snd_mixer_oss_conv2(long val, long min, long max)
{
return snd_mixer_oss_conv(val, 0, 100, min, max);
}
#if 0
static void snd_mixer_oss_recsrce_set(struct snd_card *card, int slot)
{
struct snd_mixer_oss *mixer = card->mixer_oss;
if (mixer)
mixer->mask_recsrc |= 1 << slot;
}
static int snd_mixer_oss_recsrce_get(struct snd_card *card, int slot)
{
struct snd_mixer_oss *mixer = card->mixer_oss;
if (mixer && (mixer->mask_recsrc & (1 << slot)))
return 1;
return 0;
}
#endif
#define SNDRV_MIXER_OSS_SIGNATURE 0x65999250
#define SNDRV_MIXER_OSS_ITEM_GLOBAL 0
#define SNDRV_MIXER_OSS_ITEM_GSWITCH 1
#define SNDRV_MIXER_OSS_ITEM_GROUTE 2
#define SNDRV_MIXER_OSS_ITEM_GVOLUME 3
#define SNDRV_MIXER_OSS_ITEM_PSWITCH 4
#define SNDRV_MIXER_OSS_ITEM_PROUTE 5
#define SNDRV_MIXER_OSS_ITEM_PVOLUME 6
#define SNDRV_MIXER_OSS_ITEM_CSWITCH 7
#define SNDRV_MIXER_OSS_ITEM_CROUTE 8
#define SNDRV_MIXER_OSS_ITEM_CVOLUME 9
#define SNDRV_MIXER_OSS_ITEM_CAPTURE 10
#define SNDRV_MIXER_OSS_ITEM_COUNT 11
#define SNDRV_MIXER_OSS_PRESENT_GLOBAL (1<<0)
#define SNDRV_MIXER_OSS_PRESENT_GSWITCH (1<<1)
#define SNDRV_MIXER_OSS_PRESENT_GROUTE (1<<2)
#define SNDRV_MIXER_OSS_PRESENT_GVOLUME (1<<3)
#define SNDRV_MIXER_OSS_PRESENT_PSWITCH (1<<4)
#define SNDRV_MIXER_OSS_PRESENT_PROUTE (1<<5)
#define SNDRV_MIXER_OSS_PRESENT_PVOLUME (1<<6)
#define SNDRV_MIXER_OSS_PRESENT_CSWITCH (1<<7)
#define SNDRV_MIXER_OSS_PRESENT_CROUTE (1<<8)
#define SNDRV_MIXER_OSS_PRESENT_CVOLUME (1<<9)
#define SNDRV_MIXER_OSS_PRESENT_CAPTURE (1<<10)
struct slot {
unsigned int signature;
unsigned int present;
unsigned int channels;
unsigned int numid[SNDRV_MIXER_OSS_ITEM_COUNT];
unsigned int capture_item;
const struct snd_mixer_oss_assign_table *assigned;
unsigned int allocated: 1;
};
Annotation
- Immediate include surface: `linux/init.h`, `linux/slab.h`, `linux/time.h`, `linux/string.h`, `linux/module.h`, `linux/compat.h`, `sound/core.h`, `sound/minors.h`.
- Detected declarations: `struct slot`, `struct snd_mixer_oss_assign_table`, `function snd_mixer_oss_open`, `function snd_mixer_oss_release`, `function snd_mixer_oss_info`, `function snd_mixer_oss_info_obsolete`, `function snd_mixer_oss_caps`, `function snd_mixer_oss_devmask`, `function snd_mixer_oss_stereodevs`, `function snd_mixer_oss_recmask`.
- Atlas domain: Driver Families / sound/core.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.