sound/mips/hal2.c
Source file repositories/reference/linux-study-clean/sound/mips/hal2.c
File Facts
- System
- Linux kernel
- Corpus path
sound/mips/hal2.c- Extension
.c- Size
- 24572 bytes
- Lines
- 896
- 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.
- 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/kernel.hlinux/init.hlinux/interrupt.hlinux/dma-mapping.hlinux/platform_device.hlinux/io.hlinux/slab.hlinux/module.hasm/sgi/hpc3.hasm/sgi/ip22.hsound/core.hsound/control.hsound/pcm.hsound/pcm-indirect.hsound/initval.hhal2.h
Detected Declarations
struct hal2_pbusstruct hal2_descstruct hal2_codecstruct snd_hal2function hal2_readfunction hal2_writefunction hal2_i_read32function hal2_i_write16function hal2_i_write32function hal2_i_setbit16function hal2_i_clearbit16function hal2_gain_infofunction hal2_gain_getfunction hal2_gain_putfunction hal2_mixer_createfunction hal2_interruptfunction hal2_compute_ratefunction hal2_set_dac_ratefunction hal2_set_adc_ratefunction hal2_setup_dacfunction hal2_setup_adcfunction hal2_start_dacfunction hal2_start_adcfunction hal2_stop_dacfunction hal2_stop_adcfunction hal2_alloc_dmabuffunction hal2_free_dmabuffunction hal2_playback_openfunction hal2_playback_closefunction hal2_playback_preparefunction hal2_playback_triggerfunction hal2_playback_pointerfunction hal2_playback_transferfunction hal2_playback_ackfunction hal2_capture_openfunction hal2_capture_closefunction hal2_capture_preparefunction hal2_capture_triggerfunction hal2_capture_pointerfunction hal2_capture_transferfunction hal2_capture_ackfunction hal2_pcm_createfunction hal2_dev_freefunction hal2_init_codecfunction hal2_detectfunction hal2_createfunction hal2_probefunction hal2_remove
Annotated Snippet
struct hal2_pbus {
struct hpc3_pbus_dmacregs *pbus;
int pbusnr;
unsigned int ctrl; /* Current state of pbus->pbdma_ctrl */
};
struct hal2_desc {
struct hpc_dma_desc desc;
u32 pad; /* padding */
};
struct hal2_codec {
struct snd_pcm_indirect pcm_indirect;
struct snd_pcm_substream *substream;
unsigned char *buffer;
dma_addr_t buffer_dma;
struct hal2_desc *desc;
dma_addr_t desc_dma;
int desc_count;
struct hal2_pbus pbus;
int voices; /* mono/stereo */
unsigned int sample_rate;
unsigned int master; /* Master frequency */
unsigned short mod; /* MOD value */
unsigned short inc; /* INC value */
};
#define H2_MIX_OUTPUT_ATT 0
#define H2_MIX_INPUT_GAIN 1
struct snd_hal2 {
struct snd_card *card;
struct hal2_ctl_regs *ctl_regs; /* HAL2 ctl registers */
struct hal2_aes_regs *aes_regs; /* HAL2 aes registers */
struct hal2_vol_regs *vol_regs; /* HAL2 vol registers */
struct hal2_syn_regs *syn_regs; /* HAL2 syn registers */
struct hal2_codec dac;
struct hal2_codec adc;
};
#define H2_INDIRECT_WAIT(regs) while (hal2_read(®s->isr) & H2_ISR_TSTATUS);
#define H2_READ_ADDR(addr) (addr | (1<<7))
#define H2_WRITE_ADDR(addr) (addr)
static inline u32 hal2_read(u32 *reg)
{
return __raw_readl(reg);
}
static inline void hal2_write(u32 val, u32 *reg)
{
__raw_writel(val, reg);
}
static u32 hal2_i_read32(struct snd_hal2 *hal2, u16 addr)
{
u32 ret;
struct hal2_ctl_regs *regs = hal2->ctl_regs;
hal2_write(H2_READ_ADDR(addr), ®s->iar);
H2_INDIRECT_WAIT(regs);
ret = hal2_read(®s->idr0) & 0xffff;
hal2_write(H2_READ_ADDR(addr) | 0x1, ®s->iar);
H2_INDIRECT_WAIT(regs);
ret |= (hal2_read(®s->idr0) & 0xffff) << 16;
return ret;
}
static void hal2_i_write16(struct snd_hal2 *hal2, u16 addr, u16 val)
{
struct hal2_ctl_regs *regs = hal2->ctl_regs;
hal2_write(val, ®s->idr0);
hal2_write(0, ®s->idr1);
hal2_write(0, ®s->idr2);
hal2_write(0, ®s->idr3);
hal2_write(H2_WRITE_ADDR(addr), ®s->iar);
H2_INDIRECT_WAIT(regs);
}
static void hal2_i_write32(struct snd_hal2 *hal2, u16 addr, u32 val)
{
struct hal2_ctl_regs *regs = hal2->ctl_regs;
hal2_write(val & 0xffff, ®s->idr0);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/interrupt.h`, `linux/dma-mapping.h`, `linux/platform_device.h`, `linux/io.h`, `linux/slab.h`, `linux/module.h`.
- Detected declarations: `struct hal2_pbus`, `struct hal2_desc`, `struct hal2_codec`, `struct snd_hal2`, `function hal2_read`, `function hal2_write`, `function hal2_i_read32`, `function hal2_i_write16`, `function hal2_i_write32`, `function hal2_i_setbit16`.
- Atlas domain: Driver Families / sound/mips.
- Implementation status: source 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.