LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v3 0/2] drm/komeda: Add rotation support on Komeda driver
@ 2019-05-28  3:56 Lowry Li (Arm Technology China)
  2019-05-28  3:57 ` [PATCH v3 1/2] " Lowry Li (Arm Technology China)
  2019-05-28  3:57 ` [PATCH v3 2/2] drm/komeda: Adds limitation check for AFBC wide block not support Rot90 Lowry Li (Arm Technology China)
  0 siblings, 2 replies; 5+ messages in thread
From: Lowry Li (Arm Technology China) @ 2019-05-28  3:56 UTC (permalink / raw)
  To: Liviu Dudau, james qian wang (Arm Technology China),
	maarten.lankhorst, seanpaul, airlied, Brian Starkey
  Cc: Julien Yin (Arm Technology China),
	Jonathan Chai (Arm Technology China),
	Ayan Halder, dri-devel, linux-kernel, nd

Hi,

This serie aims at adding the support for rotation on Komeda driver.
For rotation, D71 doesn't support Rot90 for AFBC wide block. So this patch
set also includes the limitation check.

This patch series depends on:
- https://patchwork.freedesktop.org/series/59915/
- https://patchwork.freedesktop.org/series/58665/
- https://patchwork.freedesktop.org/series/59000/
- https://patchwork.freedesktop.org/series/59002/
- https://patchwork.freedesktop.org/series/59471/
- https://patchwork.freedesktop.org/series/58710/

Changes since v1:
- Modify patch denpendency in the comment

Changes since v2:
- Rebase the code

Regards,
Lowry

Lowry Li (Arm Technology China) (2):
  drm/komeda: Add rotation support on Komeda driver
  drm/komeda: Adds limitation check for AFBC wide block not support
    Rot90

 drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c      | 15 +++++++++++++++
 .../gpu/drm/arm/display/komeda/komeda_format_caps.c   |  7 ++++++-
 .../gpu/drm/arm/display/komeda/komeda_format_caps.h   | 19 ++++++++++++++++++-
 .../gpu/drm/arm/display/komeda/komeda_framebuffer.c   | 18 +++++++++---------
 .../gpu/drm/arm/display/komeda/komeda_framebuffer.h   |  5 +++--
 .../drm/arm/display/komeda/komeda_pipeline_state.c    | 15 ++++++++++++++-
 drivers/gpu/drm/arm/display/komeda/komeda_plane.c     | 18 +++++++++++++++++-
 7 files changed, 82 insertions(+), 15 deletions(-)

-- 
1.9.1


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

* [PATCH v3 1/2] drm/komeda: Add rotation support on Komeda driver
  2019-05-28  3:56 [PATCH v3 0/2] drm/komeda: Add rotation support on Komeda driver Lowry Li (Arm Technology China)
