diff options
author | Benjamin Li <benl@squareup.com> | 2021-05-09 08:52:18 -0700 |
---|---|---|
committer | Benjamin Li <benl@squareup.com> | 2021-05-09 08:52:18 -0700 |
commit | b00b28d1e722b161ad90c703ef3ae4807ba6efc6 (patch) | |
tree | 3f21e7ce64d8b803a2c06256ff1dce82a1d3bdee | |
parent | 9127dc88344d7c62037b4b4305c9c73da6826981 (diff) | |
download | drm_hwcomposer-b00b28d1e722b161ad90c703ef3ae4807ba6efc6.tar.gz |
drm_hwcomposer: reject rotations reported as unsupported by hardware
Currently we only check for the presence of any rotation support -- but
hardware may choose to, say, only support 180 degree rotation. Respect
the specific rotation capabilities reported through DRM properties.
Signed-off-by: Benjamin Li <benl@squareup.com>
-rw-r--r-- | drm/DrmPlane.cpp | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/drm/DrmPlane.cpp b/drm/DrmPlane.cpp index b841189..9dd44ff 100644 --- a/drm/DrmPlane.cpp +++ b/drm/DrmPlane.cpp @@ -165,10 +165,35 @@ bool DrmPlane::GetCrtcSupported(const DrmCrtc &crtc) const { } bool DrmPlane::IsValidForLayer(DrmHwcLayer *layer) { - if ((rotation_property_.id() == 0) && - layer->transform != DrmHwcTransform::kIdentity) { - ALOGV("Rotation is not supported on plane %d", id_); - return false; + if (rotation_property_.id() == 0) { + if (layer->transform != DrmHwcTransform::kIdentity) { + ALOGV("Rotation is not supported on plane %d", id_); + return false; + } + } else { + // For rotation checks, we assume the hardware reports its capabilities + // consistently (e.g. a 270 degree rotation is a 90 degree rotation + H + // flip + V flip; it wouldn't make sense to support all of the latter but + // not the former). + int ret = 0; + const std::pair<enum DrmHwcTransform, std::string> transforms[] = + {{kFlipH, "reflect-x"}, + {kFlipV, "reflect-y"}, + {kRotate90, "rotate-90"}, + {kRotate180, "rotate-180"}, + {kRotate270, "rotate-270"}}; + + for (const auto &[transform, name] : transforms) { + if (layer->transform & transform) { + std::tie(std::ignore, + ret) = rotation_property_.GetEnumValueWithName(name); + if (ret) { + ALOGV("Rotation '%s' is not supported on plane %d", name.c_str(), + id_); + return false; + } + } + } } if (alpha_property_.id() == 0 && layer->alpha != 0xffff) { |