linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: i2c: rdacm2x: properly set subdev entity function
@ 2022-03-08 12:55 Laurentiu Palcu
  2022-03-09  8:43 ` Jacopo Mondi
  0 siblings, 1 reply; 4+ messages in thread
From: Laurentiu Palcu @ 2022-03-08 12:55 UTC (permalink / raw)
  To: Jacopo Mondi, Kieran Bingham, Laurent Pinchart,
	Niklas Söderlund, Mauro Carvalho Chehab
  Cc: Laurentiu Palcu, linux-media, linux-kernel

The subdevice entity function was left unset, which produces a warning
when probing the device:

mxc-md bus@58000000:camera: Entity type for entity rdacm20 19-0051 was
not initialized!

Also, set the entity flags to MEDIA_ENT_FL_DEFAULT instead of
MEDIA_ENT_F_CAM_SENSOR which will be used for entity's function instead.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
---
Hi,

Only tested the rdacm20 part but I believe rdacm21 should work as well.

Cheers,
laurentiu

 drivers/media/i2c/rdacm20.c | 3 ++-
 drivers/media/i2c/rdacm21.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/rdacm20.c b/drivers/media/i2c/rdacm20.c
index 025a610de893..ea5b7d5151ee 100644
--- a/drivers/media/i2c/rdacm20.c
+++ b/drivers/media/i2c/rdacm20.c
@@ -611,7 +611,8 @@ static int rdacm20_probe(struct i2c_client *client)
 		goto error_free_ctrls;
 
 	dev->pad.flags = MEDIA_PAD_FL_SOURCE;
-	dev->sd.entity.flags |= MEDIA_ENT_F_CAM_SENSOR;
+	dev->sd.entity.flags |= MEDIA_ENT_FL_DEFAULT;
+	dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
 	if (ret < 0)
 		goto error_free_ctrls;
diff --git a/drivers/media/i2c/rdacm21.c b/drivers/media/i2c/rdacm21.c
index 12ec5467ed1e..be89bd43e88b 100644
--- a/drivers/media/i2c/rdacm21.c
+++ b/drivers/media/i2c/rdacm21.c
@@ -583,7 +583,8 @@ static int rdacm21_probe(struct i2c_client *client)
 		goto error_free_ctrls;
 
 	dev->pad.flags = MEDIA_PAD_FL_SOURCE;
-	dev->sd.entity.flags |= MEDIA_ENT_F_CAM_SENSOR;
+	dev->sd.entity.flags |= MEDIA_ENT_FL_DEFAULT;
+	dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
 	if (ret < 0)
 		goto error_free_ctrls;
-- 
2.33.0


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

* Re: [PATCH] media: i2c: rdacm2x: properly set subdev entity function
  2022-03-08 12:55 [PATCH] media: i2c: rdacm2x: properly set subdev entity function Laurentiu Palcu
@ 2022-03-09  8:43 ` Jacopo Mondi
  2022-03-09  9:29   ` Laurentiu Palcu
  0 siblings, 1 reply; 4+ messages in thread
From: Jacopo Mondi @ 2022-03-09  8:43 UTC (permalink / raw)
  To: Laurentiu Palcu
  Cc: Jacopo Mondi, Kieran Bingham, Laurent Pinchart,
	Niklas Söderlund, Mauro Carvalho Chehab, linux-media,
	linux-kernel

Hi Laurentiu,

On Tue, Mar 08, 2022 at 02:55:49PM +0200, Laurentiu Palcu wrote:
> The subdevice entity function was left unset, which produces a warning
> when probing the device:
>
> mxc-md bus@58000000:camera: Entity type for entity rdacm20 19-0051 was
> not initialized!
>
> Also, set the entity flags to MEDIA_ENT_FL_DEFAULT instead of
> MEDIA_ENT_F_CAM_SENSOR which will be used for entity's function instead.
>
> Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
> ---
> Hi,
>
> Only tested the rdacm20 part but I believe rdacm21 should work as well.
>
> Cheers,
> laurentiu
>
>  drivers/media/i2c/rdacm20.c | 3 ++-
>  drivers/media/i2c/rdacm21.c | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/i2c/rdacm20.c b/drivers/media/i2c/rdacm20.c
> index 025a610de893..ea5b7d5151ee 100644
> --- a/drivers/media/i2c/rdacm20.c
> +++ b/drivers/media/i2c/rdacm20.c
> @@ -611,7 +611,8 @@ static int rdacm20_probe(struct i2c_client *client)
>  		goto error_free_ctrls;
>
>  	dev->pad.flags = MEDIA_PAD_FL_SOURCE;
> -	dev->sd.entity.flags |= MEDIA_ENT_F_CAM_SENSOR;
> +	dev->sd.entity.flags |= MEDIA_ENT_FL_DEFAULT;

I'm not sure if setting the DEFAULT flag is right:

 * %MEDIA_ENT_FL_DEFAULT
 *    indicates the default entity for a given type.
 *    This can be used to report the default audio and video devices or the
 *    default camera sensor.

In a typical setup there will be several RDACM2x in use, marking all
of them as "default" seems not right (if I understood the flag
description right).


> +	dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;

This seems right, and it's probably worth a Fixes tag?

Thanks
   j

>  	ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
>  	if (ret < 0)
>  		goto error_free_ctrls;
> diff --git a/drivers/media/i2c/rdacm21.c b/drivers/media/i2c/rdacm21.c
> index 12ec5467ed1e..be89bd43e88b 100644
> --- a/drivers/media/i2c/rdacm21.c
> +++ b/drivers/media/i2c/rdacm21.c
> @@ -583,7 +583,8 @@ static int rdacm21_probe(struct i2c_client *client)
>  		goto error_free_ctrls;
>
>  	dev->pad.flags = MEDIA_PAD_FL_SOURCE;
> -	dev->sd.entity.flags |= MEDIA_ENT_F_CAM_SENSOR;
> +	dev->sd.entity.flags |= MEDIA_ENT_FL_DEFAULT;
> +	dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
>  	ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
>  	if (ret < 0)
>  		goto error_free_ctrls;
> --
> 2.33.0
>

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

* Re: [PATCH] media: i2c: rdacm2x: properly set subdev entity function
  2022-03-09  8:43 ` Jacopo Mondi
