Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2583996pxa; Mon, 24 Aug 2020 19:33:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuLKfABBDqi7gZzQqhbFYGYHGJtEEX0Bn+lgq+w3qPOuhRDqnJ7bOvZ8T+8FZ/Fqw+7itB X-Received: by 2002:a05:6402:22ab:: with SMTP id cx11mr8466888edb.102.1598322821565; Mon, 24 Aug 2020 19:33:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598322821; cv=none; d=google.com; s=arc-20160816; b=zutIe8kKILvkcBrbUx2kjx90Hye2xgO6cLMN9IvyBUH0yfIMdQKpxeKfVUGyVn2jG8 DDaEvtjIl0anFq3zHb5WEoU+bpivzf16gqo+Xdv4vzO7lSrBoM8vmN/od226SSxWnf1v BeQZrTAH70ga5TbAt4Op7Tq8GsFyWzx2kI076GJm0e/SYW1JJGC5cjtMhBOEw10VqzSd 0X52gUrv4/PpNqhax4uSbYJxvVSonvW6m6Wz2bFIzXhJ2/jT0fqGK12GWAcbb5P3EQOX +SMih+YgbAnHyzjCMDbNUJAIfDd8vqkFr9YUhSg81ox/dLFgdaiqs4f7T6gnUnCxCzX8 AwLw== 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=UVrepQbKS5smnSSp+87jEgzSFfpHNiyewdFx9duqOuI=; b=HnFpXC9StUsElCEH+W9gmw0x871TbI5YITxw9q43SlT/2vu1gHdix9AhExXPxirKYI knOvrEh/EQwz1dOHXNAP6mR00LT0UyJucr1MbIIJK6wE7wTNr6PBt/gkTofJ27O9VRSm 8LkgLORMh8QoQgPxMpwfpW9WDzuRKaeNS8pQ3zvA7N7fiprBOhbCO5X+4c53UmxUw6bg qIBaX9h0A/+6hjaSQtL4kspBFimkxNgF5v+7hDwgWLIA19Afdqe3EHAhP+VAmua7PFGf 5ypsugXs4MRUhE46wm8dR7M9z/nzTDE98tkQTnjXvaCdQHvcwnB/rRSgNYtwMmxZD1up N6HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nRvBhDEI; 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 l7si9286119edv.419.2020.08.24.19.33.18; Mon, 24 Aug 2020 19:33:41 -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=nRvBhDEI; 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 S1728110AbgHYCcH (ORCPT + 99 others); Mon, 24 Aug 2020 22:32:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727935AbgHYCcB (ORCPT ); Mon, 24 Aug 2020 22:32:01 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C73C3C061755 for ; Mon, 24 Aug 2020 19:32:00 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id s16so8013594qtn.7 for ; Mon, 24 Aug 2020 19:32:00 -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=UVrepQbKS5smnSSp+87jEgzSFfpHNiyewdFx9duqOuI=; b=nRvBhDEI2BV+7EkphcVZVX66VEDD/PwjhzFsTQK4NxX+EE6wLIEL664mNEQMeaUFKx OS1dJafMgXYxr8be451Uq1L8f1iq5lfV0il3Y1wQ7YUQhAQrqMvtH3kLIOe3J4znjE1s tPTo5RNXQtnvydNifkvx3L+nuKPNf/EPeNIbFLdXf+mXFzZp3AHcQDcuE9QpUXDAiJx2 gd+Tmk4/NX3ImimYlJHQTLJcsf+SRjrFMrPOlNI6PcVZngoHv4W8XVRBTlAWJmReIpxC phUE1ngDlu0uCM/dUBIe4y7xLRpluQ74HrtCWtFilFkALDIZjw+M4wCFqAYnzqS1GKL7 Ip1w== 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=UVrepQbKS5smnSSp+87jEgzSFfpHNiyewdFx9duqOuI=; b=VFro7LLmVS+okjtRndgPbB40N5FxCaCzbEfa/C34psGxPlgHvWiMuBKj/TlIfula/n qAzHvrlzmbpeYdLoUIiUorasYgD/iROi2MB8xCv/DHtwMgl5Jl1xQadtEvBFCvtDHhSW /yWSWQeZzg+aSl/k49isUfhEbURPXAGQRJkSGgXL+zKfsLcH36EjLTJ4Z5y7p/GCMct1 20W3V2RkbYkCykmVC4Hvkj675TbyG9YpA/bn9gk2Xhq2ZkiK4zYt+ZJWI3dCtp9Vphkw Z1ixl8i2/rD7219uaL5VAZgavSJlgediee86qAa2GbnLDC+zYhC8Ntt1ZauPTsT4kGw6 J8BA== X-Gm-Message-State: AOAM531CqaR/30eLCuIxeT59IEwTxUzuozPFvbTRnGSTUtFxJ9sQL6wh YqgeyRvHaNVHOwbhCMxjhEXh6qKtmec= X-Received: by 2002:ac8:4652:: with SMTP id f18mr7395756qto.142.1598322719808; Mon, 24 Aug 2020 19:31:59 -0700 (PDT) Received: from atma2.hitronhub.home ([2607:fea8:56e0:6d60::2db6]) by smtp.gmail.com with ESMTPSA id x137sm11095372qkb.47.2020.08.24.19.31.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2020 19:31:59 -0700 (PDT) From: Rodrigo Siqueira To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Brian Starkey , Liviu Dudau , Daniel Vetter , Simon Ser , Leandro Ribeiro , melissa.srw@gmail.com, daniels@collabora.com, Emil Velikov Subject: [PATCH v5 2/3] drm/vkms: Compute CRC without change input data Date: Mon, 24 Aug 2020 22:31:41 -0400 Message-Id: <20200825023142.2561220-3-rodrigosiqueiramelo@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200825023142.2561220-1-rodrigosiqueiramelo@gmail.com> References: <20200825023142.2561220-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 V4 (Emil): - Move bitmap_clear operation and comments to get_pixel function Signed-off-by: Rodrigo Siqueira --- 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