From patchwork Wed Nov 17 14:19:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12624735 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 09382C433F5 for ; Wed, 17 Nov 2021 14:19: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 C544961BE3 for ; Wed, 17 Nov 2021 14:19:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C544961BE3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.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 AAE1C6E471; Wed, 17 Nov 2021 14:19:43 +0000 (UTC) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0EBBB6E051 for ; Wed, 17 Nov 2021 14:19:35 +0000 (UTC) Received: by mail-wr1-x430.google.com with SMTP id w29so4975422wra.12 for ; Wed, 17 Nov 2021 06:19:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ybygRqz89X6PWHUm5yVoNp/ouF0lEkQ3IO8ZQyZIpmw=; b=6A/IHLLB6/oQZkGwdVYvRX0+wArc2hL3/y8nPki86c+4dU8T7I50askZ82FWCnEmsS qyyvwjQhCHnDiu+tgb/XnhyIVZLR8UR7TJ6z1SutLU//aHzEXDBaApAGOQtplQNDDU/9 NKB+Ed37syi/YU6XehLpKgu366RAL8YPBozm1LGaLDrmKyY19WUy3IwxVaSzsWxZSAso giT8YIGO1RoPwwZcRt0a/1jCP6l1merJdQd9aAy34obaSgxnYkGG0Ea2QPshWVpwPNA6 WOy5SMaUiwIXoGB0Oydb44ej87rqFyVQdJBfSgNbn/p9xJYv6rSuuo0sT1cGuOIitZ2H /l1g== 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=ybygRqz89X6PWHUm5yVoNp/ouF0lEkQ3IO8ZQyZIpmw=; b=bRnZu6ouzq3G+Y38U0Sq6sSAhcRWJgOjmrRq40b5Y/Ni7shAufH/ddt/i9uv0a9x70 IfLyVunk9a6fU9+ous2I5CbPLbVepHboc4zkm/Hh1gYzZE9UbHDzZLnWnTs9pBV4Qiyn 8d0m7TobfWkthUcrobVHdrrDGNdrVA9q5LXievJZA+AzIzlKkD2oF0rI5jmVQ78bJkWu rih3ZTT5tu591vc1UY8MC36MvBeOXlpwtIKoanmCNPaDik/ZDm56JNvZQcAdqIu9qizJ zt6LOSJkXWlwDAPuTnIq/KGild2+IdXamwIJmdsPPy7Yw/rdE8YyK2qF7dy700c/0OEE 2imA== X-Gm-Message-State: AOAM533w9nrDzemxUkgNr+oXfn6yYqSO+xpcQ1jCVxydWXXMFhLAB7yU NMqw5c8h7pWskTT1mwLL+Yk1EA== X-Google-Smtp-Source: ABdhPJyGYg9Z2tde6LZd6N3n1S6Xjr7QCyaRmF3v5j14j0oLqwEn0zizDO/pf+hpuGrawjr3nMH3uw== X-Received: by 2002:a05:6000:381:: with SMTP id u1mr19710700wrf.383.1637158773387; Wed, 17 Nov 2021 06:19:33 -0800 (PST) Received: from localhost.localdomain ([2001:861:44c0:66c0:f98b:434c:566c:492d]) by smtp.gmail.com with ESMTPSA id o10sm33803wri.15.2021.11.17.06.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Nov 2021 06:19:32 -0800 (PST) From: Neil Armstrong To: tomba@kernel.org Subject: [PATCH v7 1/9] drm/omap: add sanity plane state check Date: Wed, 17 Nov 2021 15:19:20 +0100 Message-Id: <20211117141928.771082-2-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117141928.771082-1-narmstrong@baylibre.com> References: <20211117141928.771082-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2065; h=from:subject; bh=fRkx/RPkFxPenXM1+XojYlY6DoZHNd/vTOwe0D2eHgI=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhlQ9LcfQR81+VKXldrcyliXmf4wAP1+2GSxnSWUvK iH4ZMFaJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYZUPSwAKCRB33NvayMhJ0c0REA Ck1IPmCiheHrRrGeQ9Rsgt9sOU1sUsI4o8CIeVTG2Tp2iBf9DrA9Dc6A9OVkpfHkG4eaaqPvycyX0N ucX+m58NAKu89/S7Pp+Aa4Pekj8qnwae3shxOq9Lbk/SaEqqpUTYQhoSYpG1pp14LJxM07pmjQ/xgU AKusu1twKCUaWR/2LHtF+kb71frnhnvwepacO4o7UZFP0XNGd7OIbUBrBaUdtoJHrpYuxqc1TAenYq 5ApLS6cLdZ6rdo2kqXbyqtUdrUr/Ol8Hpepz+V1tUFUqkF2voOalYEngbO5jLFIoOIc7DKXi5/VSYx beo9lPw1z3gZcTLqQdQzf4aL+txhac3IfXFTM/CJTHpI+qSBtq5UZgDv5uOAiUfU3RVKr9vRrnk9ju OtNM6xGjVk22CO0NKqJW+OIE5rAvSLKtiRaR5+CzJEivfcb5Cr959TkDTawwy8Ut0j3njHyLcSIJeo wKVoMhjcCNKXfSG3QyTXly4uFYId4pgUHWZGupLtPAt1JtuTKcYO9KAR4r3rlvuC5UOw6cXBj+9GlF LQDcn7Q8fpcOFx9IxXtzpereG1wPxpfLxiUVhBf4p2j1LSORGpJC47h2C4bCvJnj8ZNaZm+S+B+qha A+dv5cgMRRwZJzBQMo8NzuDkhNwmtP4AVTh6E5J9gRGwFYehgpF+0VVRTg6A== X-Developer-Key: i=narmstrong@baylibre.com; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , khilman@baylibre.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Tomi Valkeinen , linux-omap@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Call drm_atomic_helper_check_plane_state() from the plane atomic_check() callback in order to add plane state sanity checking. It will permit filtering out totally bad scaling factors, even if the real check are done later in the atomic commit. Calling drm_atomic_helper_check_plane_state() also sets plane_state->visible which will be useful when dynamically assigning hw overlays to planes. Signed-off-by: Benoit Parrot Signed-off-by: Neil Armstrong Reviewed-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/omap_plane.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 512af976b7e9..c3de4f339387 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -104,12 +104,15 @@ static void omap_plane_atomic_disable(struct drm_plane *plane, dispc_ovl_enable(priv->dispc, omap_plane->id, false); } +#define FRAC_16_16(mult, div) (((mult) << 16) / (div)) + static int omap_plane_atomic_check(struct drm_plane *plane, struct drm_atomic_state *state) { struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane); struct drm_crtc_state *crtc_state; + int ret; if (!new_plane_state->fb) return 0; @@ -127,6 +130,18 @@ static int omap_plane_atomic_check(struct drm_plane *plane, if (!crtc_state->enable) return 0; + /* + * Note: these are just sanity checks to filter out totally bad scaling + * factors. The real limits must be calculated case by case, and + * unfortunately we currently do those checks only at the commit + * phase in dispc. + */ + ret = drm_atomic_helper_check_plane_state(new_plane_state, crtc_state, + FRAC_16_16(1, 8), FRAC_16_16(8, 1), + true, true); + if (ret) + return ret; + if (new_plane_state->crtc_x < 0 || new_plane_state->crtc_y < 0) return -EINVAL; From patchwork Wed Nov 17 14:19:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12624729 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 35935C433F5 for ; Wed, 17 Nov 2021 14:19:40 +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 01C3061BD3 for ; Wed, 17 Nov 2021 14:19:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 01C3061BD3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.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 2FB506E441; Wed, 17 Nov 2021 14:19:38 +0000 (UTC) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3BB226E3D2 for ; Wed, 17 Nov 2021 14:19:36 +0000 (UTC) Received: by mail-wr1-x42b.google.com with SMTP id i5so5055910wrb.2 for ; Wed, 17 Nov 2021 06:19:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K00jtiHR3a3nshL+n7FY4Xvtri9GsBUdjgKHR2E0gL0=; b=r4jGJ5/Ik9v/vL0506Yfiy2OfryDzslqCMp5VmzY7n55oCVnb5ZPgTjiUGP7kpNUZ5 LDMvF2ZORoJcS/Sv9YkfzcLNTqxI5o1inwHpMRNh2N/2vlm4nB1TXDBmodAZRCrR4RVw r5A35/ljAqew9aRUMu7m+uyHHi0DB4G67x+DMnYxMtmmdOFJA8QxZkWRGa+fzDBJL87r JRYR1oEI6BHfcuF17nhkhVhp6hGLgQoaMySFtF1ggGYscdu9/fPawsD1d7m6kGhLixKV 3x4kDvF1v1UGvQ6gTKOSXeFWGOLrtIkui8vZFEk95INkuctCMbDlb1Y9vwWjkiMFfLOy fG+g== 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=K00jtiHR3a3nshL+n7FY4Xvtri9GsBUdjgKHR2E0gL0=; b=thTdjzkDiOjxj1A78K1McGxFhq0hh2+SgtoZOzSlC8ytdwm/0J8egLZoW2oG5Ks4A+ o+HuivhSVfvdV6zTvq66eBjJU2usMCeXvH7IDZAmUSgRKzDUFGkIZoVI+a7tYdYOC+kC rMSUD2viEeyzfmvVQqlrDoirASVE/KyHf6T27TrgWuyRwrSW6vdLVj/0MNDcTwhvD4xS z/jZtJxPrBBN3obUBWKLwtNlKxhFywzVn6q+6VR1UUlAR7GqVWwLlCZJkWJ5M3Qkr6Ae +aiLrwd8bJYM0DksR4WYhAnqM8P7JE0KIDGXf/IC4pcoZVk4gnsSlhC4aGAdKMPZJDhX HSHA== X-Gm-Message-State: AOAM533vuV5RZMQsmUreR4l+6LVyp8wD/8Y2KA7VUJKkmv2pamc/rN4/ YuWWX8iSjTNqzpKmw/pOLobRXQ== X-Google-Smtp-Source: ABdhPJwmhx8Pg48GvIJsX9PXhjuJxleriROCHGiF3tz035a44BUgW8o0I/TRe2d9RFJrPSNiMwoSfg== X-Received: by 2002:a5d:4e09:: with SMTP id p9mr20504154wrt.28.1637158774639; Wed, 17 Nov 2021 06:19:34 -0800 (PST) Received: from localhost.localdomain ([2001:861:44c0:66c0:f98b:434c:566c:492d]) by smtp.gmail.com with ESMTPSA id o10sm33803wri.15.2021.11.17.06.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Nov 2021 06:19:33 -0800 (PST) From: Neil Armstrong To: tomba@kernel.org Subject: [PATCH v7 2/9] drm/omap: Add ability to check if requested plane modes can be supported Date: Wed, 17 Nov 2021 15:19:21 +0100 Message-Id: <20211117141928.771082-3-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117141928.771082-1-narmstrong@baylibre.com> References: <20211117141928.771082-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5947; i=narmstrong@baylibre.com; h=from:subject; bh=a0cNaFTzuPgxf5OxEz8GBwuXSBh+Ci0H5dCeEwFLoJc=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhlQ9LRs09n1oSuj2jsVit0wsHmTSBkmbnDLaWl0zQ 7wGQst+JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYZUPSwAKCRB33NvayMhJ0SftEA DHYEyKB3DMYuW4wkbpibCzyu62azioympJs6RKn9kvsMTkcAl5PhCwNV3zHGXWU0KG5GJ2YB8UdjQo RjRcq4jjLduWNTaV9/zYJw0EGGYq47BqUhWGbhxw22/KYvpuciyw9pKpSAqxdgZYYGNEaY5xuFwacU t0Kg7onfLIyMkC4ZK5HBJmsKcKfMZIr93E0xf/GXEL4dSnrKp0+xZG7aIV3V2s+nQAchRFR7F8lPEk vg3lQf12utAN2I2E/zRfNodPIsm5JBwJxRTRkHIb7c4CBaYpiV8bIi6AKZAluxQ7QjuINV3J2lqr4y 5T0OsLXIyNJwQ3Aox07O5jQEUg1dgnz4VGa2eWAaCbIEjIw8AgG2ceT4tVntB29UrmmXzwCD3xqh+y sYSMFIlV0nLC/+ttZlO6Ajxvr4SeJpbtb/GQDn0NF47lGLwDlWYw5LggfzF0RX/oMKxrTFDAYBEJI8 G9/UFzoI5y5a4aLULrd/A8NcEoVVszXew7ZkpfT8ahZpYpjOB51gdi2nnimbldng6/LNWqm6rE1u++ ve/MEfkhrfg6Go1nsGAkxPhwJ4JJFmKaM/iC5p3bydyI3m6V0CYJXsfr+tm50YAUXvVFr6etzBUKYb 32t79PkdeIbaa7Gg9rGta6FfYMxE4z1KScP6tjnvcOtdl1XsW1wm/fRaOPzA== X-Developer-Key: i=narmstrong@baylibre.com; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , khilman@baylibre.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Tomi Valkeinen , linux-omap@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Benoit Parrot We currently assume that an overlay has the same maximum width and maximum height as the overlay manager. This assumption is incorrect. On some variants the overlay manager maximum width is twice the maximum width that the overlay can handle. We need to add the appropriate data per variant as well as export a helper function to retrieve the data so check can be made dynamically in omap_plane_atomic_check(). Signed-off-by: Benoit Parrot Signed-off-by: Neil Armstrong Reviewed-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/dss/dispc.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/omapdrm/dss/dss.h | 2 ++ drivers/gpu/drm/omapdrm/omap_plane.c | 14 ++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index b440147ae28b..d3cf9d9aef63 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -92,6 +92,8 @@ struct dispc_features { u8 mgr_height_start; u16 mgr_width_max; u16 mgr_height_max; + u16 ovl_width_max; + u16 ovl_height_max; unsigned long max_lcd_pclk; unsigned long max_tv_pclk; unsigned int max_downscale; @@ -2599,6 +2601,12 @@ static int dispc_ovl_calc_scaling(struct dispc_device *dispc, return 0; } +void dispc_ovl_get_max_size(struct dispc_device *dispc, u16 *width, u16 *height) +{ + *width = dispc->feat->ovl_width_max; + *height = dispc->feat->ovl_height_max; +} + static int dispc_ovl_setup_common(struct dispc_device *dispc, enum omap_plane_id plane, enum omap_overlay_caps caps, @@ -4240,6 +4248,8 @@ static const struct dispc_features omap24xx_dispc_feats = { .mgr_height_start = 26, .mgr_width_max = 2048, .mgr_height_max = 2048, + .ovl_width_max = 2048, + .ovl_height_max = 2048, .max_lcd_pclk = 66500000, .max_downscale = 2, /* @@ -4278,6 +4288,8 @@ static const struct dispc_features omap34xx_rev1_0_dispc_feats = { .mgr_height_start = 26, .mgr_width_max = 2048, .mgr_height_max = 2048, + .ovl_width_max = 2048, + .ovl_height_max = 2048, .max_lcd_pclk = 173000000, .max_tv_pclk = 59000000, .max_downscale = 4, @@ -4313,6 +4325,8 @@ static const struct dispc_features omap34xx_rev3_0_dispc_feats = { .mgr_height_start = 26, .mgr_width_max = 2048, .mgr_height_max = 2048, + .ovl_width_max = 2048, + .ovl_height_max = 2048, .max_lcd_pclk = 173000000, .max_tv_pclk = 59000000, .max_downscale = 4, @@ -4348,6 +4362,8 @@ static const struct dispc_features omap36xx_dispc_feats = { .mgr_height_start = 26, .mgr_width_max = 2048, .mgr_height_max = 2048, + .ovl_width_max = 2048, + .ovl_height_max = 2048, .max_lcd_pclk = 173000000, .max_tv_pclk = 59000000, .max_downscale = 4, @@ -4383,6 +4399,8 @@ static const struct dispc_features am43xx_dispc_feats = { .mgr_height_start = 26, .mgr_width_max = 2048, .mgr_height_max = 2048, + .ovl_width_max = 2048, + .ovl_height_max = 2048, .max_lcd_pclk = 173000000, .max_tv_pclk = 59000000, .max_downscale = 4, @@ -4418,6 +4436,8 @@ static const struct dispc_features omap44xx_dispc_feats = { .mgr_height_start = 26, .mgr_width_max = 2048, .mgr_height_max = 2048, + .ovl_width_max = 2048, + .ovl_height_max = 2048, .max_lcd_pclk = 170000000, .max_tv_pclk = 185625000, .max_downscale = 4, @@ -4457,6 +4477,8 @@ static const struct dispc_features omap54xx_dispc_feats = { .mgr_height_start = 27, .mgr_width_max = 4096, .mgr_height_max = 4096, + .ovl_width_max = 2048, + .ovl_height_max = 4096, .max_lcd_pclk = 170000000, .max_tv_pclk = 192000000, .max_downscale = 4, diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index a547527bb2f3..14c39f7c3988 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -397,6 +397,8 @@ int dispc_get_num_mgrs(struct dispc_device *dispc); const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc, enum omap_plane_id plane); +void dispc_ovl_get_max_size(struct dispc_device *dispc, u16 *width, u16 *height); + u32 dispc_read_irqstatus(struct dispc_device *dispc); void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask); void dispc_write_irqenable(struct dispc_device *dispc, u32 mask); diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index c3de4f339387..846698c21a4a 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -111,12 +111,19 @@ static int omap_plane_atomic_check(struct drm_plane *plane, { struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane); + struct omap_drm_private *priv = plane->dev->dev_private; struct drm_crtc_state *crtc_state; + u32 max_width, max_height; + u16 width, height; int ret; if (!new_plane_state->fb) return 0; + dispc_ovl_get_max_size(priv->dispc, &width, &height); + max_width = width << 16; + max_height = height << 16; + /* crtc should only be NULL when disabling (i.e., !new_plane_state->fb) */ if (WARN_ON(!new_plane_state->crtc)) return 0; @@ -151,6 +158,13 @@ static int omap_plane_atomic_check(struct drm_plane *plane, if (new_plane_state->crtc_y + new_plane_state->crtc_h > crtc_state->adjusted_mode.vdisplay) return -EINVAL; + /* Make sure dimensions are within bounds. */ + if (new_plane_state->src_h > max_height || new_plane_state->crtc_h > height) + return -EINVAL; + + if (new_plane_state->src_w > max_width || new_plane_state->crtc_w > width) + return -EINVAL; + if (new_plane_state->rotation != DRM_MODE_ROTATE_0 && !omap_framebuffer_supports_rotation(new_plane_state->fb)) return -EINVAL; From patchwork Wed Nov 17 14:19:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12624731 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 881A4C4332F for ; Wed, 17 Nov 2021 14:19:43 +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 5475861C32 for ; Wed, 17 Nov 2021 14:19:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5475861C32 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.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 ED7C36E3D2; Wed, 17 Nov 2021 14:19:37 +0000 (UTC) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 659C56E3D2 for ; Wed, 17 Nov 2021 14:19:37 +0000 (UTC) Received: by mail-wr1-x42e.google.com with SMTP id w29so4975629wra.12 for ; Wed, 17 Nov 2021 06:19:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Gb6rdR8r5bxnCwwvMcUXuUQs475rnlgLqYUIOtwuUmQ=; b=EHUzwvR6NodJpEIVTgFemNR6loQk8F9zIj8MfM5yI13PXt46bs4FyIhma5+6l557HB Jq7L5BhdtQ+ak31/tUsbIYTlxXdnLVyHuabArY0aGeEmUogogueidx/53wN215avv3ht 8yhwNw1YXJ6ktot9PMbt8OS3AOH2gm8CJ6B3IMlq1Zbzly0HGhNHmCeqD3pZwMApxNm5 GH/eQKxA/LVctq459zR+9Ewk07TROBAeXvUJjvh0h7kLGD9QmplEu/GhpFgKsgJMXMrs cXeFOMbqUMKB0Fv0GoMCoo577xOZ23ANGN7sVgP3lTqeV/5orkouAE12UZMr1edUNoEs hdSQ== 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=Gb6rdR8r5bxnCwwvMcUXuUQs475rnlgLqYUIOtwuUmQ=; b=Skvl+kiyeyzYzcc1YmD/Htk3JMgUBEhfZE7Lk5Lsa5JQow2gBSXkN39NQ2xDKKQn2U Fkq4jPsCWBezWFAwzMOfzXELQb2c2WrJ3IYq0aml6O+ZyBn1cWRv+2mThIJlUpwLajGh HB9jhvetdChIyMOff7va3Oeto49osbRdMuzNCfPofgp3kdxW3fc7Gz7HTHSVsAe8GH4k 77Upa+j2ph+ziQ5jDadh3BQ9E9miAb135A/GFFamjbsgfM6U8ROHyE5/uoCCfsDZKQRl UDLyED2EX17rjqo/516GmyHIdGWvEh/0kuAYiYzXUZv1MWlkBuI6XIK9wlwynrK44RsX vjSQ== X-Gm-Message-State: AOAM531wVjT3vNJyrMaqSMhiYLuO8PKekNgNa0AWILeKvVlq3qXQGzNi gEz33dU80FqUBUpr2OuiifEbLQ== X-Google-Smtp-Source: ABdhPJxs6gQED3x1xQTvItqVNfy4M5Qo43kL+qfgVTxzRYn7Au/Zt2MrLDv6L4EpPCU2Vk8oKw2lvA== X-Received: by 2002:a5d:6e82:: with SMTP id k2mr21106137wrz.147.1637158775596; Wed, 17 Nov 2021 06:19:35 -0800 (PST) Received: from localhost.localdomain ([2001:861:44c0:66c0:f98b:434c:566c:492d]) by smtp.gmail.com with ESMTPSA id o10sm33803wri.15.2021.11.17.06.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Nov 2021 06:19:35 -0800 (PST) From: Neil Armstrong To: tomba@kernel.org Subject: [PATCH v7 3/9] drm/omap: Add ovl checking funcs to dispc_ops Date: Wed, 17 Nov 2021 15:19:22 +0100 Message-Id: <20211117141928.771082-4-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117141928.771082-1-narmstrong@baylibre.com> References: <20211117141928.771082-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2394; i=narmstrong@baylibre.com; h=from:subject; bh=3ZuXHPw5i+CUkF1E6yMQB6Ye+gRoZAVN+ibCccMbko0=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhlQ9MpgMs+k9m9KjXxdMN+K5FnHZiwxhfuTNuc+hO 8TYYyFCJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYZUPTAAKCRB33NvayMhJ0dXDD/ 9rddJZzDAyVVy0zGuJSR5vrT9SscH7YKGzgbzi/QbvYdk3qS0IsRCk9Sa5wvzir+mZO7bceGeXohXy LmudE6CoP8VliR0xTFksaJgXTvispoaLEEVksHWNwX7FJc4eTt0uMceYKKU9jlpRyYkf1L5sd5L09d Cpq3QWnqlS713r4N3YQL/C4HffyzYST/2NAxEpZp9UYhjXffall80+HiKy1IphicvXur82WEMR9sfo +ZPe9syKsSSQoKyf2ri2JXyvvSTlnujSQ3CElNT0dirwyTQEVyG6azzDLfz6GhnJDY8MPf9++1h6nO YZdtL6IXRTOBxCXdt71Hjg6nVj8xAndQ0KxyRI4KC7A8ZmjgmBAf2dKaW9/fCOzICYNActo93En0sy +8VNIc/BBgKBS/KOk6rZPIRgM0wasMEJ3xCQbuy6EcuSd9HI5+NFTgs2AYGN4rPkwdYt5+2FzYgSXj Dcr+rYrnOoNZq18h37vDUPn+mrWJFugvLN9VQwVeDf9b3ZHN4230A1vak5hW3VmTeixazGFYEuGbS4 fEEVRghmrsKiA7vnlYtL1dP6w9bA1YEgvVouHp3CAbttr8lgGUm9URfZXiQhIlSne4MKuevqbMSlJf TAkPJ9yptpRpKJVcBQ0Kvt4sBiIRgXd7y9TqBWQdNTsKJfl0AA4m+MSnreBQ== X-Developer-Key: i=narmstrong@baylibre.com; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , khilman@baylibre.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Tomi Valkeinen , linux-omap@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Benoit Parrot In order to be able to dynamically assign overlays to planes we need to be able to asses the overlay capabilities. Add a helper function to be able to retrieve the supported capabilities of an overlay. And export the function to check if a fourcc is supported on a given overlay. Signed-off-by: Benoit Parrot Signed-off-by: Neil Armstrong Reviewed-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/dss/dispc.c | 9 +++++++-- drivers/gpu/drm/omapdrm/dss/dss.h | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index d3cf9d9aef63..2da4d36a3446 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -1281,8 +1281,8 @@ static u32 dispc_ovl_get_burst_size(struct dispc_device *dispc, return dispc->feat->burst_size_unit * 8; } -static bool dispc_ovl_color_mode_supported(struct dispc_device *dispc, - enum omap_plane_id plane, u32 fourcc) +bool dispc_ovl_color_mode_supported(struct dispc_device *dispc, + enum omap_plane_id plane, u32 fourcc) { const u32 *modes; unsigned int i; @@ -2489,6 +2489,11 @@ static int dispc_ovl_calc_scaling_44xx(struct dispc_device *dispc, return 0; } +enum omap_overlay_caps dispc_ovl_get_caps(struct dispc_device *dispc, enum omap_plane_id plane) +{ + return dispc->feat->overlay_caps[plane]; +} + #define DIV_FRAC(dividend, divisor) \ ((dividend) * 100 / (divisor) - ((dividend) / (divisor) * 100)) diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index 14c39f7c3988..4ff02fbc0e71 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -398,6 +398,9 @@ const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc, enum omap_plane_id plane); void dispc_ovl_get_max_size(struct dispc_device *dispc, u16 *width, u16 *height); +bool dispc_ovl_color_mode_supported(struct dispc_device *dispc, + enum omap_plane_id plane, u32 fourcc); +enum omap_overlay_caps dispc_ovl_get_caps(struct dispc_device *dispc, enum omap_plane_id plane); u32 dispc_read_irqstatus(struct dispc_device *dispc); void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask); From patchwork Wed Nov 17 14:19:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12624739 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 5B9ADC433FE for ; Wed, 17 Nov 2021 14:19:55 +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 2A5EB61C32 for ; Wed, 17 Nov 2021 14:19:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2A5EB61C32 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.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 778EB6E461; Wed, 17 Nov 2021 14:19:51 +0000 (UTC) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7CA116E459 for ; Wed, 17 Nov 2021 14:19:38 +0000 (UTC) Received: by mail-wr1-x435.google.com with SMTP id n29so4997553wra.11 for ; Wed, 17 Nov 2021 06:19:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+L93Bd9XaleDoYmvTcv0VKJ5BS5XSCgLSsbmQrw8Brg=; b=Kx8Okj5fiQGKiUwRwaEm8W6W+RQ/sAbfWG7kc7p8ovthv9R0WF4BfWx0DfcUVu1adg VtugHEyqEu16dYV55l/FjFQ1Ta797YBunIp6zverM1mtCynmn+wmNGxOMpdoit1hEszL 39AJKt2fuBxRO1tMT5itgFVKZhsyLAn1NPcJA6ni8pMCMT1xebZpadtmB6zvZnNyd2Sl E7S1zFGHt9STgQrZwn+ga5NjRN5LPDyZsbWDi/6CPibgq/vbUehHZCNnJM//DBYjZeT8 KMjw+HT4D3thheQE6biFc5Omp6PpCO6D3tcg43UEsUHeHTfywmg9+3yDRONgK6JyzkwN CLdw== 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=+L93Bd9XaleDoYmvTcv0VKJ5BS5XSCgLSsbmQrw8Brg=; b=KfAjYniL8qWaG46bceEWG9wcqIJeBKOce3+iGIUEslTlG2WiKPDcHs7clQ7b+we6YS X9JP2S2p1KrhhOGtK1jqTDhgnmbLdX365Fad76fi8aVfA25i2YbVP6HwCL9huPFg3xi6 zu96jajZFA7cajOqrdXwtT7EfoAvDudBpNJoGBbEynx+9qKStA4qx4Eqk5g8vcacd+I1 g7Jk6JtEka7/8KiR3l2vEWLgFQdkYIseiQjVu9KYWuXM0NV/nD7HNvaD4gdckqZA+k+e He66t8eyyQkYmyseCo7Y9lToyAfNOFwb7wSyB8foA5M8WvpZHNv13W+XXq3t0ytNJZ4h cSrw== X-Gm-Message-State: AOAM531bnIb8PpVknYiTE3ZCaPqfewzvhYti+faQPxiy4Y3VZ8VWnZte g8FJwtTHMDciY4sr6b3XBi+jnw== X-Google-Smtp-Source: ABdhPJw24de9q2BNeVfTTofBqWQInwD3iup9I3+dMT+WNt1FXhTWsvG26QMZJ9cb4SKCTI0/RDvFKA== X-Received: by 2002:adf:ec45:: with SMTP id w5mr20340154wrn.183.1637158776839; Wed, 17 Nov 2021 06:19:36 -0800 (PST) Received: from localhost.localdomain ([2001:861:44c0:66c0:f98b:434c:566c:492d]) by smtp.gmail.com with ESMTPSA id o10sm33803wri.15.2021.11.17.06.19.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Nov 2021 06:19:36 -0800 (PST) From: Neil Armstrong To: tomba@kernel.org Subject: [PATCH v7 4/9] drm/omap: introduce omap_hw_overlay Date: Wed, 17 Nov 2021 15:19:23 +0100 Message-Id: <20211117141928.771082-5-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117141928.771082-1-narmstrong@baylibre.com> References: <20211117141928.771082-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=11150; i=narmstrong@baylibre.com; h=from:subject; bh=tEPJSC765zHK0xM+teSUNg5FcwPPs9/+cGq9soeZt1s=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhlQ9MbZEYYidyF2gWXBZmH5lQD33H5Lbxb/iKVBwR 3ed56h+JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYZUPTAAKCRB33NvayMhJ0fmrEA CrgVOQeh9+FCmPf0xHl/hwCi0p86LeZeHMYgDafov6HdwaDrkqIvUBmTFP9Ds5rw5pnCGeQ57SOMv0 Sgx8vUaGKUmhg6Fd4BBwkyitQZhUAju3WiWcRRL6AaBRSS2fOt7UsEJco0wfUIdL1e2TWPvEEXv63V HsX8VohqyyY+R+A7Ng0Mrfi/Ds94F9gCidGaE2+gDJBIa620Mm18xTNd77PklbZC7a5tXFza60XqSY GsHsEz7oF7tmKHpVYfcz72PVlPIY5+A9+EOgA2Tg6di2pGKR9CJd/Nr6cqvK5V6XVBguLLgYk+FQg3 F8fiDai4ovLeBk1ZkqpnO5a/XfAmvrH6fBz/ZrfKKLuuG6FMLseoyKUwS86KaRAmviTeTdZ4f3QtZt HH2Ei8vhs5/br2bzu2VSvsD0M5xk9/MZKypnugfM0WldpQLDp+Fr3NmYMyVi8zx+JnwGTShdkDoWnW Aa6BSiUa33ri8ZzKh27XmcIPdCHzSj80+kgmcW0WaVblA1VVCoGfkhcBKAGH0KNZSxbZpeSKXlTsrD WGi23uyKAQ6ihCfCwzIRR3evbeLDIL7b2fzY2tOhiEfsauGJIH1qbHwe4NqLgrbymtKV1MESws+xft 8+iUeEM7rRDe1vFRhm3Q8sh9g5NZKI49OtMlq+58tHhvReylKdk0Oitf1mFA== X-Developer-Key: i=narmstrong@baylibre.com; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , khilman@baylibre.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Tomi Valkeinen , linux-omap@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Benoit Parrot Split out the hardware overlay specifics from omap_plane. To start, the hw overlays are statically assigned to planes. The goal is to eventually assign hw overlays dynamically to planes during plane->atomic_check() based on requested caps (scaling, YUV, etc). And then perform hw overlay re-assignment if required. Signed-off-by: Benoit Parrot Signed-off-by: Neil Armstrong Reviewed-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/Makefile | 1 + drivers/gpu/drm/omapdrm/omap_drv.c | 9 ++- drivers/gpu/drm/omapdrm/omap_drv.h | 4 ++ drivers/gpu/drm/omapdrm/omap_overlay.c | 84 ++++++++++++++++++++++++++ drivers/gpu/drm/omapdrm/omap_overlay.h | 30 +++++++++ drivers/gpu/drm/omapdrm/omap_plane.c | 54 +++++++---------- 6 files changed, 148 insertions(+), 34 deletions(-) create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.c create mode 100644 drivers/gpu/drm/omapdrm/omap_overlay.h diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile index 21e8277ff88f..710b4e0abcf0 100644 --- a/drivers/gpu/drm/omapdrm/Makefile +++ b/drivers/gpu/drm/omapdrm/Makefile @@ -9,6 +9,7 @@ omapdrm-y := omap_drv.o \ omap_debugfs.o \ omap_crtc.o \ omap_plane.o \ + omap_overlay.o \ omap_encoder.o \ omap_fb.o \ omap_gem.o \ diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index c05d3975cb31..f17a72a4023e 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -583,10 +583,14 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev) omap_gem_init(ddev); + ret = omap_hwoverlays_init(priv); + if (ret) + goto err_gem_deinit; + ret = omap_modeset_init(ddev); if (ret) { dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret); - goto err_gem_deinit; + goto err_free_overlays; } /* Initialize vblank handling, start with all CRTCs disabled. */ @@ -618,6 +622,8 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev) omap_fbdev_fini(ddev); err_cleanup_modeset: omap_modeset_fini(ddev); +err_free_overlays: + omap_hwoverlays_destroy(priv); err_gem_deinit: omap_gem_deinit(ddev); destroy_workqueue(priv->wq); @@ -642,6 +648,7 @@ static void omapdrm_cleanup(struct omap_drm_private *priv) drm_atomic_helper_shutdown(ddev); omap_modeset_fini(ddev); + omap_hwoverlays_destroy(priv); omap_gem_deinit(ddev); destroy_workqueue(priv->wq); diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index 591d4c273f02..b4d9c2062723 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -24,6 +24,7 @@ #include "omap_gem.h" #include "omap_irq.h" #include "omap_plane.h" +#include "omap_overlay.h" #define DBG(fmt, ...) DRM_DEBUG_DRIVER(fmt"\n", ##__VA_ARGS__) #define VERB(fmt, ...) if (0) DRM_DEBUG_DRIVER(fmt, ##__VA_ARGS__) /* verbose debug */ @@ -57,6 +58,9 @@ struct omap_drm_private { unsigned int num_planes; struct drm_plane *planes[8]; + unsigned int num_ovls; + struct omap_hw_overlay *overlays[8]; + struct drm_fb_helper *fbdev; struct workqueue_struct *wq; diff --git a/drivers/gpu/drm/omapdrm/omap_overlay.c b/drivers/gpu/drm/omapdrm/omap_overlay.c new file mode 100644 index 000000000000..de67b39529bd --- /dev/null +++ b/drivers/gpu/drm/omapdrm/omap_overlay.c @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ + * Author: Benoit Parrot + */ + +#include +#include +#include + +#include "omap_dmm_tiler.h" +#include "omap_drv.h" + +/* + * overlay funcs + */ +static const char * const overlay_id_to_name[] = { + [OMAP_DSS_GFX] = "gfx", + [OMAP_DSS_VIDEO1] = "vid1", + [OMAP_DSS_VIDEO2] = "vid2", + [OMAP_DSS_VIDEO3] = "vid3", +}; + +static void omap_overlay_destroy(struct omap_hw_overlay *overlay) +{ + kfree(overlay); +} + +static struct omap_hw_overlay *omap_overlay_init(enum omap_plane_id overlay_id, + enum omap_overlay_caps caps) +{ + struct omap_hw_overlay *overlay; + + overlay = kzalloc(sizeof(*overlay), GFP_KERNEL); + if (!overlay) + return ERR_PTR(-ENOMEM); + + overlay->name = overlay_id_to_name[overlay_id]; + overlay->id = overlay_id; + overlay->caps = caps; + + return overlay; +} + +int omap_hwoverlays_init(struct omap_drm_private *priv) +{ + static const enum omap_plane_id hw_plane_ids[] = { + OMAP_DSS_GFX, OMAP_DSS_VIDEO1, + OMAP_DSS_VIDEO2, OMAP_DSS_VIDEO3, + }; + u32 num_overlays = dispc_get_num_ovls(priv->dispc); + enum omap_overlay_caps caps; + int i, ret; + + for (i = 0; i < num_overlays; i++) { + struct omap_hw_overlay *overlay; + + caps = dispc_ovl_get_caps(priv->dispc, hw_plane_ids[i]); + overlay = omap_overlay_init(hw_plane_ids[i], caps); + if (IS_ERR(overlay)) { + ret = PTR_ERR(overlay); + dev_err(priv->dev, "failed to construct overlay for %s (%d)\n", + overlay_id_to_name[i], ret); + omap_hwoverlays_destroy(priv); + return ret; + } + overlay->idx = priv->num_ovls; + priv->overlays[priv->num_ovls++] = overlay; + } + + return 0; +} + +void omap_hwoverlays_destroy(struct omap_drm_private *priv) +{ + int i; + + for (i = 0; i < priv->num_ovls; i++) { + omap_overlay_destroy(priv->overlays[i]); + priv->overlays[i] = NULL; + } + + priv->num_ovls = 0; +} diff --git a/drivers/gpu/drm/omapdrm/omap_overlay.h b/drivers/gpu/drm/omapdrm/omap_overlay.h new file mode 100644 index 000000000000..51d26aebf77d --- /dev/null +++ b/drivers/gpu/drm/omapdrm/omap_overlay.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ + * Author: Benoit Parrot + */ + +#ifndef __OMAPDRM_OVERLAY_H__ +#define __OMAPDRM_OVERLAY_H__ + +#include + +enum drm_plane_type; + +struct drm_device; +struct drm_mode_object; +struct drm_plane; + +/* Used to associate a HW overlay/plane to a plane */ +struct omap_hw_overlay { + unsigned int idx; + + const char *name; + enum omap_plane_id id; + + enum omap_overlay_caps caps; +}; + +int omap_hwoverlays_init(struct omap_drm_private *priv); +void omap_hwoverlays_destroy(struct omap_drm_private *priv); +#endif /* __OMAPDRM_OVERLAY_H__ */ diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 846698c21a4a..8cc2b899f20c 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -21,7 +21,8 @@ struct omap_plane { struct drm_plane base; enum omap_plane_id id; - const char *name; + + struct omap_hw_overlay *overlay; }; static int omap_plane_prepare_fb(struct drm_plane *plane, @@ -49,10 +50,11 @@ static void omap_plane_atomic_update(struct drm_plane *plane, struct omap_plane *omap_plane = to_omap_plane(plane); struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane); + enum omap_plane_id ovl_id = omap_plane->overlay->id; struct omap_overlay_info info; int ret; - DBG("%s, crtc=%p fb=%p", omap_plane->name, new_state->crtc, + DBG("%s, crtc=%p fb=%p", plane->name, new_state->crtc, new_state->fb); memset(&info, 0, sizeof(info)); @@ -77,17 +79,17 @@ static void omap_plane_atomic_update(struct drm_plane *plane, &info.paddr, &info.p_uv_addr); /* and finally, update omapdss: */ - ret = dispc_ovl_setup(priv->dispc, omap_plane->id, &info, + ret = dispc_ovl_setup(priv->dispc, ovl_id, &info, omap_crtc_timings(new_state->crtc), false, omap_crtc_channel(new_state->crtc)); if (ret) { dev_err(plane->dev->dev, "Failed to setup plane %s\n", - omap_plane->name); - dispc_ovl_enable(priv->dispc, omap_plane->id, false); + plane->name); + dispc_ovl_enable(priv->dispc, ovl_id, false); return; } - dispc_ovl_enable(priv->dispc, omap_plane->id, true); + dispc_ovl_enable(priv->dispc, ovl_id, true); } static void omap_plane_atomic_disable(struct drm_plane *plane, @@ -97,11 +99,12 @@ static void omap_plane_atomic_disable(struct drm_plane *plane, plane); struct omap_drm_private *priv = plane->dev->dev_private; struct omap_plane *omap_plane = to_omap_plane(plane); + enum omap_plane_id ovl_id = omap_plane->overlay->id; new_state->rotation = DRM_MODE_ROTATE_0; new_state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : omap_plane->id; - dispc_ovl_enable(priv->dispc, omap_plane->id, false); + dispc_ovl_enable(priv->dispc, ovl_id, false); } #define FRAC_16_16(mult, div) (((mult) << 16) / (div)) @@ -184,7 +187,7 @@ static void omap_plane_destroy(struct drm_plane *plane) { struct omap_plane *omap_plane = to_omap_plane(plane); - DBG("%s", omap_plane->name); + DBG("%s", plane->name); drm_plane_cleanup(plane); @@ -290,20 +293,6 @@ static bool omap_plane_supports_yuv(struct drm_plane *plane) return false; } -static const char *plane_id_to_name[] = { - [OMAP_DSS_GFX] = "gfx", - [OMAP_DSS_VIDEO1] = "vid1", - [OMAP_DSS_VIDEO2] = "vid2", - [OMAP_DSS_VIDEO3] = "vid3", -}; - -static const enum omap_plane_id plane_idx_to_id[] = { - OMAP_DSS_GFX, - OMAP_DSS_VIDEO1, - OMAP_DSS_VIDEO2, - OMAP_DSS_VIDEO3, -}; - /* initialize plane */ struct drm_plane *omap_plane_init(struct drm_device *dev, int idx, enum drm_plane_type type, @@ -313,27 +302,26 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, unsigned int num_planes = dispc_get_num_ovls(priv->dispc); struct drm_plane *plane; struct omap_plane *omap_plane; - enum omap_plane_id id; int ret; u32 nformats; const u32 *formats; - if (WARN_ON(idx >= ARRAY_SIZE(plane_idx_to_id))) + if (WARN_ON(idx >= num_planes)) return ERR_PTR(-EINVAL); - id = plane_idx_to_id[idx]; - - DBG("%s: type=%d", plane_id_to_name[id], type); - omap_plane = kzalloc(sizeof(*omap_plane), GFP_KERNEL); if (!omap_plane) return ERR_PTR(-ENOMEM); - formats = dispc_ovl_get_color_modes(priv->dispc, id); + omap_plane->id = idx; + omap_plane->overlay = priv->overlays[idx]; + + DBG("%d: type=%d", omap_plane->id, type); + DBG(" crtc_mask: 0x%04x", possible_crtcs); + + formats = dispc_ovl_get_color_modes(priv->dispc, omap_plane->overlay->id); for (nformats = 0; formats[nformats]; ++nformats) ; - omap_plane->id = id; - omap_plane->name = plane_id_to_name[id]; plane = &omap_plane->base; @@ -363,8 +351,8 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, return plane; error: - dev_err(dev->dev, "%s(): could not create plane: %s\n", - __func__, plane_id_to_name[id]); + dev_err(dev->dev, "%s(): could not create plane: %d\n", + __func__, omap_plane->id); kfree(omap_plane); return NULL; From patchwork Wed Nov 17 14:19:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12624737 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 EAC83C433EF for ; Wed, 17 Nov 2021 14:19:52 +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 B4D4761BE3 for ; Wed, 17 Nov 2021 14:19:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B4D4761BE3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.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 015DB6E47A; Wed, 17 Nov 2021 14:19:43 +0000 (UTC) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 947C26E471 for ; Wed, 17 Nov 2021 14:19:39 +0000 (UTC) Received: by mail-wr1-x42f.google.com with SMTP id d5so5077247wrc.1 for ; Wed, 17 Nov 2021 06:19:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z7XROMuoMUndfAObhvgnMrtL9JrHT86GQvneGL5hOEY=; b=AVRpLMfxCJQRGv0y6ImphRLweCTVNdidTEV3BLg7/KA7ozeKmVcjEjCNl3BgYPV3ii 3ngHNZJaBnzSh7PLPu5GA6/lWggGssH9WARO913D3cH3iIF5fkFH+f92OCiuF0KUl3iI owDxFaIvPLAh3BJFnIO4sz80tjKqMnt7dzQPu9jLtdF8LH/G8wdFhXf+lKRAjgxGD9Ks 27+jisIvXyu2wXEBR0cmeE4/1wwvvAyi5Czgh93CRuhYpniz+5pW8O8j2oXzrXILSwPl OT+MahWH50o0URrH4X2h32ppkTTf5ktPCytDdfJ6m72474bYRuckHpQXt3kCGmpifwcd JTig== 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=Z7XROMuoMUndfAObhvgnMrtL9JrHT86GQvneGL5hOEY=; b=qk6x0usXUrjy3WBGu8nn1EA0WzhF3qsp0cJ63FoLnveCelsMjeu4JJWDeU0AHlL0rS COX6Wshfu5hvMEqztk7Ms57VtMvZbjpR9JwuoIAMM4nIBPHCc++/MNgSCv9znX02zXWl urXbvnBDqVbNT0RNC0nboJIXvaM7mPH4MKfNLl3quCv4JPErlzDmi088MfXs2EfGqe6Q N/OfqaB1y1wtgHRuHe/XhADMs38RYKKWNetL+blzQtXHHZRLc8yHl6E/9xtrrJH1e1WD N6qQhaOIPKT/VAlVgs8BLTl+144nAAP3NlFSD+rbTV3DyQ586JAyDTDgCY3ODKKseQ+I B8Sw== X-Gm-Message-State: AOAM530q20H9uU0tst6Wv24KZjAw4uA2P2ippINYHp3prQLza/QLie37 pRbO+PcPwtsCk3w0kC8P0vUZdPFhjLoEhPLc X-Google-Smtp-Source: ABdhPJxtqq9P4rD5wH2L6JkUHJ8yLqNqWeuBSt1tS6kZhEWgYfB/kb6C4FIfFmVMXeKVach9cdPrRQ== X-Received: by 2002:a05:6000:1862:: with SMTP id d2mr20330364wri.251.1637158777855; Wed, 17 Nov 2021 06:19:37 -0800 (PST) Received: from localhost.localdomain ([2001:861:44c0:66c0:f98b:434c:566c:492d]) by smtp.gmail.com with ESMTPSA id o10sm33803wri.15.2021.11.17.06.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Nov 2021 06:19:37 -0800 (PST) From: Neil Armstrong To: tomba@kernel.org Subject: [PATCH v7 5/9] drm/omap: omap_plane: subclass drm_plane_state Date: Wed, 17 Nov 2021 15:19:24 +0100 Message-Id: <20211117141928.771082-6-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117141928.771082-1-narmstrong@baylibre.com> References: <20211117141928.771082-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2857; i=narmstrong@baylibre.com; h=from:subject; bh=wprebf5uOc8BWQya/EJqV1uICFFQ6AiuRw3piy3F3/s=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhlQ9M1QiYTusr8ZvoTMumWHhn7A0DvlhqufmL4C8b 36n+Rs+JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYZUPTAAKCRB33NvayMhJ0fg7EA CqoUSF+KiXfDfGX6aACnQAeSwlsftC1xouMBP1Hqg2KclI0fX55XTlpznJogIaPJ5K2iRi2Fs1iqRB ++7IFCAjlSw5nrPK+EU9BKk97airrlU0aC4ek4DqQebw0DP1YpZB0OhzKuNe9W6XDhGW5g6WTc0DUr 9ASwVbluz/ABEj6Ko580UAtDE77N3ICOBTUdNpBgJzjmlrL14ipHEatLwf+6AvviQ2vzCLfjOVxj9J id2wGXgseghtV0pax0THuQMWTFOm6avj+YMpGTJimJyG9/DvPBSONBQmAQCtHcu4OJb3bWt21XWvBe WHAlCrftlkC3oKsfxlkgxA+DeIvKiH0fyqKeSkLb3IwZDaYgc9aqmW1OdJMlPYMJ6B1UQO3TUBiOP4 f7l3eBhWXjdx1JbueO0gZBGwCynIPHfiPX6vG1JYeAvIXF9QGd4HrJPzbMof/Q9TIU/NMzo/9N0ZtK l1BeEHFTVDs2YUXvR6Nmc0gvqzUD962DOeXuDcqnDJfaMt0WAb7KvVzCWxxhuzif+UBBOnJtOAcU1i XBvyNKBGOy18gCXKM5X434MNpu6IYEOGTFrWL8hHkjpJQNH8v7A5DEbpysP8f3MoRxtxN4ZLTIn5Vr qcR/NIhKdJ4AWeuOZYZca+1No3EAPBe8vhsP0Ac1s7pkFjZysbpyoXqqQpwg== X-Developer-Key: i=narmstrong@baylibre.com; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , khilman@baylibre.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Tomi Valkeinen , linux-omap@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Benoit Parrot In preparation to add omap plane state specific extensions we need to subclass drm_plane_state and add the relevant helpers. The addition of specific extension will be done separately. Signed-off-by: Benoit Parrot Signed-off-by: Neil Armstrong Reviewed-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/omap_plane.c | 36 +++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 8cc2b899f20c..72d5adbbadfa 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -16,6 +16,13 @@ * plane funcs */ +#define to_omap_plane_state(x) container_of(x, struct omap_plane_state, base) + +struct omap_plane_state { + /* Must be first. */ + struct drm_plane_state base; +}; + #define to_omap_plane(x) container_of(x, struct omap_plane, base) struct omap_plane { @@ -221,11 +228,17 @@ void omap_plane_install_properties(struct drm_plane *plane, static void omap_plane_reset(struct drm_plane *plane) { struct omap_plane *omap_plane = to_omap_plane(plane); + struct omap_plane_state *omap_state; - drm_atomic_helper_plane_reset(plane); - if (!plane->state) + if (plane->state) + drm_atomic_helper_plane_destroy_state(plane, plane->state); + + omap_state = kzalloc(sizeof(*omap_state), GFP_KERNEL); + if (!omap_state) return; + __drm_atomic_helper_plane_reset(plane, &omap_state->base); + /* * Set the zpos default depending on whether we are a primary or overlay * plane. @@ -236,6 +249,23 @@ static void omap_plane_reset(struct drm_plane *plane) plane->state->color_range = DRM_COLOR_YCBCR_FULL_RANGE; } +static struct drm_plane_state * +omap_plane_atomic_duplicate_state(struct drm_plane *plane) +{ + struct omap_plane_state *state; + + if (WARN_ON(!plane->state)) + return NULL; + + state = kmalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return NULL; + + __drm_atomic_helper_plane_duplicate_state(plane, &state->base); + + return &state->base; +} + static int omap_plane_atomic_set_property(struct drm_plane *plane, struct drm_plane_state *state, struct drm_property *property, @@ -271,7 +301,7 @@ static const struct drm_plane_funcs omap_plane_funcs = { .disable_plane = drm_atomic_helper_disable_plane, .reset = omap_plane_reset, .destroy = omap_plane_destroy, - .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, + .atomic_duplicate_state = omap_plane_atomic_duplicate_state, .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, .atomic_set_property = omap_plane_atomic_set_property, .atomic_get_property = omap_plane_atomic_get_property, From patchwork Wed Nov 17 14:19:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12624733 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 7010FC433EF for ; Wed, 17 Nov 2021 14:19:47 +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 3D4D861A79 for ; Wed, 17 Nov 2021 14:19:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3D4D861A79 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.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 C852B6E459; Wed, 17 Nov 2021 14:19:42 +0000 (UTC) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8572D6E459 for ; Wed, 17 Nov 2021 14:19:40 +0000 (UTC) Received: by mail-wr1-x431.google.com with SMTP id s13so5052216wrb.3 for ; Wed, 17 Nov 2021 06:19:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XFN1iAlCGNW7IzWbu4eDHGUjnr+W3i9LZHVoBYu01+A=; b=U1vhbfIXppOzwTzeLpz6GRfxgAXKL9kRt1mPqlWDeuNYlcfIYYGWZmaaiSItzyFqBl aRUU528UUXfUpX71PHiOfhZMBGbNG3ZE3dfxTKxyrRNGpGJhs+mTX9fwvXLN0DIB1kpz UteBtDzslGwp5ACz3kuYLDCd5/In1x0Ju14vQGjizIDc0Id1RFeV3kE9VbPhTvl0uDnt etLdJppogMRGf4OQMNK1LglozOMp2fM/ArhpTwLHKByd5wI+SSFGtPuRgJu4HLYiFVK0 HUHzoacLlywHZQprlVmMZxTHvAMamFOz1sfBHqzK1qCXbX1GdOkOi1QAyDrkKDtHq/86 nPEw== 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=XFN1iAlCGNW7IzWbu4eDHGUjnr+W3i9LZHVoBYu01+A=; b=PdNXT9GRXSXwL2s4IXtjlAUgO0v8UPkQp2nLWDtSspdGtgwaj5E6MewZp/HxTIVa6f G0FTsBTcfqJ+L4ohtXXmwZUHLNT3sWcTWtU847qzEF1jg011NZI/7nfZIZBDBlKjK4a7 0bwVzf6Syg/szE0dlYRN7BY4u+oZ0dGb7z7GGiZbHAX16MBQFBIPJL/Tl4FAMqfgYg5L SY+w+Amgp/oZJyTk1tUftJAWpQmpJxX3wETTmvFRL39j5AwM5KtiN+ZibjIouvYwIoTp 1kQqAFqevCClD71Vmvjv1GaraR6G0uE24vaLXMhy9+mmiowz5v8SNHXScfgV23hp/fCO QgkQ== X-Gm-Message-State: AOAM530ERC0jarwBhH8VXDsSkC3Rk60zSI4OIgBFJ05tJ1j7BgvYsXjF R1L0ibTOsHNlIqKGTb6ISUL5kg== X-Google-Smtp-Source: ABdhPJyEZTXvCuAnDxowItg/gHq8mZEnMB4Gr/92Syg9xsfEMKJA3tuoQ8+M6gfvbOI2RZc121tufg== X-Received: by 2002:a5d:4492:: with SMTP id j18mr21256460wrq.397.1637158778918; Wed, 17 Nov 2021 06:19:38 -0800 (PST) Received: from localhost.localdomain ([2001:861:44c0:66c0:f98b:434c:566c:492d]) by smtp.gmail.com with ESMTPSA id o10sm33803wri.15.2021.11.17.06.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Nov 2021 06:19:38 -0800 (PST) From: Neil Armstrong To: tomba@kernel.org Subject: [PATCH v7 6/9] drm/omap: Add global state as a private atomic object Date: Wed, 17 Nov 2021 15:19:25 +0100 Message-Id: <20211117141928.771082-7-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117141928.771082-1-narmstrong@baylibre.com> References: <20211117141928.771082-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6382; i=narmstrong@baylibre.com; h=from:subject; bh=xnZMVWOIQ7dDQHmJjRrc3xW37tyCw1rW1wJyrCeCLpE=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhlQ9MuUGjpRhFrMXdqdfEi+koF6aDbsMOGLujcIr8 p/Jx2eyJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYZUPTAAKCRB33NvayMhJ0ejuD/ 9KReaF6hyhi6iQ1XCUqsvxNI83Acpi3+eRVmklA2cqdDjn8GBpDbQGpayY73JrHFg3jEj0FdVBHczO r80ahjcia+9WetezrGM4KWYYLrl6wO58jnS1dyw/rep3ZMKgN9+1klhszoeV4dxHwsch0OkPgSxIEw XNIKiC/64Io4lxVfGFGYKPcZOintbrtst2fUYQkaVtAd+m4lPvZMZXd9LUmAT32yoF7B0BKtVrokdu mJSF5lLMjGJE415mjb7w6GoxczhPi5pLbBs9r9QEr1l7Fs/pEkIEpsIxDE6uQOFaiaLhDY/WIK2Cs+ 4yLjjDjEdbSuFJs+V2jffgpx9FNiVhQCi+VUL+sAcwrOKkaHN9LTKkHQYd0IA4/KvdnKCihLm+0p8q oVnODxvHxKhwUi248LrDBHH4J+BQnu+Yv18BbAJgTJjuAUD9blwN9KHB94oMbKilW2NrapzdKu6jN+ wr3zoEadY8nGAcOCfe1toWql+521/pwA9Cp43bzhAVBVbYRZWGwy0H52ceyfMdGxCT+2SwRKlpy9l5 8UlRTzmg+nFfPz8ca73DkknEe5sBWlV/7C094Mjh2OdOGfRk+mxMiqAogxQD3BMvHzil+3G9IfD5pI TNI2/cfT7CZKIBy8Oiii0/Fmul/TMzU+oq/hNh8gINKT6QIR5XVZ8tbv9g2Q== X-Developer-Key: i=narmstrong@baylibre.com; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , khilman@baylibre.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Benoit Parrot Global shared resources (like hw overlays) for omapdrm are implemented as a part of atomic state using the drm_private_obj infrastructure available in the atomic core. omap_global_state is introduced as a drm atomic private object. The two funcs omap_get_global_state() and omap_get_existing_global_state() are the two variants that will be used to access omap_global_state. drm_mode_config_init() needs to be called earlier because it creates/initializes the private_obj link list maintained by the atomic framework. The private_obj link list has to exist prior to calling drm_atomic_private_obj_init(). Similarly the cleanup handler are reordered appropriately. Signed-off-by: Benoit Parrot Signed-off-by: Neil Armstrong --- drivers/gpu/drm/omapdrm/omap_drv.c | 91 +++++++++++++++++++++++++++++- drivers/gpu/drm/omapdrm/omap_drv.h | 17 ++++++ 2 files changed, 105 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index f17a72a4023e..44a9dcb3100c 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -128,6 +128,82 @@ static const struct drm_mode_config_funcs omap_mode_config_funcs = { .atomic_commit = drm_atomic_helper_commit, }; +/* Global/shared object state funcs */ + +/* + * This is a helper that returns the private state currently in operation. + * Note that this would return the "old_state" if called in the atomic check + * path, and the "new_state" after the atomic swap has been done. + */ +struct omap_global_state * +omap_get_existing_global_state(struct omap_drm_private *priv) +{ + return to_omap_global_state(priv->glob_obj.state); +} + +/* + * This acquires the modeset lock set aside for global state, creates + * a new duplicated private object state. + */ +struct omap_global_state *__must_check +omap_get_global_state(struct drm_atomic_state *s) +{ + struct omap_drm_private *priv = s->dev->dev_private; + struct drm_private_state *priv_state; + + priv_state = drm_atomic_get_private_obj_state(s, &priv->glob_obj); + if (IS_ERR(priv_state)) + return ERR_CAST(priv_state); + + return to_omap_global_state(priv_state); +} + +static struct drm_private_state * +omap_global_duplicate_state(struct drm_private_obj *obj) +{ + struct omap_global_state *state; + + state = kmemdup(obj->state, sizeof(*state), GFP_KERNEL); + if (!state) + return NULL; + + __drm_atomic_helper_private_obj_duplicate_state(obj, &state->base); + + return &state->base; +} + +static void omap_global_destroy_state(struct drm_private_obj *obj, + struct drm_private_state *state) +{ + struct omap_global_state *omap_state = to_omap_global_state(state); + + kfree(omap_state); +} + +static const struct drm_private_state_funcs omap_global_state_funcs = { + .atomic_duplicate_state = omap_global_duplicate_state, + .atomic_destroy_state = omap_global_destroy_state, +}; + +static int omap_global_obj_init(struct drm_device *dev) +{ + struct omap_drm_private *priv = dev->dev_private; + struct omap_global_state *state; + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return -ENOMEM; + + drm_atomic_private_obj_init(dev, &priv->glob_obj, &state->base, + &omap_global_state_funcs); + return 0; +} + +static void omap_global_obj_fini(struct omap_drm_private *priv) +{ + drm_atomic_private_obj_fini(&priv->glob_obj); +} + static void omap_disconnect_pipelines(struct drm_device *ddev) { struct omap_drm_private *priv = ddev->dev_private; @@ -231,8 +307,6 @@ static int omap_modeset_init(struct drm_device *dev) if (!omapdss_stack_is_ready()) return -EPROBE_DEFER; - drm_mode_config_init(dev); - ret = omap_modeset_init_properties(dev); if (ret < 0) return ret; @@ -583,10 +657,16 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev) omap_gem_init(ddev); - ret = omap_hwoverlays_init(priv); + drm_mode_config_init(ddev); + + ret = omap_global_obj_init(ddev); if (ret) goto err_gem_deinit; + ret = omap_hwoverlays_init(priv); + if (ret) + goto err_free_priv_obj; + ret = omap_modeset_init(ddev); if (ret) { dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret); @@ -624,7 +704,10 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev) omap_modeset_fini(ddev); err_free_overlays: omap_hwoverlays_destroy(priv); +err_free_priv_obj: + omap_global_obj_fini(priv); err_gem_deinit: + drm_mode_config_cleanup(ddev); omap_gem_deinit(ddev); destroy_workqueue(priv->wq); omap_disconnect_pipelines(ddev); @@ -649,6 +732,8 @@ static void omapdrm_cleanup(struct omap_drm_private *priv) omap_modeset_fini(ddev); omap_hwoverlays_destroy(priv); + omap_global_obj_fini(priv); + drm_mode_config_cleanup(ddev); omap_gem_deinit(ddev); destroy_workqueue(priv->wq); diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index b4d9c2062723..a3079aad7ae3 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -14,6 +14,7 @@ #include "dss/omapdss.h" #include "dss/dss.h" +#include #include #include @@ -41,6 +42,16 @@ struct omap_drm_pipeline { unsigned int alias_id; }; +/* + * Global private object state for tracking resources that are shared across + * multiple kms objects (planes/crtcs/etc). + */ +#define to_omap_global_state(x) container_of(x, struct omap_global_state, base) + +struct omap_global_state { + struct drm_private_state base; +}; + struct omap_drm_private { struct drm_device *ddev; struct device *dev; @@ -61,6 +72,8 @@ struct omap_drm_private { unsigned int num_ovls; struct omap_hw_overlay *overlays[8]; + struct drm_private_obj glob_obj; + struct drm_fb_helper *fbdev; struct workqueue_struct *wq; @@ -89,4 +102,8 @@ struct omap_drm_private { void omap_debugfs_init(struct drm_minor *minor); +struct omap_global_state * __must_check omap_get_global_state(struct drm_atomic_state *s); + +struct omap_global_state *omap_get_existing_global_state(struct omap_drm_private *priv); + #endif /* __OMAPDRM_DRV_H__ */ From patchwork Wed Nov 17 14:19:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12624743 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 2E21DC433F5 for ; Wed, 17 Nov 2021 14:20:00 +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 EF00861BE3 for ; Wed, 17 Nov 2021 14:19:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EF00861BE3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.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 A2BC26E4AB; Wed, 17 Nov 2021 14:19:57 +0000 (UTC) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by gabe.freedesktop.org (Postfix) with ESMTPS id B77256E459 for ; Wed, 17 Nov 2021 14:19:41 +0000 (UTC) Received: by mail-wr1-x435.google.com with SMTP id d27so5032102wrb.6 for ; Wed, 17 Nov 2021 06:19:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CV1zKwNbI/2030jcl+IzocFnQ2jPmElxdOJWMeaDePA=; b=fiOTmd4aHCylwgsBuyU588+WfZFb42tyKunWCXh5vufZz9pxAOCvhTVxELWJvA8TQo SY4B+QspyDCCmrXNDutMS3vmm5jhW0LNmxQJLjFxV+qDufXsira++HCDHPspv6WKzNPk orJYF1HzAb9FQSqtdxpGU3JvtPDOGbvIcMgTL1AV5aa5nwfH7B782dNPxxL+rQ4H5bGC 2sS4VcyVikRHKyaBf0UEUS71KeQ9gBR5rFsGql2+o5H7X9zIwycS8db71b2B7HwTmweA kougFIyZwdXl+eE9/rs8pm3HmfB6uH+Kge1mJRvBhlSdnuzSx8/5BZkBUlNxwe+fSQYC Wm9Q== 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=CV1zKwNbI/2030jcl+IzocFnQ2jPmElxdOJWMeaDePA=; b=hCTV76/6y9vEfmDKip629EQUEjnnZ83e5wbezopBBqj94inrzChyx8zpbAARqXFjjP 80I3N7AWn+RhFVPwyiSL+wuznrEAUC6wvsVUyKkBGMwHhrXA0EN+eOfOXaRyTmgSO44/ +quO5bXA1QxvG58f9z5tKxznO0FhwUpYOiCxhyNW4rc7IBwRu2/bipiXEYnAt2h0rzTv URI6pyTpOPD1fXV3LjP7Edxx2EcNCvgn5OlL5OUE745bjzW/KvvlwVD0J/DLVpELlOJj vqFrUEGw0/uGkKdZKav1CLikGKTHg6Wsf08/OyGnyDJvpZCN7fC9I1eHqCQVW0EdYAef dpHg== X-Gm-Message-State: AOAM532hCzE6Zb5YNyVHSv5f4akWeByiWQFFsfmqHvjSR4d89sjQ0l4I rGtoEA+fVZdgnFtzfmqnsJRC4g== X-Google-Smtp-Source: ABdhPJxPdLjvcNVaW4gvNbb1PeH/aYauHt5UAbxCnuBEHn5cJC32hXISVbMzj4WLvlfmW6yqsk525Q== X-Received: by 2002:adf:df0c:: with SMTP id y12mr21671660wrl.168.1637158779993; Wed, 17 Nov 2021 06:19:39 -0800 (PST) Received: from localhost.localdomain ([2001:861:44c0:66c0:f98b:434c:566c:492d]) by smtp.gmail.com with ESMTPSA id o10sm33803wri.15.2021.11.17.06.19.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Nov 2021 06:19:39 -0800 (PST) From: Neil Armstrong To: tomba@kernel.org Subject: [PATCH v7 7/9] drm/omap: dynamically assign hw overlays to planes Date: Wed, 17 Nov 2021 15:19:26 +0100 Message-Id: <20211117141928.771082-8-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117141928.771082-1-narmstrong@baylibre.com> References: <20211117141928.771082-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=14839; i=narmstrong@baylibre.com; h=from:subject; bh=YaIjt7FDG7natZRgL/VX/xfVhvxtI9Fm3S8VpheLtAc=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhlQ9MuDZf6mWd4D5lFpvaKlbjn8CM3+i4HF8mhH+j e5T8JjKJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYZUPTAAKCRB33NvayMhJ0dpjD/ 9ou4F6BBtgK52CvsKkp+dJzTLfCXpDe6KSWOMf/+L3hwBxePx+lbkRUYD3x82sDGrJw/6A5TEs78Tp uu0yqtsKXbnhUkrwWf22tWcbwy8uE4avba7cfigoBlBw2TeZOuuw5vHsJZPzfFiPB4bRUzCyLieyVD 69QV+NQq7YF/aa1FZlg7t3T7d4Z6Cs4VGBVYslggg1A6nbcj/0GRyzVmFM6Km69ug19Ckn71RRi7te L70wwqXisUIbg45GL7mOy01htfG2+h3SNFuzP2wecXL8XReTrLg+Tn8YlQeUzJoky3K0DGC4ztQhCh cR0Zl1HUPP3Db3ho4iY7Q97BrD9OmgZ8dRXNiCTO4wruZCcGiaxjsulR3WUFbiOfmQkKSGy7Zvc/Hc T165fav1cRo96MPxrBhl8MsEKfcOBXzidJJMYYNT1kfiYGdzw/Rbj7uJeuofKSABeUoWxS4kxs/Jju +eWgugjdKosNh6MNtIdIavj2XUPrwdfbAEGkw3rs5Zsws0I00yJmiQA0XH9o7/2U18eKsjVUuKJdKO xfzmfMn9HqTPix+Rh5Kc8npNTf60PI7zLrI3ZmWXIjPkBAMo7nrsbXQ3GWlV7FltHv2zbOhYgzhZaS m4bxWINeWv15sT09oLnGTiK5vDUClJnMfW2x09XU+LwgIbKgsHFkOvjTTpnQ== X-Developer-Key: i=narmstrong@baylibre.com; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , khilman@baylibre.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Benoit Parrot (re)assign the hw overlays to planes based on required caps, and to handle situations where we could not modify an in-use plane. This means all planes advertise the superset of formats and properties. Userspace must (as always) use atomic TEST_ONLY step for atomic updates, as not all planes may be available for use on every frame. The mapping of hwoverlays to plane is stored in omap_global_state, so that state updates are atomically committed in the same way that plane/etc state updates are managed. This is needed because the omap_plane_state keeps a pointer to the hwoverlay, and we don't want global state to become out of sync with the plane state if an atomic update fails, we hit deadlock/ backoff scenario, etc. The use of global_state_lock keeps multiple parallel updates which both re-assign hwoverlays properly serialized. Signed-off-by: Benoit Parrot Signed-off-by: Neil Armstrong --- drivers/gpu/drm/omapdrm/omap_drv.h | 3 + drivers/gpu/drm/omapdrm/omap_overlay.c | 109 +++++++++++++++++++++ drivers/gpu/drm/omapdrm/omap_overlay.h | 4 + drivers/gpu/drm/omapdrm/omap_plane.c | 127 ++++++++++++++++++++----- 4 files changed, 220 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index a3079aad7ae3..825960fd3ea9 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -50,6 +50,9 @@ struct omap_drm_pipeline { struct omap_global_state { struct drm_private_state base; + + /* global atomic state of assignment between overlays and planes */ + struct drm_plane *hwoverlay_to_plane[8]; }; struct omap_drm_private { diff --git a/drivers/gpu/drm/omapdrm/omap_overlay.c b/drivers/gpu/drm/omapdrm/omap_overlay.c index de67b39529bd..afb2b44fdf86 100644 --- a/drivers/gpu/drm/omapdrm/omap_overlay.c +++ b/drivers/gpu/drm/omapdrm/omap_overlay.c @@ -21,6 +21,115 @@ static const char * const overlay_id_to_name[] = { [OMAP_DSS_VIDEO3] = "vid3", }; +/* + * Find a free overlay with the required caps and supported fourcc + */ +static struct omap_hw_overlay * +omap_plane_find_free_overlay(struct drm_device *dev, struct drm_plane *hwoverlay_to_plane[], + u32 caps, u32 fourcc) +{ + struct omap_drm_private *priv = dev->dev_private; + int i; + + DBG("caps: %x fourcc: %x", caps, fourcc); + + for (i = 0; i < priv->num_ovls; i++) { + struct omap_hw_overlay *cur = priv->overlays[i]; + + DBG("%d: id: %d cur->caps: %x", + cur->idx, cur->id, cur->caps); + + /* skip if already in-use */ + if (hwoverlay_to_plane[cur->idx]) + continue; + + /* skip if doesn't support some required caps: */ + if (caps & ~cur->caps) + continue; + + /* check supported format */ + if (!dispc_ovl_color_mode_supported(priv->dispc, + cur->id, fourcc)) + continue; + + return cur; + } + + DBG("no match"); + return NULL; +} + +/* + * Assign a new overlay to a plane with the required caps and supported fourcc + * If a plane need a new overlay, the previous one should have been released + * with omap_overlay_release() + * This should be called from the plane atomic_check() in order to prepare the + * next global overlay_map to be enabled when atomic transaction is valid. + */ +int omap_overlay_assign(struct drm_atomic_state *s, struct drm_plane *plane, + u32 caps, u32 fourcc, struct omap_hw_overlay **overlay) +{ + /* Get the global state of the current atomic transaction */ + struct omap_global_state *state = omap_get_global_state(s); + struct drm_plane **overlay_map = state->hwoverlay_to_plane; + struct omap_hw_overlay *ovl; + + ovl = omap_plane_find_free_overlay(s->dev, overlay_map, caps, fourcc); + if (!ovl) + return -ENOMEM; + + overlay_map[ovl->idx] = plane; + *overlay = ovl; + + DBG("%s: assign to plane %s caps %x", ovl->name, plane->name, caps); + + return 0; +} + +/* + * Release an overlay from a plane if the plane gets not visible or the plane + * need a new overlay if overlay caps changes. + * This should be called from the plane atomic_check() in order to prepare the + * next global overlay_map to be enabled when atomic transaction is valid. + */ +void omap_overlay_release(struct drm_atomic_state *s, struct omap_hw_overlay *overlay) +{ + /* Get the global state of the current atomic transaction */ + struct omap_global_state *state = omap_get_global_state(s); + struct drm_plane **overlay_map = state->hwoverlay_to_plane; + + if (!overlay) + return; + + if (WARN_ON(!overlay_map[overlay->idx])) + return; + + DBG("%s: release from plane %s", overlay->name, overlay_map[overlay->idx]->name); + + overlay_map[overlay->idx] = NULL; +} + +/* + * Update an overlay state that was attached to a plane before the current atomic state. + * This should be called from the plane atomic_update() or atomic_disable(), + * where an overlay association to a plane could have changed between the old and current + * atomic state. + */ +void omap_overlay_update_state(struct omap_drm_private *priv, + struct omap_hw_overlay *overlay) +{ + struct omap_global_state *state = omap_get_existing_global_state(priv); + struct drm_plane **overlay_map = state->hwoverlay_to_plane; + + /* Check if this overlay is not used anymore, then disable it */ + if (!overlay_map[overlay->idx]) { + DBG("%s: disabled", overlay->name); + + /* disable the overlay */ + dispc_ovl_enable(priv->dispc, overlay->id, false); + } +} + static void omap_overlay_destroy(struct omap_hw_overlay *overlay) { kfree(overlay); diff --git a/drivers/gpu/drm/omapdrm/omap_overlay.h b/drivers/gpu/drm/omapdrm/omap_overlay.h index 51d26aebf77d..38ca55e1e2d7 100644 --- a/drivers/gpu/drm/omapdrm/omap_overlay.h +++ b/drivers/gpu/drm/omapdrm/omap_overlay.h @@ -27,4 +27,8 @@ struct omap_hw_overlay { int omap_hwoverlays_init(struct omap_drm_private *priv); void omap_hwoverlays_destroy(struct omap_drm_private *priv); +int omap_overlay_assign(struct drm_atomic_state *s, struct drm_plane *plane, + u32 caps, u32 fourcc, struct omap_hw_overlay **overlay); +void omap_overlay_release(struct drm_atomic_state *s, struct omap_hw_overlay *overlay); +void omap_overlay_update_state(struct omap_drm_private *priv, struct omap_hw_overlay *overlay); #endif /* __OMAPDRM_OVERLAY_H__ */ diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 72d5adbbadfa..ce5ed45401fb 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "omap_dmm_tiler.h" #include "omap_drv.h" @@ -21,6 +22,8 @@ struct omap_plane_state { /* Must be first. */ struct drm_plane_state base; + + struct omap_hw_overlay *overlay; }; #define to_omap_plane(x) container_of(x, struct omap_plane, base) @@ -28,8 +31,6 @@ struct omap_plane_state { struct omap_plane { struct drm_plane base; enum omap_plane_id id; - - struct omap_hw_overlay *overlay; }; static int omap_plane_prepare_fb(struct drm_plane *plane, @@ -54,13 +55,29 @@ static void omap_plane_atomic_update(struct drm_plane *plane, struct drm_atomic_state *state) { struct omap_drm_private *priv = plane->dev->dev_private; - struct omap_plane *omap_plane = to_omap_plane(plane); struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane); - enum omap_plane_id ovl_id = omap_plane->overlay->id; + struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, + plane); + struct omap_plane_state *new_omap_state; + struct omap_plane_state *old_omap_state; struct omap_overlay_info info; + enum omap_plane_id ovl_id; int ret; + new_omap_state = to_omap_plane_state(new_state); + old_omap_state = to_omap_plane_state(old_state); + + /* Cleanup previously held overlay if needed */ + if (old_omap_state->overlay) + omap_overlay_update_state(priv, old_omap_state->overlay); + + if (!new_omap_state->overlay) { + DBG("[PLANE:%d:%s] no overlay attached", plane->base.id, plane->name); + return; + } + + ovl_id = new_omap_state->overlay->id; DBG("%s, crtc=%p fb=%p", plane->name, new_state->crtc, new_state->fb); @@ -79,9 +96,9 @@ static void omap_plane_atomic_update(struct drm_plane *plane, /* update scanout: */ omap_framebuffer_update_scanout(new_state->fb, new_state, &info); - DBG("%dx%d -> %dx%d (%d)", info.width, info.height, - info.out_width, info.out_height, - info.screen_width); + DBG("%s: %dx%d -> %dx%d (%d)", + new_omap_state->overlay->name, info.width, info.height, + info.out_width, info.out_height, info.screen_width); DBG("%d,%d %pad %pad", info.pos_x, info.pos_y, &info.paddr, &info.p_uv_addr); @@ -102,16 +119,26 @@ static void omap_plane_atomic_update(struct drm_plane *plane, static void omap_plane_atomic_disable(struct drm_plane *plane, struct drm_atomic_state *state) { - struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, - plane); struct omap_drm_private *priv = plane->dev->dev_private; struct omap_plane *omap_plane = to_omap_plane(plane); - enum omap_plane_id ovl_id = omap_plane->overlay->id; + struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, + plane); + struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, + plane); + struct omap_plane_state *new_omap_state; + struct omap_plane_state *old_omap_state; + + new_omap_state = to_omap_plane_state(new_state); + old_omap_state = to_omap_plane_state(old_state); + + if (!old_omap_state->overlay) + return; new_state->rotation = DRM_MODE_ROTATE_0; new_state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : omap_plane->id; - dispc_ovl_enable(priv->dispc, ovl_id, false); + omap_overlay_update_state(priv, old_omap_state->overlay); + new_omap_state->overlay = NULL; } #define FRAC_16_16(mult, div) (((mult) << 16) / (div)) @@ -121,32 +148,37 @@ static int omap_plane_atomic_check(struct drm_plane *plane, { struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane); + struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, + plane); struct omap_drm_private *priv = plane->dev->dev_private; + struct omap_plane_state *omap_state = to_omap_plane_state(new_plane_state); + struct omap_global_state *omap_overlay_global_state; struct drm_crtc_state *crtc_state; + bool new_hw_overlay = false; u32 max_width, max_height; + struct drm_crtc *crtc; u16 width, height; + u32 caps = 0; + u32 fourcc; int ret; - if (!new_plane_state->fb) - return 0; + omap_overlay_global_state = omap_get_global_state(state); + if (IS_ERR(omap_overlay_global_state)) + return PTR_ERR(omap_overlay_global_state); dispc_ovl_get_max_size(priv->dispc, &width, &height); max_width = width << 16; max_height = height << 16; - /* crtc should only be NULL when disabling (i.e., !new_plane_state->fb) */ - if (WARN_ON(!new_plane_state->crtc)) + crtc = new_plane_state->crtc ? new_plane_state->crtc : plane->state->crtc; + if (!crtc) return 0; - crtc_state = drm_atomic_get_existing_crtc_state(state, - new_plane_state->crtc); + crtc_state = drm_atomic_get_existing_crtc_state(state, crtc); /* we should have a crtc state if the plane is attached to a crtc */ if (WARN_ON(!crtc_state)) return 0; - if (!crtc_state->enable) - return 0; - /* * Note: these are just sanity checks to filter out totally bad scaling * factors. The real limits must be calculated case by case, and @@ -159,6 +191,15 @@ static int omap_plane_atomic_check(struct drm_plane *plane, if (ret) return ret; + DBG("%s: visible %d -> %d", plane->name, + old_plane_state->visible, new_plane_state->visible); + + if (!new_plane_state->visible) { + omap_overlay_release(state, omap_state->overlay); + omap_state->overlay = NULL; + return 0; + } + if (new_plane_state->crtc_x < 0 || new_plane_state->crtc_y < 0) return -EINVAL; @@ -179,6 +220,43 @@ static int omap_plane_atomic_check(struct drm_plane *plane, !omap_framebuffer_supports_rotation(new_plane_state->fb)) return -EINVAL; + if ((new_plane_state->src_w >> 16) != new_plane_state->crtc_w || + (new_plane_state->src_h >> 16) != new_plane_state->crtc_h) + caps |= OMAP_DSS_OVL_CAP_SCALE; + + fourcc = new_plane_state->fb->format->format; + + /* + * (re)allocate hw overlay if we don't have one or + * there is a caps mismatch + */ + if (!omap_state->overlay || (caps & ~omap_state->overlay->caps)) { + new_hw_overlay = true; + } else { + /* check supported format */ + if (!dispc_ovl_color_mode_supported(priv->dispc, omap_state->overlay->id, + fourcc)) + new_hw_overlay = true; + } + + if (new_hw_overlay) { + struct omap_hw_overlay *old_ovl = omap_state->overlay; + struct omap_hw_overlay *new_ovl = NULL; + + omap_overlay_release(state, old_ovl); + + ret = omap_overlay_assign(state, plane, caps, fourcc, &new_ovl); + if (ret) { + DBG("%s: failed to assign hw_overlay", plane->name); + omap_state->overlay = NULL; + return ret; + } + + omap_state->overlay = new_ovl; + } + + DBG("plane: %s overlay_id: %d", plane->name, omap_state->overlay->id); + return 0; } @@ -252,17 +330,21 @@ static void omap_plane_reset(struct drm_plane *plane) static struct drm_plane_state * omap_plane_atomic_duplicate_state(struct drm_plane *plane) { - struct omap_plane_state *state; + struct omap_plane_state *state, *current_state; if (WARN_ON(!plane->state)) return NULL; + current_state = to_omap_plane_state(plane->state); + state = kmalloc(sizeof(*state), GFP_KERNEL); if (!state) return NULL; __drm_atomic_helper_plane_duplicate_state(plane, &state->base); + state->overlay = current_state->overlay; + return &state->base; } @@ -344,12 +426,11 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, return ERR_PTR(-ENOMEM); omap_plane->id = idx; - omap_plane->overlay = priv->overlays[idx]; DBG("%d: type=%d", omap_plane->id, type); DBG(" crtc_mask: 0x%04x", possible_crtcs); - formats = dispc_ovl_get_color_modes(priv->dispc, omap_plane->overlay->id); + formats = dispc_ovl_get_color_modes(priv->dispc, omap_plane->id); for (nformats = 0; formats[nformats]; ++nformats) ; From patchwork Wed Nov 17 14:19:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12624741 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 C216AC433F5 for ; Wed, 17 Nov 2021 14:19:57 +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 8DE7561C32 for ; Wed, 17 Nov 2021 14:19:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8DE7561C32 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.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 0C1546E4A5; Wed, 17 Nov 2021 14:19:55 +0000 (UTC) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by gabe.freedesktop.org (Postfix) with ESMTPS id D6DD36E461 for ; Wed, 17 Nov 2021 14:19:42 +0000 (UTC) Received: by mail-wr1-x42b.google.com with SMTP id u1so4985738wru.13 for ; Wed, 17 Nov 2021 06:19:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MFbb3rRC6CkwVaBmsFg7w37a3G8MDFjwzQkPk2t8wc8=; b=YoYvZVkCpOMlpNMu5GRBDUNDrcw27KAAW2A7PQ5i0wTQqeqlh/J9aUvAT4Gi1raMOs DaUNZWVtcIiIIg/XawEzUd5FVumlENuQiNNgtyrRqfNNB6wCWoIr7vZ7ab+iTN7TRnf1 00oYjUpCCX9hwJdtSqoZvJBtf4+R+2OYWHhWU+/7OV0erZN8zm82SGt3JD53Myw+OkCr YfEg/RtEXdA6mu53N5/Ksu6uYg6wcy13Vu0l0ONyyO09tSbhCgKcHc2HrY01Y9EsMi0z Ge+BeWOaKkTbus1xr1UtWg0P9wRzINmiFVMd1xG7QOLgo6u4wj2RQ0nz/kw10Q5zhox5 VzVg== 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=MFbb3rRC6CkwVaBmsFg7w37a3G8MDFjwzQkPk2t8wc8=; b=gvC/r2cteBUgz94OrSmfGCZEXhqb6lPvxMiViaNefiNPzQk7HIwy6QvEgk8upvNybj FTxSQrMrdTjrx899Xcyfgl2s5rJ1pdKycUFvyp3VQDyTrUVgd58/TIn8Bwx8spq2/mQe AvW5GYxi9g+j00odnrBRhZc0TZCp/yjfcKQIyVNGhjg87Q/DgFVyESDRgpnuupn0WW0z yaDoqHf+xcEhVmQqu68BHJXp4xj5dh6obn8FnKIo12QBKrkLbTvW9q51SrGZyoFIIt0q IsPVTPlpn1TcZQ75pBbhySLEmbWWNShv1yQdWg3ZSIS+aKUeWVHLF5i9cyL41rzowtGl 7ZkA== X-Gm-Message-State: AOAM531MxGDkmqIOqeCjg95hjgUZekp0luObohjNu25Ypp0BxoyP5WDV h9koux8WwyarzlEFo8Hmh4rTFQ== X-Google-Smtp-Source: ABdhPJw7uxvrrCV1Yon1GxDh+Ova8AePIueSwHwgQnyuE7lmYJXI+VqBKsWNufu80QQ4VIQ0XeUgyg== X-Received: by 2002:a05:6000:1862:: with SMTP id d2mr20330832wri.251.1637158781261; Wed, 17 Nov 2021 06:19:41 -0800 (PST) Received: from localhost.localdomain ([2001:861:44c0:66c0:f98b:434c:566c:492d]) by smtp.gmail.com with ESMTPSA id o10sm33803wri.15.2021.11.17.06.19.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Nov 2021 06:19:40 -0800 (PST) From: Neil Armstrong To: tomba@kernel.org Subject: [PATCH v7 8/9] drm/omap: add plane_atomic_print_state support Date: Wed, 17 Nov 2021 15:19:27 +0100 Message-Id: <20211117141928.771082-9-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117141928.771082-1-narmstrong@baylibre.com> References: <20211117141928.771082-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1645; i=narmstrong@baylibre.com; h=from:subject; bh=Pda2Ac0adRphf+l3IU8dWodFMXXAu4U1eOV5bDdRzdI=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhlQ9MvHDhUMYwMTVhslq4itOuJ9Xjr7S6DtjCpGiK xEPJ8FGJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYZUPTAAKCRB33NvayMhJ0UBNEA CBoe3cUZs6+knh7KLHllThJ7FU3smJZ+1KASHRlcUFjtnCNR9FNuyGuFFMjG9t48pJ/bYrXMxMIlnO jjteeYLSIjfXi1XM4f765+FhL5VlmqmTITWZYE0ckovQeJ2bQRIXQUiylYqGhOcKHXp59HYAq+ck5b iw2hn4CvicvlAm3pg5dZYLgb9/vaVCr8e1oML1LxczgOGA/gXa3M8ADX7Itq8woKm9mOe57anXkdRY eFAEk4zObIzN7YLY9vigoYIUpQ7JxTsWjcdI4gejzafPGIsnerE2nbmqKmsVG6Qy4exm/g6amTduNR 9JD40sfdlSHGN/N26FmYKpG59LsPkmoLxi4PlVXiOL05vO1wzU51LiU4TLWYw0Fqc4J6C/WswyKHBq FuH9gUuEVSsf6oUkPK5/phA4vCeL0kxmJx0m5lg0xHkqgtQeULa1lsxZrccbdbXD1klOOQ8O+4fk+5 nmRRYVbX6Aws4ci46H2VhhJsB3/bQmDE7t6DXfM/V7gnM+jz4tzCn5G9WVPfnzyO0Xl27Wh6q1j+4Q YwktfnN4GtZ+sZoRssYxT8QHZC2rq7dOCk8ZAa9LHy1MsaGgOo+0qoRMTer6ioHUxvNxBVw4R1XfTa jNhUZDwmjZdMYibtVrlc7pKKmLR/V0eYmWrJURctYWdTAOQXBGNzLik8vFBw== X-Developer-Key: i=narmstrong@baylibre.com; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , khilman@baylibre.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Benoit Parrot Now that we added specific item to our subclassed drm_plane_state we can add omap_plane_atomic_print_state() helper to dump out our own driver specific plane state. Signed-off-by: Benoit Parrot Signed-off-by: Neil Armstrong --- drivers/gpu/drm/omapdrm/omap_plane.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index ce5ed45401fb..23b752d837a4 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -348,6 +348,19 @@ omap_plane_atomic_duplicate_state(struct drm_plane *plane) return &state->base; } +static void omap_plane_atomic_print_state(struct drm_printer *p, + const struct drm_plane_state *state) +{ + struct omap_plane_state *omap_state = to_omap_plane_state(state); + + if (omap_state->overlay) + drm_printf(p, "\toverlay=%s (caps=0x%x)\n", + omap_state->overlay->name, + omap_state->overlay->caps); + else + drm_printf(p, "\toverlay=None\n"); +} + static int omap_plane_atomic_set_property(struct drm_plane *plane, struct drm_plane_state *state, struct drm_property *property, @@ -387,6 +400,7 @@ static const struct drm_plane_funcs omap_plane_funcs = { .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, .atomic_set_property = omap_plane_atomic_set_property, .atomic_get_property = omap_plane_atomic_get_property, + .atomic_print_state = omap_plane_atomic_print_state, }; static bool omap_plane_supports_yuv(struct drm_plane *plane) From patchwork Wed Nov 17 14:19:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12624745 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 1D8A3C4332F for ; Wed, 17 Nov 2021 14:20:02 +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 DDBCA6322C for ; Wed, 17 Nov 2021 14:20:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DDBCA6322C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.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 D7C346E4B1; Wed, 17 Nov 2021 14:19:57 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 284F66E491 for ; Wed, 17 Nov 2021 14:19:44 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id u1so4985848wru.13 for ; Wed, 17 Nov 2021 06:19:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QPpWi6BwPx2mscCj65VKGDwuScaYCJ38/JnfAWsKtWA=; b=nJ1IGc7Ce8BzNwzC03cZxMSWnP0omMpEkkN/vysetw4X1xf8HI1GYDRHtM0Sk6sY8t rb6pUPvoBmbIRhqZAWE0q7pjzxW+efwfjRFndQSls53lgSgKwR3E9mFdkz4nm56Hc9hd Q99tiCVKo4dT1lZp+snra2gzZLLBtdFALlWhdNPchQXJ7sHFzg4u4YD/fhcQwW+7VgVn Hju3jvIpwVMaEaQ3G3j0QaIf6pBAy0cChDFsS8aLXqQMpG7+F6qMReM1nDhXKOvp1SrW PJuwoGyjvzd45MSjj3VAdXUaJm/7GQKVMTGGyXlUomJbRDtDcpHfLCMZ7TCEl8xq8BuB RmJw== 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=QPpWi6BwPx2mscCj65VKGDwuScaYCJ38/JnfAWsKtWA=; b=Uzztzjs7M/e6/Um60N6SCgpRse7WSWik6lqaUg/xPT3vQHiQdpsCfluvLyq6jqNGyg O3pxt9GhvRcH+xSmOTtadVxNpBCY8bg7ft0hW5Aod10EbRG9Y1H9jVr8IxX1LtEY297u MmQZVJas2IHs4B2bO48f3/Mo7kU8QAkj6OhL4As2EAvL/Xi0YzgAvls/u9baQaAzuCId 50bamUDuYvFSBVcjGZ7qY8cqTYgzOUF0aG6GyknJtTUnbeA892RaZ8AfhVpt7sfxLsOW xSvKhohr3fBypLDRVpto1E5eg9/Hov6zRzDjhokeAHNFLDoD+LtxSgH8uj0Mz8pPKmLW 1YMg== X-Gm-Message-State: AOAM533MMR9CiqOJb4FQikwA8f/FIk5RAe39Fx9UeVa1fTxYDEK4aoxX TsDHYqgNwA7d5qEyoONpp8dJkg== X-Google-Smtp-Source: ABdhPJy/37kC0ngGwIZLyC8Dv6gu+zwPo38T+7PnRBcz4r5W1DlGtjtFrRLmB21G0QKZMvM53AGsvA== X-Received: by 2002:a5d:4492:: with SMTP id j18mr21256967wrq.397.1637158782387; Wed, 17 Nov 2021 06:19:42 -0800 (PST) Received: from localhost.localdomain ([2001:861:44c0:66c0:f98b:434c:566c:492d]) by smtp.gmail.com with ESMTPSA id o10sm33803wri.15.2021.11.17.06.19.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Nov 2021 06:19:41 -0800 (PST) From: Neil Armstrong To: tomba@kernel.org Subject: [PATCH v7 9/9] drm/omap: Add a 'right overlay' to plane state Date: Wed, 17 Nov 2021 15:19:28 +0100 Message-Id: <20211117141928.771082-10-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211117141928.771082-1-narmstrong@baylibre.com> References: <20211117141928.771082-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=18783; i=narmstrong@baylibre.com; h=from:subject; bh=29wscSk13dUIY++8rw7N2jgrpwm2DqCcLw9Je5vimkQ=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhlQ9M+kYNmtrzBUBtYIYyuzF6Bqdh1Hl2TsypdMap Ht/3VXyJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYZUPTAAKCRB33NvayMhJ0UFSD/ 9L1pFQrg8DWVxikubWb2lkD3zJ+440I1vtb2BPiwqCBcMW5Tj/GQ9bjh3kN/O3xCzDUtojg1cl23R+ 3mH3BkFZyZTPf9fwqVLSnToCc6V/o62CsW+r4eoHeQ2PPxpeH6vA0ebKk532RbBR31ijp4lHCDI8Fj 184LCQBHORR9Alqg4bvl/RfoXpcQVw05Szaj9BxgRc1SP6ufQn9tUULyQlCHZ4gI4UL2MbtFvhYcn5 QImahQtvzvhViPQe1RVQeRMrfGxG6mIavrhQH1VEFRM+IzALmawr6AqtwofXcx0fzRtEn4/aUmWy8B M854HAiZQNMBhEqT66K5m6b6GZygR9yuA7YiYezdaTRpdRhv3yW4T0TsMBez5qqO6D8D/kMCmne7UI stvHLnj5tJov5rKEG9yTjC5yMLmkcTcit/LhFIyKhLbosI3DhM6yOZlm/Br6TWyTWbLgJT+3kB/3e9 20T7RyclXl+kqcjqOZHbjGvhElrXbP3GbILyhi+tZ/NjjM68lZMB7QLBvzzW29X0ZdysYU6XvtdjPq 4Kw96u2G/lfGVVC39w4ko2qAa/LTZ0YwBPMzfUIu1FBosJW5LTmn8X3IRFuHuFt/YzCyfkGIegyPrW vzulf0uKjNW9udGVDOAKJBTFdq7NSW5m3HVjNrg3vNr4rsaMWVW+czExoXOg== X-Developer-Key: i=narmstrong@baylibre.com; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong , khilman@baylibre.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Benoit Parrot If the drm_plane has a source width that's greater than the max width supported by a single hw overlay, then we assign a 'r_overlay' to it in omap_plane_atomic_check(). Both overlays should have the capabilities required to handle the source framebuffer. The only parameters that vary between the left and right hwoverlays are the src_w, crtc_w, src_x and crtc_x as we just even chop the fb into left and right halves. We also take care of not creating odd width size when dealing with YUV formats. Since both halves need to be 'appear' side by side the zpos is recalculated when dealing with dual overlay cases so that the other planes zpos is consistent. Depending on user space usage it is possible that on occasion the number of requested planes exceeds the numbers of overlays required to display them. In that case a failure would be returned for the plane that cannot be handled at that time. It is up to user space to make sure the H/W resource are not over-subscribed. Signed-off-by: Benoit Parrot Signed-off-by: Neil Armstrong --- drivers/gpu/drm/omapdrm/omap_drv.c | 98 ++++++++++++++++++++- drivers/gpu/drm/omapdrm/omap_fb.c | 33 ++++++- drivers/gpu/drm/omapdrm/omap_fb.h | 4 +- drivers/gpu/drm/omapdrm/omap_overlay.c | 23 ++++- drivers/gpu/drm/omapdrm/omap_overlay.h | 3 +- drivers/gpu/drm/omapdrm/omap_plane.c | 117 +++++++++++++++++++++++-- drivers/gpu/drm/omapdrm/omap_plane.h | 1 + 7 files changed, 267 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 44a9dcb3100c..2720a58ccd90 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -117,6 +117,102 @@ static void omap_atomic_commit_tail(struct drm_atomic_state *old_state) dispc_runtime_put(priv->dispc); } +static int drm_atomic_state_normalized_zpos_cmp(const void *a, const void *b) +{ + const struct drm_plane_state *sa = *(struct drm_plane_state **)a; + const struct drm_plane_state *sb = *(struct drm_plane_state **)b; + + if (sa->normalized_zpos != sb->normalized_zpos) + return sa->normalized_zpos - sb->normalized_zpos; + else + return sa->plane->base.id - sb->plane->base.id; +} + +/* + * This replaces the drm_atomic_normalize_zpos to handle the dual overlay case. + * + * Since both halves need to be 'appear' side by side the zpos is + * recalculated when dealing with dual overlay cases so that the other + * planes zpos is consistent. + */ +static int omap_atomic_update_normalize_zpos(struct drm_device *dev, + struct drm_atomic_state *state) +{ + struct drm_crtc *crtc; + struct drm_crtc_state *old_state, *new_state; + struct drm_plane *plane; + int c, i, n, inc; + int total_planes = dev->mode_config.num_total_plane; + struct drm_plane_state **states; + int ret = 0; + + states = kmalloc_array(total_planes, sizeof(*states), GFP_KERNEL); + if (!states) + return -ENOMEM; + + for_each_oldnew_crtc_in_state(state, crtc, old_state, new_state, c) { + if (old_state->plane_mask == new_state->plane_mask && + !new_state->zpos_changed) + continue; + + /* Reset plane increment and index value for every crtc */ + n = 0; + + /* + * Normalization process might create new states for planes + * which normalized_zpos has to be recalculated. + */ + drm_for_each_plane_mask(plane, dev, new_state->plane_mask) { + struct drm_plane_state *plane_state = + drm_atomic_get_plane_state(new_state->state, + plane); + if (IS_ERR(plane_state)) { + ret = PTR_ERR(plane_state); + goto done; + } + states[n++] = plane_state; + } + + sort(states, n, sizeof(*states), + drm_atomic_state_normalized_zpos_cmp, NULL); + + for (i = 0, inc = 0; i < n; i++) { + plane = states[i]->plane; + + states[i]->normalized_zpos = i + inc; + DRM_DEBUG_ATOMIC("[PLANE:%d:%s] updated normalized zpos value %d\n", + plane->base.id, plane->name, + states[i]->normalized_zpos); + + if (is_omap_plane_dual_overlay(states[i])) + inc++; + } + new_state->zpos_changed = true; + } + +done: + kfree(states); + return ret; +} + +static int omap_atomic_check(struct drm_device *dev, + struct drm_atomic_state *state) +{ + int ret; + + ret = drm_atomic_helper_check(dev, state); + if (ret) + return ret; + + if (dev->mode_config.normalize_zpos) { + ret = omap_atomic_update_normalize_zpos(dev, state); + if (ret) + return ret; + } + + return 0; +} + static const struct drm_mode_config_helper_funcs omap_mode_config_helper_funcs = { .atomic_commit_tail = omap_atomic_commit_tail, }; @@ -124,7 +220,7 @@ static const struct drm_mode_config_helper_funcs omap_mode_config_helper_funcs = static const struct drm_mode_config_funcs omap_mode_config_funcs = { .fb_create = omap_framebuffer_create, .output_poll_changed = drm_fb_helper_output_poll_changed, - .atomic_check = drm_atomic_helper_check, + .atomic_check = omap_atomic_check, .atomic_commit = drm_atomic_helper_commit, }; diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 190afc564914..895e66b08a81 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -131,7 +131,9 @@ static u32 drm_rotation_to_tiler(unsigned int drm_rot) /* update ovl info for scanout, handles cases of multi-planar fb's, etc. */ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, - struct drm_plane_state *state, struct omap_overlay_info *info) + struct drm_plane_state *state, + struct omap_overlay_info *info, + struct omap_overlay_info *r_info) { struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb); const struct drm_format_info *format = omap_fb->format; @@ -218,6 +220,35 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, } else { info->p_uv_addr = 0; } + + if (r_info) { + info->width /= 2; + info->out_width /= 2; + + *r_info = *info; + + if (fb->format->is_yuv) { + if (info->width & 1) { + info->width++; + r_info->width--; + } + + if (info->out_width & 1) { + info->out_width++; + r_info->out_width--; + } + } + + r_info->pos_x = info->pos_x + info->out_width; + + r_info->paddr = get_linear_addr(fb, format, 0, + x + info->width, y); + if (fb->format->format == DRM_FORMAT_NV12) { + r_info->p_uv_addr = + get_linear_addr(fb, format, 1, + x + info->width, y); + } + } } /* pin, prepare for scanout: */ diff --git a/drivers/gpu/drm/omapdrm/omap_fb.h b/drivers/gpu/drm/omapdrm/omap_fb.h index c0e19aed8220..b75f0b5ef1d8 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.h +++ b/drivers/gpu/drm/omapdrm/omap_fb.h @@ -26,7 +26,9 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, int omap_framebuffer_pin(struct drm_framebuffer *fb); void omap_framebuffer_unpin(struct drm_framebuffer *fb); void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, - struct drm_plane_state *state, struct omap_overlay_info *info); + struct drm_plane_state *state, + struct omap_overlay_info *info, + struct omap_overlay_info *r_info); bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb); void omap_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m); diff --git a/drivers/gpu/drm/omapdrm/omap_overlay.c b/drivers/gpu/drm/omapdrm/omap_overlay.c index afb2b44fdf86..10730c9b2752 100644 --- a/drivers/gpu/drm/omapdrm/omap_overlay.c +++ b/drivers/gpu/drm/omapdrm/omap_overlay.c @@ -67,12 +67,13 @@ omap_plane_find_free_overlay(struct drm_device *dev, struct drm_plane *hwoverlay * next global overlay_map to be enabled when atomic transaction is valid. */ int omap_overlay_assign(struct drm_atomic_state *s, struct drm_plane *plane, - u32 caps, u32 fourcc, struct omap_hw_overlay **overlay) + u32 caps, u32 fourcc, struct omap_hw_overlay **overlay, + struct omap_hw_overlay **r_overlay) { /* Get the global state of the current atomic transaction */ struct omap_global_state *state = omap_get_global_state(s); struct drm_plane **overlay_map = state->hwoverlay_to_plane; - struct omap_hw_overlay *ovl; + struct omap_hw_overlay *ovl, *r_ovl; ovl = omap_plane_find_free_overlay(s->dev, overlay_map, caps, fourcc); if (!ovl) @@ -81,8 +82,26 @@ int omap_overlay_assign(struct drm_atomic_state *s, struct drm_plane *plane, overlay_map[ovl->idx] = plane; *overlay = ovl; + if (r_overlay) { + r_ovl = omap_plane_find_free_overlay(s->dev, overlay_map, + caps, fourcc); + if (!r_ovl) { + overlay_map[r_ovl->idx] = NULL; + *overlay = NULL; + return -ENOMEM; + } + + overlay_map[r_ovl->idx] = plane; + *r_overlay = r_ovl; + } + DBG("%s: assign to plane %s caps %x", ovl->name, plane->name, caps); + if (r_overlay) { + DBG("%s: assign to right of plane %s caps %x", + r_ovl->name, plane->name, caps); + } + return 0; } diff --git a/drivers/gpu/drm/omapdrm/omap_overlay.h b/drivers/gpu/drm/omapdrm/omap_overlay.h index 38ca55e1e2d7..e36a43f35563 100644 --- a/drivers/gpu/drm/omapdrm/omap_overlay.h +++ b/drivers/gpu/drm/omapdrm/omap_overlay.h @@ -28,7 +28,8 @@ struct omap_hw_overlay { int omap_hwoverlays_init(struct omap_drm_private *priv); void omap_hwoverlays_destroy(struct omap_drm_private *priv); int omap_overlay_assign(struct drm_atomic_state *s, struct drm_plane *plane, - u32 caps, u32 fourcc, struct omap_hw_overlay **overlay); + u32 caps, u32 fourcc, struct omap_hw_overlay **overlay, + struct omap_hw_overlay **r_overlay); void omap_overlay_release(struct drm_atomic_state *s, struct omap_hw_overlay *overlay); void omap_overlay_update_state(struct omap_drm_private *priv, struct omap_hw_overlay *overlay); #endif /* __OMAPDRM_OVERLAY_H__ */ diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 23b752d837a4..b35205c4e979 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -24,6 +24,7 @@ struct omap_plane_state { struct drm_plane_state base; struct omap_hw_overlay *overlay; + struct omap_hw_overlay *r_overlay; /* right overlay */ }; #define to_omap_plane(x) container_of(x, struct omap_plane, base) @@ -33,6 +34,13 @@ struct omap_plane { enum omap_plane_id id; }; +bool is_omap_plane_dual_overlay(struct drm_plane_state *state) +{ + struct omap_plane_state *omap_state = to_omap_plane_state(state); + + return !!omap_state->r_overlay; +} + static int omap_plane_prepare_fb(struct drm_plane *plane, struct drm_plane_state *new_state) { @@ -61,16 +69,21 @@ static void omap_plane_atomic_update(struct drm_plane *plane, plane); struct omap_plane_state *new_omap_state; struct omap_plane_state *old_omap_state; - struct omap_overlay_info info; - enum omap_plane_id ovl_id; + struct omap_overlay_info info, r_info; + enum omap_plane_id ovl_id, r_ovl_id; int ret; + bool dual_ovl; new_omap_state = to_omap_plane_state(new_state); old_omap_state = to_omap_plane_state(old_state); + dual_ovl = is_omap_plane_dual_overlay(new_state); + /* Cleanup previously held overlay if needed */ if (old_omap_state->overlay) omap_overlay_update_state(priv, old_omap_state->overlay); + if (old_omap_state->r_overlay) + omap_overlay_update_state(priv, old_omap_state->r_overlay); if (!new_omap_state->overlay) { DBG("[PLANE:%d:%s] no overlay attached", plane->base.id, plane->name); @@ -93,8 +106,11 @@ static void omap_plane_atomic_update(struct drm_plane *plane, info.color_encoding = new_state->color_encoding; info.color_range = new_state->color_range; + r_info = info; + /* update scanout: */ - omap_framebuffer_update_scanout(new_state->fb, new_state, &info); + omap_framebuffer_update_scanout(new_state->fb, new_state, &info, + dual_ovl ? &r_info : NULL); DBG("%s: %dx%d -> %dx%d (%d)", new_omap_state->overlay->name, info.width, info.height, @@ -102,6 +118,23 @@ static void omap_plane_atomic_update(struct drm_plane *plane, DBG("%d,%d %pad %pad", info.pos_x, info.pos_y, &info.paddr, &info.p_uv_addr); + if (dual_ovl) { + r_ovl_id = new_omap_state->r_overlay->id; + /* + * If the current plane uses 2 hw planes the very next + * zorder is used by the r_overlay so we just use the + * main overlay zorder + 1 + */ + r_info.zorder = info.zorder + 1; + + DBG("%s: %dx%d -> %dx%d (%d)", + new_omap_state->r_overlay->name, + r_info.width, r_info.height, + r_info.out_width, r_info.out_height, r_info.screen_width); + DBG("%d,%d %pad %pad", r_info.pos_x, r_info.pos_y, + &r_info.paddr, &r_info.p_uv_addr); + } + /* and finally, update omapdss: */ ret = dispc_ovl_setup(priv->dispc, ovl_id, &info, omap_crtc_timings(new_state->crtc), false, @@ -114,6 +147,21 @@ static void omap_plane_atomic_update(struct drm_plane *plane, } dispc_ovl_enable(priv->dispc, ovl_id, true); + + if (dual_ovl) { + ret = dispc_ovl_setup(priv->dispc, r_ovl_id, &r_info, + omap_crtc_timings(new_state->crtc), false, + omap_crtc_channel(new_state->crtc)); + if (ret) { + dev_err(plane->dev->dev, "Failed to setup plane right-overlay %s\n", + plane->name); + dispc_ovl_enable(priv->dispc, r_ovl_id, false); + dispc_ovl_enable(priv->dispc, ovl_id, false); + return; + } + + dispc_ovl_enable(priv->dispc, r_ovl_id, true); + } } static void omap_plane_atomic_disable(struct drm_plane *plane, @@ -139,6 +187,11 @@ static void omap_plane_atomic_disable(struct drm_plane *plane, omap_overlay_update_state(priv, old_omap_state->overlay); new_omap_state->overlay = NULL; + + if (is_omap_plane_dual_overlay(old_state)) { + omap_overlay_update_state(priv, old_omap_state->r_overlay); + new_omap_state->r_overlay = NULL; + } } #define FRAC_16_16(mult, div) (((mult) << 16) / (div)) @@ -154,6 +207,7 @@ static int omap_plane_atomic_check(struct drm_plane *plane, struct omap_plane_state *omap_state = to_omap_plane_state(new_plane_state); struct omap_global_state *omap_overlay_global_state; struct drm_crtc_state *crtc_state; + bool new_r_hw_overlay = false; bool new_hw_overlay = false; u32 max_width, max_height; struct drm_crtc *crtc; @@ -196,7 +250,9 @@ static int omap_plane_atomic_check(struct drm_plane *plane, if (!new_plane_state->visible) { omap_overlay_release(state, omap_state->overlay); + omap_overlay_release(state, omap_state->r_overlay); omap_state->overlay = NULL; + omap_state->r_overlay = NULL; return 0; } @@ -213,8 +269,30 @@ static int omap_plane_atomic_check(struct drm_plane *plane, if (new_plane_state->src_h > max_height || new_plane_state->crtc_h > height) return -EINVAL; - if (new_plane_state->src_w > max_width || new_plane_state->crtc_w > width) - return -EINVAL; + + if (new_plane_state->src_w > max_width || new_plane_state->crtc_w > width) { + bool is_fourcc_yuv = new_plane_state->fb->format->is_yuv; + + if (is_fourcc_yuv && (((new_plane_state->src_w >> 16) / 2 & 1) || + new_plane_state->crtc_w / 2 & 1)) { + /* + * When calculating the split overlay width + * and it yield an odd value we will need to adjust + * the indivual width +/- 1. So make sure it fits + */ + if (new_plane_state->src_w <= ((2 * width - 1) << 16) && + new_plane_state->crtc_w <= (2 * width - 1)) + new_r_hw_overlay = true; + else + return -EINVAL; + } else { + if (new_plane_state->src_w <= (2 * max_width) && + new_plane_state->crtc_w <= (2 * width)) + new_r_hw_overlay = true; + else + return -EINVAL; + } + } if (new_plane_state->rotation != DRM_MODE_ROTATE_0 && !omap_framebuffer_supports_rotation(new_plane_state->fb)) @@ -239,24 +317,44 @@ static int omap_plane_atomic_check(struct drm_plane *plane, new_hw_overlay = true; } + /* + * check if we need two overlays and only have 1 or + * if we had 2 overlays but will only need 1 + */ + if ((new_r_hw_overlay && !omap_state->r_overlay) || + (!new_r_hw_overlay && omap_state->r_overlay)) + new_hw_overlay = true; + if (new_hw_overlay) { struct omap_hw_overlay *old_ovl = omap_state->overlay; + struct omap_hw_overlay *old_r_ovl = omap_state->r_overlay; struct omap_hw_overlay *new_ovl = NULL; + struct omap_hw_overlay *new_r_ovl = NULL; omap_overlay_release(state, old_ovl); + omap_overlay_release(state, old_r_ovl); - ret = omap_overlay_assign(state, plane, caps, fourcc, &new_ovl); + ret = omap_overlay_assign(state, plane, caps, fourcc, &new_ovl, + new_r_hw_overlay ? &new_r_ovl : NULL); if (ret) { DBG("%s: failed to assign hw_overlay", plane->name); omap_state->overlay = NULL; + omap_state->r_overlay = NULL; return ret; } omap_state->overlay = new_ovl; + if (new_r_hw_overlay) + omap_state->r_overlay = new_r_ovl; + else + omap_state->r_overlay = NULL; } DBG("plane: %s overlay_id: %d", plane->name, omap_state->overlay->id); + if (omap_state->r_overlay) + DBG("plane: %s r_overlay_id: %d", plane->name, omap_state->r_overlay->id); + return 0; } @@ -344,6 +442,7 @@ omap_plane_atomic_duplicate_state(struct drm_plane *plane) __drm_atomic_helper_plane_duplicate_state(plane, &state->base); state->overlay = current_state->overlay; + state->r_overlay = current_state->r_overlay; return &state->base; } @@ -359,6 +458,12 @@ static void omap_plane_atomic_print_state(struct drm_printer *p, omap_state->overlay->caps); else drm_printf(p, "\toverlay=None\n"); + if (omap_state->r_overlay) + drm_printf(p, "\tr_overlay=%s (caps=0x%x)\n", + omap_state->r_overlay->name, + omap_state->r_overlay->caps); + else + drm_printf(p, "\tr_overlay=None\n"); } static int omap_plane_atomic_set_property(struct drm_plane *plane, diff --git a/drivers/gpu/drm/omapdrm/omap_plane.h b/drivers/gpu/drm/omapdrm/omap_plane.h index 0c28fe8ffa20..a9a33e12722a 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.h +++ b/drivers/gpu/drm/omapdrm/omap_plane.h @@ -22,5 +22,6 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, u32 possible_crtcs); void omap_plane_install_properties(struct drm_plane *plane, struct drm_mode_object *obj); +bool is_omap_plane_dual_overlay(struct drm_plane_state *state); #endif /* __OMAPDRM_PLANE_H__ */