drivers/media/usb/hdpvr/hdpvr-video.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/hdpvr/hdpvr-video.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/hdpvr/hdpvr-video.c- Extension
.c- Size
- 31892 bytes
- Lines
- 1259
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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
linux/kernel.hlinux/errno.hlinux/init.hlinux/slab.hlinux/module.hlinux/uaccess.hlinux/usb.hlinux/mutex.hlinux/workqueue.hlinux/videodev2.hlinux/v4l2-dv-timings.hmedia/v4l2-dev.hmedia/v4l2-common.hmedia/v4l2-dv-timings.hmedia/v4l2-ioctl.hmedia/v4l2-event.hhdpvr.h
Detected Declarations
struct hdpvr_fhfunction Copyrightfunction list_sizefunction list_for_eachfunction hdpvr_read_bulk_callbackfunction hdpvr_cancel_queuefunction list_for_each_entryfunction hdpvr_free_queuefunction hdpvr_free_buffersfunction hdpvr_alloc_buffersfunction hdpvr_submit_buffersfunction hdpvr_transmit_buffersfunction hdpvr_start_streamingfunction hdpvr_stop_streamingfunction usb_rcvbulkpipefunction hdpvr_openfunction hdpvr_releasefunction hdpvr_v4l2_readfunction hdpvr_pollfunction vidioc_querycapfunction vidioc_s_stdfunction vidioc_g_stdfunction vidioc_querystdfunction vidioc_s_dv_timingsfunction vidioc_g_dv_timingsfunction vidioc_query_dv_timingsfunction vidioc_enum_dv_timingsfunction vidioc_dv_timings_capfunction vidioc_enum_inputfunction vidioc_s_inputfunction vidioc_g_inputfunction vidioc_enumaudiofunction vidioc_s_audiofunction vidioc_g_audiofunction hdpvr_try_ctrlfunction hdpvr_s_ctrlfunction vidioc_enum_fmt_vid_capfunction vidioc_g_fmt_vid_capfunction formatfunction vidioc_encoder_cmdfunction vidioc_try_encoder_cmdfunction hdpvr_device_releasefunction hdpvr_register_videodev
Annotated Snippet
struct hdpvr_fh {
struct v4l2_fh fh;
bool legacy_mode;
};
static inline struct hdpvr_fh *file_to_hdpvr_fh(struct file *file)
{
return container_of(file_to_v4l2_fh(file), struct hdpvr_fh, fh);
}
static uint list_size(struct list_head *list)
{
struct list_head *tmp;
uint count = 0;
list_for_each(tmp, list) {
count++;
}
return count;
}
/*=========================================================================*/
/* urb callback */
static void hdpvr_read_bulk_callback(struct urb *urb)
{
struct hdpvr_buffer *buf = (struct hdpvr_buffer *)urb->context;
struct hdpvr_device *dev = buf->dev;
/* marking buffer as received and wake waiting */
buf->status = BUFSTAT_READY;
wake_up_interruptible(&dev->wait_data);
}
/*=========================================================================*/
/* buffer bits */
/* function expects dev->io_mutex to be hold by caller */
int hdpvr_cancel_queue(struct hdpvr_device *dev)
{
struct hdpvr_buffer *buf;
list_for_each_entry(buf, &dev->rec_buff_list, buff_list) {
usb_kill_urb(buf->urb);
buf->status = BUFSTAT_AVAILABLE;
}
list_splice_init(&dev->rec_buff_list, dev->free_buff_list.prev);
return 0;
}
static int hdpvr_free_queue(struct list_head *q)
{
struct list_head *tmp;
struct list_head *p;
struct hdpvr_buffer *buf;
struct urb *urb;
for (p = q->next; p != q;) {
buf = list_entry(p, struct hdpvr_buffer, buff_list);
urb = buf->urb;
usb_free_coherent(urb->dev, urb->transfer_buffer_length,
urb->transfer_buffer, urb->transfer_dma);
usb_free_urb(urb);
tmp = p->next;
list_del(p);
kfree(buf);
p = tmp;
}
return 0;
}
/* function expects dev->io_mutex to be hold by caller */
int hdpvr_free_buffers(struct hdpvr_device *dev)
{
hdpvr_cancel_queue(dev);
hdpvr_free_queue(&dev->free_buff_list);
hdpvr_free_queue(&dev->rec_buff_list);
return 0;
}
/* function expects dev->io_mutex to be hold by caller */
int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count)
{
uint i;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/init.h`, `linux/slab.h`, `linux/module.h`, `linux/uaccess.h`, `linux/usb.h`, `linux/mutex.h`.
- Detected declarations: `struct hdpvr_fh`, `function Copyright`, `function list_size`, `function list_for_each`, `function hdpvr_read_bulk_callback`, `function hdpvr_cancel_queue`, `function list_for_each_entry`, `function hdpvr_free_queue`, `function hdpvr_free_buffers`, `function hdpvr_alloc_buffers`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.