From: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Cc: Brian Starkey <brian.starkey@arm.com>,
Liviu Dudau <liviu.dudau@arm.com>,
Daniel Vetter <daniel@ffwll.ch>, Simon Ser <contact@emersion.fr>,
Leandro Ribeiro <leandro.ribeiro@collabora.com>,
melissa.srw@gmail.com, daniels@collabora.com,
Emil Velikov <emil.l.velikov@gmail.com>
Subject: [PATCH v5 2/3] drm/vkms: Compute CRC without change input data
Date: Mon, 24 Aug 2020 22:31:41 -0400 [thread overview]
Message-ID: <20200825023142.2561220-3-rodrigosiqueiramelo@gmail.com> (raw)
In-Reply-To: <20200825023142.2561220-1-rodrigosiqueiramelo@gmail.com>
The compute_crc() function is responsible for calculating the
framebuffer CRC value; due to the XRGB format, this function has to
ignore the alpha channel during the CRC computation. Therefore,
compute_crc() set zero to the alpha channel directly in the input
framebuffer, which is not a problem since this function receives a copy
of the original buffer. However, if we want to use this function in a
context without a buffer copy, it will change the initial value. This
patch makes compute_crc() calculate the CRC value without modifying the
input framebuffer.
Change in V4 (Emil):
- Move bitmap_clear operation and comments to get_pixel function
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
---
drivers/gpu/drm/vkms/vkms_composer.c | 38 ++++++++++++++++++----------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
index 4d8bc04bb6ee..387b0690a64a 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -9,33 +9,43 @@
#include "vkms_drv.h"
+static u32 get_pixel_from_buffer(int x, int y, const u8 *buffer,
+ const struct vkms_composer *composer)
+{
+ u32 pixel;
+ int src_offset = composer->offset + (y * composer->pitch)
+ + (x * composer->cpp);
+
+ pixel = *(u32 *)&buffer[src_offset];
+ /* XRGB format ignores Alpha channel */
+ bitmap_clear((void *)&pixel, 0, 8);
+
+ return pixel;
+}
+
/**
* compute_crc - Compute CRC value on output frame
*
- * @vaddr_out: address to final framebuffer
+ * @vaddr: address to final framebuffer
* @composer: framebuffer's metadata
*
* returns CRC value computed using crc32 on the visible portion of
* the final framebuffer at vaddr_out
*/
-static uint32_t compute_crc(void *vaddr_out, struct vkms_composer *composer)
+static uint32_t compute_crc(const u8 *vaddr,
+ const struct vkms_composer *composer)
{
- int i, j, src_offset;
+ int x, y;
+ u32 crc = 0, pixel = 0;
int x_src = composer->src.x1 >> 16;
int y_src = composer->src.y1 >> 16;
int h_src = drm_rect_height(&composer->src) >> 16;
int w_src = drm_rect_width(&composer->src) >> 16;
- u32 crc = 0;
-
- for (i = y_src; i < y_src + h_src; ++i) {
- for (j = x_src; j < x_src + w_src; ++j) {
- src_offset = composer->offset
- + (i * composer->pitch)
- + (j * composer->cpp);
- /* XRGB format ignores Alpha channel */
- bitmap_clear(vaddr_out + src_offset, 24, 8);
- crc = crc32_le(crc, vaddr_out + src_offset,
- sizeof(u32));
+
+ for (y = y_src; y < y_src + h_src; ++y) {
+ for (x = x_src; x < x_src + w_src; ++x) {
+ pixel = get_pixel_from_buffer(x, y, vaddr, composer);
+ crc = crc32_le(crc, (void *)&pixel, sizeof(u32));
}
}
--
2.28.0
next prev parent reply other threads:[~2020-08-25 2:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-25 2:31 [PATCH v5 0/3] drm/vkms: Introduces writeback support Rodrigo Siqueira
2020-08-25 2:31 ` [PATCH v5 1/3] drm/vkms: Decouple crc operations from composer Rodrigo Siqueira
2020-08-25 16:12 ` Melissa Wen
2020-08-25 2:31 ` Rodrigo Siqueira [this message]
2020-08-25 15:42 ` [PATCH v5 2/3] drm/vkms: Compute CRC without change input data Melissa Wen
2020-08-25 2:31 ` [PATCH v5 3/3] drm/vkms: Add support for writeback Rodrigo Siqueira
2020-08-25 15:45 ` Melissa Wen
2020-08-25 16:10 ` Melissa Wen
2020-08-25 16:02 ` [PATCH v5 0/3] drm/vkms: Introduces writeback support Melissa Wen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200825023142.2561220-3-rodrigosiqueiramelo@gmail.com \
--to=rodrigosiqueiramelo@gmail.com \
--cc=brian.starkey@arm.com \
--cc=contact@emersion.fr \
--cc=daniel@ffwll.ch \
--cc=daniels@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=leandro.ribeiro@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=melissa.srw@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®