Commit 5c9d7e79 authored by Jason-JH.Lin's avatar Jason-JH.Lin Committed by Chun-Kuang Hu
Browse files

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: 74608d8f ("drm/mediatek: Add DRM_MODE_ROTATE_0 to rotation property")
Signed-off-by: default avatarJason-JH.Lin <jason-jh.lin@mediatek.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: default avatarCK Hu <ck.hu@mediatek.com>
Link: https://patchwork.kernel.org/project/dri-devel/patch/20241118025126.30808-1-jason-jh.lin@mediatek.com/


Signed-off-by: default avatarChun-Kuang Hu <chunkuang.hu@kernel.org>
parent f8d9b917
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -492,6 +492,7 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
	unsigned int addr = pending->addr;
	unsigned int pitch_lsb = pending->pitch & GENMASK(15, 0);
	unsigned int fmt = pending->format;
	unsigned int rotation = pending->rotation;
	unsigned int offset = (pending->y << 16) | pending->x;
	unsigned int src_size = (pending->height << 16) | pending->width;
	unsigned int blend_mode = state->base.pixel_blend_mode;
@@ -524,12 +525,19 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
			ignore_pixel_alpha = OVL_CONST_BLEND;
	}

	if (pending->rotation & DRM_MODE_REFLECT_Y) {
	/*
	 * Treat rotate 180 as flip x + flip y, and XOR the original rotation value
	 * to flip x + flip y to support both in the same time.
	 */
	if (rotation & DRM_MODE_ROTATE_180)
		rotation ^= DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y;

	if (rotation & DRM_MODE_REFLECT_Y) {
		con |= OVL_CON_VIRT_FLIP;
		addr += (pending->height - 1) * pending->pitch;
	}

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