drm_hwcomposer: Fix DRM and HWC rotation direction misalignment
[DRM API][1] uses a counter-clockwise direction, while [HWC API][2] uses a clockwise. [1]: https://elixir.bootlin.com/linux/v6.5.7/source/include/uapi/drm/drm_mode.h#L172 [2]: https://cs.android.com/android/platform/superproject/main/+/main:hardware/libhardware/include_all/hardware/hwcomposer_defs.h;l=96;drc=e9d7337d9d1edc0d8e3ece246ecde747e345e876 Closes: https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/-/issues/78 Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
This commit is contained in:
parent
492739c5b3
commit
b9bd2712fb
2 changed files with 11 additions and 4 deletions
|
|
@ -33,6 +33,7 @@ namespace android {
|
|||
|
||||
class DrmFbIdHandle;
|
||||
|
||||
/* Rotation is defined in the clockwise direction */
|
||||
enum LayerTransform : uint32_t {
|
||||
kIdentity = 0,
|
||||
kFlipH = 1 << 0,
|
||||
|
|
|
|||
|
|
@ -88,14 +88,17 @@ int DrmPlane::Init() {
|
|||
|
||||
GetPlaneProperty("zpos", zpos_property_, Presence::kOptional);
|
||||
|
||||
/* DRM/KMS uses counter-clockwise rotations, while HWC API uses
|
||||
* clockwise. That's why 90 and 270 are swapped here.
|
||||
*/
|
||||
if (GetPlaneProperty("rotation", rotation_property_, Presence::kOptional)) {
|
||||
rotation_property_.AddEnumToMap("rotate-0", LayerTransform::kIdentity,
|
||||
transform_enum_map_);
|
||||
rotation_property_.AddEnumToMap("rotate-90", LayerTransform::kRotate90,
|
||||
rotation_property_.AddEnumToMap("rotate-90", LayerTransform::kRotate270,
|
||||
transform_enum_map_);
|
||||
rotation_property_.AddEnumToMap("rotate-180", LayerTransform::kRotate180,
|
||||
transform_enum_map_);
|
||||
rotation_property_.AddEnumToMap("rotate-270", LayerTransform::kRotate270,
|
||||
rotation_property_.AddEnumToMap("rotate-270", LayerTransform::kRotate90,
|
||||
transform_enum_map_);
|
||||
rotation_property_.AddEnumToMap("reflect-x", LayerTransform::kFlipH,
|
||||
transform_enum_map_);
|
||||
|
|
@ -220,16 +223,19 @@ bool DrmPlane::HasNonRgbFormat() const {
|
|||
|
||||
static uint64_t ToDrmRotation(LayerTransform transform) {
|
||||
uint64_t rotation = 0;
|
||||
/* DRM/KMS uses counter-clockwise rotations, while HWC API uses
|
||||
* clockwise. That's why 90 and 270 are swapped here.
|
||||
*/
|
||||
if ((transform & LayerTransform::kFlipH) != 0)
|
||||
rotation |= DRM_MODE_REFLECT_X;
|
||||
if ((transform & LayerTransform::kFlipV) != 0)
|
||||
rotation |= DRM_MODE_REFLECT_Y;
|
||||
if ((transform & LayerTransform::kRotate90) != 0)
|
||||
rotation |= DRM_MODE_ROTATE_90;
|
||||
rotation |= DRM_MODE_ROTATE_270;
|
||||
else if ((transform & LayerTransform::kRotate180) != 0)
|
||||
rotation |= DRM_MODE_ROTATE_180;
|
||||
else if ((transform & LayerTransform::kRotate270) != 0)
|
||||
rotation |= DRM_MODE_ROTATE_270;
|
||||
rotation |= DRM_MODE_ROTATE_90;
|
||||
else
|
||||
rotation |= DRM_MODE_ROTATE_0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue