sound/isa/es1688/es1688_lib.c
Source file repositories/reference/linux-study-clean/sound/isa/es1688/es1688_lib.c
File Facts
- System
- Linux kernel
- Corpus path
sound/isa/es1688/es1688_lib.c- Extension
.c- Size
- 28327 bytes
- Lines
- 976
- 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.
- 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.hlinux/io.hsound/core.hsound/es1688.hsound/initval.hasm/dma.h
Detected Declarations
function snd_es1688_dsp_commandfunction snd_es1688_dsp_get_bytefunction snd_es1688_writefunction snd_es1688_readfunction snd_es1688_mixer_writefunction snd_es1688_mixer_readfunction snd_es1688_resetfunction snd_es1688_probefunction scoped_guardfunction scoped_guardfunction snd_es1688_initfunction scoped_guardfunction scoped_guardfunction scoped_guardfunction snd_es1688_set_ratefunction snd_es1688_triggerfunction snd_es1688_playback_preparefunction snd_es1688_playback_triggerfunction snd_es1688_capture_preparefunction snd_es1688_capture_triggerfunction snd_es1688_interruptfunction snd_es1688_playback_pointerfunction snd_es1688_capture_pointerfunction snd_es1688_playback_openfunction snd_es1688_capture_openfunction snd_es1688_playback_closefunction snd_es1688_capture_closefunction snd_es1688_freefunction snd_es1688_dev_freefunction snd_es1688_createfunction snd_es1688_pcmfunction snd_es1688_info_muxfunction snd_es1688_get_muxfunction snd_es1688_put_muxfunction snd_es1688_info_singlefunction snd_es1688_get_singlefunction snd_es1688_put_singlefunction snd_es1688_info_doublefunction snd_es1688_get_doublefunction snd_es1688_put_doublefunction snd_es1688_mixerexport snd_es1688_resetexport snd_es1688_mixer_writeexport snd_es1688_createexport snd_es1688_pcmexport snd_es1688_mixer
Annotated Snippet
if ((inb(ES1688P(chip, STATUS)) & 0x80) == 0) {
outb(val, ES1688P(chip, COMMAND));
return 1;
}
dev_dbg(chip->card->dev, "%s: timeout (0x%x)\n", __func__, val);
return 0;
}
static int snd_es1688_dsp_get_byte(struct snd_es1688 *chip)
{
int i;
for (i = 1000; i; i--)
if (inb(ES1688P(chip, DATA_AVAIL)) & 0x80)
return inb(ES1688P(chip, READ));
dev_dbg(chip->card->dev, "es1688 get byte failed: 0x%lx = 0x%x!!!\n",
ES1688P(chip, DATA_AVAIL), inb(ES1688P(chip, DATA_AVAIL)));
return -ENODEV;
}
static int snd_es1688_write(struct snd_es1688 *chip,
unsigned char reg, unsigned char data)
{
if (!snd_es1688_dsp_command(chip, reg))
return 0;
return snd_es1688_dsp_command(chip, data);
}
static int snd_es1688_read(struct snd_es1688 *chip, unsigned char reg)
{
/* Read a byte from an extended mode register of ES1688 */
if (!snd_es1688_dsp_command(chip, 0xc0))
return -1;
if (!snd_es1688_dsp_command(chip, reg))
return -1;
return snd_es1688_dsp_get_byte(chip);
}
void snd_es1688_mixer_write(struct snd_es1688 *chip,
unsigned char reg, unsigned char data)
{
outb(reg, ES1688P(chip, MIXER_ADDR));
udelay(10);
outb(data, ES1688P(chip, MIXER_DATA));
udelay(10);
}
static unsigned char snd_es1688_mixer_read(struct snd_es1688 *chip, unsigned char reg)
{
unsigned char result;
outb(reg, ES1688P(chip, MIXER_ADDR));
udelay(10);
result = inb(ES1688P(chip, MIXER_DATA));
udelay(10);
return result;
}
int snd_es1688_reset(struct snd_es1688 *chip)
{
int i;
outb(3, ES1688P(chip, RESET)); /* valid only for ESS chips, SB -> 1 */
udelay(10);
outb(0, ES1688P(chip, RESET));
udelay(30);
for (i = 0; i < 1000 && !(inb(ES1688P(chip, DATA_AVAIL)) & 0x80); i++);
if (inb(ES1688P(chip, READ)) != 0xaa) {
dev_dbg(chip->card->dev, "ess_reset at 0x%lx: failed!!!\n",
chip->port);
return -ENODEV;
}
snd_es1688_dsp_command(chip, 0xc6); /* enable extended mode */
return 0;
}
EXPORT_SYMBOL(snd_es1688_reset);
static int snd_es1688_probe(struct snd_es1688 *chip)
{
unsigned short major, minor;
int i;
/*
* initialization sequence
*/
scoped_guard(spinlock_irqsave, &chip->reg_lock) { /* Some ESS1688 cards need this */
inb(ES1688P(chip, ENABLE1)); /* ENABLE1 */
inb(ES1688P(chip, ENABLE1)); /* ENABLE1 */
inb(ES1688P(chip, ENABLE1)); /* ENABLE1 */
Annotation
- Immediate include surface: `linux/init.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/slab.h`, `linux/ioport.h`, `linux/module.h`, `linux/io.h`, `sound/core.h`.
- Detected declarations: `function snd_es1688_dsp_command`, `function snd_es1688_dsp_get_byte`, `function snd_es1688_write`, `function snd_es1688_read`, `function snd_es1688_mixer_write`, `function snd_es1688_mixer_read`, `function snd_es1688_reset`, `function snd_es1688_probe`, `function scoped_guard`, `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.