Commit c5bcd683 authored by David Stevens's avatar David Stevens Committed by Commit Bot

ozone/drm: force bt601 colorspace

Until system wide colorspace support is improved, force planes to BT601
for consistency across platforms and kernel versions.

Bug: 1102317
Change-Id: Ice5a1221b5a142a5c163288d4261eca2fb1c611c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2336347Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796687}
parent 8821257d
......@@ -536,4 +536,15 @@ int GetFourCCFormatForOpaqueFramebuffer(gfx::BufferFormat format) {
}
}
uint64_t GetEnumValueForName(int fd, int property_id, const char* str) {
ScopedDrmPropertyPtr res(drmModeGetProperty(fd, property_id));
for (int i = 0; i < res->count_enums; ++i) {
if (strcmp(res->enums[i].name, str) == 0) {
return res->enums[i].value;
}
}
NOTREACHED();
return 0;
}
} // namespace ui
......@@ -98,6 +98,8 @@ float ModeRefreshRate(const drmModeModeInfo& mode);
bool ModeIsInterlaced(const drmModeModeInfo& mode);
uint64_t GetEnumValueForName(int fd, int property_id, const char* str);
} // namespace ui
#endif // UI_OZONE_PLATFORM_DRM_COMMON_DRM_UTIL_H_
......@@ -8,6 +8,7 @@
#include <drm_mode.h>
#include "base/logging.h"
#include "ui/ozone/platform/drm/common/drm_util.h"
#include "ui/ozone/platform/drm/gpu/drm_device.h"
#include "ui/ozone/platform/drm/gpu/drm_gpu_util.h"
......@@ -92,6 +93,14 @@ bool HardwareDisplayPlane::Initialize(DrmDevice* drm) {
if (properties_.type.id)
type_ = GetPlaneType(properties_.type.value);
if (properties_.plane_color_encoding.id) {
color_encoding_bt601_ =
GetEnumValueForName(drm->get_fd(), properties_.plane_color_encoding.id,
"ITU-R BT.601 YCbCr");
color_range_limited_ = GetEnumValueForName(
drm->get_fd(), properties_.plane_color_range.id, "YCbCr limited range");
}
VLOG(3) << "Initialized plane=" << id_ << " crtc_mask=" << std::hex << "0x"
<< crtc_mask_ << std::dec
<< " supported_formats_count=" << supported_formats_.size()
......@@ -168,6 +177,10 @@ void HardwareDisplayPlane::InitializeProperties(DrmDevice* drm) {
GetDrmPropertyForName(drm, props.get(), "IN_FENCE_FD",
&properties_.in_fence_fd);
GetDrmPropertyForName(drm, props.get(), "PLANE_CTM", &properties_.plane_ctm);
GetDrmPropertyForName(drm, props.get(), "COLOR_ENCODING",
&properties_.plane_color_encoding);
GetDrmPropertyForName(drm, props.get(), "COLOR_RANGE",
&properties_.plane_color_range);
}
} // namespace ui
......@@ -68,6 +68,8 @@ class HardwareDisplayPlane {
DrmDevice::Property in_formats;
DrmDevice::Property in_fence_fd;
DrmDevice::Property plane_ctm;
DrmDevice::Property plane_color_encoding;
DrmDevice::Property plane_color_range;
};
const uint32_t id_;
......@@ -82,6 +84,9 @@ class HardwareDisplayPlane {
std::vector<uint32_t> supported_formats_;
std::vector<drm_format_modifier> supported_format_modifiers_;
uint64_t color_encoding_bt601_;
uint64_t color_range_limited_;
private:
void InitializeProperties(DrmDevice* drm);
......
......@@ -64,6 +64,12 @@ bool HardwareDisplayPlaneAtomic::Initialize(DrmDevice* drm) {
properties_.src_w.id && properties_.src_h.id;
LOG_IF(ERROR, !ret) << "Failed to find all required properties for plane="
<< id_;
ret &= (properties_.plane_color_encoding.id == 0) ==
(properties_.plane_color_range.id == 0);
LOG_IF(ERROR, !ret) << "Inconsistent color management properties for plane="
<< id_;
return ret;
}
......@@ -119,6 +125,16 @@ bool HardwareDisplayPlaneAtomic::SetPlaneData(
AddPropertyIfValid(property_set, id_, properties_.in_fence_fd);
}
if (properties_.plane_color_encoding.id) {
properties_.plane_color_encoding.value = color_encoding_bt601_;
properties_.plane_color_range.value = color_range_limited_;
plane_set_succeeded =
plane_set_succeeded &&
AddPropertyIfValid(property_set, id_,
properties_.plane_color_encoding) &&
AddPropertyIfValid(property_set, id_, properties_.plane_color_range);
}
if (!plane_set_succeeded) {
LOG(ERROR) << "Failed to set plane data";
return false;
......
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