sound/isa/sb/sb_common.c
Source file repositories/reference/linux-study-clean/sound/isa/sb/sb_common.c
File Facts
- System
- Linux kernel
- Corpus path
sound/isa/sb/sb_common.c- Extension
.c- Size
- 5733 bytes
- Lines
- 258
- Domain
- Driver Families
- Bucket
- sound/isa
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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.
- 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/delay.hlinux/init.hlinux/interrupt.hlinux/slab.hlinux/ioport.hlinux/module.hlinux/io.hsound/core.hsound/sb.hsound/initval.hasm/dma.h
Detected Declarations
function snd_sbdsp_commandfunction snd_sbdsp_get_bytefunction snd_sbdsp_resetfunction snd_sbdsp_versionfunction snd_sbdsp_probefunction scoped_guardfunction snd_sbdsp_createexport snd_sbdsp_commandexport snd_sbdsp_get_byteexport snd_sbdsp_resetexport snd_sbdsp_createexport snd_sbmixer_writeexport snd_sbmixer_readexport snd_sbmixer_newexport snd_sbmixer_add_ctlexport snd_sbmixer_suspendexport snd_sbmixer_resume
Annotated Snippet
if ((inb(SBP(chip, STATUS)) & 0x80) == 0) {
outb(val, SBP(chip, COMMAND));
return 1;
}
dev_dbg(chip->card->dev, "%s [0x%lx]: timeout (0x%x)\n", __func__, chip->port, val);
return 0;
}
int snd_sbdsp_get_byte(struct snd_sb *chip)
{
int val;
int i;
for (i = BUSY_LOOPS; i; i--) {
if (inb(SBP(chip, DATA_AVAIL)) & 0x80) {
val = inb(SBP(chip, READ));
#ifdef IO_DEBUG
dev_dbg(chip->card->dev, "get_byte 0x%x\n", val);
#endif
return val;
}
}
dev_dbg(chip->card->dev, "%s [0x%lx]: timeout\n", __func__, chip->port);
return -ENODEV;
}
int snd_sbdsp_reset(struct snd_sb *chip)
{
int i;
outb(1, SBP(chip, RESET));
udelay(10);
outb(0, SBP(chip, RESET));
udelay(30);
for (i = BUSY_LOOPS; i; i--)
if (inb(SBP(chip, DATA_AVAIL)) & 0x80) {
if (inb(SBP(chip, READ)) == 0xaa)
return 0;
else
break;
}
if (chip->card)
dev_dbg(chip->card->dev, "%s [0x%lx] failed...\n", __func__, chip->port);
return -ENODEV;
}
static int snd_sbdsp_version(struct snd_sb * chip)
{
unsigned int result;
snd_sbdsp_command(chip, SB_DSP_GET_VERSION);
result = (short) snd_sbdsp_get_byte(chip) << 8;
result |= (short) snd_sbdsp_get_byte(chip);
return result;
}
static int snd_sbdsp_probe(struct snd_sb * chip)
{
int version;
int major, minor;
char *str;
/*
* initialization sequence
*/
scoped_guard(spinlock_irqsave, &chip->reg_lock) {
if (snd_sbdsp_reset(chip) < 0)
return -ENODEV;
version = snd_sbdsp_version(chip);
if (version < 0)
return -ENODEV;
}
major = version >> 8;
minor = version & 0xff;
dev_dbg(chip->card->dev, "SB [0x%lx]: DSP chip found, version = %i.%i\n",
chip->port, major, minor);
switch (chip->hardware) {
case SB_HW_AUTO:
switch (major) {
case 1:
chip->hardware = SB_HW_10;
str = "1.0";
break;
case 2:
if (minor) {
chip->hardware = SB_HW_201;
str = "2.01+";
} else {
chip->hardware = SB_HW_20;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/init.h`, `linux/interrupt.h`, `linux/slab.h`, `linux/ioport.h`, `linux/module.h`, `linux/io.h`, `sound/core.h`.
- Detected declarations: `function snd_sbdsp_command`, `function snd_sbdsp_get_byte`, `function snd_sbdsp_reset`, `function snd_sbdsp_version`, `function snd_sbdsp_probe`, `function scoped_guard`, `function snd_sbdsp_create`, `export snd_sbdsp_command`, `export snd_sbdsp_get_byte`, `export snd_sbdsp_reset`.
- Atlas domain: Driver Families / sound/isa.
- Implementation status: integration 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.