Commit 6c428b57 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

V4L/DVB (12376): em28xx: fix V4L2 API compliance: don't expose audio inputs for devices without it

V4L2 API (chapter 1.5) states that:

	Drivers must implement all input ioctls when the device has one
	or more inputs, all output ioctls when the device has one or more outputs.
	When the device has any audio inputs or outputs the driver must set the
	V4L2_CAP_AUDIO flag in the struct v4l2_capability returned by the
	VIDIOC_QUERYCAP ioctl.

So, devices without audio input should return -EINVAL.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 00c1e216
...@@ -1005,6 +1005,9 @@ static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a) ...@@ -1005,6 +1005,9 @@ static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
struct em28xx_fh *fh = priv; struct em28xx_fh *fh = priv;
struct em28xx *dev = fh->dev; struct em28xx *dev = fh->dev;
if (!dev->audio_mode.has_audio)
return -EINVAL;
switch (a->index) { switch (a->index) {
case EM28XX_AMUX_VIDEO: case EM28XX_AMUX_VIDEO:
strcpy(a->name, "Television"); strcpy(a->name, "Television");
...@@ -1046,6 +1049,9 @@ static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a) ...@@ -1046,6 +1049,9 @@ static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a)
struct em28xx *dev = fh->dev; struct em28xx *dev = fh->dev;
if (!dev->audio_mode.has_audio)
return -EINVAL;
if (a->index >= MAX_EM28XX_INPUT) if (a->index >= MAX_EM28XX_INPUT)
return -EINVAL; return -EINVAL;
if (0 == INPUT(a->index)->type) if (0 == INPUT(a->index)->type)
...@@ -1464,9 +1470,11 @@ static int vidioc_querycap(struct file *file, void *priv, ...@@ -1464,9 +1470,11 @@ static int vidioc_querycap(struct file *file, void *priv,
cap->capabilities = cap->capabilities =
V4L2_CAP_SLICED_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_CAPTURE |
V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_CAPTURE |
V4L2_CAP_AUDIO |
V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
if (dev->audio_mode.has_audio)
cap->capabilities |= V4L2_CAP_AUDIO;
if (dev->tuner_type != TUNER_ABSENT) if (dev->tuner_type != TUNER_ABSENT)
cap->capabilities |= V4L2_CAP_TUNER; cap->capabilities |= V4L2_CAP_TUNER;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment