All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] media: imx: imx-mipi-csis: Add i.MX8MP support
@ 2022-06-15 19:25 Laurent Pinchart
  2022-06-15 19:25 ` [PATCH 1/4] media: imx: imx-mipi-csis: Set the subdev fwnode for endpoint matching Laurent Pinchart
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Laurent Pinchart @ 2022-06-15 19:25 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Paul Elder, Rui Miguel Silva, kernel, linux-imx,
	Rob Herring, Krzysztof Kozlowski, devicetree

Hello,

This small patch series is a collection of independent patches that
collectively enable i.MX8MP support for the imx-mipi-csis CSI-2
receiver.

Technically speaking, only patch 4/4 is needed to get the driver working
on the i.MX8MP SoC. However, patch 1/4 fixes a related kernel log
warning, and patch 3/4 is required for integration with the ISP found in
that SoC. Patch 2/4 is the only one that is not strictly required, but
I've thrown it in the series as it has been developed as part of i.MX8MP
enablement.

Laurent Pinchart (4):
  media: imx: imx-mipi-csis: Set the subdev fwnode for endpoint matching
  media: imx: imx-mipi-csis: Add version register
  media: imx: imx-mipi-csis: Implement the .get_frame_desc() operation
  dt-bindings: media: nxp,imx-mipi-csi2: i.MX8MP support

 .../bindings/media/nxp,imx-mipi-csi2.yaml     | 11 +++--
 drivers/media/platform/nxp/imx-mipi-csis.c    | 41 +++++++++++++++++++
 2 files changed, 49 insertions(+), 3 deletions(-)


base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56
-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] media: imx: imx-mipi-csis: Set the subdev fwnode for endpoint matching
  2022-06-15 19:25 [PATCH 0/4] media: imx: imx-mipi-csis: Add i.MX8MP support Laurent Pinchart
@ 2022-06-15 19:25 ` Laurent Pinchart
  2022-06-15 23:50   ` Rui Miguel Silva
  2022-06-15 19:26 ` [PATCH 2/4] media: imx: imx-mipi-csis: Add version register Laurent Pinchart
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Laurent Pinchart @ 2022-06-15 19:25 UTC (permalink / raw)
  To: linux-media; +Cc: Jacopo Mondi, Paul Elder, Rui Miguel Silva, kernel, linux-imx

Endpoint matching is preferred over device matching with the async
notifier framework. Set the fwnode in the v4l2_subdev for the CSIS to
the endpoint connected to the next device.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/platform/nxp/imx-mipi-csis.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
index 80b1c021d14a..09a220c1bfe8 100644
--- a/drivers/media/platform/nxp/imx-mipi-csis.c
+++ b/drivers/media/platform/nxp/imx-mipi-csis.c
@@ -1378,6 +1378,13 @@ static int mipi_csis_subdev_init(struct mipi_csis_device *csis)
 
 	sd->dev = csis->dev;
 
+	sd->fwnode = fwnode_graph_get_endpoint_by_id(dev_fwnode(csis->dev),
+						     1, 0, 0);
+	if (!sd->fwnode) {
+		dev_err(csis->dev, "Unable to retrieve endpoint for port@1\n");
+		return -ENOENT;
+	}
+
 	csis->csis_fmt = &mipi_csis_formats[0];
 	mipi_csis_init_cfg(sd, NULL);
 
@@ -1498,6 +1505,7 @@ static int mipi_csis_probe(struct platform_device *pdev)
 	v4l2_async_unregister_subdev(&csis->sd);
 disable_clock:
 	mipi_csis_clk_disable(csis);
+	fwnode_handle_put(csis->sd.fwnode);
 	mutex_destroy(&csis->lock);
 
 	return ret;
@@ -1517,6 +1525,7 @@ static int mipi_csis_remove(struct platform_device *pdev)
 	mipi_csis_runtime_suspend(&pdev->dev);
 	mipi_csis_clk_disable(csis);
 	media_entity_cleanup(&csis->sd.entity);
+	fwnode_handle_put(csis->sd.fwnode);
 	mutex_destroy(&csis->lock);
 	pm_runtime_set_suspended(&pdev->dev);
 
-- 
Regards,

Laurent Pinchart


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] media: imx: imx-mipi-csis: Add version register
  2022-06-15 19:25 [PATCH 0/4] media: imx: imx-mipi-csis: Add i.MX8MP support Laurent Pinchart
  2022-06-15 19:25 ` [PATCH 1/4] media: imx: imx-mipi-csis: Set the subdev fwnode for endpoint matching Laurent Pinchart
@ 2022-06-15 19:26 ` Laurent Pinchart
  2022-06-15 23:51   ` Rui Miguel Silva
  2022-06-15 19:26 ` [PATCH 3/4] media: imx: imx-mipi-csis: Implement the .get_frame_desc() operation Laurent Pinchart
  2022-06-15 19:26 ` [PATCH 4/4] dt-bindings: media: nxp,imx-mipi-csi2: i.MX8MP support Laurent Pinchart
  3 siblings, 1 reply; 11+ messages in thread
From: Laurent Pinchart @ 2022-06-15 19:26 UTC (permalink / raw)
  To: linux-media; +Cc: Jacopo Mondi, Paul Elder, Rui Miguel Silva, kernel, linux-imx

Register at offset 0x00 isn't documented, but the NXP BSP
imx8-mipi-csi2-sam driver defines it as a version register. Tests on
i.MX7D and i.MX8MP have confirmed this, with values matching the version
of the IP core specified in the respective reference manuals.

This commit doesn't make use of the version register at runtime as the
compatible strings are enough to identify the IP core version.
Nonetheless, capturing the information in register definitions that
don't affect the code negatively is useful for future development.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/platform/nxp/imx-mipi-csis.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
index 09a220c1bfe8..8674aaad5fa0 100644
--- a/drivers/media/platform/nxp/imx-mipi-csis.c
+++ b/drivers/media/platform/nxp/imx-mipi-csis.c
@@ -46,6 +46,11 @@
 
 /* Register map definition */
 
+/* CSIS version */
+#define MIPI_CSIS_VERSION			0x00
+#define MIPI_CSIS_VERSION_IMX7D			0x03030505
+#define MIPI_CSIS_VERSION_IMX8MP		0x03060301
+
 /* CSIS common control */
 #define MIPI_CSIS_CMN_CTRL			0x04
 #define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW	BIT(16)
-- 
Regards,

Laurent Pinchart


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] media: imx: imx-mipi-csis: Implement the .get_frame_desc() operation
  2022-06-15 19:25 [PATCH 0/4] media: imx: imx-mipi-csis: Add i.MX8MP support Laurent Pinchart
  2022-06-15 19:25 ` [PATCH 1/4] media: imx: imx-mipi-csis: Set the subdev fwnode for endpoint matching Laurent Pinchart
  2022-06-15 19:26 ` [PATCH 2/4] media: imx: imx-mipi-csis: Add version register Laurent Pinchart
@ 2022-06-15 19:26 ` Laurent Pinchart
  2022-06-15 23:53   ` Rui Miguel Silva
  2022-06-15 19:26 ` [PATCH 4/4] dt-bindings: media: nxp,imx-mipi-csi2: i.MX8MP support Laurent Pinchart
  3 siblings, 1 reply; 11+ messages in thread
From: Laurent Pinchart @ 2022-06-15 19:26 UTC (permalink / raw)
  To: linux-media; +Cc: Jacopo Mondi, Paul Elder, Rui Miguel Silva, kernel, linux-imx

The CSIS is connected to its sink through an SoC-specific gasket that
needs to be configured. Depending on the platform, the gasket
configuration requires knowing the CSI-2 DT. To provide the needed
information, implement the .get_frame_desc() operation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/platform/nxp/imx-mipi-csis.c | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
index 8674aaad5fa0..905072871ed2 100644
--- a/drivers/media/platform/nxp/imx-mipi-csis.c
+++ b/drivers/media/platform/nxp/imx-mipi-csis.c
@@ -1160,6 +1160,32 @@ static int mipi_csis_set_fmt(struct v4l2_subdev *sd,
 	return 0;
 }
 
+static int mipi_csis_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
+				    struct v4l2_mbus_frame_desc *fd)
+{
+	struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd);
+	struct v4l2_mbus_frame_desc_entry *entry = &fd->entry[0];
+
+	if (pad != CSIS_PAD_SOURCE)
+		return -EINVAL;
+
+	fd->type = V4L2_MBUS_FRAME_DESC_TYPE_PARALLEL;
+	fd->num_entries = 1;
+
+	memset(entry, 0, sizeof(*entry));
+
+	mutex_lock(&csis->lock);
+
+	entry->flags = 0;
+	entry->pixelcode = csis->csis_fmt->code;
+	entry->bus.csi2.vc = 0;
+	entry->bus.csi2.dt = csis->csis_fmt->data_type;
+
+	mutex_unlock(&csis->lock);
+
+	return 0;
+}
+
 static int mipi_csis_log_status(struct v4l2_subdev *sd)
 {
 	struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd);
@@ -1184,6 +1210,7 @@ static const struct v4l2_subdev_pad_ops mipi_csis_pad_ops = {
 	.enum_mbus_code		= mipi_csis_enum_mbus_code,
 	.get_fmt		= mipi_csis_get_fmt,
 	.set_fmt		= mipi_csis_set_fmt,
+	.get_frame_desc		= mipi_csis_get_frame_desc,
 };
 
 static const struct v4l2_subdev_ops mipi_csis_subdev_ops = {
-- 
Regards,

Laurent Pinchart


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] dt-bindings: media: nxp,imx-mipi-csi2: i.MX8MP support
  2022-06-15 19:25 [PATCH 0/4] media: imx: imx-mipi-csis: Add i.MX8MP support Laurent Pinchart
                   ` (2 preceding siblings ...)
  2022-06-15 19:26 ` [PATCH 3/4] media: imx: imx-mipi-csis: Implement the .get_frame_desc() operation Laurent Pinchart
@ 2022-06-15 19:26 ` Laurent Pinchart
  2022-06-15 21:01   ` Krzysztof Kozlowski
  3 siblings, 1 reply; 11+ messages in thread
From: Laurent Pinchart @ 2022-06-15 19:26 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Paul Elder, Rui Miguel Silva, kernel, linux-imx,
	Rob Herring, Krzysztof Kozlowski, devicetree

The CSIS CSI-2 receiver in the i.MX8MP seems to be identical to the
version present in the i.MX8MM. Add a device-specific compatible string,
with a fallback to the i.MX8MM compatible.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../devicetree/bindings/media/nxp,imx-mipi-csi2.yaml  | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/nxp,imx-mipi-csi2.yaml b/Documentation/devicetree/bindings/media/nxp,imx-mipi-csi2.yaml
index 36b135bf9f2a..03a23a26c4f3 100644
--- a/Documentation/devicetree/bindings/media/nxp,imx-mipi-csi2.yaml
+++ b/Documentation/devicetree/bindings/media/nxp,imx-mipi-csi2.yaml
@@ -22,9 +22,14 @@ description: |-
 
 properties:
   compatible:
-    enum:
-      - fsl,imx7-mipi-csi2
-      - fsl,imx8mm-mipi-csi2
+    oneOf:
+      - enum:
+          - fsl,imx7-mipi-csi2
+          - fsl,imx8mm-mipi-csi2
+      - items:
+          - enum:
+              - fsl,imx8mp-mipi-csi2
+          - const: fsl,imx8mm-mipi-csi2
 
   reg:
     maxItems: 1
-- 
Regards,

Laurent Pinchart


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] dt-bindings: media: nxp,imx-mipi-csi2: i.MX8MP support
  2022-06-15 19:26 ` [PATCH 4/4] dt-bindings: media: nxp,imx-mipi-csi2: i.MX8MP support Laurent Pinchart
@ 2022-06-15 21:01   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2022-06-15 21:01 UTC (permalink / raw)
  To: Laurent Pinchart, linux-media
  Cc: Jacopo Mondi, Paul Elder, Rui Miguel Silva, kernel, linux-imx,
	Rob Herring, Krzysztof Kozlowski, devicetree

On 15/06/2022 12:26, Laurent Pinchart wrote:
> The CSIS CSI-2 receiver in the i.MX8MP seems to be identical to the
> version present in the i.MX8MM. Add a device-specific compatible string,
> with a fallback to the i.MX8MM compatible.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>


Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] media: imx: imx-mipi-csis: Set the subdev fwnode for endpoint matching
  2022-06-15 19:25 ` [PATCH 1/4] media: imx: imx-mipi-csis: Set the subdev fwnode for endpoint matching Laurent Pinchart
@ 2022-06-15 23:50   ` Rui Miguel Silva
  0 siblings, 0 replies; 11+ messages in thread
From: Rui Miguel Silva @ 2022-06-15 23:50 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-media, Jacopo Mondi, Paul Elder, kernel, linux-imx

Hey Laurent,

On Wed, Jun 15, 2022 at 10:25:59PM +0300, Laurent Pinchart wrote:
> Endpoint matching is preferred over device matching with the async
> notifier framework. Set the fwnode in the v4l2_subdev for the CSIS to
> the endpoint connected to the next device.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

LGTM,
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>

Cheers,
   Rui
> ---
>  drivers/media/platform/nxp/imx-mipi-csis.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
> index 80b1c021d14a..09a220c1bfe8 100644
> --- a/drivers/media/platform/nxp/imx-mipi-csis.c
> +++ b/drivers/media/platform/nxp/imx-mipi-csis.c
> @@ -1378,6 +1378,13 @@ static int mipi_csis_subdev_init(struct mipi_csis_device *csis)
>  
>  	sd->dev = csis->dev;
>  
> +	sd->fwnode = fwnode_graph_get_endpoint_by_id(dev_fwnode(csis->dev),
> +						     1, 0, 0);
> +	if (!sd->fwnode) {
> +		dev_err(csis->dev, "Unable to retrieve endpoint for port@1\n");
> +		return -ENOENT;
> +	}
> +
>  	csis->csis_fmt = &mipi_csis_formats[0];
>  	mipi_csis_init_cfg(sd, NULL);
>  
> @@ -1498,6 +1505,7 @@ static int mipi_csis_probe(struct platform_device *pdev)
>  	v4l2_async_unregister_subdev(&csis->sd);
>  disable_clock:
>  	mipi_csis_clk_disable(csis);
> +	fwnode_handle_put(csis->sd.fwnode);
>  	mutex_destroy(&csis->lock);
>  
>  	return ret;
> @@ -1517,6 +1525,7 @@ static int mipi_csis_remove(struct platform_device *pdev)
>  	mipi_csis_runtime_suspend(&pdev->dev);
>  	mipi_csis_clk_disable(csis);
>  	media_entity_cleanup(&csis->sd.entity);
> +	fwnode_handle_put(csis->sd.fwnode);
>  	mutex_destroy(&csis->lock);
>  	pm_runtime_set_suspended(&pdev->dev);
>  
> -- 
> Regards,
> 
> Laurent Pinchart
>
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] media: imx: imx-mipi-csis: Add version register
  2022-06-15 19:26 ` [PATCH 2/4] media: imx: imx-mipi-csis: Add version register Laurent Pinchart
