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.

Dependency Surface

Detected Declarations

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

Implementation Notes