Skip to contentSkip to conversation

Fix errors when reporting rotation capability

PATCH In review Hsiao Chien Sung 2 participants 6 messages Nov 24, 2023 – Dec 19, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v4 cover Fix errors when reporting rotation capability

This commit is based on [email protected].

This bug was found when running IGT tests.
For CRTCs that doesn't support rotation should still return DRM_MODE_ROTATE_0, otherwise the test will fail to restart. Returns the hardware capabilities accordingly.

Changes in v4:
- Remove rotation property from the driver data since OVL rotation property for all chips are the same

Changes in v3:
- Return 0 (not support) if rotation capabilities is not defined in the driver data.

Changes in v2:
- Restore DRM_MODE_ROTATE_180 (reflect x + reflect y = rotate 180)
- Define supported rotations in the driver data

Hsiao Chien Sung (1):
drm/mediatek: Fix errors when reporting rotation capability

 drivers/gpu/drm/mediatek/mtk_disp_drv.h        |  1 +
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c        | 18 ++++++------------
 .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c    |  9 +++++++++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c    |  1 +
 drivers/gpu/drm/mediatek/mtk_drm_plane.c       |  2 +-
 5 files changed, 18 insertions(+), 13 deletions(-)

--
2.39.2

#1 lore raw

PATCH v4 1/1 drm/mediatek: Fix errors when reporting rotation capability

Create rotation property according to the hardware capability. Since currently OVL of all chips support same rotation, no need to define it in the driver data.

Fixes 84d805753983 ("drm/mediatek: Support reflect-y plane rotation")
---
 drivers/gpu/drm/mediatek/mtk_disp_drv.h        |  1 +
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c        | 18 ++++++------------
 .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c    |  9 +++++++++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c    |  1 +
 drivers/gpu/drm/mediatek/mtk_drm_plane.c       |  2 +-
 5 files changed, 18 insertions(+), 13 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_drv.h +1 -0
