diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2012-06-09 10:57:46 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-06 16:19:26 -0400 |
commit | d84f2d9483efa6fc69afb82b89ed9615c159470f (patch) | |
tree | 90ef6ac222e203330c2a9ac42b3b4dbae16c3632 /drivers | |
parent | efbceecd4522a41b8442c6b4f68b4508d57d1ccf (diff) |
[media] v4l2-ioctl.c: use the new table for selection ioctls
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/v4l2-ioctl.c | 262 |
1 files changed, 127 insertions, 135 deletions
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 798ee42d4e1a..179b22c80b4d 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c | |||
@@ -555,17 +555,45 @@ static void v4l_print_ext_controls(const void *arg, bool write_only) | |||
555 | pr_cont("\n"); | 555 | pr_cont("\n"); |
556 | } | 556 | } |
557 | 557 | ||
558 | static void v4l_print_u32(const void *arg, bool write_only) | 558 | static void v4l_print_cropcap(const void *arg, bool write_only) |
559 | { | 559 | { |
560 | pr_cont("value=%u\n", *(const u32 *)arg); | 560 | const struct v4l2_cropcap *p = arg; |
561 | |||
562 | pr_cont("type=%s, bounds wxh=%dx%d, x,y=%d,%d, " | ||
563 | "defrect wxh=%dx%d, x,y=%d,%d\n, " | ||
564 | "pixelaspect %d/%d\n", | ||
565 | prt_names(p->type, v4l2_type_names), | ||
566 | p->bounds.width, p->bounds.height, | ||
567 | p->bounds.left, p->bounds.top, | ||
568 | p->defrect.width, p->defrect.height, | ||
569 | p->defrect.left, p->defrect.top, | ||
570 | p->pixelaspect.numerator, p->pixelaspect.denominator); | ||
561 | } | 571 | } |
562 | 572 | ||
563 | static inline void dbgrect(struct video_device *vfd, char *s, | 573 | static void v4l_print_crop(const void *arg, bool write_only) |
564 | struct v4l2_rect *r) | ||
565 | { | 574 | { |
566 | dbgarg2("%sRect start at %dx%d, size=%dx%d\n", s, r->left, r->top, | 575 | const struct v4l2_crop *p = arg; |
567 | r->width, r->height); | 576 | |
568 | }; | 577 | pr_cont("type=%s, wxh=%dx%d, x,y=%d,%d\n", |
578 | prt_names(p->type, v4l2_type_names), | ||
579 | p->c.width, p->c.height, | ||
580 | p->c.left, p->c.top); | ||
581 | } | ||
582 | |||
583 | static void v4l_print_selection(const void *arg, bool write_only) | ||
584 | { | ||
585 | const struct v4l2_selection *p = arg; | ||
586 | |||
587 | pr_cont("type=%s, target=%d, flags=0x%x, wxh=%dx%d, x,y=%d,%d\n", | ||
588 | prt_names(p->type, v4l2_type_names), | ||
589 | p->target, p->flags, | ||
590 | p->r.width, p->r.height, p->r.left, p->r.top); | ||
591 | } | ||
592 | |||
593 | static void v4l_print_u32(const void *arg, bool write_only) | ||
594 | { | ||
595 | pr_cont("value=%u\n", *(const u32 *)arg); | ||
596 | } | ||
569 | 597 | ||
570 | static void dbgtimings(struct video_device *vfd, | 598 | static void dbgtimings(struct video_device *vfd, |
571 | const struct v4l2_dv_timings *p) | 599 | const struct v4l2_dv_timings *p) |
@@ -1383,6 +1411,93 @@ static int v4l_try_ext_ctrls(const struct v4l2_ioctl_ops *ops, | |||
1383 | -EINVAL; | 1411 | -EINVAL; |
1384 | } | 1412 | } |
1385 | 1413 | ||
1414 | static int v4l_g_crop(const struct v4l2_ioctl_ops *ops, | ||
1415 | struct file *file, void *fh, void *arg) | ||
1416 | { | ||
1417 | struct v4l2_crop *p = arg; | ||
1418 | struct v4l2_selection s = { | ||
1419 | .type = p->type, | ||
1420 | }; | ||
1421 | int ret; | ||
1422 | |||
1423 | if (ops->vidioc_g_crop) | ||
1424 | return ops->vidioc_g_crop(file, fh, p); | ||
1425 | /* simulate capture crop using selection api */ | ||
1426 | |||
1427 | /* crop means compose for output devices */ | ||
1428 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1429 | s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; | ||
1430 | else | ||
1431 | s.target = V4L2_SEL_TGT_CROP_ACTIVE; | ||
1432 | |||
1433 | ret = ops->vidioc_g_selection(file, fh, &s); | ||
1434 | |||
1435 | /* copying results to old structure on success */ | ||
1436 | if (!ret) | ||
1437 | p->c = s.r; | ||
1438 | return ret; | ||
1439 | } | ||
1440 | |||
1441 | static int v4l_s_crop(const struct v4l2_ioctl_ops *ops, | ||
1442 | struct file *file, void *fh, void *arg) | ||
1443 | { | ||
1444 | struct v4l2_crop *p = arg; | ||
1445 | struct v4l2_selection s = { | ||
1446 | .type = p->type, | ||
1447 | .r = p->c, | ||
1448 | }; | ||
1449 | |||
1450 | if (ops->vidioc_s_crop) | ||
1451 | return ops->vidioc_s_crop(file, fh, p); | ||
1452 | /* simulate capture crop using selection api */ | ||
1453 | |||
1454 | /* crop means compose for output devices */ | ||
1455 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1456 | s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; | ||
1457 | else | ||
1458 | s.target = V4L2_SEL_TGT_CROP_ACTIVE; | ||
1459 | |||
1460 | return ops->vidioc_s_selection(file, fh, &s); | ||
1461 | } | ||
1462 | |||
1463 | static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, | ||
1464 | struct file *file, void *fh, void *arg) | ||
1465 | { | ||
1466 | struct v4l2_cropcap *p = arg; | ||
1467 | struct v4l2_selection s = { .type = p->type }; | ||
1468 | int ret; | ||
1469 | |||
1470 | if (ops->vidioc_cropcap) | ||
1471 | return ops->vidioc_cropcap(file, fh, p); | ||
1472 | |||
1473 | /* obtaining bounds */ | ||
1474 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1475 | s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS; | ||
1476 | else | ||
1477 | s.target = V4L2_SEL_TGT_CROP_BOUNDS; | ||
1478 | |||
1479 | ret = ops->vidioc_g_selection(file, fh, &s); | ||
1480 | if (ret) | ||
1481 | return ret; | ||
1482 | p->bounds = s.r; | ||
1483 | |||
1484 | /* obtaining defrect */ | ||
1485 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1486 | s.target = V4L2_SEL_TGT_COMPOSE_DEFAULT; | ||
1487 | else | ||
1488 | s.target = V4L2_SEL_TGT_CROP_DEFAULT; | ||
1489 | |||
1490 | ret = ops->vidioc_g_selection(file, fh, &s); | ||
1491 | if (ret) | ||
1492 | return ret; | ||
1493 | p->defrect = s.r; | ||
1494 | |||
1495 | /* setting trivial pixelaspect */ | ||
1496 | p->pixelaspect.numerator = 1; | ||
1497 | p->pixelaspect.denominator = 1; | ||
1498 | return 0; | ||
1499 | } | ||
1500 | |||
1386 | struct v4l2_ioctl_info { | 1501 | struct v4l2_ioctl_info { |
1387 | unsigned int ioctl; | 1502 | unsigned int ioctl; |
1388 | u32 flags; | 1503 | u32 flags; |
@@ -1472,11 +1587,11 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { | |||
1472 | IOCTL_INFO_STD(VIDIOC_S_MODULATOR, vidioc_s_modulator, v4l_print_modulator, INFO_FL_PRIO), | 1587 | IOCTL_INFO_STD(VIDIOC_S_MODULATOR, vidioc_s_modulator, v4l_print_modulator, INFO_FL_PRIO), |
1473 | IOCTL_INFO_FNC(VIDIOC_G_FREQUENCY, v4l_g_frequency, v4l_print_frequency, INFO_FL_CLEAR(v4l2_frequency, tuner)), | 1588 | IOCTL_INFO_FNC(VIDIOC_G_FREQUENCY, v4l_g_frequency, v4l_print_frequency, INFO_FL_CLEAR(v4l2_frequency, tuner)), |
1474 | IOCTL_INFO_FNC(VIDIOC_S_FREQUENCY, v4l_s_frequency, v4l_print_frequency, INFO_FL_PRIO), | 1589 | IOCTL_INFO_FNC(VIDIOC_S_FREQUENCY, v4l_s_frequency, v4l_print_frequency, INFO_FL_PRIO), |
1475 | IOCTL_INFO(VIDIOC_CROPCAP, INFO_FL_CLEAR(v4l2_cropcap, type)), | 1590 | IOCTL_INFO_FNC(VIDIOC_CROPCAP, v4l_cropcap, v4l_print_cropcap, INFO_FL_CLEAR(v4l2_cropcap, type)), |
1476 | IOCTL_INFO(VIDIOC_G_CROP, INFO_FL_CLEAR(v4l2_crop, type)), | 1591 | IOCTL_INFO_FNC(VIDIOC_G_CROP, v4l_g_crop, v4l_print_crop, INFO_FL_CLEAR(v4l2_crop, type)), |
1477 | IOCTL_INFO(VIDIOC_S_CROP, INFO_FL_PRIO), | 1592 | IOCTL_INFO_FNC(VIDIOC_S_CROP, v4l_s_crop, v4l_print_crop, INFO_FL_PRIO), |
1478 | IOCTL_INFO(VIDIOC_G_SELECTION, 0), | 1593 | IOCTL_INFO_STD(VIDIOC_G_SELECTION, vidioc_g_selection, v4l_print_selection, 0), |
1479 | IOCTL_INFO(VIDIOC_S_SELECTION, INFO_FL_PRIO), | 1594 | IOCTL_INFO_STD(VIDIOC_S_SELECTION, vidioc_s_selection, v4l_print_selection, INFO_FL_PRIO), |
1480 | IOCTL_INFO(VIDIOC_G_JPEGCOMP, 0), | 1595 | IOCTL_INFO(VIDIOC_G_JPEGCOMP, 0), |
1481 | IOCTL_INFO(VIDIOC_S_JPEGCOMP, INFO_FL_PRIO), | 1596 | IOCTL_INFO(VIDIOC_S_JPEGCOMP, INFO_FL_PRIO), |
1482 | IOCTL_INFO_FNC(VIDIOC_QUERYSTD, v4l_querystd, v4l_print_std, 0), | 1597 | IOCTL_INFO_FNC(VIDIOC_QUERYSTD, v4l_querystd, v4l_print_std, 0), |
@@ -1621,129 +1736,6 @@ static long __video_do_ioctl(struct file *file, | |||
1621 | } | 1736 | } |
1622 | 1737 | ||
1623 | switch (cmd) { | 1738 | switch (cmd) { |
1624 | case VIDIOC_G_CROP: | ||
1625 | { | ||
1626 | struct v4l2_crop *p = arg; | ||
1627 | |||
1628 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | ||
1629 | |||
1630 | if (ops->vidioc_g_crop) { | ||
1631 | ret = ops->vidioc_g_crop(file, fh, p); | ||
1632 | } else { | ||
1633 | /* simulate capture crop using selection api */ | ||
1634 | struct v4l2_selection s = { | ||
1635 | .type = p->type, | ||
1636 | }; | ||
1637 | |||
1638 | /* crop means compose for output devices */ | ||
1639 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1640 | s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; | ||
1641 | else | ||
1642 | s.target = V4L2_SEL_TGT_CROP_ACTIVE; | ||
1643 | |||
1644 | ret = ops->vidioc_g_selection(file, fh, &s); | ||
1645 | |||
1646 | /* copying results to old structure on success */ | ||
1647 | if (!ret) | ||
1648 | p->c = s.r; | ||
1649 | } | ||
1650 | |||
1651 | if (!ret) | ||
1652 | dbgrect(vfd, "", &p->c); | ||
1653 | break; | ||
1654 | } | ||
1655 | case VIDIOC_S_CROP: | ||
1656 | { | ||
1657 | struct v4l2_crop *p = arg; | ||
1658 | |||
1659 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | ||
1660 | dbgrect(vfd, "", &p->c); | ||
1661 | |||
1662 | if (ops->vidioc_s_crop) { | ||
1663 | ret = ops->vidioc_s_crop(file, fh, p); | ||
1664 | } else { | ||
1665 | /* simulate capture crop using selection api */ | ||
1666 | struct v4l2_selection s = { | ||
1667 | .type = p->type, | ||
1668 | .r = p->c, | ||
1669 | }; | ||
1670 | |||
1671 | /* crop means compose for output devices */ | ||
1672 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1673 | s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; | ||
1674 | else | ||
1675 | s.target = V4L2_SEL_TGT_CROP_ACTIVE; | ||
1676 | |||
1677 | ret = ops->vidioc_s_selection(file, fh, &s); | ||
1678 | } | ||
1679 | break; | ||
1680 | } | ||
1681 | case VIDIOC_G_SELECTION: | ||
1682 | { | ||
1683 | struct v4l2_selection *p = arg; | ||
1684 | |||
1685 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | ||
1686 | |||
1687 | ret = ops->vidioc_g_selection(file, fh, p); | ||
1688 | if (!ret) | ||
1689 | dbgrect(vfd, "", &p->r); | ||
1690 | break; | ||
1691 | } | ||
1692 | case VIDIOC_S_SELECTION: | ||
1693 | { | ||
1694 | struct v4l2_selection *p = arg; | ||
1695 | |||
1696 | |||
1697 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | ||
1698 | dbgrect(vfd, "", &p->r); | ||
1699 | |||
1700 | ret = ops->vidioc_s_selection(file, fh, p); | ||
1701 | break; | ||
1702 | } | ||
1703 | case VIDIOC_CROPCAP: | ||
1704 | { | ||
1705 | struct v4l2_cropcap *p = arg; | ||
1706 | |||
1707 | /*FIXME: Should also show v4l2_fract pixelaspect */ | ||
1708 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | ||
1709 | if (ops->vidioc_cropcap) { | ||
1710 | ret = ops->vidioc_cropcap(file, fh, p); | ||
1711 | } else { | ||
1712 | struct v4l2_selection s = { .type = p->type }; | ||
1713 | |||
1714 | /* obtaining bounds */ | ||
1715 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1716 | s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS; | ||
1717 | else | ||
1718 | s.target = V4L2_SEL_TGT_CROP_BOUNDS; | ||
1719 | |||
1720 | ret = ops->vidioc_g_selection(file, fh, &s); | ||
1721 | if (ret) | ||
1722 | break; | ||
1723 | p->bounds = s.r; | ||
1724 | |||
1725 | /* obtaining defrect */ | ||
1726 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1727 | s.target = V4L2_SEL_TGT_COMPOSE_DEFAULT; | ||
1728 | else | ||
1729 | s.target = V4L2_SEL_TGT_CROP_DEFAULT; | ||
1730 | |||
1731 | ret = ops->vidioc_g_selection(file, fh, &s); | ||
1732 | if (ret) | ||
1733 | break; | ||
1734 | p->defrect = s.r; | ||
1735 | |||
1736 | /* setting trivial pixelaspect */ | ||
1737 | p->pixelaspect.numerator = 1; | ||
1738 | p->pixelaspect.denominator = 1; | ||
1739 | } | ||
1740 | |||
1741 | if (!ret) { | ||
1742 | dbgrect(vfd, "bounds ", &p->bounds); | ||
1743 | dbgrect(vfd, "defrect ", &p->defrect); | ||
1744 | } | ||
1745 | break; | ||
1746 | } | ||
1747 | case VIDIOC_G_JPEGCOMP: | 1739 | case VIDIOC_G_JPEGCOMP: |
1748 | { | 1740 | { |
1749 | struct v4l2_jpegcompression *p = arg; | 1741 | struct v4l2_jpegcompression *p = arg; |