From patchwork Tue Apr 13 07:54:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 12199565 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A887C433B4 for ; Tue, 13 Apr 2021 07:55:03 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2001A613B1 for ; Tue, 13 Apr 2021 07:55:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2001A613B1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E5326E217; Tue, 13 Apr 2021 07:55:02 +0000 (UTC) Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 139716E217 for ; Tue, 13 Apr 2021 07:55:01 +0000 (UTC) Received: by mail-wm1-x32e.google.com with SMTP id k128so8172554wmk.4 for ; Tue, 13 Apr 2021 00:55:00 -0700 (PDT) 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; bh=0GvgA1racKrpTSVDZjQw5lJlS7yNUXjRv+Dx3EsFT4g=; b=dNA/9VJ50JpvT/XEnMMrUUVREDlPw5geW9D36H6UAEvuxC9LgSyaKtDhIghnY94Rj0 R/EkoxcH5SNlTZ6SMsM+cW4elttN/j8bHNzx8MFU5pVp2U1xpr7HgMeU3DxqYyAx6GEm smbYVigLpuXmIgS20D5ICvO1R8vOAN1yDfffLSlXr2raeXOXvykyk9lFOi4rHTjFp0a+ 09snzHjaffpv0EZdJZDALkONDvrYnCCPXG5mNKtsCpqs7SewOZBGeerOmnnzLsFEBBWz wGT1B33i96vdHx8zf+zW5Pmi31WL/j6wgD/XvH8of+F0DIkj/CQAL/U97JmIlRHHMWLf r+jA== 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; bh=0GvgA1racKrpTSVDZjQw5lJlS7yNUXjRv+Dx3EsFT4g=; b=D+iSeVb1RG4MBO6/FjJnYOMM9jYjSKK3jkULmnv+XqVlRt6oM/HDrZLITOaeCUAq24 lll4ZN+YY+ECt5SqY7qd78zsmAiZkJbK0Ang2IlYgX5TVdL79JY564jeaGwUcduknypj VA8Nlor9RBpbr5Gkr7XE0L3oImSKLowNO+SNPOMYofImHP1XSuvpgPUKms2lZ65z11+W qym1X/9/5tBDHWl5vLHpc1Wmcfwl1U8sYFZns7lAAXTflFODyTQmf8rVOpfQBjwW/w63 HWWpvXuH/dP1pv6rGQkuSR78RP4+vCO9Tb1xkrJ1NZb36FjExObJEwxb0nFRDcT0aQU7 ubfw== X-Gm-Message-State: AOAM530oFms+teW36Hn/MKvDKTKIoNNraldSqjNjn0NEhtbHFZEbd/um BbXp/MR7HASJKSipluf5O2WjCeTjphNmww== X-Google-Smtp-Source: ABdhPJzrD4wsIIQAipKufrdkCpobubzhYCjmT70tPGudPiqGwEboMR8/Zb6CX0SXZtu47m4EH1CIEA== X-Received: by 2002:a05:600c:4f4f:: with SMTP id m15mr2767598wmq.29.1618300499457; Tue, 13 Apr 2021 00:54:59 -0700 (PDT) Received: from smtp.gmail.com (a95-92-181-29.cpe.netcabo.pt. [95.92.181.29]) by smtp.gmail.com with ESMTPSA id a7sm20755813wrn.50.2021.04.13.00.54.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 00:54:58 -0700 (PDT) Date: Tue, 13 Apr 2021 04:54:52 -0300 From: Melissa Wen To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 3/4] drm/vkms: add XRGB planes composition Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Haneen Mohammed , Sumera Priyadarsini , Rodrigo Siqueira , David Airlie Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add support for composing XRGB888 planes in addition to the ARGB8888 format. In the case of an XRGB plane at the top, the composition consists of just copying the RGB values of a pixel from src to dst, without the need for alpha blending operations for each pixel. Signed-off-by: Melissa Wen Reviewed-by: Daniel Vetter --- drivers/gpu/drm/vkms/vkms_composer.c | 22 ++++++++++++++++++---- drivers/gpu/drm/vkms/vkms_plane.c | 7 ++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index be8f1d33c645..7fe1fdb3af39 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -76,6 +77,11 @@ static void alpha_blending(const u8 *argb_src, u8 *argb_dst) argb_dst[3] = 0xFF; } +static void x_blending(const u8 *xrgb_src, u8 *xrgb_dst) +{ + memcpy(xrgb_dst, xrgb_src, sizeof(u8) * 3); +} + /** * blend - blend value at vaddr_src with value at vaddr_dst * @vaddr_dst: destination address @@ -91,7 +97,8 @@ static void alpha_blending(const u8 *argb_src, u8 *argb_dst) */ static void blend(void *vaddr_dst, void *vaddr_src, struct vkms_composer *dst_composer, - struct vkms_composer *src_composer) + struct vkms_composer *src_composer, + void (*pixel_blend)(const u8 *, u8 *)) { int i, j, j_dst, i_dst; int offset_src, offset_dst; @@ -119,7 +126,7 @@ static void blend(void *vaddr_dst, void *vaddr_src, pixel_src = (u8 *)(vaddr_src + offset_src); pixel_dst = (u8 *)(vaddr_dst + offset_dst); - alpha_blending(pixel_src, pixel_dst); + pixel_blend(pixel_src, pixel_dst); } i_dst++; } @@ -131,6 +138,8 @@ static void compose_planes(struct vkms_composer *primary_composer, { struct drm_gem_object *plane_obj; struct drm_gem_shmem_object *plane_shmem_obj; + struct drm_framebuffer *fb = &plane_composer->fb; + void (*pixel_blend)(const u8 *p_src, u8 *p_dst); plane_obj = drm_gem_fb_get_obj(&plane_composer->fb, 0); plane_shmem_obj = to_drm_gem_shmem_obj(plane_obj); @@ -138,8 +147,13 @@ static void compose_planes(struct vkms_composer *primary_composer, if (WARN_ON(!plane_shmem_obj->vaddr)) return; - blend(vaddr_out, plane_shmem_obj->vaddr, - primary_composer, plane_composer); + if (fb->format->format == DRM_FORMAT_ARGB8888) + pixel_blend = &alpha_blending; + else + pixel_blend = &x_blending; + + blend(vaddr_out, plane_shmem_obj->vaddr, primary_composer, + plane_composer, pixel_blend); } static int composite(void **vaddr_out, diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 135140f8e87a..da4251aff67f 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -16,8 +16,9 @@ static const u32 vkms_formats[] = { DRM_FORMAT_XRGB8888, }; -static const u32 vkms_cursor_formats[] = { +static const u32 vkms_plane_formats[] = { DRM_FORMAT_ARGB8888, + DRM_FORMAT_XRGB8888 }; static struct drm_plane_state * @@ -200,8 +201,8 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, int nformats; if (type == DRM_PLANE_TYPE_CURSOR) { - formats = vkms_cursor_formats; - nformats = ARRAY_SIZE(vkms_cursor_formats); + formats = vkms_plane_formats; + nformats = ARRAY_SIZE(vkms_plane_formats); funcs = &vkms_primary_helper_funcs; } else { formats = vkms_formats;