drivers/media/platform/nxp/mx2_emmaprp.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/nxp/mx2_emmaprp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/nxp/mx2_emmaprp.c- Extension
.c- Size
- 23939 bytes
- Lines
- 906
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/clk.hlinux/slab.hlinux/interrupt.hlinux/io.hlinux/platform_device.hmedia/v4l2-mem2mem.hmedia/v4l2-device.hmedia/v4l2-ioctl.hmedia/videobuf2-dma-contig.hlinux/sizes.h
Detected Declarations
struct emmaprp_fmtstruct emmaprp_q_datastruct emmaprp_devstruct emmaprp_ctxfunction emmaprp_job_abortfunction emmaprp_dump_regsfunction emmaprp_device_runfunction emmaprp_irqfunction 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 emmaprp_queue_setupfunction emmaprp_buf_preparefunction emmaprp_buf_queuefunction queue_initfunction emmaprp_openfunction emmaprp_releasefunction emmaprp_probefunction emmaprp_remove
Annotated Snippet
struct emmaprp_fmt {
u32 fourcc;
/* Types the format can be used for */
u32 types;
};
static struct emmaprp_fmt formats[] = {
{
.fourcc = V4L2_PIX_FMT_YUV420,
.types = MEM2MEM_CAPTURE,
},
{
.fourcc = V4L2_PIX_FMT_YUYV,
.types = MEM2MEM_OUTPUT,
},
};
/* Per-queue, driver-specific private data */
struct emmaprp_q_data {
unsigned int width;
unsigned int height;
unsigned int sizeimage;
struct emmaprp_fmt *fmt;
};
enum {
V4L2_M2M_SRC = 0,
V4L2_M2M_DST = 1,
};
#define NUM_FORMATS ARRAY_SIZE(formats)
static struct emmaprp_fmt *find_format(struct v4l2_format *f)
{
struct emmaprp_fmt *fmt;
unsigned int k;
for (k = 0; k < NUM_FORMATS; k++) {
fmt = &formats[k];
if (fmt->fourcc == f->fmt.pix.pixelformat)
break;
}
if (k == NUM_FORMATS)
return NULL;
return &formats[k];
}
struct emmaprp_dev {
struct v4l2_device v4l2_dev;
struct video_device *vfd;
struct mutex dev_mutex;
spinlock_t irqlock;
void __iomem *base_emma;
struct clk *clk_emma_ahb, *clk_emma_ipg;
struct v4l2_m2m_dev *m2m_dev;
};
struct emmaprp_ctx {
struct v4l2_fh fh;
struct emmaprp_dev *dev;
/* Abort requested by m2m */
int aborting;
struct emmaprp_q_data q_data[2];
};
static inline struct emmaprp_ctx *file_to_emmaprp_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct emmaprp_ctx, fh);
}
static struct emmaprp_q_data *get_q_data(struct emmaprp_ctx *ctx,
enum v4l2_buf_type type)
{
switch (type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
return &(ctx->q_data[V4L2_M2M_SRC]);
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
return &(ctx->q_data[V4L2_M2M_DST]);
default:
BUG();
}
return NULL;
}
/*
Annotation
- Immediate include surface: `linux/module.h`, `linux/clk.h`, `linux/slab.h`, `linux/interrupt.h`, `linux/io.h`, `linux/platform_device.h`, `media/v4l2-mem2mem.h`, `media/v4l2-device.h`.
- Detected declarations: `struct emmaprp_fmt`, `struct emmaprp_q_data`, `struct emmaprp_dev`, `struct emmaprp_ctx`, `function emmaprp_job_abort`, `function emmaprp_dump_regs`, `function emmaprp_device_run`, `function emmaprp_irq`, `function vidioc_querycap`, `function enum_fmt`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.