drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c- Extension
.c- Size
- 22934 bytes
- Lines
- 862
- 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/container_of.hlinux/device.hlinux/errno.hlinux/kernel.hlinux/limits.hlinux/minmax.hlinux/mutex.hlinux/pm_runtime.hlinux/slab.hlinux/spinlock.hlinux/string.hlinux/types.hlinux/videodev2.hmedia/media-entity.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-event.hmedia/v4l2-fh.hmedia/v4l2-ioctl.hmedia/v4l2-mem2mem.hmedia/videobuf2-core.hmedia/videobuf2-dma-contig.himx8-isi-core.h
Detected Declarations
struct mxc_isi_m2m_bufferstruct mxc_isi_m2m_ctx_queue_datastruct mxc_isi_m2m_ctxfunction to_isi_m2m_bufferfunction mxc_isi_m2m_ctx_qdatafunction mxc_isi_m2m_frame_write_donefunction mxc_isi_m2m_device_runfunction mxc_isi_m2m_vb2_queue_setupfunction mxc_isi_m2m_vb2_buffer_initfunction mxc_isi_m2m_vb2_buffer_preparefunction mxc_isi_m2m_vb2_buffer_queuefunction mxc_isi_m2m_vb2_prepare_streamingfunction mxc_isi_m2m_vb2_start_streamingfunction mxc_isi_m2m_vb2_stop_streamingfunction mxc_isi_m2m_vb2_unprepare_streamingfunction mxc_isi_m2m_queue_initfunction ctrl_to_mxc_isi_m2m_ctxfunction mxc_isi_m2m_ctx_s_ctrlfunction mxc_isi_m2m_ctx_ctrls_createfunction mxc_isi_m2m_ctx_ctrls_deletefunction mxc_isi_m2m_querycapfunction mxc_isi_m2m_enum_fmt_vidfunction __mxc_isi_m2m_try_fmt_vidfunction mxc_isi_m2m_try_fmt_vidfunction mxc_isi_m2m_g_fmt_vidfunction mxc_isi_m2m_s_fmt_vidfunction mxc_isi_m2m_init_formatfunction mxc_isi_m2m_openfunction mxc_isi_m2m_releasefunction mxc_isi_m2m_suspendfunction mxc_isi_m2m_resumefunction mxc_isi_m2m_registerfunction mxc_isi_m2m_unregister
Annotated Snippet
struct mxc_isi_m2m_buffer {
struct v4l2_m2m_buffer buf;
dma_addr_t dma_addrs[3];
};
struct mxc_isi_m2m_ctx_queue_data {
struct v4l2_pix_format_mplane format;
const struct mxc_isi_format_info *info;
u32 sequence;
};
struct mxc_isi_m2m_ctx {
struct v4l2_fh fh;
struct mxc_isi_m2m *m2m;
/* Protects the m2m vb2 queues */
struct mutex vb2_lock;
struct {
struct mxc_isi_m2m_ctx_queue_data out;
struct mxc_isi_m2m_ctx_queue_data cap;
} queues;
struct {
struct v4l2_ctrl_handler handler;
unsigned int alpha;
bool hflip;
bool vflip;
} ctrls;
bool chained;
};
static inline struct mxc_isi_m2m_buffer *
to_isi_m2m_buffer(struct vb2_v4l2_buffer *buf)
{
return container_of(buf, struct mxc_isi_m2m_buffer, buf.vb);
}
static inline struct mxc_isi_m2m_ctx *file_to_isi_m2m_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct mxc_isi_m2m_ctx, fh);
}
static inline struct mxc_isi_m2m_ctx_queue_data *
mxc_isi_m2m_ctx_qdata(struct mxc_isi_m2m_ctx *ctx, enum v4l2_buf_type type)
{
if (V4L2_TYPE_IS_OUTPUT(type))
return &ctx->queues.out;
else
return &ctx->queues.cap;
}
/* -----------------------------------------------------------------------------
* V4L2 M2M device operations
*/
static void mxc_isi_m2m_frame_write_done(struct mxc_isi_pipe *pipe, u32 status)
{
struct mxc_isi_m2m *m2m = &pipe->isi->m2m;
struct vb2_v4l2_buffer *src_vbuf, *dst_vbuf;
struct mxc_isi_m2m_ctx *ctx;
ctx = v4l2_m2m_get_curr_priv(m2m->m2m_dev);
if (!ctx) {
dev_err(m2m->isi->dev,
"Instance released before the end of transaction\n");
return;
}
src_vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
dst_vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
v4l2_m2m_buf_copy_metadata(src_vbuf, dst_vbuf);
src_vbuf->sequence = ctx->queues.out.sequence++;
dst_vbuf->sequence = ctx->queues.cap.sequence++;
v4l2_m2m_buf_done(src_vbuf, VB2_BUF_STATE_DONE);
v4l2_m2m_buf_done(dst_vbuf, VB2_BUF_STATE_DONE);
v4l2_m2m_job_finish(m2m->m2m_dev, ctx->fh.m2m_ctx);
}
static void mxc_isi_m2m_device_run(void *priv)
{
struct mxc_isi_m2m_ctx *ctx = priv;
struct mxc_isi_m2m *m2m = ctx->m2m;
struct vb2_v4l2_buffer *src_vbuf, *dst_vbuf;
struct mxc_isi_m2m_buffer *src_buf, *dst_buf;
Annotation
- Immediate include surface: `linux/container_of.h`, `linux/device.h`, `linux/errno.h`, `linux/kernel.h`, `linux/limits.h`, `linux/minmax.h`, `linux/mutex.h`, `linux/pm_runtime.h`.
- Detected declarations: `struct mxc_isi_m2m_buffer`, `struct mxc_isi_m2m_ctx_queue_data`, `struct mxc_isi_m2m_ctx`, `function to_isi_m2m_buffer`, `function mxc_isi_m2m_ctx_qdata`, `function mxc_isi_m2m_frame_write_done`, `function mxc_isi_m2m_device_run`, `function mxc_isi_m2m_vb2_queue_setup`, `function mxc_isi_m2m_vb2_buffer_init`, `function mxc_isi_m2m_vb2_buffer_prepare`.
- 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.