@ 2022-03-09  9:29   ` Laurentiu Palcu
  2022-03-09 10:07     ` Kieran Bingham
  0 siblings, 1 reply; 4+ messages in thread
From: Laurentiu Palcu @ 2022-03-09  9:29 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: Jacopo Mondi, Kieran Bingham, Laurent Pinchart,
	Niklas Söderlund, Mauro Carvalho Chehab, linux-media,
	linux-kernel

Hi Jacopo,

On Wed, Mar 09, 2022 at 09:43:11AM +0100, Jacopo Mondi wrote:
> Hi Laurentiu,
> 
> On Tue, Mar 08, 2022 at 02:55:49PM +0200, Laurentiu Palcu wrote:
> > The subdevice entity function was left unset, which produces a warning
> > when probing the device:
> >
> > mxc-md bus@58000000:camera: Entity type for entity rdacm20 19-0051 was
> > not initialized!
> >
> > Also, set the entity flags to MEDIA_ENT_FL_DEFAULT instead of
> > MEDIA_ENT_F_CAM_SENSOR which will be used for entity's function instead.
> >
> > Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
> > ---
> > Hi,
> >
> > Only tested the rdacm20 part but I believe rdacm21 should work as well.
> >
> > Cheers,
> > laurentiu
> >
> >  drivers/media/i2c/rdacm20.c | 3 ++-
> >  drivers/media/i2c/rdacm21.c | 3 ++-
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/i2c/rdacm20.c b/drivers/media/i2c/rdacm20.c
> > index 025a610de893..ea5b7d5151ee 100644
> > --- a/drivers/media/i2c/rdacm20.c
> > +++ b/drivers/media/i2c/rdacm20.c
> > @@ -611,7 +611,8 @@ static int rdacm20_probe(struct i2c_client *client)
> >  		goto error_free_ctrls;
> >
> >  	dev->pad.flags = MEDIA_PAD_FL_SOURCE;
> > -	dev->sd.entity.flags |= MEDIA_ENT_F_CAM_SENSOR;
> > +	dev->sd.entity.flags |= MEDIA_ENT_FL_DEFAULT;
> 
> I'm not sure if setting the DEFAULT flag is right:
> 
>  * %MEDIA_ENT_FL_DEFAULT
>  *    indicates the default entity for a given type.
>  *    This can be used to report the default audio and video devices or the
>  *    default camera sensor.
> 
> In a typical setup there will be several RDACM2x in use, marking all
> of them as "default" seems not right (if I understood the flag
> description right).

My initial thought was to not set the entity flags at all. However,
since the old code had the flags set to MEDIA_ENT_F_CAM_SENSOR which is,
essentially, 0x20001, setting it to MEDIA_ENT_FL_DEFAULT (1 << 0) would
mean, basically, the same thing and would not affect existing user apps
that might already probe that flag... Removing the flag now might
potentially break existing apps. :/

Are there any other opinions on this one?

> 
> 
> > +	dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
> 
> This seems right, and it's probably worth a Fixes tag?

I'll send a v2 with the Fixes tag which I meant to add but totally
forgot...

Cheers,
Laurentiu

> 
> Thanks
>    j
> 
> >  	ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
> >  	if (ret < 0)
> >  		goto error_free_ctrls;
> > diff --git a/drivers/media/i2c/rdacm21.c b/drivers/media/i2c/rdacm21.c
> > index 12ec5467ed1e..be89bd43e88b 100644
> > --- a/drivers/media/i2c/rdacm21.c
> > +++ b/drivers/media/i2c/rdacm21.c
> > @@ -583,7 +583,8 @@ static int rdacm21_probe(struct i2c_client *client)
> >  		goto error_free_ctrls;
> >
> >  	dev->pad.flags = MEDIA_PAD_FL_SOURCE;
> > -	dev->sd.entity.flags |= MEDIA_ENT_F_CAM_SENSOR;
> > +	dev->sd.entity.flags |= MEDIA_ENT_FL_DEFAULT;
> > +	dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
> >  	ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
> >  	if (ret < 0)
> >  		goto error_free_ctrls;
> > --
> > 2.33.0
> >

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

* Re: [PATCH] media: i2c: rdacm2x: properly set subdev entity function
  2022-03-09  9:29   ` Laurentiu Palcu
@ 2022-03-09 10:07     ` Kieran Bingham
  0 siblings, 0 replies; 4+ messages in thread
From: Kieran Bingham @ 2022-03-09 10:07 UTC (permalink / raw)
  To: Jacopo Mondi, Laurentiu Palcu
  Cc: Jacopo Mondi, Laurent Pinchart, Niklas Söderlund,
	Mauro Carvalho Chehab, linux-media, linux-kernel

