[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250821-95_cam-v3-25-c9286fbb34b9@nxp.com>
Date: Thu, 21 Aug 2025 16:16:00 -0400
From: Frank Li <Frank.Li@....com>
To: Rui Miguel Silva <rmfrfs@...il.com>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Martin Kepplinger <martink@...teo.de>, Purism Kernel Team <kernel@...i.sm>,
Mauro Carvalho Chehab <mchehab@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Eugen Hristev <eugen.hristev@...aro.org>, Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>, Peng Fan <peng.fan@....com>,
Alice Yuan <alice.yuan@....com>, Vinod Koul <vkoul@...nel.org>,
Kishon Vijay Abraham I <kishon@...nel.org>,
Philipp Zabel <p.zabel@...gutronix.de>,
Steve Longerbeam <slongerbeam@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-media@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, imx@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org, linux-phy@...ts.infradead.org,
linux-staging@...ts.linux.dev, Frank Li <Frank.Li@....com>
Subject: [PATCH v3 25/31] media: synopsys: csi2: Add default simple
dw_csi2_subdev_init_state
Add default simple dw_csi2_subdev_init_state, which have 1 sink and 1
source pad, 1920x1080p and MEDIA_BUS_FMT_UYVY8_1X16 format.
Signed-off-by: Frank Li <Frank.Li@....com>
---
drivers/media/platform/synopsys/mipi-csi2.c | 57 ++++++++++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/synopsys/mipi-csi2.c b/drivers/media/platform/synopsys/mipi-csi2.c
index 632ae5fd7da7850374c79dcff63b6ee4aee7b611..0b3bb099329017e81d2fb41387a3671e429dfe1c 100644
--- a/drivers/media/platform/synopsys/mipi-csi2.c
+++ b/drivers/media/platform/synopsys/mipi-csi2.c
@@ -831,6 +831,59 @@ static const struct v4l2_async_notifier_operations csi2_notify_ops = {
.unbind = csi2_notify_unbind,
};
+static const struct v4l2_mbus_framefmt dwc_csi_default_fmt = {
+ .code = MEDIA_BUS_FMT_UYVY8_1X16,
+ .width = 1920,
+ .height = 1080,
+ .field = V4L2_FIELD_NONE,
+ .colorspace = V4L2_COLORSPACE_SMPTE170M,
+ .xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(V4L2_COLORSPACE_SMPTE170M),
+ .ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(V4L2_COLORSPACE_SMPTE170M),
+ .quantization = V4L2_QUANTIZATION_LIM_RANGE,
+};
+
+static int dw_csi2_subdev_set_routing(struct v4l2_subdev *sd,
+ struct v4l2_subdev_state *state,
+ struct v4l2_subdev_krouting *routing)
+{
+ int ret;
+
+ if (routing->num_routes > V4L2_FRAME_DESC_ENTRY_MAX)
+ return -EINVAL;
+
+ ret = v4l2_subdev_routing_validate(sd, routing,
+ V4L2_SUBDEV_ROUTING_ONLY_1_TO_1);
+ if (ret)
+ return ret;
+
+ return v4l2_subdev_set_routing_with_fmt(sd, state, routing, &dwc_csi_default_fmt);
+}
+
+static int dw_csi2_subdev_init_state_simple(struct v4l2_subdev *sd,
+ struct v4l2_subdev_state *sd_state)
+{
+ struct v4l2_subdev_route routes[] = {
+ {
+ .sink_pad = 0,
+ .sink_stream = 0,
+ .source_pad = 1,
+ .source_stream = 0,
+ .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE,
+ },
+ };
+
+ struct v4l2_subdev_krouting routing = {
+ .num_routes = ARRAY_SIZE(routes),
+ .routes = routes,
+ };
+
+ return dw_csi2_subdev_set_routing(sd, sd_state, &routing);
+}
+
+static const struct v4l2_subdev_internal_ops dw_csi2_simple_internal_ops = {
+ .init_state = dw_csi2_subdev_init_state_simple,
+};
+
static int csi2_async_register(struct dw_mipi_csi2_dev *csi2)
{
struct v4l2_fwnode_endpoint vep = {
@@ -954,7 +1007,9 @@ int dw_mipi_csi2_init(struct platform_device *pdev, struct dw_mipi_csi2_dev *csi
csi2->sd.owner = config->module;
strscpy(csi2->sd.name, config->name, sizeof(csi2->sd.name));
- csi2->sd.internal_ops = config->internal_ops;
+ csi2->sd.internal_ops = config->internal_ops ?
+ config->internal_ops :
+ &dw_csi2_simple_internal_ops;
csi2->sd.grp_id = config->grp_id;
csi2->config = config;
--
2.34.1
Powered by blists - more mailing lists