From patchwork Wed Jul 10 01:53:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 11037703 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 C2C16138D for ; Wed, 10 Jul 2019 01:53:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B043E288A9 for ; Wed, 10 Jul 2019 01:53:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D83728900; Wed, 10 Jul 2019 01:53:16 +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 365B3288A9 for ; Wed, 10 Jul 2019 01:53:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B0638991A; Wed, 10 Jul 2019 01:53:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2C8068991A for ; Wed, 10 Jul 2019 01:53:13 +0000 (UTC) Received: by mail-qk1-x743.google.com with SMTP id g18so700420qkl.3 for ; Tue, 09 Jul 2019 18:53:13 -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=FKfKo9B1CRcLmq9txqUh+s6WgoiWvagwqjoqjlaktJU=; b=LHqgQlYGoxIR6R3condMQDeyJ0IJl3rL27/dhVw/SrDq1MgsOFRDqa1JIVlsffHlVg BmlLsOmZYemXB4ESDRRWgis0d4nP5fGkq83X2qokJR+xAIVu5/HGr3pvgiJs43+XxMDo zVKa/nWqMXU71Ccw5U3PTaHaXH66rAgeobTBvu0Hm4LG81F7rrcZli+Tdy0TSSZSGQ4U VDf8PKfiaGKqpcWRQ4Y5/NxpBMGFixC3PilMiQVyMkkZ2VfXT9wDNydTcCyX1M7Cb19W j3PZAMfaUn7+fTTuRlFQLU9KCpICBXSGX2btV0ExXl+BtJJJtOb5YdJU1bksLNbiF4HF UWIQ== X-Gm-Message-State: APjAAAWRqVoDZ8yO005E1mJMofV9QR1o3c+qzg8b++c1nes9QLruV9H1 oLJm9pIkG6OkxUd1n56N1jA= X-Google-Smtp-Source: APXvYqyZjtPAFXEGx7q45BTzK4GpDZO61jVLHi6J+VWw6K/jS1ABqei5HrMR7yozVU/yyBtdt5MQYg== X-Received: by 2002:a37:6a87:: with SMTP id f129mr21369566qkc.183.1562723592266; Tue, 09 Jul 2019 18:53:12 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.22]) by smtp.gmail.com with ESMTPSA id q9sm374109qkm.63.2019.07.09.18.53.08 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 18:53:11 -0700 (PDT) Date: Tue, 9 Jul 2019 22:53:06 -0300 From: Rodrigo Siqueira To: Daniel Vetter , Haneen Mohammed , David Airlie , Simon Ser , Oleg Vasilev , Mamta Shukla , Harry Wentland Subject: [PATCH 1/2] drm/vkms: Rework blend function Message-ID: References: MIME-Version: 1.0 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=FKfKo9B1CRcLmq9txqUh+s6WgoiWvagwqjoqjlaktJU=; b=Ir1ZXekjheKQ6toSOnazwLGOvTBSlwDXx8BzQTcnNzWqkj1klkMDDPjRiG1Ahlgtl3 jQPJEWcO+vtuySDBjAO6ffP7pg6ge85idG5UlKT6GWr2Ufa++K0UJ++76BoyxVvyCiEc IWeU0AqvzWTlqPQzhbaOZ4jiEkfIKrgv3r3WI46sLu4pPTorgswp4fh0XzdkJsrFmZSf G+6wcLqi11dlqMa/6W/ytbQO3lvCgrG7mNoGczFNW4BsQM2KllSsXEzUZAhhHQ8a6HCK syvttwtUXn4VTJL01gLUKBsPBXOjOowQSlUr5f0WN9PPW6T4i7XMabpHcGuxmthum5dE slww== 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 For combining the cursor into the primary plane, vkms invokes a function named blend which iterates in both buffers and ends up by copying the cursor into the primary buffer. This patch, rework part of the blend function to prepare it for using the alpha channel for blending. Cc: Haneen Mohammed Cc: Mamta Shukla Cc: Harry Wentland Cc: Daniel Vetter Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/vkms/vkms_composer.c | 39 +++++++++++++++++----------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 2317803e7320..fb106964d8bf 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -15,6 +15,17 @@ static u32 get_pixel_from_buffer(int x, int y, const u8 *buffer, return *(u32 *)&buffer[src_offset]; } +static void set_pixel(int x, int y, u8 *buffer, + const struct vkms_composer *composer, const u32 value) +{ + int offset = composer->offset + (y * composer->pitch) + + (x * composer->cpp); + u32 *dst; + + dst = (u32 *)&buffer[offset]; + *dst = value; +} + /** * compute_crc - Compute CRC value on output frame * @@ -50,7 +61,7 @@ static uint32_t compute_crc(const u8 *vaddr, * blend - belnd value at vaddr_src with value at vaddr_dst * @vaddr_dst: destination address * @vaddr_src: source address - * @dest_composer: destination framebuffer's metadata + * @dst_composer: destination framebuffer's metadata * @src_composer: source framebuffer's metadata * * Blend value at vaddr_src with value at vaddr_dst. @@ -62,11 +73,10 @@ static uint32_t compute_crc(const u8 *vaddr, * instead of overwriting it. */ static void blend(void *vaddr_dst, void *vaddr_src, - struct vkms_composer *dest_composer, + struct vkms_composer *dst_composer, struct vkms_composer *src_composer) { - int i, j, j_dst, i_dst; - int offset_src, offset_dst; + int y, x, j_dst, i_dst; int x_src = src_composer->src.x1 >> 16; int y_src = src_composer->src.y1 >> 16; @@ -79,17 +89,16 @@ static void blend(void *vaddr_dst, void *vaddr_src, int y_limit = y_src + h_dst; int x_limit = x_src + w_dst; - for (i = y_src, i_dst = y_dst; i < y_limit; ++i) { - for (j = x_src, j_dst = x_dst; j < x_limit; ++j) { - offset_dst = dest_composer->offset - + (i_dst * dest_composer->pitch) - + (j_dst++ * dest_composer->cpp); - offset_src = src_composer->offset - + (i * src_composer->pitch) - + (j * src_composer->cpp); - - memcpy(vaddr_dst + offset_dst, - vaddr_src + offset_src, sizeof(u32)); + u32 pixel_src; + + for (y = y_src, i_dst = y_dst; y < y_limit; ++y) { + for (x = x_src, j_dst = x_dst; x < x_limit; ++x) { + pixel_src = get_pixel_from_buffer(x, y, + vaddr_src, + src_composer); + set_pixel(j_dst, i_dst, vaddr_dst, dest_composer, + pixel_src); + j_dst++; } i_dst++; } From patchwork Wed Jul 10 01:54:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 11037705 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 6077713A4 for ; Wed, 10 Jul 2019 01:54:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 505AF288A9 for ; Wed, 10 Jul 2019 01:54:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4025928900; Wed, 10 Jul 2019 01:54:14 +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 CF128288A9 for ; Wed, 10 Jul 2019 01:54:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A1F88992E; Wed, 10 Jul 2019 01:54:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by gabe.freedesktop.org (Postfix) with ESMTPS id 43E528992E for ; Wed, 10 Jul 2019 01:54:12 +0000 (UTC) Received: by mail-qt1-x844.google.com with SMTP id w17so741907qto.10 for ; Tue, 09 Jul 2019 18:54:12 -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=Rl/l0lv/RtftyGXlBncrpuyucSyNxpAjwoNFIcH2g3s=; b=L4moPOPZ6owV0vP5sfXqeBCA2j/8Rw/PtOxZItrl+kemlDztq8YoIwqvBfErERqFYY G9H4vUyNYZ8lvA9XZDRrU0/NdTfhJMXbx+69rQDI79r7dt1HKKsa0Ps8b/PhEQFqcaBw xkptGzqTN/dRcsn8+5SXljyP7lTvAeZZuJCfPzi8ZqR4PCKwXRwKrK7fnoFIzft/dnGH gRPjBcacDi9YSaamuExIcFH7ePiN4oFb4Bvt4WeotHm2I1QnbwNdLNU8zgDaQZV4UHI2 m9c3c9h/6NKOhTxVXIc4ScnF1SpbsjTiG4vdYYMJqb6XXYxwplsFwMB2mwcijFD2ntF6 RvEA== X-Gm-Message-State: APjAAAUQ/TpIpUF5fgVFksdfsh9VsdSIHAEDZrrbmnoeRIYckXt4uJjK 2UuHEudNKdt/QgTZoX3Mlww= X-Google-Smtp-Source: APXvYqwdGvebD5uoi6JfsmmnbR3yoS0xb1kwNdhLQ2mb7mTC91DvgkA4fuimynlpMDk6de4G6s28wg== X-Received: by 2002:ac8:2c17:: with SMTP id d23mr21131594qta.385.1562723651223; Tue, 09 Jul 2019 18:54:11 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.22]) by smtp.gmail.com with ESMTPSA id i22sm348098qti.30.2019.07.09.18.54.07 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 18:54:10 -0700 (PDT) Date: Tue, 9 Jul 2019 22:54:05 -0300 From: Rodrigo Siqueira To: Daniel Vetter , Haneen Mohammed , David Airlie , Simon Ser , Oleg Vasilev , Mamta Shukla , Harry Wentland Subject: [PATCH 2/2] drm/vkms: Use alpha channel for blending cursor with primary Message-ID: References: MIME-Version: 1.0 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=Rl/l0lv/RtftyGXlBncrpuyucSyNxpAjwoNFIcH2g3s=; b=ejFKPXzvn1phIqms4yYo1HxB+xY6s8QiTpK9ZIM9O57fTojLMYHr/DRRFzDGTZ6WRr AfHD/+bLrnMSON1NNIFDBkrmigmXylIQs5w6oZMKtm6KatMB/VhnG0YdC1yrMZxSyxPz 563vtMNEkXSXr/+cvyhEZTIwSSa7d6Hzps4Sx6wGLO+75TAysv2hPme8AWIC852GRMoj 1P4K6TstYvbDRr91qonIYHaO1qCMF4pxk3FpIisyVcXK7iYJ4gZHomtRJawJfCuwaKGB mbYE4Kmc/j8BrNLum2hJwSB2zrSguVLEFdOd53KuH3R17Oj64eVTkggetf1le5Q3pnTU 88Sw== 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 Currently, the blend function overwriting the cursor value into the primary plane. This patch utilizes the alpha value for a fully transparent blend of the cursor (vaddr_src) with primary (vaddr_dst) instead of overwriting it in blend(). Cc: Haneen Mohammed Cc: Mamta Shukla Cc: Harry Wentland Cc: Daniel Vetter Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/vkms/vkms_composer.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index fb106964d8bf..bb758a5131a4 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -26,6 +26,17 @@ static void set_pixel(int x, int y, u8 *buffer, *dst = value; } +static u32 apply_alpha(u32 src, u32 dst) +{ + u8 alpha; + u32 k; + + alpha = src >> 24; + alpha = (alpha + 1) >> 8; + k = (alpha << 24) - alpha; + return (k & src) | (~k & dst); +} + /** * compute_crc - Compute CRC value on output frame * @@ -89,15 +100,19 @@ static void blend(void *vaddr_dst, void *vaddr_src, int y_limit = y_src + h_dst; int x_limit = x_src + w_dst; - u32 pixel_src; + u32 pixel_src, pixel_dst, new_pixel; for (y = y_src, i_dst = y_dst; y < y_limit; ++y) { for (x = x_src, j_dst = x_dst; x < x_limit; ++x) { pixel_src = get_pixel_from_buffer(x, y, vaddr_src, src_composer); - set_pixel(j_dst, i_dst, vaddr_dst, dest_composer, - pixel_src); + pixel_dst = get_pixel_from_buffer(j_dst, i_dst, + vaddr_dst, + dst_composer); + new_pixel = apply_alpha(pixel_src, pixel_dst); + set_pixel(j_dst, i_dst, vaddr_dst, dst_composer, + new_pixel); j_dst++; } i_dst++;