Commit b7b206e8 authored by Fritz Koenig's avatar Fritz Koenig Committed by Commit Bot

media/gpu/v4l2: Pass UBWC modifier to V4L2

V4L2 does not support modifiers with the current API.
This is a way to allow UBWC to be turned on for
Qualcomm SOCs by using a special format.

This should be reverted once V4L2 has an api that
supports modifiers.

BUG=b:149525848
BUG=b:166275274
TEST=none

Change-Id: I89e8d543fc8f021fd184bbfe26fdab689747c330
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2343804
Commit-Queue: Fritz Koenig <frkoenig@chromium.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803912}
parent 28bcc89a
...@@ -1274,6 +1274,19 @@ bool V4L2Queue::SupportsRequests() { ...@@ -1274,6 +1274,19 @@ bool V4L2Queue::SupportsRequests() {
return supports_requests_; return supports_requests_;
} }
base::Optional<struct v4l2_format> V4L2Queue::SetModifierFormat(
uint64_t modifier,
const gfx::Size& size) {
if (DRM_FORMAT_MOD_QCOM_COMPRESSED == modifier) {
const uint32_t v4l2_pix_fmt_nv12_ubwc = v4l2_fourcc('Q', '1', '2', '8');
auto format = SetFormat(v4l2_pix_fmt_nv12_ubwc, size, 0);
if (!format)
VPLOGF(1) << "Failed to set magic modifier format.";
return format;
}
return base::nullopt;
}
// 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 {
......
...@@ -397,6 +397,11 @@ class MEDIA_GPU_EXPORT V4L2Queue ...@@ -397,6 +397,11 @@ class MEDIA_GPU_EXPORT V4L2Queue
// Returns true if requests are supported by this queue. // Returns true if requests are supported by this queue.
bool SupportsRequests(); bool SupportsRequests();
// TODO (b/166275274) : Remove this once V4L2 properly supports modifiers.
// Out of band method to configure V4L2 for modifier use.
base::Optional<struct v4l2_format> SetModifierFormat(uint64_t modifier,
const gfx::Size& size);
private: private:
~V4L2Queue(); ~V4L2Queue();
......
...@@ -344,6 +344,24 @@ bool V4L2VideoDecoder::SetupOutputFormat(const gfx::Size& size, ...@@ -344,6 +344,24 @@ bool V4L2VideoDecoder::SetupOutputFormat(const gfx::Size& size,
<< " != " << layout->size().ToString(); << " != " << layout->size().ToString();
return false; return false;
} }
if (layout->modifier() &&
layout->modifier() != gfx::NativePixmapHandle::kNoModifier) {
base::Optional<struct v4l2_format> modifier_format =
output_queue_->SetModifierFormat(layout->modifier(), size);
if (!modifier_format)
return false;
gfx::Size size_for_modifier_format(format->fmt.pix_mp.width,
format->fmt.pix_mp.height);
if (size_for_modifier_format != adjusted_size) {
VLOGF(1)
<< "Buffers were allocated for " << adjusted_size.ToString()
<< " but modifier format is expecting buffers to be allocated for "
<< size_for_modifier_format.ToString();
return false;
}
}
} }
return true; return 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