All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Small MC + CIO2 cleanups
@ 2023-05-05 20:54 Sakari Ailus
  2023-05-05 20:54 ` [PATCH 1/2] media: uapi: Make media_entity_get_fwnode_pad() fwnode argument const Sakari Ailus
  2023-05-05 20:54 ` [PATCH 2/2] media: pci: ipu3-cio2: Obtain remote pad from endpoint Sakari Ailus
  0 siblings, 2 replies; 4+ messages in thread
From: Sakari Ailus @ 2023-05-05 20:54 UTC (permalink / raw)
  To: linux-media; +Cc: bingbu.cao

Hi all,

Here are two small cleanups for MC + IPU3 CIO2 driver.

Sakari Ailus (2):
  media: uapi: Make media_entity_get_fwnode_pad() fwnode argument const
  media: pci: ipu3-cio2: Obtain remote pad from endpoint

 drivers/media/mc/mc-entity.c                  |  2 +-
 drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 30 +++++++++----------
 include/media/media-entity.h                  |  2 +-
 3 files changed, 17 insertions(+), 17 deletions(-)

-- 
2.30.2


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

* [PATCH 1/2] media: uapi: Make media_entity_get_fwnode_pad() fwnode argument const
  2023-05-05 20:54 [PATCH 0/2] Small MC + CIO2 cleanups Sakari Ailus
@ 2023-05-05 20:54 ` Sakari Ailus
  2023-06-02  9:11   ` Laurent Pinchart
  2023-05-05 20:54 ` [PATCH 2/2] media: pci: ipu3-cio2: Obtain remote pad from endpoint Sakari Ailus
  1 sibling, 1 reply; 4+ messages in thread
From: Sakari Ailus @ 2023-05-05 20:54 UTC (permalink / raw)
  To: linux-media; +Cc: bingbu.cao

fwnode_graph_parse_endpoint() fwnode argument is now const, therefore make
media_entity_get_fwnode_pad() fwnode argument const as well.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/mc/mc-entity.c | 2 +-
 include/media/media-entity.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
index c1bc48c4d239..5ea9d3e5d59b 100644
--- a/drivers/media/mc/mc-entity.c
+++ b/drivers/media/mc/mc-entity.c
@@ -1426,7 +1426,7 @@ struct media_pad *media_pad_remote_pad_unique(const struct media_pad *pad)
 EXPORT_SYMBOL_GPL(media_pad_remote_pad_unique);
 
 int media_entity_get_fwnode_pad(struct media_entity *entity,
-				struct fwnode_handle *fwnode,
+				const struct fwnode_handle *fwnode,
 				unsigned long direction_flags)
 {
 	struct fwnode_endpoint endpoint;
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index e4f556911c3f..2b6cd343ee9e 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -1079,7 +1079,7 @@ struct media_pipeline *media_pad_pipeline(struct media_pad *pad);
  * Return: returns the pad number on success or a negative error code.
  */
 int media_entity_get_fwnode_pad(struct media_entity *entity,
-				struct fwnode_handle *fwnode,
+				const struct fwnode_handle *fwnode,
 				unsigned long direction_flags);
 
 /**
-- 
2.30.2


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

* [PATCH 2/2] media: pci: ipu3-cio2: Obtain remote pad from endpoint
  2023-05-05 20:54 [PATCH 0/2] Small MC + CIO2 cleanups Sakari Ailus
  2023-05-05 20:54 ` [PATCH 1/2] media: uapi: Make media_entity_get_fwnode_pad() fwnode argument const Sakari Ailus
@ 2023-05-05 20:54 ` Sakari Ailus
  1 sibling, 0 replies; 4+ messages in thread
From: Sakari Ailus @ 2023-05-05 20:54 UTC (permalink / raw)
  To: linux-media; +Cc: bingbu.cao

Use the endpoint fwnode to find out the remote pad, instead of using the
first source pad found. Also improve error messages.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 30 +++++++++----------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
index 3c84cb121632..0a6fbe0e29db 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
@@ -1373,6 +1373,7 @@ static const struct v4l2_subdev_ops cio2_subdev_ops = {
 struct sensor_async_subdev {
 	struct v4l2_async_subdev asd;
 	struct csi2_bus_info csi2;
+	struct fwnode_endpoint endpoint;
 };
 
 #define to_sensor_asd(asd)	container_of(asd, struct sensor_async_subdev, asd)
@@ -1424,24 +1425,22 @@ static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)
 		s_asd = to_sensor_asd(asd);
 		q = &cio2->queue[s_asd->csi2.port];
 
-		for (pad = 0; pad < q->sensor->entity.num_pads; pad++)
-			if (q->sensor->entity.pads[pad].flags &
-						MEDIA_PAD_FL_SOURCE)
-				break;
-
-		if (pad == q->sensor->entity.num_pads) {
-			dev_err(dev, "failed to find src pad for %s\n",
-				q->sensor->name);
-			return -ENXIO;
+		ret = media_entity_get_fwnode_pad(&q->sensor->entity,
+						  s_asd->endpoint.local_fwnode,
+						  MEDIA_PAD_FL_SOURCE);
+		if (ret < 0) {
+			dev_err(dev, "no endpoint for %pfw (%d)\n", s_asd->endpoint.local_fwnode, ret);
+			return ret;
 		}
 
-		ret = media_create_pad_link(
-				&q->sensor->entity, pad,
-				&q->subdev.entity, CIO2_PAD_SINK,
-				0);
+		pad = ret;
+
+		ret = media_create_pad_link(&q->sensor->entity, pad,
+					    &q->subdev.entity, CIO2_PAD_SINK,
+					    0);
 		if (ret) {
-			dev_err(dev, "failed to create link for %s\n",
-				q->sensor->name);
+			dev_err(dev, "failed to create link for %s (endpoint %pfw, error %d)\n",
+				q->sensor->name, s_asd->endpoint.local_fwnode, ret);
 			return ret;
 		}
 	}
@@ -1485,6 +1484,7 @@ static int cio2_parse_firmware(struct cio2_device *cio2)
 			goto err_parse;
 		}
 
+		s_asd->endpoint = vep.base;
 		s_asd->csi2.port = vep.base.port;
 		s_asd->csi2.lanes = vep.bus.mipi_csi2.num_data_lanes;
 
-- 
2.30.2


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

* Re: [PATCH 1/2] media: uapi: Make media_entity_get_fwnode_pad() fwnode argument const
  2023-05-05 20:54 ` [PATCH 1/2] media: uapi: Make media_entity_get_fwnode_pad() fwnode argument const Sakari Ailus
@ 2023-06-02  9:11   ` Laurent Pinchart
  0 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2023-06-02  9:11 UTC (permalink / raw)
  To: Sakari Ailus; +Cc: linux-media, bingbu.cao

Hi Sakari,

Thank you for the patch.

On Fri, May 05, 2023 at 11:54:15PM +0300, Sakari Ailus wrote:
> fwnode_graph_parse_endpoint() fwnode argument is now const, therefore make
> media_entity_get_fwnode_pad() fwnode argument const as well.

"now", since 2017 :-) I'd phrase the commit message as

The media_entity_get_fwnode_pad() function never modifies its fwnode
argument. Make it const to allow usage of the function in contexts where
the fwnode pointer is const.

> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

> ---
>  drivers/media/mc/mc-entity.c | 2 +-
>  include/media/media-entity.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
> index c1bc48c4d239..5ea9d3e5d59b 100644
> --- a/drivers/media/mc/mc-entity.c
> +++ b/drivers/media/mc/mc-entity.c
> @@ -1426,7 +1426,7 @@ struct media_pad *media_pad_remote_pad_unique(const struct media_pad *pad)
>  EXPORT_SYMBOL_GPL(media_pad_remote_pad_unique);
>  
>  int media_entity_get_fwnode_pad(struct media_entity *entity,
> -				struct fwnode_handle *fwnode,
> +				const struct fwnode_handle *fwnode,
>  				unsigned long direction_flags)
>  {
>  	struct fwnode_endpoint endpoint;
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index e4f556911c3f..2b6cd343ee9e 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -1079,7 +1079,7 @@ struct media_pipeline *media_pad_pipeline(struct media_pad *pad);
>   * Return: returns the pad number on success or a negative error code.
>   */
>  int media_entity_get_fwnode_pad(struct media_entity *entity,
> -				struct fwnode_handle *fwnode,
> +				const struct fwnode_handle *fwnode,
>  				unsigned long direction_flags);
>  
>  /**

-- 
Regards,

Laurent Pinchart

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

end of thread, other threads:[~2023-06-02  9:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-05 20:54 [PATCH 0/2] Small MC + CIO2 cleanups Sakari Ailus
2023-05-05 20:54 ` [PATCH 1/2] media: uapi: Make media_entity_get_fwnode_pad() fwnode argument const Sakari Ailus
2023-06-02  9:11   ` Laurent Pinchart
2023-05-05 20:54 ` [PATCH 2/2] media: pci: ipu3-cio2: Obtain remote pad from endpoint Sakari Ailus

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.