Skip to content

Commit 5c9d7e7

Browse files
Jason-JH.LinChun-Kuang Hu
authored andcommitted
drm/mediatek: Add support for 180-degree rotation in the display driver
mediatek-drm driver reported the capability of 180-degree rotation by adding `DRM_MODE_ROTATE_180` to the plane property, as flip-x combined with flip-y equals a 180-degree rotation. However, we did not handle the rotation property in the driver and lead to rotation issues. Fixes: 74608d8 ("drm/mediatek: Add DRM_MODE_ROTATE_0 to rotation property") Signed-off-by: Jason-JH.Lin <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Reviewed-by: CK Hu <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent f8d9b91 commit 5c9d7e7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/gpu/drm/mediatek/mtk_disp_ovl.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
492492
unsigned int addr = pending->addr;
493493
unsigned int pitch_lsb = pending->pitch & GENMASK(15, 0);
494494
unsigned int fmt = pending->format;
495+
unsigned int rotation = pending->rotation;
495496
unsigned int offset = (pending->y << 16) | pending->x;
496497
unsigned int src_size = (pending->height << 16) | pending->width;
497498
unsigned int blend_mode = state->base.pixel_blend_mode;
@@ -524,12 +525,19 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
524525
ignore_pixel_alpha = OVL_CONST_BLEND;
525526
}
526527

527-
if (pending->rotation & DRM_MODE_REFLECT_Y) {
528+
/*
529+
* Treat rotate 180 as flip x + flip y, and XOR the original rotation value
530+
* to flip x + flip y to support both in the same time.
531+
*/
532+
if (rotation & DRM_MODE_ROTATE_180)
533+
rotation ^= DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y;
534+
535+
if (rotation & DRM_MODE_REFLECT_Y) {
528536
con |= OVL_CON_VIRT_FLIP;
529537
addr += (pending->height - 1) * pending->pitch;
530538
}
531539

532-
if (pending->rotation & DRM_MODE_REFLECT_X) {
540+
if (rotation & DRM_MODE_REFLECT_X) {
533541
con |= OVL_CON_HORZ_FLIP;
534542
addr += pending->pitch - 1;
535543
}

0 commit comments

Comments
 (0)