v4l2-ctl: add support for SDR FMT
authorHans Verkuil <hans.verkuil@cisco.com>
Wed, 5 Mar 2014 20:35:26 +0000 (21:35 +0100)
committerHans Verkuil <hans.verkuil@cisco.com>
Wed, 5 Mar 2014 20:35:26 +0000 (21:35 +0100)
Add support for FMT IOCTL operations used for SDR receivers.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/v4l2-ctl/Makefile.am
utils/v4l2-ctl/v4l2-ctl-common.cpp
utils/v4l2-ctl/v4l2-ctl.cpp
utils/v4l2-ctl/v4l2-ctl.h

index b5744e7..becaa15 100644 (file)
@@ -8,5 +8,5 @@ ivtv_ctl_LDFLAGS = -lm
 v4l2_ctl_SOURCES = v4l2-ctl.cpp v4l2-ctl.h v4l2-ctl-common.cpp v4l2-ctl-tuner.cpp \
        v4l2-ctl-io.cpp v4l2-ctl-stds.cpp v4l2-ctl-vidcap.cpp v4l2-ctl-vidout.cpp \
        v4l2-ctl-overlay.cpp v4l2-ctl-vbi.cpp v4l2-ctl-selection.cpp v4l2-ctl-misc.cpp \
-       v4l2-ctl-streaming.cpp v4l2-ctl-test-patterns.cpp
+       v4l2-ctl-streaming.cpp v4l2-ctl-test-patterns.cpp v4l2-ctl-sdr.cpp
 v4l2_ctl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la
index 055a92d..a68f1c6 100644 (file)
@@ -67,6 +67,7 @@ void common_usage(void)
               "  --help-io          input/output options\n"
               "  --help-misc        miscellaneous options\n"
               "  --help-overlay     overlay format options\n"
+              "  --help-sdr         SDR format options\n"
               "  --help-selection   crop/selection options\n"
               "  --help-stds        standards and other video timings options\n"
               "  --help-streaming   streaming options\n"
index 41930d2..33a86bb 100644 (file)
@@ -84,6 +84,7 @@ static struct option long_options[] = {
        {"help-vidout", no_argument, 0, OptHelpVidOut},
        {"help-overlay", no_argument, 0, OptHelpOverlay},
        {"help-vbi", no_argument, 0, OptHelpVbi},
+       {"help-sdr", no_argument, 0, OptHelpSdr},
        {"help-selection", no_argument, 0, OptHelpSelection},
        {"help-misc", no_argument, 0, OptHelpMisc},
        {"help-streaming", no_argument, 0, OptHelpStreaming},
@@ -109,6 +110,7 @@ static struct option long_options[] = {
        {"list-framesizes", required_argument, 0, OptListFrameSizes},
        {"list-frameintervals", required_argument, 0, OptListFrameIntervals},
        {"list-formats-overlay", no_argument, 0, OptListOverlayFormats},
+       {"list-formats-sdr", no_argument, 0, OptListSdrFormats},
        {"list-formats-out", no_argument, 0, OptListOutFormats},
        {"list-fields-out", no_argument, 0, OptListOutFields},
        {"clear-clips", no_argument, 0, OptClearClips},
@@ -145,6 +147,9 @@ static struct option long_options[] = {
        {"try-fmt-sliced-vbi-out", required_argument, 0, OptTrySlicedVbiOutFormat},
        {"get-fmt-vbi", no_argument, 0, OptGetVbiFormat},
        {"get-fmt-vbi-out", no_argument, 0, OptGetVbiOutFormat},
+       {"get-fmt-sdr", no_argument, 0, OptGetSdrFormat},
+       {"set-fmt-sdr", required_argument, 0, OptSetSdrFormat},
+       {"try-fmt-sdr", required_argument, 0, OptTrySdrFormat},
        {"get-sliced-vbi-cap", no_argument, 0, OptGetSlicedVbiCap},
        {"get-sliced-vbi-out-cap", no_argument, 0, OptGetSlicedVbiOutCap},
        {"get-fbuf", no_argument, 0, OptGetFBuf},
@@ -219,6 +224,7 @@ static void usage_all(void)
        vidout_usage();
        overlay_usage();
        vbi_usage();
+       sdr_usage();
        selection_usage();
        misc_usage();
        streaming_usage();
@@ -287,6 +293,8 @@ std::string buftype2s(int type)
                return "Sliced VBI Output";
        case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
                return "Video Output Overlay";
+       case V4L2_BUF_TYPE_SDR_CAPTURE:
+               return "SDR Capture";
        default:
                return "Unknown (" + num2s(type) + ")";
        }
@@ -479,6 +487,9 @@ void printfmt(const struct v4l2_format &vfmt)
                }
                printf("\tI/O Size       : %u\n", vfmt.fmt.sliced.io_size);
                break;
+       case V4L2_BUF_TYPE_SDR_CAPTURE:
+               printf("\tSample Format   : %s\n", fcc2s(vfmt.fmt.sdr.pixelformat).c_str());
+               break;
        }
 }
 
