Skip to content

Commit

Permalink
V4L/DVB (10192): em28xx: fix input selection
Browse files Browse the repository at this point in the history
em28xx were trying to access the third input entry, even for boards that
don't support it.

This patch reviews the input mux selection fixing this bug and a few
other troubles, like not validating the input on one userspace ioctl.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Mauro Carvalho Chehab committed Jan 29, 2009
1 parent 18e352e commit 24c3c41
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions drivers/media/video/em28xx/em28xx-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,10 +886,10 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
if (0 == INPUT(i)->type)
return -EINVAL;

mutex_lock(&dev->lock);

video_mux(dev, i);
dev->ctl_input = i;

mutex_lock(&dev->lock);
video_mux(dev, dev->ctl_input);
mutex_unlock(&dev->lock);
return 0;
}
Expand Down Expand Up @@ -939,6 +939,12 @@ static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a)
struct em28xx_fh *fh = priv;
struct em28xx *dev = fh->dev;


if (a->index >= MAX_EM28XX_INPUT)
return -EINVAL;
if (0 == INPUT(a->index)->type)
return -EINVAL;

mutex_lock(&dev->lock);

dev->ctl_ainput = INPUT(a->index)->amux;
Expand Down Expand Up @@ -1957,34 +1963,33 @@ int em28xx_register_analog_devices(struct em28xx *dev)
(EM28XX_VERSION_CODE >> 16) & 0xff,
(EM28XX_VERSION_CODE >> 8) & 0xff, EM28XX_VERSION_CODE & 0xff);

/* set default norm */
dev->norm = em28xx_video_template.current_norm;
dev->width = norm_maxw(dev);
dev->height = norm_maxh(dev);
dev->interlaced = EM28XX_INTERLACED_DEFAULT;
dev->hscale = 0;
dev->vscale = 0;
dev->ctl_input = 0;

/* Analog specific initialization */
dev->format = &format[0];
video_mux(dev, 0);
video_mux(dev, dev->ctl_input);

/* Audio defaults */
dev->mute = 1;
dev->volume = 0x1f;

/* enable vbi capturing */

/* em28xx_write_reg(dev, EM28XX_R0E_AUDIOSRC, 0xc0); audio register */
/* em28xx_write_reg(dev, EM28XX_R0F_XCLK, 0x80); clk register */
em28xx_write_reg(dev, EM28XX_R11_VINCTRL, 0x51);

dev->mute = 1; /* maybe not the right place... */
dev->volume = 0x1f;

em28xx_set_outfmt(dev);
em28xx_colorlevels_set_default(dev);
em28xx_compression_disable(dev);

/* set default norm */
dev->norm = em28xx_video_template.current_norm;
dev->width = norm_maxw(dev);
dev->height = norm_maxh(dev);
dev->interlaced = EM28XX_INTERLACED_DEFAULT;
dev->hscale = 0;
dev->vscale = 0;

/* FIXME: This is a very bad hack! Not all devices have TV on input 2 */
dev->ctl_input = 2;

/* allocate and fill video video_device struct */
dev->vdev = em28xx_vdev_init(dev, &em28xx_video_template, "video");
if (!dev->vdev) {
Expand Down

0 comments on commit 24c3c41

Please sign in to comment.