From nobody Thu Oct 2 01:01:47 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 DE74F3019C1; Thu, 25 Sep 2025 15:55:30 +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=1758815733; cv=none; b=eN52amSnVXYcl9msp02J2I+XytG8LFY1R1WwxK/Pb7AHlXOGd60aDezFEs67tjgw8/pTeY3ZfWxxEgac73dJASO3mZ+9iTyfYsKyTX0majW5e+cLVVQdX+Z+sWcO/uhuRH8s6bV0m9prb7WXJ35GWhK0EtLQskxTyDK2l363GZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758815733; c=relaxed/simple; bh=0eohwAR/y++4oPMxRnpqozTlsghcWn2K5MPx0wPe8gg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u1MElmGt3GfPibKirGZUJwQbUQXTY+BdGWsiuJl5IrFADTrnoMFbTyoNgGNK2AIvNAzVPFW6+er6jHWDv5ZbxgiLhIsm5zhQhWAdtqH1fihPctT/r+/RfIETg1oRnumOAa1KAuw9jfCJqegu4ufUlsOqboOJ6wLoVWzG51OPgKQ= 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=mcs2YirO; 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="mcs2YirO" Received: from [127.0.1.1] (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 628B21D1C; Thu, 25 Sep 2025 17:54:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1758815642; bh=0eohwAR/y++4oPMxRnpqozTlsghcWn2K5MPx0wPe8gg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mcs2YirOd9cwzKG03SPsBv9Hu8SCoekmPeGuYhxWzmjddYDdUZlXWueul6Gl41IYx OlSU4tm4LTT8NyUg7pGfK2BAw7s9Sznpt2dx178Xg0suyV0meuVCt35XXyToGzG51e Xy1ALGMN1+X/f0UGnFoTTnMuTD/J6JnE42tAkOCY= From: Isaac Scott Date: Thu, 25 Sep 2025 16:54:26 +0100 Subject: [PATCH v4 1/4] media: v4l: Add helper to get number of active lanes via a pad Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250925-active-data-lanes-v4-1-8b54e3d5af6c@ideasonboard.com> References: <20250925-active-data-lanes-v4-0-8b54e3d5af6c@ideasonboard.com> In-Reply-To: <20250925-active-data-lanes-v4-0-8b54e3d5af6c@ideasonboard.com> To: Mauro Carvalho Chehab , Rui Miguel Silva , Laurent Pinchart , Martin Kepplinger , Purism Kernel Team , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Isaac Scott , Frank Li X-Mailer: b4 0.13.0 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 maximum number of lanes available. Reviewed-by: Frank Li Reviewed-by: Laurent Pinchart Signed-off-by: Isaac Scott --- drivers/media/v4l2-core/v4l2-common.c | 29 +++++++++++++++++++++++++++++ include/media/v4l2-common.h | 20 ++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-cor= e/v4l2-common.c index b367d479d6b3..2b4cec25e751 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -573,6 +573,35 @@ s64 v4l2_get_link_freq(const 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); + +unsigned int v4l2_get_active_data_lanes(const struct media_pad *pad, + unsigned int max_data_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; + + /* This relies on the mbus_config being zeroed at init time */ + lanes =3D mbus_config.bus.mipi_csi2.num_data_lanes; + if (!lanes) + return max_data_lanes; + + if (lanes > max_data_lanes) { + dev_dbg(sd->dev, "Active data lanes (%u) exceeds max (%u)\n", + lanes, max_data_lanes); + return -EINVAL; + } + + return lanes; +} +EXPORT_SYMBOL_GPL(v4l2_get_active_data_lanes); #endif =20 /* diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index 5c0a7f6b5bb6..950df46cb27a 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -581,6 +581,26 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane = *pixfmt, u32 pixelformat, #ifdef CONFIG_MEDIA_CONTROLLER s64 v4l2_get_link_freq(const struct media_pad *pad, unsigned int mul, unsigned int div); + +/** + * v4l2_get_active_data_lanes - Get number of active data lanes from driver + * + * @pad: The transmitter's media pad. + * @max_data_lanes: The maximum number of active data lanes supported by + * the MIPI CSI link in hardware. + * + * This function is intended for obtaining the number of data lanes that a= re + * actively being used by the driver for a MIPI CSI-2 device on a given me= dia pad. + * This information is derived from a mbus_config fetched from a device dr= iver + * using the get_mbus_config v4l2_subdev pad op. + * + * Return: + * * >0: Number of active data lanes + * * %-EINVAL: Number of active data lanes is invalid, as it exceeds the m= aximum + * supported data lanes. + */ +unsigned int v4l2_get_active_data_lanes(const struct media_pad *pad, + unsigned int max_data_lanes); #endif =20 void v4l2_simplify_fraction(u32 *numerator, u32 *denominator, --=20 2.43.0 From nobody Thu Oct 2 01:01:47 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 20AD0304971; Thu, 25 Sep 2025 15:55:32 +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=1758815734; cv=none; b=d2aO68aiq6hkCkoBEdDsa3we5/BopIrs+NUi8PSD1N229gyBbeiqlE/1UOGEF5YukA+oSwxEjxCOrXftr19dlL72HPhxJT5mo4+ISRGCDHlMDx9aa1gHtShfiy07HsmcmNzL1KzYarjUuOIMX1mhbNPtOWjx+lHU07h0t2yxmTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758815734; c=relaxed/simple; bh=wxwjv0TH/jBveXmTmMdoYRFOMmVEcjeoTCUVDdp1DUg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EIkCOhMscWO8BGauOyQtaPHmxDv5Es8Whzw164S5VSgVxTvKFacjqCFMMoBWtbpgDIQriBxv1YtjYY3mjMNUqulZZQsYOkR3udPhLMqJehBy1O19YY5L7o81phRK9LLqlwAB8wWSW3nygNJ+rErEHPmK9Rszm3NSgsYu846B9/E= 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=NVoeSH+f; 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="NVoeSH+f" Received: from [127.0.1.1] (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 223B51E32; Thu, 25 Sep 2025 17:54:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1758815642; bh=wxwjv0TH/jBveXmTmMdoYRFOMmVEcjeoTCUVDdp1DUg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NVoeSH+fYusndWUvE/2r4PXA/JAsYgOxUJvo0V6Dlm7AbTqj66i4uYy0Ah+hBvWmo nbvsI9YnOWQ2DJoowfCpbqTjP+acRfRls7kneiGejy5BXn8WvjOMMMNe5LU3rtJ03y CnXXPJvtlXT3Gwj4kbmzkti/oRgW9qdZwDSihQmI= From: Isaac Scott Date: Thu, 25 Sep 2025 16:54:27 +0100 Subject: [PATCH v4 2/4] media: imx-mipi-csis: Move redundant debug print in probe Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250925-active-data-lanes-v4-2-8b54e3d5af6c@ideasonboard.com> References: <20250925-active-data-lanes-v4-0-8b54e3d5af6c@ideasonboard.com> In-Reply-To: <20250925-active-data-lanes-v4-0-8b54e3d5af6c@ideasonboard.com> To: Mauro Carvalho Chehab , Rui Miguel Silva , Laurent Pinchart , Martin Kepplinger , Purism Kernel Team , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Isaac Scott X-Mailer: b4 0.13.0 The number of data lanes is already printed as part of mipi_csis_async_register(), making the first part of this print redundant. Remove the redundant print, and move the debug print for clock frequency to mipi_csis_parse_dt(). Signed-off-by: Isaac Scott Reviewed-by: Frank Li --- drivers/media/platform/nxp/imx-mipi-csis.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/pla= tform/nxp/imx-mipi-csis.c index d5de7854f579..7c2a679dca2e 100644 --- a/drivers/media/platform/nxp/imx-mipi-csis.c +++ b/drivers/media/platform/nxp/imx-mipi-csis.c @@ -1481,6 +1481,7 @@ static int mipi_csis_parse_dt(struct mipi_csis_device= *csis) struct device_node *node =3D csis->dev->of_node; =20 of_property_read_u32(node, "clock-frequency", &csis->clk_frequency); + dev_dbg(csis->dev, "clock frequency: %u\n", csis->clk_frequency); =20 csis->num_channels =3D 1; of_property_read_u32(node, "fsl,num-channels", &csis->num_channels); @@ -1566,9 +1567,6 @@ static int mipi_csis_probe(struct platform_device *pd= ev) goto err_unregister_all; } =20 - dev_info(dev, "lanes: %d, freq: %u\n", - csis->bus.num_data_lanes, csis->clk_frequency); - return 0; =20 err_unregister_all: --=20 2.43.0 From nobody Thu Oct 2 01:01:47 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 0E6BA302CA3; Thu, 25 Sep 2025 15:55:34 +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=1758815736; cv=none; b=tJyzRPujCf1LCzFkuz8US88w3rRNuhJ9mfViEhDL5FLvzeJcRkOqmaBUuHrCqSRo/oPeetmJOCpeFFjmuscZE2FkmxHoq1sQj9z9ZI3SGkaQYrM1lgO0XRPzsNCgavxNcZm53URfUSibLJ3XLJ9jo5VEUoulU0SiMiho9qtbVY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758815736; c=relaxed/simple; bh=id013NlFyzuJMf+mdvtdKKj31ZyAXitg+Te/hkly/4o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=crByNtSN17ZqPBRkfvVYcd0dUVpbaNC3FlgnfsI4nh2twrgCU8GJZLt7g2XmBJIiZ8R5b8qDDs3DWGReQi1fj1sINHShmy78y+K4GX/i3h5rCLVN2XyOGMBXuc1gf7y+KFKzB4J63MY2HFEtab8ViOhvB7lJ/wZx2Sh432gN4a0= 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=LJDTh92d; 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="LJDTh92d" Received: from [127.0.1.1] (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CFC861E3C; Thu, 25 Sep 2025 17:54:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1758815643; bh=id013NlFyzuJMf+mdvtdKKj31ZyAXitg+Te/hkly/4o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LJDTh92dkIfWw5AwKRlog+j+7eoH1q4eIYu5fw8Y7uG0zP/uxJ5yqr5gGdS9tATZk lTj23G0bblsByB51GiZ2hxv2xryYVWnmO0qpSnH5+55ehsuCj/sCSCHeRCqCK3yGPe auneg2BY4ItMk2QLpoLud6riamaMEQQYxXdA/DYg= From: Isaac Scott Date: Thu, 25 Sep 2025 16:54:28 +0100 Subject: [PATCH v4 3/4] media: imx-mipi-csis: Store the number of data_lanes configured in dt Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250925-active-data-lanes-v4-3-8b54e3d5af6c@ideasonboard.com> References: <20250925-active-data-lanes-v4-0-8b54e3d5af6c@ideasonboard.com> In-Reply-To: <20250925-active-data-lanes-v4-0-8b54e3d5af6c@ideasonboard.com> To: Mauro Carvalho Chehab , Rui Miguel Silva , Laurent Pinchart , Martin Kepplinger , Purism Kernel Team , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Isaac Scott X-Mailer: b4 0.13.0 The number of active data lanes in use on a MIPI CSI2 bus is not necessarily always the maximum. To allow us to configure the number of data lanes actively in use, store the maximum to ensure we can configure a number of data lanes that is supported. Signed-off-by: Isaac Scott --- drivers/media/platform/nxp/imx-mipi-csis.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/pla= tform/nxp/imx-mipi-csis.c index 7c2a679dca2e..838a1ad123b5 100644 --- a/drivers/media/platform/nxp/imx-mipi-csis.c +++ b/drivers/media/platform/nxp/imx-mipi-csis.c @@ -351,6 +351,8 @@ struct mipi_csis_device { u32 hs_settle; u32 clk_settle; =20 + unsigned int num_data_lanes; + spinlock_t slock; /* Protect events */ struct mipi_csis_event events[MIPI_CSIS_NUM_EVENTS]; struct dentry *debugfs_root; @@ -573,7 +575,7 @@ static void mipi_csis_system_enable(struct mipi_csis_de= vice *csis, int on) val =3D mipi_csis_read(csis, MIPI_CSIS_DPHY_CMN_CTRL); val &=3D ~MIPI_CSIS_DPHY_CMN_CTRL_ENABLE; if (on) { - mask =3D (1 << (csis->bus.num_data_lanes + 1)) - 1; + mask =3D (1 << (csis->num_data_lanes + 1)) - 1; val |=3D (mask & MIPI_CSIS_DPHY_CMN_CTRL_ENABLE); } mipi_csis_write(csis, MIPI_CSIS_DPHY_CMN_CTRL, val); @@ -623,7 +625,7 @@ static int mipi_csis_calculate_params(struct mipi_csis_= device *csis, =20 /* Calculate the line rate from the pixel rate. */ link_freq =3D v4l2_get_link_freq(csis->source.pad, csis_fmt->width, - csis->bus.num_data_lanes * 2); + csis->num_data_lanes * 2); if (link_freq < 0) { dev_err(csis->dev, "Unable to obtain link frequency: %d\n", (int)link_freq); @@ -668,7 +670,7 @@ static void mipi_csis_set_params(struct mipi_csis_devic= e *csis, const struct v4l2_mbus_framefmt *format, const struct csis_pix_format *csis_fmt) { - int lanes =3D csis->bus.num_data_lanes; + int lanes =3D csis->num_data_lanes; u32 val; =20 val =3D mipi_csis_read(csis, MIPI_CSIS_CMN_CTRL); @@ -1366,8 +1368,9 @@ static int mipi_csis_async_register(struct mipi_csis_= device *csis) } =20 csis->bus =3D vep.bus.mipi_csi2; + csis->num_data_lanes =3D csis->bus.num_data_lanes; =20 - dev_dbg(csis->dev, "data lanes: %d\n", csis->bus.num_data_lanes); + dev_dbg(csis->dev, "max data lanes: %d\n", csis->bus.num_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 Thu Oct 2 01:01:47 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 73EEB3019C1; Thu, 25 Sep 2025 15:55:36 +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=1758815738; cv=none; b=pSIyjwWkpZuTr5Y4g6uCVZ0FLqiCpjQS9TVEcohYIdy2+sL6z3TIeL/3NgS9RerEEkTaHmt+jSCOrxg8+L0W2tCRLiALgh+ov3V15/JJ6GaLL2WxE4qGgn36oQKVRLgGWEv26A/VNBnp25TNFkEknCPpGzdErnJCtm4pn+EoTe8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758815738; c=relaxed/simple; bh=/lYx9HajpxPlfcmmhJX0reUWRFqHU9LFR9AeyxwXFvs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=O0R8mDIdvPJkbdmeoj0k6qbTDgm7GChYS20zyFYPSGyS5u1rRJoAq43eYeKNShjvUQ5tljQ1JUC2Aee2caZxHbWskyTAx/Px7kS7CGtRsIIHjlGLK0xHbF9JVjt1fCAwTEVbPBCFTUsn+1AWd8ar0RwWgkCRxAOLwq6htI9RzUQ= 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=kPzyiha4; 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="kPzyiha4" Received: from [127.0.1.1] (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8760AD0; Thu, 25 Sep 2025 17:54:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1758815644; bh=/lYx9HajpxPlfcmmhJX0reUWRFqHU9LFR9AeyxwXFvs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kPzyiha4JC5Hq+Csjvya3qKr/yrHn0ySD9dej4E3Z14t/3SUAjucOnnZeWwSY9Dpk r2MdDMzyvk5zcf29zim9/bqMAXX1kLBzovOzdeFq/biX9/51ojTqd2EiViTF6CEFJV zXRUSdQO+EAAfyCREfn7dMuXFmsThJVj+6LfMCto= From: Isaac Scott Date: Thu, 25 Sep 2025 16:54:29 +0100 Subject: [PATCH v4 4/4] media: imx-mipi-csis: Get number of active lanes via mbus_config Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250925-active-data-lanes-v4-4-8b54e3d5af6c@ideasonboard.com> References: <20250925-active-data-lanes-v4-0-8b54e3d5af6c@ideasonboard.com> In-Reply-To: <20250925-active-data-lanes-v4-0-8b54e3d5af6c@ideasonboard.com> To: Mauro Carvalho Chehab , Rui Miguel Silva , Laurent Pinchart , Martin Kepplinger , Purism Kernel Team , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Isaac Scott X-Mailer: b4 0.13.0 The number of lanes actively used by a MIPI CSI transmitter may differ from that which is defined in device tree, due to the source device not using all of the connected data lanes on the board. As such, call on v4l2_get_active_data_lanes() to check if the driver reports a differing number of lanes to the maximum, and use that number of active lanes. If the number of active data lanes is invalid, or the op is not supported, use the maximum number of allowed data lanes. Signed-off-by: Isaac Scott --- drivers/media/platform/nxp/imx-mipi-csis.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/pla= tform/nxp/imx-mipi-csis.c index 838a1ad123b5..637ef6e614fa 100644 --- a/drivers/media/platform/nxp/imx-mipi-csis.c +++ b/drivers/media/platform/nxp/imx-mipi-csis.c @@ -1034,6 +1034,10 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd= , int enable) format =3D v4l2_subdev_state_get_format(state, CSIS_PAD_SINK); csis_fmt =3D find_csis_format(format->code); =20 + ret =3D v4l2_get_active_data_lanes(csis->source.pad, + csis->bus.num_data_lanes); + csis->num_data_lanes =3D ret < 0 ? csis->bus.num_data_lanes : ret; + ret =3D mipi_csis_calculate_params(csis, csis_fmt); if (ret < 0) goto err_unlock; --=20 2.43.0