Commit 98fc7d27 authored by David Staessens's avatar David Staessens Committed by Commit Bot

media/gpu/V4L2VEA: Move IsCtrlExposed functionality to the V4L2 device.

This CL moves the IsCtrlExposed function to the V4L2 device, so it can be
reused at other places. Additionally this reduces the number of IOCTLS executed
directly inside the VEA, to provide a better abstraction of the V4L2 device.

TEST=./video_encode_accelerator_unittest on hana

BUG=None

Change-Id: I37981e0b75adcd386a6065f25560dd89dce41791
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1969083Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Commit-Queue: David Staessens <dstaessens@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732674}
parent e50087b9
...@@ -1943,6 +1943,15 @@ V4L2RequestsQueue* V4L2Device::GetRequestsQueue() { ...@@ -1943,6 +1943,15 @@ V4L2RequestsQueue* V4L2Device::GetRequestsQueue() {
return requests_queue_.get(); return requests_queue_.get();
} }
bool V4L2Device::IsCtrlExposed(uint32_t ctrl_id) {
DCHECK_CALLED_ON_VALID_SEQUENCE(client_sequence_checker_);
struct v4l2_queryctrl query_ctrl {};
query_ctrl.id = ctrl_id;
return Ioctl(VIDIOC_QUERYCTRL, &query_ctrl) == 0;
}
class V4L2Request { class V4L2Request {
public: public:
// Apply the passed controls to the request. // Apply the passed controls to the request.
......
...@@ -690,6 +690,9 @@ class MEDIA_GPU_EXPORT V4L2Device ...@@ -690,6 +690,9 @@ class MEDIA_GPU_EXPORT V4L2Device
// the queue creation failed or if requests are not supported. // the queue creation failed or if requests are not supported.
V4L2RequestsQueue* GetRequestsQueue(); V4L2RequestsQueue* GetRequestsQueue();
// Check whether the V4L2 control with specified |ctrl_id| is supported.
bool IsCtrlExposed(uint32_t ctrl_id);
protected: protected:
friend class base::RefCountedThreadSafe<V4L2Device>; friend class base::RefCountedThreadSafe<V4L2Device>;
V4L2Device(); V4L2Device();
......
...@@ -1494,15 +1494,6 @@ bool V4L2VideoEncodeAccelerator::SetFormats(VideoPixelFormat input_format, ...@@ -1494,15 +1494,6 @@ bool V4L2VideoEncodeAccelerator::SetFormats(VideoPixelFormat input_format,
return true; return true;
} }
bool V4L2VideoEncodeAccelerator::IsCtrlExposed(uint32_t ctrl_id) {
DCHECK_CALLED_ON_VALID_SEQUENCE(encoder_sequence_checker_);
struct v4l2_queryctrl query_ctrl{};
query_ctrl.id = ctrl_id;
return device_->Ioctl(VIDIOC_QUERYCTRL, &query_ctrl) == 0;
}
bool V4L2VideoEncodeAccelerator::SetExtCtrls( bool V4L2VideoEncodeAccelerator::SetExtCtrls(
std::vector<struct v4l2_ext_control> ctrls) { std::vector<struct v4l2_ext_control> ctrls) {
DCHECK_CALLED_ON_VALID_SEQUENCE(encoder_sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(encoder_sequence_checker_);
...@@ -1537,7 +1528,7 @@ bool V4L2VideoEncodeAccelerator::InitControls(const Config& config) { ...@@ -1537,7 +1528,7 @@ bool V4L2VideoEncodeAccelerator::InitControls(const Config& config) {
#endif #endif
// Request to inject SPS and PPS before each IDR, if the device supports // Request to inject SPS and PPS before each IDR, if the device supports
// that feature. Otherwise we'll have to cache and inject ourselves. // that feature. Otherwise we'll have to cache and inject ourselves.
if (IsCtrlExposed(V4L2_CID_MPEG_VIDEO_H264_SPS_PPS_BEFORE_IDR)) { if (device_->IsCtrlExposed(V4L2_CID_MPEG_VIDEO_H264_SPS_PPS_BEFORE_IDR)) {
memset(&ctrl, 0, sizeof(ctrl)); memset(&ctrl, 0, sizeof(ctrl));
ctrl.id = V4L2_CID_MPEG_VIDEO_H264_SPS_PPS_BEFORE_IDR; ctrl.id = V4L2_CID_MPEG_VIDEO_H264_SPS_PPS_BEFORE_IDR;
ctrl.value = 1; ctrl.value = 1;
......
...@@ -233,10 +233,6 @@ class MEDIA_GPU_EXPORT V4L2VideoEncodeAccelerator ...@@ -233,10 +233,6 @@ class MEDIA_GPU_EXPORT V4L2VideoEncodeAccelerator
// Set controls in |ctrls| and return true if successful. // Set controls in |ctrls| and return true if successful.
bool SetExtCtrls(std::vector<struct v4l2_ext_control> ctrls); bool SetExtCtrls(std::vector<struct v4l2_ext_control> ctrls);
// Return true if a V4L2 control of |ctrl_id| is supported by the device,
// false otherwise.
bool IsCtrlExposed(uint32_t ctrl_id);
// Allocates |count| video frames with |visible_size| for image processor's // Allocates |count| video frames with |visible_size| for image processor's
// output buffers. Returns false if there's something wrong. // output buffers. Returns false if there's something wrong.
bool AllocateImageProcessorOutputBuffers(size_t count, bool AllocateImageProcessorOutputBuffers(size_t count,
......
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