drivers/media/usb/stk1160/stk1160-video.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/stk1160/stk1160-video.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/stk1160/stk1160-video.c- Extension
.c- Size
- 12153 bytes
- Lines
- 524
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/usb.hlinux/slab.hlinux/ratelimit.hstk1160.h
Detected Declarations
function print_err_statusfunction stk1160_buffer_donefunction stk1160_copy_videofunction stk1160_process_isocfunction stk1160_isoc_irqfunction stk1160_cancel_isocfunction stk_free_urbfunction stk1160_free_isocfunction stk1160_uninit_isocfunction stk1160_fill_urbfunction stk1160_alloc_isoc
Annotated Snippet
if (offset > buf->length) {
dev_warn_ratelimited(dev->dev, "offset out of bounds\n");
return;
}
if (lencopy > buf->length - offset) {
lencopy = buf->length - offset;
remain = lencopy;
}
/* Check if the copy is done */
if (lencopy == 0 || remain == 0)
return;
if (lencopy < 0) {
printk_ratelimited(KERN_WARNING "stk1160: negative lencopy detected\n");
return;
}
if ((unsigned long)dst + lencopy >
(unsigned long)buf->mem + buf->length) {
printk_ratelimited(KERN_WARNING "stk1160: buffer overflow detected\n");
return;
}
memcpy(dst, src, lencopy);
remain -= lencopy;
buf->bytesused += lencopy;
buf->pos += lencopy;
}
}
/*
* Controls the isoc copy of each urb packet
*/
static void stk1160_process_isoc(struct stk1160 *dev, struct urb *urb)
{
int i, len, status;
u8 *p;
if (!dev) {
stk1160_warn("%s called with null device\n", __func__);
return;
}
if (urb->status < 0) {
/* Print status and drop current packet (or field?) */
print_err_status(dev, -1, urb->status);
return;
}
for (i = 0; i < urb->number_of_packets; i++) {
status = urb->iso_frame_desc[i].status;
if (status < 0) {
print_err_status(dev, i, status);
continue;
}
/* Get packet actual length and pointer to data */
p = urb->transfer_buffer + urb->iso_frame_desc[i].offset;
len = urb->iso_frame_desc[i].actual_length;
/* Empty packet */
if (len <= 4)
continue;
/*
* An 8-byte packet sequence means end of field.
* So if we don't have any packet, we start receiving one now
* and if we do have a packet, then we are done with it.
*
* These end of field packets are always 0xc0 or 0x80,
* but not always 8-byte long so we don't check packet length.
*/
if (p[0] == 0xc0) {
/*
* If first byte is 0xc0 then we received
* second field, and frame has ended.
*/
if (dev->isoc_ctl.buf != NULL)
stk1160_buffer_done(dev);
dev->isoc_ctl.buf = stk1160_next_buffer(dev);
if (dev->isoc_ctl.buf == NULL)
return;
}
/*
* If we don't have a buffer here, then it means we
Annotation
- Immediate include surface: `linux/module.h`, `linux/usb.h`, `linux/slab.h`, `linux/ratelimit.h`, `stk1160.h`.
- Detected declarations: `function print_err_status`, `function stk1160_buffer_done`, `function stk1160_copy_video`, `function stk1160_process_isoc`, `function stk1160_isoc_irq`, `function stk1160_cancel_isoc`, `function stk_free_urb`, `function stk1160_free_isoc`, `function stk1160_uninit_isoc`, `function stk1160_fill_urb`.
- 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.
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.