linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] drm/vkms: Use alpha value for blending
@ 2019-07-10  1:52 Rodrigo Siqueira
  2019-07-10  1:53 ` [PATCH 1/2] drm/vkms: Rework blend function Rodrigo Siqueira
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rodrigo Siqueira @ 2019-07-10  1:52 UTC (permalink / raw)
  To: Daniel Vetter, Haneen Mohammed, David Airlie, Simon Ser,
	Oleg Vasilev, Mamta Shukla, Harry Wentland
  Cc: dri-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 686 bytes --]

The first patch of this series reworks part of the blend function to
improve the readability and also for preparing it for using alpha value.
The second patch updates the blend function for applying alpha value for
a fully transparent blend. After applying this patchset,
pipe-a-cursor-alpha-transparent in kms_cursor_crc start to pass.

This patchset depends on:
https://patchwork.freedesktop.org/series/61738/

Rodrigo Siqueira (2):
  drm/vkms: Rework blend function
  drm/vkms: Use alpha channel for blending cursor with primary

 drivers/gpu/drm/vkms/vkms_composer.c | 54 ++++++++++++++++++++--------
 1 file changed, 39 insertions(+), 15 deletions(-)

-- 
2.21.0

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* [PATCH 1/2] drm/vkms: Rework blend function
  2019-07-10  1:52 [PATCH 0/2] drm/vkms: Use alpha value for blending Rodrigo Siqueira
@ 2019-07-10  1:53 ` Rodrigo Siqueira
  2019-07-10  1:54 ` [PATCH 2/2] drm/vkms: Use alpha channel for blending cursor with primary Rodrigo Siqueira
  2019-07-10 16:46 ` [PATCH 0/2] drm/vkms: Use alpha value for blending Daniel Vetter
  2 siblings, 0 replies; 4+ messages in thread
From: Rodrigo Siqueira @ 2019-07-10  1:53 UTC (permalink / raw)
  To: Daniel Vetter, Haneen Mohammed, David Airlie, Simon Ser,
	Oleg Vasilev, Mamta Shukla, Harry Wentland
  Cc: dri-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3164 bytes --]

For combining the cursor into the primary plane, vkms invokes a function
named blend which iterates in both buffers and ends up by copying the
cursor into the primary buffer. This patch, rework part of the blend
function to prepare it for using the alpha channel for blending.

Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
Cc: Mamta Shukla <mamtashukla555@gmail.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
---
 drivers/gpu/drm/vkms/vkms_composer.c | 39 +++++++++++++++++-----------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
index 2317803e7320..fb106964d8bf 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -15,6 +15,17 @@ static u32 get_pixel_from_buffer(int x, int y, const u8 *buffer,
 	return *(u32 *)&buffer[src_offset];
 }
 
