sound/isa/sb/sb8_main.c
Source file repositories/reference/linux-study-clean/sound/isa/sb/sb8_main.c
File Facts
- System
- Linux kernel
- Corpus path
sound/isa/sb/sb8_main.c- Extension
.c- Size
- 16629 bytes
- Lines
- 581
- 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.
- 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/io.hasm/dma.hlinux/init.hlinux/time.hlinux/module.hsound/core.hsound/sb.h
Detected Declarations
function snd_sb8_hw_constraint_rate_channelsfunction snd_sb8_hw_constraint_channels_ratefunction snd_sb8_playback_preparefunction scoped_guardfunction snd_sb8_playback_triggerfunction snd_sb8_capture_preparefunction scoped_guardfunction snd_sb8_capture_triggerfunction snd_sb8dsp_interruptfunction snd_sb8_playback_pointerfunction snd_sb8_capture_pointerfunction snd_sb8_openfunction scoped_guardfunction snd_sb8_closefunction snd_sb8dsp_pcmexport snd_sb8dsp_pcmexport snd_sb8dsp_interruptexport snd_sb8dsp_midi_interruptexport snd_sb8dsp_midi
Annotated Snippet
if (err >= 0 && den) {
params->rate_num = num;
params->rate_den = den;
}
return err;
}
return 0;
}
static int snd_sb8_hw_constraint_channels_rate(struct snd_pcm_hw_params *params,
struct snd_pcm_hw_rule *rule)
{
struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
if (r->min > SB8_RATE(22050) || r->max <= SB8_RATE(11025)) {
struct snd_interval t = { .min = 1, .max = 1 };
return snd_interval_refine(hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS), &t);
}
return 0;
}
static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream)
{
struct snd_sb *chip = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
unsigned int mixreg, rate, size, count;
unsigned char format;
unsigned char stereo = runtime->channels > 1;
int dma;
rate = runtime->rate;
switch (chip->hardware) {
case SB_HW_JAZZ16:
if (runtime->format == SNDRV_PCM_FORMAT_S16_LE) {
if (chip->mode & SB_MODE_CAPTURE_16)
return -EBUSY;
else
chip->mode |= SB_MODE_PLAYBACK_16;
}
chip->playback_format = SB_DSP_LO_OUTPUT_AUTO;
break;
case SB_HW_PRO:
if (runtime->channels > 1) {
if (snd_BUG_ON(rate != SB8_RATE(11025) &&
rate != SB8_RATE(22050)))
return -EINVAL;
chip->playback_format = SB_DSP_HI_OUTPUT_AUTO;
break;
}
fallthrough;
case SB_HW_201:
if (rate > 23000) {
chip->playback_format = SB_DSP_HI_OUTPUT_AUTO;
break;
}
fallthrough;
case SB_HW_20:
chip->playback_format = SB_DSP_LO_OUTPUT_AUTO;
break;
case SB_HW_10:
chip->playback_format = SB_DSP_OUTPUT;
break;
default:
return -EINVAL;
}
if (chip->mode & SB_MODE_PLAYBACK_16) {
format = stereo ? SB_DSP_STEREO_16BIT : SB_DSP_MONO_16BIT;
dma = chip->dma16;
} else {
format = stereo ? SB_DSP_STEREO_8BIT : SB_DSP_MONO_8BIT;
chip->mode |= SB_MODE_PLAYBACK_8;
dma = chip->dma8;
}
size = chip->p_dma_size = snd_pcm_lib_buffer_bytes(substream);
count = chip->p_period_size = snd_pcm_lib_period_bytes(substream);
scoped_guard(spinlock_irqsave, &chip->reg_lock) {
snd_sbdsp_command(chip, SB_DSP_SPEAKER_ON);
if (chip->hardware == SB_HW_JAZZ16)
snd_sbdsp_command(chip, format);
else if (stereo) {
/* set playback stereo mode */
scoped_guard(spinlock, &chip->mixer_lock) {
mixreg = snd_sbmixer_read(chip, SB_DSP_STEREO_SW);
snd_sbmixer_write(chip, SB_DSP_STEREO_SW, mixreg | 0x02);
}
/* Soundblaster hardware programming reference guide, 3-23 */
snd_sbdsp_command(chip, SB_DSP_DMA8_EXIT);
runtime->dma_area[0] = 0x80;
snd_dma_program(dma, runtime->dma_addr, 1, DMA_MODE_WRITE);
/* force interrupt */
Annotation
- Immediate include surface: `linux/io.h`, `asm/dma.h`, `linux/init.h`, `linux/time.h`, `linux/module.h`, `sound/core.h`, `sound/sb.h`.
- Detected declarations: `function snd_sb8_hw_constraint_rate_channels`, `function snd_sb8_hw_constraint_channels_rate`, `function snd_sb8_playback_prepare`, `function scoped_guard`, `function snd_sb8_playback_trigger`, `function snd_sb8_capture_prepare`, `function scoped_guard`, `function snd_sb8_capture_trigger`, `function snd_sb8dsp_interrupt`, `function snd_sb8_playback_pointer`.
- Atlas domain: Driver Families / sound/isa.
- Implementation status: integration implementation candidate.
- 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.