@ 2019-05-28  3:57 ` Lowry Li (Arm Technology China)
  2019-05-28  6:08   ` james qian wang (Arm Technology China)
  2019-05-28  3:57 ` [PATCH v3 2/2] drm/komeda: Adds limitation check for AFBC wide block not support Rot90 Lowry Li (Arm Technology China)
  1 sibling, 1 reply; 5+ messages in thread
From: Lowry Li (Arm Technology China) @ 2019-05-28  3:57 UTC (permalink / raw)
  To: Liviu Dudau, james qian wang (Arm Technology China),
	maarten.lankhorst, seanpaul, airlied, Brian Starkey
  Cc: Julien Yin (Arm Technology China),
	Jonathan Chai (Arm Technology China),
	Ayan Halder, dri-devel, linux-kernel, nd

From: "Lowry Li (Arm Technology China)" <Lowry.Li@arm.com>

- Adds rotation property to plane.
- Komeda display rotation support diverges from the specific formats,
so need to check the user required rotation type with the format caps
and reject the commit if it can not be supported.
- In the layer validate flow, sets the rotation value to the layer
state. If r90 or r270, swap the width and height of the data flow
for next stage.

Signed-off-by: Lowry Li (Arm Technology China) <lowry.li@arm.com>
---
 drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h  | 11 +++++++++++
 .../gpu/drm/arm/display/komeda/komeda_pipeline_state.c   |  7 +++++++
 drivers/gpu/drm/arm/display/komeda/komeda_plane.c        | 16 ++++++++++++++++
 3 files changed, 34 insertions(+)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
index bc3b2df36..96de22e 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
@@ -79,6 +79,17 @@ struct komeda_format_caps_table {
 
 extern u64 komeda_supported_modifiers[];
 
+static inline const char *komeda_get_format_name(u32 fourcc, u64 modifier)
+{
+	struct drm_format_name_buf buf;
+	static char name[64];
+
+	snprintf(name, sizeof(name), "%s with modifier: 0x%llx.",
+		 drm_get_format_name(fourcc, &buf), modifier);
+
+	return name;
+}
+
 const struct komeda_format_caps *
 komeda_get_format_caps(struct komeda_format_caps_table *table,
 		       u32 fourcc, u64 modifier);
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
index db34ea2..34737c0 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
@@ -339,6 +339,13 @@ struct komeda_pipeline_state *
 	/* update the data flow for the next stage */
 	komeda_component_set_output(&dflow->input, &layer->base, 0);
 
+	/*
+	 * The rotation has been handled by layer, so adjusted the data flow for
+	 * the next stage.
+	 */
+	if (drm_rotation_90_or_270(st->rot))
+		swap(dflow->in_h, dflow->in_w);
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
index 9b87c25..c9f37ff 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
@@ -10,6 +10,7 @@
 #include <drm/drm_print.h>
 #include "komeda_dev.h"
 #include "komeda_kms.h"
+#include "komeda_framebuffer.h"
 
 static int
 komeda_plane_init_data_flow(struct drm_plane_state *st,
@@ -17,6 +18,7 @@
 {
 	struct komeda_plane_state *kplane_st = to_kplane_st(st);
 	struct drm_framebuffer *fb = st->fb;
+	const struct komeda_format_caps *caps = to_kfb(fb)->format_caps;
 
 	memset(dflow, 0, sizeof(*dflow));
 
@@ -37,6 +39,15 @@
 	dflow->in_w = st->src_w >> 16;
 	dflow->in_h = st->src_h >> 16;
 
+	dflow->rot = drm_rotation_simplify(st->rotation, caps->supported_rots);
+	if (!has_bits(dflow->rot, caps->supported_rots)) {
+		DRM_DEBUG_ATOMIC("rotation(0x%x) isn't supported by %s.\n",
+				 dflow->rot,
+				 komeda_get_format_name(caps->fourcc,
+							fb->modifier));
+		return -EINVAL;
+	}
+
 	dflow->en_img_enhancement = kplane_st->img_enhancement;
 
 	komeda_complete_data_flow_cfg(dflow);
@@ -303,6 +314,11 @@ static int komeda_plane_add(struct komeda_kms_dev *kms,
 
 	drm_plane_helper_add(plane, &komeda_plane_helper_funcs);
 
+	err = drm_plane_create_rotation_property(plane, DRM_MODE_ROTATE_0,
+						 layer->supported_rots);
+	if (err)
+		goto cleanup;
+
 	err = drm_plane_create_alpha_property(plane);
 	if (err)
 		goto cleanup;
-- 
1.9.1


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

* [PATCH v3 2/2] drm/komeda: Adds limitation check for AFBC wide block not support Rot90
  2019-05-28  3:56 [PATCH v3 0/2] drm/komeda: Add rotation support on Komeda driver Lowry Li (Arm Technology China)
  2019-05-28  3:57 ` [PATCH v3 1/2] " Lowry Li (Arm Technology China)
@ 2019-05-28  3:57 ` Lowry Li (Arm Technology China)
  2019-05-28  6:14   ` james qian wang (Arm Technology China)
  1 sibling, 1 reply; 5+ messages in thread
From: Lowry Li (Arm Technology China) @ 2019-05-28  3:57 UTC (permalink / raw)
  To: Liviu Dudau, james qian wang (Arm Technology China),
	maarten.lankhorst, seanpaul, airlied, Brian Starkey
  Cc: Julien Yin (Arm Technology China),
	Jonathan Chai (Arm Technology China),
	Ayan Halder, dri-devel, linux-kernel, nd

From: "Lowry Li (Arm Technology China)" <Lowry.Li@arm.com>

Komeda series hardware doesn't support Rot90 for AFBC wide block. So
add limitation check to reject it if such configuration has been posted.

Signed-off-by: Lowry Li (Arm Technology China) <lowry.li@arm.com>
---
 drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c       | 15 +++++++++++++++
 .../gpu/drm/arm/display/komeda/komeda_format_caps.c    |  7 ++++++-
 .../gpu/drm/arm/display/komeda/komeda_format_caps.h    |  8 +++++++-
 .../gpu/drm/arm/display/komeda/komeda_framebuffer.c    | 18 +++++++++---------
 .../gpu/drm/arm/display/komeda/komeda_framebuffer.h    |  5 +++--
 .../gpu/drm/arm/display/komeda/komeda_pipeline_state.c |  8 +++++++-
 drivers/gpu/drm/arm/display/komeda/komeda_plane.c      |  2 +-
 7 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
index 1c914f8..4563c2a 100644
--- a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
+++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
@@ -494,11 +494,26 @@ static int d71_enum_resources(struct komeda_dev *mdev)
 	{__HW_ID(6, 7),	0/*DRM_FORMAT_YUV420_10BIT*/, 1,	RICH,	Rot_ALL_H_V,	LYT_NM, AFB_TH},
 };
 
+static bool d71_format_mod_supported(const struct komeda_format_caps *caps,
+				     u32 layer_type, u64 modifier, u32 rot)
+{
+	uint64_t layout = modifier & AFBC_FORMAT_MOD_BLOCK_SIZE_MASK;
+
+	if ((layout == AFBC_FORMAT_MOD_BLOCK_SIZE_32x8) &&
+	    drm_rotation_90_or_270(rot)) {
+		DRM_DEBUG_ATOMIC("D71 doesn't support ROT90 for WB-AFBC.\n");
+		return false;
+	}
+
+	return true;
+}
+
 static void d71_init_fmt_tbl(struct komeda_dev *mdev)
 {
 	struct komeda_format_caps_table *table = &mdev->fmt_tbl;
 
 	table->format_caps = d71_format_caps_table;
+	table->format_mod_supported = d71_format_mod_supported;
 	table->n_formats = ARRAY_SIZE(d71_format_caps_table);
 }
 
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c
index b219514..cd4d9f5 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c
@@ -74,7 +74,8 @@
 };
 
 bool komeda_format_mod_supported(struct komeda_format_caps_table *table,
-				 u32 layer_type, u32 fourcc, u64 modifier)
+				 u32 layer_type, u32 fourcc, u64 modifier,
+				 u32 rot)
 {
 	const struct komeda_format_caps *caps;
 
@@ -85,6 +86,10 @@ bool komeda_format_mod_supported(struct komeda_format_caps_table *table,
 	if (!(caps->supported_layer_types & layer_type))
 		return false;
 
+	if (table->format_mod_supported)
+		return table->format_mod_supported(caps, layer_type, modifier,
+						   rot);
+
 	return true;
 }
 
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
index 96de22e..381e873 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
@@ -71,10 +71,15 @@ struct komeda_format_caps {
  *
  * @n_formats: the size of format_caps list.
  * @format_caps: format_caps list.
+ * @format_mod_supported: Optional. Some HW may have special requirements or
+ * limitations which can not be described by format_caps, this func supply HW
+ * the ability to do the further HW specific check.
  */
 struct komeda_format_caps_table {
 	u32 n_formats;
 	const struct komeda_format_caps *format_caps;
+	bool (*format_mod_supported)(const struct komeda_format_caps *caps,
+				     u32 layer_type, u64 modifier, u32 rot);
 };
 
 extern u64 komeda_supported_modifiers[];
@@ -100,6 +105,7 @@ u32 *komeda_get_layer_fourcc_list(struct komeda_format_caps_table *table,
 void komeda_put_fourcc_list(u32 *fourcc_list);
 
 bool komeda_format_mod_supported(struct komeda_format_caps_table *table,
-				 u32 layer_type, u32 fourcc, u64 modifier);
+				 u32 layer_type, u32 fourcc, u64 modifier,
+				 u32 rot);
 
 #endif
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
index d0e713a..5f63dec 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
@@ -240,20 +240,20 @@ struct drm_framebuffer *
 }
 
 /* if the fb can be supported by a specific layer */
-bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type)
+bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type,
+				  u32 rot)
 {
 	struct drm_framebuffer *fb = &kfb->base;
 	struct komeda_dev *mdev = fb->dev->dev_private;
-	const struct komeda_format_caps *caps;
 	u32 fourcc = fb->format->format;
 	u64 modifier = fb->modifier;
+	bool supported;
 
-	caps = komeda_get_format_caps(&mdev->fmt_tbl, fourcc, modifier);
-	if (!caps)
-		return false;
+	supported = komeda_format_mod_supported(&mdev->fmt_tbl, layer_type,
+						fourcc, modifier, rot);
+	if (!supported)
+		DRM_DEBUG_ATOMIC("Layer TYPE: %d doesn't support fb FMT: %s.\n",
+			layer_type, komeda_get_format_name(fourcc, modifier));
 
-	if (!(caps->supported_layer_types & layer_type))
-		return false;
-
-	return true;
+	return supported;
 }
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h
index e3bab0d..6cbb2f6 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h
@@ -35,9 +35,10 @@ struct komeda_fb {
 
 struct drm_framebuffer *
 komeda_fb_create(struct drm_device *dev, struct drm_file *file,
-		 const struct drm_mode_fb_cmd2 *mode_cmd);
+		const struct drm_mode_fb_cmd2 *mode_cmd);
 dma_addr_t
 komeda_fb_get_pixel_addr(struct komeda_fb *kfb, int x, int y, int plane);
-bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type);
+bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type,
+		u32 rot);
 
 #endif
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
index 34737c0..042d4d7 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
@@ -274,6 +274,11 @@ struct komeda_pipeline_state *
 		       struct komeda_plane_state *kplane_st,
 		       struct komeda_data_flow_cfg *dflow)
 {
+	struct komeda_fb *kfb = to_kfb(kplane_st->base.fb);
+
+	if (!komeda_fb_is_layer_supported(kfb, layer->layer_type, dflow->rot))
+		return -EINVAL;
+
 	if (!in_range(&layer->hsize_in, dflow->in_w)) {
 		DRM_DEBUG_ATOMIC("src_w: %d is out of range.\n", dflow->in_w);
 		return -EINVAL;
@@ -359,7 +364,8 @@ struct komeda_pipeline_state *
 	struct komeda_layer_state *st;
 	int i;
 
-	if (!komeda_fb_is_layer_supported(kfb, wb_layer->layer_type))
+	if (!komeda_fb_is_layer_supported(kfb, wb_layer->layer_type,
+					  dflow->rot))
 		return -EINVAL;
 
 	c_st = komeda_component_get_state_and_set_user(&wb_layer->base,
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
index c9f37ff..798ee24 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
@@ -216,7 +216,7 @@ static void komeda_plane_reset(struct drm_plane *plane)
 	u32 layer_type = kplane->layer->layer_type;
 
 	return komeda_format_mod_supported(&mdev->fmt_tbl, layer_type,
-					   format, modifier);
+					   format, modifier, 0);
 }
 
 static const struct drm_plane_funcs komeda_plane_funcs = {
-- 
1.9.1


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

* Re: [PATCH v3 1/2] drm/komeda: Add rotation support on Komeda driver
  2019-05-28  3:57 ` [PATCH v3 1/2] " Lowry Li (Arm Technology China)
@ 2019-05-28  6:08   ` james qian wang (Arm Technology China)
  0 siblings, 0 replies; 5+ messages in thread
From: james qian wang (Arm Technology China) @ 2019-05-28  6:08 UTC (permalink / raw)
  To: Lowry Li (Arm Technology China)
  Cc: Liviu Dudau, maarten.lankhorst, seanpaul, airlied, Brian Starkey,
	Julien Yin (Arm Technology China),
	Jonathan Chai (Arm Technology China),
	Ayan Halder, dri-devel, linux-kernel, nd

On Tue, May 28, 2019 at 11:57:00AM +0800, Lowry Li (Arm Technology China) wrote:
> From: "Lowry Li (Arm Technology China)" <Lowry.Li@arm.com>
> 
> - Adds rotation property to plane.
> - Komeda display rotation support diverges from the specific formats,
> so need to check the user required rotation type with the format caps
> and reject the commit if it can not be supported.
> - In the layer validate flow, sets the rotation value to the layer
> state. If r90 or r270, swap the width and height of the data flow
> for next stage.
> 
> Signed-off-by: Lowry Li (Arm Technology China) <lowry.li@arm.com>
> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h  | 11 +++++++++++
>  .../gpu/drm/arm/display/komeda/komeda_pipeline_state.c   |  7 +++++++
>  drivers/gpu/drm/arm/display/komeda/komeda_plane.c        | 16 ++++++++++++++++
>  3 files changed, 34 insertions(+)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
> index bc3b2df36..96de22e 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
> @@ -79,6 +79,17 @@ struct komeda_format_caps_table {
>  
>  extern u64 komeda_supported_modifiers[];
>  
> +static inline const char *komeda_get_format_name(u32 fourcc, u64 modifier)
> +{
> +	struct drm_format_name_buf buf;
> +	static char name[64];
> +
> +	snprintf(name, sizeof(name), "%s with modifier: 0x%llx.",
> +		 drm_get_format_name(fourcc, &buf), modifier);
> +
> +	return name;
> +}
> +
>  const struct komeda_format_caps *
>  komeda_get_format_caps(struct komeda_format_caps_table *table,
>  		       u32 fourcc, u64 modifier);
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> index db34ea2..34737c0 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> @@ -339,6 +339,13 @@ struct komeda_pipeline_state *
>  	/* update the data flow for the next stage */
>  	komeda_component_set_output(&dflow->input, &layer->base, 0);
>  
> +	/*
> +	 * The rotation has been handled by layer, so adjusted the data flow for
> +	 * the next stage.
> +	 */
> +	if (drm_rotation_90_or_270(st->rot))
> +		swap(dflow->in_h, dflow->in_w);
> +
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
> index 9b87c25..c9f37ff 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
> @@ -10,6 +10,7 @@
>  #include <drm/drm_print.h>
>  #include "komeda_dev.h"
>  #include "komeda_kms.h"
> +#include "komeda_framebuffer.h"
>  
>  static int
>  komeda_plane_init_data_flow(struct drm_plane_state *st,
> @@ -17,6 +18,7 @@
>  {
>  	struct komeda_plane_state *kplane_st = to_kplane_st(st);
>  	struct drm_framebuffer *fb = st->fb;
> +	const struct komeda_format_caps *caps = to_kfb(fb)->format_caps;
>  
>  	memset(dflow, 0, sizeof(*dflow));
>  
> @@ -37,6 +39,15 @@
>  	dflow->in_w = st->src_w >> 16;
>  	dflow->in_h = st->src_h >> 16;
>  
> +	dflow->rot = drm_rotation_simplify(st->rotation, caps->supported_rots);
> +	if (!has_bits(dflow->rot, caps->supported_rots)) {
> +		DRM_DEBUG_ATOMIC("rotation(0x%x) isn't supported by %s.\n",
> +				 dflow->rot,
> +				 komeda_get_format_name(caps->fourcc,
> +							fb->modifier));
> +		return -EINVAL;
> +	}
> +
>  	dflow->en_img_enhancement = kplane_st->img_enhancement;
>  
>  	komeda_complete_data_flow_cfg(dflow);
> @@ -303,6 +314,11 @@ static int komeda_plane_add(struct komeda_kms_dev *kms,
>  
>  	drm_plane_helper_add(plane, &komeda_plane_helper_funcs);
>  
> +	err = drm_plane_create_rotation_property(plane, DRM_MODE_ROTATE_0,
> +						 layer->supported_rots);
> +	if (err)
> +		goto cleanup;
> +
>  	err = drm_plane_create_alpha_property(plane);
>  	if (err)
>  		goto cleanup;
> -- 
> 1.9.1
> 

Looks good to me.

Reviewed-by: James Qian Wang (Arm Technology China) <james.qian.wang@arm.com>

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

* Re: [PATCH v3 2/2] drm/komeda: Adds limitation check for AFBC wide block not support Rot90
  2019-05-28  3:57 ` [PATCH v3 2/2] drm/komeda: Adds limitation check for AFBC wide block not support Rot90 Lowry Li (Arm Technology China)
@ 2019-05-28  6:14   ` james qian wang (Arm Technology China)
  0 siblings, 0 replies; 5+ messages in thread
From: james qian wang (Arm Technology China) @ 2019-05-28  6:14 UTC (permalink / raw)
  To: Lowry Li (Arm Technology China)
  Cc: Liviu Dudau, maarten.lankhorst, seanpaul, airlied, Brian Starkey,
	Julien Yin (Arm Technology China),
	Jonathan Chai (Arm Technology China),
	Ayan Halder, dri-devel, linux-kernel, nd

On Tue, May 28, 2019 at 11:57:05AM +0800, Lowry Li (Arm Technology China) wrote:
> From: "Lowry Li (Arm Technology China)" <Lowry.Li@arm.com>
> 
> Komeda series hardware doesn't support Rot90 for AFBC wide block. So
> add limitation check to reject it if such configuration has been posted.
> 
> Signed-off-by: Lowry Li (Arm Technology China) <lowry.li@arm.com>
> ---
>  drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c       | 15 +++++++++++++++
>  .../gpu/drm/arm/display/komeda/komeda_format_caps.c    |  7 ++++++-
>  .../gpu/drm/arm/display/komeda/komeda_format_caps.h    |  8 +++++++-
>  .../gpu/drm/arm/display/komeda/komeda_framebuffer.c    | 18 +++++++++---------
>  .../gpu/drm/arm/display/komeda/komeda_framebuffer.h    |  5 +++--
>  .../gpu/drm/arm/display/komeda/komeda_pipeline_state.c |  8 +++++++-
>  drivers/gpu/drm/arm/display/komeda/komeda_plane.c      |  2 +-
>  7 files changed, 48 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
> index 1c914f8..4563c2a 100644
> --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
> +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
> @@ -494,11 +494,26 @@ static int d71_enum_resources(struct komeda_dev *mdev)
>  	{__HW_ID(6, 7),	0/*DRM_FORMAT_YUV420_10BIT*/, 1,	RICH,	Rot_ALL_H_V,	LYT_NM, AFB_TH},
>  };
>  
> +static bool d71_format_mod_supported(const struct komeda_format_caps *caps,
> +				     u32 layer_type, u64 modifier, u32 rot)
> +{
> +	uint64_t layout = modifier & AFBC_FORMAT_MOD_BLOCK_SIZE_MASK;
> +
> +	if ((layout == AFBC_FORMAT_MOD_BLOCK_SIZE_32x8) &&
> +	    drm_rotation_90_or_270(rot)) {
> +		DRM_DEBUG_ATOMIC("D71 doesn't support ROT90 for WB-AFBC.\n");
> +		return false;
> +	}
> +
> +	return true;
> +}
> +
>  static void d71_init_fmt_tbl(struct komeda_dev *mdev)
>  {
>  	struct komeda_format_caps_table *table = &mdev->fmt_tbl;
>  
>  	table->format_caps = d71_format_caps_table;
> +	table->format_mod_supported = d71_format_mod_supported;
>  	table->n_formats = ARRAY_SIZE(d71_format_caps_table);
>  }
>  
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c
> index b219514..cd4d9f5 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.c
> @@ -74,7 +74,8 @@
>  };
>  
>  bool komeda_format_mod_supported(struct komeda_format_caps_table *table,
> -				 u32 layer_type, u32 fourcc, u64 modifier)
> +				 u32 layer_type, u32 fourcc, u64 modifier,
> +				 u32 rot)
>  {
>  	const struct komeda_format_caps *caps;
>  
> @@ -85,6 +86,10 @@ bool komeda_format_mod_supported(struct komeda_format_caps_table *table,
>  	if (!(caps->supported_layer_types & layer_type))
>  		return false;
>  
> +	if (table->format_mod_supported)
> +		return table->format_mod_supported(caps, layer_type, modifier,
> +						   rot);
> +
>  	return true;
>  }
>  
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
> index 96de22e..381e873 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_format_caps.h
> @@ -71,10 +71,15 @@ struct komeda_format_caps {
>   *
>   * @n_formats: the size of format_caps list.
>   * @format_caps: format_caps list.
> + * @format_mod_supported: Optional. Some HW may have special requirements or
> + * limitations which can not be described by format_caps, this func supply HW
> + * the ability to do the further HW specific check.
>   */
>  struct komeda_format_caps_table {
>  	u32 n_formats;
>  	const struct komeda_format_caps *format_caps;
> +	bool (*format_mod_supported)(const struct komeda_format_caps *caps,
> +				     u32 layer_type, u64 modifier, u32 rot);
>  };
>  
>  extern u64 komeda_supported_modifiers[];
> @@ -100,6 +105,7 @@ u32 *komeda_get_layer_fourcc_list(struct komeda_format_caps_table *table,
>  void komeda_put_fourcc_list(u32 *fourcc_list);
>  
>  bool komeda_format_mod_supported(struct komeda_format_caps_table *table,
> -				 u32 layer_type, u32 fourcc, u64 modifier);
> +				 u32 layer_type, u32 fourcc, u64 modifier,
> +				 u32 rot);
>  
>  #endif
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
> index d0e713a..5f63dec 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
> @@ -240,20 +240,20 @@ struct drm_framebuffer *
>  }
>  
>  /* if the fb can be supported by a specific layer */
> -bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type)
> +bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type,
> +				  u32 rot)
>  {
>  	struct drm_framebuffer *fb = &kfb->base;
>  	struct komeda_dev *mdev = fb->dev->dev_private;
> -	const struct komeda_format_caps *caps;
>  	u32 fourcc = fb->format->format;
>  	u64 modifier = fb->modifier;
> +	bool supported;
>  
> -	caps = komeda_get_format_caps(&mdev->fmt_tbl, fourcc, modifier);
> -	if (!caps)
> -		return false;
> +	supported = komeda_format_mod_supported(&mdev->fmt_tbl, layer_type,
> +						fourcc, modifier, rot);
> +	if (!supported)
> +		DRM_DEBUG_ATOMIC("Layer TYPE: %d doesn't support fb FMT: %s.\n",
> +			layer_type, komeda_get_format_name(fourcc, modifier));
>  
> -	if (!(caps->supported_layer_types & layer_type))
> -		return false;
> -
> -	return true;
> +	return supported;
>  }
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h
> index e3bab0d..6cbb2f6 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h
> @@ -35,9 +35,10 @@ struct komeda_fb {
>  
>  struct drm_framebuffer *
>  komeda_fb_create(struct drm_device *dev, struct drm_file *file,
> -		 const struct drm_mode_fb_cmd2 *mode_cmd);
> +		const struct drm_mode_fb_cmd2 *mode_cmd);
>  dma_addr_t
>  komeda_fb_get_pixel_addr(struct komeda_fb *kfb, int x, int y, int plane);
> -bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type);
> +bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type,
> +		u32 rot);
>  
>  #endif
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> index 34737c0..042d4d7 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_pipeline_state.c
> @@ -274,6 +274,11 @@ struct komeda_pipeline_state *
>  		       struct komeda_plane_state *kplane_st,
>  		       struct komeda_data_flow_cfg *dflow)
>  {
> +	struct komeda_fb *kfb = to_kfb(kplane_st->base.fb);
> +
> +	if (!komeda_fb_is_layer_supported(kfb, layer->layer_type, dflow->rot))
> +		return -EINVAL;
> +
>  	if (!in_range(&layer->hsize_in, dflow->in_w)) {
>  		DRM_DEBUG_ATOMIC("src_w: %d is out of range.\n", dflow->in_w);
>  		return -EINVAL;
> @@ -359,7 +364,8 @@ struct komeda_pipeline_state *
>  	struct komeda_layer_state *st;
>  	int i;
>  
> -	if (!komeda_fb_is_layer_supported(kfb, wb_layer->layer_type))
> +	if (!komeda_fb_is_layer_supported(kfb, wb_layer->layer_type,
> +					  dflow->rot))
>  		return -EINVAL;
>  
>  	c_st = komeda_component_get_state_and_set_user(&wb_layer->base,
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
> index c9f37ff..798ee24 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
> @@ -216,7 +216,7 @@ static void komeda_plane_reset(struct drm_plane *plane)
>  	u32 layer_type = kplane->layer->layer_type;
>  
>  	return komeda_format_mod_supported(&mdev->fmt_tbl, layer_type,
> -					   format, modifier);
> +					   format, modifier, 0);
>  }
>  
>  static const struct drm_plane_funcs komeda_plane_funcs = {
> -- 
> 1.9.1
> 

LGTM.

Reviewed-by: James Qian Wang (Arm Technology China) <james.qian.wang@arm.com>

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

end of thread, other threads:[~2019-05-28  6:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-28  3:56 [PATCH v3 0/2] drm/komeda: Add rotation support on Komeda driver Lowry Li (Arm Technology China)
2019-05-28  3:57 ` [PATCH v3 1/2] " Lowry Li (Arm Technology China)
2019-05-28  6:08   ` james qian wang (Arm Technology China)
2019-05-28  3:57 ` [PATCH v3 2/2] drm/komeda: Adds limitation check for AFBC wide block not support Rot90 Lowry Li (Arm Technology China)
2019-05-28  6:14   ` james qian wang (Arm Technology China)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).