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.
- 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
linux/module.hlinux/slab.hlinux/interrupt.hlinux/dmaengine.hlinux/platform_device.hmedia/v4l2-mem2mem.hmedia/v4l2-device.hmedia/v4l2-ioctl.hmedia/videobuf2-dma-contig.h
Detected Declarations
struct deinterlace_fmtstruct deinterlace_q_datastruct deinterlace_devstruct deinterlace_ctxfunction deinterlace_job_readyfunction deinterlace_job_abortfunction dma_callbackfunction deinterlace_issue_dmafunction deinterlace_device_runfunction vidioc_querycapfunction enum_fmtfunction vidioc_enum_fmt_vid_capfunction vidioc_enum_fmt_vid_outfunction vidioc_g_fmtfunction vidioc_g_fmt_vid_outfunction vidioc_g_fmt_vid_capfunction vidioc_try_fmtfunction vidioc_try_fmt_vid_capfunction vidioc_try_fmt_vid_outfunction vidioc_s_fmtfunction vidioc_s_fmt_vid_capfunction vidioc_s_fmt_vid_outfunction vidioc_streamonfunction deinterlace_queue_setupfunction deinterlace_buf_preparefunction deinterlace_buf_queuefunction queue_initfunction deinterlace_openfunction deinterlace_releasefunction deinterlace_probefunction deinterlace_remove
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
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/interrupt.h`, `linux/dmaengine.h`, `linux/platform_device.h`, `media/v4l2-mem2mem.h`, `media/v4l2-device.h`, `media/v4l2-ioctl.h`.
- Detected declarations: `struct deinterlace_fmt`, `struct deinterlace_q_data`, `struct deinterlace_dev`, `struct deinterlace_ctx`, `function deinterlace_job_ready`, `function deinterlace_job_abort`, `function dma_callback`, `function deinterlace_issue_dma`, `function deinterlace_device_run`, `function vidioc_querycap`.
- 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.