From nobody Fri Oct 3 08:51:08 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7BA12EA14A; Wed, 3 Sep 2025 10:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756895001; cv=none; b=GL4cUn7mDQygEUn+Ajwt6UpFWofjAkEskhupF8O800P8f2DiKYqLAa68/88UqZ2XEvLsd3iCORmcxufeeRWo2uHePsXb6hn71GLAS47SPPSKZ0NopkmEG5C3OIb+Fi3C84cnIRgQC1lMbGE/vo34qrhbXNHNZVKax1SrknOiGZc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756895001; c=relaxed/simple; bh=m7VoVORCRPmE9sJDD1t63RnEi0k7Sc7WqvjsbxvaBpg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RnH/tVyKj2y/5mpoYkd3URv1S/ZWL5DojE3cZqLm1f6G/9q6jqKpSpo8cFlF94tXjB0tE71GyPjRwkssZ6KAHL19YsCggnqYOWoM9YgzaDNOBkcPDBvQM/fyWyePcRgkJnQHEhkMH5LQBqvRZCcVR1KDzTIoHNtyQV+uaqnEhtU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=aTqTeDd2; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="aTqTeDd2" Received: from isaac-ThinkPad-T16-Gen-2.lan (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4A6CBC6D; Wed, 3 Sep 2025 12:22:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1756894926; bh=m7VoVORCRPmE9sJDD1t63RnEi0k7Sc7WqvjsbxvaBpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aTqTeDd2KK/HXBeiT9CweKPF0VShHez7ziwt5AHJpFXKXX/Xcgha5IP7J6HaQ9Cd7 +gnK4FOmCbGTrk8By0o6cwMY6gd3MB2A4+qlm4JjT5EqnaAnSeovwEhnDkplr1jcbI Vxhp7/HC7UwJe0mM1KzLtTk+qPZoequlPF7NdTHU= From: Isaac Scott To: laurent.pinchart@ideasonboard.com Cc: rmfrfs@gmail.com, martink@posteo.de, kernel@puri.sm, mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-media@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, hverkuil@kernel.org, nicolas.dufresne@collabora.com, sakari.ailus@linux.intel.com, tomi.valkeinen@ideasonboard.com, jonas@kwiboo.se, dan.scally+renesas@ideasonboard.com, m.szyprowski@samsung.com, mehdi.djait@linux.intel.com, niklas.soderlund+renesas@ragnatech.se, Isaac Scott Subject: [PATCH v2 1/3] media: v4l: Add helper to get number of active lanes via a pad Date: Wed, 3 Sep 2025 11:22:40 +0100 Message-ID: <20250903102243.1563527-2-isaac.scott@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250903102243.1563527-1-isaac.scott@ideasonboard.com> References: <20250903102243.1563527-1-isaac.scott@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Sometimes, users will not use all of the MIPI CSI 2 lanes available when connecting to the MIPI CSI receiver of their device. Add a helper function that checks the mbus_config for the device driver to allow users to define the number of active data lanes through the get_mbus_config op. If the driver does not implement this op, fall back to using the number of data lanes specified in device tree. Signed-off-by: Isaac Scott Reviewed-by: Frank Li --- drivers/media/v4l2-core/v4l2-common.c | 25 +++++++++++++++++++++++++ include/media/v4l2-common.h | 1 + 2 files changed, 26 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-cor= e/v4l2-common.c index 6e585bc76367..8683107b3704 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -571,6 +571,31 @@ s64 __v4l2_get_link_freq_pad(struct media_pad *pad, un= signed int mul, return __v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div); } EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_pad); + +unsigned int v4l2_get_active_data_lanes(const struct media_pad *pad, unsig= ned int dt_lanes) +{ + struct v4l2_mbus_config mbus_config =3D {}; + struct v4l2_subdev *sd; + unsigned int lanes; + int ret; + + sd =3D media_entity_to_v4l2_subdev(pad->entity); + ret =3D v4l2_subdev_call(sd, pad, get_mbus_config, pad->index, + &mbus_config); + if (ret < 0 && ret !=3D -ENOIOCTLCMD) + return ret; + + if (!mbus_config.bus.mipi_csi2.num_data_lanes) + return dt_lanes; + + lanes =3D mbus_config.bus.mipi_csi2.num_data_lanes; + + if (lanes < 0 || lanes > dt_lanes) + return -EINVAL; + + return lanes; +} +EXPORT_SYMBOL_GPL(v4l2_get_active_data_lanes); #endif /* CONFIG_MEDIA_CONTROLLER */ =20 /* diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index 0a43f56578bc..3f8937260c76 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -584,6 +584,7 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *= pixfmt, u32 pixelformat, (pad, mul, div) s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul, unsigned int div); +unsigned int v4l2_get_active_data_lanes(const struct media_pad *pad, unsig= ned int dt_lanes); #else #define v4l2_get_link_freq(handler, mul, div) \ __v4l2_get_link_freq_ctrl(handler, mul, div) --=20 2.43.0 From nobody Fri Oct 3 08:51:08 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46B392DAFDD; Wed, 3 Sep 2025 10:23:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756895002; cv=none; b=j0A5Is6jZU4prJpxVNXTqd1hcKHWOqbpqeQdgAIocZFxVquIJJwMbl2+4IdFUc6Ygc8oFmqQA3xTMl1Vn+YFC0ARBvQ59hZXBPwQv3zisCegG9V7E+/mKzWZlONqtGla4JBV4gxn9WSj6GGB2kIMrsFufTj+wt94pyA5IIf5YnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756895002; c=relaxed/simple; bh=wKtrXGuOI00qmTLY6sya8CgZIXHv8Sh4X0UtJ+kBBos=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ecmHqdSFWCz9DJcMQezvBz0wpozzVU3Wdb4kPxh3mIxAvkBw8A67k7Aai6XvWkXFthA53AQepv2FlUtFZCT/6wOKRkCR9TNSSnsMpmssLCQqBM52PMIxIIW9JWRE5XB3EDLxWbPEDNqUcrp00a7rOrZcUhjvFzogQ92rok/UKXA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=SN0HIu0m; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SN0HIu0m" Received: from isaac-ThinkPad-T16-Gen-2.lan (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D495EF0F; Wed, 3 Sep 2025 12:22:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1756894927; bh=wKtrXGuOI00qmTLY6sya8CgZIXHv8Sh4X0UtJ+kBBos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SN0HIu0mSKVqZ8lzu0YoXTlyHir/zVF2lCG49uM02XG7n/1AQnOyDMnG3tnUCL39L h9JM6T3P1dqqS0jen8OQ366bKeCST1CGk8QdkQ4Vlzy8iqFhGDjCrbAVX+IyKfF/d+ hFr9J4DB+txdNoBe3xHSA66sNjYACn6nyi9dSUfY= From: Isaac Scott To: laurent.pinchart@ideasonboard.com Cc: rmfrfs@gmail.com, martink@posteo.de, kernel@puri.sm, mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-media@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, hverkuil@kernel.org, nicolas.dufresne@collabora.com, sakari.ailus@linux.intel.com, tomi.valkeinen@ideasonboard.com, jonas@kwiboo.se, dan.scally+renesas@ideasonboard.com, m.szyprowski@samsung.com, mehdi.djait@linux.intel.com, niklas.soderlund+renesas@ragnatech.se, Isaac Scott Subject: [PATCH v2 2/3] media: imx-mipi-csis: Store the number of data_lanes configured in dt Date: Wed, 3 Sep 2025 11:22:41 +0100 Message-ID: <20250903102243.1563527-3-isaac.scott@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250903102243.1563527-1-isaac.scott@ideasonboard.com> References: <20250903102243.1563527-1-isaac.scott@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The number of lanes actively used by a MIPI CSI transmitter may differ from that which is defined in device tree. To allow us to be able to set the number of configured lanes without changing the maximum lane count, store the number of lanes configured in device tree, and adjust the debug print to reflect the device tree value. Signed-off-by: Isaac Scott --- drivers/media/platform/nxp/imx-mipi-csis.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/pla= tform/nxp/imx-mipi-csis.c index 2beb5f43c2c0..fc89325f2f94 100644 --- a/drivers/media/platform/nxp/imx-mipi-csis.c +++ b/drivers/media/platform/nxp/imx-mipi-csis.c @@ -313,6 +313,8 @@ struct mipi_csis_device { u32 hs_settle; u32 clk_settle; =20 + unsigned int max_data_lanes; + spinlock_t slock; /* Protect events */ struct mipi_csis_event events[MIPI_CSIS_NUM_EVENTS]; struct dentry *debugfs_root; @@ -1299,8 +1301,9 @@ static int mipi_csis_async_register(struct mipi_csis_= device *csis) } =20 csis->bus =3D vep.bus.mipi_csi2; + csis->max_data_lanes =3D vep.bus.mipi_csi2.num_data_lanes; =20 - dev_dbg(csis->dev, "data lanes: %d\n", csis->bus.num_data_lanes); + dev_dbg(csis->dev, "data lanes: %d\n", csis->max_data_lanes); dev_dbg(csis->dev, "flags: 0x%08x\n", csis->bus.flags); =20 asd =3D v4l2_async_nf_add_fwnode_remote(&csis->notifier, ep, --=20 2.43.0 From nobody Fri Oct 3 08:51:08 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFC942F0C6E; Wed, 3 Sep 2025 10:23:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756895004; cv=none; b=m1T2SeON1dfn21nfyHFIynKGntICDgjLoA45RF/IALtDWGLKYKb4xGKDI8dNiyBrAhKKBYKk1c0bAQk7KMnE/YqW+zF2FJj1x/MRn62Db0iVtCf15xGnykOSsdcZNg/on/C3ODCmORHzExtRDFFwKLOfa8a3g9xLI+EAx0JMP8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756895004; c=relaxed/simple; bh=j1y9w4zVSTWdKaySI00pSSbx5Q3O9jpXo7haUuEXkdc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sTNVKHwvCgB+xAcsymqCeYkf/jKT9WugDZ9yBX4JSJ7pgGaUYWRyTJYBMKcJWQIxeqTTayz0o+PUno4SEWqc5F7lzLNHqA6kZapsU/NUMk29fglUIl2ed/Fd9KtvqGax9U8wqKtMhQEp4Uyh6jrHObZFxCZDfrU0FW4InClITK4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=m1LIxV1k; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="m1LIxV1k" Received: from isaac-ThinkPad-T16-Gen-2.lan (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0BC271026; Wed, 3 Sep 2025 12:22:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1756894929; bh=j1y9w4zVSTWdKaySI00pSSbx5Q3O9jpXo7haUuEXkdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m1LIxV1kOlHdB5TjOrinTOZZvgc2N1xIEBzcH0wrmaA7X0+ddSb60RmdOCmX1500e ZxsrZEQnA/sMf4x+o90/65HHyUEvRseJ8+lrCieeHGV6dRDzRUvC5rdytReL0ORLRz kcy+vdfNfa1kO2/R28uAgO5rjEli4fYOQ6gXKFXg= From: Isaac Scott To: laurent.pinchart@ideasonboard.com Cc: rmfrfs@gmail.com, martink@posteo.de, kernel@puri.sm, mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-media@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, hverkuil@kernel.org, nicolas.dufresne@collabora.com, sakari.ailus@linux.intel.com, tomi.valkeinen@ideasonboard.com, jonas@kwiboo.se, dan.scally+renesas@ideasonboard.com, m.szyprowski@samsung.com, mehdi.djait@linux.intel.com, niklas.soderlund+renesas@ragnatech.se, Isaac Scott Subject: [PATCH v2 3/3] media: imx-mipi-csis: Get number of active lanes via mbus_config Date: Wed, 3 Sep 2025 11:22:42 +0100 Message-ID: <20250903102243.1563527-4-isaac.scott@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250903102243.1563527-1-isaac.scott@ideasonboard.com> References: <20250903102243.1563527-1-isaac.scott@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The number of lanes actively used by a MIPI CSI transmitter may differ from that which is defined in device tree. As such, call on v4l2_get_active_data_lanes to check if the driver reports a differing number of lanes to device tree, and use that number of active lanes. If the number of active data lanes is invalid, or the op is not supported, it will use the number of lanes defined in device tree. Signed-off-by: Isaac Scott --- drivers/media/platform/nxp/imx-mipi-csis.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/pla= tform/nxp/imx-mipi-csis.c index fc89325f2f94..985be511bcd0 100644 --- a/drivers/media/platform/nxp/imx-mipi-csis.c +++ b/drivers/media/platform/nxp/imx-mipi-csis.c @@ -967,6 +967,9 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, i= nt enable) format =3D v4l2_subdev_state_get_format(state, CSIS_PAD_SINK); csis_fmt =3D find_csis_format(format->code); =20 + csis->bus.num_data_lanes =3D v4l2_get_active_data_lanes(csis->source.pad, + csis->max_data_lanes); + ret =3D mipi_csis_calculate_params(csis, csis_fmt); if (ret < 0) goto err_unlock; --=20 2.43.0