diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-02-14 17:43:44 +0100 |
---|---|---|
committer | Hans Verkuil <hverkuil@xs4all.nl> | 2009-02-14 17:43:44 +0100 |
commit | c70e5dd6b23d260a1294ff4b23f49ccd78999c86 (patch) | |
tree | d9263a8042811d5145daba8f296ed469d73928fc /linux/drivers | |
parent | f9bd48b87f02902de6b355af1489669baaad39b5 (diff) | |
download | mediapointer-dvb-s2-c70e5dd6b23d260a1294ff4b23f49ccd78999c86.tar.gz mediapointer-dvb-s2-c70e5dd6b23d260a1294ff4b23f49ccd78999c86.tar.bz2 |
vivi: controls are per-device, not global.
From: Hans Verkuil <hverkuil@xs4all.nl>
Priority: normal
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Diffstat (limited to 'linux/drivers')
-rw-r--r-- | linux/drivers/media/video/vivi.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/linux/drivers/media/video/vivi.c b/linux/drivers/media/video/vivi.c index e4cb33ca0..207dfa58f 100644 --- a/linux/drivers/media/video/vivi.c +++ b/linux/drivers/media/video/vivi.c @@ -128,8 +128,6 @@ static struct v4l2_queryctrl vivi_qctrl[] = { } }; -static int qctl_regs[ARRAY_SIZE(vivi_qctrl)]; - #define dprintk(dev, level, fmt, arg...) \ v4l2_dbg(level, debug, &dev->v4l2_dev, fmt, ## arg) @@ -242,6 +240,9 @@ struct vivi_dev { /* Input Number */ int input; + + /* Control 'registers' */ + int qctl_regs[ARRAY_SIZE(vivi_qctrl)]; }; struct vivi_fh { @@ -1111,12 +1112,14 @@ static int vidioc_queryctrl(struct file *file, void *priv, static int vidioc_g_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl) { + struct vivi_fh *fh = priv; + struct vivi_dev *dev = fh->dev; int i; for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++) if (ctrl->id == vivi_qctrl[i].id) { - ctrl->value = qctl_regs[i]; - return (0); + ctrl->value = dev->qctl_regs[i]; + return 0; } return -EINVAL; @@ -1124,16 +1127,18 @@ static int vidioc_g_ctrl(struct file *file, void *priv, static int vidioc_s_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl) { + struct vivi_fh *fh = priv; + struct vivi_dev *dev = fh->dev; int i; for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++) if (ctrl->id == vivi_qctrl[i].id) { - if (ctrl->value < vivi_qctrl[i].minimum - || ctrl->value > vivi_qctrl[i].maximum) { - return (-ERANGE); - } - qctl_regs[i] = ctrl->value; - return (0); + if (ctrl->value < vivi_qctrl[i].minimum || + ctrl->value > vivi_qctrl[i].maximum) { + return -ERANGE; + } + dev->qctl_regs[i] = ctrl->value; + return 0; } return -EINVAL; } @@ -1146,7 +1151,6 @@ static int vivi_open(struct file *file) { struct vivi_dev *dev = video_drvdata(file); struct vivi_fh *fh = NULL; - int i; int retval = 0; mutex_lock(&dev->mutex); @@ -1180,10 +1184,6 @@ static int vivi_open(struct file *file) fh->width = 640; fh->height = 480; - /* Put all controls at a sane state */ - for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++) - qctl_regs[i] = vivi_qctrl[i].default_value; - /* Resets frame counters */ dev->h = 0; dev->m = 0; @@ -1341,18 +1341,18 @@ static int vivi_release(void) return 0; } -static int __init vivi_create_instance(int i) +static int __init vivi_create_instance(int inst) { struct vivi_dev *dev; struct video_device *vfd; - int ret; + int ret, i; dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), - "%s-%03d", VIVI_MODULE_NAME, i); + "%s-%03d", VIVI_MODULE_NAME, inst); ret = v4l2_device_register(NULL, &dev->v4l2_dev); if (ret) goto free_dev; @@ -1378,6 +1378,10 @@ static int __init vivi_create_instance(int i) video_set_drvdata(vfd, dev); + /* Set all controls to their default value. */ + for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++) + dev->qctl_regs[i] = vivi_qctrl[i].default_value; + /* Now that everything is fine, let's add it to device list */ list_add_tail(&dev->vivi_devlist, &vivi_devlist); |