aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-06-09 09:06:25 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-07-06 16:19:41 -0400
commitf16f77b0193c04e0c549c8e22546a8cd24e44d79 (patch)
tree772525a6037905a5db983b0d3b418b042095ade6 /drivers
parentd806f2df48098efca104d00a7db237dc39eea858 (diff)
[media] v4l2-ioctl.c: use the new table for debug 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.c139
1 files changed, 89 insertions, 50 deletions
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index 935fcbc2d50b..ee11e08cb04c 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -629,11 +629,42 @@ static void v4l_print_decoder_cmd(const void *arg, bool write_only)
629 pr_info("pts=%llu\n", p->stop.pts); 629 pr_info("pts=%llu\n", p->stop.pts);
630} 630}
631 631
632static void v4l_print_dbg_chip_ident(const void *arg, bool write_only)
633{
634 const struct v4l2_dbg_chip_ident *p = arg;
635
636 pr_cont("type=%u, ", p->match.type);
637 if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER)
638 pr_cont("name=%s, ", p->match.name);
639 else
640 pr_cont("addr=%u, ", p->match.addr);
641 pr_cont("chip_ident=%u, revision=0x%x\n",
642 p->ident, p->revision);
643}
644
645static void v4l_print_dbg_register(const void *arg, bool write_only)
646{
647 const struct v4l2_dbg_register *p = arg;
648
649 pr_cont("type=%u, ", p->match.type);
650 if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER)
651 pr_cont("name=%s, ", p->match.name);
652 else
653 pr_cont("addr=%u, ", p->match.addr);
654 pr_cont("reg=0x%llx, val=0x%llx\n",
655 p->reg, p->val);
656}
657
632static void v4l_print_u32(const void *arg, bool write_only) 658static void v4l_print_u32(const void *arg, bool write_only)
633{ 659{
634 pr_cont("value=%u\n", *(const u32 *)arg); 660 pr_cont("value=%u\n", *(const u32 *)arg);
635} 661}
636 662
663static void v4l_print_newline(const void *arg, bool write_only)
664{
665 pr_cont("\n");
666}
667
637static void dbgtimings(struct video_device *vfd, 668static void dbgtimings(struct video_device *vfd,
638 const struct v4l2_dv_timings *p) 669 const struct v4l2_dv_timings *p)
639{ 670{
@@ -1537,6 +1568,60 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops,
1537 return 0; 1568 return 0;
1538} 1569}
1539 1570
1571static int v4l_log_status(const struct v4l2_ioctl_ops *ops,
1572 struct file *file, void *fh, void *arg)
1573{
1574 struct video_device *vfd = video_devdata(file);
1575 int ret;
1576
1577 if (vfd->v4l2_dev)
1578 pr_info("%s: ================= START STATUS =================\n",
1579 vfd->v4l2_dev->name);
1580 ret = ops->vidioc_log_status(file, fh);
1581 if (vfd->v4l2_dev)
1582 pr_info("%s: ================== END STATUS ==================\n",
1583 vfd->v4l2_dev->name);
1584 return ret;
1585}
1586
1587static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops,
1588 struct file *file, void *fh, void *arg)
1589{
1590#ifdef CONFIG_VIDEO_ADV_DEBUG
1591 struct v4l2_dbg_register *p = arg;
1592
1593 if (!capable(CAP_SYS_ADMIN))
1594 return -EPERM;
1595 return ops->vidioc_g_register(file, fh, p);
1596#else
1597 return -ENOTTY;
1598#endif
1599}
1600
1601static int v4l_dbg_s_register(const struct v4l2_ioctl_ops *ops,
1602 struct file *file, void *fh, void *arg)
1603{
1604#ifdef CONFIG_VIDEO_ADV_DEBUG
1605 struct v4l2_dbg_register *p = arg;
1606
1607 if (!capable(CAP_SYS_ADMIN))
1608 return -EPERM;
1609 return ops->vidioc_s_register(file, fh, p);
1610#else
1611 return -ENOTTY;
1612#endif
1613}
1614
1615static int v4l_dbg_g_chip_ident(const struct v4l2_ioctl_ops *ops,
1616 struct file *file, void *fh, void *arg)
1617{
1618 struct v4l2_dbg_chip_ident *p = arg;
1619
1620 p->ident = V4L2_IDENT_NONE;
1621 p->revision = 0;
1622 return ops->vidioc_g_chip_ident(file, fh, p);
1623}
1624
1540struct v4l2_ioctl_info { 1625struct v4l2_ioctl_info {
1541 unsigned int ioctl; 1626 unsigned int ioctl;
1542 u32 flags; 1627 u32 flags;
@@ -1640,7 +1725,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = {
1640 IOCTL_INFO_FNC(VIDIOC_G_PRIORITY, v4l_g_priority, v4l_print_u32, 0), 1725 IOCTL_INFO_FNC(VIDIOC_G_PRIORITY, v4l_g_priority, v4l_print_u32, 0),
1641 IOCTL_INFO_FNC(VIDIOC_S_PRIORITY, v4l_s_priority, v4l_print_u32, INFO_FL_PRIO), 1726 IOCTL_INFO_FNC(VIDIOC_S_PRIORITY, v4l_s_priority, v4l_print_u32, INFO_FL_PRIO),
1642 IOCTL_INFO(VIDIOC_G_SLICED_VBI_CAP, INFO_FL_CLEAR(v4l2_sliced_vbi_cap, type)), 1727 IOCTL_INFO(VIDIOC_G_SLICED_VBI_CAP, INFO_FL_CLEAR(v4l2_sliced_vbi_cap, type)),
1643 IOCTL_INFO(VIDIOC_LOG_STATUS, 0), 1728 IOCTL_INFO_FNC(VIDIOC_LOG_STATUS, v4l_log_status, v4l_print_newline, 0),
1644 IOCTL_INFO_FNC(VIDIOC_G_EXT_CTRLS, v4l_g_ext_ctrls, v4l_print_ext_controls, INFO_FL_CTRL), 1729 IOCTL_INFO_FNC(VIDIOC_G_EXT_CTRLS, v4l_g_ext_ctrls, v4l_print_ext_controls, INFO_FL_CTRL),
1645 IOCTL_INFO_FNC(VIDIOC_S_EXT_CTRLS, v4l_s_ext_ctrls, v4l_print_ext_controls, INFO_FL_PRIO | INFO_FL_CTRL), 1730 IOCTL_INFO_FNC(VIDIOC_S_EXT_CTRLS, v4l_s_ext_ctrls, v4l_print_ext_controls, INFO_FL_PRIO | INFO_FL_CTRL),
1646 IOCTL_INFO_FNC(VIDIOC_TRY_EXT_CTRLS, v4l_try_ext_ctrls, v4l_print_ext_controls, 0), 1731 IOCTL_INFO_FNC(VIDIOC_TRY_EXT_CTRLS, v4l_try_ext_ctrls, v4l_print_ext_controls, 0),
@@ -1651,9 +1736,9 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = {
1651 IOCTL_INFO_STD(VIDIOC_TRY_ENCODER_CMD, vidioc_try_encoder_cmd, v4l_print_encoder_cmd, INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), 1736 IOCTL_INFO_STD(VIDIOC_TRY_ENCODER_CMD, vidioc_try_encoder_cmd, v4l_print_encoder_cmd, INFO_FL_CLEAR(v4l2_encoder_cmd, flags)),
1652 IOCTL_INFO_STD(VIDIOC_DECODER_CMD, vidioc_decoder_cmd, v4l_print_decoder_cmd, INFO_FL_PRIO), 1737 IOCTL_INFO_STD(VIDIOC_DECODER_CMD, vidioc_decoder_cmd, v4l_print_decoder_cmd, INFO_FL_PRIO),
1653 IOCTL_INFO_STD(VIDIOC_TRY_DECODER_CMD, vidioc_try_decoder_cmd, v4l_print_decoder_cmd, 0), 1738 IOCTL_INFO_STD(VIDIOC_TRY_DECODER_CMD, vidioc_try_decoder_cmd, v4l_print_decoder_cmd, 0),
1654 IOCTL_INFO(VIDIOC_DBG_S_REGISTER, 0), 1739 IOCTL_INFO_FNC(VIDIOC_DBG_S_REGISTER, v4l_dbg_s_register, v4l_print_dbg_register, 0),
1655 IOCTL_INFO(VIDIOC_DBG_G_REGISTER, 0), 1740 IOCTL_INFO_FNC(VIDIOC_DBG_G_REGISTER, v4l_dbg_g_register, v4l_print_dbg_register, 0),
1656 IOCTL_INFO(VIDIOC_DBG_G_CHIP_IDENT, 0), 1741 IOCTL_INFO_FNC(VIDIOC_DBG_G_CHIP_IDENT, v4l_dbg_g_chip_ident, v4l_print_dbg_chip_ident, 0),
1657 IOCTL_INFO_FNC(VIDIOC_S_HW_FREQ_SEEK, v4l_s_hw_freq_seek, v4l_print_hw_freq_seek, INFO_FL_PRIO), 1742 IOCTL_INFO_FNC(VIDIOC_S_HW_FREQ_SEEK, v4l_s_hw_freq_seek, v4l_print_hw_freq_seek, INFO_FL_PRIO),
1658 IOCTL_INFO(VIDIOC_ENUM_DV_PRESETS, 0), 1743 IOCTL_INFO(VIDIOC_ENUM_DV_PRESETS, 0),
1659 IOCTL_INFO(VIDIOC_S_DV_PRESET, INFO_FL_PRIO), 1744 IOCTL_INFO(VIDIOC_S_DV_PRESET, INFO_FL_PRIO),
@@ -1788,52 +1873,6 @@ static long __video_do_ioctl(struct file *file,
1788 dbgarg2("service_set=%d\n", p->service_set); 1873 dbgarg2("service_set=%d\n", p->service_set);
1789 break; 1874 break;
1790 } 1875 }
1791 case VIDIOC_LOG_STATUS:
1792 {
1793 if (vfd->v4l2_dev)
1794 pr_info("%s: ================= START STATUS =================\n",
1795 vfd->v4l2_dev->name);
1796 ret = ops->vidioc_log_status(file, fh);
1797 if (vfd->v4l2_dev)
1798 pr_info("%s: ================== END STATUS ==================\n",
1799 vfd->v4l2_dev->name);
1800 break;
1801 }
1802 case VIDIOC_DBG_G_REGISTER:
1803 {
1804#ifdef CONFIG_VIDEO_ADV_DEBUG
1805 struct v4l2_dbg_register *p = arg;
1806
1807 if (!capable(CAP_SYS_ADMIN))
1808 ret = -EPERM;
1809 else
1810 ret = ops->vidioc_g_register(file, fh, p);
1811#endif
1812 break;
1813 }
1814 case VIDIOC_DBG_S_REGISTER:
1815 {
1816#ifdef CONFIG_VIDEO_ADV_DEBUG
1817 struct v4l2_dbg_register *p = arg;
1818
1819 if (!capable(CAP_SYS_ADMIN))
1820 ret = -EPERM;
1821 else
1822 ret = ops->vidioc_s_register(file, fh, p);
1823#endif
1824 break;
1825 }
1826 case VIDIOC_DBG_G_CHIP_IDENT:
1827 {
1828 struct v4l2_dbg_chip_ident *p = arg;
1829
1830 p->ident = V4L2_IDENT_NONE;
1831 p->revision = 0;
1832 ret = ops->vidioc_g_chip_ident(file, fh, p);
1833 if (!ret)
1834 dbgarg(cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision);
1835 break;
1836 }
1837 case VIDIOC_ENUM_FRAMESIZES: 1876 case VIDIOC_ENUM_FRAMESIZES:
1838 { 1877 {
1839 struct v4l2_frmsizeenum *p = arg; 1878 struct v4l2_frmsizeenum *p = arg;