All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] V4L: add convenience macros to the subdevice / Media Controller API
@ 2011-09-29  8:18 Guennadi Liakhovetski
  2011-09-29  8:31 ` Laurent Pinchart
  0 siblings, 1 reply; 8+ messages in thread
From: Guennadi Liakhovetski @ 2011-09-29  8:18 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Laurent Pinchart

Drivers, that can be built and work with and without
CONFIG_VIDEO_V4L2_SUBDEV_API, need the v4l2_subdev_get_try_format() and
v4l2_subdev_get_try_crop() functions, even though their return value
should never be dereferenced. Also add convenience macros to init and
clean up subdevice internal media entities.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 include/media/v4l2-subdev.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index f0f3358..4670506 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -569,6 +569,9 @@ v4l2_subdev_get_try_crop(struct v4l2_subdev_fh *fh, unsigned int pad)
 {
 	return &fh->try_crop[pad];
 }
+#else
+#define v4l2_subdev_get_try_format(arg...)	NULL
+#define v4l2_subdev_get_try_crop(arg...)	NULL
 #endif
 
 extern const struct v4l2_file_operations v4l2_subdev_fops;
@@ -610,4 +613,12 @@ void v4l2_subdev_init(struct v4l2_subdev *sd,
 	((!(sd) || !(sd)->v4l2_dev || !(sd)->v4l2_dev->notify) ? -ENODEV : \
 	 (sd)->v4l2_dev->notify((sd), (notification), (arg)))
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+#define subdev_media_entity_init(sd, n, p, e)	media_entity_init(&(sd)->entity, n, p, e)
+#define subdev_media_entity_cleanup(sd)		media_entity_cleanup(&(sd)->entity)
+#else
+#define subdev_media_entity_init(sd, n, p, e)	0
+#define subdev_media_entity_cleanup(sd)		do {} while (0)
+#endif
+
 #endif
-- 
1.7.2.5


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

* Re: [PATCH] V4L: add convenience macros to the subdevice / Media Controller API
  2011-09-29  8:18 [PATCH] V4L: add convenience macros to the subdevice / Media Controller API Guennadi Liakhovetski
@ 2011-09-29  8:31 ` Laurent Pinchart
  2011-09-29  8:44   ` Guennadi Liakhovetski
  0 siblings, 1 reply; 8+ messages in thread
From: Laurent Pinchart @ 2011-09-29  8:31 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: Linux Media Mailing List

Hi Guennadi,

Thanks for the patch.

On Thursday 29 September 2011 10:18:31 Guennadi Liakhovetski wrote:
> Drivers, that can be built and work with and without
> CONFIG_VIDEO_V4L2_SUBDEV_API, need the v4l2_subdev_get_try_format() and
> v4l2_subdev_get_try_crop() functions, even though their return value
> should never be dereferenced. Also add convenience macros to init and
> clean up subdevice internal media entities.

Why don't you just make the drivers depend on CONFIG_VIDEO_V4L2_SUBDEV_API ? 
They don't need to actually export a device node to userspace, but they 
require the in-kernel API.

> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
>  include/media/v4l2-subdev.h |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
> 
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index f0f3358..4670506 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -569,6 +569,9 @@ v4l2_subdev_get_try_crop(struct v4l2_subdev_fh *fh,
> unsigned int pad) {
>  	return &fh->try_crop[pad];
>  }
> +#else
> +#define v4l2_subdev_get_try_format(arg...)	NULL
> +#define v4l2_subdev_get_try_crop(arg...)	NULL
>  #endif
> 
>  extern const struct v4l2_file_operations v4l2_subdev_fops;
> @@ -610,4 +613,12 @@ void v4l2_subdev_init(struct v4l2_subdev *sd,
>  	((!(sd) || !(sd)->v4l2_dev || !(sd)->v4l2_dev->notify) ? -ENODEV : \
>  	 (sd)->v4l2_dev->notify((sd), (notification), (arg)))
> 
> +#if defined(CONFIG_MEDIA_CONTROLLER)
> +#define subdev_media_entity_init(sd, n, p,
> e)	media_entity_init(&(sd)->entity, n, p, e) +#define
> subdev_media_entity_cleanup(sd)		media_entity_cleanup(&(sd)->entity)
> +#else
> +#define subdev_media_entity_init(sd, n, p, e)	0
> +#define subdev_media_entity_cleanup(sd)		do {} while (0)
> +#endif
> +
>  #endif

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH] V4L: add convenience macros to the subdevice / Media Controller API
  2011-09-29  8:31 ` Laurent Pinchart
@ 2011-09-29  8:44   ` Guennadi Liakhovetski
  2011-09-29 11:11     ` Laurent Pinchart
  0 siblings, 1 reply; 8+ messages in thread
From: Guennadi Liakhovetski @ 2011-09-29  8:44 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Linux Media Mailing List

On Thu, 29 Sep 2011, Laurent Pinchart wrote:

> Hi Guennadi,
> 
> Thanks for the patch.
> 
> On Thursday 29 September 2011 10:18:31 Guennadi Liakhovetski wrote:
> > Drivers, that can be built and work with and without
> > CONFIG_VIDEO_V4L2_SUBDEV_API, need the v4l2_subdev_get_try_format() and
> > v4l2_subdev_get_try_crop() functions, even though their return value
> > should never be dereferenced. Also add convenience macros to init and
> > clean up subdevice internal media entities.
> 
> Why don't you just make the drivers depend on CONFIG_VIDEO_V4L2_SUBDEV_API ? 
> They don't need to actually export a device node to userspace, but they 
> require the in-kernel API.

Why? Why should the user build and load all the media controller stuff, 
buy all the in-kernel objects and code to never actually use it? Where 
OTOH all is needed to avoid that is a couple of NOP macros?

Thanks
Guennadi

> 
> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> > ---
> >  include/media/v4l2-subdev.h |   11 +++++++++++
> >  1 files changed, 11 insertions(+), 0 deletions(-)
> > 
> > diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> > index f0f3358..4670506 100644
> > --- a/include/media/v4l2-subdev.h
> > +++ b/include/media/v4l2-subdev.h
> > @@ -569,6 +569,9 @@ v4l2_subdev_get_try_crop(struct v4l2_subdev_fh *fh,
> > unsigned int pad) {
> >  	return &fh->try_crop[pad];
> >  }
> > +#else
> > +#define v4l2_subdev_get_try_format(arg...)	NULL
> > +#define v4l2_subdev_get_try_crop(arg...)	NULL
> >  #endif
> > 
> >  extern const struct v4l2_file_operations v4l2_subdev_fops;
> > @@ -610,4 +613,12 @@ void v4l2_subdev_init(struct v4l2_subdev *sd,
> >  	((!(sd) || !(sd)->v4l2_dev || !(sd)->v4l2_dev->notify) ? -ENODEV : \
> >  	 (sd)->v4l2_dev->notify((sd), (notification), (arg)))
> > 
> > +#if defined(CONFIG_MEDIA_CONTROLLER)
> > +#define subdev_media_entity_init(sd, n, p,
> > e)	media_entity_init(&(sd)->entity, n, p, e) +#define
> > subdev_media_entity_cleanup(sd)		media_entity_cleanup(&(sd)->entity)
> > +#else
> > +#define subdev_media_entity_init(sd, n, p, e)	0
> > +#define subdev_media_entity_cleanup(sd)		do {} while (0)
> > +#endif
> > +
> >  #endif
> 
> -- 
> Regards,
> 
> Laurent Pinchart
> 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

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

* Re: [PATCH] V4L: add convenience macros to the subdevice / Media Controller API
  2011-09-29  8:44   ` Guennadi Liakhovetski
@ 2011-09-29 11:11     ` Laurent Pinchart
  2011-12-06  8:40       ` Guennadi Liakhovetski
  0 siblings, 1 reply; 8+ messages in thread
From: Laurent Pinchart @ 2011-09-29 11:11 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: Linux Media Mailing List

Hi Guennadi,

On Thursday 29 September 2011 10:44:14 Guennadi Liakhovetski wrote:
> On Thu, 29 Sep 2011, Laurent Pinchart wrote:
> > On Thursday 29 September 2011 10:18:31 Guennadi Liakhovetski wrote:
> > > Drivers, that can be built and work with and without
> > > CONFIG_VIDEO_V4L2_SUBDEV_API, need the v4l2_subdev_get_try_format() and
> > > v4l2_subdev_get_try_crop() functions, even though their return value
> > > should never be dereferenced. Also add convenience macros to init and
> > > clean up subdevice internal media entities.
> > 
> > Why don't you just make the drivers depend on
> > CONFIG_VIDEO_V4L2_SUBDEV_API ? They don't need to actually export a
> > device node to userspace, but they require the in-kernel API.
> 
> Why? Why should the user build and load all the media controller stuff,
> buy all the in-kernel objects and code to never actually use it? Where
> OTOH all is needed to avoid that is a couple of NOP macros?

Because the automatic compatibility layer that will translate video operations 
to pad operations will need to access pads, so subdevs that implement a pad-
level API need to export it to the bridge, even if the bridge is not MC-aware.

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH] V4L: add convenience macros to the subdevice / Media Controller API
  2011-09-29 11:11     ` Laurent Pinchart
@ 2011-12-06  8:40       ` Guennadi Liakhovetski
  2011-12-06 10:49         ` Laurent Pinchart
  0 siblings, 1 reply; 8+ messages in thread
From: Guennadi Liakhovetski @ 2011-12-06  8:40 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Linux Media Mailing List

Hi Laurent

On Thu, 29 Sep 2011, Laurent Pinchart wrote:

> Hi Guennadi,
> 
> On Thursday 29 September 2011 10:44:14 Guennadi Liakhovetski wrote:
> > On Thu, 29 Sep 2011, Laurent Pinchart wrote:
> > > On Thursday 29 September 2011 10:18:31 Guennadi Liakhovetski wrote:
> > > > Drivers, that can be built and work with and without
> > > > CONFIG_VIDEO_V4L2_SUBDEV_API, need the v4l2_subdev_get_try_format() and
> > > > v4l2_subdev_get_try_crop() functions, even though their return value
> > > > should never be dereferenced. Also add convenience macros to init and
> > > > clean up subdevice internal media entities.
> > > 
> > > Why don't you just make the drivers depend on
> > > CONFIG_VIDEO_V4L2_SUBDEV_API ? They don't need to actually export a
> > > device node to userspace, but they require the in-kernel API.
> > 
> > Why? Why should the user build and load all the media controller stuff,
> > buy all the in-kernel objects and code to never actually use it? Where
> > OTOH all is needed to avoid that is a couple of NOP macros?
> 
> Because the automatic compatibility layer that will translate video operations 
> to pad operations will need to access pads, so subdevs that implement a pad-
> level API need to export it to the bridge, even if the bridge is not MC-aware.

I might be missing something, but it seems to me, that if 
CONFIG_VIDEO_V4L2_SUBDEV_API is not defined, no pads are exported to the 
user space (and you mean a compatibility layer in the user space, don't 
you?), so, noone will be able to accesss them.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

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

* Re: [PATCH] V4L: add convenience macros to the subdevice / Media Controller API
  2011-12-06  8:40       ` Guennadi Liakhovetski
@ 2011-12-06 10:49         ` Laurent Pinchart
  2011-12-06 12:04           ` Guennadi Liakhovetski
  0 siblings, 1 reply; 8+ messages in thread
From: Laurent Pinchart @ 2011-12-06 10:49 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: Linux Media Mailing List

Hi Guennadi,

On Tuesday 06 December 2011 09:40:41 Guennadi Liakhovetski wrote:
> On Thu, 29 Sep 2011, Laurent Pinchart wrote:
> > On Thursday 29 September 2011 10:44:14 Guennadi Liakhovetski wrote:
> > > On Thu, 29 Sep 2011, Laurent Pinchart wrote:
> > > > On Thursday 29 September 2011 10:18:31 Guennadi Liakhovetski wrote:
> > > > > Drivers, that can be built and work with and without
> > > > > CONFIG_VIDEO_V4L2_SUBDEV_API, need the v4l2_subdev_get_try_format()
> > > > > and v4l2_subdev_get_try_crop() functions, even though their return
> > > > > value should never be dereferenced. Also add convenience macros to
> > > > > init and clean up subdevice internal media entities.
> > > > 
> > > > Why don't you just make the drivers depend on
> > > > CONFIG_VIDEO_V4L2_SUBDEV_API ? They don't need to actually export a
> > > > device node to userspace, but they require the in-kernel API.
> > > 
> > > Why? Why should the user build and load all the media controller stuff,
> > > buy all the in-kernel objects and code to never actually use it? Where
> > > OTOH all is needed to avoid that is a couple of NOP macros?
> > 
> > Because the automatic compatibility layer that will translate video
> > operations to pad operations will need to access pads, so subdevs that
> > implement a pad- level API need to export it to the bridge, even if the
> > bridge is not MC-aware.
> 
> I might be missing something, but it seems to me, that if
> CONFIG_VIDEO_V4L2_SUBDEV_API is not defined, no pads are exported to the
> user space (and you mean a compatibility layer in the user space, don't
> you?), so, noone will be able to accesss them.

No, I meant a compatibility layer in kernel space. Basically something like 
(totally untested)

int v4l2_subdev_get_mbus_format(struct v4l2_subdev *sd, struct 
v4l2_mbus_framefmt *format)
{
	struct v4l2_subdev_format fmt;
	int ret;

	ret = v4l2_subdev_call(sd, video, g_mbus_fmt, format);
	if (ret != ENOIOCTLCMD)
		return ret;

	fmt.pad = 0;
	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
	fmt.format = *format;

	ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &fmt);
	if (ret < 0 && ret != ENOIOCTLCMD)
		*format = fmt.format;

	return ret;
}

Or the other way around, trying pad::get_fmt before video::g_mbus_fmt.

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH] V4L: add convenience macros to the subdevice / Media Controller API
  2011-12-06 10:49         ` Laurent Pinchart
