From patchwork Wed Jun 26 01:38:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 11016719 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE2DE924 for ; Wed, 26 Jun 2019 01:38:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA582271CB for ; Wed, 26 Jun 2019 01:38:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAABB285F2; Wed, 26 Jun 2019 01:38:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6EF3B271CB for ; Wed, 26 Jun 2019 01:38:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8701A6E1D3; Wed, 26 Jun 2019 01:38:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by gabe.freedesktop.org (Postfix) with ESMTPS id 206FC6E1D3 for ; Wed, 26 Jun 2019 01:38:37 +0000 (UTC) Received: by mail-qk1-x744.google.com with SMTP id i125so346924qkd.6 for ; Tue, 25 Jun 2019 18:38:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=VhvsA2mFJL5Xe5+RHkMF0VDR29nwFdCWp8jzkz78NKs=; b=JuEY+K+Q7LNXdcwF6pFIDekSRRucFs+z/FnytpMhGK59dGIdcaianMYbAbJjN5LILh gfLqZYVdxuaEMJeqiwlOkufhabGgsUM8CeLVMauzLramsxfiExbIGcPlwRD92YjxVRrN FpQ3fMnDNteGPEcjQkMLmEMBoRWatnOM5CeVjAFfX0ASC+1zCb0kh3AtuLKpSSRQd7Fx +LQMKnTdbSmwpjU4MZ5Yq1/MPEBHuqXSp9alTA7XS/0T2CE293K0H/EcEiijoduEf8BF BJnvLuK66TfOkihu6cm/V7W7ytlWOV7QOpdE8p5k03F1So1E3UTFD+XZbOi6bWNwpRXx FUMA== X-Gm-Message-State: APjAAAX7PYi6IFMgKB1lHcSP6xhdXo1WkX0OqbK1onmwBBTTpPhsFNKT dRaMl0NmLDpMML+7UgPptaI= X-Google-Smtp-Source: APXvYqxZZf0LF7ILRzNdTHyeclwzLjQ3OWXOXs+v+XxDfPqPWC8/3w4blmvuCJH391wQzNWiyx780A== X-Received: by 2002:a37:668c:: with SMTP id a134mr1564017qkc.477.1561513116203; Tue, 25 Jun 2019 18:38:36 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id h40sm9967150qth.4.2019.06.25.18.38.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 25 Jun 2019 18:38:35 -0700 (PDT) Date: Tue, 25 Jun 2019 22:38:31 -0300 From: Rodrigo Siqueira To: Brian Starkey , Liviu Dudau , Daniel Vetter , Haneen Mohammed , Simon Ser Subject: [PATCH V3 4/5] drm/vkms: Compute CRC without change input data Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=VhvsA2mFJL5Xe5+RHkMF0VDR29nwFdCWp8jzkz78NKs=; b=rwstq9SV12XPNESW3bHDHzxMr1EbE9kLJvo0w/fufz8IIyTZmnFvZ5I0iflsdlXn1M EZ356wSG1KOO40stlTjAjI/D9Wm64ctkumXNZZIrSFfuyMpm68Xxn1/xGSpDuSxCfvyp nM81CeAOeXw3tiT6smx1EVrBpt08DuAqPWQyWS8yHQ7ZQrtZra7c+V5YSuk+Bm2da2O+ 8myyuA5/z5qJY4aB4EGlNih5NEihjgGWqddNIcPNnao0NReUTUpy8cLiiPq5DPM3haCa HpvJ6m7EtIhDXO9/mE+WUCaTmP/pWcHeGIStjWNU1VBab7O5vZ5c1WDOqx5g8OZ/fX+F 40Jg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/vkms/vkms_composer.c | 31 +++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 51a270514219..8126aa0f968f 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -6,33 +6,40 @@ #include #include +static u32 get_pixel_from_buffer(int x, int y, const u8 *buffer, + const struct vkms_composer *composer) +{ + int src_offset = composer->offset + (y * composer->pitch) + + (x * composer->cpp); + + return *(u32 *)&buffer[src_offset]; +} + /** * 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; 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; + u32 crc = 0, pixel = 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); + for (y = y_src; y < y_src + h_src; ++y) { + for (x = x_src; x < x_src + w_src; ++x) { /* XRGB format ignores Alpha channel */ - memset(vaddr_out + src_offset + 24, 0, 8); - crc = crc32_le(crc, vaddr_out + src_offset, - sizeof(u32)); + pixel = get_pixel_from_buffer(x, y, vaddr, composer); + bitmap_clear((void *)&pixel, 0, 8); + crc = crc32_le(crc, (void *)&pixel, sizeof(u32)); } }