All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for v3.6] VIDIOC_ENUM_FREQ_BANDS fix
@ 2012-08-01 19:52 Hans Verkuil
  2012-08-01 20:41 ` Rémi Denis-Courmont
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Verkuil @ 2012-08-01 19:52 UTC (permalink / raw)
  To: linux-media

When VIDIOC_ENUM_FREQ_BANDS is called for a driver that doesn't supply an
enum_freq_bands op, then it will fall back to reporting a single freq band
based on information from g_tuner or g_modulator.

Due to a bug this is an infinite list since the index field wasn't tested.

This patch fixes this and returns -EINVAL if index != 0.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index c3b7b5f..54f4ac6 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -1853,6 +1853,8 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,
 			.type = type,
 		};
 
+		if (p->index)
+			return -EINVAL;
 		err = ops->vidioc_g_tuner(file, fh, &t);
 		if (err)
 			return err;
@@ -1870,6 +1872,8 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,
 
 		if (type != V4L2_TUNER_RADIO)
 			return -EINVAL;
+		if (p->index)
+			return -EINVAL;
 		err = ops->vidioc_g_modulator(file, fh, &m);
 		if (err)
 			return err;

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

* Re: [PATCH for v3.6] VIDIOC_ENUM_FREQ_BANDS fix
  2012-08-01 19:52 [PATCH for v3.6] VIDIOC_ENUM_FREQ_BANDS fix Hans Verkuil
@ 2012-08-01 20:41 ` Rémi Denis-Courmont
  2012-08-02  6:25   ` Hans Verkuil
  0 siblings, 1 reply; 3+ messages in thread
From: Rémi Denis-Courmont @ 2012-08-01 20:41 UTC (permalink / raw)
  To: linux-media

Le mercredi 1 août 2012 22:52:46 Hans Verkuil, vous avez écrit :
> When VIDIOC_ENUM_FREQ_BANDS is called for a driver that doesn't supply an
> enum_freq_bands op, then it will fall back to reporting a single freq band
> based on information from g_tuner or g_modulator.

By the way...

Isn't V4L2_TUNER_CAP_FREQ_BANDS expected to tell whether the driver can 
enumerate bands? Why is there a need for fallback implementation?

-- 
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis

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

* Re: [PATCH for v3.6] VIDIOC_ENUM_FREQ_BANDS fix
  2012-08-01 20:41 ` Rémi Denis-Courmont
@ 2012-08-02  6:25   ` Hans Verkuil
  0 siblings, 0 replies; 3+ messages in thread
From: Hans Verkuil @ 2012-08-02  6:25 UTC (permalink / raw)
  To: Rémi Denis-Courmont; +Cc: linux-media

On Wed August 1 2012 22:41:16 Rémi Denis-Courmont wrote:
> Le mercredi 1 août 2012 22:52:46 Hans Verkuil, vous avez écrit :
> > When VIDIOC_ENUM_FREQ_BANDS is called for a driver that doesn't supply an
> > enum_freq_bands op, then it will fall back to reporting a single freq band
> > based on information from g_tuner or g_modulator.
> 
> By the way...
> 
> Isn't V4L2_TUNER_CAP_FREQ_BANDS expected to tell whether the driver can 
> enumerate bands?

Yes. And it is set as well in this fallback case.

> Why is there a need for fallback implementation?

The main reason is that struct v4l2_frequency_band also returns the modulation
of the frequency band. For all existing drivers (except radio-cadet, which
now implements enum_freq_bands) this can be deduced by the type of device node
that's used (/dev/radioX means FM, /dev/videoX or vbiX means VSB). While the
application could do the same we decided it was more consistent if the V4L2
core does that for the application. It was trivial to implement.

So apps will benefit, and only drivers that actually have more than one
frequency band need to go to the trouble of implementing enum_freq_bands.

Regards,

	Hans

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

end of thread, other threads:[~2012-08-02  6:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-01 19:52 [PATCH for v3.6] VIDIOC_ENUM_FREQ_BANDS fix Hans Verkuil
2012-08-01 20:41 ` Rémi Denis-Courmont
2012-08-02  6:25   ` Hans Verkuil

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.