+static void set_pixel(int x, int y, u8 *buffer,
+		      const struct vkms_composer *composer, const u32 value)
+{
+	int offset = composer->offset + (y * composer->pitch)
+				      + (x * composer->cpp);
+	u32 *dst;
+
+	dst = (u32 *)&buffer[offset];
+	*dst = value;
+}
+
 /**
  * compute_crc - Compute CRC value on output frame
  *
@@ -50,7 +61,7 @@ static uint32_t compute_crc(const u8 *vaddr,
  * blend - belnd value at vaddr_src with value at vaddr_dst
  * @vaddr_dst: destination address
  * @vaddr_src: source address
- * @dest_composer: destination framebuffer's metadata
+ * @dst_composer: destination framebuffer's metadata
  * @src_composer: source framebuffer's metadata
  *
  * Blend value at vaddr_src with value at vaddr_dst.
@@ -62,11 +73,10 @@ static uint32_t compute_crc(const u8 *vaddr,
  *	 instead of overwriting it.
  */
 static void blend(void *vaddr_dst, void *vaddr_src,
-		  struct vkms_composer *dest_composer,
+		  struct vkms_composer *dst_composer,
 		  struct vkms_composer *src_composer)
 {
-	int i, j, j_dst, i_dst;
-	int offset_src, offset_dst;
+	int y, x, j_dst, i_dst;
 
 	int x_src = src_composer->src.x1 >> 16;
 	int y_src = src_composer->src.y1 >> 16;
@@ -79,17 +89,16 @@ static void blend(void *vaddr_dst, void *vaddr_src,
 	int y_limit = y_src + h_dst;
 	int x_limit = x_src + w_dst;
 
-	for (i = y_src, i_dst = y_dst; i < y_limit; ++i) {
-		for (j = x_src, j_dst = x_dst; j < x_limit; ++j) {
-			offset_dst = dest_composer->offset
-				     + (i_dst * dest_composer->pitch)
-				     + (j_dst++ * dest_composer->cpp);
-			offset_src = src_composer->offset
-				     + (i * src_composer->pitch)
-				     + (j * src_composer->cpp);
-
-			memcpy(vaddr_dst + offset_dst,
-			       vaddr_src + offset_src, sizeof(u32));
+	u32 pixel_src;
+
+	for (y = y_src, i_dst = y_dst; y < y_limit; ++y) {
+		for (x = x_src, j_dst = x_dst; x < x_limit; ++x) {
+			pixel_src = get_pixel_from_buffer(x, y,
+							  vaddr_src,
+							  src_composer);
+			set_pixel(j_dst, i_dst, vaddr_dst, dest_composer,
+				  pixel_src);
+			j_dst++;
 		}
 		i_dst++;
 	}
-- 
2.21.0

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* [PATCH 2/2] drm/vkms: Use alpha channel for blending cursor with primary
  2019-07-10  1:52 [PATCH 0/2] drm/vkms: Use alpha value for blending Rodrigo Siqueira
  2019-07-10  1:53 ` [PATCH 1/2] drm/vkms: Rework blend function Rodrigo Siqueira
@ 2019-07-10  1:54 ` Rodrigo Siqueira
  2019-07-10 16:46 ` [PATCH 0/2] drm/vkms: Use alpha value for blending Daniel Vetter
  2 siblings, 0 replies; 4+ messages in thread
From: Rodrigo Siqueira @ 2019-07-10  1:54 UTC (permalink / raw)
  To: Daniel Vetter, Haneen Mohammed, David Airlie, Simon Ser,
	Oleg Vasilev, Mamta Shukla, Harry Wentland
  Cc: dri-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1929 bytes --]

Currently, the blend function overwriting the cursor value into the
primary plane. This patch utilizes the alpha value for a fully
transparent blend of the cursor (vaddr_src) with primary (vaddr_dst)
instead of overwriting it in blend().

Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
Cc: Mamta Shukla <mamtashukla555@gmail.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
---
 drivers/gpu/drm/vkms/vkms_composer.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
index fb106964d8bf..bb758a5131a4 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -26,6 +26,17 @@ static void set_pixel(int x, int y, u8 *buffer,
 	*dst = value;
 }
 
+static u32 apply_alpha(u32 src, u32 dst)
+{
+	u8 alpha;
+	u32 k;
+
+	alpha = src >> 24;
+	alpha = (alpha + 1) >> 8;
+	k = (alpha << 24) - alpha;
+	return (k & src) | (~k & dst);
+}
+
 /**
  * compute_crc - Compute CRC value on output frame
  *
@@ -89,15 +100,19 @@ static void blend(void *vaddr_dst, void *vaddr_src,
 	int y_limit = y_src + h_dst;
 	int x_limit = x_src + w_dst;
 
-	u32 pixel_src;
+	u32 pixel_src, pixel_dst, new_pixel;
 
 	for (y = y_src, i_dst = y_dst; y < y_limit; ++y) {
 		for (x = x_src, j_dst = x_dst; x < x_limit; ++x) {
 			pixel_src = get_pixel_from_buffer(x, y,
 							  vaddr_src,
 							  src_composer);
-			set_pixel(j_dst, i_dst, vaddr_dst, dest_composer,
-				  pixel_src);
+			pixel_dst = get_pixel_from_buffer(j_dst, i_dst,
+							  vaddr_dst,
+							  dst_composer);
+			new_pixel = apply_alpha(pixel_src, pixel_dst);
+			set_pixel(j_dst, i_dst, vaddr_dst, dst_composer,
+				  new_pixel);
 			j_dst++;
 		}
 		i_dst++;
-- 
2.21.0

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 0/2] drm/vkms: Use alpha value for blending
  2019-07-10  1:52 [PATCH 0/2] drm/vkms: Use alpha value for blending Rodrigo Siqueira
  2019-07-10  1:53 ` [PATCH 1/2] drm/vkms: Rework blend function Rodrigo Siqueira
  2019-07-10  1:54 ` [PATCH 2/2] drm/vkms: Use alpha channel for blending cursor with primary Rodrigo Siqueira
@ 2019-07-10 16:46 ` Daniel Vetter
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2019-07-10 16:46 UTC (permalink / raw)
  To: Rodrigo Siqueira
  Cc: Daniel Vetter, Haneen Mohammed, David Airlie, Simon Ser,
	Oleg Vasilev, Mamta Shukla, Harry Wentland, dri-devel,
	linux-kernel

On Tue, Jul 09, 2019 at 10:52:02PM -0300, Rodrigo Siqueira wrote:
> The first patch of this series reworks part of the blend function to
> improve the readability and also for preparing it for using alpha value.
> The second patch updates the blend function for applying alpha value for
> a fully transparent blend. After applying this patchset,
> pipe-a-cursor-alpha-transparent in kms_cursor_crc start to pass.

Looking at the series I wonder whether we should go right ahead to
reworking the entire composer pipeline to future proof it for multiple
planes and other pixel modes. Or whether enabling alpha blending with what
we have now is a better idea, but that means more complicated refactoring
later on ...

> This patchset depends on:
> https://patchwork.freedesktop.org/series/61738/

Ok I guess I need to look at this one here first.
-Daniel

> 
> Rodrigo Siqueira (2):
>   drm/vkms: Rework blend function
>   drm/vkms: Use alpha channel for blending cursor with primary
> 
>  drivers/gpu/drm/vkms/vkms_composer.c | 54 ++++++++++++++++++++--------
>  1 file changed, 39 insertions(+), 15 deletions(-)
> 
> -- 
> 2.21.0



-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

end of thread, other threads:[~2019-07-10 16:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-10  1:52 [PATCH 0/2] drm/vkms: Use alpha value for blending Rodrigo Siqueira
2019-07-10  1:53 ` [PATCH 1/2] drm/vkms: Rework blend function Rodrigo Siqueira
2019-07-10  1:54 ` [PATCH 2/2] drm/vkms: Use alpha channel for blending cursor with primary Rodrigo Siqueira
2019-07-10 16:46 ` [PATCH 0/2] drm/vkms: Use alpha value for blending Daniel Vetter

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