[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220311143532.265091-45-paul.kocialkowski@bootlin.com>
Date: Fri, 11 Mar 2022 15:35:30 +0100
From: Paul Kocialkowski <paul.kocialkowski@...tlin.com>
To: linux-kernel@...r.kernel.org, linux-media@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev
Cc: Yong Deng <yong.deng@...ewell.com>,
Paul Kocialkowski <paul.kocialkowski@...tlin.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Chen-Yu Tsai <wens@...e.org>,
Jernej Skrabec <jernej.skrabec@...il.com>,
Samuel Holland <samuel@...lland.org>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>
Subject: [PATCH v3 44/46] media: sun6i-csi: Detect the availability of the ISP
Add a helper to detect whether the ISP is available and connected
and store the indication in a driver-wide variable.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@...tlin.com>
---
.../platform/sunxi/sun6i-csi/sun6i_csi.c | 33 +++++++++++++++++++
.../platform/sunxi/sun6i-csi/sun6i_csi.h | 3 ++
2 files changed, 36 insertions(+)
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
index 794ac53dcd30..f17be8e091a9 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
@@ -25,6 +25,35 @@
#include "sun6i_csi_capture.h"
#include "sun6i_csi_reg.h"
+/* ISP */
+
+static bool sun6i_csi_isp_detect(struct sun6i_csi_device *csi_dev)
+{
+ struct device *dev = csi_dev->dev;
+ struct fwnode_handle *handle = NULL;
+
+ /* ISP is not available if disabled in kernel config. */
+ if (!IS_ENABLED(CONFIG_VIDEO_SUN6I_ISP))
+ return 0;
+
+ /*
+ * ISP is not available if not connected via fwnode graph.
+ * This weill also check that the remote parent node is available.
+ */
+ handle = fwnode_graph_get_endpoint_by_id(dev_fwnode(dev),
+ SUN6I_CSI_PORT_ISP, 0,
+ FWNODE_GRAPH_ENDPOINT_NEXT);
+ if (!handle)
+ return 0;
+
+ fwnode_handle_put(handle);
+
+ dev_info(dev, "ISP link is available\n");
+ csi_dev->isp_available = true;
+
+ return 0;
+}
+
/* Media */
static const struct media_device_ops sun6i_csi_media_ops = {
@@ -323,6 +352,10 @@ static int sun6i_csi_probe(struct platform_device *platform_dev)
if (ret)
return ret;
+ ret = sun6i_csi_isp_detect(csi_dev);
+ if (ret)
+ goto error_resources;
+
ret = sun6i_csi_v4l2_setup(csi_dev);
if (ret)
goto error_resources;
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
index e3c1150d99f5..ee5b04f75311 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
@@ -22,6 +22,7 @@
enum sun6i_csi_port {
SUN6I_CSI_PORT_PARALLEL = 0,
SUN6I_CSI_PORT_MIPI_CSI2 = 1,
+ SUN6I_CSI_PORT_ISP = 2,
};
struct sun6i_csi_buffer {
@@ -47,6 +48,8 @@ struct sun6i_csi_device {
struct clk *clk_mod;
struct clk *clk_ram;
struct reset_control *reset;
+
+ bool isp_available;
};
struct sun6i_csi_variant {
--
2.35.1
Powered by blists - more mailing lists