@ 2011-12-06 12:04           ` Guennadi Liakhovetski
  2011-12-11 23:38             ` Laurent Pinchart
  0 siblings, 1 reply; 8+ messages in thread
From: Guennadi Liakhovetski @ 2011-12-06 12:04 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Linux Media Mailing List

On Tue, 6 Dec 2011, Laurent Pinchart wrote:

> Hi Guennadi,
> 
> On Tuesday 06 December 2011 09:40:41 Guennadi Liakhovetski wrote:
> > On Thu, 29 Sep 2011, Laurent Pinchart wrote:
> > > On Thursday 29 September 2011 10:44:14 Guennadi Liakhovetski wrote:
> > > > On Thu, 29 Sep 2011, Laurent Pinchart wrote:
> > > > > On Thursday 29 September 2011 10:18:31 Guennadi Liakhovetski wrote:
> > > > > > Drivers, that can be built and work with and without
> > > > > > CONFIG_VIDEO_V4L2_SUBDEV_API, need the v4l2_subdev_get_try_format()
> > > > > > and v4l2_subdev_get_try_crop() functions, even though their return
> > > > > > value should never be dereferenced. Also add convenience macros to
> > > > > > init and clean up subdevice internal media entities.
> > > > > 
> > > > > Why don't you just make the drivers depend on
> > > > > CONFIG_VIDEO_V4L2_SUBDEV_API ? They don't need to actually export a
> > > > > device node to userspace, but they require the in-kernel API.
> > > > 
> > > > Why? Why should the user build and load all the media controller stuff,
> > > > buy all the in-kernel objects and code to never actually use it? Where
> > > > OTOH all is needed to avoid that is a couple of NOP macros?
> > > 
> > > Because the automatic compatibility layer that will translate video
> > > operations to pad operations will need to access pads, so subdevs that
> > > implement a pad- level API need to export it to the bridge, even if the
> > > bridge is not MC-aware.
> > 
> > I might be missing something, but it seems to me, that if
> > CONFIG_VIDEO_V4L2_SUBDEV_API is not defined, no pads are exported to the
> > user space (and you mean a compatibility layer in the user space, don't
> > you?), so, noone will be able to accesss them.
> 
> No, I meant a compatibility layer in kernel space. Basically something like 
> (totally untested)

Aha, so, a "future" layer.

> int v4l2_subdev_get_mbus_format(struct v4l2_subdev *sd, struct 
> v4l2_mbus_framefmt *format)
> {
> 	struct v4l2_subdev_format fmt;
> 	int ret;
> 
> 	ret = v4l2_subdev_call(sd, video, g_mbus_fmt, format);
> 	if (ret != ENOIOCTLCMD)

you mean "-E..."

> 		return ret;
> 
> 	fmt.pad = 0;
> 	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
> 	fmt.format = *format;
> 
> 	ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &fmt);
> 	if (ret < 0 && ret != ENOIOCTLCMD)

You, probably, actually mean "if (!ret)"

> 		*format = fmt.format;
> 
> 	return ret;
> }
> 
> Or the other way around, trying pad::get_fmt before video::g_mbus_fmt.

Ok, I understand what you mean now. Any idea when this layer is going to 
be implemented?

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

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

* Re: [PATCH] V4L: add convenience macros to the subdevice / Media Controller API
  2011-12-06 12:04           ` Guennadi Liakhovetski
@ 2011-12-11 23:38             ` Laurent Pinchart
  0 siblings, 0 replies; 8+ messages in thread
From: Laurent Pinchart @ 2011-12-11 23:38 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: Linux Media Mailing List

Hi Guennadi,

On Tuesday 06 December 2011 13:04:00 Guennadi Liakhovetski wrote:
> On Tue, 6 Dec 2011, Laurent Pinchart wrote:
> > On Tuesday 06 December 2011 09:40:41 Guennadi Liakhovetski wrote:
> > > On Thu, 29 Sep 2011, Laurent Pinchart wrote:
> > > > On Thursday 29 September 2011 10:44:14 Guennadi Liakhovetski wrote:
> > > > > On Thu, 29 Sep 2011, Laurent Pinchart wrote:
> > > > > > On Thursday 29 September 2011 10:18:31 Guennadi Liakhovetski 
wrote:
> > > > > > > Drivers, that can be built and work with and without
> > > > > > > CONFIG_VIDEO_V4L2_SUBDEV_API, need the
> > > > > > > v4l2_subdev_get_try_format() and v4l2_subdev_get_try_crop()
> > > > > > > functions, even though their return value should never be
> > > > > > > dereferenced. Also add convenience macros to init and clean up
> > > > > > > subdevice internal media entities.
> > > > > > 
> > > > > > Why don't you just make the drivers depend on
> > > > > > CONFIG_VIDEO_V4L2_SUBDEV_API ? They don't need to actually export
> > > > > > a device node to userspace, but they require the in-kernel API.
> > > > > 
> > > > > Why? Why should the user build and load all the media controller
> > > > > stuff, buy all the in-kernel objects and code to never actually
> > > > > use it? Where OTOH all is needed to avoid that is a couple of NOP
> > > > > macros?
> > > > 
> > > > Because the automatic compatibility layer that will translate video
> > > > operations to pad operations will need to access pads, so subdevs
> > > > that implement a pad- level API need to export it to the bridge,
> > > > even if the bridge is not MC-aware.
> > > 
> > > I might be missing something, but it seems to me, that if
> > > CONFIG_VIDEO_V4L2_SUBDEV_API is not defined, no pads are exported to
> > > the user space (and you mean a compatibility layer in the user space,
> > > don't you?), so, noone will be able to accesss them.
> > 
> > No, I meant a compatibility layer in kernel space. Basically something
> > like (totally untested)
> 
> Aha, so, a "future" layer.
> 
> > int v4l2_subdev_get_mbus_format(struct v4l2_subdev *sd, struct
> > v4l2_mbus_framefmt *format)
> > {
> > 
> > 	struct v4l2_subdev_format fmt;
> > 	int ret;
> > 	
> > 	ret = v4l2_subdev_call(sd, video, g_mbus_fmt, format);
> > 	if (ret != ENOIOCTLCMD)
> 
> you mean "-E..."
> 
> > 		return ret;
> > 	
> > 	fmt.pad = 0;
> > 	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
> > 	fmt.format = *format;
> > 	
> > 	ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &fmt);
> > 	if (ret < 0 && ret != ENOIOCTLCMD)
> 
> You, probably, actually mean "if (!ret)"
> 
> > 		*format = fmt.format;
> > 	
> > 	return ret;
> > 
> > }
> > 
> > Or the other way around, trying pad::get_fmt before video::g_mbus_fmt.
> 
> Ok, I understand what you mean now. Any idea when this layer is going to
> be implemented?

As soon as someone needs it and works on it I guess :-) I can give it a try, 
but I'm pretty busy at the moment. Do you have driver(s) that would be good 
test candidates for that ?

-- 
Regards,

Laurent Pinchart

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

end of thread, other threads:[~2011-12-11 23:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-29  8:18 [PATCH] V4L: add convenience macros to the subdevice / Media Controller API Guennadi Liakhovetski
2011-09-29  8:31 ` Laurent Pinchart
2011-09-29  8:44   ` Guennadi Liakhovetski
2011-09-29 11:11     ` Laurent Pinchart
2011-12-06  8:40       ` Guennadi Liakhovetski
2011-12-06 10:49         ` Laurent Pinchart
2011-12-06 12:04           ` Guennadi Liakhovetski
2011-12-11 23:38             ` Laurent Pinchart

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.