@ 2022-06-15 23:51   ` Rui Miguel Silva
  0 siblings, 0 replies; 11+ messages in thread
From: Rui Miguel Silva @ 2022-06-15 23:51 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-media, Jacopo Mondi, Paul Elder, kernel, linux-imx

Hey Laurent,
On Wed, Jun 15, 2022 at 10:26:00PM +0300, Laurent Pinchart wrote:
> Register at offset 0x00 isn't documented, but the NXP BSP
> imx8-mipi-csi2-sam driver defines it as a version register. Tests on
> i.MX7D and i.MX8MP have confirmed this, with values matching the version
> of the IP core specified in the respective reference manuals.
> 
> This commit doesn't make use of the version register at runtime as the
> compatible strings are enough to identify the IP core version.
> Nonetheless, capturing the information in register definitions that
> don't affect the code negatively is useful for future development.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Nothing against this.

Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>

Cheers,
   Rui

> ---
>  drivers/media/platform/nxp/imx-mipi-csis.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
> index 09a220c1bfe8..8674aaad5fa0 100644
> --- a/drivers/media/platform/nxp/imx-mipi-csis.c
> +++ b/drivers/media/platform/nxp/imx-mipi-csis.c
> @@ -46,6 +46,11 @@
>  
>  /* Register map definition */
>  
> +/* CSIS version */
> +#define MIPI_CSIS_VERSION			0x00
> +#define MIPI_CSIS_VERSION_IMX7D			0x03030505
> +#define MIPI_CSIS_VERSION_IMX8MP		0x03060301
> +
>  /* CSIS common control */
>  #define MIPI_CSIS_CMN_CTRL			0x04
>  #define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW	BIT(16)
> -- 
> Regards,
> 
> Laurent Pinchart
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] media: imx: imx-mipi-csis: Implement the .get_frame_desc() operation
  2022-06-15 19:26 ` [PATCH 3/4] media: imx: imx-mipi-csis: Implement the .get_frame_desc() operation Laurent Pinchart
@ 2022-06-15 23:53   ` Rui Miguel Silva
  2022-06-15 23:59     ` Laurent Pinchart
  0 siblings, 1 reply; 11+ messages in thread
From: Rui Miguel Silva @ 2022-06-15 23:53 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-media, Jacopo Mondi, Paul Elder, kernel, linux-imx

Hi Laurent,
On Wed, Jun 15, 2022 at 10:26:01PM +0300, Laurent Pinchart wrote:
> The CSIS is connected to its sink through an SoC-specific gasket that
> needs to be configured. Depending on the platform, the gasket
> configuration requires knowing the CSI-2 DT. To provide the needed
> information, implement the .get_frame_desc() operation.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/media/platform/nxp/imx-mipi-csis.c | 27 ++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
> index 8674aaad5fa0..905072871ed2 100644
> --- a/drivers/media/platform/nxp/imx-mipi-csis.c
> +++ b/drivers/media/platform/nxp/imx-mipi-csis.c
> @@ -1160,6 +1160,32 @@ static int mipi_csis_set_fmt(struct v4l2_subdev *sd,
>  	return 0;
>  }
>  
> +static int mipi_csis_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
> +				    struct v4l2_mbus_frame_desc *fd)
> +{
> +	struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd);
> +	struct v4l2_mbus_frame_desc_entry *entry = &fd->entry[0];

Think that you should check *fd before use here, other than that.

Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>

Cheers,
   Rui

> +
> +	if (pad != CSIS_PAD_SOURCE)
> +		return -EINVAL;
> +
> +	fd->type = V4L2_MBUS_FRAME_DESC_TYPE_PARALLEL;
> +	fd->num_entries = 1;
> +
> +	memset(entry, 0, sizeof(*entry));
> +
> +	mutex_lock(&csis->lock);
> +
> +	entry->flags = 0;
> +	entry->pixelcode = csis->csis_fmt->code;
> +	entry->bus.csi2.vc = 0;
> +	entry->bus.csi2.dt = csis->csis_fmt->data_type;
> +
> +	mutex_unlock(&csis->lock);
> +
> +	return 0;
> +}
> +
>  static int mipi_csis_log_status(struct v4l2_subdev *sd)
>  {
>  	struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd);
> @@ -1184,6 +1210,7 @@ static const struct v4l2_subdev_pad_ops mipi_csis_pad_ops = {
>  	.enum_mbus_code		= mipi_csis_enum_mbus_code,
>  	.get_fmt		= mipi_csis_get_fmt,
>  	.set_fmt		= mipi_csis_set_fmt,
> +	.get_frame_desc		= mipi_csis_get_frame_desc,
>  };
>  
>  static const struct v4l2_subdev_ops mipi_csis_subdev_ops = {
> -- 
> Regards,
> 
> Laurent Pinchart
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] media: imx: imx-mipi-csis: Implement the .get_frame_desc() operation
  2022-06-15 23:53   ` Rui Miguel Silva
@ 2022-06-15 23:59     ` Laurent Pinchart
  2022-06-16  0:09       ` Rui Miguel Silva
  0 siblings, 1 reply; 11+ messages in thread
From: Laurent Pinchart @ 2022-06-15 23:59 UTC (permalink / raw)
  To: Rui Miguel Silva; +Cc: linux-media, Jacopo Mondi, Paul Elder, kernel, linux-imx

Hi Rui,

On Thu, Jun 16, 2022 at 12:53:14AM +0100, Rui Miguel Silva wrote:
> On Wed, Jun 15, 2022 at 10:26:01PM +0300, Laurent Pinchart wrote:
> > The CSIS is connected to its sink through an SoC-specific gasket that
> > needs to be configured. Depending on the platform, the gasket
> > configuration requires knowing the CSI-2 DT. To provide the needed
> > information, implement the .get_frame_desc() operation.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  drivers/media/platform/nxp/imx-mipi-csis.c | 27 ++++++++++++++++++++++
> >  1 file changed, 27 insertions(+)
> > 
> > diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
> > index 8674aaad5fa0..905072871ed2 100644
> > --- a/drivers/media/platform/nxp/imx-mipi-csis.c
> > +++ b/drivers/media/platform/nxp/imx-mipi-csis.c
> > @@ -1160,6 +1160,32 @@ static int mipi_csis_set_fmt(struct v4l2_subdev *sd,
> >  	return 0;
> >  }
> >  
> > +static int mipi_csis_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
> > +				    struct v4l2_mbus_frame_desc *fd)
> > +{
> > +	struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd);
> > +	struct v4l2_mbus_frame_desc_entry *entry = &fd->entry[0];
> 
> Think that you should check *fd before use here, other than that.

fd isn't supposed to be null, the same way sd isn't, or the various
format pointers passed to other subdev operations aren't. We don't check
those either, that's why I haven't checked fd here.

> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
> 
> > +
> > +	if (pad != CSIS_PAD_SOURCE)
> > +		return -EINVAL;
> > +
> > +	fd->type = V4L2_MBUS_FRAME_DESC_TYPE_PARALLEL;
> > +	fd->num_entries = 1;
> > +
> > +	memset(entry, 0, sizeof(*entry));
> > +
> > +	mutex_lock(&csis->lock);
> > +
> > +	entry->flags = 0;
> > +	entry->pixelcode = csis->csis_fmt->code;
> > +	entry->bus.csi2.vc = 0;
> > +	entry->bus.csi2.dt = csis->csis_fmt->data_type;
> > +
> > +	mutex_unlock(&csis->lock);
> > +
> > +	return 0;
> > +}
> > +
> >  static int mipi_csis_log_status(struct v4l2_subdev *sd)
> >  {
> >  	struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd);
> > @@ -1184,6 +1210,7 @@ static const struct v4l2_subdev_pad_ops mipi_csis_pad_ops = {
> >  	.enum_mbus_code		= mipi_csis_enum_mbus_code,
> >  	.get_fmt		= mipi_csis_get_fmt,
> >  	.set_fmt		= mipi_csis_set_fmt,
> > +	.get_frame_desc		= mipi_csis_get_frame_desc,
> >  };
> >  
> >  static const struct v4l2_subdev_ops mipi_csis_subdev_ops = {

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] media: imx: imx-mipi-csis: Implement the .get_frame_desc() operation
  2022-06-15 23:59     ` Laurent Pinchart
