Commit 2de705a0 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

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

This reverts commit ac6f2444.

Reason for revert: This CL breaks HW decoder on hana.

Original change's description:
> 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.DecodeAccelVDVP8ResolutionSwitch on veyron_minnie-kernelnext.
> TEST=ran tast with video.DecodeAccelVDH264ResolutionSwitch on veyron_minnie-kernelnext.
> TEST=ran tast with video.DecodeAccelVDVP8 on veyron_minnie-kernelnext.
> TEST=ran tast with video.DecodeAccelVDH264 on veyron_minnie-kernelnext.
> TEST=ran tast with video.DecodeAccelVDVP8ResolutionSwitch on veyron_minnie.
> TEST=ran tast with video.DecodeAccelVDH264ResolutionSwitch on veyron_minnie.
> TEST=ran tast with video.DecodeAccelVDVP8 on veyron_minnie.
> TEST=ran tast with video.DecodeAccelVDH264 on veyron_minnie.
> 
> Signed-off-by: Francois Buergisser <fbuergisser@chromium.org>
> Change-Id: Icdceab06d3b263d0ce68993b3ee753bd650706dd
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880208
> Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
> Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#709376}

TBR=acourbot@chromium.org,fbuergisser@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: chromium:1009921
Change-Id: Ib3cf55aa900296f882372d4cf092e947115859e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1890190Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710738}
parent 18c6a9a6
...@@ -771,22 +771,6 @@ V4L2Queue::V4L2Queue(scoped_refptr<V4L2Device> dev, ...@@ -771,22 +771,6 @@ V4L2Queue::V4L2Queue(scoped_refptr<V4L2Device> dev,
destroy_cb_(std::move(destroy_cb)), destroy_cb_(std::move(destroy_cb)),
weak_this_factory_(this) { weak_this_factory_(this) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 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.";
}
} }
V4L2Queue::~V4L2Queue() { V4L2Queue::~V4L2Queue() {
...@@ -1097,10 +1081,6 @@ size_t V4L2Queue::QueuedBuffersCount() const { ...@@ -1097,10 +1081,6 @@ size_t V4L2Queue::QueuedBuffersCount() const {
return queued_buffers_.size(); return queued_buffers_.size();
} }
bool V4L2Queue::SupportsRequests() {
return supports_requests_;
}
// This class is used to expose V4L2Queue's constructor to this module. This is // This class is used to expose V4L2Queue's constructor to this module. This is
// to ensure that nobody else can create instances of it. // to ensure that nobody else can create instances of it.
class V4L2QueueFactory { class V4L2QueueFactory {
......
...@@ -338,9 +338,6 @@ class MEDIA_GPU_EXPORT V4L2Queue ...@@ -338,9 +338,6 @@ class MEDIA_GPU_EXPORT V4L2Queue
// Returns the number of buffers currently queued on this queue. // Returns the number of buffers currently queued on this queue.
size_t QueuedBuffersCount() const; size_t QueuedBuffersCount() const;
// Returns true if requests are supported by this queue.
bool SupportsRequests();
private: private:
~V4L2Queue(); ~V4L2Queue();
...@@ -350,8 +347,6 @@ class MEDIA_GPU_EXPORT V4L2Queue ...@@ -350,8 +347,6 @@ class MEDIA_GPU_EXPORT V4L2Queue
const enum v4l2_buf_type type_; const enum v4l2_buf_type type_;
enum v4l2_memory memory_ = V4L2_MEMORY_MMAP; enum v4l2_memory memory_ = V4L2_MEMORY_MMAP;
bool is_streaming_ = false; bool is_streaming_ = false;
// Set to true if the queue supports requests.
bool supports_requests_ = false;
size_t planes_count_ = 0; size_t planes_count_ = 0;
// Current format as set by SetFormat. // Current format as set by SetFormat.
base::Optional<struct v4l2_format> current_format_; base::Optional<struct v4l2_format> current_format_;
......
...@@ -124,7 +124,7 @@ V4L2StatelessVideoDecoderBackend::~V4L2StatelessVideoDecoderBackend() { ...@@ -124,7 +124,7 @@ V4L2StatelessVideoDecoderBackend::~V4L2StatelessVideoDecoderBackend() {
avd_ = nullptr; avd_ = nullptr;
} }
if (input_queue_->SupportsRequests()) { if (supports_requests_) {
requests_ = {}; requests_ = {};
media_fd_.reset(); media_fd_.reset();
} }
...@@ -133,23 +133,15 @@ V4L2StatelessVideoDecoderBackend::~V4L2StatelessVideoDecoderBackend() { ...@@ -133,23 +133,15 @@ V4L2StatelessVideoDecoderBackend::~V4L2StatelessVideoDecoderBackend() {
bool V4L2StatelessVideoDecoderBackend::Initialize() { bool V4L2StatelessVideoDecoderBackend::Initialize() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (input_queue_->SupportsRequests()) { if (!CheckRequestAPISupport()) {
DCHECK(!media_fd_.is_valid()); VPLOGF(1) << "Failed to check request api support.";
// Let's try to open the media device return false;
// TODO(crbug.com/985230): remove this hardcoding, replace with V4L2Device
// integration.
int media_fd = open("/dev/media-dec0", O_RDWR, 0);
if (media_fd < 0) {
VPLOGF(1) << "Failed to open media device.";
return false;
}
media_fd_ = base::ScopedFD(media_fd);
} }
// Create codec-specific AcceleratedVideoDecoder. // Create codec-specific AcceleratedVideoDecoder.
// TODO(akahuang): Check the profile is supported. // TODO(akahuang): Check the profile is supported.
if (profile_ >= H264PROFILE_MIN && profile_ <= H264PROFILE_MAX) { if (profile_ >= H264PROFILE_MIN && profile_ <= H264PROFILE_MAX) {
if (input_queue_->SupportsRequests()) { if (supports_requests_) {
avd_.reset(new H264Decoder( avd_.reset(new H264Decoder(
std::make_unique<V4L2H264Accelerator>(this, device_.get()))); std::make_unique<V4L2H264Accelerator>(this, device_.get())));
} else { } else {
...@@ -157,7 +149,7 @@ bool V4L2StatelessVideoDecoderBackend::Initialize() { ...@@ -157,7 +149,7 @@ bool V4L2StatelessVideoDecoderBackend::Initialize() {
std::make_unique<V4L2LegacyH264Accelerator>(this, device_.get()))); std::make_unique<V4L2LegacyH264Accelerator>(this, device_.get())));
} }
} else if (profile_ >= VP8PROFILE_MIN && profile_ <= VP8PROFILE_MAX) { } else if (profile_ >= VP8PROFILE_MIN && profile_ <= VP8PROFILE_MAX) {
if (input_queue_->SupportsRequests()) { if (supports_requests_) {
avd_.reset(new VP8Decoder( avd_.reset(new VP8Decoder(
std::make_unique<V4L2VP8Accelerator>(this, device_.get()))); std::make_unique<V4L2VP8Accelerator>(this, device_.get())));
} else { } else {
...@@ -172,7 +164,7 @@ bool V4L2StatelessVideoDecoderBackend::Initialize() { ...@@ -172,7 +164,7 @@ bool V4L2StatelessVideoDecoderBackend::Initialize() {
return false; return false;
} }
if (input_queue_->SupportsRequests() && !AllocateRequests()) { if (supports_requests_ && !AllocateRequests()) {
return false; return false;
} }
...@@ -260,7 +252,7 @@ V4L2StatelessVideoDecoderBackend::CreateSurface() { ...@@ -260,7 +252,7 @@ V4L2StatelessVideoDecoderBackend::CreateSurface() {
} }
scoped_refptr<V4L2DecodeSurface> dec_surface; scoped_refptr<V4L2DecodeSurface> dec_surface;
if (input_queue_->SupportsRequests()) { if (supports_requests_) {
DCHECK(!requests_.empty()); DCHECK(!requests_.empty());
base::ScopedFD request = std::move(requests_.front()); base::ScopedFD request = std::move(requests_.front());
requests_.pop(); requests_.pop();
...@@ -561,6 +553,39 @@ void V4L2StatelessVideoDecoderBackend::ClearPendingRequests( ...@@ -561,6 +553,39 @@ 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.";
DCHECK(!media_fd_.is_valid());
// Let's try to open the media device
// TODO(crbug.com/985230): remove this hardcoding, replace with V4L2Device
// integration.
int media_fd = open("/dev/media-dec0", O_RDWR, 0);
if (media_fd < 0) {
VPLOGF(1) << "Failed to open media device.";
return false;
}
media_fd_ = base::ScopedFD(media_fd);
} else {
VLOGF(1) << "Using config store.";
}
return true;
}
bool V4L2StatelessVideoDecoderBackend::AllocateRequests() { bool V4L2StatelessVideoDecoderBackend::AllocateRequests() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DVLOGF(3); DVLOGF(3);
......
...@@ -117,6 +117,8 @@ class V4L2StatelessVideoDecoderBackend : public V4L2VideoDecoderBackend, ...@@ -117,6 +117,8 @@ class V4L2StatelessVideoDecoderBackend : public V4L2VideoDecoderBackend,
// Setup the format of V4L2 output buffer, and allocate new buffer set. // Setup the format of V4L2 output buffer, and allocate new buffer set.
bool ChangeResolution(); bool ChangeResolution();
// Check whether request api is supported or not.
bool CheckRequestAPISupport();
// Allocate necessary request buffers is request api is supported. // Allocate necessary request buffers is request api is supported.
bool AllocateRequests(); bool AllocateRequests();
...@@ -156,6 +158,8 @@ class V4L2StatelessVideoDecoderBackend : public V4L2VideoDecoderBackend, ...@@ -156,6 +158,8 @@ class V4L2StatelessVideoDecoderBackend : public V4L2VideoDecoderBackend,
// Callbacks of EOS buffer passed from Decode(). // Callbacks of EOS buffer passed from Decode().
VideoDecoder::DecodeCB flush_cb_; VideoDecoder::DecodeCB flush_cb_;
// Set to true during Initialize() if the codec driver supports request API.
bool supports_requests_ = false;
// FIFO queue of requests, only used if supports_requests_ is true. // FIFO queue of requests, only used if supports_requests_ is true.
base::queue<base::ScopedFD> requests_; base::queue<base::ScopedFD> requests_;
// Stores the media file descriptor, only used if supports_requests_ is true. // Stores the media file descriptor, only used if supports_requests_ is true.
......
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