aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/gspca
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-02-16 12:42:59 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-05 13:11:22 -0500
commit70c8ecf54bf735f300f86bde562420af90bf9db4 (patch)
treefd4ff36e7ea9ebe7f582fe8e779c0e52dd3c2a08 /drivers/media/usb/gspca
parent2effe6de386212fe721aae132ee4735cd37a9b13 (diff)
[media] gspca: Remove old control code now that all drivers are converted
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/usb/gspca')
-rw-r--r--drivers/media/usb/gspca/gspca.c160
-rw-r--r--drivers/media/usb/gspca/gspca.h24
2 files changed, 0 insertions, 184 deletions
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 3564bdbb2ea3..5784ff4e1b2f 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -984,7 +984,6 @@ out:
984 984
985static void gspca_set_default_mode(struct gspca_dev *gspca_dev) 985static void gspca_set_default_mode(struct gspca_dev *gspca_dev)
986{ 986{
987 struct gspca_ctrl *ctrl;
988 int i; 987 int i;
989 988
990 i = gspca_dev->cam.nmodes - 1; /* take the highest mode */ 989 i = gspca_dev->cam.nmodes - 1; /* take the highest mode */
@@ -993,17 +992,8 @@ static void gspca_set_default_mode(struct gspca_dev *gspca_dev)
993 gspca_dev->height = gspca_dev->cam.cam_mode[i].height; 992 gspca_dev->height = gspca_dev->cam.cam_mode[i].height;
994 gspca_dev->pixfmt = gspca_dev->cam.cam_mode[i].pixelformat; 993 gspca_dev->pixfmt = gspca_dev->cam.cam_mode[i].pixelformat;
995 994
996 /* set the current control values to their default values
997 * which may have changed in sd_init() */
998 /* does nothing if ctrl_handler == NULL */ 995 /* does nothing if ctrl_handler == NULL */
999 v4l2_ctrl_handler_setup(gspca_dev->vdev.ctrl_handler); 996 v4l2_ctrl_handler_setup(gspca_dev->vdev.ctrl_handler);
1000 ctrl = gspca_dev->cam.ctrls;
1001 if (ctrl != NULL) {
1002 for (i = 0;
1003 i < gspca_dev->sd_desc->nctrls;
1004 i++, ctrl++)
1005 ctrl->val = ctrl->def;
1006 }
1007} 997}
1008 998
1009static int wxh_to_mode(struct gspca_dev *gspca_dev, 999static int wxh_to_mode(struct gspca_dev *gspca_dev,
@@ -1357,134 +1347,6 @@ static int vidioc_querycap(struct file *file, void *priv,
1357 return 0; 1347 return 0;
1358} 1348}
1359 1349
1360static int get_ctrl(struct gspca_dev *gspca_dev,
1361 int id)
1362{
1363 const struct ctrl *ctrls;
1364 int i;
1365
1366 for (i = 0, ctrls = gspca_dev->sd_desc->ctrls;
1367 i < gspca_dev->sd_desc->nctrls;
1368 i++, ctrls++) {
1369 if (gspca_dev->ctrl_dis & (1 << i))
1370 continue;
1371 if (id == ctrls->qctrl.id)
1372 return i;
1373 }
1374 return -1;
1375}
1376
1377static int vidioc_queryctrl(struct file *file, void *priv,
1378 struct v4l2_queryctrl *q_ctrl)
1379{
1380 struct gspca_dev *gspca_dev = video_drvdata(file);
1381 const struct ctrl *ctrls;
1382 struct gspca_ctrl *gspca_ctrl;
1383 int i, idx;
1384 u32 id;
1385
1386 id = q_ctrl->id;
1387 if (id & V4L2_CTRL_FLAG_NEXT_CTRL) {
1388 id &= V4L2_CTRL_ID_MASK;
1389 id++;
1390 idx = -1;
1391 for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) {
1392 if (gspca_dev->ctrl_dis & (1 << i))
1393 continue;
1394 if (gspca_dev->sd_desc->ctrls[i].qctrl.id < id)
1395 continue;
1396 if (idx >= 0
1397 && gspca_dev->sd_desc->ctrls[i].qctrl.id
1398 > gspca_dev->sd_desc->ctrls[idx].qctrl.id)
1399 continue;
1400 idx = i;
1401 }
1402 } else {
1403 idx = get_ctrl(gspca_dev, id);
1404 }
1405 if (idx < 0)
1406 return -EINVAL;
1407 ctrls = &gspca_dev->sd_desc->ctrls[idx];
1408 memcpy(q_ctrl, &ctrls->qctrl, sizeof *q_ctrl);
1409 if (gspca_dev->cam.ctrls != NULL) {
1410 gspca_ctrl = &gspca_dev->cam.ctrls[idx];
1411 q_ctrl->default_value = gspca_ctrl->def;
1412 q_ctrl->minimum = gspca_ctrl->min;
1413 q_ctrl->maximum = gspca_ctrl->max;
1414 }
1415 if (gspca_dev->ctrl_inac & (1 << idx))
1416 q_ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
1417 return 0;
1418}
1419
1420static int vidioc_s_ctrl(struct file *file, void *priv,
1421 struct v4l2_control *ctrl)
1422{
1423 struct gspca_dev *gspca_dev = video_drvdata(file);
1424 const struct ctrl *ctrls;
1425 struct gspca_ctrl *gspca_ctrl;
1426 int idx;
1427
1428 idx = get_ctrl(gspca_dev, ctrl->id);
1429 if (idx < 0)
1430 return -EINVAL;
1431 if (gspca_dev->ctrl_inac & (1 << idx))
1432 return -EINVAL;
1433 ctrls = &gspca_dev->sd_desc->ctrls[idx];
1434 if (gspca_dev->cam.ctrls != NULL) {
1435 gspca_ctrl = &gspca_dev->cam.ctrls[idx];
1436 if (ctrl->value < gspca_ctrl->min
1437 || ctrl->value > gspca_ctrl->max)
1438 return -ERANGE;
1439 } else {
1440 gspca_ctrl = NULL;
1441 if (ctrl->value < ctrls->qctrl.minimum
1442 || ctrl->value > ctrls->qctrl.maximum)
1443 return -ERANGE;
1444 }
1445 PDEBUG(D_CONF, "set ctrl [%08x] = %d", ctrl->id, ctrl->value);
1446 gspca_dev->usb_err = 0;
1447 if (ctrls->set != NULL)
1448 return ctrls->set(gspca_dev, ctrl->value);
1449 if (gspca_ctrl != NULL) {
1450 gspca_ctrl->val = ctrl->value;
1451 if (ctrls->set_control != NULL
1452 && gspca_dev->streaming)
1453 ctrls->set_control(gspca_dev);
1454 }
1455 return gspca_dev->usb_err;
1456}
1457
1458static int vidioc_g_ctrl(struct file *file, void *priv,
1459 struct v4l2_control *ctrl)
1460{
1461 struct gspca_dev *gspca_dev = video_drvdata(file);
1462 const struct ctrl *ctrls;
1463 int idx;
1464
1465 idx = get_ctrl(gspca_dev, ctrl->id);
1466 if (idx < 0)
1467 return -EINVAL;
1468 ctrls = &gspca_dev->sd_desc->ctrls[idx];
1469
1470 gspca_dev->usb_err = 0;
1471 if (ctrls->get != NULL)
1472 return ctrls->get(gspca_dev, &ctrl->value);
1473 if (gspca_dev->cam.ctrls != NULL)
1474 ctrl->value = gspca_dev->cam.ctrls[idx].val;
1475 return 0;
1476}
1477
1478static int vidioc_querymenu(struct file *file, void *priv,
1479 struct v4l2_querymenu *qmenu)
1480{
1481 struct gspca_dev *gspca_dev = video_drvdata(file);
1482
1483 if (!gspca_dev->sd_desc->querymenu)
1484 return -ENOTTY;
1485 return gspca_dev->sd_desc->querymenu(gspca_dev, qmenu);
1486}
1487
1488static int vidioc_enum_input(struct file *file, void *priv, 1350static int vidioc_enum_input(struct file *file, void *priv,
1489 struct v4l2_input *input) 1351 struct v4l2_input *input)
1490{ 1352{
@@ -2125,10 +1987,6 @@ static const struct v4l2_ioctl_ops dev_ioctl_ops = {
2125 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, 1987 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
2126 .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, 1988 .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap,
2127 .vidioc_streamon = vidioc_streamon, 1989 .vidioc_streamon = vidioc_streamon,
2128 .vidioc_queryctrl = vidioc_queryctrl,
2129 .vidioc_g_ctrl = vidioc_g_ctrl,
2130 .vidioc_s_ctrl = vidioc_s_ctrl,
2131 .vidioc_querymenu = vidioc_querymenu,
2132 .vidioc_enum_input = vidioc_enum_input, 1990 .vidioc_enum_input = vidioc_enum_input,
2133 .vidioc_g_input = vidioc_g_input, 1991 .vidioc_g_input = vidioc_g_input,
2134 .vidioc_s_input = vidioc_s_input, 1992 .vidioc_s_input = vidioc_s_input,
@@ -2157,22 +2015,6 @@ static const struct video_device gspca_template = {
2157 .release = video_device_release_empty, /* We use v4l2_dev.release */ 2015 .release = video_device_release_empty, /* We use v4l2_dev.release */
2158}; 2016};
2159 2017
2160/* initialize the controls */
2161static void ctrls_init(struct gspca_dev *gspca_dev)
2162{
2163 struct gspca_ctrl *ctrl;
2164 int i;
2165
2166 for (i = 0, ctrl = gspca_dev->cam.ctrls;
2167 i < gspca_dev->sd_desc->nctrls;
2168 i++, ctrl++) {
2169 ctrl->def = gspca_dev->sd_desc->ctrls[i].qctrl.default_value;
2170 ctrl->val = ctrl->def;
2171 ctrl->min = gspca_dev->sd_desc->ctrls[i].qctrl.minimum;
2172 ctrl->max = gspca_dev->sd_desc->ctrls[i].qctrl.maximum;
2173 }
2174}
2175
2176/* 2018/*
2177 * probe and create a new gspca device 2019 * probe and create a new gspca device
2178 * 2020 *
@@ -2249,8 +2091,6 @@ int gspca_dev_probe2(struct usb_interface *intf,
2249 ret = sd_desc->config(gspca_dev, id); 2091 ret = sd_desc->config(gspca_dev, id);
2250 if (ret < 0) 2092 if (ret < 0)
2251 goto out; 2093 goto out;
2252 if (gspca_dev->cam.ctrls != NULL)
2253 ctrls_init(gspca_dev);
2254 ret = sd_desc->init(gspca_dev); 2094 ret = sd_desc->init(gspca_dev);
2255 if (ret < 0) 2095 if (ret < 0)
2256 goto out; 2096 goto out;
diff --git a/drivers/media/usb/gspca/gspca.h b/drivers/media/usb/gspca/gspca.h
index 5559932bf2f5..ac62cd3b590e 100644
--- a/drivers/media/usb/gspca/gspca.h
+++ b/drivers/media/usb/gspca/gspca.h
@@ -46,20 +46,11 @@ struct framerates {
46 int nrates; 46 int nrates;
47}; 47};
48 48
49/* control definition */
50struct gspca_ctrl {
51 s16 val; /* current value */
52 s16 def; /* default value */
53 s16 min, max; /* minimum and maximum values */
54};
55
56/* device information - set at probe time */ 49/* device information - set at probe time */
57struct cam { 50struct cam {
58 const struct v4l2_pix_format *cam_mode; /* size nmodes */ 51 const struct v4l2_pix_format *cam_mode; /* size nmodes */
59 const struct framerates *mode_framerates; /* must have size nmodes, 52 const struct framerates *mode_framerates; /* must have size nmodes,
60 * just like cam_mode */ 53 * just like cam_mode */
61 struct gspca_ctrl *ctrls; /* control table - size nctrls */
62 /* may be NULL */
63 u32 bulk_size; /* buffer size when image transfer by bulk */ 54 u32 bulk_size; /* buffer size when image transfer by bulk */
64 u32 input_flags; /* value for ENUM_INPUT status flags */ 55 u32 input_flags; /* value for ENUM_INPUT status flags */
65 u8 nmodes; /* size of cam_mode */ 56 u8 nmodes; /* size of cam_mode */
@@ -93,8 +84,6 @@ typedef int (*cam_ident_op) (struct gspca_dev *,
93 struct v4l2_dbg_chip_ident *); 84 struct v4l2_dbg_chip_ident *);
94typedef void (*cam_streamparm_op) (struct gspca_dev *, 85typedef void (*cam_streamparm_op) (struct gspca_dev *,
95 struct v4l2_streamparm *); 86 struct v4l2_streamparm *);
96typedef int (*cam_qmnu_op) (struct gspca_dev *,
97 struct v4l2_querymenu *);
98typedef void (*cam_pkt_op) (struct gspca_dev *gspca_dev, 87typedef void (*cam_pkt_op) (struct gspca_dev *gspca_dev,
99 u8 *data, 88 u8 *data,
100 int len); 89 int len);
@@ -102,20 +91,10 @@ typedef int (*cam_int_pkt_op) (struct gspca_dev *gspca_dev,
102 u8 *data, 91 u8 *data,
103 int len); 92 int len);
104 93
105struct ctrl {
106 struct v4l2_queryctrl qctrl;
107 int (*set)(struct gspca_dev *, __s32);
108 int (*get)(struct gspca_dev *, __s32 *);
109 cam_v_op set_control;
110};
111
112/* subdriver description */ 94/* subdriver description */
113struct sd_desc { 95struct sd_desc {
114/* information */ 96/* information */
115 const char *name; /* sub-driver name */ 97 const char *name; /* sub-driver name */
116/* controls */
117 const struct ctrl *ctrls; /* static control definition */
118 int nctrls;
119/* mandatory operations */ 98/* mandatory operations */
120 cam_cf_op config; /* called on probe */ 99 cam_cf_op config; /* called on probe */
121 cam_op init; /* called on probe and resume */ 100 cam_op init; /* called on probe and resume */
@@ -130,7 +109,6 @@ struct sd_desc {
130 cam_v_op dq_callback; /* called when a frame has been dequeued */ 109 cam_v_op dq_callback; /* called when a frame has been dequeued */
131 cam_get_jpg_op get_jcomp; 110 cam_get_jpg_op get_jcomp;
132 cam_set_jpg_op set_jcomp; 111 cam_set_jpg_op set_jcomp;
133 cam_qmnu_op querymenu;
134 cam_streamparm_op get_streamparm; 112 cam_streamparm_op get_streamparm;
135 cam_streamparm_op set_streamparm; 113 cam_streamparm_op set_streamparm;
136#ifdef CONFIG_VIDEO_ADV_DEBUG 114#ifdef CONFIG_VIDEO_ADV_DEBUG
@@ -174,8 +152,6 @@ struct gspca_dev {
174 152
175 struct cam cam; /* device information */ 153 struct cam cam; /* device information */
176 const struct sd_desc *sd_desc; /* subdriver description */ 154 const struct sd_desc *sd_desc; /* subdriver description */
177 unsigned ctrl_dis; /* disabled controls (bit map) */
178 unsigned ctrl_inac; /* inactive controls (bit map) */
179 struct v4l2_ctrl_handler ctrl_handler; 155 struct v4l2_ctrl_handler ctrl_handler;
180 156
181 /* autogain and exposure or gain control cluster, these are global as 157 /* autogain and exposure or gain control cluster, these are global as