* [PATCH] media: Accept non-subdev sinks in v4l2_create_fwnode_links_to_pad()
@ 2023-03-24 10:35 Laurent Pinchart
2023-04-13 13:21 ` Vaishnav Achath
0 siblings, 1 reply; 4+ messages in thread
From: Laurent Pinchart @ 2023-03-24 10:35 UTC (permalink / raw)
To: linux-media; +Cc: Sakari Ailus, Vaishnav Achath
The v4l2_create_fwnode_links_to_pad() helper requires the sink pad
passed to it to belong to a subdev. This requirement can be lifted
easily. Make the function usable for non-subdev sinks, which allows
using it with video_device sinks.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
drivers/media/v4l2-core/v4l2-mc.c | 15 ++++++---------
include/media/v4l2-mc.h | 8 ++++----
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
index b01474717dca..bf0c18100664 100644
--- a/drivers/media/v4l2-core/v4l2-mc.c
+++ b/drivers/media/v4l2-core/v4l2-mc.c
@@ -313,14 +313,11 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
struct media_pad *sink, u32 flags)
{
struct fwnode_handle *endpoint;
- struct v4l2_subdev *sink_sd;
if (!(sink->flags & MEDIA_PAD_FL_SINK) ||
!is_media_entity_v4l2_subdev(sink->entity))
return -EINVAL;
- sink_sd = media_entity_to_v4l2_subdev(sink->entity);
-
fwnode_graph_for_each_endpoint(dev_fwnode(src_sd->dev), endpoint) {
struct fwnode_handle *remote_ep;
int src_idx, sink_idx, ret;
@@ -340,7 +337,7 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
* ask the sink to verify it owns the remote endpoint,
* and translate to a sink pad.
*/
- sink_idx = media_entity_get_fwnode_pad(&sink_sd->entity,
+ sink_idx = media_entity_get_fwnode_pad(sink->entity,
remote_ep,
MEDIA_PAD_FL_SINK);
fwnode_handle_put(remote_ep);
@@ -362,17 +359,17 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
if (media_entity_find_link(src, sink))
continue;
- dev_dbg(sink_sd->dev, "creating link %s:%d -> %s:%d\n",
+ dev_dbg(src_sd->dev, "creating link %s:%d -> %s:%d\n",
src_sd->entity.name, src_idx,
- sink_sd->entity.name, sink_idx);
+ sink->entity->name, sink_idx);
ret = media_create_pad_link(&src_sd->entity, src_idx,
- &sink_sd->entity, sink_idx, flags);
+ sink->entity, sink_idx, flags);
if (ret) {
- dev_err(sink_sd->dev,
+ dev_err(src_sd->dev,
"link %s:%d -> %s:%d failed with %d\n",
src_sd->entity.name, src_idx,
- sink_sd->entity.name, sink_idx, ret);
+ sink->entity->name, sink_idx, ret);
fwnode_handle_put(endpoint);
return ret;
diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h
index c181685923d5..b39586dfba35 100644
--- a/include/media/v4l2-mc.h
+++ b/include/media/v4l2-mc.h
@@ -87,17 +87,17 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q);
/**
* v4l2_create_fwnode_links_to_pad - Create fwnode-based links from a
- * source subdev to a sink subdev pad.
+ * source subdev to a sink pad.
*
* @src_sd: pointer to a source subdev
- * @sink: pointer to a subdev sink pad
+ * @sink: pointer to a sink pad
* @flags: the link flags
*
* This function searches for fwnode endpoint connections from a source
* subdevice to a single sink pad, and if suitable connections are found,
* translates them into media links to that pad. The function can be
- * called by the sink subdevice, in its v4l2-async notifier subdev bound
- * callback, to create links from a bound source subdevice.
+ * called by the sink, in its v4l2-async notifier bound callback, to create
+ * links from a bound source subdevice.
*
* The @flags argument specifies the link flags. The caller shall ensure that
* the flags are valid regardless of the number of links that may be created.
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] media: Accept non-subdev sinks in v4l2_create_fwnode_links_to_pad()
2023-03-24 10:35 [PATCH] media: Accept non-subdev sinks in v4l2_create_fwnode_links_to_pad() Laurent Pinchart
@ 2023-04-13 13:21 ` Vaishnav Achath
2023-04-20 16:45 ` Laurent Pinchart
0 siblings, 1 reply; 4+ messages in thread
From: Vaishnav Achath @ 2023-04-13 13:21 UTC (permalink / raw)
To: Laurent Pinchart, linux-media; +Cc: Sakari Ailus, Vaishnav Achath
Hi Laurent,
Thank you for the patch, sorry for the delay in response,
On 24/03/23 16:05, Laurent Pinchart wrote:
> The v4l2_create_fwnode_links_to_pad() helper requires the sink pad
> passed to it to belong to a subdev. This requirement can be lifted
> easily. Make the function usable for non-subdev sinks, which allows
> using it with video_device sinks.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> drivers/media/v4l2-core/v4l2-mc.c | 15 ++++++---------
> include/media/v4l2-mc.h | 8 ++++----
> 2 files changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
> index b01474717dca..bf0c18100664 100644
> --- a/drivers/media/v4l2-core/v4l2-mc.c
> +++ b/drivers/media/v4l2-core/v4l2-mc.c
> @@ -313,14 +313,11 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
> struct media_pad *sink, u32 flags)
> {
> struct fwnode_handle *endpoint;
> - struct v4l2_subdev *sink_sd;
>
> if (!(sink->flags & MEDIA_PAD_FL_SINK) ||
> !is_media_entity_v4l2_subdev(sink->entity))
should we drop the second check here also, i.e
!is_media_entity_v4l2_subdev(sink->entity)
to accept non-subdev sinks? is my understanding correct?
Thanks and Regards,
Vaishnav
> return -EINVAL;
>
> - sink_sd = media_entity_to_v4l2_subdev(sink->entity);
> -
> fwnode_graph_for_each_endpoint(dev_fwnode(src_sd->dev), endpoint) {
> struct fwnode_handle *remote_ep;
> int src_idx, sink_idx, ret;
> @@ -340,7 +337,7 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
> * ask the sink to verify it owns the remote endpoint,
> * and translate to a sink pad.
> */
> - sink_idx = media_entity_get_fwnode_pad(&sink_sd->entity,
> + sink_idx = media_entity_get_fwnode_pad(sink->entity,
> remote_ep,
> MEDIA_PAD_FL_SINK);
> fwnode_handle_put(remote_ep);
> @@ -362,17 +359,17 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
> if (media_entity_find_link(src, sink))
> continue;
>
> - dev_dbg(sink_sd->dev, "creating link %s:%d -> %s:%d\n",
> + dev_dbg(src_sd->dev, "creating link %s:%d -> %s:%d\n",
> src_sd->entity.name, src_idx,
> - sink_sd->entity.name, sink_idx);
> + sink->entity->name, sink_idx);
>
> ret = media_create_pad_link(&src_sd->entity, src_idx,
> - &sink_sd->entity, sink_idx, flags);
> + sink->entity, sink_idx, flags);
> if (ret) {
> - dev_err(sink_sd->dev,
> + dev_err(src_sd->dev,
> "link %s:%d -> %s:%d failed with %d\n",
> src_sd->entity.name, src_idx,
> - sink_sd->entity.name, sink_idx, ret);
> + sink->entity->name, sink_idx, ret);
>
> fwnode_handle_put(endpoint);
> return ret;
> diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h
> index c181685923d5..b39586dfba35 100644
> --- a/include/media/v4l2-mc.h
> +++ b/include/media/v4l2-mc.h
> @@ -87,17 +87,17 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q);
>
> /**
> * v4l2_create_fwnode_links_to_pad - Create fwnode-based links from a
> - * source subdev to a sink subdev pad.
> + * source subdev to a sink pad.
> *
> * @src_sd: pointer to a source subdev
> - * @sink: pointer to a subdev sink pad
> + * @sink: pointer to a sink pad
> * @flags: the link flags
> *
> * This function searches for fwnode endpoint connections from a source
> * subdevice to a single sink pad, and if suitable connections are found,
> * translates them into media links to that pad. The function can be
> - * called by the sink subdevice, in its v4l2-async notifier subdev bound
> - * callback, to create links from a bound source subdevice.
> + * called by the sink, in its v4l2-async notifier bound callback, to create
> + * links from a bound source subdevice.
> *
> * The @flags argument specifies the link flags. The caller shall ensure that
> * the flags are valid regardless of the number of links that may be created.
--
Regards,
Vaishnav
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] media: Accept non-subdev sinks in v4l2_create_fwnode_links_to_pad()
2023-04-13 13:21 ` Vaishnav Achath
@ 2023-04-20 16:45 ` Laurent Pinchart
2023-04-21 12:01 ` Vaishnav Achath
0 siblings, 1 reply; 4+ messages in thread
From: Laurent Pinchart @ 2023-04-20 16:45 UTC (permalink / raw)
To: Vaishnav Achath; +Cc: linux-media, Sakari Ailus
Hi Vaishnav,
On Thu, Apr 13, 2023 at 06:51:23PM +0530, Vaishnav Achath wrote:
> Hi Laurent,
>
> Thank you for the patch, sorry for the delay in response,
>
> On 24/03/23 16:05, Laurent Pinchart wrote:
> > The v4l2_create_fwnode_links_to_pad() helper requires the sink pad
> > passed to it to belong to a subdev. This requirement can be lifted
> > easily. Make the function usable for non-subdev sinks, which allows
> > using it with video_device sinks.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > drivers/media/v4l2-core/v4l2-mc.c | 15 ++++++---------
> > include/media/v4l2-mc.h | 8 ++++----
> > 2 files changed, 10 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
> > index b01474717dca..bf0c18100664 100644
> > --- a/drivers/media/v4l2-core/v4l2-mc.c
> > +++ b/drivers/media/v4l2-core/v4l2-mc.c
> > @@ -313,14 +313,11 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
> > struct media_pad *sink, u32 flags)
> > {
> > struct fwnode_handle *endpoint;
> > - struct v4l2_subdev *sink_sd;
> >
> > if (!(sink->flags & MEDIA_PAD_FL_SINK) ||
> > !is_media_entity_v4l2_subdev(sink->entity))
>
> should we drop the second check here also, i.e
>
> !is_media_entity_v4l2_subdev(sink->entity)
>
> to accept non-subdev sinks? is my understanding correct?
You're absolutely right. The patch has been merged already I'm afraid.
Would you like to submit a fix, or should I do so ? In the latter case,
can I include a Reported-by tag with your name ?
> > return -EINVAL;
> >
> > - sink_sd = media_entity_to_v4l2_subdev(sink->entity);
> > -
> > fwnode_graph_for_each_endpoint(dev_fwnode(src_sd->dev), endpoint) {
> > struct fwnode_handle *remote_ep;
> > int src_idx, sink_idx, ret;
> > @@ -340,7 +337,7 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
> > * ask the sink to verify it owns the remote endpoint,
> > * and translate to a sink pad.
> > */
> > - sink_idx = media_entity_get_fwnode_pad(&sink_sd->entity,
> > + sink_idx = media_entity_get_fwnode_pad(sink->entity,
> > remote_ep,
> > MEDIA_PAD_FL_SINK);
> > fwnode_handle_put(remote_ep);
> > @@ -362,17 +359,17 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
> > if (media_entity_find_link(src, sink))
> > continue;
> >
> > - dev_dbg(sink_sd->dev, "creating link %s:%d -> %s:%d\n",
> > + dev_dbg(src_sd->dev, "creating link %s:%d -> %s:%d\n",
> > src_sd->entity.name, src_idx,
> > - sink_sd->entity.name, sink_idx);
> > + sink->entity->name, sink_idx);
> >
> > ret = media_create_pad_link(&src_sd->entity, src_idx,
> > - &sink_sd->entity, sink_idx, flags);
> > + sink->entity, sink_idx, flags);
> > if (ret) {
> > - dev_err(sink_sd->dev,
> > + dev_err(src_sd->dev,
> > "link %s:%d -> %s:%d failed with %d\n",
> > src_sd->entity.name, src_idx,
> > - sink_sd->entity.name, sink_idx, ret);
> > + sink->entity->name, sink_idx, ret);
> >
> > fwnode_handle_put(endpoint);
> > return ret;
> > diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h
> > index c181685923d5..b39586dfba35 100644
> > --- a/include/media/v4l2-mc.h
> > +++ b/include/media/v4l2-mc.h
> > @@ -87,17 +87,17 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q);
> >
> > /**
> > * v4l2_create_fwnode_links_to_pad - Create fwnode-based links from a
> > - * source subdev to a sink subdev pad.
> > + * source subdev to a sink pad.
> > *
> > * @src_sd: pointer to a source subdev
> > - * @sink: pointer to a subdev sink pad
> > + * @sink: pointer to a sink pad
> > * @flags: the link flags
> > *
> > * This function searches for fwnode endpoint connections from a source
> > * subdevice to a single sink pad, and if suitable connections are found,
> > * translates them into media links to that pad. The function can be
> > - * called by the sink subdevice, in its v4l2-async notifier subdev bound
> > - * callback, to create links from a bound source subdevice.
> > + * called by the sink, in its v4l2-async notifier bound callback, to create
> > + * links from a bound source subdevice.
> > *
> > * The @flags argument specifies the link flags. The caller shall ensure that
> > * the flags are valid regardless of the number of links that may be created.
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] media: Accept non-subdev sinks in v4l2_create_fwnode_links_to_pad()
2023-04-20 16:45 ` Laurent Pinchart
@ 2023-04-21 12:01 ` Vaishnav Achath
0 siblings, 0 replies; 4+ messages in thread
From: Vaishnav Achath @ 2023-04-21 12:01 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: linux-media, Sakari Ailus, u-kumar1
Hi Laurent,
On 20/04/23 22:15, Laurent Pinchart wrote:
> Hi Vaishnav,
>
> On Thu, Apr 13, 2023 at 06:51:23PM +0530, Vaishnav Achath wrote:
>> Hi Laurent,
>>
>> Thank you for the patch, sorry for the delay in response,
>>
>> On 24/03/23 16:05, Laurent Pinchart wrote:
>>> The v4l2_create_fwnode_links_to_pad() helper requires the sink pad
>>> passed to it to belong to a subdev. This requirement can be lifted
>>> easily. Make the function usable for non-subdev sinks, which allows
>>> using it with video_device sinks.
>>>
>>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> ---
>>> drivers/media/v4l2-core/v4l2-mc.c | 15 ++++++---------
>>> include/media/v4l2-mc.h | 8 ++++----
>>> 2 files changed, 10 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
>>> index b01474717dca..bf0c18100664 100644
>>> --- a/drivers/media/v4l2-core/v4l2-mc.c
>>> +++ b/drivers/media/v4l2-core/v4l2-mc.c
>>> @@ -313,14 +313,11 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
>>> struct media_pad *sink, u32 flags)
>>> {
>>> struct fwnode_handle *endpoint;
>>> - struct v4l2_subdev *sink_sd;
>>>
>>> if (!(sink->flags & MEDIA_PAD_FL_SINK) ||
>>> !is_media_entity_v4l2_subdev(sink->entity))
>>
>> should we drop the second check here also, i.e
>>
>> !is_media_entity_v4l2_subdev(sink->entity)
>>
>> to accept non-subdev sinks? is my understanding correct?
>
> You're absolutely right. The patch has been merged already I'm afraid.
> Would you like to submit a fix, or should I do so ? In the latter case,
> can I include a Reported-by tag with your name ?
>
Thank you for confirming, I have send a fix for this as I had tested with the
fix while reworking the j721e-csi2rx series,
https://lore.kernel.org/all/20230421100430.28962-1-vaishnav.a@ti.com/
Thanks and Regards,
Vaishnav
>>> return -EINVAL;
>>>
>>> - sink_sd = media_entity_to_v4l2_subdev(sink->entity);
>>> -
>>> fwnode_graph_for_each_endpoint(dev_fwnode(src_sd->dev), endpoint) {
>>> struct fwnode_handle *remote_ep;
>>> int src_idx, sink_idx, ret;
>>> @@ -340,7 +337,7 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
>>> * ask the sink to verify it owns the remote endpoint,
>>> * and translate to a sink pad.
>>> */
>>> - sink_idx = media_entity_get_fwnode_pad(&sink_sd->entity,
>>> + sink_idx = media_entity_get_fwnode_pad(sink->entity,
>>> remote_ep,
>>> MEDIA_PAD_FL_SINK);
>>> fwnode_handle_put(remote_ep);
>>> @@ -362,17 +359,17 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
>>> if (media_entity_find_link(src, sink))
>>> continue;
>>>
>>> - dev_dbg(sink_sd->dev, "creating link %s:%d -> %s:%d\n",
>>> + dev_dbg(src_sd->dev, "creating link %s:%d -> %s:%d\n",
>>> src_sd->entity.name, src_idx,
>>> - sink_sd->entity.name, sink_idx);
>>> + sink->entity->name, sink_idx);
>>>
>>> ret = media_create_pad_link(&src_sd->entity, src_idx,
>>> - &sink_sd->entity, sink_idx, flags);
>>> + sink->entity, sink_idx, flags);
>>> if (ret) {
>>> - dev_err(sink_sd->dev,
>>> + dev_err(src_sd->dev,
>>> "link %s:%d -> %s:%d failed with %d\n",
>>> src_sd->entity.name, src_idx,
>>> - sink_sd->entity.name, sink_idx, ret);
>>> + sink->entity->name, sink_idx, ret);
>>>
>>> fwnode_handle_put(endpoint);
>>> return ret;
>>> diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h
>>> index c181685923d5..b39586dfba35 100644
>>> --- a/include/media/v4l2-mc.h
>>> +++ b/include/media/v4l2-mc.h
>>> @@ -87,17 +87,17 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q);
>>>
>>> /**
>>> * v4l2_create_fwnode_links_to_pad - Create fwnode-based links from a
>>> - * source subdev to a sink subdev pad.
>>> + * source subdev to a sink pad.
>>> *
>>> * @src_sd: pointer to a source subdev
>>> - * @sink: pointer to a subdev sink pad
>>> + * @sink: pointer to a sink pad
>>> * @flags: the link flags
>>> *
>>> * This function searches for fwnode endpoint connections from a source
>>> * subdevice to a single sink pad, and if suitable connections are found,
>>> * translates them into media links to that pad. The function can be
>>> - * called by the sink subdevice, in its v4l2-async notifier subdev bound
>>> - * callback, to create links from a bound source subdevice.
>>> + * called by the sink, in its v4l2-async notifier bound callback, to create
>>> + * links from a bound source subdevice.
>>> *
>>> * The @flags argument specifies the link flags. The caller shall ensure that
>>> * the flags are valid regardless of the number of links that may be created.
>
--
Regards,
Vaishnav
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-21 12:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24 10:35 [PATCH] media: Accept non-subdev sinks in v4l2_create_fwnode_links_to_pad() Laurent Pinchart
2023-04-13 13:21 ` Vaishnav Achath
2023-04-20 16:45 ` Laurent Pinchart
2023-04-21 12:01 ` Vaishnav Achath
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.