From patchwork Tue Mar 5 16:24:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mamta Shukla X-Patchwork-Id: 10840527 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 B6F961669 for ; Wed, 6 Mar 2019 08:09:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2C832CAFD for ; Wed, 6 Mar 2019 08:09:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96EA12CBFD; Wed, 6 Mar 2019 08:09:52 +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 223112CAFD for ; Wed, 6 Mar 2019 08:09:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2ED716E0B5; Wed, 6 Mar 2019 08:09:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8509B89E3B for ; Tue, 5 Mar 2019 16:24:52 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id q17so6070357pfh.10 for ; Tue, 05 Mar 2019 08:24:52 -0800 (PST) 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:subject:message-id:mime-version :content-disposition:user-agent; bh=zZLT74jfzw/2gDUsqBM5yTdDkj8cjaubA8Z3mVexoVw=; b=t/xDAUrskLpAElHSIn79cJZ8HnwHjq+klZ2Uk112Yg+/0zLMWEIN1JyrIQOUPYoyV8 mE+TZTfEOGdzUjoqpXwWjv1c7X2ZozX9UWymbs1Xp/gG9NYHV9ZMumxLmjbZ+f/jTG3i IU1yTwbUkCvvMdPCXT3hriq9ngxJzRY4GaAUrAi2qfGxl1Sj21Zyyr3z4672LWaQ4VOV 7AnYUkmyX8q4R0BaAv52st9x0K7mtdGrhcYJnxTk51gy9baWNDNVbmF28Czf0bk9uZvf AC7COurErimR08xVlhwaErDjAAnqeSsXUZ+6fzcnWvxUoxK9K58j31cttMkZoT1EdlE0 nZpw== X-Gm-Message-State: APjAAAWaCkQR3kbpVdJyobQPscsm9d7sp/csDW2M+bjmzqk4RRcBeJAY p/zdusN9nXThurm+NngJm84= X-Google-Smtp-Source: APXvYqwZAeQs5Bj+caCwspmt/Is3EPjQDiQmKG8CN7m08h9t5K9Lmzmssy08N0e4bRNhfo5CM4qA5g== X-Received: by 2002:a63:145b:: with SMTP id 27mr2066589pgu.74.1551803091998; Tue, 05 Mar 2019 08:24:51 -0800 (PST) Received: from armorer ([59.88.107.46]) by smtp.gmail.com with ESMTPSA id b65sm21221243pfm.127.2019.03.05.08.24.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Mar 2019 08:24:51 -0800 (PST) Date: Tue, 5 Mar 2019 21:54:47 +0530 From: Mamta Shukla To: dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch, harry.wentland@amd.com, hamohammed.sa@gmail.com, rodrigosiqueiramelo@gmail.com, manasi.d.navare@intel.com Subject: [PATCH v2] drm/vkms: Add overlay plane support Message-ID: <20190305162447.GA15792@armorer> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Mailman-Approved-At: Wed, 06 Mar 2019 08:09:28 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=zZLT74jfzw/2gDUsqBM5yTdDkj8cjaubA8Z3mVexoVw=; b=TEfB3a4DnvW7UzelMKVjR3/d/x0vC3dNqZpqxfFqXeRN0tRGHJ1R3C1t50pOmBjnc/ 7sTOqNtyH1ANkTXowI1s2AKI6+mxnnsqLq2pH1uTB4b/w80BPyEevaduqonZkFwCPenm wsUCIqy9AfzhjP872f6SKr0xCH3705wAFvdzti1eBMkGt1SmYYZHmn+4fsqyMBvdq1gE 7c1E2TPxCPHXiTjRI66ZiWA9mhSY1FRG3cwxqcc9nc0+t/aYYnFbItJcFB1djiKCi4FI K83Q5TY3kEz1R9ZULUmn0gSAmBL4RIFfTrmL33UG1KV3wjybh7OOFZQRSSO3bkIWCxt8 OZRg== 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add overlay plane support in vkms aligned with cursor and primary plane with module option 'enable_overlay' to enable/disable overlay plane while testing. This currently passes plane-position-covered-pipe-A-plane subtest from IGT kms_plane test. Signed-off-by: Mamta Shukla --- change in v2: -Fix warning: return makes pointer from integer without a cast using ERR_PTR drivers/gpu/drm/vkms/vkms_crc.c | 36 +++++++++++++++++++++++++++---- drivers/gpu/drm/vkms/vkms_drv.c | 4 ++++ drivers/gpu/drm/vkms/vkms_drv.h | 8 +++++++ drivers/gpu/drm/vkms/vkms_plane.c | 36 ++++++++++++++++++++++++++++++- 4 files changed, 79 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crc.c b/drivers/gpu/drm/vkms/vkms_crc.c index 4dd6c155363d..ac3ed863cf34 100644 --- a/drivers/gpu/drm/vkms/vkms_crc.c +++ b/drivers/gpu/drm/vkms/vkms_crc.c @@ -109,6 +109,25 @@ static void blend(void *vaddr_dst, void *vaddr_src, } } +static void compose_overlay(struct vkms_crc_data *overlay_crc, + struct vkms_crc_data *primary_crc, void *vaddr_out) { + struct drm_gem_object *overlay_obj; + struct vkms_gem_object *overlay_vkms_obj; + + overlay_obj = drm_gem_fb_get_obj(&overlay_crc->fb, 0); + overlay_vkms_obj = drm_gem_to_vkms_gem(overlay_obj); + mutex_lock(&overlay_vkms_obj->pages_lock); + if(!overlay_vkms_obj->vaddr){ + DRM_WARN("overlay palne vaddr is NULL"); + goto out; + } + + blend(vaddr_out, overlay_vkms_obj->vaddr, primary_crc, overlay_crc); + +out: + mutex_unlock(&overlay_vkms_obj->pages_lock); +} + static void compose_cursor(struct vkms_crc_data *cursor_crc, struct vkms_crc_data *primary_crc, void *vaddr_out) { @@ -131,7 +150,8 @@ static void compose_cursor(struct vkms_crc_data *cursor_crc, } static uint32_t _vkms_get_crc(struct vkms_crc_data *primary_crc, - struct vkms_crc_data *cursor_crc) + struct vkms_crc_data *cursor_crc, + struct vkms_crc_data *overlay_crc) { struct drm_framebuffer *fb = &primary_crc->fb; struct drm_gem_object *gem_obj = drm_gem_fb_get_obj(fb, 0); @@ -154,6 +174,8 @@ static uint32_t _vkms_get_crc(struct vkms_crc_data *primary_crc, memcpy(vaddr_out, vkms_obj->vaddr, vkms_obj->gem.size); mutex_unlock(&vkms_obj->pages_lock); + if (overlay_crc) + compose_overlay(overlay_crc, primary_crc, vaddr_out); if (cursor_crc) compose_cursor(cursor_crc, primary_crc, vaddr_out); @@ -184,6 +206,7 @@ void vkms_crc_work_handle(struct work_struct *work) output); struct vkms_crc_data *primary_crc = NULL; struct vkms_crc_data *cursor_crc = NULL; + struct vkms_crc_data *overlay_crc = NULL; struct drm_plane *plane; u32 crc32 = 0; u64 frame_start, frame_end; @@ -210,12 +233,17 @@ void vkms_crc_work_handle(struct work_struct *work) if (plane->type == DRM_PLANE_TYPE_PRIMARY) primary_crc = crc_data; - else + + if (plane->type == DRM_PLANE_TYPE_CURSOR) cursor_crc = crc_data; + + if (plane->type == DRM_PLANE_TYPE_OVERLAY) + overlay_crc = crc_data; } - if (primary_crc) - crc32 = _vkms_get_crc(primary_crc, cursor_crc); + if (primary_crc){ + crc32 = _vkms_get_crc(primary_crc, cursor_crc, overlay_crc); + } frame_end = drm_crtc_accurate_vblank_count(crtc); diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 738dd6206d85..b08ad6f95675 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -29,6 +29,10 @@ bool enable_cursor; module_param_named(enable_cursor, enable_cursor, bool, 0444); MODULE_PARM_DESC(enable_cursor, "Enable/Disable cursor support"); +bool enable_overlay; +module_param_named(enable_overlay, enable_overlay, bool, 0444); +MODULE_PARM_DESC(enable_overlay, "Enable/Disable overlay support"); + static const struct file_operations vkms_driver_fops = { .owner = THIS_MODULE, .open = drm_open, diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 81f1cfbeb936..81dceadfde62 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -20,6 +20,8 @@ extern bool enable_cursor; +extern bool enable_overlay; + static const u32 vkms_formats[] = { DRM_FORMAT_XRGB8888, }; @@ -28,6 +30,10 @@ static const u32 vkms_cursor_formats[] = { DRM_FORMAT_ARGB8888, }; +static const u32 vkms_overlay_formats[] ={ + DRM_FORMAT_ARGB8888, +}; + struct vkms_crc_data { struct drm_framebuffer fb; struct drm_rect src, dst; @@ -118,6 +124,8 @@ int vkms_output_init(struct vkms_device *vkmsdev); struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, enum drm_plane_type type); +struct drm_plane *vkms_overlay_init(struct vkms_device *vkmsdev); + /* Gem stuff */ struct drm_gem_object *vkms_gem_create(struct drm_device *dev, struct drm_file *file, diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 0e67d2d42f0c..d540b9500633 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -114,7 +114,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_CURSOR)|(plane->type == DRM_PLANE_TYPE_OVERLAY)) can_position = true; ret = drm_atomic_helper_check_plane_state(state, crtc_state, @@ -167,6 +167,40 @@ static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = { .cleanup_fb = vkms_cleanup_fb, }; +struct drm_plane *vkms_overlay_init(struct vkms_device *vkmsdev) +{ + struct drm_device *dev = &vkmsdev->drm; + const struct drm_plane_helper_funcs *funcs; + struct drm_plane *overlay; + const u32 *formats; + int ret, nformats; + unsigned int blend_caps = BIT(DRM_MODE_BLEND_PIXEL_NONE) | + BIT(DRM_MODE_BLEND_PREMULTI); + + overlay = kzalloc(sizeof(*overlay), GFP_KERNEL); + if (!overlay) + return ERR_PTR(-ENOMEM); + + formats = vkms_overlay_formats; + nformats = ARRAY_SIZE(vkms_overlay_formats); + funcs = &vkms_primary_helper_funcs; + drm_plane_helper_add(overlay, funcs); + drm_plane_create_alpha_property(overlay); + drm_plane_create_blend_mode_property(overlay, blend_caps); + + ret = drm_universal_plane_init(dev, overlay, 0, + &vkms_plane_funcs, + formats, nformats, + NULL, + DRM_PLANE_TYPE_OVERLAY, NULL); + if (ret){ + kfree(overlay); + return ERR_PTR(ret); + } + + return overlay; +} + struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, enum drm_plane_type type) {