This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/v4l-utils.git tree:
Subject: v4l2-ctl: add support to try/set raw VBI formats Author: Hans Verkuil <[email protected]> Date: Tue Jun 17 13:09:33 2014 +0200 This was the last bit of missing functionality from v4l2-ctl, now that this is in the full V4L2 API functionality is available through v4l2-ctl. Signed-off-by: Hans Verkuil <[email protected]> utils/v4l2-ctl/v4l2-ctl-vbi.cpp | 116 +++++++++++++++++++++++++++++++++++++- utils/v4l2-ctl/v4l2-ctl.cpp | 4 + utils/v4l2-ctl/v4l2-ctl.h | 8 +- 3 files changed, 120 insertions(+), 8 deletions(-) --- http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=566266878ee835fdbb8170f5d95b04f1219b8c22 diff --git a/utils/v4l2-ctl/v4l2-ctl-vbi.cpp b/utils/v4l2-ctl/v4l2-ctl-vbi.cpp index 49a43f0..3b6b557 100644 --- a/utils/v4l2-ctl/v4l2-ctl-vbi.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-vbi.cpp @@ -16,10 +16,10 @@ #include "v4l2-ctl.h" - struct v4l2_format vbi_fmt; /* set_format/get_format for sliced VBI */ - struct v4l2_format vbi_fmt_out; /* set_format/get_format for sliced VBI output */ - struct v4l2_format raw_fmt; /* set_format/get_format for VBI */ - struct v4l2_format raw_fmt_out; /* set_format/get_format for VBI output */ +static struct v4l2_format vbi_fmt; /* set_format/get_format for sliced VBI */ +static struct v4l2_format vbi_fmt_out; /* set_format/get_format for sliced VBI output */ +static struct v4l2_format raw_fmt; /* set_format/get_format for VBI */ +static struct v4l2_format raw_fmt_out; /* set_format/get_format for VBI output */ void vbi_usage(void) { @@ -48,6 +48,19 @@ void vbi_usage(void) " vps: VPS (PAL/SECAM)\n" " --get-fmt-vbi query the VBI capture format [VIDIOC_G_FMT]\n" " --get-fmt-vbi-out query the VBI output format [VIDIOC_G_FMT]\n" + " --set-fmt-vbi\n" + " --try-fmt-vbi\n" + " --set-fmt-vbi-out\n" + " --try-fmt-vbi-out=samplingrate=<r>,offset=<o>,samplesperline=<spl>,\n" + " start0=<s0>,count0=<c0>,start1=<s1>,count1=<c1>\n" + " set/try the raw VBI capture/output format [VIDIOC_S/TRY_FMT]\n" + " samplingrate: samples per second\n" + " offset: horizontal offset in samples\n" + " samplesperline: samples per line\n" + " start0: start line number of the first field\n" + " count0: number of lines in the first field\n" + " start1: start line number of the second field\n" + " count1: number of lines in the second field\n" ); } @@ -68,6 +81,7 @@ void vbi_cmd(int ch, char *optarg) char *value, *subs; bool found_off = false; v4l2_format *fmt = &vbi_fmt; + v4l2_format *raw = &raw_fmt; switch (ch) { case OptSetSlicedVbiOutFormat: @@ -119,9 +133,75 @@ void vbi_cmd(int ch, char *optarg) exit(1); } break; + case OptSetVbiOutFormat: + case OptTryVbiOutFormat: + raw = &raw_fmt_out; + /* fall through */ + case OptSetVbiFormat: + case OptTryVbiFormat: + subs = optarg; + memset(&raw->fmt.vbi, 0, sizeof(raw->fmt.vbi)); + while (*subs != '\0') { + static const char *const subopts[] = { + "samplingrate", + "offset", + "samplesperline", + "start0", + "start1", + "count0", + "count1", + NULL + }; + + switch (parse_subopt(&subs, subopts, &value)) { + case 0: + raw->fmt.vbi.sampling_rate = strtoul(value, NULL, 0); + break; + case 1: + raw->fmt.vbi.offset = strtoul(value, NULL, 0); + break; + case 2: + raw->fmt.vbi.samples_per_line = strtoul(value, NULL, 0); + break; + case 3: + raw->fmt.vbi.start[0] = strtoul(value, NULL, 0); + break; + case 4: + raw->fmt.vbi.start[1] = strtoul(value, NULL, 0); + break; + case 5: + raw->fmt.vbi.count[0] = strtoul(value, NULL, 0); + break; + case 6: + raw->fmt.vbi.count[1] = strtoul(value, NULL, 0); + break; + default: + vbi_usage(); + break; + } + } + break; } } +static void fill_raw_vbi(v4l2_vbi_format &dst, const v4l2_vbi_format &src) +{ + if (src.sampling_rate) + dst.sampling_rate = src.sampling_rate; + if (src.offset) + dst.offset = src.offset; + if (src.samples_per_line) + dst.samples_per_line = src.samples_per_line; + if (src.start[0]) + dst.start[0] = src.start[0]; + if (src.start[1]) + dst.start[1] = src.start[1]; + if (src.count[0]) + dst.count[0] = src.count[0]; + if (src.count[1]) + dst.count[1] = src.count[1]; +} + void vbi_set(int fd) { int ret; @@ -145,6 +225,34 @@ void vbi_set(int fd) if (ret == 0 && (verbose || options[OptTrySlicedVbiOutFormat])) printfmt(vbi_fmt_out); } + + if (options[OptSetVbiFormat] || options[OptTryVbiFormat]) { + v4l2_format fmt; + + fmt.type = vbi_fmt.type = V4L2_BUF_TYPE_VBI_CAPTURE; + doioctl(fd, VIDIOC_G_FMT, &fmt); + fill_raw_vbi(fmt.fmt.vbi, raw_fmt.fmt.vbi); + if (options[OptSetVbiFormat]) + ret = doioctl(fd, VIDIOC_S_FMT, &raw_fmt); + else + ret = doioctl(fd, VIDIOC_TRY_FMT, &raw_fmt); + if (ret == 0 && (verbose || options[OptTryVbiFormat])) + printfmt(vbi_fmt); + } + + if (options[OptSetVbiOutFormat] || options[OptTryVbiOutFormat]) { + v4l2_format fmt; + + fmt.type = vbi_fmt.type = V4L2_BUF_TYPE_VBI_OUTPUT; + doioctl(fd, VIDIOC_G_FMT, &fmt); + fill_raw_vbi(fmt.fmt.vbi, raw_fmt.fmt.vbi); + if (options[OptSetVbiOutFormat]) + ret = doioctl(fd, VIDIOC_S_FMT, &raw_fmt); + else + ret = doioctl(fd, VIDIOC_TRY_FMT, &raw_fmt); + if (ret == 0 && (verbose || options[OptTryVbiOutFormat])) + printfmt(vbi_fmt); + } } void vbi_get(int fd) diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp index 8d0cfbc..72c091c 100644 --- a/utils/v4l2-ctl/v4l2-ctl.cpp +++ b/utils/v4l2-ctl/v4l2-ctl.cpp @@ -143,7 +143,11 @@ static struct option long_options[] = { {"set-fmt-sliced-vbi-out", required_argument, 0, OptSetSlicedVbiOutFormat}, {"try-fmt-sliced-vbi-out", required_argument, 0, OptTrySlicedVbiOutFormat}, {"get-fmt-vbi", no_argument, 0, OptGetVbiFormat}, + {"set-fmt-vbi", required_argument, 0, OptSetVbiFormat}, + {"try-fmt-vbi", required_argument, 0, OptTryVbiFormat}, {"get-fmt-vbi-out", no_argument, 0, OptGetVbiOutFormat}, + {"set-fmt-vbi-out", required_argument, 0, OptSetVbiOutFormat}, + {"try-fmt-vbi-out", required_argument, 0, OptTryVbiOutFormat}, {"get-fmt-sdr", no_argument, 0, OptGetSdrFormat}, {"set-fmt-sdr", required_argument, 0, OptSetSdrFormat}, {"try-fmt-sdr", required_argument, 0, OptTrySdrFormat}, diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h index 4e4038d..bf90c8e 100644 --- a/utils/v4l2-ctl/v4l2-ctl.h +++ b/utils/v4l2-ctl/v4l2-ctl.h @@ -66,8 +66,8 @@ enum Option { OptGetVideoOutFormat, OptSetSlicedVbiOutFormat, OptSetOverlayFormat, - //OptSetVbiFormat, TODO - //OptSetVbiOutFormat, TODO + OptSetVbiFormat, + OptSetVbiOutFormat, OptSetSdrFormat, OptSetVideoOutFormat, OptTryVideoOutFormat, @@ -75,8 +75,8 @@ enum Option { OptTrySlicedVbiFormat, OptTryVideoFormat, OptTryOverlayFormat, - //OptTryVbiFormat, TODO - //OptTryVbiOutFormat, TODO + OptTryVbiFormat, + OptTryVbiOutFormat, OptTrySdrFormat, OptAll, OptListStandards, _______________________________________________ linuxtv-commits mailing list [email protected] http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits
