aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDean Anderson <dean@sensoray.com>2010-03-05 12:29:09 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-17 23:46:36 -0400
commit2e70db9a4553e0f79cb4db05c0552d33932cca80 (patch)
tree6cf3924f13285f1c56fa1f8be7a441ea0c6ba18f /drivers
parent3fa0060526eafe3eeda1db681b4aab5b79d4543e (diff)
V4L/DVB: s2255drv: cleanup of V4L2 controls
Signed-off-by: Dean Anderson <dean@sensoray.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/s2255drv.c166
1 files changed, 62 insertions, 104 deletions
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 882a79679dc6..631a84eea1ae 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -310,7 +310,7 @@ struct s2255_fh {
310/* Need DSP version 5+ for video status feature */ 310/* Need DSP version 5+ for video status feature */
311#define S2255_MIN_DSP_STATUS 5 311#define S2255_MIN_DSP_STATUS 5
312#define S2255_MAJOR_VERSION 1 312#define S2255_MAJOR_VERSION 1
313#define S2255_MINOR_VERSION 16 313#define S2255_MINOR_VERSION 17
314#define S2255_RELEASE 0 314#define S2255_RELEASE 0
315#define S2255_VERSION KERNEL_VERSION(S2255_MAJOR_VERSION, \ 315#define S2255_VERSION KERNEL_VERSION(S2255_MAJOR_VERSION, \
316 S2255_MINOR_VERSION, \ 316 S2255_MINOR_VERSION, \
@@ -384,49 +384,6 @@ MODULE_DEVICE_TABLE(usb, s2255_table);
384 384
385#define BUFFER_TIMEOUT msecs_to_jiffies(400) 385#define BUFFER_TIMEOUT msecs_to_jiffies(400)
386 386
387/* supported controls */
388static struct v4l2_queryctrl s2255_qctrl[] = {
389 {
390 .id = V4L2_CID_BRIGHTNESS,
391 .type = V4L2_CTRL_TYPE_INTEGER,
392 .name = "Brightness",
393 .minimum = -127,
394 .maximum = 128,
395 .step = 1,
396 .default_value = 0,
397 .flags = 0,
398 }, {
399 .id = V4L2_CID_CONTRAST,
400 .type = V4L2_CTRL_TYPE_INTEGER,
401 .name = "Contrast",
402 .minimum = 0,
403 .maximum = 255,
404 .step = 0x1,
405 .default_value = DEF_CONTRAST,
406 .flags = 0,
407 }, {
408 .id = V4L2_CID_SATURATION,
409 .type = V4L2_CTRL_TYPE_INTEGER,
410 .name = "Saturation",
411 .minimum = 0,
412 .maximum = 255,
413 .step = 0x1,
414 .default_value = DEF_SATURATION,
415 .flags = 0,
416 }, {
417 .id = V4L2_CID_HUE,
418 .type = V4L2_CTRL_TYPE_INTEGER,
419 .name = "Hue",
420 .minimum = 0,
421 .maximum = 255,
422 .step = 0x1,
423 .default_value = DEF_HUE,
424 .flags = 0,
425 }
426};
427
428static int qctl_regs[ARRAY_SIZE(s2255_qctrl)];
429
430/* image formats. */ 387/* image formats. */
431static const struct s2255_fmt formats[] = { 388static const struct s2255_fmt formats[] = {
432 { 389 {
@@ -1472,74 +1429,82 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
1472static int vidioc_queryctrl(struct file *file, void *priv, 1429static int vidioc_queryctrl(struct file *file, void *priv,
1473 struct v4l2_queryctrl *qc) 1430 struct v4l2_queryctrl *qc)
1474{ 1431{
1475 int i; 1432 switch (qc->id) {
1476 1433 case V4L2_CID_BRIGHTNESS:
1477 for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++) 1434 v4l2_ctrl_query_fill(qc, -127, 127, 1, DEF_BRIGHT);
1478 if (qc->id && qc->id == s2255_qctrl[i].id) { 1435 break;
1479 memcpy(qc, &(s2255_qctrl[i]), sizeof(*qc)); 1436 case V4L2_CID_CONTRAST:
1480 return 0; 1437 v4l2_ctrl_query_fill(qc, 0, 255, 1, DEF_CONTRAST);
1481 } 1438 break;
1482 1439 case V4L2_CID_SATURATION:
1483 dprintk(4, "query_ctrl -EINVAL %d\n", qc->id); 1440 v4l2_ctrl_query_fill(qc, 0, 255, 1, DEF_SATURATION);
1484 return -EINVAL; 1441 break;
1442 case V4L2_CID_HUE:
1443 v4l2_ctrl_query_fill(qc, 0, 255, 1, DEF_HUE);
1444 break;
1445 default:
1446 return -EINVAL;
1447 }
1448 dprintk(4, "%s, id %d\n", __func__, qc->id);
1449 return 0;
1485} 1450}
1486 1451
1487static int vidioc_g_ctrl(struct file *file, void *priv, 1452static int vidioc_g_ctrl(struct file *file, void *priv,
1488 struct v4l2_control *ctrl) 1453 struct v4l2_control *ctrl)
1489{ 1454{
1490 int i; 1455 struct s2255_fh *fh = priv;
1491 1456 switch (ctrl->id) {
1492 for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++) 1457 case V4L2_CID_BRIGHTNESS:
1493 if (ctrl->id == s2255_qctrl[i].id) { 1458 ctrl->value = fh->mode.bright;
1494 ctrl->value = qctl_regs[i]; 1459 break;
1495 return 0; 1460 case V4L2_CID_CONTRAST:
1496 } 1461 ctrl->value = fh->mode.contrast;
1497 dprintk(4, "g_ctrl -EINVAL\n"); 1462 break;
1498 1463 case V4L2_CID_SATURATION:
1499 return -EINVAL; 1464 ctrl->value = fh->mode.saturation;
1465 break;
1466 case V4L2_CID_HUE:
1467 ctrl->value = fh->mode.hue;
1468 break;
1469 default:
1470 return -EINVAL;
1471 }
1472 dprintk(4, "%s, id %d val %d\n", __func__, ctrl->id, ctrl->value);
1473 return 0;
1500} 1474}
1501 1475
1502static int vidioc_s_ctrl(struct file *file, void *priv, 1476static int vidioc_s_ctrl(struct file *file, void *priv,
1503 struct v4l2_control *ctrl) 1477 struct v4l2_control *ctrl)
1504{ 1478{
1505 int i;
1506 struct s2255_fh *fh = priv; 1479 struct s2255_fh *fh = priv;
1507 struct s2255_dev *dev = fh->dev; 1480 struct s2255_dev *dev = fh->dev;
1508 struct s2255_mode *mode; 1481 struct s2255_mode *mode;
1509 mode = &fh->mode; 1482 mode = &fh->mode;
1510 dprintk(4, "vidioc_s_ctrl\n"); 1483 dprintk(4, "%s\n", __func__);
1511 for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++) { 1484 /* update the mode to the corresponding value */
1512 if (ctrl->id == s2255_qctrl[i].id) { 1485 switch (ctrl->id) {
1513 if (ctrl->value < s2255_qctrl[i].minimum || 1486 case V4L2_CID_BRIGHTNESS:
1514 ctrl->value > s2255_qctrl[i].maximum) 1487 mode->bright = ctrl->value;
1515 return -ERANGE; 1488 break;
1516 1489 case V4L2_CID_CONTRAST:
1517 qctl_regs[i] = ctrl->value; 1490 mode->contrast = ctrl->value;
1518 /* update the mode to the corresponding value */ 1491 break;
1519 switch (ctrl->id) { 1492 case V4L2_CID_HUE:
1520 case V4L2_CID_BRIGHTNESS: 1493 mode->hue = ctrl->value;
1521 mode->bright = ctrl->value; 1494 break;
1522 break; 1495 case V4L2_CID_SATURATION:
1523 case V4L2_CID_CONTRAST: 1496 mode->saturation = ctrl->value;
1524 mode->contrast = ctrl->value; 1497 break;
1525 break; 1498 default:
1526 case V4L2_CID_HUE: 1499 return -EINVAL;
1527 mode->hue = ctrl->value;
1528 break;
1529 case V4L2_CID_SATURATION:
1530 mode->saturation = ctrl->value;
1531 break;
1532 }
1533 mode->restart = 0;
1534 /* set mode here. Note: stream does not need restarted.
1535 some V4L programs restart stream unnecessarily
1536 after a s_crtl.
1537 */
1538 s2255_set_mode(dev, fh->channel, mode);
1539 return 0;
1540 }
1541 } 1500 }
1542 return -EINVAL; 1501 mode->restart = 0;
1502 /* set mode here. Note: stream does not need restarted.
1503 some V4L programs restart stream unnecessarily
1504 after a s_crtl.
1505 */
1506 s2255_set_mode(dev, fh->channel, mode);
1507 return 0;
1543} 1508}
1544 1509
1545static int vidioc_g_jpegcomp(struct file *file, void *priv, 1510static int vidioc_g_jpegcomp(struct file *file, void *priv,
@@ -1701,18 +1666,11 @@ static int s2255_open(struct file *file)
1701 fh->width = LINE_SZ_4CIFS_NTSC; 1666 fh->width = LINE_SZ_4CIFS_NTSC;
1702 fh->height = NUM_LINES_4CIFS_NTSC * 2; 1667 fh->height = NUM_LINES_4CIFS_NTSC * 2;
1703 fh->channel = cur_channel; 1668 fh->channel = cur_channel;
1704
1705 /* configure channel to default state */ 1669 /* configure channel to default state */
1706 if (!dev->chn_configured[cur_channel]) { 1670 if (!dev->chn_configured[cur_channel]) {
1707 s2255_set_mode(dev, cur_channel, &fh->mode); 1671 s2255_set_mode(dev, cur_channel, &fh->mode);
1708 dev->chn_configured[cur_channel] = 1; 1672 dev->chn_configured[cur_channel] = 1;
1709 } 1673 }
1710
1711
1712 /* Put all controls at a sane state */
1713 for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++)
1714 qctl_regs[i] = s2255_qctrl[i].default_value;
1715
1716 dprintk(1, "s2255drv: open dev=%s type=%s users=%d\n", 1674 dprintk(1, "s2255drv: open dev=%s type=%s users=%d\n",
1717 video_device_node_name(vdev), v4l2_type_names[type], 1675 video_device_node_name(vdev), v4l2_type_names[type],
1718 dev->users[cur_channel]); 1676 dev->users[cur_channel]);