drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c- Extension
.c- Size
- 32701 bytes
- Lines
- 1263
- 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.
- 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/slab.hpvrusb2-context.hpvrusb2-hdw.hpvrusb2.hpvrusb2-debug.hpvrusb2-v4l2.hpvrusb2-ioread.hlinux/videodev2.hlinux/module.hmedia/v4l2-dev.hmedia/v4l2-device.hmedia/v4l2-fh.hmedia/v4l2-common.hmedia/v4l2-ioctl.h
Detected Declarations
struct pvr2_v4l2struct pvr2_v4l2_devstruct pvr2_v4l2_fhstruct pvr2_v4l2function pvr2_querycapfunction pvr2_g_stdfunction pvr2_s_stdfunction pvr2_querystdfunction pvr2_enum_inputfunction pvr2_g_inputfunction pvr2_s_inputfunction pvr2_enumaudiofunction pvr2_g_audiofunction pvr2_s_audiofunction pvr2_g_tunerfunction pvr2_s_tunerfunction pvr2_s_frequencyfunction pvr2_g_frequencyfunction pvr2_enum_fmt_vid_capfunction pvr2_g_fmt_vid_capfunction pvr2_try_fmt_vid_capfunction pvr2_s_fmt_vid_capfunction pvr2_streamonfunction pvr2_streamofffunction pvr2_query_ext_ctrlfunction pvr2_querymenufunction pvr2_g_ext_ctrlsfunction pvr2_s_ext_ctrlsfunction pvr2_try_ext_ctrlsfunction pvr2_g_pixelaspectfunction pvr2_g_selectionfunction pvr2_s_selectionfunction pvr2_log_statusfunction pvr2_v4l2_dev_destroyfunction pvr2_v4l2_dev_disassociate_parentfunction pvr2_v4l2_destroy_no_lockfunction pvr2_video_device_releasefunction pvr2_v4l2_internal_checkfunction pvr2_v4l2_releasefunction list_emptyfunction pvr2_v4l2_openfunction pvr2_v4l2_notifyfunction pvr2_v4l2_iosetupfunction pvr2_v4l2_readfunction pvr2_v4l2_pollfunction pvr2_v4l2_dev_init
Annotated Snippet
struct pvr2_v4l2_dev {
struct video_device devbase; /* MUST be first! */
struct pvr2_v4l2 *v4lp;
struct pvr2_context_stream *stream;
/* Information about this device: */
enum pvr2_config config; /* Expected stream format */
int v4l_type; /* V4L defined type for this device node */
enum pvr2_v4l_type minor_type; /* pvr2-understood minor device type */
};
struct pvr2_v4l2_fh {
struct v4l2_fh fh;
struct pvr2_channel channel;
struct pvr2_v4l2_dev *pdi;
struct pvr2_ioread *rhp;
struct file *file;
wait_queue_head_t wait_data;
int fw_mode_flag;
/* Map contiguous ordinal value to input id */
unsigned char *input_map;
unsigned int input_cnt;
};
static inline struct pvr2_v4l2_fh *to_pvr2_v4l2_fh(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct pvr2_v4l2_fh, fh);
}
struct pvr2_v4l2 {
struct pvr2_channel channel;
/* streams - Note that these must be separately, individually,
* allocated pointers. This is because the v4l core is going to
* manage their deletion - separately, individually... */
struct pvr2_v4l2_dev *dev_video;
struct pvr2_v4l2_dev *dev_radio;
};
static int video_nr[PVR_NUM] = {[0 ... PVR_NUM-1] = -1};
module_param_array(video_nr, int, NULL, 0444);
MODULE_PARM_DESC(video_nr, "Offset for device's video dev minor");
static int radio_nr[PVR_NUM] = {[0 ... PVR_NUM-1] = -1};
module_param_array(radio_nr, int, NULL, 0444);
MODULE_PARM_DESC(radio_nr, "Offset for device's radio dev minor");
static int vbi_nr[PVR_NUM] = {[0 ... PVR_NUM-1] = -1};
module_param_array(vbi_nr, int, NULL, 0444);
MODULE_PARM_DESC(vbi_nr, "Offset for device's vbi dev minor");
#define PVR_FORMAT_PIX 0
#define PVR_FORMAT_VBI 1
static struct v4l2_format pvr_format [] = {
[PVR_FORMAT_PIX] = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.fmt = {
.pix = {
.width = 720,
.height = 576,
.pixelformat = V4L2_PIX_FMT_MPEG,
.field = V4L2_FIELD_INTERLACED,
/* FIXME : Don't know what to put here... */
.sizeimage = 32 * 1024,
}
}
},
[PVR_FORMAT_VBI] = {
.type = V4L2_BUF_TYPE_VBI_CAPTURE,
.fmt = {
.vbi = {
.sampling_rate = 27000000,
.offset = 248,
.samples_per_line = 1443,
.sample_format = V4L2_PIX_FMT_GREY,
.start = { 0, 0 },
.count = { 0, 0 },
.flags = 0,
}
}
}
};
/*
* This is part of Video 4 Linux API. These procedures handle ioctl() calls.
*/
static int pvr2_querycap(struct file *file, void *priv, struct v4l2_capability *cap)
{
struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `pvrusb2-context.h`, `pvrusb2-hdw.h`, `pvrusb2.h`, `pvrusb2-debug.h`, `pvrusb2-v4l2.h`, `pvrusb2-ioread.h`.
- Detected declarations: `struct pvr2_v4l2`, `struct pvr2_v4l2_dev`, `struct pvr2_v4l2_fh`, `struct pvr2_v4l2`, `function pvr2_querycap`, `function pvr2_g_std`, `function pvr2_s_std`, `function pvr2_querystd`, `function pvr2_enum_input`, `function pvr2_g_input`.
- 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.
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.