index 4d6e8b667bc3..c5afeb7c5527 100644
@@ -127,6 +127,7 @@ void mtk_ovl_adaptor_register_vblank_cb(struct device *dev, void (*vblank_cb)(vo
 void mtk_ovl_adaptor_unregister_vblank_cb(struct device *dev);
 void mtk_ovl_adaptor_enable_vblank(struct device *dev);
 void mtk_ovl_adaptor_disable_vblank(struct device *dev);
+unsigned int mtk_ovl_adaptor_supported_rotations(struct device *dev);
 void mtk_ovl_adaptor_start(struct device *dev);
 void mtk_ovl_adaptor_stop(struct device *dev);
 unsigned int mtk_ovl_adaptor_layer_nr(struct device *dev);
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +6 -12
index ecc38932fd44..319bbfde5cf9 100644
@@ -415,6 +415,10 @@ unsigned int mtk_ovl_layer_nr(struct device *dev)
 
 unsigned int mtk_ovl_supported_rotations(struct device *dev)
 {
+	/*
+	 * although currently OVL can only do reflection,
+	 * reflect x + reflect y = rotate 180
+	 */
 	return DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_180 |
 	       DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y;
 }
@@ -423,27 +427,17 @@ int mtk_ovl_layer_check(struct device *dev, unsigned int idx,
 			struct mtk_plane_state *mtk_state)
 {
 	struct drm_plane_state *state = &mtk_state->base;
-	unsigned int rotation = 0;
 
-	rotation = drm_rotation_simplify(state->rotation,
-					 DRM_MODE_ROTATE_0 |
-					 DRM_MODE_REFLECT_X |
-					 DRM_MODE_REFLECT_Y);
-	rotation &= ~DRM_MODE_ROTATE_0;
-
-	/* We can only do reflection, not rotation */
-	if ((rotation & DRM_MODE_ROTATE_MASK) != 0)
+	if (state->rotation & ~mtk_ovl_supported_rotations(dev))
 		return -EINVAL;
 
 	/*
 	 * TODO: Rotating/reflecting YUV buffers is not supported at this time.
 	 *	 Only RGB[AX] variants are supported.
 	 */
-	if (state->fb->format->is_yuv && rotation != 0)
+	if (state->fb->format->is_yuv && (state->rotation & ~DRM_MODE_ROTATE_0))
 		return -EINVAL;
 
-	state->rotation = rotation;
-
 	return 0;
 }
 
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +9 -0
index 4398db9a6276..273c79d37bef 100644
@@ -383,6 +383,15 @@ void mtk_ovl_adaptor_register_vblank_cb(struct device *dev, void (*vblank_cb)(vo
 				     vblank_cb, vblank_cb_data);
 }
 
+unsigned int mtk_ovl_adaptor_supported_rotations(struct device *dev)
+{
+	/*
+	 * should still return DRM_MODE_ROTATE_0 if rotation is not supported,
+	 * or IGT will fail.
+	 */
+	return DRM_MODE_ROTATE_0;
+}
+
 void mtk_ovl_adaptor_unregister_vblank_cb(struct device *dev)
 {
 	struct mtk_disp_ovl_adaptor *ovl_adaptor = dev_get_drvdata(dev);
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +1 -0
index ffa4868b1222..206dd6f6f99e 100644
@@ -422,6 +422,7 @@ static const struct mtk_ddp_comp_funcs ddp_ovl_adaptor = {
 	.remove = mtk_ovl_adaptor_remove_comp,
 	.get_formats = mtk_ovl_adaptor_get_formats,
 	.get_num_formats = mtk_ovl_adaptor_get_num_formats,
+	.supported_rotations = mtk_ovl_adaptor_supported_rotations,
 };
 
 static const char * const mtk_ddp_comp_stem[MTK_DDP_COMP_TYPE_MAX] = {
drivers/gpu/drm/mediatek/mtk_drm_plane.c +1 -1
index e2ec61b69618..894c39a38a58 100644
@@ -344,7 +344,7 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
 		return err;
 	}
 
-	if (supported_rotations & ~DRM_MODE_ROTATE_0) {
+	if (supported_rotations) {
 		err = drm_plane_create_rotation_property(plane,
 							 DRM_MODE_ROTATE_0,
 							 supported_rotations);

--
2.39.2

#2 lore raw

Re: [PATCH v4 1/1] drm/mediatek: Fix errors when reporting rotation capability

Hi, Hsiao-chien:

Quoted 58 lines · Hsiao Chien Sung

Create rotation property according to the hardware capability. Since currently OVL of all chips support same rotation, no need to define it in the driver data.

Fixes 84d805753983 ("drm/mediatek: Support reflect-y plane

rotation")

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

---
 drivers/gpu/drm/mediatek/mtk_disp_drv.h        |  1 +
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c        | 18 ++++++--------
----
 .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c    |  9 +++++++++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c    |  1 +
 drivers/gpu/drm/mediatek/mtk_drm_plane.c       |  2 +-
 5 files changed, 18 insertions(+), 13 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_drv.h +0 -0
index 4d6e8b667bc3..c5afeb7c5527 100644
@@ -127,6 +127,7 @@ void mtk_ovl_adaptor_register_vblank_cb(struct

device *dev, void (*vblank_cb)(vo
void mtk_ovl_adaptor_unregister_vblank_cb(struct device *dev); void mtk_ovl_adaptor_enable_vblank(struct device *dev); void mtk_ovl_adaptor_disable_vblank(struct device *dev);
+unsigned int mtk_ovl_adaptor_supported_rotations(struct device *dev);
void mtk_ovl_adaptor_start(struct device *dev);
void mtk_ovl_adaptor_stop(struct device *dev); unsigned int mtk_ovl_adaptor_layer_nr(struct device *dev);

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +4 -0
index ecc38932fd44..319bbfde5cf9 100644
@@ -415,6 +415,10 @@ unsigned int mtk_ovl_layer_nr(struct device
 *dev)
 
 unsigned int mtk_ovl_supported_rotations(struct device *dev)
 {
+	/*
+	 * although currently OVL can only do reflection,
+	 * reflect x + reflect y = rotate 180
+	 */
 	return DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_180 |
 	       DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y;

}

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0 -1
@@ -423,27 +427,17 @@ int mtk_ovl_layer_check(struct device *dev,
 unsigned int idx,
 			struct mtk_plane_state *mtk_state)
 {
 	struct drm_plane_state *state = &mtk_state->base;
-	unsigned int rotation = 0;
 

drivers/gpu/drm/mediatek/mtk_disp_ovl.c int mtk_ovl_layer_check(struct device *dev, · line 433

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1 -8
-	rotation = drm_rotation_simplify(state->rotation,
-					 DRM_MODE_ROTATE_0 |
-					 DRM_MODE_REFLECT_X |
-					 DRM_MODE_REFLECT_Y);
-	rotation &= ~DRM_MODE_ROTATE_0;
-
-	/* We can only do reflection, not rotation */
-	if ((rotation & DRM_MODE_ROTATE_MASK) != 0)
+	if (state->rotation & ~mtk_ovl_supported_rotations(dev))
 		return -EINVAL;

The commit message of this patch is "Create rotation property according to the hardware capability". I think this modification is not related to create property, so separate this to another patch.

Quoted 61 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0 -0
 	/*
 	 * TODO: Rotating/reflecting YUV buffers is not supported at

this time.

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1 -1
 	 *	 Only RGB[AX] variants are supported.
 	 */
-	if (state->fb->format->is_yuv && rotation != 0)
+	if (state->fb->format->is_yuv && (state->rotation &

~DRM_MODE_ROTATE_0))

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0 -2
 		return -EINVAL;
 
-	state->rotation = rotation;
-
 	return 0;
 }
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +0 -0
index 4398db9a6276..273c79d37bef 100644
@@ -383,6 +383,15 @@ void mtk_ovl_adaptor_register_vblank_cb(struct

device *dev, void (*vblank_cb)(vo

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +4 -0
 				     vblank_cb, vblank_cb_data);
 }
 
+unsigned int mtk_ovl_adaptor_supported_rotations(struct device *dev)
+{
+	/*
+	 * should still return DRM_MODE_ROTATE_0 if rotation is not

supported,

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +5 -0
+	 * or IGT will fail.
+	 */
+	return DRM_MODE_ROTATE_0;
+}
+
 void mtk_ovl_adaptor_unregister_vblank_cb(struct device *dev)
 {
 	struct mtk_disp_ovl_adaptor *ovl_adaptor =

dev_get_drvdata(dev);

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +1 -0
index ffa4868b1222..206dd6f6f99e 100644
@@ -422,6 +422,7 @@ static const struct mtk_ddp_comp_funcs
 ddp_ovl_adaptor = {
 	.remove = mtk_ovl_adaptor_remove_comp,
 	.get_formats = mtk_ovl_adaptor_get_formats,
 	.get_num_formats = mtk_ovl_adaptor_get_num_formats,
+	.supported_rotations = mtk_ovl_adaptor_supported_rotations,
 };
 

static const char * const mtk_ddp_comp_stem[MTK_DDP_COMP_TYPE_MAX] =
{

drivers/gpu/drm/mediatek/mtk_drm_plane.c +0 -0
index e2ec61b69618..894c39a38a58 100644

drivers/gpu/drm/mediatek/mtk_drm_plane.c int mtk_plane_init(struct drm_device *dev, struct · line 348

Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_drm_plane.c +1 -1
@@ -344,7 +344,7 @@ int mtk_plane_init(struct drm_device *dev, struct
 drm_plane *plane,
 		return err;
 	}
 
-	if (supported_rotations & ~DRM_MODE_ROTATE_0) {
+	if (supported_rotations) {

Why need this modification?
Before Sean's patch [1], only support rotate 0 and does not create property and it works. Why does it must create property for only support rotate 0?

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/gpu/drm/mediatek/mtk_drm_plane.c?h=v6.7-rc6&id=ef87d3e2dd251374c5c9fa3b6502aeff8fe29da9

Regards,
CK

Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_drm_plane.c +0 -0
 		err = drm_plane_create_rotation_property(plane,
 							 DRM_MODE_ROTAT

E_0,
supported_rota
tions);
--
2.39.2

#3 lore raw

Re: [PATCH v4 1/1] drm/mediatek: Fix errors when reporting rotation capability

Hi CK,

Quoted 61 lines · CK Hu (胡俊光)

Hi, Hsiao-chien:

Quoted 58 lines · Hsiao Chien Sung

Create rotation property according to the hardware capability. Since currently OVL of all chips support same rotation, no need to define it in the driver data.

Fixes 84d805753983 ("drm/mediatek: Support reflect-y plane

rotation")

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

---
 drivers/gpu/drm/mediatek/mtk_disp_drv.h        |  1 +
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c        | 18 ++++++--------
----
 .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c    |  9 +++++++++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c    |  1 +
 drivers/gpu/drm/mediatek/mtk_drm_plane.c       |  2 +-
 5 files changed, 18 insertions(+), 13 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_drv.h +0 -0
index 4d6e8b667bc3..c5afeb7c5527 100644
@@ -127,6 +127,7 @@ void mtk_ovl_adaptor_register_vblank_cb(struct

device *dev, void (*vblank_cb)(vo
void mtk_ovl_adaptor_unregister_vblank_cb(struct device *dev); void mtk_ovl_adaptor_enable_vblank(struct device *dev); void mtk_ovl_adaptor_disable_vblank(struct device *dev);
+unsigned int mtk_ovl_adaptor_supported_rotations(struct device *dev);
void mtk_ovl_adaptor_start(struct device *dev);
void mtk_ovl_adaptor_stop(struct device *dev); unsigned int mtk_ovl_adaptor_layer_nr(struct device *dev);

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +4 -0
index ecc38932fd44..319bbfde5cf9 100644
@@ -415,6 +415,10 @@ unsigned int mtk_ovl_layer_nr(struct device
 *dev)
 
 unsigned int mtk_ovl_supported_rotations(struct device *dev)
 {
+	/*
+	 * although currently OVL can only do reflection,
+	 * reflect x + reflect y = rotate 180
+	 */
 	return DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_180 |
 	       DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y;

}

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0 -1
@@ -423,27 +427,17 @@ int mtk_ovl_layer_check(struct device *dev,
 unsigned int idx,
 			struct mtk_plane_state *mtk_state)
 {
 	struct drm_plane_state *state = &mtk_state->base;
-	unsigned int rotation = 0;
 
Quoted 15 lines

drivers/gpu/drm/mediatek/mtk_disp_ovl.c int mtk_ovl_layer_check(struct device *dev, unsigned int idx, · line 432

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1 -8
-	rotation = drm_rotation_simplify(state->rotation,
-					 DRM_MODE_ROTATE_0 |
-					 DRM_MODE_REFLECT_X |
-					 DRM_MODE_REFLECT_Y);
-	rotation &= ~DRM_MODE_ROTATE_0;
-
-	/* We can only do reflection, not rotation */
-	if ((rotation & DRM_MODE_ROTATE_MASK) != 0)
+	if (state->rotation & ~mtk_ovl_supported_rotations(dev))
 		return -EINVAL;

The commit message of this patch is "Create rotation property according
to the hardware capability". I think this modification is not related to create property, so separate this to another patch.

Since these modifications are all related to rotation property, or should I change the title and commit message to "Modify roation property for passing IGT"?

Quoted 69 lines
Quoted 69 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0 -0
 	/*
 	 * TODO: Rotating/reflecting YUV buffers is not supported at

this time.

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1 -1
 	 *	 Only RGB[AX] variants are supported.
 	 */
-	if (state->fb->format->is_yuv && rotation != 0)
+	if (state->fb->format->is_yuv && (state->rotation &

~DRM_MODE_ROTATE_0))

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0 -2
 		return -EINVAL;
 
-	state->rotation = rotation;
-
 	return 0;
 }
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +0 -0
index 4398db9a6276..273c79d37bef 100644
@@ -383,6 +383,15 @@ void mtk_ovl_adaptor_register_vblank_cb(struct

device *dev, void (*vblank_cb)(vo

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +1 -0
 				     vblank_cb, vblank_cb_data);
 }
 
+unsigned int mtk_ovl_adaptor_supported_rotations(struct device

*dev)

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +3 -0
+{
+	/*
+	 * should still return DRM_MODE_ROTATE_0 if rotation is not

supported,

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +5 -0
+	 * or IGT will fail.
+	 */
+	return DRM_MODE_ROTATE_0;
+}
+
 void mtk_ovl_adaptor_unregister_vblank_cb(struct device *dev)
 {
 	struct mtk_disp_ovl_adaptor *ovl_adaptor =

dev_get_drvdata(dev);

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +1 -0
index ffa4868b1222..206dd6f6f99e 100644
@@ -422,6 +422,7 @@ static const struct mtk_ddp_comp_funcs
 ddp_ovl_adaptor = {
 	.remove = mtk_ovl_adaptor_remove_comp,
 	.get_formats = mtk_ovl_adaptor_get_formats,
 	.get_num_formats = mtk_ovl_adaptor_get_num_formats,
+	.supported_rotations = mtk_ovl_adaptor_supported_rotations,
 };
 

static const char * const mtk_ddp_comp_stem[MTK_DDP_COMP_TYPE_MAX]
=
{

drivers/gpu/drm/mediatek/mtk_drm_plane.c +0 -0
index e2ec61b69618..894c39a38a58 100644
@@ -344,7 +344,7 @@ int mtk_plane_init(struct drm_device *dev,

struct
drm_plane *plane,

drivers/gpu/drm/mediatek/mtk_drm_plane.c +0 -0
 		return err;
 	}
Quoted 7 lines

drivers/gpu/drm/mediatek/mtk_drm_plane.c int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane, · line 347

Quoted 2 lines
drivers/gpu/drm/mediatek/mtk_drm_plane.c +1 -1
-	if (supported_rotations & ~DRM_MODE_ROTATE_0) {
+	if (supported_rotations) {

Why need this modification?
Before Sean's patch [1], only support rotate 0 and does not create property and it works. Why does it must create property for only support rotate 0?

Yes, as long as the user doesn't check rotation properties before commiting the pitures, there will be no problem. But IGT somehow checked this DRM_MODE_ROTATE_0 flag before executing the tests (not all of them), and leads to failures in these test itmes.

Quoted 4 lines

[1]

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/gpu/drm/mediatek/mtk_drm_plane.c?h=v6.7-rc6&id=ef87d3e2dd251374c5c9fa3b6502aeff8fe29da9

Quoted 12 lines

Regards,
CK

Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_drm_plane.c +0 -0
 		err = drm_plane_create_rotation_property(plane,
 							 DRM_MODE_ROTAT

E_0,
supported_rota
tions);
--
2.39.2

Thanks,
Shawn

#4 lore raw

Re: [PATCH v4 1/1] drm/mediatek: Fix errors when reporting rotation capability

Hi, Hsiao-chien:

Quoted 83 lines · Shawn Sung (宋孝謙)

Hi CK,

Quoted 63 lines · CK Hu (胡俊光)

Hi, Hsiao-chien:

Quoted 60 lines · Hsiao Chien Sung

Create rotation property according to the hardware capability. Since currently OVL of all chips support same rotation, no need to define it in the driver data.

Fixes 84d805753983 ("drm/mediatek: Support reflect-y plane

rotation")

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

---
 drivers/gpu/drm/mediatek/mtk_disp_drv.h        |  1 +
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c        | 18 ++++++----
----
----
 .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c    |  9 +++++++++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c    |  1 +
 drivers/gpu/drm/mediatek/mtk_drm_plane.c       |  2 +-
 5 files changed, 18 insertions(+), 13 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_drv.h +0 -0
index 4d6e8b667bc3..c5afeb7c5527 100644
@@ -127,6 +127,7 @@ void

mtk_ovl_adaptor_register_vblank_cb(struct
device *dev, void (*vblank_cb)(vo
void mtk_ovl_adaptor_unregister_vblank_cb(struct device *dev); void mtk_ovl_adaptor_enable_vblank(struct device *dev); void mtk_ovl_adaptor_disable_vblank(struct device *dev);
+unsigned int mtk_ovl_adaptor_supported_rotations(struct device *dev);
void mtk_ovl_adaptor_start(struct device *dev);
void mtk_ovl_adaptor_stop(struct device *dev); unsigned int mtk_ovl_adaptor_layer_nr(struct device *dev);

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +4 -0
index ecc38932fd44..319bbfde5cf9 100644
@@ -415,6 +415,10 @@ unsigned int mtk_ovl_layer_nr(struct device
 *dev)
 
 unsigned int mtk_ovl_supported_rotations(struct device *dev)
 {
+	/*
+	 * although currently OVL can only do reflection,
+	 * reflect x + reflect y = rotate 180
+	 */
 	return DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_180 |
 	       DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y;

}

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0 -1
@@ -423,27 +427,17 @@ int mtk_ovl_layer_check(struct device *dev,
 unsigned int idx,
 			struct mtk_plane_state *mtk_state)
 {
 	struct drm_plane_state *state = &mtk_state->base;
-	unsigned int rotation = 0;
 
Quoted 16 lines

drivers/gpu/drm/mediatek/mtk_disp_ovl.c int mtk_ovl_layer_check(struct device *dev, unsigned int idx, · line 432

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1 -8
-	rotation = drm_rotation_simplify(state->rotation,
-					 DRM_MODE_ROTATE_0 |
-					 DRM_MODE_REFLECT_X |
-					 DRM_MODE_REFLECT_Y);
-	rotation &= ~DRM_MODE_ROTATE_0;
-
-	/* We can only do reflection, not rotation */
-	if ((rotation & DRM_MODE_ROTATE_MASK) != 0)
+	if (state->rotation & ~mtk_ovl_supported_rotations(dev))
 		return -EINVAL;

The commit message of this patch is "Create rotation property according
to the hardware capability". I think this modification is not related
to create property, so separate this to another patch.

Quoted 3 lines

Since these modifications are all related to rotation property, or should I change the title and commit message to "Modify roation property for passing IGT"?

OK. But I don't know why do this, so describe more about this.

Quoted 80 lines
Quoted 72 lines
Quoted 72 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0 -0
 	/*
 	 * TODO: Rotating/reflecting YUV buffers is not supported at

this time.

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1 -1
 	 *	 Only RGB[AX] variants are supported.
 	 */
-	if (state->fb->format->is_yuv && rotation != 0)
+	if (state->fb->format->is_yuv && (state->rotation &

~DRM_MODE_ROTATE_0))

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0 -2
 		return -EINVAL;
 
-	state->rotation = rotation;
-
 	return 0;
 }
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +0 -0
index 4398db9a6276..273c79d37bef 100644
@@ -383,6 +383,15 @@ void

mtk_ovl_adaptor_register_vblank_cb(struct
device *dev, void (*vblank_cb)(vo

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +1 -0
 				     vblank_cb, vblank_cb_data);
 }
 
+unsigned int mtk_ovl_adaptor_supported_rotations(struct device

*dev)

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +3 -0
+{
+	/*
+	 * should still return DRM_MODE_ROTATE_0 if rotation is not

supported,

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +5 -0
+	 * or IGT will fail.
+	 */
+	return DRM_MODE_ROTATE_0;
+}
+
 void mtk_ovl_adaptor_unregister_vblank_cb(struct device *dev)
 {
 	struct mtk_disp_ovl_adaptor *ovl_adaptor =

dev_get_drvdata(dev);

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +1 -0
index ffa4868b1222..206dd6f6f99e 100644
@@ -422,6 +422,7 @@ static const struct mtk_ddp_comp_funcs
 ddp_ovl_adaptor = {
 	.remove = mtk_ovl_adaptor_remove_comp,
 	.get_formats = mtk_ovl_adaptor_get_formats,
 	.get_num_formats = mtk_ovl_adaptor_get_num_formats,
+	.supported_rotations = mtk_ovl_adaptor_supported_rotations,
 };
 

static const char * const
mtk_ddp_comp_stem[MTK_DDP_COMP_TYPE_MAX]
=
{

drivers/gpu/drm/mediatek/mtk_drm_plane.c +0 -0
index e2ec61b69618..894c39a38a58 100644
@@ -344,7 +344,7 @@ int mtk_plane_init(struct drm_device *dev,

struct
drm_plane *plane,

drivers/gpu/drm/mediatek/mtk_drm_plane.c +0 -0
 		return err;
 	}
Quoted 7 lines

drivers/gpu/drm/mediatek/mtk_drm_plane.c int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane, · line 347

Quoted 2 lines
drivers/gpu/drm/mediatek/mtk_drm_plane.c +1 -1
-	if (supported_rotations & ~DRM_MODE_ROTATE_0) {
+	if (supported_rotations) {

Why need this modification?
Before Sean's patch [1], only support rotate 0 and does not create property and it works. Why does it must create property for only support rotate 0?

Quoted 5 lines

Yes, as long as the user doesn't check rotation properties before commiting the pitures, there will be no problem. But IGT somehow checked this DRM_MODE_ROTATE_0 flag before executing the tests (not all
of them), and leads to failures in these test itmes.

OK, so, when supported_rotations == NULL (mtk_disp_rdma), it should also create rotation property. But I'm confused that if IGT assume that all drm driver should have rotation property, why drm core does not add this property for all drm driver?

Regards,
CK

Quoted 7 lines
Quoted 5 lines

[1]

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/gpu/drm/mediatek/mtk_drm_plane.c?h=v6.7-rc6&id=ef87d3e2dd251374c5c9fa3b6502aeff8fe29da9

Quoted 15 lines
Quoted 12 lines

Regards,
CK

Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_drm_plane.c +0 -0
 		err = drm_plane_create_rotation_property(plane,
 							 DRM_MODE_ROTAT

E_0,
supported_rota
tions);
--
2.39.2

Thanks,
Shawn

#5 lore raw

Re: [PATCH v4 1/1] drm/mediatek: Fix errors when reporting rotation capability

Hi CK,

Quoted 89 lines · CK Hu (胡俊光)

Hi, Hsiao-chien:

Quoted 86 lines · Shawn Sung (宋孝謙)

Hi CK,

Quoted 82 lines · CK Hu (胡俊光)

Hi, Hsiao-chien:

Quoted 63 lines · Hsiao Chien Sung

Create rotation property according to the hardware capability. Since currently OVL of all chips support same rotation, no need to define it in the driver data.

Fixes 84d805753983 ("drm/mediatek: Support reflect-y plane

rotation")

Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>

---
 drivers/gpu/drm/mediatek/mtk_disp_drv.h        |  1 +
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c        | 18 ++++++----
----
----
 .../gpu/drm/mediatek/mtk_disp_ovl_adaptor.c    |  9 +++++++++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c    |  1 +
 drivers/gpu/drm/mediatek/mtk_drm_plane.c       |  2 +-
 5 files changed, 18 insertions(+), 13 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_drv.h +0 -0
index 4d6e8b667bc3..c5afeb7c5527 100644
@@ -127,6 +127,7 @@ void

mtk_ovl_adaptor_register_vblank_cb(struct
device *dev, void (*vblank_cb)(vo
void mtk_ovl_adaptor_unregister_vblank_cb(struct device *dev); void mtk_ovl_adaptor_enable_vblank(struct device *dev); void mtk_ovl_adaptor_disable_vblank(struct device *dev);
+unsigned int mtk_ovl_adaptor_supported_rotations(struct device *dev);
void mtk_ovl_adaptor_start(struct device *dev);
void mtk_ovl_adaptor_stop(struct device *dev); unsigned int mtk_ovl_adaptor_layer_nr(struct device *dev);

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0 -0
index ecc38932fd44..319bbfde5cf9 100644
@@ -415,6 +415,10 @@ unsigned int mtk_ovl_layer_nr(struct

device
*dev)

unsigned int mtk_ovl_supported_rotations(struct device *dev) {

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +4 -2
+	/*
+	 * although currently OVL can only do reflection,
+	 * reflect x + reflect y = rotate 180
+	 */
 	return DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_180 |
 	       DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y;
 }
@@ -423,27 +427,17 @@ int mtk_ovl_layer_check(struct device
 *dev,
 unsigned int idx,
 			struct mtk_plane_state *mtk_state)
 {
 	struct drm_plane_state *state = &mtk_state->base;
-	unsigned int rotation = 0;
 
-	rotation = drm_rotation_simplify(state->rotation,

drivers/gpu/drm/mediatek/mtk_disp_ovl.c int mtk_ovl_layer_check(struct device · line 435

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1 -7
-					 DRM_MODE_ROTATE_0 |
-					 DRM_MODE_REFLECT_X |
-					 DRM_MODE_REFLECT_Y);
-	rotation &= ~DRM_MODE_ROTATE_0;
-
-	/* We can only do reflection, not rotation */
-	if ((rotation & DRM_MODE_ROTATE_MASK) != 0)
+	if (state->rotation &
 ~mtk_ovl_supported_rotations(dev))
 		return -EINVAL;

The commit message of this patch is "Create rotation property according
to the hardware capability". I think this modification is not related
to create property, so separate this to another patch.

Quoted 6 lines
Quoted 3 lines

Since these modifications are all related to rotation property, or should I change the title and commit message to "Modify roation property for passing IGT"?

OK. But I don't know why do this, so describe more about this.

Got it, thanks. Will add more information to the commit message.

Quoted 91 lines
Quoted 85 lines
Quoted 76 lines
Quoted 76 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0 -0
 	/*
 	 * TODO: Rotating/reflecting YUV buffers is not

supported at
this time.

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +1 -1
 	 *	 Only RGB[AX] variants are supported.
 	 */
-	if (state->fb->format->is_yuv && rotation != 0)
+	if (state->fb->format->is_yuv && (state->rotation &

~DRM_MODE_ROTATE_0))

drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0 -2
 		return -EINVAL;
 
-	state->rotation = rotation;
-
 	return 0;
 }
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +0 -0
index 4398db9a6276..273c79d37bef 100644
@@ -383,6 +383,15 @@ void

mtk_ovl_adaptor_register_vblank_cb(struct
device *dev, void (*vblank_cb)(vo
vblank_cb,
vblank_cb_data);
}

+unsigned int mtk_ovl_adaptor_supported_rotations(struct device *dev)

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +3 -0
+{
+	/*
+	 * should still return DRM_MODE_ROTATE_0 if rotation is

not
supported,

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +5 -0
+	 * or IGT will fail.
+	 */
+	return DRM_MODE_ROTATE_0;
+}
+
 void mtk_ovl_adaptor_unregister_vblank_cb(struct device *dev)
 {
 	struct mtk_disp_ovl_adaptor *ovl_adaptor =

dev_get_drvdata(dev);

drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c +1 -0
index ffa4868b1222..206dd6f6f99e 100644
@@ -422,6 +422,7 @@ static const struct mtk_ddp_comp_funcs
 ddp_ovl_adaptor = {
 	.remove = mtk_ovl_adaptor_remove_comp,
 	.get_formats = mtk_ovl_adaptor_get_formats,
 	.get_num_formats = mtk_ovl_adaptor_get_num_formats,
+	.supported_rotations =
 mtk_ovl_adaptor_supported_rotations,
 };

static const char * const
mtk_ddp_comp_stem[MTK_DDP_COMP_TYPE_MAX]
=
{

drivers/gpu/drm/mediatek/mtk_drm_plane.c +0 -0
index e2ec61b69618..894c39a38a58 100644
@@ -344,7 +344,7 @@ int mtk_plane_init(struct drm_device *dev,

struct
drm_plane *plane,

drivers/gpu/drm/mediatek/mtk_drm_plane.c +0 -0
 		return err;
 	}
Quoted 8 lines

drivers/gpu/drm/mediatek/mtk_drm_plane.c int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane, · line 347

Quoted 2 lines
drivers/gpu/drm/mediatek/mtk_drm_plane.c +1 -1
-	if (supported_rotations & ~DRM_MODE_ROTATE_0) {
+	if (supported_rotations) {

Why need this modification?
Before Sean's patch [1], only support rotate 0 and does not create
property and it works. Why does it must create property for only support rotate 0?

Quoted 5 lines

Yes, as long as the user doesn't check rotation properties before commiting the pitures, there will be no problem. But IGT somehow checked this DRM_MODE_ROTATE_0 flag before executing the tests (not all
of them), and leads to failures in these test itmes.

Quoted 7 lines

OK, so, when supported_rotations == NULL (mtk_disp_rdma), it should also create rotation property. But I'm confused that if IGT assume that
all drm driver should have rotation property, why drm core does not add
this property for all drm driver?

After checking the report, only "graphics.IgtKms.kms_flip_unstable" has such a constraint. However, since IGT version is still keep updating, there are not guarantees about this behavior.

I did search for "DRM_MODE_ROTATE_0" in the kernel to check if there is any rule or even suggestion about setting this property, but the flag is rarely even mentioned.

Maybe we could also report this issue to IGT team instead of changing the behavior of our driver.

Quoted 12 lines

Regards,
CK

Quoted 7 lines
Quoted 5 lines

[1]

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/gpu/drm/mediatek/mtk_drm_plane.c?h=v6.7-rc6&id=ef87d3e2dd251374c5c9fa3b6502aeff8fe29da9

Quoted 17 lines
Quoted 17 lines
Quoted 14 lines

Regards,
CK

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_drm_plane.c +0 -0
 		err = drm_plane_create_rotation_property(plane,
 							 DRM_MO

DE_ROTAT
E_0,
suppor
ted_rota
tions);
--
2.39.2

Thanks,
Shawn