Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp388726pxk; Sun, 30 Aug 2020 07:23:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWTisbU6VzFZCaCyLhTMS5eQQCLdApJTa0ARpbNFX+PKqMjYUsnwBA945wGs9jaNx9ocQ2 X-Received: by 2002:a17:906:7f0b:: with SMTP id d11mr8380430ejr.116.1598797386334; Sun, 30 Aug 2020 07:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598797386; cv=none; d=google.com; s=arc-20160816; b=X/ptl/sORcvVUuyfqoe1yq0lIeKeOzGe4AdLGdwKxyAfPA6nYFXSSU58w4YujHM/gR x5cFFXeij/IOLAUZAjwdLXicsHs6xU/ZyU+e1I7TM+Q5PYhDNxVkby09qpUZ2yUBxbbv 1TsAi4JGzxunVRLWcmfPAEikc894LoH4cvQaPHpsbYevbBXYiCDXIWiC7jEE+D3eK2qQ nCYqn/uRrQcRErZ+s6OpSvOf7lan0N6t5AHDWHMIHpgtyUKOYNxDZMlAUWhP3vFFsXnw dgLmsgBB2phPKT1+foSQdEIsRuUM50gg2QqruGTz1iNBRxCdN6fctFHV7X9JCXxGIQdp MV2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3bwWKMSkRvOEL7YPRUvfw4HtVpw9bW0LN4U6a+UXn+Q=; b=TdcCkle6KkIkvXUanAKz0tpNei1jWBwXCvaiCN2fSYUeGX5vC0nqRpItZSJLIHFmB0 R2EXh0IukUd/3rnEVKDciGiHTykQnUpTxye7ggiywlmiNt7gd9u6llinh+Z+b6TNV0cA Y9ej7pTlBRXMA4F1ZhDRFzQxaN0U5u8riQykXCa3Sr21SRquKBNNNQCmcIFwqx6QN9+D HOwpGDwZeR6jJJ6ZSOloSsXRLW3wg9Uh6vkJoF7AG3cpIOZcTxelRUoTTNqxPnYzh/sy BTvIAHzqLJyyBkKhN9IY0kdGSUpdKQoePyKRcbgYVq20d5LC6YjJenlrUWU0D8UHOVzk Xc4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TufzN+pN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e24si3341800eds.212.2020.08.30.07.22.43; Sun, 30 Aug 2020 07:23:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TufzN+pN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726881AbgH3OVM (ORCPT + 99 others); Sun, 30 Aug 2020 10:21:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726126AbgH3OUh (ORCPT ); Sun, 30 Aug 2020 10:20:37 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51C68C061236 for ; Sun, 30 Aug 2020 07:20:37 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id w186so4002088qkd.1 for ; Sun, 30 Aug 2020 07:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3bwWKMSkRvOEL7YPRUvfw4HtVpw9bW0LN4U6a+UXn+Q=; b=TufzN+pNu74PL6ESl+o6lR3qczJn4loFbgr5N0BarA4Pbscrm+frzq70lvB8EhtG+t P5s2t1Hjk+t0zDmsFl/Ws54uZpVilXQQW6QMU82/dV8hfLfElNMNkQ85Q9+z9NjOTfc5 cLwagE1GrgGsVX8SLilPtnqOIYPTEKvFFmwDrhlzlvCmSDLNKx9cz7LGOH5Qz/yUf/JY qPWHRXFx1aMfXeezKG96O+b9V9F0b7kqnEVTHsyOAIcLfN82O16nykd1Zaks42Ipt/hr i6GuhouHzMMrqnbzox3VPvyRfagVOtyHNQsX6/Jr9YMzwr+Ini7soxhqfI/tQ0DDPyFp C57g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3bwWKMSkRvOEL7YPRUvfw4HtVpw9bW0LN4U6a+UXn+Q=; b=h+cnwBjgUHYeDB8tzHrliqb0pTXDue1cQLz7sd52AuGwT7FzUqt3uH7d/I9pnLEVKX gqAvT/8qSd4q7K2iYycBXbVakfppExwQlJ864xqTWUXahG5jQHf/yfN8iwItsINduhd2 Ic5QpWpvz9Vqisx+k3dS0wW6I8eMVo7Vh1y6Mlx+ADv4q3b0LuYBxC/UPaFaJAy67GZd ksRU2DfAA9LLOF980QhN6ii+JbM1e5+SjqLvz8KUlTG8vGMp2mW+BCMfBQmzIMIfYWwq JSVbSl6lO5wee7d4B2eMi+80dvq6l3J1yw/zH7XAKL3xeEF2w+g1FpuFCBqpSRhHfcuI vVVw== X-Gm-Message-State: AOAM532OcnAo0CWk3uqxZLrOOX9NDwfmwUCeUSjs9w/XQI6rWJ/9JfVw WhcDcdOQPMJ/IwYyn4aetBdx/dI4LlKUaA== X-Received: by 2002:a37:8601:: with SMTP id i1mr7332702qkd.307.1598797236348; Sun, 30 Aug 2020 07:20:36 -0700 (PDT) Received: from atma2.hitronhub.home ([2607:fea8:56e0:6d60::2db6]) by smtp.gmail.com with ESMTPSA id o72sm5884861qka.113.2020.08.30.07.20.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2020 07:20:35 -0700 (PDT) From: Rodrigo Siqueira To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: melissa.srw@gmail.com, Brian Starkey , Liviu Dudau , Daniel Vetter , Simon Ser , Leandro Ribeiro , daniels@collabora.com, Emil Velikov Subject: [PATCH v6 2/3] drm/vkms: Compute CRC without change input data Date: Sun, 30 Aug 2020 10:19:59 -0400 Message-Id: <20200830142000.146706-3-rodrigosiqueiramelo@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200830142000.146706-1-rodrigosiqueiramelo@gmail.com> References: <20200830142000.146706-1-rodrigosiqueiramelo@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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: Rodrigo Siqueira --- drivers/gpu/drm/vkms/vkms_composer.c | 34 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index f67d1baf1942..c5b32fe5870f 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -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)); } } -- 2.28.0