From patchwork Tue Oct 5 20:16:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Matheus Andrade Torrente X-Patchwork-Id: 12537617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5748CC433FE for ; Tue, 5 Oct 2021 20:17: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 26DD1611C0 for ; Tue, 5 Oct 2021 20:17:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 26DD1611C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B6A36EC36; Tue, 5 Oct 2021 20:17:19 +0000 (UTC) Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB9866EC36 for ; Tue, 5 Oct 2021 20:17:18 +0000 (UTC) Received: by mail-qk1-x72e.google.com with SMTP id l7so307021qkk.0 for ; Tue, 05 Oct 2021 13:17:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eQmPLWNW1IY5/Dg8Jm1l2vIuP9swkD1cu5LVox+VT4I=; b=PNG/pldsxqYbC9oCx2hEVKGUetySKmV/9Gw5YTbs6ImYpuZV8+B9ivdI7fNC+s7is6 dkgUaOx4eJ6MENUZXVL1c1AWcx/FnzYqboM8ukXUWAHJ6lwM+Z881ND/uzP6cyD8ndsh ZPQUWSvztxr7OLcpPsncd35F5J3pib9WxpQteQt1cfRpuLgeyx0gJLRQlZNU699J51j2 iCjjM8mZS3vJzwaN3ciThL/MMQ3KpdvM0gjEjMi+86Kh2O20GigaX11Lwbr6guwONYJ2 HsXAbZbcRJGj8RMFUVyHEpqgnSmNxdZks0TideI1PWkfNGQqukuKVmg23OAvUotkiHV0 8VlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eQmPLWNW1IY5/Dg8Jm1l2vIuP9swkD1cu5LVox+VT4I=; b=CDAcFddaZErXaxR2pSX5pNawJ7zMkV+RS7K5JOYTswUMao0eHRAQYj6ScTr6XAc+OH XvVrWjUEjTll+k4xfxzwrRHQOSYgreEB6fMBS4yR61KDZRntcEKiB2+/R1FNs/+l/d8z UZecM8KX4HWuzVd+bC/ha7/XMTJF4mYTUf5Chxf4NVs0C/ijmVVeNtAPk38T0HFVj4G0 2J0fHywzAMZHFR27MnR8q16NM9FBSrNg88ZcTjHcrOP3XMOF/+QBWAt6ahKFKcKSNaCS D9te3ZK7aCCU+6V9QoC+ex1XwvvEPIOlpFiQH3XtCuXaMaeKpfMtoUK8FMEqJRqoXaci TJcA== X-Gm-Message-State: AOAM530W7u/S43SLaHZEEji+8SEwjugtQlsQriJfTYZuwmpMCSry0XhI lcOZjCyHMzdXOganfTBodQA= X-Google-Smtp-Source: ABdhPJyS7pMg5Ied1Xw4G/llYOv2jaR5rl91JrAI1AzrWW/achNjVkFSaUGyiz7TZ/j3+ASMPZdgdA== X-Received: by 2002:a05:620a:49d:: with SMTP id 29mr16626521qkr.518.1633465037876; Tue, 05 Oct 2021 13:17:17 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:125:9b98::1007]) by smtp.googlemail.com with ESMTPSA id j2sm13056905qta.84.2021.10.05.13.17.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 13:17:17 -0700 (PDT) From: Igor Matheus Andrade Torrente To: rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com Cc: Igor Matheus Andrade Torrente , hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie, contact@emersion.fr, leandro.ribeiro@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lkcamp@lists.libreplanetbr.org Subject: [PATCH 1/6] drm: vkms: Replace the deprecated drm_mode_config_init Date: Tue, 5 Oct 2021 17:16:32 -0300 Message-Id: <20211005201637.58563-2-igormtorrente@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211005201637.58563-1-igormtorrente@gmail.com> References: <20211005201637.58563-1-igormtorrente@gmail.com> MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The `drm_mode_config_init` was deprecated since c3b790e commit, and it's being replaced by the `drmm_mode_config_init`. Signed-off-by: Igor Matheus Andrade Torrente --- drivers/gpu/drm/vkms/vkms_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 0ffe5f0e33f7..828868920494 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -140,8 +140,11 @@ static const struct drm_mode_config_helper_funcs vkms_mode_config_helpers = { static int vkms_modeset_init(struct vkms_device *vkmsdev) { struct drm_device *dev = &vkmsdev->drm; + int ret = drmm_mode_config_init(dev); + + if (ret < 0) + return ret; - drm_mode_config_init(dev); dev->mode_config.funcs = &vkms_mode_funcs; dev->mode_config.min_width = XRES_MIN; dev->mode_config.min_height = YRES_MIN; From patchwork Tue Oct 5 20:16:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Matheus Andrade Torrente X-Patchwork-Id: 12537619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 139AFC433EF for ; Tue, 5 Oct 2021 20:17:27 +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 D4C7361090 for ; Tue, 5 Oct 2021 20:17:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D4C7361090 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A9BC6E456; Tue, 5 Oct 2021 20:17:26 +0000 (UTC) Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F0C76E456 for ; Tue, 5 Oct 2021 20:17:25 +0000 (UTC) Received: by mail-qv1-xf34.google.com with SMTP id a16so479944qvm.2 for ; Tue, 05 Oct 2021 13:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BiKFws1LTfnXE8+X4ABwTgmNjXHoNfEwbCSS8ItVQas=; b=co4EnEkfrgrh7fi6J4fu/8uhxJYKeXyHmth9reo9jbIBZbS+fSN/s8x2BbsDKciN7U PKafyY2LqLULq3yg6bbKD/RzLNdPdqAxvt5+IwTSD7kmQWpCXtrjerrzI/RmwSuHpi5n thMYBJMtNrz/hx0XzHIZY8wj4wXK/EzXVBc+2hj8fjgy1fCv+WnbdoOGp0rO8oXUGD7d uQlaGj69Gk1I34xp3N+T7dDrgwi0J9fHHNiJns3abwigQAA+2dSc0+zBqPFSDwWa8z7f ll8aciJHLnIoJoWh8IL7AaN/oQdYnzjv3rbstXUaummgWw0AK3AjQ8wv66d/+Rn6zTMX GQEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BiKFws1LTfnXE8+X4ABwTgmNjXHoNfEwbCSS8ItVQas=; b=Mw2QmBypvdEBTZLP3f9Z6pj62UJ2fYghG9gpGHyjQE832XgMdAO3sbUAq1G2vcGp9G i0ApNwsuNRFYZy8s0ycqjzoghld6zKcBN3rid9QKYB6+y8dRGcRClOlhTHCm2DpVfCAt j9rqPjpLAxGJd8VMWPCzYgA3hAPm2wAbXK2dO4WQSPM46Bx4zoQ9uCeaAV1sWnie+z84 FezwDgg+qp2Jh15kuYmV/+X/rBrIWiQ7MCjp/drYU97fgbvzjTLfHPNpdAattfXAdIVl bKtdVSs6yCDx8e082yEq2M6LurzoCpru99Dkk64brZG7QBwJl8Q5Lp7/pjnIl7mtlkRz toSg== X-Gm-Message-State: AOAM530zMEaVc/ItF458nPqWYzTMxIN5HMruXT6kiDmFyeOs6naHkQ+g f1rWtRvj/gxrTh0fQQIFtJ4= X-Google-Smtp-Source: ABdhPJykS5ENlYXTGS/IxtP8RHgN1eD8BM3QPEdDjOciJhZSrdbmvO+fYM+ubtj3euqoGI4Ag4zl6A== X-Received: by 2002:ad4:4d07:: with SMTP id l7mr2128853qvl.32.1633465044206; Tue, 05 Oct 2021 13:17:24 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:125:9b98::1007]) by smtp.googlemail.com with ESMTPSA id j2sm13056905qta.84.2021.10.05.13.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 13:17:24 -0700 (PDT) From: Igor Matheus Andrade Torrente To: rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com Cc: Igor Matheus Andrade Torrente , hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie, contact@emersion.fr, leandro.ribeiro@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lkcamp@lists.libreplanetbr.org Subject: [PATCH 2/6] drm: vkms: Alloc the compose frame using vzalloc Date: Tue, 5 Oct 2021 17:16:33 -0300 Message-Id: <20211005201637.58563-3-igormtorrente@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211005201637.58563-1-igormtorrente@gmail.com> References: <20211005201637.58563-1-igormtorrente@gmail.com> MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently, the memory to the composition frame is being allocated using the kzmalloc. This comes with the limitation of maximum size of one page size(which in the x86_64 is 4Kb and 4MB for default and hugepage respectively). Somes test of igt (e.g. kms_plane@pixel-format) uses more than 4MB when testing some pixel formats like ARGB16161616. This problem is addessed by allocating the memory using kvzalloc that circunvents this limitation. Signed-off-by: Igor Matheus Andrade Torrente --- drivers/gpu/drm/vkms/vkms_composer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 9e8204be9a14..82f79e508f81 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -180,7 +180,7 @@ static int compose_active_planes(void **vaddr_out, int i; if (!*vaddr_out) { - *vaddr_out = kzalloc(gem_obj->size, GFP_KERNEL); + *vaddr_out = kvzalloc(gem_obj->size, GFP_KERNEL); if (!*vaddr_out) { DRM_ERROR("Cannot allocate memory for output frame."); return -ENOMEM; @@ -263,7 +263,7 @@ void vkms_composer_worker(struct work_struct *work) crtc_state); if (ret) { if (ret == -EINVAL && !wb_pending) - kfree(vaddr_out); + kvfree(vaddr_out); return; } @@ -275,7 +275,7 @@ void vkms_composer_worker(struct work_struct *work) crtc_state->wb_pending = false; spin_unlock_irq(&out->composer_lock); } else { - kfree(vaddr_out); + kvfree(vaddr_out); } /* From patchwork Tue Oct 5 20:16:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Matheus Andrade Torrente X-Patchwork-Id: 12537621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9A4AC433F5 for ; Tue, 5 Oct 2021 20:17:31 +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 8CEB061090 for ; Tue, 5 Oct 2021 20:17:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8CEB061090 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AC8056EC35; Tue, 5 Oct 2021 20:17:30 +0000 (UTC) Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by gabe.freedesktop.org (Postfix) with ESMTPS id E9B0A6EC35 for ; Tue, 5 Oct 2021 20:17:28 +0000 (UTC) Received: by mail-qt1-x82f.google.com with SMTP id e16so350076qts.4 for ; Tue, 05 Oct 2021 13:17:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MLpOU2gtDlN/t3YQqeM1ZuC76+nni+Jjgvk3fLJVQKY=; b=RwfG7yaYvor7iaI3TZc1YwftZ27vcx7i0037yizes8DSPwQ9lcL5MSDT9l0mqhKyDH iDX1hitbLAWnMbfQmw3tbHYlmxNMNVkmvzVUIzny978etjMoJ3e1qWgFHkDRtt8JwXA9 i47D7HgfjzL2YD7gkhYn/54tIbtcy4aBVkRJGWDZ/OgtY57gOYWOUPAELR/PDh4hoxku eKZe0ahF45G8hlDXaxhqw58JImQGwL1d6aFoHNYUuUmFzpk2SRailTLrmUqbTjYvMn5c Ox7Kvr29srBP1p5VHj5DAZKpqPg7TfoAx1VHqBDbTlrRTnoDx1ctxptAu85c7Y7chNTL iO1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MLpOU2gtDlN/t3YQqeM1ZuC76+nni+Jjgvk3fLJVQKY=; b=A9ApmoTe15zkOOYuf3dulCdayKrUUKu92wiN33hc8ClwFV6LWGtPKA3EaRU7oLh14f UqpJ0R3++0uCrq3oLBwuHVzCbz/AKsPyBRnL0a0Jku+gBdf3lToR8ghIPK4lRg7fivmv zd71I1oJJhWDAPL3sEc/uWjDF3PA+PamlC61cJUNQjSPNffb7AkVvvk7LV6HKs0Nt2vn H8IaTPyEAiqHupiuIkATDoftOvO+gQmvz5SSGEc0fCZh32JiS80UkAI8WJN4Y6QUBFmO FOzancF2W7cWI//vhCtfDugXqpEubf59a6KqwSXI5cPd8vMYimH3M0QicXC3nccbNaTf eIyA== X-Gm-Message-State: AOAM5320j59Ku9/GfwbV3UfdNIdh6Q1BHDIz2JgSIVxtJtoYIbWKKF6Y EXrsqLms0aCm6pDVc5AuylI= X-Google-Smtp-Source: ABdhPJyctVOHylaCsucvT+4OfzMwlJtBm8lqPYlWmlvb3RV4i5pAD1BpFisEj8qbW1OkcJN2waEaMA== X-Received: by 2002:aed:27d9:: with SMTP id m25mr22303427qtg.85.1633465048127; Tue, 05 Oct 2021 13:17:28 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:125:9b98::1007]) by smtp.googlemail.com with ESMTPSA id j2sm13056905qta.84.2021.10.05.13.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 13:17:27 -0700 (PDT) From: Igor Matheus Andrade Torrente To: rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com Cc: Igor Matheus Andrade Torrente , hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie, contact@emersion.fr, leandro.ribeiro@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lkcamp@lists.libreplanetbr.org Subject: [PATCH 3/6] drm: vkms: Replace hardcoded value of `vkms_composer.map` to DRM_FORMAT_MAX_PLANES Date: Tue, 5 Oct 2021 17:16:34 -0300 Message-Id: <20211005201637.58563-4-igormtorrente@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211005201637.58563-1-igormtorrente@gmail.com> References: <20211005201637.58563-1-igormtorrente@gmail.com> MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The `map` vector at `vkms_composer` uses a hardcoded value to define its size. If someday the maximum number of planes increases, this hardcoded value can be a problem. This value is being replaced with the DRM_FORMAT_MAX_PLANES macro. Signed-off-by: Igor Matheus Andrade Torrente Acked-by: Thomas Zimmermann --- drivers/gpu/drm/vkms/vkms_drv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index d48c23d40ce5..64e62993b06f 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -28,7 +28,7 @@ struct vkms_writeback_job { struct vkms_composer { struct drm_framebuffer fb; struct drm_rect src, dst; - struct dma_buf_map map[4]; + struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]; unsigned int offset; unsigned int pitch; unsigned int cpp; From patchwork Tue Oct 5 20:16:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Matheus Andrade Torrente X-Patchwork-Id: 12537623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE416C433F5 for ; Tue, 5 Oct 2021 20:17:36 +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 AB277611C0 for ; Tue, 5 Oct 2021 20:17:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AB277611C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 143906EC37; Tue, 5 Oct 2021 20:17:36 +0000 (UTC) Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4911B6EC37 for ; Tue, 5 Oct 2021 20:17:35 +0000 (UTC) Received: by mail-qk1-x731.google.com with SMTP id f130so239039qke.6 for ; Tue, 05 Oct 2021 13:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SiGk0N0u2kNmWFJE+qdtUv44eJh4PhxY8jpg4qljUIo=; b=qE6FbcNe2zE3FSLev1D+zWw+UKU+QeBXsQty/MKhWK0IvqdeeYmE78XFNh/CxVu9M+ CRr18MughfBb73ehlJuIF6pQJP/KI9oun8LBbJRgnYqt05Wp8GkxOEyEol1jDMt5m9V9 VtR9n+zCggYsSynnn5/NIa5t621y+J0ZxqLcWxuzG12QjfVCy4zR22iy62INZJdffPcy SUuHOU85a2i+rO+ZJ0JyPwYkPi4/U6qjCJvLDtQjvi7iEl91nIFeMnONSBtBOBVFaCSG oOdnTJKymsTdmMUBwH00rcVmv5JV1KHfGY0qcE0R72ilfjxst8THzteIWiVdI7gbuxsY S3Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SiGk0N0u2kNmWFJE+qdtUv44eJh4PhxY8jpg4qljUIo=; b=yvCAKmNdrhJI4Kmln1VL8jGLZ4UhX7qU4Trr9TQOTXYs7t80wuC/ozfIoy0PcK5gUi HktUi+LOdskdmHdVfdk/CbIZfXuyh+tb+8WWlqdSAVP06TJh/x94450AmO5GBnRBDYar Y7OTCYh8ismNR6pzvt6Uul11H5XJvc3JIuvIJ9pBn+9jrCfD+Q78q/Xtrwwg36pdB6+F +Cv38TGtU4US7uvCs4b1sBhDwWwDmolvxNypyJIpN/Q4UIdNWOoG+aPI3XFVLRlhW24e XI1N5Nx9IKjXBGFdZg5qKTY+tNZI1b51xo0uY0QNc7ePBbojzsgZpN/77bPOAME2/OH+ qwiw== X-Gm-Message-State: AOAM531D4/7Zvmw1NdcunA2jyfEvHbOqApv4Ji8Zlu1+h4Y1BVrnMaez jYa1EdoSmEfvkPtgxQ+tqqA= X-Google-Smtp-Source: ABdhPJy1bwOZXI7Zcw2koJzJ4UlX9eEJnk7Ohg5sT+jmVMGoMNjwr+0+Vy8SsIL6b1mk+I/7CRPNEQ== X-Received: by 2002:a37:8941:: with SMTP id l62mr16661388qkd.100.1633465054491; Tue, 05 Oct 2021 13:17:34 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:125:9b98::1007]) by smtp.googlemail.com with ESMTPSA id j2sm13056905qta.84.2021.10.05.13.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 13:17:34 -0700 (PDT) From: Igor Matheus Andrade Torrente To: rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com Cc: Igor Matheus Andrade Torrente , hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie, contact@emersion.fr, leandro.ribeiro@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lkcamp@lists.libreplanetbr.org Subject: [PATCH 4/6] drm: vkms: Add fb information to `vkms_writeback_job` Date: Tue, 5 Oct 2021 17:16:35 -0300 Message-Id: <20211005201637.58563-5-igormtorrente@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211005201637.58563-1-igormtorrente@gmail.com> References: <20211005201637.58563-1-igormtorrente@gmail.com> MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This commit is the groundwork to introduce new formats to the planes and writeback buffer. As part of it, a new buffer metadata field is added to `vkms_writeback_job`, this metadata is represented by the `vkms_composer` struct. This will allow us, in the future, to have different compositing and wb format types. Signed-off-by: Igor Matheus Andrade Torrente --- drivers/gpu/drm/vkms/vkms_drv.h | 10 +++++----- drivers/gpu/drm/vkms/vkms_writeback.c | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 64e62993b06f..d62f8ebd454b 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -20,11 +20,6 @@ #define XRES_MAX 8192 #define YRES_MAX 8192 -struct vkms_writeback_job { - struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]; - struct dma_buf_map data[DRM_FORMAT_MAX_PLANES]; -}; - struct vkms_composer { struct drm_framebuffer fb; struct drm_rect src, dst; @@ -34,6 +29,11 @@ struct vkms_composer { unsigned int cpp; }; +struct vkms_writeback_job { + struct dma_buf_map data[DRM_FORMAT_MAX_PLANES]; + struct vkms_composer composer; +}; + /** * vkms_plane_state - Driver specific plane state * @base: base plane state diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index 8694227f555f..5a3e12f105dc 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -75,7 +75,7 @@ static int vkms_wb_prepare_job(struct drm_writeback_connector *wb_connector, if (!vkmsjob) return -ENOMEM; - ret = drm_gem_fb_vmap(job->fb, vkmsjob->map, vkmsjob->data); + ret = drm_gem_fb_vmap(job->fb, vkmsjob->composer.map, vkmsjob->data); if (ret) { DRM_ERROR("vmap failed: %d\n", ret); goto err_kfree; @@ -99,7 +99,7 @@ static void vkms_wb_cleanup_job(struct drm_writeback_connector *connector, if (!job->fb) return; - drm_gem_fb_vunmap(job->fb, vkmsjob->map); + drm_gem_fb_vunmap(job->fb, vkmsjob->composer.map); vkmsdev = drm_device_to_vkms_device(job->fb->dev); vkms_set_composer(&vkmsdev->output, false); @@ -116,14 +116,24 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn, struct drm_writeback_connector *wb_conn = &output->wb_connector; struct drm_connector_state *conn_state = wb_conn->base.state; struct vkms_crtc_state *crtc_state = output->composer_state; + struct drm_framebuffer *fb = connector_state->writeback_job->fb; + struct vkms_writeback_job *active_wb; + struct vkms_composer *wb_composer; if (!conn_state) return; vkms_set_composer(&vkmsdev->output, true); + active_wb = conn_state->writeback_job->priv; + wb_composer = &active_wb->composer; + spin_lock_irq(&output->composer_lock); - crtc_state->active_writeback = conn_state->writeback_job->priv; + crtc_state->active_writeback = active_wb; + memcpy(&wb_composer->fb, fb, sizeof(struct drm_framebuffer)); + wb_composer->offset = fb->offsets[0]; + wb_composer->pitch = fb->pitches[0]; + wb_composer->cpp = fb->format->cpp[0]; crtc_state->wb_pending = true; spin_unlock_irq(&output->composer_lock); drm_writeback_queue_job(wb_conn, connector_state); From patchwork Tue Oct 5 20:16:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Matheus Andrade Torrente X-Patchwork-Id: 12537625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54E64C433EF for ; Tue, 5 Oct 2021 20:17:45 +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 25B6F61251 for ; Tue, 5 Oct 2021 20:17:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 25B6F61251 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 396536EC39; Tue, 5 Oct 2021 20:17:44 +0000 (UTC) Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 93C516EC39 for ; Tue, 5 Oct 2021 20:17:43 +0000 (UTC) Received: by mail-qv1-xf31.google.com with SMTP id cv2so467909qvb.5 for ; Tue, 05 Oct 2021 13:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hw6zQBB3a/F2ZAgG/KXWLByNsFS27rGehUO+SIvRQ4Q=; b=o9CDrrkODu+wta3WyPeh0D3N/zFw7tVgLZKNGjEHDkWJknzmsPiuQNguvSgXowtTfV /N2hv+AzfyBtt9LT6zfyPLctDdAuQLCQUzo3SkEu7blfSDcKT5nNY9CL+HpTPA/oFOuW fxGGsmUSY7zb3OKPsP75JlmkQMvG8Z/IqIleMgIF6KeSq015G74aY+dQr7lo0WQSAWnr eSrNyqCHhU6RNYVL28Wj2crxyNWzlQl9NKBkyeqyoOm/qONpiAlaiDWeFcqRqHtTYoSM U1SE0Ak8TxIteLUZMEvG/SVoUxJ9uMFX0eGUIKDUnNu5Xmw56I4TdEuYoaHRKQ/CTzjM un8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hw6zQBB3a/F2ZAgG/KXWLByNsFS27rGehUO+SIvRQ4Q=; b=32kmXjnqQMszt8rZaaaMPN6EcGJgGBoT7Fsf19n7qGEN8t8hj6K7ZuM1QiZynv+bUG Nf5i6pv5DBk4ZuuEkuX3LPLgyBt++QjgcNxHlNBovxdEqQ1XUlXDr/NqEDiFJ6YJbxXo t2/7bHwNOk1303Ju8bRdlodAMDOK3O0HxPso413nQSsuycpiGpKRZOng0vlWmJGtqIoK J+zJRVWfd0bfGi8ygWrGnqasXu8dzOtvn0pnWMnjyxTlaxQZGmob00KwRAgT/4TGWOCX /fLd7BQdhkRF+xNygSl2trqJg31YELyiDIHGIN/dIBoZ/f4HBDA+QDexljsCzuKh0snZ PWdg== X-Gm-Message-State: AOAM531JWcLBYpN3MEaemSB0xFNnbmZnx6y9abxU4izT2Bz5m0em+Wrq qqpoVX97J9PD3GxuBDuaQYw= X-Google-Smtp-Source: ABdhPJzTpcgNw4xSMuq6xHMghK3hfM/f1yxE9eke26u2+bu+JQuPQWijqS4vmVLi6Fot9c37dfrZXw== X-Received: by 2002:a0c:ea90:: with SMTP id d16mr24485qvp.18.1633465062843; Tue, 05 Oct 2021 13:17:42 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:125:9b98::1007]) by smtp.googlemail.com with ESMTPSA id j2sm13056905qta.84.2021.10.05.13.17.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 13:17:42 -0700 (PDT) From: Igor Matheus Andrade Torrente To: rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com Cc: Igor Matheus Andrade Torrente , hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie, contact@emersion.fr, leandro.ribeiro@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lkcamp@lists.libreplanetbr.org Subject: [PATCH 5/6] drm: vkms: Prepare `vkms_wb_encoder_atomic_check` to accept multiple formats Date: Tue, 5 Oct 2021 17:16:36 -0300 Message-Id: <20211005201637.58563-6-igormtorrente@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211005201637.58563-1-igormtorrente@gmail.com> References: <20211005201637.58563-1-igormtorrente@gmail.com> MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently, the vkms atomic check only goes through the first position of the `vkms_wb_formats` vector. This change prepares the atomic_check to check the entire vector. Signed-off-by: Igor Matheus Andrade Torrente --- drivers/gpu/drm/vkms/vkms_writeback.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index 5a3e12f105dc..56978f499203 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -30,6 +30,8 @@ static int vkms_wb_encoder_atomic_check(struct drm_encoder *encoder, { struct drm_framebuffer *fb; const struct drm_display_mode *mode = &crtc_state->mode; + bool format_supported = false; + int i; if (!conn_state->writeback_job || !conn_state->writeback_job->fb) return 0; @@ -41,7 +43,14 @@ static int vkms_wb_encoder_atomic_check(struct drm_encoder *encoder, return -EINVAL; } - if (fb->format->format != vkms_wb_formats[0]) { + for (i = 0; i < ARRAY_SIZE(vkms_wb_formats); i++) { + if (fb->format->format == vkms_wb_formats[i]) { + format_supported = true; + break; + } + } + + if (!format_supported) { DRM_DEBUG_KMS("Invalid pixel format %p4cc\n", &fb->format->format); return -EINVAL; From patchwork Tue Oct 5 20:16:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Matheus Andrade Torrente X-Patchwork-Id: 12537627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18B8FC433EF for ; Tue, 5 Oct 2021 20:17:50 +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 DD97D6141B for ; Tue, 5 Oct 2021 20:17:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DD97D6141B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 13A106EC3B; Tue, 5 Oct 2021 20:17:49 +0000 (UTC) Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by gabe.freedesktop.org (Postfix) with ESMTPS id A6AA86EC3B for ; Tue, 5 Oct 2021 20:17:47 +0000 (UTC) Received: by mail-qt1-x829.google.com with SMTP id m26so371491qtn.1 for ; Tue, 05 Oct 2021 13:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hWRdzcwy5pavNEYEELsEY50gWUTPCGMh6fXm38Kcnwg=; b=MoULmMNCc4Idu9ZImFeNa1VIhx/xzUslMv/8+5o4nSuRkW5osOBewyuxo0wtI0f/mv wz4jLSoonROXu/Wldp2TXAu/xXwzBVXFNOwp8ibWsBQ1KdOmUbdQV4LAZ56/6EIsEAo8 9nI1q+VxUoFfh9Q3+DI2gxKoLMs0p3rcGxBUbtcYXcpqm7SdZ8vURyi0zl2DFisT2aLQ wNGujKBsaRl4CeSZpUjF7zP4L4qGXOK7WI8c667OevdJActG3GMqhKJabzzqj+GHaQm0 tED16j/iyfDYcS9QucM1ZYynPWSmkVPqDdgugL9XKg/xdsE8b3uemOjZNjc44F3fROLI Te7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hWRdzcwy5pavNEYEELsEY50gWUTPCGMh6fXm38Kcnwg=; b=mcnJb/Ii2uZIVjktc4NOmgGoO1ZNHmggR98MQrAHaAIINP3tzOqAiB9+2Vh5Gufnlt 8zxDX5oQBKn8ulLIrnzT19RfIrZekOxwzWb/IuPf2egdvk83eRrTGa89j2e9MZCZzpv2 t4fn6nffwidoR2cT+Ko+QbqSVEGpSZ7Exsq7IDPWQQJOiHoVGBnLKjDdm8YUvaBC/e3X rKZgJpWj1+xlcQYwfWQXVGYc0hcBrBE1ky61N+pmucJgwRxwDnxIZR4+hOOsOle/LFtG XHK+f4F6eOTG2Pul4fcbCXxLIH00Vya24WTw/JiBNUbNLNQGzNDcNEZEQvG/bMh4eGnY R7EA== X-Gm-Message-State: AOAM533mfTKVT8+M7V/9Kx5Lz3Eg5hkgzOFRtFqdOAjxtrjOXPXWQdN4 WqlmCFJer0Ve4i4/fCfX78U= X-Google-Smtp-Source: ABdhPJz3mYgQzp0H6NaSiD0iK49qRhDH80PVSZE25keNhKKJ+X696uqWCtGvNVBHgQ+wFBfHvR8txQ== X-Received: by 2002:ac8:698f:: with SMTP id o15mr22021492qtq.104.1633465066720; Tue, 05 Oct 2021 13:17:46 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:125:9b98::1007]) by smtp.googlemail.com with ESMTPSA id j2sm13056905qta.84.2021.10.05.13.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 13:17:46 -0700 (PDT) From: Igor Matheus Andrade Torrente To: rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com Cc: Igor Matheus Andrade Torrente , hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie, contact@emersion.fr, leandro.ribeiro@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lkcamp@lists.libreplanetbr.org Subject: [PATCH 6/6] drm: vkms: Refactor the plane composer to accept new formats Date: Tue, 5 Oct 2021 17:16:37 -0300 Message-Id: <20211005201637.58563-7-igormtorrente@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211005201637.58563-1-igormtorrente@gmail.com> References: <20211005201637.58563-1-igormtorrente@gmail.com> MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently the blend function only accepts XRGB_8888 and ARGB_8888 as a color input. This patch refactors all the functions related to the plane composition to overcome this limitation. Now the blend function receives a format handler to each plane and a blend function pointer. It will take two ARGB_1616161616 pixels, one for each handler, and will use the blend function to calculate and store the final color in the output buffer. These format handlers will receive the `vkms_composer` and a pair of coordinates. And they should return the respective pixel in the ARGB_16161616 format. The blend function will receive two ARGB_16161616 pixels, x, y, and the vkms_composer of the output buffer. The method should perform the blend operation and store output to the format aforementioned ARGB_16161616. Signed-off-by: Igor Matheus Andrade Torrente Reported-by: kernel test robot Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/gpu/drm/vkms/vkms_composer.c | 275 ++++++++++++++------------- drivers/gpu/drm/vkms/vkms_formats.h | 125 ++++++++++++ 2 files changed, 271 insertions(+), 129 deletions(-) create mode 100644 drivers/gpu/drm/vkms/vkms_formats.h diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 82f79e508f81..1e7c10c02a52 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -9,18 +9,28 @@ #include #include "vkms_drv.h" - -static u32 get_pixel_from_buffer(int x, int y, const u8 *buffer, - const struct vkms_composer *composer) -{ - u32 pixel; - int src_offset = composer->offset + (y * composer->pitch) - + (x * composer->cpp); - - pixel = *(u32 *)&buffer[src_offset]; - - return pixel; -} +#include "vkms_formats.h" + +#define get_output_vkms_composer(buffer_pointer, composer) \ + ((struct vkms_composer) { \ + .fb = (struct drm_framebuffer) { \ + .format = &(struct drm_format_info) { \ + .format = DRM_FORMAT_ARGB16161616, \ + }, \ + }, \ + .map[0].vaddr = (buffer_pointer), \ + .src = (composer)->src, \ + .dst = (composer)->dst, \ + .cpp = sizeof(u64), \ + .pitch = drm_rect_width(&(composer)->dst) * sizeof(u64) \ + }) + +struct vkms_pixel_composition_functions { + u64 (*get_src_pixel)(struct vkms_composer *composer, int x, int y); + u64 (*get_dst_pixel)(struct vkms_composer *composer, int x, int y); + void (*pixel_blend)(u64 argb_src1, u64 argb_src2, int x, int y, + struct vkms_composer *dst_composer); +}; /** * compute_crc - Compute CRC value on output frame @@ -31,42 +41,33 @@ static u32 get_pixel_from_buffer(int x, int y, const u8 *buffer, * returns CRC value computed using crc32 on the visible portion of * the final framebuffer at vaddr_out */ -static uint32_t compute_crc(const u8 *vaddr, +static uint32_t compute_crc(const __le64 *vaddr, const struct vkms_composer *composer) { - int x, y; - u32 crc = 0, pixel = 0; - int x_src = composer->src.x1 >> 16; - int y_src = composer->src.y1 >> 16; - int h_src = drm_rect_height(&composer->src) >> 16; - int w_src = drm_rect_width(&composer->src) >> 16; - - for (y = y_src; y < y_src + h_src; ++y) { - for (x = x_src; x < x_src + w_src; ++x) { - pixel = get_pixel_from_buffer(x, y, vaddr, composer); - crc = crc32_le(crc, (void *)&pixel, sizeof(u32)); - } - } + int h = drm_rect_height(&composer->dst); + int w = drm_rect_width(&composer->dst); - return crc; + return crc32_le(0, (void *)vaddr, w * h * sizeof(u64)); } -static u8 blend_channel(u8 src, u8 dst, u8 alpha) +static __le16 blend_channel(u16 src, u16 dst, u16 alpha) { - u32 pre_blend; - u8 new_color; + u64 pre_blend; + u16 new_color; - pre_blend = (src * 255 + dst * (255 - alpha)); + pre_blend = (src * 0xffff + dst * (0xffff - alpha)); - /* Faster div by 255 */ - new_color = ((pre_blend + ((pre_blend + 257) >> 8)) >> 8); + new_color = DIV_ROUND_UP(pre_blend, 0xffff); - return new_color; + return cpu_to_le16(new_color); } /** * alpha_blend - alpha blending equation - * @argb_src: src pixel on premultiplied alpha mode + * @argb_src1: pixel of the source plane on premultiplied alpha mode + * @argb_src2: pixel of the destiny planes on premultiplied alpha mode + * @x: The x coodinate(width) of the pixel + * @y: The y coodinate(heigth) of the pixel * @argb_dst: dst pixel completely opaque * * blend pixels using premultiplied blend formula. The current DRM assumption @@ -74,50 +75,52 @@ static u8 blend_channel(u8 src, u8 dst, u8 alpha) * channel values. See more drm_plane_create_blend_mode_property(). Also, this * formula assumes a completely opaque background. */ -static void alpha_blend(const u8 *argb_src, u8 *argb_dst) +static void alpha_blend(u64 argb_src1, u64 argb_src2, int y, int x, + struct vkms_composer *dst_composer) { - u8 alpha; + __le16 *output_pixel = packed_pixels_addr(dst_composer, y, x); - alpha = argb_src[3]; - argb_dst[0] = blend_channel(argb_src[0], argb_dst[0], alpha); - argb_dst[1] = blend_channel(argb_src[1], argb_dst[1], alpha); - argb_dst[2] = blend_channel(argb_src[2], argb_dst[2], alpha); -} + u16 src1_a = (argb_src1 & (0xffffllu << 48)) >> 48; + u16 src1_r = (argb_src1 & (0xffffllu << 32)) >> 32; + u16 src1_g = (argb_src1 & (0xffffllu << 16)) >> 16; + u16 src1_b = argb_src1 & 0xffffllu; -/** - * x_blend - blending equation that ignores the pixel alpha - * - * overwrites RGB color value from src pixel to dst pixel. - */ -static void x_blend(const u8 *xrgb_src, u8 *xrgb_dst) -{ - memcpy(xrgb_dst, xrgb_src, sizeof(u8) * 3); + u16 src2_r = (argb_src2 & (0xffffllu << 32)) >> 32; + u16 src2_g = (argb_src2 & (0xffffllu << 16)) >> 16; + u16 src2_b = argb_src2 & 0xffffllu; + + output_pixel[0] = blend_channel(src1_b, src2_b, src1_a); + output_pixel[1] = blend_channel(src1_g, src2_g, src1_a); + output_pixel[2] = blend_channel(src1_r, src2_r, src1_a); + output_pixel[3] = 0xffff; } /** - * blend - blend value at vaddr_src with value at vaddr_dst - * @vaddr_dst: destination address - * @vaddr_src: source address - * @dst_composer: destination framebuffer's metadata * @src_composer: source framebuffer's metadata - * @pixel_blend: blending equation based on plane format + * @dst_composer: destiny framebuffer's metadata + * @funcs: A struct containing all the composition functions(get_src_pixel, + * get_dst_pixel, and pixel_blend) * - * Blend the vaddr_src value with the vaddr_dst value using a pixel blend - * equation according to the supported plane formats DRM_FORMAT_(A/XRGB8888) - * and clearing alpha channel to an completely opaque background. This function - * uses buffer's metadata to locate the new composite values at vaddr_dst. + * Using the pixel_blend function passed as parameter, this function blends + * all pixels from src planes into a output buffer. + * Information of the output buffer is in the dst_composer parameter + * and the source plane in the src_composer. + * The get_src_pixel will use the src_composer to get the respective pixel, + * convert, and return it as ARGB_16161616. + * The same is true for the dst_composer and get_dst_pixel respectively. + * And finally, the blend function will receive the dst_composer, src, + * and dst pixels. Blend, and store thre result in the output using the + * dst_composer buffer information. * * TODO: completely clear the primary plane (a = 0xff) before starting to blend * pixel color values */ -static void blend(void *vaddr_dst, void *vaddr_src, +static void blend(struct vkms_composer *src_composer, struct vkms_composer *dst_composer, - struct vkms_composer *src_composer, - void (*pixel_blend)(const u8 *, u8 *)) + struct vkms_pixel_composition_functions *funcs) { int i, j, j_dst, i_dst; - int offset_src, offset_dst; - u8 *pixel_dst, *pixel_src; + u64 pixel_dst, pixel_src; int x_src = src_composer->src.x1 >> 16; int y_src = src_composer->src.y1 >> 16; @@ -130,80 +133,101 @@ static void blend(void *vaddr_dst, void *vaddr_src, 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 = dst_composer->offset - + (i_dst * dst_composer->pitch) - + (j_dst++ * dst_composer->cpp); - offset_src = src_composer->offset - + (i * src_composer->pitch) - + (j * src_composer->cpp); - - pixel_src = (u8 *)(vaddr_src + offset_src); - pixel_dst = (u8 *)(vaddr_dst + offset_dst); - pixel_blend(pixel_src, pixel_dst); - /* clearing alpha channel (0xff)*/ - pixel_dst[3] = 0xff; + for (i = y_src, i_dst = y_dst; i < y_limit; ++i, i_dst++) { + for (j = x_src, j_dst = x_dst; j < x_limit; ++j, j_dst++) { + pixel_src = funcs->get_src_pixel(src_composer, j, i); + pixel_dst = funcs->get_dst_pixel(dst_composer, j_dst, i_dst); + + funcs->pixel_blend(pixel_src, pixel_dst, j_dst, i_dst, + dst_composer); } - i_dst++; } } -static void compose_plane(struct vkms_composer *primary_composer, - struct vkms_composer *plane_composer, - void *vaddr_out) +static u64 ((*get_pixel_fmt_transform_function(u32 format)) + (struct vkms_composer *, int, int)) { - struct drm_framebuffer *fb = &plane_composer->fb; - void *vaddr; - void (*pixel_blend)(const u8 *p_src, u8 *p_dst); + if (format == DRM_FORMAT_ARGB8888) + return &ARGB8888_to_ARGB16161616; + else if (format == DRM_FORMAT_ARGB16161616) + return &get_ARGB16161616; + else + return &XRGB8888_to_ARGB16161616; +} - if (WARN_ON(dma_buf_map_is_null(&primary_composer->map[0]))) - return; +static void ((*get_pixel_blend_function(u32 format)) + (u64, u64, int, int, struct vkms_composer *)) +{ + if (format == DRM_FORMAT_ARGB8888) + return &convert_to_ARGB8888; + else if (format == DRM_FORMAT_ARGB16161616) + return &convert_to_ARGB16161616; + else + return &convert_to_XRGB8888; +} - vaddr = plane_composer->map[0].vaddr; +static void compose_plane(struct vkms_composer *src_composer, + struct vkms_composer *dst_composer, + struct vkms_pixel_composition_functions *funcs) +{ + u32 src_format = src_composer->fb.format->format; + u32 dst_format = dst_composer->fb.format->format; - if (fb->format->format == DRM_FORMAT_ARGB8888) - pixel_blend = &alpha_blend; - else - pixel_blend = &x_blend; + funcs->get_src_pixel = get_pixel_fmt_transform_function(src_format); + funcs->get_dst_pixel = get_pixel_fmt_transform_function(dst_format); - blend(vaddr_out, vaddr, primary_composer, plane_composer, pixel_blend); + blend(src_composer, dst_composer, funcs); } -static int compose_active_planes(void **vaddr_out, - struct vkms_composer *primary_composer, - struct vkms_crtc_state *crtc_state) +static __le64 *compose_active_planes(struct vkms_composer *primary_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); - const void *vaddr; + struct vkms_plane_state **active_planes = crtc_state->active_planes; + int h = drm_rect_height(&primary_composer->dst); + int w = drm_rect_width(&primary_composer->dst); + struct vkms_pixel_composition_functions funcs; + struct vkms_composer dst_composer; + __le64 *vaddr_out; int i; - if (!*vaddr_out) { - *vaddr_out = kvzalloc(gem_obj->size, GFP_KERNEL); - if (!*vaddr_out) { - DRM_ERROR("Cannot allocate memory for output frame."); - return -ENOMEM; - } - } - if (WARN_ON(dma_buf_map_is_null(&primary_composer->map[0]))) - return -EINVAL; + return NULL; - vaddr = primary_composer->map[0].vaddr; + vaddr_out = kvzalloc(w * h * sizeof(__le64), GFP_KERNEL); + if (!vaddr_out) { + DRM_ERROR("Cannot allocate memory for output frame."); + return NULL; + } - memcpy(*vaddr_out, vaddr, gem_obj->size); + dst_composer = get_output_vkms_composer(vaddr_out, primary_composer); + funcs.pixel_blend = get_pixel_blend_function(DRM_FORMAT_ARGB16161616); + compose_plane(active_planes[0]->composer, &dst_composer, &funcs); /* If there are other planes besides primary, we consider the active * planes should be in z-order and compose them associatively: * ((primary <- overlay) <- cursor) */ + funcs.pixel_blend = alpha_blend; for (i = 1; i < crtc_state->num_active_planes; i++) - compose_plane(primary_composer, - crtc_state->active_planes[i]->composer, - *vaddr_out); + compose_plane(active_planes[i]->composer, &dst_composer, &funcs); - return 0; + return vaddr_out; +} + +static void write_wb_buffer(struct vkms_writeback_job *active_wb, + struct vkms_composer *primary_composer, + __le64 *vaddr_out) +{ + u32 dst_fb_format = active_wb->composer.fb.format->format; + struct vkms_pixel_composition_functions funcs; + struct vkms_composer src_composer; + + src_composer = get_output_vkms_composer(vaddr_out, primary_composer); + funcs.pixel_blend = get_pixel_blend_function(dst_fb_format); + active_wb->composer.src = primary_composer->src; + active_wb->composer.dst = primary_composer->dst; + + compose_plane(&src_composer, &active_wb->composer, &funcs); } /** @@ -221,14 +245,14 @@ void vkms_composer_worker(struct work_struct *work) struct vkms_crtc_state, composer_work); struct drm_crtc *crtc = crtc_state->base.crtc; + struct vkms_writeback_job *active_wb = crtc_state->active_writeback; struct vkms_output *out = drm_crtc_to_vkms_output(crtc); struct vkms_composer *primary_composer = NULL; struct vkms_plane_state *act_plane = NULL; bool crc_pending, wb_pending; - void *vaddr_out = NULL; + __le64 *vaddr_out = NULL; u32 crc32 = 0; u64 frame_start, frame_end; - int ret; spin_lock_irq(&out->composer_lock); frame_start = crtc_state->frame_start; @@ -256,28 +280,21 @@ void vkms_composer_worker(struct work_struct *work) if (!primary_composer) return; - if (wb_pending) - vaddr_out = crtc_state->active_writeback->data[0].vaddr; - - ret = compose_active_planes(&vaddr_out, primary_composer, - crtc_state); - if (ret) { - if (ret == -EINVAL && !wb_pending) - kvfree(vaddr_out); + vaddr_out = compose_active_planes(primary_composer, crtc_state); + if (!vaddr_out) return; - } - - crc32 = compute_crc(vaddr_out, primary_composer); if (wb_pending) { + write_wb_buffer(active_wb, primary_composer, vaddr_out); drm_writeback_signal_completion(&out->wb_connector, 0); spin_lock_irq(&out->composer_lock); crtc_state->wb_pending = false; spin_unlock_irq(&out->composer_lock); - } else { - kvfree(vaddr_out); } + crc32 = compute_crc(vaddr_out, primary_composer); + kvfree(vaddr_out); + /* * The worker can fall behind the vblank hrtimer, make sure we catch up. */ diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h new file mode 100644 index 000000000000..60e21adbf68d --- /dev/null +++ b/drivers/gpu/drm/vkms/vkms_formats.h @@ -0,0 +1,125 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _VKMS_FORMATS_H_ +#define _VKMS_FORMATS_H_ + +#include + +#define pixel_offset(composer, x, y) \ + ((composer)->offset + ((y) * (composer)->pitch) + ((x) * (composer)->cpp)) + +/* + * packed_pixels_addr - Get the pointer to pixel of a given pair of coordinates + * + * @composer: Buffer metadata + * @x: The x(width) coordinate of the 2D buffer + * @y: The y(Heigth) coordinate of the 2D buffer + * + * Takes the information stored in the composer, a pair of coordinates, and + * returns the address of the first color channel. + * This function assumes the channels are packed together, i.e. a color channel + * comes immediately after another. And therefore, this function doesn't work + * for YUV with chroma subsampling (e.g. YUV420 and NV21). + */ +void *packed_pixels_addr(struct vkms_composer *composer, int x, int y) +{ + int offset = pixel_offset(composer, x, y); + + return (u8 *)composer->map[0].vaddr + offset; +} + +u64 ARGB8888_to_ARGB16161616(struct vkms_composer *composer, int x, int y) +{ + u8 *pixel_addr = packed_pixels_addr(composer, x, y); + + /* + * Organizes the channels in their respective positions and converts + * the 8 bits channel to 16. + * The 257 is the "conversion ratio". This number is obtained by the + * (2^16 - 1) / (2^8 - 1) division. Which, in this case, tries to get + * the best color value in a color space with more possibilities. + * And a similar idea applies to others RGB color conversions. + */ + return ((u64)pixel_addr[3] * 257) << 48 | + ((u64)pixel_addr[2] * 257) << 32 | + ((u64)pixel_addr[1] * 257) << 16 | + ((u64)pixel_addr[0] * 257); +} + +u64 XRGB8888_to_ARGB16161616(struct vkms_composer *composer, int x, int y) +{ + u8 *pixel_addr = packed_pixels_addr(composer, x, y); + + /* + * The same as the ARGB8888 but with the alpha channel as the + * maximum value as possible. + */ + return 0xffffllu << 48 | + ((u64)pixel_addr[2] * 257) << 32 | + ((u64)pixel_addr[1] * 257) << 16 | + ((u64)pixel_addr[0] * 257); +} + +u64 get_ARGB16161616(struct vkms_composer *composer, int x, int y) +{ + __le64 *pixel_addr = packed_pixels_addr(composer, x, y); + + /* + * Because the format byte order is in little-endian and this code + * needs to run on big-endian machines too, we need modify + * the byte order from little-endian to the CPU native byte order. + */ + return le64_to_cpu(*pixel_addr); +} + +/* + * The following functions are used as blend operations. But unlike the + * `alpha_blend`, these functions take an ARGB16161616 pixel from the + * source, convert it to a specific format, and store it in the destination. + * + * They are used in the `compose_active_planes` and `write_wb_buffer` to + * copy and convert one pixel from/to the output buffer to/from + * another buffer (e.g. writeback buffer, primary plane buffer). + */ + +void convert_to_ARGB8888(u64 argb_src1, u64 argb_src2, int x, int y, + struct vkms_composer *dst_composer) +{ + u8 *pixel_addr = packed_pixels_addr(dst_composer, x, y); + + /* + * This sequence below is important because the format's byte order is + * in little-endian. In the case of the ARGB8888 the memory is + * organized this way: + * + * | Addr | = blue channel + * | Addr + 1 | = green channel + * | Addr + 2 | = Red channel + * | Addr + 3 | = Alpha channel + */ + pixel_addr[0] = DIV_ROUND_UP(argb_src1 & 0xffffllu, 257); + pixel_addr[1] = DIV_ROUND_UP((argb_src1 & (0xffffllu << 16)) >> 16, 257); + pixel_addr[2] = DIV_ROUND_UP((argb_src1 & (0xffffllu << 32)) >> 32, 257); + pixel_addr[3] = DIV_ROUND_UP((argb_src1 & (0xffffllu << 48)) >> 48, 257); +} + +void convert_to_XRGB8888(u64 argb_src1, u64 argb_src2, int x, int y, + struct vkms_composer *dst_composer) +{ + u8 *pixel_addr = packed_pixels_addr(dst_composer, x, y); + + pixel_addr[0] = DIV_ROUND_UP(argb_src1 & 0xffffllu, 257); + pixel_addr[1] = DIV_ROUND_UP((argb_src1 & (0xffffllu << 16)) >> 16, 257); + pixel_addr[2] = DIV_ROUND_UP((argb_src1 & (0xffffllu << 32)) >> 32, 257); + pixel_addr[3] = 0xff; +} + +void convert_to_ARGB16161616(u64 argb_src1, u64 argb_src2, int x, int y, + struct vkms_composer *dst_composer) +{ + __le64 *pixel_addr = packed_pixels_addr(dst_composer, x, y); + + *pixel_addr = cpu_to_le64(argb_src1); +} + +#endif /* _VKMS_FORMATS_H_ */