sound/pci/aw2/aw2-saa7146.c
Source file repositories/reference/linux-study-clean/sound/pci/aw2/aw2-saa7146.c
File Facts
- System
- Linux kernel
- Corpus path
sound/pci/aw2/aw2-saa7146.c- Extension
.c- Size
- 12088 bytes
- Lines
- 449
- Domain
- Driver Families
- Bucket
- sound/pci
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/pci.hlinux/interrupt.hlinux/delay.hlinux/io.hsound/core.hsound/initval.hsound/pcm.hsound/pcm_params.hsaa7146.haw2-saa7146.haw2-tsl.c
Detected Declarations
function snd_aw2_saa7146_freefunction snd_aw2_saa7146_setupfunction snd_aw2_saa7146_pcm_init_playbackfunction snd_aw2_saa7146_pcm_init_capturefunction snd_aw2_saa7146_define_it_playback_callbackfunction snd_aw2_saa7146_define_it_capture_callbackfunction snd_aw2_saa7146_pcm_trigger_start_playbackfunction snd_aw2_saa7146_pcm_trigger_stop_playbackfunction snd_aw2_saa7146_pcm_trigger_start_capturefunction snd_aw2_saa7146_pcm_trigger_stop_capturefunction snd_aw2_saa7146_interruptfunction snd_aw2_saa7146_get_hw_ptr_playbackfunction snd_aw2_saa7146_get_hw_ptr_capturefunction snd_aw2_saa7146_use_digital_inputfunction snd_aw2_saa7146_is_using_digital_inputfunction snd_aw2_saa7146_get_limit
Annotated Snippet
if (arr_substream_it_playback_cb[1].p_it_callback != NULL) {
arr_substream_it_playback_cb[1].
p_it_callback(arr_substream_it_playback_cb[1].
p_callback_param);
}
}
if (isr & A2_out) {
if (arr_substream_it_playback_cb[0].p_it_callback != NULL) {
arr_substream_it_playback_cb[0].
p_it_callback(arr_substream_it_playback_cb[0].
p_callback_param);
}
}
if (isr & A1_in) {
if (arr_substream_it_capture_cb[0].p_it_callback != NULL) {
arr_substream_it_capture_cb[0].
p_it_callback(arr_substream_it_capture_cb[0].
p_callback_param);
}
}
return IRQ_HANDLED;
}
unsigned int snd_aw2_saa7146_get_hw_ptr_playback(struct snd_aw2_saa7146 *chip,
int stream_number,
unsigned char *start_addr,
unsigned int buffer_size)
{
long pci_adp = 0;
size_t ptr = 0;
if (stream_number == 0) {
pci_adp = READREG(PCI_ADP3);
ptr = pci_adp - (long)start_addr;
if (ptr == buffer_size)
ptr = 0;
}
if (stream_number == 1) {
pci_adp = READREG(PCI_ADP1);
ptr = pci_adp - (size_t) start_addr;
if (ptr == buffer_size)
ptr = 0;
}
return ptr;
}
unsigned int snd_aw2_saa7146_get_hw_ptr_capture(struct snd_aw2_saa7146 *chip,
int stream_number,
unsigned char *start_addr,
unsigned int buffer_size)
{
size_t pci_adp = 0;
size_t ptr = 0;
if (stream_number == 0) {
pci_adp = READREG(PCI_ADP2);
ptr = pci_adp - (size_t) start_addr;
if (ptr == buffer_size)
ptr = 0;
}
return ptr;
}
void snd_aw2_saa7146_use_digital_input(struct snd_aw2_saa7146 *chip,
int use_digital)
{
/* FIXME: switch between analog and digital input does not always work.
It can produce a kind of white noise. It seams that received data
are inverted sometime (endian inversion). Why ? I don't know, maybe
a problem of synchronization... However for the time being I have
not found the problem. Workaround: switch again (and again) between
digital and analog input until it works. */
if (use_digital)
WRITEREG(0x40, GPIO_CTRL);
else
WRITEREG(0x50, GPIO_CTRL);
}
int snd_aw2_saa7146_is_using_digital_input(struct snd_aw2_saa7146 *chip)
{
unsigned int reg_val = READREG(GPIO_CTRL);
if ((reg_val & 0xFF) == 0x40)
return 1;
else
return 0;
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/pci.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/io.h`, `sound/core.h`, `sound/initval.h`, `sound/pcm.h`.
- Detected declarations: `function snd_aw2_saa7146_free`, `function snd_aw2_saa7146_setup`, `function snd_aw2_saa7146_pcm_init_playback`, `function snd_aw2_saa7146_pcm_init_capture`, `function snd_aw2_saa7146_define_it_playback_callback`, `function snd_aw2_saa7146_define_it_capture_callback`, `function snd_aw2_saa7146_pcm_trigger_start_playback`, `function snd_aw2_saa7146_pcm_trigger_stop_playback`, `function snd_aw2_saa7146_pcm_trigger_start_capture`, `function snd_aw2_saa7146_pcm_trigger_stop_capture`.
- Atlas domain: Driver Families / sound/pci.
- 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.