aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDafna Hirschfeld <dafna.hirschfeld@collabora.com>2020-07-03 20:02:36 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2020-09-26 12:20:38 +0200
commit19be88073c416db5abe6fd0219aca00b596bea2e (patch)
tree85da687e4b54caff0e398e5b30b56f82b27ed69b
parentf8cf8346321c9f437ae27a676b44bda53cb103b5 (diff)
v4l2-ctl: vidcap: Add support for the CSC API
With the CSC API, capture drivers can allow userspace to request to set the colorspace fields of the pixelformat. This patch adds supports for this feature. when calling 'v4l2-ctl --set-fmt-video' on capture devices userspace can ask to change the fields 'colorspace', 'ycbcr/hsv_enc', 'quantization' and 'xfer_func' of the format if the driver supports it. Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--utils/v4l2-compliance/v4l2-test-formats.cpp5
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-vidcap.cpp39
2 files changed, 40 insertions, 4 deletions
diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp
index 5ba40d0b..ef669ca2 100644
--- a/utils/v4l2-compliance/v4l2-test-formats.cpp
+++ b/utils/v4l2-compliance/v4l2-test-formats.cpp
@@ -260,7 +260,10 @@ static int testEnumFormatsType(struct node *node, unsigned type)
if (fmtdesc.flags & ~(V4L2_FMT_FLAG_COMPRESSED | V4L2_FMT_FLAG_EMULATED |
V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM |
V4L2_FMT_FLAG_DYN_RESOLUTION |
- V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL))
+ V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL |
+ V4L2_FMT_FLAG_CSC_COLORSPACE |
+ V4L2_FMT_FLAG_CSC_YCBCR_ENC | V4L2_FMT_FLAG_CSC_HSV_ENC |
+ V4L2_FMT_FLAG_CSC_QUANTIZATION | V4L2_FMT_FLAG_CSC_XFER_FUNC))
return fail("unknown flag %08x returned\n", fmtdesc.flags);
if (!(fmtdesc.flags & V4L2_FMT_FLAG_COMPRESSED))
fail_on_test(fmtdesc.flags & (V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM |
diff --git a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
index 4f4a4ea0..1169d6a7 100644
--- a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp
@@ -8,6 +8,7 @@ static struct v4l2_frmsizeenum frmsize; /* list frame sizes */
static struct v4l2_frmivalenum frmival; /* list frame intervals */
static unsigned set_fmts;
static __u32 width, height, pixfmt, field, flags;
+static __u32 ycbcr, quantization, xfer_func, colorspace;
static __u32 bytesperline[VIDEO_MAX_PLANES];
static __u32 sizeimage[VIDEO_MAX_PLANES];
static unsigned mbus_code;
@@ -96,7 +97,6 @@ static void print_video_fields(int fd)
void vidcap_cmd(int ch, char *optarg)
{
- __u32 colorspace, xfer_func, ycbcr, quantization;
char *value, *subs;
bool be_pixfmt;
@@ -106,8 +106,7 @@ void vidcap_cmd(int ch, char *optarg)
set_fmts = parse_fmt(optarg, width, height, pixfmt, field, colorspace,
xfer_func, ycbcr, quantization, flags, bytesperline,
sizeimage);
- if (!set_fmts ||
- (set_fmts & (FmtColorspace | FmtYCbCr | FmtQuantization | FmtXferFunc))) {
+ if (!set_fmts) {
vidcap_usage();
std::exit(EXIT_FAILURE);
}
@@ -220,6 +219,23 @@ int vidcap_get_and_update_fmt(cv4l_fd &_fd, struct v4l2_format &vfmt)
vfmt.fmt.pix_mp.plane_fmt[i].sizeimage =
sizeimage[i];
}
+
+ if (set_fmts & FmtColorspace) {
+ vfmt.fmt.pix_mp.flags |= V4L2_PIX_FMT_FLAG_SET_CSC;
+ vfmt.fmt.pix_mp.colorspace = colorspace;
+ }
+ if (set_fmts & FmtYCbCr) {
+ vfmt.fmt.pix_mp.flags |= V4L2_PIX_FMT_FLAG_SET_CSC;
+ vfmt.fmt.pix_mp.ycbcr_enc = ycbcr;
+ }
+ if (set_fmts & FmtQuantization) {
+ vfmt.fmt.pix_mp.flags |= V4L2_PIX_FMT_FLAG_SET_CSC;
+ vfmt.fmt.pix_mp.quantization = quantization;
+ }
+ if (set_fmts & FmtXferFunc) {
+ vfmt.fmt.pix_mp.flags |= V4L2_PIX_FMT_FLAG_SET_CSC;
+ vfmt.fmt.pix_mp.xfer_func = xfer_func;
+ }
} else {
if (set_fmts & FmtWidth)
vfmt.fmt.pix.width = width;
@@ -249,6 +265,23 @@ int vidcap_get_and_update_fmt(cv4l_fd &_fd, struct v4l2_format &vfmt)
}
if (set_fmts & FmtSizeImage)
vfmt.fmt.pix.sizeimage = sizeimage[0];
+ if (set_fmts & FmtColorspace) {
+ vfmt.fmt.pix.flags |= V4L2_PIX_FMT_FLAG_SET_CSC;
+ vfmt.fmt.pix.colorspace = colorspace;
+ }
+ if (set_fmts & FmtYCbCr) {
+ vfmt.fmt.pix.flags |= V4L2_PIX_FMT_FLAG_SET_CSC;
+ vfmt.fmt.pix.ycbcr_enc = ycbcr;
+ }
+ if (set_fmts & FmtQuantization) {
+ vfmt.fmt.pix.flags |= V4L2_PIX_FMT_FLAG_SET_CSC;
+ vfmt.fmt.pix.quantization = quantization;
+ }
+ if (set_fmts & FmtXferFunc) {
+ vfmt.fmt.pix.flags |= V4L2_PIX_FMT_FLAG_SET_CSC;
+ vfmt.fmt.pix.xfer_func = xfer_func;
+ }
+
}
if ((set_fmts & FmtPixelFormat) &&

Privacy Policy