sound/usb/usx2y/us144mkii_capture.c
Source file repositories/reference/linux-study-clean/sound/usb/usx2y/us144mkii_capture.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/usx2y/us144mkii_capture.c- Extension
.c- Size
- 8845 bytes
- Lines
- 320
- Domain
- Driver Families
- Bucket
- sound/usb
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
us144mkii.h
Detected Declarations
function tascam_capture_openfunction tascam_capture_closefunction tascam_capture_preparefunction tascam_capture_pointerfunction scoped_guardfunction decode_tascam_capture_blockfunction tascam_capture_work_handlerfunction scoped_guardfunction scoped_guardfunction capture_urb_complete
Annotated Snippet
scoped_guard(spinlock_irqsave, &tascam->lock) {
write_ptr = tascam->capture_ring_buffer_write_ptr;
read_ptr = tascam->capture_ring_buffer_read_ptr;
available_data = (write_ptr >= read_ptr) ?
(write_ptr - read_ptr) :
(CAPTURE_RING_BUFFER_SIZE -
read_ptr + write_ptr);
can_process =
(available_data >= RAW_BYTES_PER_DECODE_BLOCK);
if (can_process) {
size_t bytes_to_end =
CAPTURE_RING_BUFFER_SIZE - read_ptr;
if (bytes_to_end >=
RAW_BYTES_PER_DECODE_BLOCK) {
memcpy(raw_block,
tascam->capture_ring_buffer +
read_ptr,
RAW_BYTES_PER_DECODE_BLOCK);
} else {
memcpy(raw_block,
tascam->capture_ring_buffer +
read_ptr,
bytes_to_end);
memcpy(raw_block + bytes_to_end,
tascam->capture_ring_buffer,
RAW_BYTES_PER_DECODE_BLOCK -
bytes_to_end);
}
tascam->capture_ring_buffer_read_ptr =
(read_ptr +
RAW_BYTES_PER_DECODE_BLOCK) %
CAPTURE_RING_BUFFER_SIZE;
}
}
if (!can_process)
break;
decode_tascam_capture_block(raw_block, decoded_block);
process_capture_routing_us144mkii(tascam, decoded_block,
routed_block);
scoped_guard(spinlock_irqsave, &tascam->lock) {
if (atomic_read(&tascam->capture_active)) {
int f;
for (f = 0; f < FRAMES_PER_DECODE_BLOCK; ++f) {
u8 *dst_frame_start =
runtime->dma_area +
frames_to_bytes(
runtime,
tascam->driver_capture_pos);
s32 *routed_frame_start =
routed_block +
(f * NUM_CHANNELS);
int c;
for (c = 0; c < NUM_CHANNELS; c++) {
u8 *dst_channel =
dst_frame_start +
(c * BYTES_PER_SAMPLE);
s32 *src_channel_s32 =
routed_frame_start + c;
memcpy(dst_channel,
((char *)src_channel_s32) +
1,
3);
}
tascam->driver_capture_pos =
(tascam->driver_capture_pos +
1) %
runtime->buffer_size;
}
}
}
}
}
void capture_urb_complete(struct urb *urb)
{
struct tascam_card *tascam = urb->context;
int ret;
if (urb->status) {
if (urb->status != -ENOENT && urb->status != -ECONNRESET &&
urb->status != -ESHUTDOWN && urb->status != -ENODEV &&
urb->status != -EPROTO)
Annotation
- Immediate include surface: `us144mkii.h`.
- Detected declarations: `function tascam_capture_open`, `function tascam_capture_close`, `function tascam_capture_prepare`, `function tascam_capture_pointer`, `function scoped_guard`, `function decode_tascam_capture_block`, `function tascam_capture_work_handler`, `function scoped_guard`, `function scoped_guard`, `function capture_urb_complete`.
- Atlas domain: Driver Families / sound/usb.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.