sound/mips/sgio2audio.c
Source file repositories/reference/linux-study-clean/sound/mips/sgio2audio.c
File Facts
- System
- Linux kernel
- Corpus path
sound/mips/sgio2audio.c- Extension
.c- Size
- 25056 bytes
- Lines
- 918
- Domain
- Driver Families
- Bucket
- sound/mips
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/delay.hlinux/spinlock.hlinux/interrupt.hlinux/dma-mapping.hlinux/platform_device.hlinux/io.hlinux/slab.hlinux/string.hlinux/module.hasm/ip32/ip32_ints.hasm/ip32/mace.hsound/core.hsound/control.hsound/pcm.hsound/initval.hsound/ad1843.h
Detected Declarations
struct snd_sgio2audio_chanstruct snd_sgio2audiofunction read_ad1843_regfunction write_ad1843_regfunction sgio2audio_gain_infofunction sgio2audio_gain_getfunction sgio2audio_gain_putfunction sgio2audio_source_infofunction sgio2audio_source_getfunction sgio2audio_source_putfunction snd_sgio2audio_new_mixerfunction snd_sgio2audio_dma_pull_fragfunction snd_sgio2audio_dma_push_fragfunction snd_sgio2audio_dma_startfunction snd_sgio2audio_dma_stopfunction snd_sgio2audio_dma_in_isrfunction snd_sgio2audio_dma_out_isrfunction snd_sgio2audio_error_isrfunction snd_sgio2audio_playback1_openfunction snd_sgio2audio_playback2_openfunction snd_sgio2audio_capture_openfunction snd_sgio2audio_pcm_closefunction snd_sgio2audio_pcm_preparefunction snd_sgio2audio_pcm_triggerfunction snd_sgio2audio_pcm_pointerfunction snd_sgio2audio_new_pcmfunction snd_sgio2audio_freefunction snd_sgio2audio_dev_freefunction snd_sgio2audio_createfunction snd_sgio2audio_probefunction snd_sgio2audio_remove
Annotated Snippet
struct snd_sgio2audio_chan {
int idx;
struct snd_pcm_substream *substream;
int pos;
snd_pcm_uframes_t size;
spinlock_t lock;
};
/* definition of the chip-specific record */
struct snd_sgio2audio {
struct snd_card *card;
/* codec */
struct snd_ad1843 ad1843;
spinlock_t ad1843_lock;
/* channels */
struct snd_sgio2audio_chan channel[3];
/* resources */
void *ring_base;
dma_addr_t ring_base_dma;
};
/* AD1843 access */
/*
* read_ad1843_reg returns the current contents of a 16 bit AD1843 register.
*
* Returns unsigned register value on success, -errno on failure.
*/
static int read_ad1843_reg(void *priv, int reg)
{
struct snd_sgio2audio *chip = priv;
int val;
guard(spinlock_irqsave)(&chip->ad1843_lock);
writeq((reg << CODEC_CONTROL_ADDRESS_SHIFT) |
CODEC_CONTROL_READ, &mace->perif.audio.codec_control);
wmb();
val = readq(&mace->perif.audio.codec_control); /* flush bus */
udelay(200);
val = readq(&mace->perif.audio.codec_read);
return val;
}
/*
* write_ad1843_reg writes the specified value to a 16 bit AD1843 register.
*/
static int write_ad1843_reg(void *priv, int reg, int word)
{
struct snd_sgio2audio *chip = priv;
int val;
guard(spinlock_irqsave)(&chip->ad1843_lock);
writeq((reg << CODEC_CONTROL_ADDRESS_SHIFT) |
(word << CODEC_CONTROL_WORD_SHIFT),
&mace->perif.audio.codec_control);
wmb();
val = readq(&mace->perif.audio.codec_control); /* flush bus */
udelay(200);
return 0;
}
static int sgio2audio_gain_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
struct snd_sgio2audio *chip = snd_kcontrol_chip(kcontrol);
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 2;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = ad1843_get_gain_max(&chip->ad1843,
(int)kcontrol->private_value);
return 0;
}
static int sgio2audio_gain_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_sgio2audio *chip = snd_kcontrol_chip(kcontrol);
int vol;
vol = ad1843_get_gain(&chip->ad1843, (int)kcontrol->private_value);
Annotation
- Immediate include surface: `linux/init.h`, `linux/delay.h`, `linux/spinlock.h`, `linux/interrupt.h`, `linux/dma-mapping.h`, `linux/platform_device.h`, `linux/io.h`, `linux/slab.h`.
- Detected declarations: `struct snd_sgio2audio_chan`, `struct snd_sgio2audio`, `function read_ad1843_reg`, `function write_ad1843_reg`, `function sgio2audio_gain_info`, `function sgio2audio_gain_get`, `function sgio2audio_gain_put`, `function sgio2audio_source_info`, `function sgio2audio_source_get`, `function sgio2audio_source_put`.
- Atlas domain: Driver Families / sound/mips.
- Implementation status: source 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.