drivers/staging/media/imx/imx-media-csi.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/imx/imx-media-csi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/imx/imx-media-csi.c- Extension
.c- Size
- 53976 bytes
- Lines
- 2096
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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/delay.hlinux/gcd.hlinux/interrupt.hlinux/module.hlinux/of_graph.hlinux/pinctrl/consumer.hlinux/platform_device.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-event.hmedia/v4l2-fwnode.hmedia/v4l2-mc.hmedia/v4l2-subdev.hmedia/videobuf2-dma-contig.hvideo/imx-ipu-v3.hmedia/imx.himx-media.h
Detected Declarations
struct csi_skip_descstruct csi_privfunction is_parallel_busfunction is_parallel_16bit_busfunction requires_passthroughfunction csi_get_upstream_mbus_configfunction csi_idmac_put_ipu_resourcesfunction csi_idmac_get_ipu_resourcesfunction csi_vb2_buf_donefunction csi_idmac_eof_interruptfunction csi_idmac_nfb4eof_interruptfunction csi_idmac_eof_timeoutfunction csi_idmac_setup_vb2_buffunction csi_idmac_unsetup_vb2_buffunction csi_idmac_setup_channelfunction csi_idmac_unsetupfunction csi_idmac_setupfunction csi_idmac_startfunction csi_idmac_wait_last_eoffunction csi_idmac_stopfunction csi_setupfunction csi_set_srcfunction csi_startfunction csi_stopfunction csi_apply_skip_intervalfunction csi_get_frame_intervalfunction csi_set_frame_intervalfunction csi_s_streamfunction csi_link_setupfunction csi_link_validatefunction __csi_get_fmtfunction __csi_get_cropfunction __csi_get_composefunction csi_try_cropfunction csi_enum_mbus_codefunction csi_enum_frame_sizefunction csi_enum_frame_intervalfunction csi_get_fmtfunction csi_try_fieldfunction csi_try_fmtfunction csi_set_fmtfunction csi_get_selectionfunction csi_set_scalefunction csi_set_selectionfunction csi_subscribe_eventfunction csi_registeredfunction csi_unregisteredfunction csi_get_fwnode_pad
Annotated Snippet
struct csi_skip_desc {
u8 keep;
u8 max_ratio;
u8 skip_smfc;
};
struct csi_priv {
struct device *dev;
struct ipu_soc *ipu;
struct v4l2_subdev sd;
struct media_pad pad[CSI_NUM_PADS];
struct v4l2_async_notifier notifier;
/* the video device at IDMAC output pad */
struct imx_media_video_dev *vdev;
struct imx_media_fim *fim;
int csi_id;
int smfc_id;
/* lock to protect all members below */
struct mutex lock;
int active_output_pad;
struct ipuv3_channel *idmac_ch;
struct ipu_smfc *smfc;
struct ipu_csi *csi;
struct v4l2_mbus_framefmt format_mbus[CSI_NUM_PADS];
const struct imx_media_pixfmt *cc[CSI_NUM_PADS];
struct v4l2_fract frame_interval[CSI_NUM_PADS];
struct v4l2_rect crop;
struct v4l2_rect compose;
const struct csi_skip_desc *skip;
/* active vb2 buffers to send to video dev sink */
struct imx_media_buffer *active_vb2_buf[2];
struct imx_media_dma_buf underrun_buf;
int ipu_buf_num; /* ipu double buffer index: 0-1 */
/* the sink for the captured frames */
struct media_entity *sink;
enum ipu_csi_dest dest;
/* the source subdev */
struct v4l2_subdev *src_sd;
/* the mipi virtual channel number at link validate */
int vc_num;
spinlock_t irqlock; /* protect eof_irq handler */
struct timer_list eof_timeout_timer;
int eof_irq;
int nfb4eof_irq;
struct v4l2_ctrl_handler ctrl_hdlr;
int stream_count; /* streaming counter */
u32 frame_sequence; /* frame sequence counter */
bool last_eof; /* waiting for last EOF at stream off */
bool nfb4eof; /* NFB4EOF encountered during streaming */
bool interweave_swap; /* swap top/bottom lines when interweaving */
struct completion last_eof_comp;
};
static inline struct csi_priv *sd_to_dev(struct v4l2_subdev *sdev)
{
return container_of(sdev, struct csi_priv, sd);
}
static inline struct csi_priv *notifier_to_dev(struct v4l2_async_notifier *n)
{
return container_of(n, struct csi_priv, notifier);
}
static inline bool is_parallel_bus(struct v4l2_mbus_config *mbus_cfg)
{
return mbus_cfg->type != V4L2_MBUS_CSI2_DPHY;
}
static inline bool is_parallel_16bit_bus(struct v4l2_mbus_config *mbus_cfg)
{
return is_parallel_bus(mbus_cfg) && mbus_cfg->bus.parallel.bus_width >= 16;
}
/*
* Check for conditions that require the IPU to handle the
* data internally as generic data, aka passthrough mode:
* - raw bayer media bus formats, or
* - BT.656 and BT.1120 (8/10-bit YUV422) data can always be processed
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gcd.h`, `linux/interrupt.h`, `linux/module.h`, `linux/of_graph.h`, `linux/pinctrl/consumer.h`, `linux/platform_device.h`, `media/v4l2-ctrls.h`.
- Detected declarations: `struct csi_skip_desc`, `struct csi_priv`, `function is_parallel_bus`, `function is_parallel_16bit_bus`, `function requires_passthrough`, `function csi_get_upstream_mbus_config`, `function csi_idmac_put_ipu_resources`, `function csi_idmac_get_ipu_resources`, `function csi_vb2_buf_done`, `function csi_idmac_eof_interrupt`.
- Atlas domain: Driver Families / drivers/staging.
- 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.