diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2012-06-09 11:55:52 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-06 16:19:53 -0400 |
commit | 458aa4a6922bf4cc22a34adfe3bd56331bbf663e (patch) | |
tree | 075ffe265e01b6678f24d09ab3e59bb22fb5e82b | |
parent | efc626b013900c5fc23b9900943356d0ece96d48 (diff) |
[media] v4l2-ioctl.c: use the new table for the remaining ioctls
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/v4l2-ioctl.c | 278 |
1 files changed, 154 insertions, 124 deletions
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index fdceac803b6f..74fe6a2797e8 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c | |||
@@ -726,6 +726,125 @@ static void v4l_print_dv_timings_cap(const void *arg, bool write_only) | |||
726 | } | 726 | } |
727 | } | 727 | } |
728 | 728 | ||
729 | static void v4l_print_frmsizeenum(const void *arg, bool write_only) | ||
730 | { | ||
731 | const struct v4l2_frmsizeenum *p = arg; | ||
732 | |||
733 | pr_cont("index=%u, pixelformat=%c%c%c%c, type=%u", | ||
734 | p->index, | ||
735 | (p->pixel_format & 0xff), | ||
736 | (p->pixel_format >> 8) & 0xff, | ||
737 | (p->pixel_format >> 16) & 0xff, | ||
738 | (p->pixel_format >> 24) & 0xff, | ||
739 | p->type); | ||
740 | switch (p->type) { | ||
741 | case V4L2_FRMSIZE_TYPE_DISCRETE: | ||
742 | pr_cont(" wxh=%ux%u\n", | ||
743 | p->discrete.width, p->discrete.height); | ||
744 | break; | ||
745 | case V4L2_FRMSIZE_TYPE_STEPWISE: | ||
746 | pr_cont(" min=%ux%u, max=%ux%u, step=%ux%u\n", | ||
747 | p->stepwise.min_width, p->stepwise.min_height, | ||
748 | p->stepwise.step_width, p->stepwise.step_height, | ||
749 | p->stepwise.max_width, p->stepwise.max_height); | ||
750 | break; | ||
751 | case V4L2_FRMSIZE_TYPE_CONTINUOUS: | ||
752 | /* fall through */ | ||
753 | default: | ||
754 | pr_cont("\n"); | ||
755 | break; | ||
756 | } | ||
757 | } | ||
758 | |||
759 | static void v4l_print_frmivalenum(const void *arg, bool write_only) | ||
760 | { | ||
761 | const struct v4l2_frmivalenum *p = arg; | ||
762 | |||
763 | pr_cont("index=%u, pixelformat=%c%c%c%c, wxh=%ux%u, type=%u", | ||
764 | p->index, | ||
765 | (p->pixel_format & 0xff), | ||
766 | (p->pixel_format >> 8) & 0xff, | ||
767 | (p->pixel_format >> 16) & 0xff, | ||
768 | (p->pixel_format >> 24) & 0xff, | ||
769 | p->width, p->height, p->type); | ||
770 | switch (p->type) { | ||
771 | case V4L2_FRMIVAL_TYPE_DISCRETE: | ||
772 | pr_cont(" fps=%d/%d\n", | ||
773 | p->discrete.numerator, | ||
774 | p->discrete.denominator); | ||
775 | break; | ||
776 | case V4L2_FRMIVAL_TYPE_STEPWISE: | ||
777 | pr_cont(" min=%d/%d, max=%d/%d, step=%d/%d\n", | ||
778 | p->stepwise.min.numerator, | ||
779 | p->stepwise.min.denominator, | ||
780 | p->stepwise.max.numerator, | ||
781 | p->stepwise.max.denominator, | ||
782 | p->stepwise.step.numerator, | ||
783 | p->stepwise.step.denominator); | ||
784 | break; | ||
785 | case V4L2_FRMIVAL_TYPE_CONTINUOUS: | ||
786 | /* fall through */ | ||
787 | default: | ||
788 | pr_cont("\n"); | ||
789 | break; | ||
790 | } | ||
791 | } | ||
792 | |||
793 | static void v4l_print_event(const void *arg, bool write_only) | ||
794 | { | ||
795 | const struct v4l2_event *p = arg; | ||
796 | const struct v4l2_event_ctrl *c; | ||
797 | |||
798 | pr_cont("type=0x%x, pending=%u, sequence=%u, id=%u, " | ||
799 | "timestamp=%lu.%9.9lu\n", | ||
800 | p->type, p->pending, p->sequence, p->id, | ||
801 | p->timestamp.tv_sec, p->timestamp.tv_nsec); | ||
802 | switch (p->type) { | ||
803 | case V4L2_EVENT_VSYNC: | ||
804 | printk(KERN_DEBUG "field=%s\n", | ||
805 | prt_names(p->u.vsync.field, v4l2_field_names)); | ||
806 | break; | ||
807 | case V4L2_EVENT_CTRL: | ||
808 | c = &p->u.ctrl; | ||
809 | printk(KERN_DEBUG "changes=0x%x, type=%u, ", | ||
810 | c->changes, c->type); | ||
811 | if (c->type == V4L2_CTRL_TYPE_INTEGER64) | ||
812 | pr_cont("value64=%lld, ", c->value64); | ||
813 | else | ||
814 | pr_cont("value=%d, ", c->value); | ||
815 | pr_cont("flags=0x%x, minimum=%d, maximum=%d, step=%d," | ||
816 | " default_value=%d\n", | ||
817 | c->flags, c->minimum, c->maximum, | ||
818 | c->step, c->default_value); | ||
819 | break; | ||
820 | case V4L2_EVENT_FRAME_SYNC: | ||
821 | pr_cont("frame_sequence=%u\n", | ||
822 | p->u.frame_sync.frame_sequence); | ||
823 | break; | ||
824 | } | ||
825 | } | ||
826 | |||
827 | static void v4l_print_event_subscription(const void *arg, bool write_only) | ||
828 | { | ||
829 | const struct v4l2_event_subscription *p = arg; | ||
830 | |||
831 | pr_cont("type=0x%x, id=0x%x, flags=0x%x\n", | ||
832 | p->type, p->id, p->flags); | ||
833 | } | ||
834 | |||
835 | static void v4l_print_sliced_vbi_cap(const void *arg, bool write_only) | ||
836 | { | ||
837 | const struct v4l2_sliced_vbi_cap *p = arg; | ||
838 | int i; | ||
839 | |||
840 | pr_cont("type=%s, service_set=0x%08x\n", | ||
841 | prt_names(p->type, v4l2_type_names), p->service_set); | ||
842 | for (i = 0; i < 24; i++) | ||
843 | printk(KERN_DEBUG "line[%02u]=0x%04x, 0x%04x\n", i, | ||
844 | p->service_lines[0][i], | ||
845 | p->service_lines[1][i]); | ||
846 | } | ||
847 | |||
729 | static void v4l_print_u32(const void *arg, bool write_only) | 848 | static void v4l_print_u32(const void *arg, bool write_only) |
730 | { | 849 | { |
731 | pr_cont("value=%u\n", *(const u32 *)arg); | 850 | pr_cont("value=%u\n", *(const u32 *)arg); |
@@ -1665,6 +1784,35 @@ static int v4l_dbg_g_chip_ident(const struct v4l2_ioctl_ops *ops, | |||
1665 | return ops->vidioc_g_chip_ident(file, fh, p); | 1784 | return ops->vidioc_g_chip_ident(file, fh, p); |
1666 | } | 1785 | } |
1667 | 1786 | ||
1787 | static int v4l_dqevent(const struct v4l2_ioctl_ops *ops, | ||
1788 | struct file *file, void *fh, void *arg) | ||
1789 | { | ||
1790 | return v4l2_event_dequeue(fh, arg, file->f_flags & O_NONBLOCK); | ||
1791 | } | ||
1792 | |||
1793 | static int v4l_subscribe_event(const struct v4l2_ioctl_ops *ops, | ||
1794 | struct file *file, void *fh, void *arg) | ||
1795 | { | ||
1796 | return ops->vidioc_subscribe_event(fh, arg); | ||
1797 | } | ||
1798 | |||
1799 | static int v4l_unsubscribe_event(const struct v4l2_ioctl_ops *ops, | ||
1800 | struct file *file, void *fh, void *arg) | ||
1801 | { | ||
1802 | return ops->vidioc_unsubscribe_event(fh, arg); | ||
1803 | } | ||
1804 | |||
1805 | static int v4l_g_sliced_vbi_cap(const struct v4l2_ioctl_ops *ops, | ||
1806 | struct file *file, void *fh, void *arg) | ||
1807 | { | ||
1808 | struct v4l2_sliced_vbi_cap *p = arg; | ||
1809 | |||
1810 | /* Clear up to type, everything after type is zeroed already */ | ||
1811 | memset(p, 0, offsetof(struct v4l2_sliced_vbi_cap, type)); | ||
1812 | |||
1813 | return ops->vidioc_g_sliced_vbi_cap(file, fh, p); | ||
1814 | } | ||
1815 | |||
1668 | struct v4l2_ioctl_info { | 1816 | struct v4l2_ioctl_info { |
1669 | unsigned int ioctl; | 1817 | unsigned int ioctl; |
1670 | u32 flags; | 1818 | u32 flags; |
@@ -1767,13 +1915,13 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { | |||
1767 | IOCTL_INFO_STD(VIDIOC_ENUMAUDOUT, vidioc_enumaudout, v4l_print_audioout, INFO_FL_CLEAR(v4l2_audioout, index)), | 1915 | IOCTL_INFO_STD(VIDIOC_ENUMAUDOUT, vidioc_enumaudout, v4l_print_audioout, INFO_FL_CLEAR(v4l2_audioout, index)), |
1768 | IOCTL_INFO_FNC(VIDIOC_G_PRIORITY, v4l_g_priority, v4l_print_u32, 0), | 1916 | IOCTL_INFO_FNC(VIDIOC_G_PRIORITY, v4l_g_priority, v4l_print_u32, 0), |
1769 | IOCTL_INFO_FNC(VIDIOC_S_PRIORITY, v4l_s_priority, v4l_print_u32, INFO_FL_PRIO), | 1917 | IOCTL_INFO_FNC(VIDIOC_S_PRIORITY, v4l_s_priority, v4l_print_u32, INFO_FL_PRIO), |
1770 | IOCTL_INFO(VIDIOC_G_SLICED_VBI_CAP, INFO_FL_CLEAR(v4l2_sliced_vbi_cap, type)), | 1918 | IOCTL_INFO_FNC(VIDIOC_G_SLICED_VBI_CAP, v4l_g_sliced_vbi_cap, v4l_print_sliced_vbi_cap, INFO_FL_CLEAR(v4l2_sliced_vbi_cap, type)), |
1771 | IOCTL_INFO_FNC(VIDIOC_LOG_STATUS, v4l_log_status, v4l_print_newline, 0), | 1919 | IOCTL_INFO_FNC(VIDIOC_LOG_STATUS, v4l_log_status, v4l_print_newline, 0), |
1772 | IOCTL_INFO_FNC(VIDIOC_G_EXT_CTRLS, v4l_g_ext_ctrls, v4l_print_ext_controls, INFO_FL_CTRL), | 1920 | IOCTL_INFO_FNC(VIDIOC_G_EXT_CTRLS, v4l_g_ext_ctrls, v4l_print_ext_controls, INFO_FL_CTRL), |
1773 | IOCTL_INFO_FNC(VIDIOC_S_EXT_CTRLS, v4l_s_ext_ctrls, v4l_print_ext_controls, INFO_FL_PRIO | INFO_FL_CTRL), | 1921 | IOCTL_INFO_FNC(VIDIOC_S_EXT_CTRLS, v4l_s_ext_ctrls, v4l_print_ext_controls, INFO_FL_PRIO | INFO_FL_CTRL), |
1774 | IOCTL_INFO_FNC(VIDIOC_TRY_EXT_CTRLS, v4l_try_ext_ctrls, v4l_print_ext_controls, 0), | 1922 | IOCTL_INFO_FNC(VIDIOC_TRY_EXT_CTRLS, v4l_try_ext_ctrls, v4l_print_ext_controls, 0), |
1775 | IOCTL_INFO(VIDIOC_ENUM_FRAMESIZES, INFO_FL_CLEAR(v4l2_frmsizeenum, pixel_format)), | 1923 | IOCTL_INFO_STD(VIDIOC_ENUM_FRAMESIZES, vidioc_enum_framesizes, v4l_print_frmsizeenum, INFO_FL_CLEAR(v4l2_frmsizeenum, pixel_format)), |
1776 | IOCTL_INFO(VIDIOC_ENUM_FRAMEINTERVALS, INFO_FL_CLEAR(v4l2_frmivalenum, height)), | 1924 | IOCTL_INFO_STD(VIDIOC_ENUM_FRAMEINTERVALS, vidioc_enum_frameintervals, v4l_print_frmivalenum, INFO_FL_CLEAR(v4l2_frmivalenum, height)), |
1777 | IOCTL_INFO_STD(VIDIOC_G_ENC_INDEX, vidioc_g_enc_index, v4l_print_enc_idx, 0), | 1925 | IOCTL_INFO_STD(VIDIOC_G_ENC_INDEX, vidioc_g_enc_index, v4l_print_enc_idx, 0), |
1778 | IOCTL_INFO_STD(VIDIOC_ENCODER_CMD, vidioc_encoder_cmd, v4l_print_encoder_cmd, INFO_FL_PRIO | INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), | 1926 | IOCTL_INFO_STD(VIDIOC_ENCODER_CMD, vidioc_encoder_cmd, v4l_print_encoder_cmd, INFO_FL_PRIO | INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), |
1779 | IOCTL_INFO_STD(VIDIOC_TRY_ENCODER_CMD, vidioc_try_encoder_cmd, v4l_print_encoder_cmd, INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), | 1927 | IOCTL_INFO_STD(VIDIOC_TRY_ENCODER_CMD, vidioc_try_encoder_cmd, v4l_print_encoder_cmd, INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), |
@@ -1789,9 +1937,9 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { | |||
1789 | IOCTL_INFO_STD(VIDIOC_QUERY_DV_PRESET, vidioc_query_dv_preset, v4l_print_dv_preset, 0), | 1937 | IOCTL_INFO_STD(VIDIOC_QUERY_DV_PRESET, vidioc_query_dv_preset, v4l_print_dv_preset, 0), |
1790 | IOCTL_INFO_STD(VIDIOC_S_DV_TIMINGS, vidioc_s_dv_timings, v4l_print_dv_timings, INFO_FL_PRIO), | 1938 | IOCTL_INFO_STD(VIDIOC_S_DV_TIMINGS, vidioc_s_dv_timings, v4l_print_dv_timings, INFO_FL_PRIO), |
1791 | IOCTL_INFO_STD(VIDIOC_G_DV_TIMINGS, vidioc_g_dv_timings, v4l_print_dv_timings, 0), | 1939 | IOCTL_INFO_STD(VIDIOC_G_DV_TIMINGS, vidioc_g_dv_timings, v4l_print_dv_timings, 0), |
1792 | IOCTL_INFO(VIDIOC_DQEVENT, 0), | 1940 | IOCTL_INFO_FNC(VIDIOC_DQEVENT, v4l_dqevent, v4l_print_event, 0), |
1793 | IOCTL_INFO(VIDIOC_SUBSCRIBE_EVENT, 0), | 1941 | IOCTL_INFO_FNC(VIDIOC_SUBSCRIBE_EVENT, v4l_subscribe_event, v4l_print_event_subscription, 0), |
1794 | IOCTL_INFO(VIDIOC_UNSUBSCRIBE_EVENT, 0), | 1942 | IOCTL_INFO_FNC(VIDIOC_UNSUBSCRIBE_EVENT, v4l_unsubscribe_event, v4l_print_event_subscription, 0), |
1795 | IOCTL_INFO_FNC(VIDIOC_CREATE_BUFS, v4l_create_bufs, v4l_print_create_buffers, INFO_FL_PRIO), | 1943 | IOCTL_INFO_FNC(VIDIOC_CREATE_BUFS, v4l_create_bufs, v4l_print_create_buffers, INFO_FL_PRIO), |
1796 | IOCTL_INFO_FNC(VIDIOC_PREPARE_BUF, v4l_prepare_buf, v4l_print_buffer, 0), | 1944 | IOCTL_INFO_FNC(VIDIOC_PREPARE_BUF, v4l_prepare_buf, v4l_print_buffer, 0), |
1797 | IOCTL_INFO_STD(VIDIOC_ENUM_DV_TIMINGS, vidioc_enum_dv_timings, v4l_print_enum_dv_timings, 0), | 1945 | IOCTL_INFO_STD(VIDIOC_ENUM_DV_TIMINGS, vidioc_enum_dv_timings, v4l_print_enum_dv_timings, 0), |
@@ -1903,124 +2051,6 @@ static long __video_do_ioctl(struct file *file, | |||
1903 | } | 2051 | } |
1904 | 2052 | ||
1905 | switch (cmd) { | 2053 | switch (cmd) { |
1906 | case VIDIOC_G_SLICED_VBI_CAP: | ||
1907 | { | ||
1908 | struct v4l2_sliced_vbi_cap *p = arg; | ||
1909 | |||
1910 | /* Clear up to type, everything after type is zerod already */ | ||
1911 | memset(p, 0, offsetof(struct v4l2_sliced_vbi_cap, type)); | ||
1912 | |||
1913 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | ||
1914 | ret = ops->vidioc_g_sliced_vbi_cap(file, fh, p); | ||
1915 | if (!ret) | ||
1916 | dbgarg2("service_set=%d\n", p->service_set); | ||
1917 | break; | ||
1918 | } | ||
1919 | case VIDIOC_ENUM_FRAMESIZES: | ||
1920 | { | ||
1921 | struct v4l2_frmsizeenum *p = arg; | ||
1922 | |||
1923 | ret = ops->vidioc_enum_framesizes(file, fh, p); | ||
1924 | dbgarg(cmd, | ||
1925 | "index=%d, pixelformat=%c%c%c%c, type=%d ", | ||
1926 | p->index, | ||
1927 | (p->pixel_format & 0xff), | ||
1928 | (p->pixel_format >> 8) & 0xff, | ||
1929 | (p->pixel_format >> 16) & 0xff, | ||
1930 | (p->pixel_format >> 24) & 0xff, | ||
1931 | p->type); | ||
1932 | switch (p->type) { | ||
1933 | case V4L2_FRMSIZE_TYPE_DISCRETE: | ||
1934 | dbgarg3("width = %d, height=%d\n", | ||
1935 | p->discrete.width, p->discrete.height); | ||
1936 | break; | ||
1937 | case V4L2_FRMSIZE_TYPE_STEPWISE: | ||
1938 | dbgarg3("min %dx%d, max %dx%d, step %dx%d\n", | ||
1939 | p->stepwise.min_width, p->stepwise.min_height, | ||
1940 | p->stepwise.step_width, p->stepwise.step_height, | ||
1941 | p->stepwise.max_width, p->stepwise.max_height); | ||
1942 | break; | ||
1943 | case V4L2_FRMSIZE_TYPE_CONTINUOUS: | ||
1944 | dbgarg3("continuous\n"); | ||
1945 | break; | ||
1946 | default: | ||
1947 | dbgarg3("- Unknown type!\n"); | ||
1948 | } | ||
1949 | |||
1950 | break; | ||
1951 | } | ||
1952 | case VIDIOC_ENUM_FRAMEINTERVALS: | ||
1953 | { | ||
1954 | struct v4l2_frmivalenum *p = arg; | ||
1955 | |||
1956 | ret = ops->vidioc_enum_frameintervals(file, fh, p); | ||
1957 | dbgarg(cmd, | ||
1958 | "index=%d, pixelformat=%d, width=%d, height=%d, type=%d ", | ||
1959 | p->index, p->pixel_format, | ||
1960 | p->width, p->height, p->type); | ||
1961 | switch (p->type) { | ||
1962 | case V4L2_FRMIVAL_TYPE_DISCRETE: | ||
1963 | dbgarg2("fps=%d/%d\n", | ||
1964 | p->discrete.numerator, | ||
1965 | p->discrete.denominator); | ||
1966 | break; | ||
1967 | case V4L2_FRMIVAL_TYPE_STEPWISE: | ||
1968 | dbgarg2("min=%d/%d, max=%d/%d, step=%d/%d\n", | ||
1969 | p->stepwise.min.numerator, | ||
1970 | p->stepwise.min.denominator, | ||
1971 | p->stepwise.max.numerator, | ||
1972 | p->stepwise.max.denominator, | ||
1973 | p->stepwise.step.numerator, | ||
1974 | p->stepwise.step.denominator); | ||
1975 | break; | ||
1976 | case V4L2_FRMIVAL_TYPE_CONTINUOUS: | ||
1977 | dbgarg2("continuous\n"); | ||
1978 | break; | ||
1979 | default: | ||
1980 | dbgarg2("- Unknown type!\n"); | ||
1981 | } | ||
1982 | break; | ||
1983 | } | ||
1984 | case VIDIOC_DQEVENT: | ||
1985 | { | ||
1986 | struct v4l2_event *ev = arg; | ||
1987 | |||
1988 | ret = v4l2_event_dequeue(fh, ev, file->f_flags & O_NONBLOCK); | ||
1989 | if (ret < 0) { | ||
1990 | dbgarg(cmd, "no pending events?"); | ||
1991 | break; | ||
1992 | } | ||
1993 | dbgarg(cmd, | ||
1994 | "pending=%d, type=0x%8.8x, sequence=%d, " | ||
1995 | "timestamp=%lu.%9.9lu ", | ||
1996 | ev->pending, ev->type, ev->sequence, | ||
1997 | ev->timestamp.tv_sec, ev->timestamp.tv_nsec); | ||
1998 | break; | ||
1999 | } | ||
2000 | case VIDIOC_SUBSCRIBE_EVENT: | ||
2001 | { | ||
2002 | struct v4l2_event_subscription *sub = arg; | ||
2003 | |||
2004 | ret = ops->vidioc_subscribe_event(fh, sub); | ||
2005 | if (ret < 0) { | ||
2006 | dbgarg(cmd, "failed, ret=%ld", ret); | ||
2007 | break; | ||
2008 | } | ||
2009 | dbgarg(cmd, "type=0x%8.8x", sub->type); | ||
2010 | break; | ||
2011 | } | ||
2012 | case VIDIOC_UNSUBSCRIBE_EVENT: | ||
2013 | { | ||
2014 | struct v4l2_event_subscription *sub = arg; | ||
2015 | |||
2016 | ret = ops->vidioc_unsubscribe_event(fh, sub); | ||
2017 | if (ret < 0) { | ||
2018 | dbgarg(cmd, "failed, ret=%ld", ret); | ||
2019 | break; | ||
2020 | } | ||
2021 | dbgarg(cmd, "type=0x%8.8x", sub->type); | ||
2022 | break; | ||
2023 | } | ||
2024 | default: | 2054 | default: |
2025 | if (!ops->vidioc_default) | 2055 | if (!ops->vidioc_default) |
2026 | break; | 2056 | break; |