// SPDX-License-Identifier: (GPL-2.0+ OR MIT) /* * Rockchip ISP1 Driver - Base driver * * Copyright (C) 2019 Collabora, Ltd. * * Based on Rockchip ISP1 driver by Rockchip Electronics Co., Ltd. * Copyright (C) 2017 Rockchip Electronics Co., Ltd. */ #include <linux/clk.h> #include <linux/interrupt.h> #include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/of.h> #include <linux/of_graph.h> #include <linux/platform_device.h> #include <linux/pinctrl/consumer.h> #include <linux/pm_runtime.h> #include <media/v4l2-fwnode.h> #include <media/v4l2-mc.h> #include "rkisp1-common.h" #include "rkisp1-csi.h" /* * ISP Details * ----------- * * ISP Comprises with: * MIPI serial camera interface * Image Signal Processing * Many Image Enhancement Blocks * Crop * Resizer * RBG display ready image * Image Rotation * * ISP Block Diagram * ----------------- * rkisp1-resizer.c rkisp1-capture.c * |====================| |=======================| * rkisp1-isp.c Main Picture Path * |==========================| |===============================================| * +-----------+ +--+--+--+--+ +--------+ +--------+ +-----------+ * | | | | | | | | | | | | | * +--------+ |\ | | | | | | | -->| Crop |->| RSZ |------------->| | * | MIPI |--->| \ | | | | | | | | | | | | | | * +--------+ | | | | |IE|IE|IE|IE| | +--------+ +--------+ | Memory | * |MUX|--->| ISP |->|0 |1 |2 |3 |---+ | Interface | * +--------+ | | | | | | | | | | +--------+ +--------+ +--------+ | | * |Parallel|--->| / | | | | | | | | | | | | | | | | * +--------+ |/ | | | | | | | -->| Crop |->| RSZ |->| RGB |->| | * | | | | | | | | | | | | Rotate | | | * +-----------+ +--+--+--+--+ +--------+ +--------+ +--------+ +-----------+ * ^ * +--------+ | |===============================================| * | DMA |------------------------------------+ Self Picture Path * +--------+ * * rkisp1-stats.c rkisp1-params.c * |===============| |===============| * +---------------+ +---------------+ * | | | | * | ISP | | ISP | * | | | | * +---------------+ +---------------+ * * * Media Topology * -------------- * * +----------+ +----------+ * | Sensor 1 | | Sensor X | * ------------ ... ------------ * | 0 | | 0 | * +----------+ +----------+ * | | * \----\ /----/ * | | * v v * +-------------+ * | 0 | * --------------- * | CSI-2 RX | * --------------- +-----------+ * | 1 | | params | * +-------------+ | (output) | * | +-----------+ * v | * +------+------+ | * | 0 | 1 |<---------+ * |------+------| * | ISP | * |------+------| * +-------------| 2 | 3 |----------+ * | +------+------+ | * | | | * v v v * +- ---------+ +-----------+ +-----------+ * | 0 | | 0 | | stats | * ------------- ------------- | (capture) | * | Resizer | | Resizer | +-----------+ * ------------| ------------| * | 1 | | 1 | * +-----------+ +-----------+ * | | * v v * +-----------+ +-----------+ * | selfpath | | mainpath | * | (capture) | | (capture) | * +-----------+ +-----------+ */ struct rkisp1_isr_data { … }; /* ---------------------------------------------------------------------------- * Sensor DT bindings */ static int rkisp1_subdev_notifier_bound(struct v4l2_async_notifier *notifier, struct v4l2_subdev *sd, struct v4l2_async_connection *asc) { … } static int rkisp1_subdev_notifier_complete(struct v4l2_async_notifier *notifier) { … } static void rkisp1_subdev_notifier_destroy(struct v4l2_async_connection *asc) { … } static const struct v4l2_async_notifier_operations rkisp1_subdev_notifier_ops = …; static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1) { … } /* ---------------------------------------------------------------------------- * Power */ static int __maybe_unused rkisp1_runtime_suspend(struct device *dev) { … } static int __maybe_unused rkisp1_runtime_resume(struct device *dev) { … } static const struct dev_pm_ops rkisp1_pm_ops = …; /* ---------------------------------------------------------------------------- * Core */ static int rkisp1_create_links(struct rkisp1_device *rkisp1) { … } static void rkisp1_entities_unregister(struct rkisp1_device *rkisp1) { … } static int rkisp1_entities_register(struct rkisp1_device *rkisp1) { … } static irqreturn_t rkisp1_isr(int irq, void *ctx) { … } static const char * const px30_isp_clks[] = …; static const struct rkisp1_isr_data px30_isp_isrs[] = …; static const struct rkisp1_info px30_isp_info = …; static const char * const rk3399_isp_clks[] = …; static const struct rkisp1_isr_data rk3399_isp_isrs[] = …; static const struct rkisp1_info rk3399_isp_info = …; static const char * const imx8mp_isp_clks[] = …; static const struct rkisp1_isr_data imx8mp_isp_isrs[] = …; static const struct rkisp1_info imx8mp_isp_info = …; static const struct of_device_id rkisp1_of_match[] = …; MODULE_DEVICE_TABLE(of, rkisp1_of_match); static int rkisp1_probe(struct platform_device *pdev) { … } static void rkisp1_remove(struct platform_device *pdev) { … } static struct platform_driver rkisp1_drv = …; module_platform_driver(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …;