[PATCH 1/2] drm/vkms: Rework blend function

From: Rodrigo Siqueira
Date: Tue Jul 09 2019 - 21:53:18 EST


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@xxxxxxxxx>
Cc: Mamta Shukla <mamtashukla555@xxxxxxxxx>
Cc: Harry Wentland <harry.wentland@xxxxxxx>
Cc: Daniel Vetter <daniel@xxxxxxxx>
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@xxxxxxxxx>
---
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: signature.asc
Description: PGP signature