@ 2022-06-16  0:09       ` Rui Miguel Silva
  0 siblings, 0 replies; 11+ messages in thread
From: Rui Miguel Silva @ 2022-06-16  0:09 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-media, Jacopo Mondi, Paul Elder, kernel, linux-imx

Hi Laurent,
On Thu, Jun 16, 2022 at 02:59:32AM +0300, Laurent Pinchart wrote:
> Hi Rui,
> 
> On Thu, Jun 16, 2022 at 12:53:14AM +0100, Rui Miguel Silva wrote:
> > On Wed, Jun 15, 2022 at 10:26:01PM +0300, Laurent Pinchart wrote:
> > > The CSIS is connected to its sink through an SoC-specific gasket that
> > > needs to be configured. Depending on the platform, the gasket
> > > configuration requires knowing the CSI-2 DT. To provide the needed
> > > information, implement the .get_frame_desc() operation.
> > > 
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > ---
> > >  drivers/media/platform/nxp/imx-mipi-csis.c | 27 ++++++++++++++++++++++
> > >  1 file changed, 27 insertions(+)
> > > 
> > > diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
> > > index 8674aaad5fa0..905072871ed2 100644
> > > --- a/drivers/media/platform/nxp/imx-mipi-csis.c
> > > +++ b/drivers/media/platform/nxp/imx-mipi-csis.c
> > > @@ -1160,6 +1160,32 @@ static int mipi_csis_set_fmt(struct v4l2_subdev *sd,
> > >  	return 0;
> > >  }
> > >  
> > > +static int mipi_csis_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
> > > +				    struct v4l2_mbus_frame_desc *fd)
> > > +{
> > > +	struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd);
> > > +	struct v4l2_mbus_frame_desc_entry *entry = &fd->entry[0];
> > 
> > Think that you should check *fd before use here, other than that.
> 
> fd isn't supposed to be null, the same way sd isn't, or the various
> format pointers passed to other subdev operations aren't. We don't check
> those either, that's why I haven't checked fd here.

Yeah, agree. Thanks.

Cheers,
   Rui

> 
> > Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
> > 
> > > +
> > > +	if (pad != CSIS_PAD_SOURCE)
> > > +		return -EINVAL;
> > > +
> > > +	fd->type = V4L2_MBUS_FRAME_DESC_TYPE_PARALLEL;
> > > +	fd->num_entries = 1;
> > > +
> > > +	memset(entry, 0, sizeof(*entry));
> > > +
> > > +	mutex_lock(&csis->lock);
> > > +
> > > +	entry->flags = 0;
> > > +	entry->pixelcode = csis->csis_fmt->code;
> > > +	entry->bus.csi2.vc = 0;
> > > +	entry->bus.csi2.dt = csis->csis_fmt->data_type;
> > > +
> > > +	mutex_unlock(&csis->lock);
> > > +
> > > +	return 0;
> > > +}
> > > +
> > >  static int mipi_csis_log_status(struct v4l2_subdev *sd)
> > >  {
> > >  	struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd);
> > > @@ -1184,6 +1210,7 @@ static const struct v4l2_subdev_pad_ops mipi_csis_pad_ops = {
> > >  	.enum_mbus_code		= mipi_csis_enum_mbus_code,
> > >  	.get_fmt		= mipi_csis_get_fmt,
> > >  	.set_fmt		= mipi_csis_set_fmt,
> > > +	.get_frame_desc		= mipi_csis_get_frame_desc,
> > >  };
> > >  
> > >  static const struct v4l2_subdev_ops mipi_csis_subdev_ops = {
> 
> -- 
> Regards,
> 
> Laurent Pinchart

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-06-16  0:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 19:25 [PATCH 0/4] media: imx: imx-mipi-csis: Add i.MX8MP support Laurent Pinchart
2022-06-15 19:25 ` [PATCH 1/4] media: imx: imx-mipi-csis: Set the subdev fwnode for endpoint matching Laurent Pinchart
2022-06-15 23:50   ` Rui Miguel Silva
2022-06-15 19:26 ` [PATCH 2/4] media: imx: imx-mipi-csis: Add version register Laurent Pinchart
2022-06-15 23:51   ` Rui Miguel Silva
2022-06-15 19:26 ` [PATCH 3/4] media: imx: imx-mipi-csis: Implement the .get_frame_desc() operation Laurent Pinchart
2022-06-15 23:53   ` Rui Miguel Silva
2022-06-15 23:59     ` Laurent Pinchart
2022-06-16  0:09       ` Rui Miguel Silva
2022-06-15 19:26 ` [PATCH 4/4] dt-bindings: media: nxp,imx-mipi-csi2: i.MX8MP support Laurent Pinchart
2022-06-15 21:01   ` Krzysztof Kozlowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.