sound/isa/gus/gus_main.c
Source file repositories/reference/linux-study-clean/sound/isa/gus/gus_main.c
File Facts
- System
- Linux kernel
- Corpus path
sound/isa/gus/gus_main.c- Extension
.c- Size
- 12566 bytes
- Lines
- 482
- 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/init.hlinux/interrupt.hlinux/delay.hlinux/slab.hlinux/ioport.hlinux/module.hsound/core.hsound/gus.hsound/control.hasm/dma.h
Detected Declarations
function snd_gus_joystick_infofunction snd_gus_joystick_getfunction snd_gus_joystick_putfunction snd_gus_init_controlfunction snd_gus_freefunction snd_gus_dev_freefunction snd_gus_createfunction snd_gus_detect_memoryfunction snd_gus_init_dma_irqfunction scoped_guardfunction scoped_guardfunction scoped_guardfunction snd_gus_check_versionfunction snd_gus_initializefunction snd_gus_suspendfunction snd_gus_resumeexport snd_gus_suspendexport snd_gus_resumeexport snd_gf1_delayexport snd_gf1_write8export snd_gf1_look8export snd_gf1_write16export snd_gf1_look16export snd_gf1_i_write8export snd_gf1_i_look8export snd_gf1_i_look16export snd_gf1_dram_addrexport snd_gf1_write_addrexport snd_gf1_pokeexport snd_gf1_peekexport snd_gf1_alloc_voiceexport snd_gf1_free_voiceexport snd_gf1_ctrl_stopexport snd_gf1_stop_voiceexport snd_gf1_new_mixerexport snd_gf1_pcm_newexport snd_gus_createexport snd_gus_initializeexport snd_gus_interruptexport snd_gf1_rawmidi_newexport snd_gus_dram_writeexport snd_gus_dram_readexport snd_gf1_lvol_to_gvol_rawexport snd_gf1_translate_freqexport snd_gf1_mem_allocexport snd_gf1_mem_xfreeexport snd_gf1_mem_free
Annotated Snippet
if (request_dma(dma2, "GUS - 2")) {
dev_err(card->dev, "gus: can't grab DMA2 %d\n", dma2);
snd_gus_free(gus);
return -EBUSY;
}
gus->gf1.dma2 = dma2;
} else {
gus->gf1.dma2 = gus->gf1.dma1;
gus->equal_dma = 1;
}
gus->timer_dev = timer_dev;
if (voices < 14)
voices = 14;
if (voices > 32)
voices = 32;
if (pcm_channels < 0)
pcm_channels = 0;
if (pcm_channels > 8)
pcm_channels = 8;
pcm_channels++;
pcm_channels &= ~1;
gus->gf1.effect = effect ? 1 : 0;
gus->gf1.active_voices = voices;
gus->gf1.pcm_channels = pcm_channels;
gus->gf1.volume_ramp = 25;
gus->gf1.smooth_pan = 1;
err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, gus, &ops);
if (err < 0) {
snd_gus_free(gus);
return err;
}
*rgus = gus;
return 0;
}
/*
* Memory detection routine for plain GF1 soundcards
*/
static int snd_gus_detect_memory(struct snd_gus_card * gus)
{
int l, idx, local;
unsigned char d;
snd_gf1_poke(gus, 0L, 0xaa);
snd_gf1_poke(gus, 1L, 0x55);
if (snd_gf1_peek(gus, 0L) != 0xaa || snd_gf1_peek(gus, 1L) != 0x55) {
dev_err(gus->card->dev,
"plain GF1 card at 0x%lx without onboard DRAM?\n",
gus->gf1.port);
return -ENOMEM;
}
for (idx = 1, d = 0xab; idx < 4; idx++, d++) {
local = idx << 18;
snd_gf1_poke(gus, local, d);
snd_gf1_poke(gus, local + 1, d + 1);
if (snd_gf1_peek(gus, local) != d ||
snd_gf1_peek(gus, local + 1) != d + 1 ||
snd_gf1_peek(gus, 0L) != 0xaa)
break;
}
#if 1
gus->gf1.memory = idx << 18;
#else
gus->gf1.memory = 256 * 1024;
#endif
for (l = 0, local = gus->gf1.memory; l < 4; l++, local -= 256 * 1024) {
gus->gf1.mem_alloc.banks_8[l].address =
gus->gf1.mem_alloc.banks_8[l].size = 0;
gus->gf1.mem_alloc.banks_16[l].address = l << 18;
gus->gf1.mem_alloc.banks_16[l].size = local > 0 ? 256 * 1024 : 0;
}
gus->gf1.mem_alloc.banks_8[0].size = gus->gf1.memory;
return 0; /* some memory were detected */
}
static int snd_gus_init_dma_irq(struct snd_gus_card * gus, int latches)
{
struct snd_card *card;
int irq, dma1, dma2;
static const unsigned char irqs[16] =
{0, 0, 1, 3, 0, 2, 0, 4, 0, 1, 0, 5, 6, 0, 0, 7};
static const unsigned char dmas[8] =
{6, 1, 0, 2, 0, 3, 4, 5};
if (snd_BUG_ON(!gus))
return -EINVAL;
card = gus->card;
if (snd_BUG_ON(!card))
return -EINVAL;
Annotation
- Immediate include surface: `linux/init.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/slab.h`, `linux/ioport.h`, `linux/module.h`, `sound/core.h`, `sound/gus.h`.
- Detected declarations: `function snd_gus_joystick_info`, `function snd_gus_joystick_get`, `function snd_gus_joystick_put`, `function snd_gus_init_control`, `function snd_gus_free`, `function snd_gus_dev_free`, `function snd_gus_create`, `function snd_gus_detect_memory`, `function snd_gus_init_dma_irq`, `function scoped_guard`.
- 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.