drivers/media/pci/cx23885/cx23885-alsa.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/cx23885/cx23885-alsa.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/cx23885/cx23885-alsa.c- Extension
.c- Size
- 14436 bytes
- Lines
- 597
- Domain
- Driver Families
- Bucket
- drivers/media
- 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
cx23885.hcx23885-reg.hlinux/module.hlinux/init.hlinux/device.hlinux/interrupt.hlinux/vmalloc.hlinux/dma-mapping.hlinux/pci.hasm/delay.hsound/core.hsound/pcm.hsound/pcm_params.hsound/control.hsound/initval.hsound/tlv.h
Detected Declarations
function cx23885_alsa_dma_initfunction cx23885_alsa_dma_mapfunction cx23885_alsa_dma_unmapfunction cx23885_alsa_dma_freefunction cx23885_start_audio_dmafunction cx23885_stop_audio_dmafunction cx23885_audio_irqfunction dsp_buffer_freefunction snd_cx23885_pcm_openfunction snd_cx23885_closefunction snd_cx23885_hw_paramsfunction snd_cx23885_hw_freefunction snd_cx23885_preparefunction snd_cx23885_card_triggerfunction snd_cx23885_pointerfunction callbackfunction snd_cx23885_pcmfunction cx23885_audio_unregister
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
*
* Support for CX23885 analog audio capture
*
* (c) 2008 Mijhail Moreyra <mijhail.moreyra@gmail.com>
* Adapted from cx88-alsa.c
* (c) 2009 Steven Toth <stoth@kernellabs.com>
*/
#include "cx23885.h"
#include "cx23885-reg.h"
#include <linux/module.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/interrupt.h>
#include <linux/vmalloc.h>
#include <linux/dma-mapping.h>
#include <linux/pci.h>
#include <asm/delay.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/control.h>
#include <sound/initval.h>
#include <sound/tlv.h>
#define AUDIO_SRAM_CHANNEL SRAM_CH07
#define dprintk(level, fmt, arg...) do { \
if (audio_debug + 1 > level) \
printk(KERN_DEBUG pr_fmt("%s: alsa: " fmt), \
chip->dev->name, ##arg); \
} while(0)
/****************************************************************************
Module global static vars
****************************************************************************/
static unsigned int disable_analog_audio;
module_param(disable_analog_audio, int, 0644);
MODULE_PARM_DESC(disable_analog_audio, "disable analog audio ALSA driver");
static unsigned int audio_debug;
module_param(audio_debug, int, 0644);
MODULE_PARM_DESC(audio_debug, "enable debug messages [analog audio]");
/****************************************************************************
Board specific functions
****************************************************************************/
/* Constants taken from cx88-reg.h */
#define AUD_INT_DN_RISCI1 (1 << 0)
#define AUD_INT_UP_RISCI1 (1 << 1)
#define AUD_INT_RDS_DN_RISCI1 (1 << 2)
#define AUD_INT_DN_RISCI2 (1 << 4) /* yes, 3 is skipped */
#define AUD_INT_UP_RISCI2 (1 << 5)
#define AUD_INT_RDS_DN_RISCI2 (1 << 6)
#define AUD_INT_DN_SYNC (1 << 12)
#define AUD_INT_UP_SYNC (1 << 13)
#define AUD_INT_RDS_DN_SYNC (1 << 14)
#define AUD_INT_OPC_ERR (1 << 16)
#define AUD_INT_BER_IRQ (1 << 20)
#define AUD_INT_MCHG_IRQ (1 << 21)
#define GP_COUNT_CONTROL_RESET 0x3
static int cx23885_alsa_dma_init(struct cx23885_audio_dev *chip,
unsigned long nr_pages)
{
struct cx23885_audio_buffer *buf = chip->buf;
struct page *pg;
int i;
buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT);
if (NULL == buf->vaddr) {
dprintk(1, "vmalloc_32(%lu pages) failed\n", nr_pages);
return -ENOMEM;
}
dprintk(1, "vmalloc is at addr %p, size=%lu\n",
buf->vaddr, nr_pages << PAGE_SHIFT);
memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT);
buf->nr_pages = nr_pages;
buf->sglist = vzalloc(array_size(sizeof(*buf->sglist), buf->nr_pages));
Annotation
- Immediate include surface: `cx23885.h`, `cx23885-reg.h`, `linux/module.h`, `linux/init.h`, `linux/device.h`, `linux/interrupt.h`, `linux/vmalloc.h`, `linux/dma-mapping.h`.
- Detected declarations: `function cx23885_alsa_dma_init`, `function cx23885_alsa_dma_map`, `function cx23885_alsa_dma_unmap`, `function cx23885_alsa_dma_free`, `function cx23885_start_audio_dma`, `function cx23885_stop_audio_dma`, `function cx23885_audio_irq`, `function dsp_buffer_free`, `function snd_cx23885_pcm_open`, `function snd_cx23885_close`.
- Atlas domain: Driver Families / drivers/media.
- 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.