@@ -540,6 +551,8 @@ static std::string cap2s(unsigned cap)
                s += "\t\tSliced VBI Capture\n";
        if (cap & V4L2_CAP_SLICED_VBI_OUTPUT)
                s += "\t\tSliced VBI Output\n";
+       if (cap & V4L2_CAP_SDR_CAPTURE)
+               s += "\t\tSDR Capture\n";
        if (cap & V4L2_CAP_RDS_CAPTURE)
                s += "\t\tRDS Capture\n";
        if (cap & V4L2_CAP_RDS_OUTPUT)
@@ -800,6 +813,7 @@ __u32 find_pixel_format(int fd, unsigned index, bool output, bool mplane)
        else
                fmt.type = mplane ?  V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE :
                        V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
        if (doioctl(fd, VIDIOC_ENUM_FMT, &fmt))
                return 0;
        return fmt.pixelformat;
@@ -877,6 +891,9 @@ int main(int argc, char **argv)
                case OptHelpVbi:
                        vbi_usage();
                        return 0;
+               case OptHelpSdr:
+                       sdr_usage();
+                       return 0;
                case OptHelpSelection:
                        selection_usage();
                        return 0;
@@ -939,6 +956,7 @@ int main(int argc, char **argv)
                        vidout_cmd(ch, optarg);
                        overlay_cmd(ch, optarg);
                        vbi_cmd(ch, optarg);
+                       sdr_cmd(ch, optarg);
                        selection_cmd(ch, optarg);
                        misc_cmd(ch, optarg);
                        streaming_cmd(ch, optarg);
@@ -1026,6 +1044,7 @@ int main(int argc, char **argv)
                options[OptGetVbiOutFormat] = 1;
                options[OptGetSlicedVbiFormat] = 1;
                options[OptGetSlicedVbiOutFormat] = 1;
+               options[OptGetSdrFormat] = 1;
                options[OptGetFBuf] = 1;
                options[OptGetCropCap] = 1;
                options[OptGetOutputCropCap] = 1;
@@ -1069,6 +1088,7 @@ int main(int argc, char **argv)
        vidout_set(fd);
        overlay_set(fd);
        vbi_set(fd);
+       sdr_set(fd);
        selection_set(fd);
        streaming_set(fd, out_fd);
        misc_set(fd);
@@ -1083,6 +1103,7 @@ int main(int argc, char **argv)
        vidout_get(fd);
        overlay_get(fd);
        vbi_get(fd);
+       sdr_get(fd);
        selection_get(fd);
        misc_get(fd);
 
@@ -1095,6 +1116,7 @@ int main(int argc, char **argv)
        vidout_list(fd);
        overlay_list(fd);
        vbi_list(fd);
+       sdr_list(fd);
        streaming_list(fd, out_fd);
 
        if (options[OptWaitForEvent]) {
index fec9b50..8fefd60 100644 (file)
@@ -42,11 +42,13 @@ enum Option {
        OptGetOverlayFormat,
        OptGetVbiFormat,
        OptGetVbiOutFormat,
+       OptGetSdrFormat,
        OptGetVideoOutFormat,
        OptSetSlicedVbiOutFormat,
        OptSetOverlayFormat,
        //OptSetVbiFormat, TODO
        //OptSetVbiOutFormat, TODO
+       OptSetSdrFormat,
        OptSetVideoOutFormat,
        OptTryVideoOutFormat,
        OptTrySlicedVbiOutFormat,
@@ -55,6 +57,7 @@ enum Option {
        OptTryOverlayFormat,
        //OptTryVbiFormat, TODO
        //OptTryVbiOutFormat, TODO
+       OptTrySdrFormat,
        OptAll,
        OptListStandards,
        OptListFormats,
@@ -63,6 +66,7 @@ enum Option {
        OptListFrameSizes,
        OptListFrameIntervals,
        OptListOverlayFormats,
+       OptListSdrFormats,
        OptListOutFormats,
        OptListOutFields,
        OptClearClips,
@@ -151,6 +155,7 @@ enum Option {
        OptHelpVidOut,
        OptHelpOverlay,
        OptHelpVbi,
+       OptHelpSdr,
        OptHelpSelection,
        OptHelpMisc,
        OptHelpStreaming,
@@ -262,6 +267,13 @@ void vbi_set(int fd);
 void vbi_get(int fd);
 void vbi_list(int fd);
 
+// v4l2-ctl-sdr.cpp
+void sdr_usage(void);
+void sdr_cmd(int ch, char *optarg);
+void sdr_set(int fd);
+void sdr_get(int fd);
+void sdr_list(int fd);
+
 // v4l2-ctl-selection.cpp
 void selection_usage(void);
 void selection_cmd(int ch, char *optarg);