From patchwork Tue Jun 18 02:42:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 11000841 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 C7F5914E5 for ; Tue, 18 Jun 2019 02:42:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B87AF2874C for ; Tue, 18 Jun 2019 02:42:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC89828A0A; Tue, 18 Jun 2019 02:42:41 +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 0D2122874C for ; Tue, 18 Jun 2019 02:42:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 56E026E0CE; Tue, 18 Jun 2019 02:42:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CEBF6E0CE for ; Tue, 18 Jun 2019 02:42:39 +0000 (UTC) Received: by mail-qk1-x741.google.com with SMTP id s22so7580055qkj.12 for ; Mon, 17 Jun 2019 19:42:39 -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=wlec/cQbN79ilcIA62j7ETPEXuZxM1Vl8+YGK7vicPE=; b=gjFSiwntvn+KHJE9s7m4D5sIbyt+MjQxh7LqU3bNJgRaZ1mCQ9foI4+qyhAqF0NaK6 4PpuIyb4nbYrxTkHwUSE0qXDQoAkMMS64xvyMh1N5Spk2r5s+U3l6dP+MVfeNSlOhU1K C/9jgPktdsYTo0+CA1t/li8P1NZvrtpxNg2foKbg5mIbVaF0vwHI/+W+SlwuGouPBzzM gm8UdM1lR/C/sLTnS3yHitw7JNdJykD1nkOyL9mFJ44J24yZv9avuqxPS83VR/wYMvQG 1NzcJLAWBpZP4DpU7pyqSFZsK9U819In4TOxmxqiN7OcSl3iLDpWNMcPy3zVXxSC9tfr /Btw== X-Gm-Message-State: APjAAAVHOY82q1Tz9knUZ0NbkV2os/NLGsOaliWBUtVJfem6tOlKVkZH oGe93VN3fbqJ/YhTnDJZnaM= X-Google-Smtp-Source: APXvYqzM6+yNmUJHDTr+5nEzxYhCkjXT7NgLVxCRPMrG8gTEANWEl/fG67mArrfESOV53aARSBl54g== X-Received: by 2002:ae9:ed0a:: with SMTP id c10mr89412855qkg.207.1560825758284; Mon, 17 Jun 2019 19:42:38 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id c16sm2678549qke.43.2019.06.17.19.42.35 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 17 Jun 2019 19:42:37 -0700 (PDT) Date: Mon, 17 Jun 2019 23:42:33 -0300 From: Rodrigo Siqueira To: Brian Starkey , Liviu Dudau , Daniel Vetter , Haneen Mohammed , Simon Ser Subject: [PATCH V2 1/5] drm/vkms: Move functions from vkms_crc to vkms_composer Message-ID: <408a662d504db1cfe13919688a4e9f7f7a6d8489.1560820888.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-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:user-agent; bh=wlec/cQbN79ilcIA62j7ETPEXuZxM1Vl8+YGK7vicPE=; b=hy5AZnnj9Sy8oB42uxpu7r94T6qFPTL3bdSzfGdNl8zDRTzuOIiSMNibJYltHAC4cZ brA8MYlM3Xqz4B6k4FuYlKDKDoZzRQpYjlPZWjXqGoU6c+QbRTdHRhm8Tz1NXjDPAhiJ QpN2QTHVDPwH5T22gJ/H28P6Yl+U0027z0t9hO/uLwfvD4LCvjAEP6PxYzwXD9nxxpwo u+qsF6jc+Sah6VQNhZnjwg485T+zUWv8cP5aMlGemK0gITwQZyntGGSXX9fe6PLpgN/R TU43u/cN/V4snL1j8FTgxd2BYE+Ylp5S/hvp2Do69nanA1szjJziLjV3HeXikt9RXFRR gjlg== 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The vkms_crc file has functions related to compose operations which are not directly associated with CRC. This patch, move those function for a new file named vkms_composer. Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/vkms/Makefile | 9 +++- drivers/gpu/drm/vkms/vkms_composer.c | 69 ++++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_composer.h | 12 +++++ drivers/gpu/drm/vkms/vkms_crc.c | 65 +------------------------- 4 files changed, 90 insertions(+), 65 deletions(-) create mode 100644 drivers/gpu/drm/vkms/vkms_composer.c create mode 100644 drivers/gpu/drm/vkms/vkms_composer.h diff --git a/drivers/gpu/drm/vkms/Makefile b/drivers/gpu/drm/vkms/Makefile index 89f09bec7b23..b4c040854bd6 100644 --- a/drivers/gpu/drm/vkms/Makefile +++ b/drivers/gpu/drm/vkms/Makefile @@ -1,4 +1,11 @@ # SPDX-License-Identifier: GPL-2.0-only -vkms-y := vkms_drv.o vkms_plane.o vkms_output.o vkms_crtc.o vkms_gem.o vkms_crc.o +vkms-y := \ + vkms_drv.o \ + vkms_plane.o \ + vkms_output.o \ + vkms_crtc.o \ + vkms_gem.o \ + vkms_composer.o \ + vkms_crc.o obj-$(CONFIG_DRM_VKMS) += vkms.o diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c new file mode 100644 index 000000000000..3d7c5e316d6e --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include "vkms_drv.h" +#include "vkms_composer.h" +#include + +/** + * blend - belnd value at vaddr_src with value at vaddr_dst + * @vaddr_dst: destination address + * @vaddr_src: source address + * @dest: destination framebuffer's metadata + * @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. + */ +void blend(void *vaddr_dst, void *vaddr_src, struct vkms_crc_data *dest, + struct vkms_crc_data *src) +{ + int i, j, j_dst, i_dst; + int offset_src, offset_dst; + + int x_src = src->src.x1 >> 16; + int y_src = src->src.y1 >> 16; + + int x_dst = src->dst.x1; + int y_dst = src->dst.y1; + int h_dst = drm_rect_height(&src->dst); + int w_dst = drm_rect_width(&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 = dest->offset + + (i_dst * dest->pitch) + + (j_dst++ * dest->cpp); + offset_src = src->offset + + (i * src->pitch) + + (j * src->cpp); + + memcpy(vaddr_dst + offset_dst, + vaddr_src + offset_src, sizeof(u32)); + } + i_dst++; + } +} + +void compose_cursor(struct vkms_crc_data *cursor, + struct vkms_crc_data *primary, void *vaddr_out) +{ + struct drm_gem_object *cursor_obj; + struct vkms_gem_object *cursor_vkms_obj; + + cursor_obj = drm_gem_fb_get_obj(&cursor->fb, 0); + cursor_vkms_obj = drm_gem_to_vkms_gem(cursor_obj); + + if (WARN_ON(!cursor_vkms_obj->vaddr)) + return; + + blend(vaddr_out, cursor_vkms_obj->vaddr, primary, cursor); +} + diff --git a/drivers/gpu/drm/vkms/vkms_composer.h b/drivers/gpu/drm/vkms/vkms_composer.h new file mode 100644 index 000000000000..53fdee17a632 --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_composer.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _VKMS_COMPOSER_H_ +#define _VKMS_COMPOSER_H_ + +void blend(void *vaddr_dst, void *vaddr_src, struct vkms_crc_data *dest, + struct vkms_crc_data *src); + +void compose_cursor(struct vkms_crc_data *cursor, + struct vkms_crc_data *primary, void *vaddr_out); + +#endif /* _VKMS_COMPOSER_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_crc.c b/drivers/gpu/drm/vkms/vkms_crc.c index 4b3146d83265..3c6a35aba494 100644 --- a/drivers/gpu/drm/vkms/vkms_crc.c +++ b/drivers/gpu/drm/vkms/vkms_crc.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ #include "vkms_drv.h" +#include "vkms_composer.h" #include #include #include @@ -39,70 +40,6 @@ static uint32_t compute_crc(void *vaddr_out, struct vkms_crc_data *crc_out) 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) -{ - 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); - - if (WARN_ON(!cursor_vkms_obj->vaddr)) - return; - - blend(vaddr_out, cursor_vkms_obj->vaddr, primary_crc, cursor_crc); -} - static uint32_t _vkms_get_crc(struct vkms_crc_data *primary_crc, struct vkms_crc_data *cursor_crc) { From patchwork Tue Jun 18 02:43:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 11000843 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 CF37214B6 for ; Tue, 18 Jun 2019 02:43:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD9C028A08 for ; Tue, 18 Jun 2019 02:43:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A248E28A0B; Tue, 18 Jun 2019 02:43:56 +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 5E78E28A08 for ; Tue, 18 Jun 2019 02:43:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A116F6E0D0; Tue, 18 Jun 2019 02:43:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4D1E76E0D0 for ; Tue, 18 Jun 2019 02:43:54 +0000 (UTC) Received: by mail-qk1-x741.google.com with SMTP id d15so7606046qkl.4 for ; Mon, 17 Jun 2019 19:43:54 -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=nX4Lct0hRbElfJ7uVhNvumeaI9+AxXzXyu4vjSUGo1M=; b=NyW8uNsvoBAo9ol7oW8It9hZpcW9GdasMk+1oHnrK57Fe4XObA77kkdRbRGhFSfJzq JGx687YDlp+NCm9kDX9F4XqpL6JHLRqNflN1sH9IMNiAY2XdJpBaQG0kZAj4Vq5Oq3ku urX/r+K8HqnCRVZ1l1em1h1NUKhQlhhZCW1DD4cE6ysxKh82lT8PBQ88AXpZbLLC2OF4 v+hVErysCUClSdIBjq0AbjRi017HUrp20S3gZzGudLHMKzluYgOreHhqgCrY5gYzdGPP T/GKn27Nm5e8+ffflNEulGI6FzkY3LLhWGDHfYGIJccY0odC1zto/y0MHBcMT/LGbjXh 4SNg== X-Gm-Message-State: APjAAAUT65cejgkpWymbIsGwr6bZ1LM9HuSM6as/RthEjgRgiJwEgDXr oBojzoyqw3PR22NjTlTSp1w= X-Google-Smtp-Source: APXvYqxaHjMOISQ9guRRmzpA9K7fPxEPwKahaqRJEEU3Oyiu+UsHUkxZRTlsd8Vnef+dSkF65wG1AA== X-Received: by 2002:a05:620a:1407:: with SMTP id d7mr80111271qkj.20.1560825833481; Mon, 17 Jun 2019 19:43:53 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id n10sm7926370qke.72.2019.06.17.19.43.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 17 Jun 2019 19:43:53 -0700 (PDT) Date: Mon, 17 Jun 2019 23:43:48 -0300 From: Rodrigo Siqueira To: Brian Starkey , Liviu Dudau , Daniel Vetter , Haneen Mohammed , Simon Ser Subject: [PATCH V2 2/5] drm/vkms: Rename crc_enabled to composer_enabled Message-ID: <1ac8e97f5884ad441e849c0399cd48ed8b6df5cb.1560820888.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-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:user-agent; bh=nX4Lct0hRbElfJ7uVhNvumeaI9+AxXzXyu4vjSUGo1M=; b=j8VmLcSzvjdb/VBg88RycwCMFYoVkDiyB70BREVjLnI/rS6u7tf/YgKFXMOIV7OKHB 8VPlv8dGUplv7FJGFKjN0ABKXZMTHe41UEEUvXk6p7BtBJZ1D6szk37oWN7ZKgb6Qpgs 14eohDBOf87aorOYeSkujUDc9oX9h/+dDCOLawoClLJ1qfRQdTMak3OFX9iG9F0V/0c8 pr4tRwousOtxRo2gbdlnWu2B/kvd0Zb8f3dUepLMfPlrKHRceNrLX1w8uGZm8u3G7ics lXf2VT2u2YBom8lUs7lotfXTJ+wwuUioh1iqUgoaA2DrZoztAYGlDE7lMHuMIs+cmOAj FSZQ== 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Rename crc_enabled to composer_enabled since it does more than just compute a CRC. Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/vkms/vkms_crc.c | 2 +- drivers/gpu/drm/vkms/vkms_crtc.c | 2 +- drivers/gpu/drm/vkms/vkms_drv.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crc.c b/drivers/gpu/drm/vkms/vkms_crc.c index 3c6a35aba494..8b215677581f 100644 --- a/drivers/gpu/drm/vkms/vkms_crc.c +++ b/drivers/gpu/drm/vkms/vkms_crc.c @@ -165,7 +165,7 @@ int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name) ret = vkms_crc_parse_source(src_name, &enabled); spin_lock_irq(&out->lock); - out->crc_enabled = enabled; + out->composer_enabled = enabled; spin_unlock_irq(&out->lock); return ret; diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 14156ed70415..24a3ff0f7ff1 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -25,7 +25,7 @@ static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer) DRM_ERROR("vkms failure on handling vblank"); state = output->crc_state; - if (state && output->crc_enabled) { + if (state && output->composer_enabled) { u64 frame = drm_crtc_accurate_vblank_count(crtc); /* update frame_start only if a queued vkms_crc_work_handle() diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 4e7450111d45..a887c05ff70e 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -72,7 +72,7 @@ struct vkms_output { spinlock_t lock; /* protected by @lock */ - bool crc_enabled; + bool composer_enabled; struct vkms_crtc_state *crc_state; spinlock_t crc_lock; From patchwork Tue Jun 18 02:45:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 11000845 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 4D57E924 for ; Tue, 18 Jun 2019 02:45:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B51A288A0 for ; Tue, 18 Jun 2019 02:45:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FAF728A00; Tue, 18 Jun 2019 02:45:13 +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 9E54428A06 for ; Tue, 18 Jun 2019 02:45:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C97E16E0D1; Tue, 18 Jun 2019 02:45:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8D9776E0D1 for ; Tue, 18 Jun 2019 02:45:10 +0000 (UTC) Received: by mail-qt1-x843.google.com with SMTP id x2so13517575qtr.0 for ; Mon, 17 Jun 2019 19:45:10 -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=Dz+adBAPcE8qvI07dIqlmwVAtO9T/l0uCjfq3X+Fk/0=; b=BnqfOuFwrzWsBAcxpSrvY1bbHayrmNXh/Et+EXGS/qn1d/2kxFDPpNnRVbza/3+hiP LNy0zFKnjH7EIAMpnxReAQ2Ep/MjqZ9thr/VfUXmaQV/n7U+PeE6FjbBWpdMCHPRoXUE easZc1rKe0GUeAsb56iKSz82AoWavSNPIq/uVYKnTrYhD9Gh3NCAUm3eca7AExOwGiG2 DGUdK0DtS85kV1OHbY7renahFE3O11YfSNG8NtEywYDNj3Wq/gC0dnSP461CWQcXJoUN rPYCkSIb97vfjnYYAtPkJ+BVdZXo1ynN7XCLmxhX5GTcyhcIb/AhZoZ5Z8H43k1pa3eF Wkag== X-Gm-Message-State: APjAAAWwWDhvG5CLmyo+J4xWCevyMV8/LkvZ0UBUYs4T8ZecknLmnDjw P0+OSEHfgo5mneugwclh1Jc= X-Google-Smtp-Source: APXvYqzmE+SzilO07+hRB3nGbI8Xd8fV9brHpP1GekfSwiVKCc/8Z3fUrjCU/xxXQkeq3u3A+VAEuA== X-Received: by 2002:ad4:5426:: with SMTP id g6mr24791223qvt.132.1560825909669; Mon, 17 Jun 2019 19:45:09 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id f68sm8133745qtb.83.2019.06.17.19.45.06 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 17 Jun 2019 19:45:09 -0700 (PDT) Date: Mon, 17 Jun 2019 23:45:04 -0300 From: Rodrigo Siqueira To: Brian Starkey , Liviu Dudau , Daniel Vetter , Haneen Mohammed , Simon Ser Subject: [PATCH V2 3/5] drm/vkms: Rename vkms_crc_data to vkms_data Message-ID: <0de57ac2d1eedf412d579796a2efedab26af7bf0.1560820888.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-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:user-agent; bh=Dz+adBAPcE8qvI07dIqlmwVAtO9T/l0uCjfq3X+Fk/0=; b=X91k3au1269cF7ErYx0NeCBvM6Ah0m0bDU7zwKjf9avUFYCLESFuLlk50/D/RXeMrq /2JqZMG6vphcLLXpmpj7NL/cqGdkqb7iW2BegoVcKGGBxeKZOJ2pLa4JyEQ4H6hjgvAS cWsSgShoCGCRcVYm427tx+zNjoUEmqLGNSd3f47ki00cNIFvKAWXIVT+2sh3PNYFh2et +PMWhmS9gW5l9hhQVWyysSWGBAUBxlrWv6babpojIUT2dcJeG1lsuTiPtmZ/zX0tH0yy 2K73o0BPF08IiR5PgonZfbavnNvLw7lwvbqe0RWKbLEw21tt6mO2fyIv/jguuwBxWGNf 2jwg== 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Rename the struct vkms_crc_data to vkms_data and also remove the CRC prefix from variables that use this struct. Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/vkms/vkms_composer.c | 8 +++---- drivers/gpu/drm/vkms/vkms_composer.h | 8 +++---- drivers/gpu/drm/vkms/vkms_crc.c | 14 +++++------ drivers/gpu/drm/vkms/vkms_drv.h | 6 ++--- drivers/gpu/drm/vkms/vkms_plane.c | 36 ++++++++++++++-------------- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 3d7c5e316d6e..c636dc672430 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -19,8 +19,8 @@ * Todo: Use the alpha value to blend vaddr_src with vaddr_dst * instead of overwriting it. */ -void blend(void *vaddr_dst, void *vaddr_src, struct vkms_crc_data *dest, - struct vkms_crc_data *src) +void blend(void *vaddr_dst, void *vaddr_src, struct vkms_data *dest, + struct vkms_data *src) { int i, j, j_dst, i_dst; int offset_src, offset_dst; @@ -52,8 +52,8 @@ void blend(void *vaddr_dst, void *vaddr_src, struct vkms_crc_data *dest, } } -void compose_cursor(struct vkms_crc_data *cursor, - struct vkms_crc_data *primary, void *vaddr_out) +void compose_cursor(struct vkms_data *cursor, struct vkms_data *primary, + void *vaddr_out) { struct drm_gem_object *cursor_obj; struct vkms_gem_object *cursor_vkms_obj; diff --git a/drivers/gpu/drm/vkms/vkms_composer.h b/drivers/gpu/drm/vkms/vkms_composer.h index 53fdee17a632..93842b4b2eed 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.h +++ b/drivers/gpu/drm/vkms/vkms_composer.h @@ -3,10 +3,10 @@ #ifndef _VKMS_COMPOSER_H_ #define _VKMS_COMPOSER_H_ -void blend(void *vaddr_dst, void *vaddr_src, struct vkms_crc_data *dest, - struct vkms_crc_data *src); +void blend(void *vaddr_dst, void *vaddr_src, struct vkms_data *dest, + struct vkms_data *src); -void compose_cursor(struct vkms_crc_data *cursor, - struct vkms_crc_data *primary, void *vaddr_out); +void compose_cursor(struct vkms_data *cursor, struct vkms_data *primary, + void *vaddr_out); #endif /* _VKMS_COMPOSER_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_crc.c b/drivers/gpu/drm/vkms/vkms_crc.c index 8b215677581f..69d0decf14af 100644 --- a/drivers/gpu/drm/vkms/vkms_crc.c +++ b/drivers/gpu/drm/vkms/vkms_crc.c @@ -16,7 +16,7 @@ * 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) +static uint32_t compute_crc(void *vaddr_out, struct vkms_data *crc_out) { int i, j, src_offset; int x_src = crc_out->src.x1 >> 16; @@ -40,8 +40,8 @@ static uint32_t compute_crc(void *vaddr_out, struct vkms_crc_data *crc_out) return crc; } -static uint32_t _vkms_get_crc(struct vkms_crc_data *primary_crc, - struct vkms_crc_data *cursor_crc) +static uint32_t _vkms_get_crc(struct vkms_data *primary_crc, + struct vkms_data *cursor_crc) { struct drm_framebuffer *fb = &primary_crc->fb; struct drm_gem_object *gem_obj = drm_gem_fb_get_obj(fb, 0); @@ -87,8 +87,8 @@ void vkms_crc_work_handle(struct work_struct *work) crc_work); struct drm_crtc *crtc = crtc_state->base.crtc; struct vkms_output *out = drm_crtc_to_vkms_output(crtc); - struct vkms_crc_data *primary_crc = NULL; - struct vkms_crc_data *cursor_crc = NULL; + struct vkms_data *primary_crc = NULL; + struct vkms_data *cursor_crc = NULL; u32 crc32 = 0; u64 frame_start, frame_end; bool crc_pending; @@ -110,10 +110,10 @@ void vkms_crc_work_handle(struct work_struct *work) return; if (crtc_state->num_active_planes >= 1) - primary_crc = crtc_state->active_planes[0]->crc_data; + primary_crc = crtc_state->active_planes[0]->data; if (crtc_state->num_active_planes == 2) - cursor_crc = crtc_state->active_planes[1]->crc_data; + cursor_crc = crtc_state->active_planes[1]->data; if (primary_crc) crc32 = _vkms_get_crc(primary_crc, cursor_crc); diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index a887c05ff70e..8d628d18105e 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -20,7 +20,7 @@ extern bool enable_cursor; -struct vkms_crc_data { +struct vkms_data { struct drm_framebuffer fb; struct drm_rect src, dst; unsigned int offset; @@ -31,11 +31,11 @@ struct vkms_crc_data { /** * vkms_plane_state - Driver specific plane state * @base: base plane state - * @crc_data: data required for CRC computation + * @data: data required for compose computation */ struct vkms_plane_state { struct drm_plane_state base; - struct vkms_crc_data *crc_data; + struct vkms_data *data; }; /** diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 0fceb6258422..8cf40297cf56 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -18,20 +18,20 @@ static struct drm_plane_state * vkms_plane_duplicate_state(struct drm_plane *plane) { struct vkms_plane_state *vkms_state; - struct vkms_crc_data *crc_data; + struct vkms_data *data; vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL); if (!vkms_state) return NULL; - crc_data = kzalloc(sizeof(*crc_data), GFP_KERNEL); - if (!crc_data) { - DRM_DEBUG_KMS("Couldn't allocate crc_data\n"); + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) { + DRM_DEBUG_KMS("Couldn't allocate vkms_data\n"); kfree(vkms_state); return NULL; } - vkms_state->crc_data = crc_data; + vkms_state->data = data; __drm_atomic_helper_plane_duplicate_state(plane, &vkms_state->base); @@ -49,12 +49,12 @@ static void vkms_plane_destroy_state(struct drm_plane *plane, /* dropping the reference we acquired in * vkms_primary_plane_update() */ - if (drm_framebuffer_read_refcount(&vkms_state->crc_data->fb)) - drm_framebuffer_put(&vkms_state->crc_data->fb); + if (drm_framebuffer_read_refcount(&vkms_state->data->fb)) + drm_framebuffer_put(&vkms_state->data->fb); } - kfree(vkms_state->crc_data); - vkms_state->crc_data = NULL; + kfree(vkms_state->data); + vkms_state->data = NULL; __drm_atomic_helper_plane_destroy_state(old_state); kfree(vkms_state); @@ -91,21 +91,21 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, { struct vkms_plane_state *vkms_plane_state; struct drm_framebuffer *fb = plane->state->fb; - struct vkms_crc_data *crc_data; + struct vkms_data *data; 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->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]; + data = vkms_plane_state->data; + memcpy(&data->src, &plane->state->src, sizeof(struct drm_rect)); + memcpy(&data->dst, &plane->state->dst, sizeof(struct drm_rect)); + memcpy(&data->fb, fb, sizeof(struct drm_framebuffer)); + drm_framebuffer_get(&data->fb); + data->offset = fb->offsets[0]; + data->pitch = fb->pitches[0]; + data->cpp = fb->format->cpp[0]; } static int vkms_plane_atomic_check(struct drm_plane *plane, From patchwork Tue Jun 18 02:45:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 11000847 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 57989924 for ; Tue, 18 Jun 2019 02:45:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 465B1288A7 for ; Tue, 18 Jun 2019 02:45:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3258628898; Tue, 18 Jun 2019 02:45:37 +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 C79DA28898 for ; Tue, 18 Jun 2019 02:45:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1E9DD89C89; Tue, 18 Jun 2019 02:45:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by gabe.freedesktop.org (Postfix) with ESMTPS id BA55889C89 for ; Tue, 18 Jun 2019 02:45:34 +0000 (UTC) Received: by mail-qt1-x842.google.com with SMTP id i34so8188885qta.6 for ; Mon, 17 Jun 2019 19:45:34 -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=8KPbeBe1Izb/oXnubNpoebguldEg1IGhY2Zsm9jUIkc=; b=C9Y/13HGULrLhENcIUkgMZjKi+6BIEdcXDLhLDJwlmgXWVDjBQyHaImMnxhu3xJIAw EGhhy1ZHOIzesWKXrY1A+jghtfHgkABHDHaE/hkIhB5VbA+Mfdzk1Ovo6McMLGq5PGh/ 9CfSMR9CrkJ2GK3ko2b+Y18oEBsxExzlafUp/FqkJjE31Y+KVwvZxrMdqCDxyt8HZa+r TIJnbiWRjx7De5YgelrL8nZ4xXeukYvYnwaCxovMcOZQ00z6pFrYE+5lKYxBz6mMHnH7 ndSy11p4CME3t6qIuTlJE+miwWyeXPJHHK5ORDV5Esx3mTspJTzwBqtwy4vbE41tJf8N hDRw== X-Gm-Message-State: APjAAAUG5vvcvFlVjx9iLSs1kLG9Ei3PZxPnu/2/c8JVevQNYn9Il17b xgG7dnuqmHqCurw+0zoLz3U= X-Google-Smtp-Source: APXvYqyjb9meqRuihmeZFMzBK6sW+mj5SPJgPZKeAR4jCHZ6vjWkicT6mbIE3vqb/ZHfyqiL5cb5Yw== X-Received: by 2002:ac8:4442:: with SMTP id m2mr17809198qtn.107.1560825933887; Mon, 17 Jun 2019 19:45:33 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id s64sm7140356qkb.56.2019.06.17.19.45.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 17 Jun 2019 19:45:33 -0700 (PDT) Date: Mon, 17 Jun 2019 23:45:29 -0300 From: Rodrigo Siqueira To: Brian Starkey , Liviu Dudau , Daniel Vetter , Haneen Mohammed , Simon Ser Subject: [PATCH V2 4/5] drm/vkms: Use index instead of 0 in possible crtc Message-ID: <971da2ede86d11357e6822409bef23cb03869f83.1560820888.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-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:user-agent; bh=8KPbeBe1Izb/oXnubNpoebguldEg1IGhY2Zsm9jUIkc=; b=jIFUNwNOQDgYQ+LupPGr48TtotyUTjpb9+gsc7h4cEidc+lFsVhBVavMi2fttyL6WP DhlEaZjRsstTTIy5yBGjHeOCYwTJ00hChejyepsRC62T+97ppWDMd82ovALdPSWhspQZ dN5zOURRRWDX/bR2dJgk9XcQk/lmme5KMkfF+M6mNIqTcT2QGxOZWCNKyOVhl5vkjBk/ VEtFeuF7NabIwp29c+dvSP+T3tCc8S3tt8l4WH8mOS7hkv5ccyXXTbT/5FD7H1NWSFS3 19XD6SZyefb/WdclBRaO8rHi/pTalTXZBMJpqaieCp8iFjmTrn0oY/43ufre+HGdId0C XEWA== 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When vkms calls drm_universal_plane_init(), it sets 0 for the possible_crtcs parameter which works well for a single encoder and connector; however, this approach is not flexible and does not fit well for vkms. This commit adds an index parameter for vkms_plane_init() which makes code flexible and enables vkms to support other DRM features. Signed-off-by: Rodrigo Siqueira Reviewed-by: Daniel Vetter --- drivers/gpu/drm/vkms/vkms_drv.c | 2 +- drivers/gpu/drm/vkms/vkms_drv.h | 4 ++-- drivers/gpu/drm/vkms/vkms_output.c | 6 +++--- drivers/gpu/drm/vkms/vkms_plane.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index cc53ef88a331..966b3d653189 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -127,7 +127,7 @@ static int vkms_modeset_init(struct vkms_device *vkmsdev) dev->mode_config.preferred_depth = 24; dev->mode_config.helper_private = &vkms_mode_config_helpers; - return vkms_output_init(vkmsdev); + return vkms_output_init(vkmsdev, 0); } static int __init vkms_init(void) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 8d628d18105e..ad63dbe5e994 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -115,10 +115,10 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, int *max_error, ktime_t *vblank_time, bool in_vblank_irq); -int vkms_output_init(struct vkms_device *vkmsdev); +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); + enum drm_plane_type type, int index); /* 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 56fb5c2a2315..fb1941a6522c 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -35,7 +35,7 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = { .get_modes = vkms_conn_get_modes, }; -int vkms_output_init(struct vkms_device *vkmsdev) +int vkms_output_init(struct vkms_device *vkmsdev, int index) { struct vkms_output *output = &vkmsdev->output; struct drm_device *dev = &vkmsdev->drm; @@ -45,12 +45,12 @@ int vkms_output_init(struct vkms_device *vkmsdev) struct drm_plane *primary, *cursor = NULL; int ret; - primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY); + primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY, index); if (IS_ERR(primary)) return PTR_ERR(primary); if (enable_cursor) { - cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR); + cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index); if (IS_ERR(cursor)) { ret = PTR_ERR(cursor); goto err_cursor; diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 8cf40297cf56..3f8e8b53f3bb 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -176,7 +176,7 @@ static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = { }; struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, - enum drm_plane_type type) + enum drm_plane_type type, int index) { struct drm_device *dev = &vkmsdev->drm; const struct drm_plane_helper_funcs *funcs; @@ -198,7 +198,7 @@ struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, funcs = &vkms_primary_helper_funcs; } - ret = drm_universal_plane_init(dev, plane, 0, + ret = drm_universal_plane_init(dev, plane, 1 << index, &vkms_plane_funcs, formats, nformats, NULL, type, NULL); From patchwork Tue Jun 18 02:45:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 11000849 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 EA87514B6 for ; Tue, 18 Jun 2019 02:46:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D725D28A00 for ; Tue, 18 Jun 2019 02:46:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA5D428A06; Tue, 18 Jun 2019 02:46:03 +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 3458728A00 for ; Tue, 18 Jun 2019 02:46:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 68CB089D8D; Tue, 18 Jun 2019 02:46:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by gabe.freedesktop.org (Postfix) with ESMTPS id B7F1889D8D for ; Tue, 18 Jun 2019 02:46:00 +0000 (UTC) Received: by mail-qk1-x742.google.com with SMTP id d15so7608340qkl.4 for ; Mon, 17 Jun 2019 19:46:00 -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=hnmSbaPYoH9LcJj1HTI+NTdpL8T7oL5uLDV7aWkGRYw=; b=j9QgpBz0TAvmemQrjP3zRq6wPTA48452SmWp1z3QQ8xfTlSGcrb5KNzBlDWODbD3Wv KpnRc/ef+YxT1CQbI62UOew6sP//qwW0drUCBVBapThbwQIaweumJv4OG9aA16kNJNXH G8UY+zNitM6CfMhJfCJ74RzMlYGjbN2atGJYmC4JXMjH0UHbimdRwAWWFaVPaWy2y3Nh lYKS1eSdnK+uCOByppYrKbbtI6WGYbJP9hJauTjXkjPDwiTM8X5J/TITAaFxnyeKwr68 fHT9XpTRjN7qfAuvu1XjuwOqz3yuOXEH+IQGHnHsDm7VMT0BRuQZmslFEcKe07jOV+Vu qxuw== X-Gm-Message-State: APjAAAVoQRaLDdS7NeRwM84YbOVY/jMHiGuXkanIXRnrEGTb79yJkPRH 6i6YKRpUW0kTDbPUw2mDrZE= X-Google-Smtp-Source: APXvYqz5ZSIcXaacdr9jK2qHSKWsTQi7aoWbIa4fZxY/5ixtQBQYHqTqT3rg/e1mEMmfOtMjvNg+zA== X-Received: by 2002:a05:620a:16ba:: with SMTP id s26mr19866476qkj.301.1560825959838; Mon, 17 Jun 2019 19:45:59 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id 41sm9866593qtp.32.2019.06.17.19.45.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 17 Jun 2019 19:45:59 -0700 (PDT) Date: Mon, 17 Jun 2019 23:45:55 -0300 From: Rodrigo Siqueira To: Brian Starkey , Liviu Dudau , Daniel Vetter , Haneen Mohammed , Simon Ser Subject: [PATCH V2 5/5] drm/vkms: Add support for writeback Message-ID: <4787369d4927fa709da050e7481e48102842fd97.1560820888.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-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:user-agent; bh=hnmSbaPYoH9LcJj1HTI+NTdpL8T7oL5uLDV7aWkGRYw=; b=SEpfCcNYyPV3gc7A0i6Ms3EhPuoD6JobPTWX9G8KOv5NY4bsZB14/9dR/bw58P/83h p/BR9eTKXzcGKyI+kIYmdSMV8hTsBkRXWFGBdFVIuEJlzjt8PTgIsWwTGCLhSuPUA231 e/2YdhYMTzJjoPDGbMQOjtd+V1uZdTN39ypP3Ln7aTpKyWGY0vB7GG3wQwUzCwzhhsOW FhY/Tc7Q0/1/H3YGNfTZP+pTM4ZboPbBFM9tVGpvomJT2UxJBlwoVqWqhvCXMi7TP/JR VKzZRysvEs8Zvt2zHS3wK3C1+0mMHPra6tbZu0EPkLXGSpGTMoRAGb4NybcJKOGVW0c3 vOQA== 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch implements the necessary functions to add writeback support for vkms. This feature is useful for testing compositors if you don't have hardware with writeback support. Change in V2: - Rework signal completion (Brian) - Integrates writeback with active_planes (Daniel) - Compose cursor (Daniel) Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/vkms/Makefile | 3 +- drivers/gpu/drm/vkms/vkms_drv.c | 7 ++ drivers/gpu/drm/vkms/vkms_drv.h | 6 + drivers/gpu/drm/vkms/vkms_output.c | 6 + drivers/gpu/drm/vkms/vkms_writeback.c | 166 ++++++++++++++++++++++++++ 5 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/vkms/vkms_writeback.c diff --git a/drivers/gpu/drm/vkms/Makefile b/drivers/gpu/drm/vkms/Makefile index b4c040854bd6..091e6fa643d1 100644 --- a/drivers/gpu/drm/vkms/Makefile +++ b/drivers/gpu/drm/vkms/Makefile @@ -6,6 +6,7 @@ vkms-y := \ vkms_crtc.o \ vkms_gem.o \ vkms_composer.o \ - vkms_crc.o + vkms_crc.o \ + vkms_writeback.o obj-$(CONFIG_DRM_VKMS) += vkms.o diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 966b3d653189..d870779abf9d 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -30,6 +30,10 @@ bool enable_cursor; module_param_named(enable_cursor, enable_cursor, bool, 0444); MODULE_PARM_DESC(enable_cursor, "Enable/Disable cursor support"); +bool enable_writeback; +module_param_named(enable_writeback, enable_writeback, bool, 0444); +MODULE_PARM_DESC(enable_writeback, "Enable/Disable writeback connector"); + static const struct file_operations vkms_driver_fops = { .owner = THIS_MODULE, .open = drm_open, @@ -158,6 +162,9 @@ static int __init vkms_init(void) goto out_fini; } + if (enable_writeback) + DRM_INFO("Writeback connector enabled"); + ret = vkms_modeset_init(vkms_device); if (ret) goto out_fini; diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index ad63dbe5e994..bf3fa737b3d7 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #define XRES_MIN 20 @@ -19,6 +20,7 @@ #define YRES_MAX 8192 extern bool enable_cursor; +extern bool enable_writeback; struct vkms_data { struct drm_framebuffer fb; @@ -63,6 +65,7 @@ struct vkms_output { struct drm_crtc crtc; struct drm_encoder encoder; struct drm_connector connector; + struct drm_writeback_connector wb_connector; struct hrtimer vblank_hrtimer; ktime_t period_ns; struct drm_pending_vblank_event *event; @@ -143,4 +146,7 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name, size_t *values_cnt); void vkms_crc_work_handle(struct work_struct *work); +/* Writeback */ +int enable_writeback_connector(struct vkms_device *vkmsdev); + #endif /* _VKMS_DRV_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index fb1941a6522c..3b093ae8f373 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -84,6 +84,12 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) goto err_attach; } + if (enable_writeback) { + ret = enable_writeback_connector(vkmsdev); + if (ret) + DRM_ERROR("Failed to init writeback connector\n"); + } + drm_mode_config_reset(dev); return 0; diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c new file mode 100644 index 000000000000..56632eb393cb --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -0,0 +1,166 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include "vkms_drv.h" +#include "vkms_composer.h" +#include +#include +#include +#include + +static const u32 vkms_wb_formats[] = { + DRM_FORMAT_XRGB8888, +}; + +static const struct drm_connector_funcs vkms_wb_connector_funcs = { + .fill_modes = drm_helper_probe_single_connector_modes, + .destroy = drm_connector_cleanup, + .reset = drm_atomic_helper_connector_reset, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, +}; + +static int vkms_wb_encoder_atomic_check(struct drm_encoder *encoder, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) +{ + struct drm_framebuffer *fb; + const struct drm_display_mode *mode = &crtc_state->mode; + + if (!conn_state->writeback_job || !conn_state->writeback_job->fb) + return 0; + + fb = conn_state->writeback_job->fb; + if (fb->width != mode->hdisplay || fb->height != mode->vdisplay) { + DRM_DEBUG_KMS("Invalid framebuffer size %ux%u\n", + fb->width, fb->height); + return -EINVAL; + } + + if (fb->format->format != DRM_FORMAT_XRGB8888) { + struct drm_format_name_buf format_name; + + DRM_DEBUG_KMS("Invalid pixel format %s\n", + drm_get_format_name(fb->format->format, + &format_name)); + return -EINVAL; + } + + return 0; +} + +static const struct drm_encoder_helper_funcs vkms_wb_encoder_helper_funcs = { + .atomic_check = vkms_wb_encoder_atomic_check, +}; + +static int vkms_wb_connector_get_modes(struct drm_connector *connector) +{ + struct drm_device *dev = connector->dev; + + return drm_add_modes_noedid(connector, dev->mode_config.max_width, + dev->mode_config.max_height); +} + +static int vkms_wb_prepare_job(struct drm_writeback_connector *wb_connector, + struct drm_writeback_job *job) +{ + struct vkms_gem_object *vkms_obj; + struct drm_gem_object *gem_obj; + int ret; + + if (!job->fb) + return 0; + + gem_obj = drm_gem_fb_get_obj(job->fb, 0); + ret = vkms_gem_vmap(gem_obj); + if (ret) { + DRM_ERROR("vmap failed: %d\n", ret); + return ret; + } + + vkms_obj = drm_gem_to_vkms_gem(gem_obj); + job->priv = vkms_obj->vaddr; + + return 0; +} + +static void vkms_wb_cleanup_job(struct drm_writeback_connector *connector, + struct drm_writeback_job *job) +{ + struct drm_gem_object *gem_obj; + + if (!job->fb) + return; + + gem_obj = drm_gem_fb_get_obj(job->fb, 0); + vkms_gem_vunmap(gem_obj); +} + +static void vkms_wb_atomic_commit(struct drm_connector *conn, + struct drm_connector_state *state) +{ + struct vkms_device *vkmsdev = drm_device_to_vkms_device(conn->dev); + struct vkms_output *output = &vkmsdev->output; + struct vkms_crtc_state *crtc_state = output->crc_state; + struct drm_writeback_connector *wb_conn = &output->wb_connector; + struct drm_connector_state *conn_state = wb_conn->base.state; + void *priv_data = conn_state->writeback_job->priv; + struct vkms_data *primary_data = NULL; + struct vkms_data *cursor_data = NULL; + struct drm_framebuffer *fb = NULL; + struct vkms_gem_object *vkms_obj; + struct drm_gem_object *gem_obj; + + if (!conn_state) + return; + + if (!conn_state->writeback_job || !conn_state->writeback_job->fb) { + DRM_DEBUG_DRIVER("Disable writeback\n"); + return; + } + + if (crtc_state->num_active_planes >= 1) + primary_data = crtc_state->active_planes[0]->data; + + if (crtc_state->num_active_planes == 2) + cursor_data = crtc_state->active_planes[1]->data; + + if (!primary_data) + return; + + fb = &primary_data->fb; + gem_obj = drm_gem_fb_get_obj(fb, 0); + vkms_obj = drm_gem_to_vkms_gem(gem_obj); + + if (!vkms_obj->vaddr || !priv_data) + return; + + drm_writeback_queue_job(wb_conn, state); + + memcpy(priv_data, vkms_obj->vaddr, vkms_obj->gem.size); + if (cursor_data) + compose_cursor(cursor_data, primary_data, priv_data); + + drm_writeback_signal_completion(wb_conn, 0); +} + +static const struct drm_connector_helper_funcs vkms_wb_conn_helper_funcs = { + .get_modes = vkms_wb_connector_get_modes, + .prepare_writeback_job = vkms_wb_prepare_job, + .cleanup_writeback_job = vkms_wb_cleanup_job, + .atomic_commit = vkms_wb_atomic_commit, +}; + +int enable_writeback_connector(struct vkms_device *vkmsdev) +{ + struct drm_writeback_connector *wb = &vkmsdev->output.wb_connector; + + vkmsdev->output.wb_connector.encoder.possible_crtcs = 1; + drm_connector_helper_add(&wb->base, &vkms_wb_conn_helper_funcs); + + return drm_writeback_connector_init(&vkmsdev->drm, wb, + &vkms_wb_connector_funcs, + &vkms_wb_encoder_helper_funcs, + vkms_wb_formats, + ARRAY_SIZE(vkms_wb_formats)); +} +