Commit 0f8d0fe9 authored by Francois Buergisser's avatar Francois Buergisser Committed by Commit Bot

media/gpu/v4l2: Check request support in queue.

The queue's support is currently checked in the video decoder but the
queue should be responsible to check whether it does support requests or not.
This patch moves the check for the request support to the V4L2Queue
constructor.

BUG=chromium:1009921
TEST=ran tast with video.DecodeAccelVD.vp8_resolution_switch on veyron_minnie.
TEST=ran tast with video.DecodeAccelVD.h264_resolution_switch on veyron_minnie.
TEST=ran tast with video.DecodeAccelVD.vp8 on veyron_minnie.
TEST=ran tast with video.DecodeAccelVD.h264 on veyron_minnie.
TEST=ran tast with video.DecodeAccelVD.vp8_resolution_switch on kevin.
TEST=ran tast with video.DecodeAccelVD.h264_resolution_switch on kevin.
TEST=ran tast with video.DecodeAccelVD.vp8 on kevin.
TEST=ran tast with video.DecodeAccelVD.h264 on kevin.
TEST=ran video_decode_accelerator_tests w/ vp8 & h264 videos but w/o VD on kevin.
Signed-off-by: default avatarFrancois Buergisser <fbuergisser@chromium.org>
Change-Id: I8c7559f2e84e0ed0690ba439e121e8b07154ed45
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1950048Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#730059}
parent d0db21fc
......@@ -797,6 +797,24 @@ V4L2Queue::V4L2Queue(scoped_refptr<V4L2Device> dev,
destroy_cb_(std::move(destroy_cb)),
weak_this_factory_(this) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Check if this queue support requests.
struct v4l2_requestbuffers reqbufs;
memset(&reqbufs, 0, sizeof(reqbufs));
reqbufs.count = 0;
reqbufs.type = type;
reqbufs.memory = V4L2_MEMORY_MMAP;
if (device_->Ioctl(VIDIOC_REQBUFS, &reqbufs) != 0) {
VPLOGF(1) << "Request support checks's VIDIOC_REQBUFS ioctl failed.";
return;
}
if (reqbufs.capabilities & V4L2_BUF_CAP_SUPPORTS_REQUESTS) {
supports_requests_ = true;
VLOGF(1) << "Using request API.";
} else {
VLOGF(1) << "Using config store API.";
}
}
V4L2Queue::~V4L2Queue() {
......@@ -1111,6 +1129,12 @@ size_t V4L2Queue::QueuedBuffersCount() const {
#undef VPQLOGF
#undef VQLOGF
bool V4L2Queue::SupportsRequests() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return supports_requests_;
}
// This class is used to expose V4L2Queue's constructor to this module. This is
// to ensure that nobody else can create instances of it.
class V4L2QueueFactory {
......
......@@ -338,6 +338,9 @@ class MEDIA_GPU_EXPORT V4L2Queue
// Returns the number of buffers currently queued on this queue.
size_t QueuedBuffersCount() const;
// Returns true if requests are supported by this queue.
bool SupportsRequests();
private:
~V4L2Queue();
......@@ -347,6 +350,8 @@ class MEDIA_GPU_EXPORT V4L2Queue
const enum v4l2_buf_type type_;
enum v4l2_memory memory_ = V4L2_MEMORY_MMAP;
bool is_streaming_ = false;
// Set to true if the queue supports requests.
bool supports_requests_ = false;
size_t planes_count_ = 0;
// Current format as set by SetFormat.
base::Optional<struct v4l2_format> current_format_;
......
......@@ -123,11 +123,6 @@ V4L2StatelessVideoDecoderBackend::~V4L2StatelessVideoDecoderBackend() {
bool V4L2StatelessVideoDecoderBackend::Initialize() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!CheckRequestAPISupport()) {
VPLOGF(1) << "Failed to check request api support.";
return false;
}
if (!IsSupportedProfile(profile_)) {
VLOGF(1) << "Unsupported profile " << GetProfileName(profile_);
return false;
......@@ -136,7 +131,7 @@ bool V4L2StatelessVideoDecoderBackend::Initialize() {
if (!CreateAvd())
return false;
if (supports_requests_) {
if (input_queue_->SupportsRequests()) {
requests_queue_ = device_->GetRequestsQueue();
if (requests_queue_ == nullptr)
return false;
......@@ -267,7 +262,7 @@ V4L2StatelessVideoDecoderBackend::CreateSurface() {
}
scoped_refptr<V4L2DecodeSurface> dec_surface;
if (supports_requests_) {
if (input_queue_->SupportsRequests()) {
V4L2RequestRef request_ref = requests_queue_->GetFreeRequest();
if (!request_ref.IsValid()) {
DVLOGF(3) << "Could not get free request.";
......@@ -610,29 +605,6 @@ void V4L2StatelessVideoDecoderBackend::ClearPendingRequests(
}
}
bool V4L2StatelessVideoDecoderBackend::CheckRequestAPISupport() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DVLOGF(3);
struct v4l2_requestbuffers reqbufs;
memset(&reqbufs, 0, sizeof(reqbufs));
reqbufs.count = 0;
reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
reqbufs.memory = V4L2_MEMORY_MMAP;
if (device_->Ioctl(VIDIOC_REQBUFS, &reqbufs) != 0) {
VPLOGF(1) << "VIDIOC_REQBUFS ioctl failed.";
return false;
}
if (reqbufs.capabilities & V4L2_BUF_CAP_SUPPORTS_REQUESTS) {
supports_requests_ = true;
VLOGF(1) << "Using request API.";
} else {
VLOGF(1) << "Using config store.";
}
return true;
}
bool V4L2StatelessVideoDecoderBackend::IsSupportedProfile(
VideoCodecProfile profile) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......@@ -661,7 +633,7 @@ bool V4L2StatelessVideoDecoderBackend::CreateAvd() {
pic_size_ = gfx::Size();
if (profile_ >= H264PROFILE_MIN && profile_ <= H264PROFILE_MAX) {
if (supports_requests_) {
if (input_queue_->SupportsRequests()) {
avd_.reset(new H264Decoder(
std::make_unique<V4L2H264Accelerator>(this, device_.get()),
profile_));
......@@ -671,7 +643,7 @@ bool V4L2StatelessVideoDecoderBackend::CreateAvd() {
profile_));
}
} else if (profile_ >= VP8PROFILE_MIN && profile_ <= VP8PROFILE_MAX) {
if (supports_requests_) {
if (input_queue_->SupportsRequests()) {
avd_.reset(new VP8Decoder(
std::make_unique<V4L2VP8Accelerator>(this, device_.get())));
} else {
......
......@@ -120,9 +120,6 @@ class V4L2StatelessVideoDecoderBackend : public V4L2VideoDecoderBackend,
// Setup the format of V4L2 output buffer, and allocate new buffer set.
void ChangeResolution();
// Check whether request api is supported or not.
bool CheckRequestAPISupport();
// Returns whether |profile| is supported by a v4l2 stateless decoder driver.
bool IsSupportedProfile(VideoCodecProfile profile);
......@@ -167,8 +164,6 @@ class V4L2StatelessVideoDecoderBackend : public V4L2VideoDecoderBackend,
// VideoCodecProfiles supported by a v4l2 stateless decoder driver.
std::vector<VideoCodecProfile> supported_profiles_;
// Set to true during Initialize() if the codec driver supports request API.
bool supports_requests_ = false;
// Reference to request queue to get free requests.
V4L2RequestsQueue* requests_queue_;
......
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