drivers/media/pci/cobalt/cobalt-alsa-pcm.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/cobalt/cobalt-alsa-pcm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/cobalt/cobalt-alsa-pcm.c- Extension
.c- Size
- 12767 bytes
- Lines
- 531
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/kernel.hlinux/delay.hmedia/v4l2-device.hsound/core.hsound/pcm.hcobalt-driver.hcobalt-alsa.hcobalt-alsa-pcm.h
Detected Declarations
function sample_cpyfunction cobalt_alsa_announce_pcm_datafunction alsa_fncfunction snd_cobalt_pcm_capture_openfunction snd_cobalt_pcm_capture_closefunction snd_cobalt_pcm_preparefunction snd_cobalt_pcm_triggerfunction snd_cobalt_pcm_pointerfunction pb_sample_cpyfunction cobalt_alsa_pb_pcm_datafunction alsa_pb_fncfunction snd_cobalt_pcm_playback_openfunction snd_cobalt_pcm_playback_closefunction snd_cobalt_pcm_pb_preparefunction snd_cobalt_pcm_pb_triggerfunction snd_cobalt_pcm_pb_pointerfunction snd_cobalt_pcm_create
Annotated Snippet
if (is_s32) {
*dst++ = 0;
*dst++ = val & 0xff;
}
*dst++ = (val >> 8) & 0xff;
*dst++ = (val >> 16) & 0xff;
len -= is_s32 ? 4 : 2;
idx++;
}
}
static void cobalt_alsa_announce_pcm_data(struct snd_cobalt_card *cobsc,
u8 *pcm_data,
size_t skip,
size_t samples)
{
struct snd_pcm_substream *substream;
struct snd_pcm_runtime *runtime;
unsigned long flags;
unsigned int oldptr;
unsigned int stride;
int length = samples;
int period_elapsed = 0;
bool is_s32;
dprintk("cobalt alsa announce ptr=%p data=%p num_bytes=%zd\n", cobsc,
pcm_data, samples);
substream = cobsc->capture_pcm_substream;
if (substream == NULL) {
dprintk("substream was NULL\n");
return;
}
runtime = substream->runtime;
if (runtime == NULL) {
dprintk("runtime was NULL\n");
return;
}
is_s32 = runtime->format == SNDRV_PCM_FORMAT_S32_LE;
stride = runtime->frame_bits >> 3;
if (stride == 0) {
dprintk("stride is zero\n");
return;
}
if (length == 0) {
dprintk("%s: length was zero\n", __func__);
return;
}
if (runtime->dma_area == NULL) {
dprintk("dma area was NULL - ignoring\n");
return;
}
oldptr = cobsc->hwptr_done_capture;
if (oldptr + length >= runtime->buffer_size) {
unsigned int cnt = runtime->buffer_size - oldptr;
unsigned i;
for (i = 0; i < cnt; i++)
sample_cpy(runtime->dma_area + (oldptr + i) * stride,
pcm_data + i * skip,
stride, is_s32);
for (i = cnt; i < length; i++)
sample_cpy(runtime->dma_area + (i - cnt) * stride,
pcm_data + i * skip, stride, is_s32);
} else {
unsigned i;
for (i = 0; i < length; i++)
sample_cpy(runtime->dma_area + (oldptr + i) * stride,
pcm_data + i * skip,
stride, is_s32);
}
snd_pcm_stream_lock_irqsave(substream, flags);
cobsc->hwptr_done_capture += length;
if (cobsc->hwptr_done_capture >=
runtime->buffer_size)
cobsc->hwptr_done_capture -=
runtime->buffer_size;
cobsc->capture_transfer_done += length;
if (cobsc->capture_transfer_done >=
runtime->period_size) {
cobsc->capture_transfer_done -=
runtime->period_size;
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/delay.h`, `media/v4l2-device.h`, `sound/core.h`, `sound/pcm.h`, `cobalt-driver.h`, `cobalt-alsa.h`.
- Detected declarations: `function sample_cpy`, `function cobalt_alsa_announce_pcm_data`, `function alsa_fnc`, `function snd_cobalt_pcm_capture_open`, `function snd_cobalt_pcm_capture_close`, `function snd_cobalt_pcm_prepare`, `function snd_cobalt_pcm_trigger`, `function snd_cobalt_pcm_pointer`, `function pb_sample_cpy`, `function cobalt_alsa_pb_pcm_data`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
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.