summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2020-06-11 12:02:14 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2020-06-25 23:47:13 +0900
commit012cfab9b17ffd084ef8fa5fcc1eb8d651ff85dc (patch)
tree0819567dcb3493c053316efaeff15232f3f10685 /src
parentb5d61c86ab23baf420764cbcc4814aee42d34a9d (diff)
v4l2: v4l2_camera_proxy: Fix v4l2-compliance support for extended formats
Fix the following v4l2-compliance error: fail: v4l2-compliance.cpp(652): !(caps & V4L2_CAP_EXT_PIX_FORMAT) Simply add V4L2_CAP_EXT_PIX_FORMAT to capabilities in querycap. In addition, populate the necessary fields in struct v4l2_pix_format to support extended pixel formats in try_fmt and g/s_fmt, and clear the reserved field for enum_fmt. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/v4l2/v4l2_camera_proxy.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index 7ac4eeb2..a87a1900 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -162,6 +162,10 @@ void V4L2CameraProxy::setFmtFromConfig(StreamConfiguration &streamConfig)
curV4L2Format_.fmt.pix.width,
curV4L2Format_.fmt.pix.height);
curV4L2Format_.fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
+ curV4L2Format_.fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
+ curV4L2Format_.fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
+ curV4L2Format_.fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT;
+ curV4L2Format_.fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT;
}
unsigned int V4L2CameraProxy::calculateSizeImage(StreamConfiguration &streamConfig)
@@ -188,7 +192,9 @@ void V4L2CameraProxy::querycap(std::shared_ptr<Camera> camera)
sizeof(capabilities_.bus_info));
/* \todo Put this in a header/config somewhere. */
capabilities_.version = KERNEL_VERSION(5, 2, 0);
- capabilities_.device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
+ capabilities_.device_caps = V4L2_CAP_VIDEO_CAPTURE
+ | V4L2_CAP_STREAMING
+ | V4L2_CAP_EXT_PIX_FORMAT;
capabilities_.capabilities = capabilities_.device_caps
| V4L2_CAP_DEVICE_CAPS;
memset(capabilities_.reserved, 0, sizeof(capabilities_.reserved));
@@ -237,11 +243,15 @@ int V4L2CameraProxy::vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc *
arg->index >= streamConfig_.formats().pixelformats().size())
return -EINVAL;
+ /* \todo Set V4L2_FMT_FLAG_COMPRESSED for compressed formats. */
+ arg->flags = 0;
/* \todo Add map from format to description. */
- utils::strlcpy(reinterpret_cast<char *>(arg->description), "Video Format Description",
- sizeof(arg->description));
+ utils::strlcpy(reinterpret_cast<char *>(arg->description),
+ "Video Format Description", sizeof(arg->description));
arg->pixelformat = drmToV4L2(streamConfig_.formats().pixelformats()[arg->index]);
+ memset(arg->reserved, 0, sizeof(arg->reserved));
+
return 0;
}
@@ -281,6 +291,10 @@ void V4L2CameraProxy::tryFormat(struct v4l2_format *arg)
arg->fmt.pix.width,
arg->fmt.pix.height);
arg->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
+ arg->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
+ arg->fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
+ arg->fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT;
+ arg->fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT;
}
int V4L2CameraProxy::vidioc_s_fmt(V4L2CameraFile *file, struct v4l2_format *arg)