drivers/media/platform/nxp/imx7-media-csi.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/nxp/imx7-media-csi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/nxp/imx7-media-csi.c- Extension
.c- Size
- 59472 bytes
- Lines
- 2289
- 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/clk.hlinux/completion.hlinux/container_of.hlinux/delay.hlinux/device.hlinux/dma-mapping.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/jiffies.hlinux/kernel.hlinux/list.hlinux/math.hlinux/minmax.hlinux/module.hlinux/mutex.hlinux/of.hlinux/platform_device.hlinux/property.hlinux/slab.hlinux/spinlock.hlinux/string.hlinux/timekeeping.hlinux/types.hmedia/media-device.hmedia/media-entity.hmedia/v4l2-async.hmedia/v4l2-common.hmedia/v4l2-dev.hmedia/v4l2-device.hmedia/v4l2-fh.hmedia/v4l2-ioctl.h
Detected Declarations
struct imx7_csi_pixfmtstruct imx7_csi_vb2_bufferstruct imx7_csi_dma_bufstruct imx7_csienum imx_csi_modelfunction to_imx7_csi_vb2_bufferfunction imx7_csi_notifier_to_devfunction imx7_csi_reg_readfunction imx7_csi_reg_writefunction imx7_csi_irq_clearfunction imx7_csi_init_defaultfunction imx7_csi_hw_enable_irqfunction imx7_csi_hw_disable_irqfunction imx7_csi_hw_enablefunction imx7_csi_hw_disablefunction imx7_csi_dma_reflashfunction imx7_csi_rx_fifo_clearfunction imx7_csi_dmareq_rff_enablefunction imx7_csi_dmareq_rff_disablefunction imx7_csi_update_buffunction imx7_csi_setup_vb2_buffunction imx7_csi_dma_unsetup_vb2_buffunction imx7_csi_free_dma_buffunction imx7_csi_alloc_dma_buffunction imx7_csi_dma_setupfunction imx7_csi_dma_cleanupfunction imx7_csi_dma_stopfunction imx7_csi_configurefunction imx7_csi_initfunction imx7_csi_deinitfunction imx7_csi_baseaddr_switch_on_second_framefunction imx7_csi_enablefunction imx7_csi_disablefunction imx7_csi_error_recoveryfunction imx7_csi_vb2_buf_donefunction imx7_csi_irq_handlerfunction imx7_csi_enum_mbus_formatsfunction imx7_csi_video_querycapfunction imx7_csi_video_enum_fmt_vid_capfunction imx7_csi_video_enum_framesizesfunction imx7_csi_video_g_fmt_vid_capfunction __imx7_csi_video_try_fmtfunction imx7_csi_video_try_fmt_vid_capfunction imx7_csi_video_s_fmt_vid_capfunction imx7_csi_video_g_selectionfunction imx7_csi_video_queue_setupfunction imx7_csi_video_buf_initfunction imx7_csi_video_buf_prepare
Annotated Snippet
struct imx7_csi_pixfmt {
/* the in-memory FourCC pixel format */
u32 fourcc;
/*
* the set of equivalent media bus codes for the fourcc.
* NOTE! codes pointer is NULL for in-memory-only formats.
*/
const u32 *codes;
int bpp; /* total bpp */
bool yuv;
};
struct imx7_csi_vb2_buffer {
struct vb2_v4l2_buffer vbuf;
struct list_head list;
};
static inline struct imx7_csi_vb2_buffer *
to_imx7_csi_vb2_buffer(struct vb2_buffer *vb)
{
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
return container_of(vbuf, struct imx7_csi_vb2_buffer, vbuf);
}
struct imx7_csi_dma_buf {
void *virt;
dma_addr_t dma_addr;
unsigned long len;
};
struct imx7_csi {
struct device *dev;
/* Resources and locks */
void __iomem *regbase;
int irq;
struct clk *mclk;
spinlock_t irqlock; /* Protects last_eof */
/* Media and V4L2 device */
struct media_device mdev;
struct v4l2_device v4l2_dev;
struct v4l2_async_notifier notifier;
struct media_pipeline pipe;
struct v4l2_subdev *src_sd;
bool is_csi2;
/* V4L2 subdev */
struct v4l2_subdev sd;
struct media_pad pad[IMX7_CSI_PADS_NUM];
/* Video device */
struct video_device *vdev; /* Video device */
struct media_pad vdev_pad; /* Video device pad */
struct v4l2_pix_format vdev_fmt; /* The user format */
const struct imx7_csi_pixfmt *vdev_cc;
struct v4l2_rect vdev_compose; /* The compose rectangle */
struct mutex vdev_mutex; /* Protect vdev operations */
struct vb2_queue q; /* The videobuf2 queue */
struct list_head ready_q; /* List of queued buffers */
spinlock_t q_lock; /* Protect ready_q */
/* Buffers and streaming state */
struct imx7_csi_vb2_buffer *active_vb2_buf[2];
struct imx7_csi_dma_buf underrun_buf;
bool is_streaming;
int buf_num;
u32 frame_sequence;
bool last_eof;
struct completion last_eof_completion;
enum imx_csi_model model;
};
static struct imx7_csi *
imx7_csi_notifier_to_dev(struct v4l2_async_notifier *n)
{
return container_of(n, struct imx7_csi, notifier);
}
/* -----------------------------------------------------------------------------
* Hardware Configuration
Annotation
- Immediate include surface: `linux/clk.h`, `linux/completion.h`, `linux/container_of.h`, `linux/delay.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/interrupt.h`.
- Detected declarations: `struct imx7_csi_pixfmt`, `struct imx7_csi_vb2_buffer`, `struct imx7_csi_dma_buf`, `struct imx7_csi`, `enum imx_csi_model`, `function to_imx7_csi_vb2_buffer`, `function imx7_csi_notifier_to_dev`, `function imx7_csi_reg_read`, `function imx7_csi_reg_write`, `function imx7_csi_irq_clear`.
- 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.