From patchwork Thu Sep 6 05:17:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10590125 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 DBE756CB for ; Thu, 6 Sep 2018 09:10:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C02202A2F1 for ; Thu, 6 Sep 2018 09:10:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B42D82A4AA; Thu, 6 Sep 2018 09:10:54 +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 4AB162A2F1 for ; Thu, 6 Sep 2018 09:10:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E74966E62C; Thu, 6 Sep 2018 09:10:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-x241.google.com (mail-qt0-x241.google.com [IPv6:2607:f8b0:400d:c0d::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id C82DE6E03D for ; Thu, 6 Sep 2018 05:17:19 +0000 (UTC) Received: by mail-qt0-x241.google.com with SMTP id j7-v6so10949737qtp.2 for ; Wed, 05 Sep 2018 22:17:19 -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=C5OkSAu6iX66PNPZMa6X0p5e607fsxmVQQHSF1b+hAM=; b=BTNg3Dl/8WxxWzCej96rQbAZ9GyPSnkJ/WL7lO7aQ3niB51S/sjxnYQ4616xFFK3bj BEEnQ1jPamNMSds4162yHkaHnSFaydth0WK9DVyYpgiKGdcRYcjZMxTFzi8Va4fzP1lA JVapPxqUIu5jGW1g3FyiafCkhiFoCIzZOtHWmdR85+c1sBskFCfZPa/LbhQpQ7pgwKTR AHiPqNpTr1RwjbaW4+vU+66AgfvEb/IiXDQm1AkOosHraCAX8T3oUvQH4vc+QniL/DEY POWqCYUFIqIXKi3HyYiqi3OpjQ8LuxBI7wU8rNNqmjryb42Y9MVtnVzNlit6JYreOEld 3pJw== X-Gm-Message-State: APzg51Dv5Fdz4UIgpYA5VZRfm0tDOWLIgCLCbAEBN5VtLhYqC3fSE771 ikQ6bcHIwEjuxaCQEAkOabQNflhf X-Google-Smtp-Source: ANB0VdY5VnyaL6vw4x9GAGQtpdwzMMI9SO6WyLunyjP/rEaubIAkYUOJOg6whL7upZ93K8dm7FnJBQ== X-Received: by 2002:a0c:ad52:: with SMTP id v18-v6mr760023qvc.75.1536211038732; Wed, 05 Sep 2018 22:17:18 -0700 (PDT) Received: from haneenDRM (dyn-160-39-42-212.dyn.columbia.edu. [160.39.42.212]) by smtp.gmail.com with ESMTPSA id z123-v6sm2083544qke.68.2018.09.05.22.17.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Sep 2018 22:17:18 -0700 (PDT) Date: Thu, 6 Sep 2018 08:17:16 +0300 From: Haneen Mohammed To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 1/3] drm/vkms: Add cursor plane support Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Mailman-Approved-At: Thu, 06 Sep 2018 09:10:02 +0000 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: hamohammed.sa@gmail.com, seanpaul@chromium.org, rodrigosiqueiramelo@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add cursor plane support and update vkms_plane_atomic_check to enable positioning cursor plane. Signed-off-by: Haneen Mohammed --- v2: - nothing drivers/gpu/drm/vkms/vkms_drv.h | 11 +++++++--- drivers/gpu/drm/vkms/vkms_output.c | 16 ++++++++++++--- drivers/gpu/drm/vkms/vkms_plane.c | 33 +++++++++++++++++++++--------- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 80af6d3a65e7..b5ed90a8f19c 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -7,8 +7,8 @@ #include #include -#define XRES_MIN 32 -#define YRES_MIN 32 +#define XRES_MIN 20 +#define YRES_MIN 20 #define XRES_DEF 1024 #define YRES_DEF 768 @@ -20,6 +20,10 @@ static const u32 vkms_formats[] = { DRM_FORMAT_XRGB8888, }; +static const u32 vkms_cursor_formats[] = { + DRM_FORMAT_ARGB8888, +}; + struct vkms_crc_data { struct drm_rect src; struct drm_framebuffer fb; @@ -104,7 +108,8 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, int vkms_output_init(struct vkms_device *vkmsdev); -struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev); +struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, + enum drm_plane_type type); /* Gem stuff */ struct drm_gem_object *vkms_gem_create(struct drm_device *dev, diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 901012cb1af1..19f9ffcbf9eb 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -49,14 +49,20 @@ int vkms_output_init(struct vkms_device *vkmsdev) struct drm_connector *connector = &output->connector; struct drm_encoder *encoder = &output->encoder; struct drm_crtc *crtc = &output->crtc; - struct drm_plane *primary; + struct drm_plane *primary, *cursor = NULL; int ret; - primary = vkms_plane_init(vkmsdev); + primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY); if (IS_ERR(primary)) return PTR_ERR(primary); - ret = vkms_crtc_init(dev, crtc, primary, NULL); + cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR); + if (IS_ERR(cursor)) { + ret = PTR_ERR(cursor); + goto err_cursor; + } + + ret = vkms_crtc_init(dev, crtc, primary, cursor); if (ret) goto err_crtc; @@ -106,6 +112,10 @@ int vkms_output_init(struct vkms_device *vkmsdev) drm_crtc_cleanup(crtc); err_crtc: + 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 c91661631c76..428247d403dc 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -81,8 +81,8 @@ static const struct drm_plane_funcs vkms_plane_funcs = { .atomic_destroy_state = vkms_plane_destroy_state, }; -static void vkms_primary_plane_update(struct drm_plane *plane, - struct drm_plane_state *old_state) +static void vkms_plane_atomic_update(struct drm_plane *plane, + struct drm_plane_state *old_state) { struct vkms_plane_state *vkms_plane_state; struct vkms_crc_data *crc_data; @@ -101,6 +101,7 @@ static int vkms_plane_atomic_check(struct drm_plane *plane, struct drm_plane_state *state) { struct drm_crtc_state *crtc_state; + bool can_position = false; int ret; if (!state->fb | !state->crtc) @@ -110,15 +111,18 @@ 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) + can_position = true; + ret = drm_atomic_helper_check_plane_state(state, crtc_state, DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING, - false, true); + can_position, true); if (ret != 0) return ret; /* for now primary plane must be visible and full screen */ - if (!state->visible) + if (!state->visible && !can_position) return -EINVAL; return 0; @@ -156,15 +160,17 @@ static void vkms_cleanup_fb(struct drm_plane *plane, } static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = { - .atomic_update = vkms_primary_plane_update, + .atomic_update = vkms_plane_atomic_update, .atomic_check = vkms_plane_atomic_check, .prepare_fb = vkms_prepare_fb, .cleanup_fb = vkms_cleanup_fb, }; -struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev) +struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, + enum drm_plane_type type) { struct drm_device *dev = &vkmsdev->drm; + const struct drm_plane_helper_funcs *funcs; struct drm_plane *plane; const u32 *formats; int ret, nformats; @@ -173,19 +179,26 @@ struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev) if (!plane) return ERR_PTR(-ENOMEM); - formats = vkms_formats; - nformats = ARRAY_SIZE(vkms_formats); + if (type == DRM_PLANE_TYPE_CURSOR) { + formats = vkms_cursor_formats; + nformats = ARRAY_SIZE(vkms_cursor_formats); + funcs = &vkms_primary_helper_funcs; + } else { + formats = vkms_formats; + nformats = ARRAY_SIZE(vkms_formats); + funcs = &vkms_primary_helper_funcs; + } ret = drm_universal_plane_init(dev, plane, 0, &vkms_plane_funcs, formats, nformats, - NULL, DRM_PLANE_TYPE_PRIMARY, NULL); + NULL, type, NULL); if (ret) { kfree(plane); return ERR_PTR(ret); } - drm_plane_helper_add(plane, &vkms_primary_helper_funcs); + drm_plane_helper_add(plane, funcs); return plane; } From patchwork Thu Sep 6 05:18:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10590131 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 10E6A6CB for ; Thu, 6 Sep 2018 09:11:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E63CD2A4AF for ; Thu, 6 Sep 2018 09:11:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA2E22A607; Thu, 6 Sep 2018 09:11:35 +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 4362F2A4AF for ; Thu, 6 Sep 2018 09:11:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A1BD6E631; Thu, 6 Sep 2018 09:10:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-x244.google.com (mail-qt0-x244.google.com [IPv6:2607:f8b0:400d:c0d::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id B20956E03D for ; Thu, 6 Sep 2018 05:18:29 +0000 (UTC) Received: by mail-qt0-x244.google.com with SMTP id r37-v6so10941792qtc.0 for ; Wed, 05 Sep 2018 22:18:29 -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=CStMHNUSpwnAAAgu+HR00LEd/c8zF4dnFDQrxIYDc7E=; b=b0NiyCV8q6ok3P6VyUmsBomh1zlOpLz+xnLfKbBcGtXJXjTOv2/ImrsWmajEJPdHhH HiRGSyBXBolIhXA3CTK5hlI1abpy/wpEtX8hMGuFGA4xNVJWkOKfT1GmBld0kOhL9fmF 9Pmw1mJMnSLmF5tMkUnpnAVMetqg1AfklODX7IKmxxUPXta/uJ9xx3FTeLacDgCHez/U qd9GxDUHqjZXxTL1OtdBXwqx4IunUtSn5nORFmoLtj0yqAgeDzuvdlsEaXMa0Irw22t/ EKYx7XtcmHrDHu1VWQ6VG14Qgo2eIIjMOnWy992sVMvY2fRXWbmcnxbQYQJSes0I7NeP Vlfg== X-Gm-Message-State: APzg51A/cxLtr7ctrUI+I7jUacWjYxuzD/EOy0poxJdrDFI2nCKzhVe3 ElAvvm+TtrskFzg86MuqZab1MG+7 X-Google-Smtp-Source: ANB0VdbBeNRHXJQWKJKnCTrjk4L4kSrIP8ZpwZ2VIWARSVXkBqtyN3PacudPILO43FzShXhb+NRNJA== X-Received: by 2002:ac8:4758:: with SMTP id k24-v6mr761135qtp.232.1536211108646; Wed, 05 Sep 2018 22:18:28 -0700 (PDT) Received: from haneenDRM (dyn-160-39-42-212.dyn.columbia.edu. [160.39.42.212]) by smtp.gmail.com with ESMTPSA id u25-v6sm2076496qkk.7.2018.09.05.22.18.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Sep 2018 22:18:28 -0700 (PDT) Date: Thu, 6 Sep 2018 08:18:26 +0300 From: Haneen Mohammed To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/3] drm/vkms: Compute CRC with Cursor Plane Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Mailman-Approved-At: Thu, 06 Sep 2018 09:10:02 +0000 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: hamohammed.sa@gmail.com, seanpaul@chromium.org, rodrigosiqueiramelo@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch compute CRC for output frame with cursor and primary plane. Blend cursor with primary plane and compute CRC on the resulted frame. This currently passes cursor-size-change, and cursor-64x64-[onscreen, offscreen, sliding, random, dpms, rapid-movement] from igt kms_cursor_crc tests. Signed-off-by: Haneen Mohammed --- v2: - clear alpha channel before computing crc for XRGB drivers/gpu/drm/vkms/vkms_crc.c | 154 +++++++++++++++++++++++++----- drivers/gpu/drm/vkms/vkms_drv.h | 5 +- drivers/gpu/drm/vkms/vkms_plane.c | 10 +- 3 files changed, 143 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crc.c b/drivers/gpu/drm/vkms/vkms_crc.c index 68db42f15086..0a2745646dfa 100644 --- a/drivers/gpu/drm/vkms/vkms_crc.c +++ b/drivers/gpu/drm/vkms/vkms_crc.c @@ -1,36 +1,143 @@ // SPDX-License-Identifier: GPL-2.0 #include "vkms_drv.h" #include +#include +#include #include -static uint32_t _vkms_get_crc(struct vkms_crc_data *crc_data) +/** + * compute_crc - Compute CRC value on output frame + * + * @vaddr_out: address to final framebuffer + * @crc_out: framebuffer's metadata + * + * returns CRC value computed using crc32 on the visible portion of + * the final framebuffer at vaddr_out + */ +static uint32_t compute_crc(void *vaddr_out, struct vkms_crc_data *crc_out) +{ + int i, j, src_offset; + int x_src = crc_out->src.x1 >> 16; + int y_src = crc_out->src.y1 >> 16; + int h_src = drm_rect_height(&crc_out->src) >> 16; + int w_src = drm_rect_width(&crc_out->src) >> 16; + u32 crc = 0; + + for (i = y_src; i < y_src + h_src; ++i) { + for (j = x_src; j < x_src + w_src; ++j) { + src_offset = crc_out->offset + + (i * crc_out->pitch) + + (j * crc_out->cpp); + /* XRGB format ignores Alpha channel */ + memset(vaddr_out + src_offset + 24, 0, 8); + crc = crc32_le(crc, vaddr_out + src_offset, + sizeof(u32)); + } + } + + return crc; +} + +/** + * blend - belnd value at vaddr_src with value at vaddr_dst + * @vaddr_dst: destination address + * @vaddr_src: source address + * @crc_dst: destination framebuffer's metadata + * @crc_src: source framebuffer's metadata + * + * Blend value at vaddr_src with value at vaddr_dst. + * Currently, this function write value at vaddr_src on value + * at vaddr_dst using buffer's metadata to locate the new values + * from vaddr_src and their distenation at vaddr_dst. + * + * Todo: Use the alpha value to blend vaddr_src with vaddr_dst + * instead of overwriting it. + */ +static void blend(void *vaddr_dst, void *vaddr_src, + struct vkms_crc_data *crc_dst, + struct vkms_crc_data *crc_src) { - struct drm_framebuffer *fb = &crc_data->fb; + int i, j, j_dst, i_dst; + int offset_src, offset_dst; + + int x_src = crc_src->src.x1 >> 16; + int y_src = crc_src->src.y1 >> 16; + + int x_dst = crc_src->dst.x1; + int y_dst = crc_src->dst.y1; + int h_dst = drm_rect_height(&crc_src->dst); + int w_dst = drm_rect_width(&crc_src->dst); + + 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 = crc_dst->offset + + (i_dst * crc_dst->pitch) + + (j_dst++ * crc_dst->cpp); + offset_src = crc_src->offset + + (i * crc_src->pitch) + + (j * crc_src->cpp); + + memcpy(vaddr_dst + offset_dst, + vaddr_src + offset_src, sizeof(u32)); + } + i_dst++; + } +} + +static void compose_cursor(struct vkms_crc_data *cursor_crc, + struct vkms_crc_data *primary_crc, void *vaddr_out) +{ + struct drm_gem_object *cursor_obj; + struct vkms_gem_object *cursor_vkms_obj; + + cursor_obj = drm_gem_fb_get_obj(&cursor_crc->fb, 0); + cursor_vkms_obj = drm_gem_to_vkms_gem(cursor_obj); + + mutex_lock(&cursor_vkms_obj->pages_lock); + if (!cursor_vkms_obj->vaddr) { + DRM_WARN("cursor plane vaddr is NULL"); + goto out; + } + + blend(vaddr_out, cursor_vkms_obj->vaddr, primary_crc, cursor_crc); + +out: + mutex_unlock(&cursor_vkms_obj->pages_lock); +} + +static uint32_t _vkms_get_crc(struct vkms_crc_data *primary_crc, + struct vkms_crc_data *cursor_crc) +{ + struct drm_framebuffer *fb = &primary_crc->fb; struct drm_gem_object *gem_obj = drm_gem_fb_get_obj(fb, 0); struct vkms_gem_object *vkms_obj = drm_gem_to_vkms_gem(gem_obj); + void *vaddr_out = kzalloc(vkms_obj->gem.size, GFP_KERNEL); u32 crc = 0; - int i = 0; - unsigned int x = crc_data->src.x1 >> 16; - unsigned int y = crc_data->src.y1 >> 16; - unsigned int height = drm_rect_height(&crc_data->src) >> 16; - unsigned int width = drm_rect_width(&crc_data->src) >> 16; - unsigned int cpp = fb->format->cpp[0]; - unsigned int src_offset; - unsigned int size_byte = width * cpp; - void *vaddr; - mutex_lock(&vkms_obj->pages_lock); - vaddr = vkms_obj->vaddr; - if (WARN_ON(!vaddr)) - goto out; + if (!vaddr_out) { + DRM_ERROR("Failed to allocate memory for output frame."); + return 0; + } - for (i = y; i < y + height; i++) { - src_offset = fb->offsets[0] + (i * fb->pitches[0]) + (x * cpp); - crc = crc32_le(crc, vaddr + src_offset, size_byte); + mutex_lock(&vkms_obj->pages_lock); + if (WARN_ON(!vkms_obj->vaddr)) { + mutex_unlock(&vkms_obj->pages_lock); + return crc; } -out: + memcpy(vaddr_out, vkms_obj->vaddr, vkms_obj->gem.size); mutex_unlock(&vkms_obj->pages_lock); + + if (cursor_crc) + compose_cursor(cursor_crc, primary_crc, vaddr_out); + + crc = compute_crc(vaddr_out, primary_crc); + + kfree(vaddr_out); + return crc; } @@ -53,6 +160,7 @@ void vkms_crc_work_handle(struct work_struct *work) struct vkms_device *vdev = container_of(out, struct vkms_device, output); struct vkms_crc_data *primary_crc = NULL; + struct vkms_crc_data *cursor_crc = NULL; struct drm_plane *plane; u32 crc32 = 0; u64 frame_start, frame_end; @@ -77,14 +185,14 @@ void vkms_crc_work_handle(struct work_struct *work) if (drm_framebuffer_read_refcount(&crc_data->fb) == 0) continue; - if (plane->type == DRM_PLANE_TYPE_PRIMARY) { + if (plane->type == DRM_PLANE_TYPE_PRIMARY) primary_crc = crc_data; - break; - } + else + cursor_crc = crc_data; } if (primary_crc) - crc32 = _vkms_get_crc(primary_crc); + crc32 = _vkms_get_crc(primary_crc, cursor_crc); frame_end = drm_crtc_accurate_vblank_count(crtc); diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index b5ed90a8f19c..c9723c069ebf 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -25,8 +25,11 @@ static const u32 vkms_cursor_formats[] = { }; struct vkms_crc_data { - struct drm_rect src; struct drm_framebuffer fb; + struct drm_rect src, dst; + unsigned int offset; + unsigned int pitch; + unsigned int cpp; }; /** diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 428247d403dc..7041007396ae 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -85,16 +85,22 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, struct drm_plane_state *old_state) { struct vkms_plane_state *vkms_plane_state; + struct drm_framebuffer *fb = plane->state->fb; struct vkms_crc_data *crc_data; - if (!plane->state->crtc || !plane->state->fb) + if (!plane->state->crtc || !fb) return; vkms_plane_state = to_vkms_plane_state(plane->state); + crc_data = vkms_plane_state->crc_data; memcpy(&crc_data->src, &plane->state->src, sizeof(struct drm_rect)); - memcpy(&crc_data->fb, plane->state->fb, sizeof(struct drm_framebuffer)); + memcpy(&crc_data->dst, &plane->state->dst, sizeof(struct drm_rect)); + memcpy(&crc_data->fb, fb, sizeof(struct drm_framebuffer)); drm_framebuffer_get(&crc_data->fb); + crc_data->offset = fb->offsets[0]; + crc_data->pitch = fb->pitches[0]; + crc_data->cpp = fb->format->cpp[0]; } static int vkms_plane_atomic_check(struct drm_plane *plane, From patchwork Thu Sep 6 05:19:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10590121 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 23C7B13BB for ; Thu, 6 Sep 2018 09:10:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 042972A2F1 for ; Thu, 6 Sep 2018 09:10:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECD852A2FE; Thu, 6 Sep 2018 09:10:18 +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 AA04D2A2F1 for ; Thu, 6 Sep 2018 09:10:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E28006E625; Thu, 6 Sep 2018 09:10:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-x244.google.com (mail-qt0-x244.google.com [IPv6:2607:f8b0:400d:c0d::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 06A7D6E5C8 for ; Thu, 6 Sep 2018 05:19:15 +0000 (UTC) Received: by mail-qt0-x244.google.com with SMTP id x7-v6so10928677qtk.5 for ; Wed, 05 Sep 2018 22:19:14 -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=ZY/Rxwzguv9lTcrr39nP7fK7UisY/Zox3Oks/6KTtMo=; b=DotmWJah2Yt42DMCnMqfpUT3t8LyvDIYTByASXZIs/jDDsKAxtPU8vFaP7Eq6C3Ybe mPTM4dPT0ab1ZDqbLKyu0toLtg7qqLXKz7QHJFS1IEnHkEBLPDRFsfyTcHSH8jXnjrl/ f7l+PRnK1/28ZXYowM9NdYCxPU4eP7UAG08uJYYgpWESJfWwuIBHSn1zd03X4yhhmi3l /Sp6JF995A90qYL3LKjtA53t5XeMQviciDgvJhu3JE+qHrdocU6udph+pA8BaaLy8edI 3OhIxIo2/vRw4Wo02YxKd0GvSrqAnBaFiMX9YXVQPd4vOH9u4AcNZ7D9JFufSArTj8is 5+Kg== X-Gm-Message-State: APzg51DC4/7sMGckQMItAWlCRkqGRMqSvmBvKJRkYwUXSw2RXLD5DbJk tyO3YaXyB5caYvMXo13OBqV96t3o X-Google-Smtp-Source: ANB0VdY1Y16rhG/FFJUOmEyRjeIOqCLua02G+YEwJYvJou3BG3ut9oaI2ckb7TDfbOKDe/oZEhnsXQ== X-Received: by 2002:ac8:fe7:: with SMTP id f36-v6mr752278qtk.63.1536211153987; Wed, 05 Sep 2018 22:19:13 -0700 (PDT) Received: from haneenDRM (dyn-160-39-42-212.dyn.columbia.edu. [160.39.42.212]) by smtp.gmail.com with ESMTPSA id w63-v6sm2038899qkc.52.2018.09.05.22.19.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Sep 2018 22:19:13 -0700 (PDT) Date: Thu, 6 Sep 2018 08:19:11 +0300 From: Haneen Mohammed To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 3/3] drm/vkms: Enable/Disable cursor support with module option Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Mailman-Approved-At: Thu, 06 Sep 2018 09:10:03 +0000 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: hamohammed.sa@gmail.com, seanpaul@chromium.org, rodrigosiqueiramelo@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Cursor support is not complete yet. Add module option 'enable_cursor' to enable/disable cursor support which is used for testing currently. Signed-off-by: Haneen Mohammed --- drivers/gpu/drm/vkms/vkms_drv.c | 4 ++++ drivers/gpu/drm/vkms/vkms_drv.h | 2 ++ drivers/gpu/drm/vkms/vkms_output.c | 13 ++++++++----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index bd9d4b2389bd..2d49ad31ad0b 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -21,6 +21,10 @@ static struct vkms_device *vkms_device; +bool enable_cursor; +module_param_named(enable_cursor, enable_cursor, bool, 0444); +MODULE_PARM_DESC(enable_cursor, "Enable/Disable cursor 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 c9723c069ebf..1c93990693e3 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -16,6 +16,8 @@ #define XRES_MAX 8192 #define YRES_MAX 8192 +extern bool enable_cursor; + static const u32 vkms_formats[] = { DRM_FORMAT_XRGB8888, }; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 19f9ffcbf9eb..271a0eb9042c 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -56,10 +56,12 @@ int vkms_output_init(struct vkms_device *vkmsdev) if (IS_ERR(primary)) return PTR_ERR(primary); - cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR); - if (IS_ERR(cursor)) { - ret = PTR_ERR(cursor); - goto err_cursor; + if (enable_cursor) { + cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR); + if (IS_ERR(cursor)) { + ret = PTR_ERR(cursor); + goto err_cursor; + } } ret = vkms_crtc_init(dev, crtc, primary, cursor); @@ -112,7 +114,8 @@ int vkms_output_init(struct vkms_device *vkmsdev) drm_crtc_cleanup(crtc); err_crtc: - drm_plane_cleanup(cursor); + if (enable_cursor) + drm_plane_cleanup(cursor); err_cursor: drm_plane_cleanup(primary);