mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/mediatek: Add support for 180-degree rotation in the display driver
@ 2024-11-18  2:51 Jason-JH.Lin
  2024-11-18  6:54 ` AngeloGioacchino Del Regno
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jason-JH.Lin @ 2024-11-18  2:51 UTC (permalink / raw)
  To: Chun-Kuang Hu
  Cc: AngeloGioacchino Del Regno, Shawn Sung, dri-devel,
	linux-mediatek, linux-kernel, linux-arm-kernel, Jason-JH . Lin,
	Singo Chang, Nancy Lin, Project_Global_Chrome_Upstream_Group,
	Fei Shao

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: 74608d8feefd ("drm/mediatek: Add DRM_MODE_ROTATE_0 to rotation property")
Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
---
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
index e0c0bb01f65a..cc825c4f2e09 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
@@ -472,6 +472,7 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
 	unsigned int hdr_pitch = pending->hdr_pitch;
 	unsigned int fmt = pending->format;
 	unsigned int offset = (pending->y << 16) | pending->x;
+	unsigned int rotation = pending->rotation;
 	unsigned int src_size = (pending->height << 16) | pending->width;
 	unsigned int blend_mode = state->base.pixel_blend_mode;
 	unsigned int ignore_pixel_alpha = 0;
@@ -513,12 +514,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;
 	}
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/mediatek: Add support for 180-degree rotation in the display driver
  2024-11-18  2:51 [PATCH] drm/mediatek: Add support for 180-degree rotation in the display driver Jason-JH.Lin
@ 2024-11-18  6:54 ` AngeloGioacchino Del Regno
  2024-11-18  7:00 ` CK Hu (胡俊光)
  2024-12-25 13:31 ` Chun-Kuang Hu
  2 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-11-18  6:54 UTC (permalink / raw)
  To: Jason-JH.Lin, Chun-Kuang Hu
  Cc: Shawn Sung, dri-devel, linux-mediatek, linux-kernel,
	linux-arm-kernel, Singo Chang, Nancy Lin,
	Project_Global_Chrome_Upstream_Group, Fei Shao

Il 18/11/24 03:51, Jason-JH.Lin ha scritto:
> 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: 74608d8feefd ("drm/mediatek: Add DRM_MODE_ROTATE_0 to rotation property")
> Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/mediatek: Add support for 180-degree rotation in the display driver
  2024-11-18  2:51 [PATCH] drm/mediatek: Add support for 180-degree rotation in the display driver Jason-JH.Lin
  2024-11-18  6:54 ` AngeloGioacchino Del Regno
@ 2024-11-18  7:00 ` CK Hu (胡俊光)
  2024-12-25 13:31 ` Chun-Kuang Hu
  2 siblings, 0 replies; 4+ messages in thread
From: CK Hu (胡俊光) @ 2024-11-18  7:00 UTC (permalink / raw)
  To: Jason-JH Lin (林睿祥), chunkuang.hu
  Cc: linux-mediatek, Singo Chang (張興國),
	linux-kernel, Shawn Sung (宋孝謙),
	Nancy Lin (林欣螢),
	dri-devel, Project_Global_Chrome_Upstream_Group,
	linux-arm-kernel, fshao, AngeloGioacchino Del Regno

Hi, Jason:

On Mon, 2024-11-18 at 10:51 +0800, Jason-JH.Lin wrote:
> 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.

Reviewed-by: CK Hu <ck.hu@mediatek.com>

> 
> Fixes: 74608d8feefd ("drm/mediatek: Add DRM_MODE_ROTATE_0 to rotation property")
> Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> index e0c0bb01f65a..cc825c4f2e09 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> @@ -472,6 +472,7 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
>  	unsigned int hdr_pitch = pending->hdr_pitch;
>  	unsigned int fmt = pending->format;
>  	unsigned int offset = (pending->y << 16) | pending->x;
> +	unsigned int rotation = pending->rotation;
>  	unsigned int src_size = (pending->height << 16) | pending->width;
>  	unsigned int blend_mode = state->base.pixel_blend_mode;
>  	unsigned int ignore_pixel_alpha = 0;
> @@ -513,12 +514,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;
>  	}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/mediatek: Add support for 180-degree rotation in the display driver
  2024-11-18  2:51 [PATCH] drm/mediatek: Add support for 180-degree rotation in the display driver Jason-JH.Lin
  2024-11-18  6:54 ` AngeloGioacchino Del Regno
  2024-11-18  7:00 ` CK Hu (胡俊光)
@ 2024-12-25 13:31 ` Chun-Kuang Hu
  2 siblings, 0 replies; 4+ messages in thread
From: Chun-Kuang Hu @ 2024-12-25 13:31 UTC (permalink / raw)
  To: Jason-JH.Lin
  Cc: Chun-Kuang Hu, AngeloGioacchino Del Regno, Shawn Sung, dri-devel,
	linux-mediatek, linux-kernel, linux-arm-kernel, Singo Chang,
	Nancy Lin, Project_Global_Chrome_Upstream_Group, Fei Shao

Hi, Jason:

Jason-JH.Lin <jason-jh.lin@mediatek.com> 於 2024年11月18日 週一 上午10:51寫道:
>
> 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.

Applied to mediatek-drm-fixes [1], thanks.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-fixes

Regards,
Chun-Kuang.

>
> Fixes: 74608d8feefd ("drm/mediatek: Add DRM_MODE_ROTATE_0 to rotation property")
> Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> index e0c0bb01f65a..cc825c4f2e09 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> @@ -472,6 +472,7 @@ void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
>         unsigned int hdr_pitch = pending->hdr_pitch;
>         unsigned int fmt = pending->format;
>         unsigned int offset = (pending->y << 16) | pending->x;
> +       unsigned int rotation = pending->rotation;
>         unsigned int src_size = (pending->height << 16) | pending->width;
>         unsigned int blend_mode = state->base.pixel_blend_mode;
>         unsigned int ignore_pixel_alpha = 0;
> @@ -513,12 +514,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;
>         }
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-25 13:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-18  2:51 [PATCH] drm/mediatek: Add support for 180-degree rotation in the display driver Jason-JH.Lin
2024-11-18  6:54 ` AngeloGioacchino Del Regno
2024-11-18  7:00 ` CK Hu (胡俊光)
2024-12-25 13:31 ` Chun-Kuang Hu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®