From patchwork Tue Apr 13 07:50:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 12199561 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 60336C433B4 for ; Tue, 13 Apr 2021 07:50:20 +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 19D3561244 for ; Tue, 13 Apr 2021 07:50:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19D3561244 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 7168C6E204; Tue, 13 Apr 2021 07:50:19 +0000 (UTC) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by gabe.freedesktop.org (Postfix) with ESMTPS id 381A36E204 for ; Tue, 13 Apr 2021 07:50:18 +0000 (UTC) Received: by mail-wr1-x436.google.com with SMTP id p6so8689488wrn.9 for ; Tue, 13 Apr 2021 00:50:18 -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=SwK+tMPzZuJzHn1ReRx+OUj2+6bNHdvV88p8aBr+RX0=; b=MsnrKCkFzSeecMcuOPMIIcHvHoIFuXANWhHF4EYu2fs1K7lPyKirReH7zL3T0WEBb1 xvc4vkLydcH06To+vFwqVIZ45h0X1pgkFWkUsKadJX3YAL/JSEpeOO5838K7mKyGomm1 U5YorUAIE9aRfySaAGpPRZ/bg5CZAY5trlj/kHwLuEMcRfn0axTnGxWBviuh2JziNJpv rYbUbMYSO3A9smCOsf80R8lE9cm1lTxeXwFx7A44PdArQdu32fBhCuayi6y8xp9Ld+g0 gxm82g764LLiQjO265UDma8zavFK81unarKVn44ceVYzdR6OV/Brx3wHaocsEkuBuuOR 6Mzw== 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=SwK+tMPzZuJzHn1ReRx+OUj2+6bNHdvV88p8aBr+RX0=; b=tHkmhV7Lo36hYUYn8SD7Ou1hdLzfoWOpsubRVOVhYFnpZexTcAF6lEi997H0wPYZhW h2qLsSkAk4k6bDGQ3be+qi3+VcbG0HAj99uV/PE+zfE1OrJTGVfRrSk9idKKR/qSRBD3 E4sNGb4QnRqBg4aLKvaOIkEJAW/DcaoCILxQBO5Eq1iX35j5khXhLMEzyP2V7/V7Zw8G Ok9iTkN2wbrEV1XtrQ8lEO/SfKDGEesx9TyUzbyqONH0ZZu8FFyNhv1wBRuJecbOj4Jt fL1mPtVJlUGmgcqCTfkkV5+NMhBx7qV3Q7KjMnJB5+8IWEjP9futOm5oM2h2MoV8zyaz nfqw== X-Gm-Message-State: AOAM53270IYUyOx7xW+Juaen70GCE+gaJMbAeWlHaa9CQ+T8ft++UqMo PH7tvUbtXJ8cnEkm3YudOQMFPwbB9VPCqg== X-Google-Smtp-Source: ABdhPJwRtnNlOSEXVkXxESLT9Fa6I4rgle/Z1prmR0y3HX14ehkfuZIJ90l7OvL4b8evY7vEgWQCUQ== X-Received: by 2002:adf:9481:: with SMTP id 1mr20118781wrr.114.1618300216580; Tue, 13 Apr 2021 00:50:16 -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 o14sm19806522wrh.88.2021.04.13.00.50.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 00:50:16 -0700 (PDT) Date: Tue, 13 Apr 2021 04:50:08 -0300 From: Melissa Wen To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 1/4] drm/vkms: init plane using drmm_universal_plane_alloc 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" By using drmm_universal_plane_alloc instead of drm_universal_plane_init, we let the DRM infrastructure handles resource allocation and cleanup. We can also get rid of some code repetitions for plane cleanup, improving code maintainability in vkms. Signed-off-by: Melissa Wen Reviewed-by: Daniel Vetter --- drivers/gpu/drm/vkms/vkms_drv.h | 8 ++++++-- drivers/gpu/drm/vkms/vkms_output.c | 19 +++++-------------- drivers/gpu/drm/vkms/vkms_plane.c | 29 +++++++++++------------------ 3 files changed, 22 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 35540c7c4416..70fb79621617 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -37,6 +37,10 @@ struct vkms_plane_state { struct vkms_composer *composer; }; +struct vkms_plane { + struct drm_plane base; +}; + /** * vkms_crtc_state - Driver specific CRTC state * @base: base CRTC state @@ -114,8 +118,8 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, int vkms_output_init(struct vkms_device *vkmsdev, int index); -struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, - enum drm_plane_type type, int index); +struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, + enum drm_plane_type type, int index); /* CRC Support */ const char *const *vkms_get_crc_sources(struct drm_crtc *crtc, diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index f5f6f15c362c..6979fbc7f821 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 vkms_plane *primary, *cursor = NULL; int ret; int writeback; @@ -49,15 +49,13 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) if (vkmsdev->config->cursor) { cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index); - if (IS_ERR(cursor)) { - ret = PTR_ERR(cursor); - goto err_cursor; - } + if (IS_ERR(cursor)) + return PTR_ERR(cursor); } - ret = vkms_crtc_init(dev, crtc, primary, cursor); + ret = vkms_crtc_init(dev, crtc, &primary->base, &cursor->base); if (ret) - goto err_crtc; + return ret; ret = drm_connector_init(dev, connector, &vkms_connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL); @@ -100,12 +98,5 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) err_connector: drm_crtc_cleanup(crtc); -err_crtc: - if (vkmsdev->config->cursor) - drm_plane_cleanup(cursor); - -err_cursor: - drm_plane_cleanup(primary); - return ret; } diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 6d310d31b75d..135140f8e87a 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -86,7 +86,6 @@ static void vkms_plane_reset(struct drm_plane *plane) static const struct drm_plane_funcs vkms_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = drm_plane_cleanup, .reset = vkms_plane_reset, .atomic_duplicate_state = vkms_plane_duplicate_state, .atomic_destroy_state = vkms_plane_destroy_state, @@ -191,18 +190,14 @@ static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = { .cleanup_fb = vkms_cleanup_fb, }; -struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, - enum drm_plane_type type, int index) +struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, + enum drm_plane_type type, int index) { struct drm_device *dev = &vkmsdev->drm; const struct drm_plane_helper_funcs *funcs; - struct drm_plane *plane; + struct vkms_plane *plane; const u32 *formats; - int ret, nformats; - - plane = kzalloc(sizeof(*plane), GFP_KERNEL); - if (!plane) - return ERR_PTR(-ENOMEM); + int nformats; if (type == DRM_PLANE_TYPE_CURSOR) { formats = vkms_cursor_formats; @@ -214,16 +209,14 @@ struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, funcs = &vkms_primary_helper_funcs; } - ret = drm_universal_plane_init(dev, plane, 1 << index, - &vkms_plane_funcs, - formats, nformats, - NULL, type, NULL); - if (ret) { - kfree(plane); - return ERR_PTR(ret); - } + plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 1 << index, + &vkms_plane_funcs, + formats, nformats, + NULL, type, NULL); + if (IS_ERR(plane)) + return plane; - drm_plane_helper_add(plane, funcs); + drm_plane_helper_add(&plane->base, funcs); return plane; } From patchwork Tue Apr 13 07:53:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 12199563 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 A8FDBC433B4 for ; Tue, 13 Apr 2021 07:53:53 +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 658E461244 for ; Tue, 13 Apr 2021 07:53:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 658E461244 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 B980289FD9; Tue, 13 Apr 2021 07:53:52 +0000 (UTC) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by gabe.freedesktop.org (Postfix) with ESMTPS id A861F89FD9 for ; Tue, 13 Apr 2021 07:53:51 +0000 (UTC) Received: by mail-wr1-x42b.google.com with SMTP id a4so15429866wrr.2 for ; Tue, 13 Apr 2021 00:53:51 -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=cngo3ZfVDnt2WPvjxNtV6TyKaeQge9GquHcF8oaTBHo=; b=FEALEW1fvVujvhwLrLqKy04CEK5dgkbiGnFfeWRd6g08SpOGjkJ3iwSvgzGuc8x4Qz +dXOMQk86OumdqqJ3i1r6hbetyoNHFLeleoGIa0rQIcR2NMy8Mn/eh6fa4A6ZhVs/ZZ1 Ij7oN3p75+O8SgHNCtjOCkLmP8mivoI/dusJP8gq/kf2rbGaQzJsI+RVgsgDL+cR/nAx QRVPfh6LQVPa6cnE329mVQlpynJXCiPl8zIqtupzgx72uubg8bEPCnb/4nk10WgqNFhG 3BBOuGNWG9cmk6bdh0LRZUJ8r+exmiJifnqEJp7o8uEvFqKss6PigfJImBqttm5yDyNZ NTxw== 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=cngo3ZfVDnt2WPvjxNtV6TyKaeQge9GquHcF8oaTBHo=; b=U9uEyRvxTFMCL9e16Ku4mHXTZ3eZAYx+oyz4L4qQ6Ai0ncQlSU3C6rTNzWv56agJv9 Gvo9tyr444dVqYAbAf6CB3E93PRpB1X1vrDU1xjXv2iuEm0v4OpUycKJJ5c+3oWh4YAB C70gcPJqIEfB/+stI65krbidPuTMnGp2piKT9J7I88nZTCjaBGA1E0zJZ0avpbDczreZ guRBpu3K3AIwwQ6e+8hFa9W/kFuPc1AilTGk0yK+RULxjIjD/TyuDY1OoJss5IjHsadN QKU97voqaw6r0E2n9IqgFUZQtKHhaFGNTLFyhQu8/IjLYVsDrzMzYasHePnqPvdd1UNG 31Kg== X-Gm-Message-State: AOAM532wc5GIIl7RqgMA0zd0BcEhVOMNje0aUZwNH/pvFjB+uscq84Gl DLihU33Am9e5Vk8OBaROtvuPzn05jxi+fQ== X-Google-Smtp-Source: ABdhPJxBDZfygoWM7Nx3x4J6+oFb/RitErtsLAWofj71x+/2CX3IuB2ITIuNxwSBVPBcY8KVrE7Zew== X-Received: by 2002:a5d:414c:: with SMTP id c12mr9183286wrq.392.1618300430134; Tue, 13 Apr 2021 00:53:50 -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 i4sm4599625wrx.56.2021.04.13.00.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 00:53:49 -0700 (PDT) Date: Tue, 13 Apr 2021 04:53:43 -0300 From: Melissa Wen To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 2/4] drm/vkms: rename cursor to plane on ops of planes composition Message-ID: <085ed9af17e0cc45e51f6befba1cd7617a36c73a.1618299945.git.melissa.srw@gmail.com> 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" 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 Reviewed-by: Daniel Vetter --- 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 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; From patchwork Tue Apr 13 07:56:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Melissa Wen X-Patchwork-Id: 12199567 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 3BB15C433ED for ; Tue, 13 Apr 2021 07:56:12 +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 CE9A4613B1 for ; Tue, 13 Apr 2021 07:56:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE9A4613B1 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 1FBC06E21C; Tue, 13 Apr 2021 07:56:11 +0000 (UTC) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 012216E21C for ; Tue, 13 Apr 2021 07:56:09 +0000 (UTC) Received: by mail-wr1-x42f.google.com with SMTP id x7so15398228wrw.10 for ; Tue, 13 Apr 2021 00:56:09 -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=mjJ4KJNwe+FBi9X8xhdF7ZWwDPbABB4kXINZ0Bg0sLs=; b=WUqe7g9OleC8DkSUp2eAm+cnGeqGD7U7YQVXRA7i3Rwb5f1wxz1clyMcbukb5SJ++I lL6xnaUK6NXp3/1iDjUZuNsLSgHUb9qwECbNXeu3suoYBj9gFIzcZOj811mzNWuueUXU iasYACw6JJpA41fwJaF6F7vXDCg5SQEFvUMt5HpUmAGVzZ9tDdTOe+KXxOHpnvi1cQCz QoisCJJNQMZArJfqIxeNZFWDomE0AtQ6brXjrKAqw+byObVk0MQGP0SD88aKcU5FZMoE dypKelBJMGK32K+oIzI9HKOlH415HBPU023BLwYiu3Yju9HsGKvdNv3v+ffdhTrTfH+t KvTg== 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=mjJ4KJNwe+FBi9X8xhdF7ZWwDPbABB4kXINZ0Bg0sLs=; b=mzo5mxfw2BpCV2evj0HOAJHvG+q0rogUY+ueFjPi3RIDt22mgFQy33PU9gqIrL5rRN 8tmZzsuI9m02AQg+fUKMpOQRbeMvX+lTy6FLI0lLaTqRhYvKVxkrIinLDJxiEMC3aJM6 UwRw4hKZ1zZZ5P8hzJci/44EDAwOGE35Dk4i7tDob7umVJ5fta2NsBmbuDVrqEQ/mJTh yOZbSBXJxpWprHw64LEpaRWVIo7dJSSm2+6EzpchTOB+qf8oEu8/cZonotje0pARjwfA lomxphEW0uBK4nryeuFZgsh7qZaDQPlgSCBf2aWZy1NLWFelUPQbs15R1fRIT61vDcWn yf7A== X-Gm-Message-State: AOAM532CAI0iDfDtBzE4AyNSZ+NbQRpCOPq37U50ZDN4Cth1b8iW/LDR e4/UPSVkcVzM2U6XNuszPcced4w+9r+riQ== X-Google-Smtp-Source: ABdhPJxzoDqNvf6G7x4EQrpAeHOlqntKGtbF5xSnedNbtEK8Lhpf+VFjQl2DRi5L4i7+P4Nk0/H0Ug== X-Received: by 2002:a05:6000:1449:: with SMTP id v9mr11793963wrx.295.1618300568321; Tue, 13 Apr 2021 00:56:08 -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 7sm18745661wry.60.2021.04.13.00.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 00:56:07 -0700 (PDT) Date: Tue, 13 Apr 2021 04:56:02 -0300 From: Melissa Wen To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 4/4] drm/vkms: add overlay support Message-ID: <792ef462f7ffcd16559a2096673d0b3b5c09777c.1618299945.git.melissa.srw@gmail.com> 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 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 Reviewed-by: Daniel Vetter --- 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 | 11 ++++++++++- drivers/gpu/drm/vkms/vkms_plane.c | 14 +++++++++++--- 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 7fe1fdb3af39..73ce1d381737 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -158,11 +158,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); @@ -177,8 +178,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; } @@ -200,7 +207,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; @@ -224,11 +231,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; @@ -236,7 +243,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 70fb79621617..ac8c9c2fa4ed 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -89,6 +89,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 6979fbc7f821..04406bd3ff02 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 vkms_plane *primary, *cursor = NULL; + struct vkms_plane *primary, *cursor = NULL, *overlay = NULL; int ret; int writeback; @@ -47,6 +47,15 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) if (IS_ERR(primary)) return PTR_ERR(primary); + if (vkmsdev->config->overlay) { + overlay = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_OVERLAY, index); + if (IS_ERR(overlay)) + return PTR_ERR(overlay); + + if (!overlay->base.possible_crtcs) + overlay->base.possible_crtcs = drm_crtc_mask(crtc); + } + if (vkmsdev->config->cursor) { cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index); if (IS_ERR(cursor)) diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index da4251aff67f..8be9eab41ea0 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -133,7 +133,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(new_plane_state, crtc_state, @@ -200,11 +200,19 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, const u32 *formats; int nformats; - if (type == DRM_PLANE_TYPE_CURSOR) { + switch (type) { + case DRM_PLANE_TYPE_PRIMARY: + formats = vkms_formats; + nformats = ARRAY_SIZE(vkms_formats); + funcs = &vkms_primary_helper_funcs; + break; + case DRM_PLANE_TYPE_CURSOR: + case DRM_PLANE_TYPE_OVERLAY: formats = vkms_plane_formats; nformats = ARRAY_SIZE(vkms_plane_formats); funcs = &vkms_primary_helper_funcs; - } else { + break; + default: formats = vkms_formats; nformats = ARRAY_SIZE(vkms_formats); funcs = &vkms_primary_helper_funcs;