aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-02-14 11:43:44 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:51 -0400
commitc41ee24bc44d5ce813da1fcf8a0f018a825cfa84 (patch)
tree7d4797bf65bcc39583ea123265081cedee2ce598
parent5ab6c9af375e27c48bd2e86f4d9f6d68c9ab98fd (diff)
V4L/DVB (10646): vivi: controls are per-device, not global.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/vivi.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 625e9662c7ad..5b4786b07ad0 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -125,8 +125,6 @@ static struct v4l2_queryctrl vivi_qctrl[] = {
125 } 125 }
126}; 126};
127 127
128static int qctl_regs[ARRAY_SIZE(vivi_qctrl)];
129
130#define dprintk(dev, level, fmt, arg...) \ 128#define dprintk(dev, level, fmt, arg...) \
131 v4l2_dbg(level, debug, &dev->v4l2_dev, fmt, ## arg) 129 v4l2_dbg(level, debug, &dev->v4l2_dev, fmt, ## arg)
132 130
@@ -239,6 +237,9 @@ struct vivi_dev {
239 237
240 /* Input Number */ 238 /* Input Number */
241 int input; 239 int input;
240
241 /* Control 'registers' */
242 int qctl_regs[ARRAY_SIZE(vivi_qctrl)];
242}; 243};
243 244
244struct vivi_fh { 245struct vivi_fh {
@@ -1108,12 +1109,14 @@ static int vidioc_queryctrl(struct file *file, void *priv,
1108static int vidioc_g_ctrl(struct file *file, void *priv, 1109static int vidioc_g_ctrl(struct file *file, void *priv,
1109 struct v4l2_control *ctrl) 1110 struct v4l2_control *ctrl)
1110{ 1111{
1112 struct vivi_fh *fh = priv;
1113 struct vivi_dev *dev = fh->dev;
1111 int i; 1114 int i;
1112 1115
1113 for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++) 1116 for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
1114 if (ctrl->id == vivi_qctrl[i].id) { 1117 if (ctrl->id == vivi_qctrl[i].id) {
1115 ctrl->value = qctl_regs[i]; 1118 ctrl->value = dev->qctl_regs[i];
1116 return (0); 1119 return 0;
1117 } 1120 }
1118 1121
1119 return -EINVAL; 1122 return -EINVAL;
@@ -1121,16 +1124,18 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
1121static int vidioc_s_ctrl(struct file *file, void *priv, 1124static int vidioc_s_ctrl(struct file *file, void *priv,
1122 struct v4l2_control *ctrl) 1125 struct v4l2_control *ctrl)
1123{ 1126{
1127 struct vivi_fh *fh = priv;
1128 struct vivi_dev *dev = fh->dev;
1124 int i; 1129 int i;
1125 1130
1126 for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++) 1131 for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
1127 if (ctrl->id == vivi_qctrl[i].id) { 1132 if (ctrl->id == vivi_qctrl[i].id) {
1128 if (ctrl->value < vivi_qctrl[i].minimum 1133 if (ctrl->value < vivi_qctrl[i].minimum ||
1129 || ctrl->value > vivi_qctrl[i].maximum) { 1134 ctrl->value > vivi_qctrl[i].maximum) {
1130 return (-ERANGE); 1135 return -ERANGE;
1131 } 1136 }
1132 qctl_regs[i] = ctrl->value; 1137 dev->qctl_regs[i] = ctrl->value;
1133 return (0); 1138 return 0;
1134 } 1139 }
1135 return -EINVAL; 1140 return -EINVAL;
1136} 1141}
@@ -1143,7 +1148,6 @@ static int vivi_open(struct file *file)
1143{ 1148{
1144 struct vivi_dev *dev = video_drvdata(file); 1149 struct vivi_dev *dev = video_drvdata(file);
1145 struct vivi_fh *fh = NULL; 1150 struct vivi_fh *fh = NULL;
1146 int i;
1147 int retval = 0; 1151 int retval = 0;
1148 1152
1149 mutex_lock(&dev->mutex); 1153 mutex_lock(&dev->mutex);
@@ -1177,10 +1181,6 @@ static int vivi_open(struct file *file)
1177 fh->width = 640; 1181 fh->width = 640;
1178 fh->height = 480; 1182 fh->height = 480;
1179 1183
1180 /* Put all controls at a sane state */
1181 for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
1182 qctl_regs[i] = vivi_qctrl[i].default_value;
1183
1184 /* Resets frame counters */ 1184 /* Resets frame counters */
1185 dev->h = 0; 1185 dev->h = 0;
1186 dev->m = 0; 1186 dev->m = 0;
@@ -1338,18 +1338,18 @@ static int vivi_release(void)
1338 return 0; 1338 return 0;
1339} 1339}
1340 1340
1341static int __init vivi_create_instance(int i) 1341static int __init vivi_create_instance(int inst)
1342{ 1342{
1343 struct vivi_dev *dev; 1343 struct vivi_dev *dev;
1344 struct video_device *vfd; 1344 struct video_device *vfd;
1345 int ret; 1345 int ret, i;
1346 1346
1347 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 1347 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1348 if (!dev) 1348 if (!dev)
1349 return -ENOMEM; 1349 return -ENOMEM;
1350 1350
1351 snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), 1351 snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name),
1352 "%s-%03d", VIVI_MODULE_NAME, i); 1352 "%s-%03d", VIVI_MODULE_NAME, inst);
1353 ret = v4l2_device_register(NULL, &dev->v4l2_dev); 1353 ret = v4l2_device_register(NULL, &dev->v4l2_dev);
1354 if (ret) 1354 if (ret)
1355 goto free_dev; 1355 goto free_dev;
@@ -1375,6 +1375,10 @@ static int __init vivi_create_instance(int i)
1375 1375
1376 video_set_drvdata(vfd, dev); 1376 video_set_drvdata(vfd, dev);
1377 1377
1378 /* Set all controls to their default value. */
1379 for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
1380 dev->qctl_regs[i] = vivi_qctrl[i].default_value;
1381
1378 /* Now that everything is fine, let's add it to device list */ 1382 /* Now that everything is fine, let's add it to device list */
1379 list_add_tail(&dev->vivi_devlist, &vivi_devlist); 1383 list_add_tail(&dev->vivi_devlist, &vivi_devlist);
1380 1384