From patchwork Sat Feb 20 14:38:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 12096889 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 307BBC433DB for ; Sat, 20 Feb 2021 14:39:01 +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 DB5D664EE1 for ; Sat, 20 Feb 2021 14:39:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB5D664EE1 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 5C2D46E1BA; Sat, 20 Feb 2021 14:39:00 +0000 (UTC) Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7405A6E1B2 for ; Sat, 20 Feb 2021 14:38:59 +0000 (UTC) Received: by mail-wm1-x32c.google.com with SMTP id a207so10394098wmd.1 for ; Sat, 20 Feb 2021 06:38:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=1mcGwYv2cie6U6D4CsYyEr2Obo5HL2xrArgwzJIG/Xg=; b=p73Bc8CbzwzlgKFh0JGIgk/2vb5ZCddiz5vHQNSpTdJO0PITyvQ8Js9drxFZaBSh+X mcGI9OKLnTFE9JTEA032L/W734d+A7D4d/QWeKRe9nMZiTAyJBhAQRqiLA6UZS/lHcAH IXGNC6MQbmMZILpNOj4nGOjP+T//40fQiJi9B5Q2q1U6o6OUbvnJj4Xuh1R1u81ivQsS MTCWU8G0X8/9tUvxSCpmvqC8JW55y578JgdyZaKIV5LNJ7unXbRrmP0C2wc3teOYxWY3 RDn5ZINMY+Y/YykWa25AZCR/f93kEj/b5RvuAymA12zj69HCa+aVucs+i2VKAbDjNKSL 6TZg== 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:mime-version :content-disposition; bh=1mcGwYv2cie6U6D4CsYyEr2Obo5HL2xrArgwzJIG/Xg=; b=SuFpk44CRNZqR7RscbsbE85ixWuVO4zganZ036scDC684TBonXJ7OhilHvyqMqoeXj 5pRIKxjVzVLXKPf+S9mS8RFz91SrHTOhzxDUzBsxIe1HTERDSjmygqriU38uC6C8X2uU QHysbacL01HYivp/BxAsrzDAZyuzo8xwDuFNo1J9ttF7sMQNhkKHT0iQX6yDmzkcMks0 aQiizk8u2NkClVoYRaafRVGArbZZZwojsVvd/npTHtQGlFRzP03Wb4ZL3ZdZli/xGqNq KwISv/ik8/VGyQlTM3Y3bohdAwaVQiJg8IrAtVW43WzebVf5gcFKsGW4h9ZyYmd9gJQ0 m8Fw== X-Gm-Message-State: AOAM533E5JiyPxCRZCTGZoXxU5jyduVoh5pqctf9Xx7rJT6C1PDcfAA/ KeG5RZK1CRwEZzE7khdpfT4= X-Google-Smtp-Source: ABdhPJzvUi9viU+WAjXHuqvXoPmZUPctC8nfV00nfzUREodCJIXa4/aOvsykU5jzJc2R9e3P42c5Hg== X-Received: by 2002:a1c:b0c2:: with SMTP id z185mr12476379wme.67.1613831938209; Sat, 20 Feb 2021 06:38:58 -0800 (PST) Received: from smtp.gmail.com (a95-92-181-29.cpe.netcabo.pt. [95.92.181.29]) by smtp.gmail.com with ESMTPSA id z13sm7120108wmi.45.2021.02.20.06.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Feb 2021 06:38:57 -0800 (PST) Date: Sat, 20 Feb 2021 11:38:50 -0300 From: Melissa Wen To: Rodrigo Siqueira , Haneen Mohammed , Daniel Vetter , Simon Ser , Sumera Priyadarsini , David Airlie Subject: [RFC PATCH 1/3] drm/vkms: decouple cursor plane setup from crtc_init Message-ID: <20210220143850.k22n4r4uel5zhxr2@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline 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: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Initialize CRTC only with primary plane (without cursor) as a preparation to init overlay plane before cursor plane and keep cursor on the top. Signed-off-by: Melissa Wen --- drivers/gpu/drm/vkms/vkms_crtc.c | 4 ++-- drivers/gpu/drm/vkms/vkms_drv.h | 2 +- drivers/gpu/drm/vkms/vkms_output.c | 14 +++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 0443b7deeaef..2d4cd7736933 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -270,12 +270,12 @@ static const struct drm_crtc_helper_funcs vkms_crtc_helper_funcs = { }; int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, - struct drm_plane *primary, struct drm_plane *cursor) + struct drm_plane *primary) { struct vkms_output *vkms_out = drm_crtc_to_vkms_output(crtc); int ret; - ret = drm_crtc_init_with_planes(dev, crtc, primary, cursor, + ret = drm_crtc_init_with_planes(dev, crtc, primary, NULL, &vkms_crtc_funcs, NULL); if (ret) { DRM_ERROR("Failed to init CRTC\n"); diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 35540c7c4416..9ad5ad8b7737 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -110,7 +110,7 @@ struct vkms_device { /* CRTC */ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, - struct drm_plane *primary, struct drm_plane *cursor); + struct drm_plane *primary); int vkms_output_init(struct vkms_device *vkmsdev, int index); diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index f5f6f15c362c..05d3bb45e6c1 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -47,6 +47,10 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) if (IS_ERR(primary)) return PTR_ERR(primary); + ret = vkms_crtc_init(dev, crtc, primary); + if (ret) + goto err_crtc; + if (vkmsdev->config->cursor) { cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index); if (IS_ERR(cursor)) { @@ -55,9 +59,9 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) } } - ret = vkms_crtc_init(dev, crtc, primary, cursor); - if (ret) - goto err_crtc; + crtc->cursor = cursor; + if (cursor && !cursor->possible_crtcs) + cursor->possible_crtcs = drm_crtc_mask(crtc); ret = drm_connector_init(dev, connector, &vkms_connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL); @@ -100,11 +104,11 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) err_connector: drm_crtc_cleanup(crtc); -err_crtc: +err_cursor: if (vkmsdev->config->cursor) drm_plane_cleanup(cursor); -err_cursor: +err_crtc: drm_plane_cleanup(primary); return ret; From patchwork Sat Feb 20 14:41:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 12096891 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 AD539C433DB for ; Sat, 20 Feb 2021 14:41:23 +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 622E564E44 for ; Sat, 20 Feb 2021 14:41:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 622E564E44 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 E03066E1CE; Sat, 20 Feb 2021 14:41:22 +0000 (UTC) Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by gabe.freedesktop.org (Postfix) with ESMTPS id 01C036E1CE for ; Sat, 20 Feb 2021 14:41:21 +0000 (UTC) Received: by mail-wm1-x331.google.com with SMTP id w4so9532517wmi.4 for ; Sat, 20 Feb 2021 06:41:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=OmF0g/VAKBYdCDgOx5TjJPBaDMsn4k/UprRXnCcx/14=; b=FK4m4lw2FLP9Sa8/oxf9uTH9VM3EHtd0Yz/zGxMQqDot7DRjLAim4AOGOKduX4yLD3 VcSzy4Lo55LFj2rMqwB43wkuB5O03es3VQHvqL6gtczyfXg73eJ8DgkVVwX5KuF0XG7x C8VA7BShMdVk1Y8AoXpI3FyO7hYoTZAo8RDHchBfRZbkx7hE+fWiE6he4oqovKlG8w/7 3Uy0Wa/vRMxBxHN1roqtWyTkXQozwwMzl9HEztVHFkXUWGPn/hVXoNYxppTe/ECvgN+D ONMbcUoGU9KXDEl9xfKZKGpjrStlG/x446HilrZ+slGMypxLVwqyRfNBc4Y5wM48Yy01 daxg== 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:mime-version :content-disposition; bh=OmF0g/VAKBYdCDgOx5TjJPBaDMsn4k/UprRXnCcx/14=; b=L/1nM2vhOeAS/2T/JPaFe/9qXZRb0WiWd5DqOHxi8AIG1PZkvAU3bJsAcqVNcZXMA8 gLk/tRY63i/XTqTICtwxeGAynV9PBfRwTbLPxFujToYPAAfHjsn35Y2MnJzaJHwRonY7 FATZxOcYeoMrMw0k1DiVVaNVCRM3ymOHJmHxyhZH+R633RISDr9bwkQGEmIPNR8oENmX 3dwt+BJtf98VRdGi8A+OboqiwGOxYVQIr+FkZN7cnwtsr/2Yzg3vpq2S+AXMCBcxLLmM 7+FrQVotPVe/VuCKDHmlsI8JjqI9V5CZEG7zmS3570LQjvPvf4jjKhn2B7WzQ0Lov/gy gkWA== X-Gm-Message-State: AOAM531jseehcQBd56c4dRRiijt+M0AoWT6aRrJopr5BMfXUFzgC3Xpc DSStcfi50qscpsAb1LPZG9Y= X-Google-Smtp-Source: ABdhPJwJ3OIxGozhrkMHmEyBn6KT9VCoG1PbgSNkHSGIX0SLIXe2DQXAWy3rMihHLJ1Cd8+vkWVxdw== X-Received: by 2002:a05:600c:4f14:: with SMTP id l20mr12932747wmq.118.1613832080718; Sat, 20 Feb 2021 06:41:20 -0800 (PST) Received: from smtp.gmail.com (a95-92-181-29.cpe.netcabo.pt. [95.92.181.29]) by smtp.gmail.com with ESMTPSA id l7sm19785386wrn.11.2021.02.20.06.41.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Feb 2021 06:41:20 -0800 (PST) Date: Sat, 20 Feb 2021 11:41:14 -0300 From: Melissa Wen To: Rodrigo Siqueira , Haneen Mohammed , Daniel Vetter , Simon Ser , Sumera Priyadarsini , David Airlie Subject: [RFC PATCH 2/3] drm/vkms: rename cursor to plane on ops of planes composition Message-ID: <20210220144114.25svrv4wbjietuqd@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline 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: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Generalize variables and function names used for planes composition (from cursor to plane), since we will reuse the operations for both cursor and overlay types. No functional change. Signed-off-by: Melissa Wen --- drivers/gpu/drm/vkms/vkms_composer.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 66c6842d70db..be8f1d33c645 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -125,26 +125,26 @@ static void blend(void *vaddr_dst, void *vaddr_src, } } -static void compose_cursor(struct vkms_composer *cursor_composer, - struct vkms_composer *primary_composer, +static void compose_planes(struct vkms_composer *primary_composer, + struct vkms_composer *plane_composer, void *vaddr_out) { - struct drm_gem_object *cursor_obj; - struct drm_gem_shmem_object *cursor_shmem_obj; + struct drm_gem_object *plane_obj; + struct drm_gem_shmem_object *plane_shmem_obj; - cursor_obj = drm_gem_fb_get_obj(&cursor_composer->fb, 0); - cursor_shmem_obj = to_drm_gem_shmem_obj(cursor_obj); + plane_obj = drm_gem_fb_get_obj(&plane_composer->fb, 0); + plane_shmem_obj = to_drm_gem_shmem_obj(plane_obj); - if (WARN_ON(!cursor_shmem_obj->vaddr)) + if (WARN_ON(!plane_shmem_obj->vaddr)) return; - blend(vaddr_out, cursor_shmem_obj->vaddr, - primary_composer, cursor_composer); + blend(vaddr_out, plane_shmem_obj->vaddr, + primary_composer, plane_composer); } -static int compose_planes(void **vaddr_out, - struct vkms_composer *primary_composer, - struct vkms_composer *cursor_composer) +static int composite(void **vaddr_out, + struct vkms_composer *primary_composer, + struct vkms_composer *cursor_composer) { struct drm_framebuffer *fb = &primary_composer->fb; struct drm_gem_object *gem_obj = drm_gem_fb_get_obj(fb, 0); @@ -164,7 +164,7 @@ static int compose_planes(void **vaddr_out, memcpy(*vaddr_out, shmem_obj->vaddr, shmem_obj->base.size); if (cursor_composer) - compose_cursor(cursor_composer, primary_composer, *vaddr_out); + compose_planes(primary_composer, cursor_composer, *vaddr_out); return 0; } @@ -222,7 +222,7 @@ void vkms_composer_worker(struct work_struct *work) if (wb_pending) vaddr_out = crtc_state->active_writeback; - ret = compose_planes(&vaddr_out, primary_composer, cursor_composer); + ret = composite(&vaddr_out, primary_composer, cursor_composer); if (ret) { if (ret == -EINVAL && !wb_pending) kfree(vaddr_out); From patchwork Sat Feb 20 14:42:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 12096893 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 CFF81C433E0 for ; Sat, 20 Feb 2021 14:42:23 +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 8674F64E44 for ; Sat, 20 Feb 2021 14:42:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8674F64E44 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 006B96E1ED; Sat, 20 Feb 2021 14:42:23 +0000 (UTC) Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8D7726E1ED for ; Sat, 20 Feb 2021 14:42:21 +0000 (UTC) Received: by mail-wm1-x334.google.com with SMTP id n10so10389469wmq.0 for ; Sat, 20 Feb 2021 06:42:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=8c2OEtQ2xFquVD5unDqqyC8aIKkzbHGyj5TQZIKT9CM=; b=E5jFdwrp5aP/0WRdepcb85giv4pKBYRElfgNV5Z1GnIjk1aP2EluUSscIvLjCCdJW9 NwSB+txSsdtbfG5XEu9WmpvxD3PCFXW0O6Qy4cP3AaENPQGd+MN4tSgPysUBvgVitduZ aPVgzrp6EL8ythEBYNArFUTwGEAAXRVQusc+C7ClCnzGW9+9JlnLd2F0V6gVd0FiCF/f KiRVCS6OeaQfa+y2kAKgHDPSsfkGgQE/epJyyb69zT3n2yll/4w60qFoLfj2Tpyj3G/4 GRe1PwAlptXnChzkHw/yMyAjWaj3It8x7dPCwMRiknxPXSxKhTddtVRMEFklcTrA873Y 5AmA== 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:mime-version :content-disposition; bh=8c2OEtQ2xFquVD5unDqqyC8aIKkzbHGyj5TQZIKT9CM=; b=lU/CgSMiOMIVXO3FG4zqNJsUH4wmh1yQd4SlqwDFxK0BSIcQZM8UvDKxgBp7gCScFP OucIDcyCXzmP6KjMCHVvqvnvfJuEERQrLJlgLMSqXe2VpFX2oRF6DWK+PlrXJxmGwbDq yAs5qRaBHMARZdtqdVPwC0xqxkZOacNEGVu3YI0YcCmaRZNaeHPMdaTpWb/vRTkXPb77 T+zjVUsFvdd0Y5CK5PCnc6Q4gs/a5Sse8ouyb/j28c4Efg779sao6QOsL2+8FWraccyD yWXNEvGViNdY8r03jnp1LYHlojE9/Cpxy6Wp/cokx8DXfI3RtEbZzdshCe2I0009oeI7 5tHg== X-Gm-Message-State: AOAM530sggRd5X1JmzeqbJkB63ZAdrezx5M93sm2wovJnL3V+D48hW44 E/bda7uYKqFdy3D+BIIjWGg= X-Google-Smtp-Source: ABdhPJwlAzuNlzkas3+XzGnHoVoHLxHZc/8L1cwG63u+94pTKzKJCOIy88KJVOPD5A+Tm8twoiJyZQ== X-Received: by 2002:a1c:7f83:: with SMTP id a125mr12544239wmd.141.1613832140292; Sat, 20 Feb 2021 06:42:20 -0800 (PST) Received: from smtp.gmail.com (a95-92-181-29.cpe.netcabo.pt. [95.92.181.29]) by smtp.gmail.com with ESMTPSA id b11sm18759078wrw.68.2021.02.20.06.42.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Feb 2021 06:42:20 -0800 (PST) Date: Sat, 20 Feb 2021 11:42:12 -0300 From: Melissa Wen To: Rodrigo Siqueira , Haneen Mohammed , Daniel Vetter , Simon Ser , Sumera Priyadarsini , David Airlie Subject: [RFC PATCH 3/3] drm/vkms: add overlay support Message-ID: <20210220144212.oqmnjxuwvevke5bn@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline 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: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add support to overlay plane, in addition to primary and cursor planes. In this approach, the plane composition still requires an active primary plane and planes are composed associatively in the order: (primary <- overlay) <- cursor It enables to run the following IGT tests successfully: - kms_plane_cursor: - pipe-A-[overlay, primary, viewport]-size-[64, 128, 256] - kms_atomic: - plane-overlay-legacy and preserves the successful execution of kms_cursor_crc, kms_writeback and kms_flip Signed-off-by: Melissa Wen --- drivers/gpu/drm/vkms/vkms_composer.c | 27 +++++++++++++++++---------- drivers/gpu/drm/vkms/vkms_drv.c | 5 +++++ drivers/gpu/drm/vkms/vkms_drv.h | 1 + drivers/gpu/drm/vkms/vkms_output.c | 17 +++++++++++++++-- drivers/gpu/drm/vkms/vkms_plane.c | 20 +++++++++++++++----- 5 files changed, 53 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index be8f1d33c645..2116da9b5a43 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -144,11 +144,12 @@ static void compose_planes(struct vkms_composer *primary_composer, static int composite(void **vaddr_out, struct vkms_composer *primary_composer, - struct vkms_composer *cursor_composer) + struct vkms_crtc_state *crtc_state) { struct drm_framebuffer *fb = &primary_composer->fb; struct drm_gem_object *gem_obj = drm_gem_fb_get_obj(fb, 0); struct drm_gem_shmem_object *shmem_obj = to_drm_gem_shmem_obj(gem_obj); + int i; if (!*vaddr_out) { *vaddr_out = kzalloc(shmem_obj->base.size, GFP_KERNEL); @@ -163,8 +164,14 @@ static int composite(void **vaddr_out, memcpy(*vaddr_out, shmem_obj->vaddr, shmem_obj->base.size); - if (cursor_composer) - compose_planes(primary_composer, cursor_composer, *vaddr_out); + /* If there are other planes besides primary, we consider the active + * planes should be in z-order and compose them associatively: + * ((primary <- overlay) <- cursor) + */ + for (i = 1; i < crtc_state->num_active_planes; i++) + compose_planes(primary_composer, + crtc_state->active_planes[i]->composer, + *vaddr_out); return 0; } @@ -186,7 +193,7 @@ void vkms_composer_worker(struct work_struct *work) struct drm_crtc *crtc = crtc_state->base.crtc; struct vkms_output *out = drm_crtc_to_vkms_output(crtc); struct vkms_composer *primary_composer = NULL; - struct vkms_composer *cursor_composer = NULL; + struct vkms_plane_state *act_plane = NULL; bool crc_pending, wb_pending; void *vaddr_out = NULL; u32 crc32 = 0; @@ -210,11 +217,11 @@ void vkms_composer_worker(struct work_struct *work) if (!crc_pending) return; - if (crtc_state->num_active_planes >= 1) - primary_composer = crtc_state->active_planes[0]->composer; - - if (crtc_state->num_active_planes == 2) - cursor_composer = crtc_state->active_planes[1]->composer; + if (crtc_state->num_active_planes >= 1) { + act_plane = crtc_state->active_planes[0]; + if (act_plane->base.plane->type == DRM_PLANE_TYPE_PRIMARY) + primary_composer = act_plane->composer; + } if (!primary_composer) return; @@ -222,7 +229,7 @@ void vkms_composer_worker(struct work_struct *work) if (wb_pending) vaddr_out = crtc_state->active_writeback; - ret = composite(&vaddr_out, primary_composer, cursor_composer); + ret = composite(&vaddr_out, primary_composer, crtc_state); if (ret) { if (ret == -EINVAL && !wb_pending) kfree(vaddr_out); diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 2173b82606f6..027ffe759440 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -44,6 +44,10 @@ static bool enable_writeback = true; module_param_named(enable_writeback, enable_writeback, bool, 0444); MODULE_PARM_DESC(enable_writeback, "Enable/Disable writeback connector support"); +static bool enable_overlay; +module_param_named(enable_overlay, enable_overlay, bool, 0444); +MODULE_PARM_DESC(enable_overlay, "Enable/Disable overlay support"); + DEFINE_DRM_GEM_FOPS(vkms_driver_fops); static void vkms_release(struct drm_device *dev) @@ -198,6 +202,7 @@ static int __init vkms_init(void) config->cursor = enable_cursor; config->writeback = enable_writeback; + config->overlay = enable_overlay; return vkms_create(config); } diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 9ad5ad8b7737..784219da8df0 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -85,6 +85,7 @@ struct vkms_device; struct vkms_config { bool writeback; bool cursor; + bool overlay; /* only set when instantiated */ struct vkms_device *dev; }; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 05d3bb45e6c1..c60d0f2e7a37 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -39,7 +39,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) struct drm_connector *connector = &output->connector; struct drm_encoder *encoder = &output->encoder; struct drm_crtc *crtc = &output->crtc; - struct drm_plane *primary, *cursor = NULL; + struct drm_plane *primary, *cursor = NULL, *overlay = NULL; int ret; int writeback; @@ -51,6 +51,16 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) if (ret) goto err_crtc; + if (vkmsdev->config->overlay) { + overlay = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_OVERLAY, index); + if (IS_ERR(overlay)) { + ret = PTR_ERR(overlay); + goto err_overlay; + } + if (overlay && !overlay->possible_crtcs) + overlay->possible_crtcs = drm_crtc_mask(crtc); + } + if (vkmsdev->config->cursor) { cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index); if (IS_ERR(cursor)) { @@ -58,7 +68,6 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) goto err_cursor; } } - crtc->cursor = cursor; if (cursor && !cursor->possible_crtcs) cursor->possible_crtcs = drm_crtc_mask(crtc); @@ -108,6 +117,10 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) if (vkmsdev->config->cursor) drm_plane_cleanup(cursor); +err_overlay: + if (vkmsdev->config->overlay) + drm_plane_cleanup(overlay); + err_crtc: drm_plane_cleanup(primary); diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 0824327cc860..8e7bb84bc894 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -19,6 +19,11 @@ static const u32 vkms_cursor_formats[] = { DRM_FORMAT_ARGB8888, }; +static const u32 vkms_overlay_formats[] = { + DRM_FORMAT_ARGB8888, + DRM_FORMAT_XRGB8888, +}; + static struct drm_plane_state * vkms_plane_duplicate_state(struct drm_plane *plane) { @@ -127,7 +132,7 @@ static int vkms_plane_atomic_check(struct drm_plane *plane, if (IS_ERR(crtc_state)) return PTR_ERR(crtc_state); - if (plane->type == DRM_PLANE_TYPE_CURSOR) + if (plane->type != DRM_PLANE_TYPE_PRIMARY) can_position = true; ret = drm_atomic_helper_check_plane_state(state, crtc_state, @@ -195,14 +200,19 @@ struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, int ret, nformats; plane = kzalloc(sizeof(*plane), GFP_KERNEL); - if (!plane) - return ERR_PTR(-ENOMEM); - if (type == DRM_PLANE_TYPE_CURSOR) { + switch (type) { + case DRM_PLANE_TYPE_CURSOR: formats = vkms_cursor_formats; nformats = ARRAY_SIZE(vkms_cursor_formats); funcs = &vkms_primary_helper_funcs; - } else { + break; + case DRM_PLANE_TYPE_OVERLAY: + formats = vkms_overlay_formats; + nformats = ARRAY_SIZE(vkms_overlay_formats); + funcs = &vkms_primary_helper_funcs; + break; + default: formats = vkms_formats; nformats = ARRAY_SIZE(vkms_formats); funcs = &vkms_primary_helper_funcs;