summaryrefslogtreecommitdiff
path: root/test/v4l2-ctl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/v4l2-ctl.cpp')
-rw-r--r--test/v4l2-ctl.cpp57
1 files changed, 53 insertions, 4 deletions
diff --git a/test/v4l2-ctl.cpp b/test/v4l2-ctl.cpp
index deb7f3fb9..6e044e563 100644
--- a/test/v4l2-ctl.cpp
+++ b/test/v4l2-ctl.cpp
@@ -36,7 +36,6 @@
#include <math.h>
#include <sys/klog.h>
-#define __user
#include <linux/videodev2.h>
#include <list>
@@ -600,6 +599,7 @@ static int doioctl(int fd, int request, void *parm, const char *name)
if (!option_verbose) return ioctl(fd, request, parm);
retVal = ioctl(fd, request, parm);
+ printf("%s: ", name);
if (retVal < 0)
printf("failed: %s\n", strerror(errno));
else
@@ -641,6 +641,24 @@ static void parse_next_subopt(char **subs, char **value)
}
}
+static void print_std(const char *prefix, const char *stds[], unsigned long long std)
+{
+ int first = 1;
+
+ printf("\t%s-", prefix);
+ while (*stds) {
+ if (std & 1) {
+ if (!first)
+ printf("/");
+ first = 0;
+ printf("%s", *stds);
+ }
+ stds++;
+ std >>= 1;
+ }
+ printf("\n");
+}
+
int main(int argc, char **argv)
{
char *value, *subs;
@@ -656,7 +674,7 @@ int main(int argc, char **argv)
/* command args */
char ch, *device = strdup("/dev/video0"); /* -d device */
struct v4l2_format vfmt; /* set_format/get_format */
- struct v4l2_tuner tuner; /* set_tuner/get_tuner */
+ struct v4l2_tuner tuner = { 0 };/* set_tuner/get_tuner */
struct v4l2_capability vcap; /* list_cap */
struct v4l2_input vin; /* list_inputs */
struct v4l2_output vout; /* list_outputs */
@@ -903,7 +921,7 @@ int main(int argc, char **argv)
fac = (tuner.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16;
}
vf.tuner = 0;
- vf.type = (enum v4l2_tuner_type)0;
+ vf.type = tuner.type;
vf.frequency = __u32(freq * fac);
if (doioctl(fd, VIDIOC_S_FREQUENCY, &vf,
"VIDIOC_S_FREQUENCY") == 0)
@@ -1131,8 +1149,39 @@ int main(int argc, char **argv)
}
if (options[OptGetStandard]) {
- if (doioctl(fd, VIDIOC_G_STD, &std, "VIDIOC_G_STD") == 0)
+ if (doioctl(fd, VIDIOC_G_STD, &std, "VIDIOC_G_STD") == 0) {
+ static const char *pal[] = {
+ "B", "B1", "G", "H", "I", "D", "D1", "K",
+ "M", "N", "Nc", "60",
+ NULL
+ };
+ static const char *ntsc[] = {
+ "M", "M-JP", "443", "M-KR",
+ NULL
+ };
+ static const char *secam[] = {
+ "B", "D", "G", "H", "K", "K1", "L", "Lc",
+ NULL
+ };
+ static const char *atsc[] = {
+ "ATSC-8-VSB", "ATSC-16-VSB",
+ NULL
+ };
+
printf("Video standard = 0x%08llx\n", (unsigned long long)std);
+ if (std & 0xfff) {
+ print_std("PAL", pal, std);
+ }
+ if (std & 0xf000) {
+ print_std("NTSC", ntsc, std >> 12);
+ }
+ if (std & 0xff0000) {
+ print_std("SECAM", secam, std >> 16);
+ }
+ if (std & 0xf000000) {
+ print_std("ATSC/HDTV", atsc, std >> 24);
+ }
+ }
}
if (options[OptListCtrlsMenus]) {