Commit 60cc2021 authored by Rodrigo Siqueira's avatar Rodrigo Siqueira

drm/vkms: Compute CRC without change input data

This commit decouples pixel manipulation from compute_crc() for avoiding
any pixel change during the CRC calculation. This commits represents a
preparation work for making VKMS able to support the writeback feature.

Change in V5 (Melissa):
- Rebase and drop bitmap for alpha
Change in V4 (Emil):
- Move bitmap_clear operation and comments to get_pixel function
Signed-off-by: default avatarRodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Reviewed-by: default avatarMelissa Wen <melissa.srw@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200830142000.146706-3-rodrigosiqueiramelo@gmail.com
parent 95302576
......@@ -9,31 +9,41 @@
#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];
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);
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));
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment