Commit 1346a6c6 authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Commit Bot

media/gpu/v4l2: add GetCtrl() method to V4L2Device

Add a simple method that allows to query a single control of a
V4L2Device and use it in the V4L2VDA. This will also come handy for the
V4L2VD.

BUG=b:149663704
TEST=VDAtest --use_vd passes on Kukui.

Change-Id: I9e306fcf4115936dde07e8595631b86ceeb6e917
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2143425
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarJeffrey Kardatzke <jkardatzke@google.com>
Cr-Commit-Position: refs/heads/master@{#759134}
parent e1b04db4
...@@ -2047,6 +2047,23 @@ bool V4L2Device::SetExtCtrls(uint32_t ctrl_class, ...@@ -2047,6 +2047,23 @@ bool V4L2Device::SetExtCtrls(uint32_t ctrl_class,
return Ioctl(VIDIOC_S_EXT_CTRLS, &ext_ctrls) == 0; return Ioctl(VIDIOC_S_EXT_CTRLS, &ext_ctrls) == 0;
} }
base::Optional<struct v4l2_ext_control> V4L2Device::GetCtrl(uint32_t ctrl_id) {
DCHECK_CALLED_ON_VALID_SEQUENCE(client_sequence_checker_);
struct v4l2_ext_control ctrl = {};
struct v4l2_ext_controls ext_ctrls = {};
ctrl.id = ctrl_id;
ext_ctrls.controls = &ctrl;
ext_ctrls.count = 1;
if (Ioctl(VIDIOC_G_EXT_CTRLS, &ext_ctrls) != 0) {
VPLOGF(3) << "Failed to get control";
return base::nullopt;
}
return ctrl;
}
class V4L2Request { class V4L2Request {
public: public:
// Apply the passed controls to the request. // Apply the passed controls to the request.
......
...@@ -726,6 +726,10 @@ class MEDIA_GPU_EXPORT V4L2Device ...@@ -726,6 +726,10 @@ class MEDIA_GPU_EXPORT V4L2Device
// whether the operation succeeded. // whether the operation succeeded.
bool SetExtCtrls(uint32_t ctrl_class, std::vector<V4L2ExtCtrl> ctrls); bool SetExtCtrls(uint32_t ctrl_class, std::vector<V4L2ExtCtrl> ctrls);
// Get the value of a single control, or base::nullopt of the control is not
// exposed by the device.
base::Optional<struct v4l2_ext_control> GetCtrl(uint32_t ctrl_id);
protected: protected:
friend class base::RefCountedThreadSafe<V4L2Device>; friend class base::RefCountedThreadSafe<V4L2Device>;
V4L2Device(); V4L2Device();
......
...@@ -2376,11 +2376,10 @@ bool V4L2VideoDecodeAccelerator::CreateOutputBuffers() { ...@@ -2376,11 +2376,10 @@ bool V4L2VideoDecodeAccelerator::CreateOutputBuffers() {
DCHECK(output_buffer_map_.empty()); DCHECK(output_buffer_map_.empty());
// Number of output buffers we need. // Number of output buffers we need.
struct v4l2_control ctrl; auto ctrl = device_->GetCtrl(V4L2_CID_MIN_BUFFERS_FOR_CAPTURE);
memset(&ctrl, 0, sizeof(ctrl)); if (!ctrl)
ctrl.id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE; return false;
IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_G_CTRL, &ctrl); output_dpb_size_ = ctrl->value;
output_dpb_size_ = ctrl.value;
// Output format setup in Initialize(). // Output format setup in Initialize().
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment