drivers/media/usb/au0828/au0828-video.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/au0828/au0828-video.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/au0828/au0828-video.c- Extension
.c- Size
- 53993 bytes
- Lines
- 2061
- 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.
- 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
au0828.hau8522.hlinux/module.hlinux/slab.hlinux/init.hlinux/device.hmedia/v4l2-common.hmedia/v4l2-mc.hmedia/v4l2-ioctl.hmedia/v4l2-event.hmedia/tuner.hau0828-reg.h
Detected Declarations
function i2c_gate_ctrlfunction print_err_statusfunction check_devfunction au0828_irq_callbackfunction au0828_uninit_isocfunction au0828_init_isocfunction buffer_filledfunction au0828_copy_videofunction get_next_buffunction au0828_copy_vbifunction vbi_get_next_buffunction au0828_isoc_copyfunction au0828_usb_v4l2_media_releasefunction au0828_usb_v4l2_releasefunction au0828_v4l2_device_registerfunction queue_setupfunction buffer_preparefunction buffer_queuefunction au0828_i2s_initfunction au0828_analog_stream_enablefunction au0828_analog_stream_disablefunction au0828_analog_stream_resetfunction au0828_stream_interruptfunction au0828_start_analog_streamingfunction au0828_stop_streamingfunction au0828_stop_vbi_streamingfunction au0828_analog_unregisterfunction au0828_vid_buffer_timeoutfunction au0828_vbi_buffer_timeoutfunction au0828_v4l2_openfunction au0828_v4l2_closefunction au0828_init_tunerfunction au0828_set_formatfunction vidioc_querycapfunction vidioc_enum_fmt_vid_capfunction vidioc_g_fmt_vid_capfunction vidioc_try_fmt_vid_capfunction vidioc_s_fmt_vid_capfunction vidioc_s_stdfunction vidioc_g_stdfunction vidioc_enum_inputfunction vidioc_g_inputfunction au0828_s_inputfunction vidioc_s_inputfunction vidioc_enumaudiofunction vidioc_g_audiofunction vidioc_s_audiofunction vidioc_g_tuner
Annotated Snippet
if (urb) {
if (!irqs_disabled())
usb_kill_urb(urb);
else
usb_unlink_urb(urb);
if (dev->isoc_ctl.transfer_buffer[i]) {
usb_free_coherent(dev->usbdev,
urb->transfer_buffer_length,
dev->isoc_ctl.transfer_buffer[i],
urb->transfer_dma);
}
usb_free_urb(urb);
dev->isoc_ctl.urb[i] = NULL;
}
dev->isoc_ctl.transfer_buffer[i] = NULL;
}
kfree(dev->isoc_ctl.urb);
kfree(dev->isoc_ctl.transfer_buffer);
dev->isoc_ctl.urb = NULL;
dev->isoc_ctl.transfer_buffer = NULL;
dev->isoc_ctl.num_bufs = 0;
dev->stream_state = STREAM_OFF;
}
/*
* Allocate URBs and start IRQ
*/
static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
int num_bufs, int max_pkt_size,
int (*isoc_copy) (struct au0828_dev *dev, struct urb *urb))
{
struct au0828_dmaqueue *dma_q = &dev->vidq;
int i;
int sb_size, pipe;
struct urb *urb;
int j, k;
int rc;
au0828_isocdbg("au0828: called au0828_prepare_isoc\n");
dev->isoc_ctl.isoc_copy = isoc_copy;
dev->isoc_ctl.num_bufs = num_bufs;
dev->isoc_ctl.urb = kcalloc(num_bufs, sizeof(void *), GFP_KERNEL);
if (!dev->isoc_ctl.urb) {
au0828_isocdbg("cannot alloc memory for usb buffers\n");
return -ENOMEM;
}
dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs, sizeof(void *),
GFP_KERNEL);
if (!dev->isoc_ctl.transfer_buffer) {
au0828_isocdbg("cannot allocate memory for usb transfer\n");
kfree(dev->isoc_ctl.urb);
return -ENOMEM;
}
dev->isoc_ctl.max_pkt_size = max_pkt_size;
dev->isoc_ctl.buf = NULL;
sb_size = max_packets * dev->isoc_ctl.max_pkt_size;
/* allocate urbs and transfer buffers */
for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
urb = usb_alloc_urb(max_packets, GFP_KERNEL);
if (!urb) {
au0828_isocdbg("cannot allocate URB\n");
au0828_uninit_isoc(dev);
return -ENOMEM;
}
dev->isoc_ctl.urb[i] = urb;
dev->isoc_ctl.transfer_buffer[i] = usb_alloc_coherent(dev->usbdev,
sb_size, GFP_KERNEL, &urb->transfer_dma);
if (!dev->isoc_ctl.transfer_buffer[i]) {
au0828_isocdbg("cannot allocate transfer buffer\n");
au0828_uninit_isoc(dev);
return -ENOMEM;
}
memset(dev->isoc_ctl.transfer_buffer[i], 0, sb_size);
pipe = usb_rcvisocpipe(dev->usbdev,
dev->isoc_in_endpointaddr);
usb_fill_int_urb(urb, dev->usbdev, pipe,
dev->isoc_ctl.transfer_buffer[i], sb_size,
Annotation
- Immediate include surface: `au0828.h`, `au8522.h`, `linux/module.h`, `linux/slab.h`, `linux/init.h`, `linux/device.h`, `media/v4l2-common.h`, `media/v4l2-mc.h`.
- Detected declarations: `function i2c_gate_ctrl`, `function print_err_status`, `function check_dev`, `function au0828_irq_callback`, `function au0828_uninit_isoc`, `function au0828_init_isoc`, `function buffer_filled`, `function au0828_copy_video`, `function get_next_buf`, `function au0828_copy_vbi`.
- 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.