2019-07-10 02:07:36

by Rodrigo Siqueira

[permalink] [raw]
Subject: [PATCH 0/2] drm/vkms: Use alpha value for blending

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


Attachments:
(No filename) (686.00 B)
signature.asc (849.00 B)
Download all attachments

2019-07-10 02:08:15

by Rodrigo Siqueira

[permalink] [raw]
Subject: [PATCH 2/2] drm/vkms: Use alpha channel for blending cursor with primary

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 <[email protected]>
Cc: Mamta Shukla <[email protected]>
Cc: Harry Wentland <[email protected]>
Cc: Daniel Vetter <[email protected]>
Signed-off-by: Rodrigo Siqueira <[email protected]>
---
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


Attachments:
(No filename) (1.88 kB)
signature.asc (849.00 B)
Download all attachments

2019-07-10 17:09:41

by Daniel Vetter

[permalink] [raw]
Subject: Re: [PATCH 0/2] drm/vkms: Use alpha value for blending

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