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>
This commit is contained in:
parent
b5d61c86ab
commit
012cfab9b1
1 changed files with 17 additions and 3 deletions
|
@ -162,6 +162,10 @@ void V4L2CameraProxy::setFmtFromConfig(StreamConfiguration &streamConfig)
|
||||||
curV4L2Format_.fmt.pix.width,
|
curV4L2Format_.fmt.pix.width,
|
||||||
curV4L2Format_.fmt.pix.height);
|
curV4L2Format_.fmt.pix.height);
|
||||||
curV4L2Format_.fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
|
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)
|
unsigned int V4L2CameraProxy::calculateSizeImage(StreamConfiguration &streamConfig)
|
||||||
|
@ -188,7 +192,9 @@ void V4L2CameraProxy::querycap(std::shared_ptr<Camera> camera)
|
||||||
sizeof(capabilities_.bus_info));
|
sizeof(capabilities_.bus_info));
|
||||||
/* \todo Put this in a header/config somewhere. */
|
/* \todo Put this in a header/config somewhere. */
|
||||||
capabilities_.version = KERNEL_VERSION(5, 2, 0);
|
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
|
capabilities_.capabilities = capabilities_.device_caps
|
||||||
| V4L2_CAP_DEVICE_CAPS;
|
| V4L2_CAP_DEVICE_CAPS;
|
||||||
memset(capabilities_.reserved, 0, sizeof(capabilities_.reserved));
|
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())
|
arg->index >= streamConfig_.formats().pixelformats().size())
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
/* \todo Set V4L2_FMT_FLAG_COMPRESSED for compressed formats. */
|
||||||
|
arg->flags = 0;
|
||||||
/* \todo Add map from format to description. */
|
/* \todo Add map from format to description. */
|
||||||
utils::strlcpy(reinterpret_cast<char *>(arg->description), "Video Format Description",
|
utils::strlcpy(reinterpret_cast<char *>(arg->description),
|
||||||
sizeof(arg->description));
|
"Video Format Description", sizeof(arg->description));
|
||||||
arg->pixelformat = drmToV4L2(streamConfig_.formats().pixelformats()[arg->index]);
|
arg->pixelformat = drmToV4L2(streamConfig_.formats().pixelformats()[arg->index]);
|
||||||
|
|
||||||
|
memset(arg->reserved, 0, sizeof(arg->reserved));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,6 +291,10 @@ void V4L2CameraProxy::tryFormat(struct v4l2_format *arg)
|
||||||
arg->fmt.pix.width,
|
arg->fmt.pix.width,
|
||||||
arg->fmt.pix.height);
|
arg->fmt.pix.height);
|
||||||
arg->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
|
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)
|
int V4L2CameraProxy::vidioc_s_fmt(V4L2CameraFile *file, struct v4l2_format *arg)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue