linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/arm/malidp: Disable pixel alpha blending for colors that do not have alpha
@ 2018-01-23 16:49 Ayan Kumar Halder
  2018-01-24 10:30 ` Liviu Dudau
  0 siblings, 1 reply; 2+ messages in thread
From: Ayan Kumar Halder @ 2018-01-23 16:49 UTC (permalink / raw)
  To: liviu.dudau, brian.starkey, malidp, airlied, dri-devel, linux-kernel
  Cc: nd, Ayan Halder

From: Ayan Halder <ayan.halder@arm.com>

Mali dp needs to disable pixel alpha blending (use layer alpha blending) to
display color formats that do not contain alpha bits per pixel

This patch depends on:

"[PATCH v2 01/19] drm/fourcc: Add a alpha field to drm_format_info"

Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
---
Change in v2:
- Use struct drm_format_info->has_alpha (boolean) to determine if a color
format has alpha channel

 drivers/gpu/drm/arm/malidp_planes.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
index e741979..3b445d9 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -35,6 +35,9 @@
 #define   LAYER_COMP_MASK		(0x3 << 12)
 #define   LAYER_COMP_PIXEL		(0x3 << 12)
 #define   LAYER_COMP_PLANE		(0x2 << 12)
+#define   LAYER_ALPHA_OFFSET		(16)
+#define   LAYER_ALPHA_MASK		(0xff)
+#define   LAYER_ALPHA(x)		(((x) & LAYER_ALPHA_MASK) << LAYER_ALPHA_OFFSET)
 #define MALIDP_LAYER_COMPOSE		0x008
 #define MALIDP_LAYER_SIZE		0x00c
 #define   LAYER_H_VAL(x)		(((x) & 0x1fff) << 0)
@@ -268,6 +271,7 @@ static void malidp_de_plane_update(struct drm_plane *plane,
 	struct malidp_plane_state *ms = to_malidp_plane_state(plane->state);
 	u32 src_w, src_h, dest_w, dest_h, val;
 	int i;
+	bool format_has_alpha = plane->state->fb->format->has_alpha;
 
 	mp = to_malidp_plane(plane);
 
@@ -319,12 +323,25 @@ static void malidp_de_plane_update(struct drm_plane *plane,
 	if (plane->state->rotation & DRM_MODE_REFLECT_Y)
 		val |= LAYER_V_FLIP;
 
-	/*
-	 * always enable pixel alpha blending until we have a way to change
-	 * blend modes
-	 */
 	val &= ~LAYER_COMP_MASK;
-	val |= LAYER_COMP_PIXEL;
+	if (format_has_alpha) {
+
+		/*
+		 * always enable pixel alpha blending until we have a way
+		 * to change blend modes
+		 */
+		val |= LAYER_COMP_PIXEL;
+	} else {
+
+		/*
+		 * do not enable pixel alpha blending as the color channel
+		 * does not have any alpha information
+		 */
+		val |= LAYER_COMP_PLANE;
+
+		/* Set layer alpha coefficient to 0xff ie fully opaque */
+		val |= LAYER_ALPHA(0xff);
+	}
 
 	val &= ~LAYER_FLOWCFG(LAYER_FLOWCFG_MASK);
 	if (plane->state->crtc) {
-- 
2.7.4

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

* Re: [PATCH v2] drm/arm/malidp: Disable pixel alpha blending for colors that do not have alpha
  2018-01-23 16:49 [PATCH v2] drm/arm/malidp: Disable pixel alpha blending for colors that do not have alpha Ayan Kumar Halder
@ 2018-01-24 10:30 ` Liviu Dudau
  0 siblings, 0 replies; 2+ messages in thread
From: Liviu Dudau @ 2018-01-24 10:30 UTC (permalink / raw)
  To: Ayan Kumar Halder
  Cc: brian.starkey, malidp, airlied, dri-devel, linux-kernel, nd

On Tue, Jan 23, 2018 at 04:49:29PM +0000, Ayan Kumar Halder wrote:
> From: Ayan Halder <ayan.halder@arm.com>
> 
> Mali dp needs to disable pixel alpha blending (use layer alpha blending) to
> display color formats that do not contain alpha bits per pixel
> 
> This patch depends on:
> 
> "[PATCH v2 01/19] drm/fourcc: Add a alpha field to drm_format_info"
> 
> Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>

Hi Ayan,

Thanks for the updated v2. I'll drop the v1 from my tree and use this
one once Maxime's patches are in drm-misc.

For this patch:

Acked-by: Liviu Dudau <liviu.dudau@arm.com>

Best regards,
Liviu


> ---
> Change in v2:
> - Use struct drm_format_info->has_alpha (boolean) to determine if a color
> format has alpha channel
> 
>  drivers/gpu/drm/arm/malidp_planes.c | 27 ++++++++++++++++++++++-----
>  1 file changed, 22 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
> index e741979..3b445d9 100644
> --- a/drivers/gpu/drm/arm/malidp_planes.c
> +++ b/drivers/gpu/drm/arm/malidp_planes.c
> @@ -35,6 +35,9 @@
>  #define   LAYER_COMP_MASK		(0x3 << 12)
>  #define   LAYER_COMP_PIXEL		(0x3 << 12)
>  #define   LAYER_COMP_PLANE		(0x2 << 12)
> +#define   LAYER_ALPHA_OFFSET		(16)
> +#define   LAYER_ALPHA_MASK		(0xff)
> +#define   LAYER_ALPHA(x)		(((x) & LAYER_ALPHA_MASK) << LAYER_ALPHA_OFFSET)
>  #define MALIDP_LAYER_COMPOSE		0x008
>  #define MALIDP_LAYER_SIZE		0x00c
>  #define   LAYER_H_VAL(x)		(((x) & 0x1fff) << 0)
> @@ -268,6 +271,7 @@ static void malidp_de_plane_update(struct drm_plane *plane,
>  	struct malidp_plane_state *ms = to_malidp_plane_state(plane->state);
>  	u32 src_w, src_h, dest_w, dest_h, val;
>  	int i;
> +	bool format_has_alpha = plane->state->fb->format->has_alpha;
>  
>  	mp = to_malidp_plane(plane);
>  
> @@ -319,12 +323,25 @@ static void malidp_de_plane_update(struct drm_plane *plane,
>  	if (plane->state->rotation & DRM_MODE_REFLECT_Y)
>  		val |= LAYER_V_FLIP;
>  
> -	/*
> -	 * always enable pixel alpha blending until we have a way to change
> -	 * blend modes
> -	 */
>  	val &= ~LAYER_COMP_MASK;
> -	val |= LAYER_COMP_PIXEL;
> +	if (format_has_alpha) {
> +
> +		/*
> +		 * always enable pixel alpha blending until we have a way
> +		 * to change blend modes
> +		 */
> +		val |= LAYER_COMP_PIXEL;
> +	} else {
> +
> +		/*
> +		 * do not enable pixel alpha blending as the color channel
> +		 * does not have any alpha information
> +		 */
> +		val |= LAYER_COMP_PLANE;
> +
> +		/* Set layer alpha coefficient to 0xff ie fully opaque */
> +		val |= LAYER_ALPHA(0xff);
> +	}
>  
>  	val &= ~LAYER_FLOWCFG(LAYER_FLOWCFG_MASK);
>  	if (plane->state->crtc) {
> -- 
> 2.7.4
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

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

end of thread, other threads:[~2018-01-24 10:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-23 16:49 [PATCH v2] drm/arm/malidp: Disable pixel alpha blending for colors that do not have alpha Ayan Kumar Halder
2018-01-24 10:30 ` Liviu Dudau

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).