Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 137927
b: refs/heads/master
c: c41ee24
h: refs/heads/master
i:
  137925: 885ea36
  137923: 1663c1f
  137919: 27ce389
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Mar 30, 2009
1 parent 490653e commit 6fadeae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5ab6c9af375e27c48bd2e86f4d9f6d68c9ab98fd
refs/heads/master: c41ee24bc44d5ce813da1fcf8a0f018a825cfa84
40 changes: 22 additions & 18 deletions trunk/drivers/media/video/vivi.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,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)

Expand Down Expand Up @@ -239,6 +237,9 @@ struct vivi_dev {

/* Input Number */
int input;

/* Control 'registers' */
int qctl_regs[ARRAY_SIZE(vivi_qctrl)];
};

struct vivi_fh {
Expand Down Expand Up @@ -1108,29 +1109,33 @@ 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;
}
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;
}
Expand All @@ -1143,7 +1148,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);
Expand Down Expand Up @@ -1177,10 +1181,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;
Expand Down Expand Up @@ -1338,18 +1338,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;
Expand All @@ -1375,6 +1375,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);

Expand Down

0 comments on commit 6fadeae

Please sign in to comment.