drivers/media/platform/nxp/imx8mq-mipi-csi2.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/nxp/imx8mq-mipi-csi2.c- Extension
.c- Size
- 28849 bytes
- Lines
- 1093
- 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/bitfield.hlinux/cleanup.hlinux/clk.hlinux/clk-provider.hlinux/delay.hlinux/errno.hlinux/interconnect.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/mfd/syscon.hlinux/module.hlinux/mutex.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.hlinux/regulator/consumer.hlinux/reset.hlinux/spinlock.hmedia/v4l2-common.hmedia/v4l2-device.hmedia/v4l2-fwnode.hmedia/v4l2-mc.hmedia/v4l2-subdev.h
Detected Declarations
struct csi_statestruct imx8mq_plat_datastruct csi_statestruct csi2_pix_formatfunction imx8mq_gpr_enablefunction imx8qxp_gpr_enablefunction imx8qxp_gpr_disablefunction imx8mq_mipi_csi_writefunction imx8mq_mipi_csi_sw_resetfunction imx8mq_mipi_csi_set_paramsfunction imx8mq_mipi_csi_calc_hs_settlefunction imx8mq_mipi_csi_start_streamfunction imx8mq_mipi_csi_stop_streamfunction imx8mq_mipi_csi_s_streamfunction imx8mq_mipi_csi_init_statefunction imx8mq_mipi_csi_enum_mbus_codefunction imx8mq_mipi_csi_set_fmtfunction mipi_notifier_to_csi2_statefunction imx8mq_mipi_csi_notify_boundfunction imx8mq_mipi_csi_async_registerfunction imx8mq_mipi_csi_pm_suspendfunction imx8mq_mipi_csi_pm_resumefunction imx8mq_mipi_csi_suspendfunction imx8mq_mipi_csi_resumefunction imx8mq_mipi_csi_runtime_suspendfunction imx8mq_mipi_csi_runtime_resumefunction imx8mq_mipi_csi_subdev_initfunction imx8mq_mipi_csi_release_iccfunction imx8mq_mipi_csi_init_iccfunction imx8mq_mipi_csi_parse_dtfunction imx8mq_mipi_csi_probefunction imx8mq_mipi_csi_remove
Annotated Snippet
struct imx8mq_plat_data {
int (*enable)(struct csi_state *state, u32 hs_settle);
void (*disable)(struct csi_state *state);
bool use_reg_csr;
};
/*
* The send level configures the number of entries that must accumulate in
* the Pixel FIFO before the data will be transferred to the video output.
* The exact value needed for this configuration is dependent on the rate at
* which the sensor transfers data to the CSI-2 Controller and the user
* video clock.
*
* The calculation is the classical rate-in rate-out type of problem: If the
* video bandwidth is 10% faster than the incoming mipi data and the video
* line length is 500 pixels, then the fifo should be allowed to fill
* 10% of the line length or 50 pixels. If the gap data is ok, then the level
* can be set to 16 and ignored.
*/
#define CSI2RX_SEND_LEVEL 64
struct csi_state {
struct device *dev;
const struct imx8mq_plat_data *pdata;
void __iomem *regs;
struct clk_bulk_data *clks;
struct clk *esc_clk;
u32 num_clks;
struct reset_control *rst;
struct regulator *mipi_phy_regulator;
struct v4l2_subdev sd;
struct media_pad pads[MIPI_CSI2_PADS_NUM];
struct v4l2_async_notifier notifier;
struct v4l2_subdev *src_sd;
struct v4l2_mbus_config_mipi_csi2 bus;
struct mutex lock; /* Protect state */
u32 state;
struct regmap *phy_gpr;
u8 phy_gpr_reg;
struct icc_path *icc_path;
s32 icc_path_bw;
};
/* -----------------------------------------------------------------------------
* Format helpers
*/
struct csi2_pix_format {
u32 code;
u8 width;
};
/* -----------------------------------------------------------------------------
* i.MX8MQ GPR
*/
#define GPR_CSI2_1_RX_ENABLE BIT(13)
#define GPR_CSI2_1_VID_INTFC_ENB BIT(12)
#define GPR_CSI2_1_HSEL BIT(10)
#define GPR_CSI2_1_CONT_CLK_MODE BIT(8)
#define GPR_CSI2_1_S_PRG_RXHS_SETTLE(x) (((x) & 0x3f) << 2)
static int imx8mq_gpr_enable(struct csi_state *state, u32 hs_settle)
{
regmap_update_bits(state->phy_gpr,
state->phy_gpr_reg,
0x3fff,
GPR_CSI2_1_RX_ENABLE |
GPR_CSI2_1_VID_INTFC_ENB |
GPR_CSI2_1_HSEL |
GPR_CSI2_1_CONT_CLK_MODE |
GPR_CSI2_1_S_PRG_RXHS_SETTLE(hs_settle));
return 0;
}
static const struct imx8mq_plat_data imx8mq_data = {
.enable = imx8mq_gpr_enable,
};
/* -----------------------------------------------------------------------------
* i.MX8QXP
*/
#define CSI2SS_PL_CLK_INTERVAL_US 100
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/cleanup.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/delay.h`, `linux/errno.h`, `linux/interconnect.h`, `linux/interrupt.h`.
- Detected declarations: `struct csi_state`, `struct imx8mq_plat_data`, `struct csi_state`, `struct csi2_pix_format`, `function imx8mq_gpr_enable`, `function imx8qxp_gpr_enable`, `function imx8qxp_gpr_disable`, `function imx8mq_mipi_csi_write`, `function imx8mq_mipi_csi_sw_reset`, `function imx8mq_mipi_csi_set_params`.
- 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.