drivers/media/platform/m2m-deinterlace.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/m2m-deinterlace.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/m2m-deinterlace.c
Extension
.c
Size
26130 bytes
Lines
998
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 deinterlace_fmt {
	u32	fourcc;
	/* Types the format can be used for */
	u32	types;
};

static struct deinterlace_fmt formats[] = {
	{
		.fourcc	= V4L2_PIX_FMT_YUV420,
		.types	= MEM2MEM_CAPTURE | MEM2MEM_OUTPUT,
	},
	{
		.fourcc	= V4L2_PIX_FMT_YUYV,
		.types	= MEM2MEM_CAPTURE | MEM2MEM_OUTPUT,
	},
};

#define NUM_FORMATS ARRAY_SIZE(formats)

/* Per-queue, driver-specific private data */
struct deinterlace_q_data {
	unsigned int		width;
	unsigned int		height;
	unsigned int		sizeimage;
	struct deinterlace_fmt	*fmt;
	enum v4l2_field		field;
};

enum {
	V4L2_M2M_SRC = 0,
	V4L2_M2M_DST = 1,
};

enum {
	YUV420_DMA_Y_ODD,
	YUV420_DMA_Y_EVEN,
	YUV420_DMA_U_ODD,
	YUV420_DMA_U_EVEN,
	YUV420_DMA_V_ODD,
	YUV420_DMA_V_EVEN,
	YUV420_DMA_Y_ODD_DOUBLING,
	YUV420_DMA_U_ODD_DOUBLING,
	YUV420_DMA_V_ODD_DOUBLING,
	YUYV_DMA_ODD,
	YUYV_DMA_EVEN,
	YUYV_DMA_EVEN_DOUBLING,
};

/* Source and destination queue data */
static struct deinterlace_q_data q_data[2];

static struct deinterlace_q_data *get_q_data(enum v4l2_buf_type type)
{
	switch (type) {
	case V4L2_BUF_TYPE_VIDEO_OUTPUT:
		return &q_data[V4L2_M2M_SRC];
	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
		return &q_data[V4L2_M2M_DST];
	default:
		BUG();
	}
	return NULL;
}

static struct deinterlace_fmt *find_format(struct v4l2_format *f)
{
	struct deinterlace_fmt *fmt;
	unsigned int k;

	for (k = 0; k < NUM_FORMATS; k++) {
		fmt = &formats[k];
		if ((fmt->types & f->type) &&
			(fmt->fourcc == f->fmt.pix.pixelformat))
			break;
	}

	if (k == NUM_FORMATS)
		return NULL;

	return &formats[k];
}

struct deinterlace_dev {
	struct v4l2_device	v4l2_dev;
	struct video_device	vfd;

	atomic_t		busy;
	struct mutex		dev_mutex;
	spinlock_t		irqlock;

Annotation

Implementation Notes