Quoting Laurentiu Palcu (2022-03-09 09:29:44)
> Hi Jacopo,
> 
> On Wed, Mar 09, 2022 at 09:43:11AM +0100, Jacopo Mondi wrote:
> > Hi Laurentiu,
> > 
> > On Tue, Mar 08, 2022 at 02:55:49PM +0200, Laurentiu Palcu wrote:
> > > The subdevice entity function was left unset, which produces a warning
> > > when probing the device:
> > >
> > > mxc-md bus@58000000:camera: Entity type for entity rdacm20 19-0051 was
> > > not initialized!
> > >
> > > Also, set the entity flags to MEDIA_ENT_FL_DEFAULT instead of
> > > MEDIA_ENT_F_CAM_SENSOR which will be used for entity's function instead.
> > >
> > > Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
> > > ---
> > > Hi,
> > >
> > > Only tested the rdacm20 part but I believe rdacm21 should work as well.
> > >
> > > Cheers,
> > > laurentiu
> > >
> > >  drivers/media/i2c/rdacm20.c | 3 ++-
> > >  drivers/media/i2c/rdacm21.c | 3 ++-
> > >  2 files changed, 4 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/media/i2c/rdacm20.c b/drivers/media/i2c/rdacm20.c
> > > index 025a610de893..ea5b7d5151ee 100644
> > > --- a/drivers/media/i2c/rdacm20.c
> > > +++ b/drivers/media/i2c/rdacm20.c
> > > @@ -611,7 +611,8 @@ static int rdacm20_probe(struct i2c_client *client)
> > >             goto error_free_ctrls;
> > >
> > >     dev->pad.flags = MEDIA_PAD_FL_SOURCE;
> > > -   dev->sd.entity.flags |= MEDIA_ENT_F_CAM_SENSOR;
> > > +   dev->sd.entity.flags |= MEDIA_ENT_FL_DEFAULT;
> > 
> > I'm not sure if setting the DEFAULT flag is right:
> > 
> >  * %MEDIA_ENT_FL_DEFAULT
> >  *    indicates the default entity for a given type.
> >  *    This can be used to report the default audio and video devices or the
> >  *    default camera sensor.
> > 
> > In a typical setup there will be several RDACM2x in use, marking all
> > of them as "default" seems not right (if I understood the flag
> > description right).
> 
> My initial thought was to not set the entity flags at all. However,
> since the old code had the flags set to MEDIA_ENT_F_CAM_SENSOR which is,
> essentially, 0x20001, setting it to MEDIA_ENT_FL_DEFAULT (1 << 0) would
> mean, basically, the same thing and would not affect existing user apps
> that might already probe that flag... Removing the flag now might
> potentially break existing apps. :/
> 
> Are there any other opinions on this one?

I don't think it's right to add an incorrect flag, and I don't think any
application should have been relying on this.

The only place an application should check for MEDIA_ENT_F_CAM_SENSOR is
in the entity function.

--
Kieran


> > 
> > 
> > > +   dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
> > 
> > This seems right, and it's probably worth a Fixes tag?
> 
> I'll send a v2 with the Fixes tag which I meant to add but totally
> forgot...
> 
> Cheers,
> Laurentiu
> 
> > 
> > Thanks
> >    j
> > 
> > >     ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
> > >     if (ret < 0)
> > >             goto error_free_ctrls;
> > > diff --git a/drivers/media/i2c/rdacm21.c b/drivers/media/i2c/rdacm21.c
> > > index 12ec5467ed1e..be89bd43e88b 100644
> > > --- a/drivers/media/i2c/rdacm21.c
> > > +++ b/drivers/media/i2c/rdacm21.c
> > > @@ -583,7 +583,8 @@ static int rdacm21_probe(struct i2c_client *client)
> > >             goto error_free_ctrls;
> > >
> > >     dev->pad.flags = MEDIA_PAD_FL_SOURCE;
> > > -   dev->sd.entity.flags |= MEDIA_ENT_F_CAM_SENSOR;
> > > +   dev->sd.entity.flags |= MEDIA_ENT_FL_DEFAULT;
> > > +   dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
> > >     ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
> > >     if (ret < 0)
> > >             goto error_free_ctrls;
> > > --
> > > 2.33.0
> > >

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

end of thread, other threads:[~2022-03-09 10:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08 12:55 [PATCH] media: i2c: rdacm2x: properly set subdev entity function Laurentiu Palcu
2022-03-09  8:43 ` Jacopo Mondi
2022-03-09  9:29   ` Laurentiu Palcu
2022-03-09 10:07     ` Kieran Bingham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).