From patchwork Mon Oct 18 14:28:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12566673 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 B5A92C433F5 for ; Mon, 18 Oct 2021 14:29:04 +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 851BC60FC2 for ; Mon, 18 Oct 2021 14:29:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 851BC60FC2 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 1DB966EA12; Mon, 18 Oct 2021 14:28:59 +0000 (UTC) Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9F7196E0A8 for ; Mon, 18 Oct 2021 14:28:47 +0000 (UTC) Received: by mail-wm1-x332.google.com with SMTP id o24so1527326wms.0 for ; Mon, 18 Oct 2021 07:28:47 -0700 (PDT) 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=jHztITnDF4fFQXSKxud+QNz8Jtqj0NJjpDNYvgJfDX8=; b=a75bCI54fwhIwi6iZBBIUBOxKcoSSV0MXSYc+y1b39wdrWdh92RsRkKHhkx/2lOioN NUrd6JMCWMYONmkG7r4RxW0akwa8sd5rnt60p/WCFZozGLxjW3tKtJI3X0SDWMlqC4j8 GdQJs84k/L93E9LPe8IqA2id9EcqcweUNJKHx82dr9DhWbp0kxq/VRLYq78pDSHl+ro6 uN0Z9qtazeYNbjPxGZzvaqMhEJ5vH3UvTSk2tXo3bEg7wC30bhJ7ZXBILjuDefnD+Gpq YXxZPRFeGBQkmeV3Ixjg89V4Wr8/9OX/WXv+tQdwAzpYmoo19DJUCABCp+KUCZLipBtL wWvg== 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=jHztITnDF4fFQXSKxud+QNz8Jtqj0NJjpDNYvgJfDX8=; b=yuL0xVXHv4sd4ww2TCTBlUOfW7syvg70A+/7frrRy6PKT4zjURxlgEK/PWmoqmGVZ1 tTU5RHcJkrd91RMn9YmqAmuXX7hZYIEKoY7EITK2Og91PYFxYJV9WSkSfXPsK55DnuWt G60XAl7zsdkzGLcQNwzXjyqdh3UTNbck8udN7M4QTsoXB9O+YnFubmjLikep2Doq7OZy GSBXAimly/pEARe/Miny5QGIDleIr/ipos+hpxvdp0hemS1Q8wnuoMXCOd+3EgEMquAS gDaqf1stfdyGJkBKXAOl2ioDYUFB8RdnV3tLVa4nzNWjDE/zmQ20bk6TkUqzD7yH8e17 5P1g== X-Gm-Message-State: AOAM532XDiOtQsUKEcjgV22icMWOhg2Fl7JwYWR0GTA7LVCp1sbGqqeC Zi7Sv7iCPAkI/32T5jghx0/OFg== X-Google-Smtp-Source: ABdhPJyUNbZdGJGYbv9xfyRTzLs3LcBStntNkLkja8uWayfJChDiCc4fbZiJlRd1tOqhu1H9OGuY7Q== X-Received: by 2002:a05:600c:cc:: with SMTP id u12mr1446004wmm.46.1634567325978; Mon, 18 Oct 2021 07:28:45 -0700 (PDT) Received: from localhost.localdomain ([2001:861:44c0:66c0:2dd7:d5eb:6e87:f924]) by smtp.gmail.com with ESMTPSA id b3sm12908495wrp.52.2021.10.18.07.28.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 07:28:45 -0700 (PDT) From: Neil Armstrong To: tomba@kernel.org Cc: linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, Neil Armstrong , Benoit Parrot Subject: [PATCH v6 1/9] drm/omap: add sanity plane state check Date: Mon, 18 Oct 2021 16:28:34 +0200 Message-Id: <20211018142842.2511200-2-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018142842.2511200-1-narmstrong@baylibre.com> References: <20211018142842.2511200-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1849; h=from:subject; bh=jRkIww6GJd5Wg+RgwNKRyh7OLNc3fS8CQvhWZ54HJl0=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhbYSFq/A8B8ssl6yiFVlKdW61NXQ3l6SuPbdR8b6q ZKp4TeGJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYW2EhQAKCRB33NvayMhJ0QgoD/ 0Y1G67QzeQnlWqz4y6rQyfTlmnlBQghuyus96kzr6X2utUqn2CCy0rJ9L4kqsuuFqHrruLjF2XBPcb JacJ0DIMHTX0WGr/RBWIxTyqlEE10Zg7uV/VTVBHmgE2bOCWNgMqRK3lFvdIr3IzNlt5EGlajO26rz gs2FwZdhTtneTdZUgUxIV2m7lSCLWgBuLjUw6lUzDJo4vw3R/3Hr8iGVGGvfG6SiGGC7M+drWWNxPi RoRYmryEINz3U1ywpQDrXP8SAJiZosCPNDyjCzn0HJxh1jZbOAW4vUw2YnbiZlw4qIcqvs0+3Ydlfs JP1Xjl68doj6DwP+PFEsGFrr9p4MpWfSmKdcZ9xq2lZJSOOVhZ1EqxE1bjKX8t7+zN8Jz2tgaWO9XY FxjXp8awUzmnEdJCKDZA862mFjykRKxKsP0mwTOsDkSt3jgv5F8yVnoUDUcRrDklqx1ludUPywsrp3 bUYtEUceq922sYSFFAqh2xGwmhtenxQKFWvf+z8HnSKWb9zJfh5pI0W64P8DrQR4mgJduDvb0lcfCy XfnLnBSRkkwwwZF3vczcvn9kijPmlpJOLdUvvbGq0cix7niwxmb67CpkfCp6JLamn48z0M6zc+HHLz BEudz0ht0gXv2v8TZjyrwJGwJslJnq/p89npsqExjha6xb4KdjTNG6M9JMxA== 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: , 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. 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 Mon Oct 18 14:28:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12566677 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 133C6C433F5 for ; Mon, 18 Oct 2021 14:29:10 +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 D86B460FC2 for ; Mon, 18 Oct 2021 14:29:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D86B460FC2 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 6EEE66EA47; Mon, 18 Oct 2021 14:28:59 +0000 (UTC) Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by gabe.freedesktop.org (Postfix) with ESMTPS id B930E6E087 for ; Mon, 18 Oct 2021 14:28:48 +0000 (UTC) Received: by mail-wm1-x329.google.com with SMTP id y74-20020a1c7d4d000000b00322f53b9bbfso5049399wmc.3 for ; Mon, 18 Oct 2021 07:28:48 -0700 (PDT) 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=PlRyqVZs8t2GxRCJeGwHfM08zQltefexaW1+bSnykxM=; b=lVKEYO5EP1/doQX6tasKJjzKVsdtxdzU6s9kAJW8P7SiRFhfArSu/0ywEfNA/NMh28 wsRMXPYF5Ktxw1PGgnzOi5OPWfe0CsVlvWZ0B6uyjScv/92Lk47pDqX+jheiD9yMT+H3 gAxH5/nHZCZMYAd0v7mW2m+dlz5SNUVDIniihpgpLK/RH46FcORnt4JNRux4iBk/CsxU SlF7HJDRH1v8ttdVx/WQvxDZvWw9uh7pgfDmZBKpSiyzvlzbVy4+xOse9kUosIFMOzZZ cow+3riXUiHEJV5uHisbdbK6iys1h0EDCaT9505eA/5tpsxmCDw6v9l5gEUUP3IiapZD zaeQ== 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=PlRyqVZs8t2GxRCJeGwHfM08zQltefexaW1+bSnykxM=; b=F8IdiglNtazCKRKUW2tWz+trsOWX3jIBszRd8brs324BpdC/szMbVoYcnEach5j9UG 5VBy4UyV5sHE77Kjw5cJDRgrAJQOx11RPHJPDxO/RS/i9huA5obLY0QhcrvAIvk7vrpZ na37AgC5Qzdk3E/AMbTYoUJhrmt8qY/HJAiait+YuHCPbbNh9RpqyAWW7WPRgOBlYNmx wMxeVSC44Cm7lXH+fr8MgfdK+G5Uy5hElfed2K4NWTL91CsXR6cOT0Sapv6iHc8iWIMH YxGJ0ntlBjNxAskpsfNvAmEtbMqNNJbdvnPABvEU0tNGyei90o6CMtBrKDCxvF90upE5 83fw== X-Gm-Message-State: AOAM532PP1blaOheYrpPeJAhXw3yFpENeC8juXhVjYCOnQwbMk8QvT9a I8+hkak3VbRoVxelnQF3gpTu9Y5MLHtaNg== X-Google-Smtp-Source: ABdhPJzC2K6B/tmzHWV8Hu16OcIq6nBCv3xLiFs5r2fmETsAlA0EeTu0lFlY/IrPc2+u91c9vQT3tA== X-Received: by 2002:a05:600c:a4b:: with SMTP id c11mr30050047wmq.97.1634567326960; Mon, 18 Oct 2021 07:28:46 -0700 (PDT) Received: from localhost.localdomain ([2001:861:44c0:66c0:2dd7:d5eb:6e87:f924]) by smtp.gmail.com with ESMTPSA id b3sm12908495wrp.52.2021.10.18.07.28.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 07:28:46 -0700 (PDT) From: Neil Armstrong To: tomba@kernel.org Cc: linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, Benoit Parrot , Neil Armstrong Subject: [PATCH v6 2/9] drm/omap: Add ability to check if requested plane modes can be supported Date: Mon, 18 Oct 2021 16:28:35 +0200 Message-Id: <20211018142842.2511200-3-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018142842.2511200-1-narmstrong@baylibre.com> References: <20211018142842.2511200-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5884; i=narmstrong@baylibre.com; h=from:subject; bh=m1fui6vsNAviHm9JjbpK2UEIata+oUxTAJinjmkQeMU=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhbYSF6EJImsbCEwAk3lfi3qnwenhpmDpa0nj1zxGv yId8A/eJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYW2EhQAKCRB33NvayMhJ0a2dD/ sGpM257UvyBFfJjFPYFW1b6eUqciEKtf4xSrPMroDyewaiQz0lKe7fdf4PXy8ndsI769SXeDg1J7JO BibYt88P5ZTXbYc5DLr5n6hsitgS/o+CzwXyAAmWPtjwiJJg/VcjYQvWmi3dLtoX1kW8T8ecf2Wh3T Dao63dP4zciFu9DSstOcPOcB5lDNw7Wp7t52RbSAzsfG3QO3DQjSXWGnaU3mGz08wItB0n9W2Ydfva aVsm2y21vKewMDLOUoEAMMf6BBCnCDq2lRGYiifA112EcfxAcuOPC+gTXnQgNj2jgzvrIgtP9D28to ukFAAAQXHNw0/hUiSmU8mVeDX4PVxZN/JiO+SyChpEoACzwJMxbzUS1FQHSCORKO3ptitD6TGD37sH Ya5HIP09T8PX1z6KfqAEuZ1rVfhAdOZDhRueW7epuenbBEP1ldxWUEpGJ0IRL5NcwgJjohgugsNSdH Rna19F+Vzv1Jy2y4zrdC6aK0sRt7TSW95iHUFZMFLfKz8a34RAfRv3wajguwFZiZmbEKRJoL0H1wnj 885Gdnd0cIDw/EtDER0X7S4RczpsZv9L76BLWT1m5flXYdgmunWbfvHW+ygFkvdBUAwqiATsnGKPwu VPmuFvmakOfItJs5cblxAkrVB9cp3pri4g7/vmycpAy1rYR2IG7ffIBG0e0g== 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: , 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 5619420cc2cc..5ac90ba6b76d 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 = 186000000, .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 Mon Oct 18 14:28:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12566665 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 8F3EEC4332F for ; Mon, 18 Oct 2021 14:28: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 5869F6128A for ; Mon, 18 Oct 2021 14:28:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5869F6128A 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 1E1C26E0A8; Mon, 18 Oct 2021 14:28:51 +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 AEB276E087 for ; Mon, 18 Oct 2021 14:28:49 +0000 (UTC) Received: by mail-wr1-x42f.google.com with SMTP id r7so41835813wrc.10 for ; Mon, 18 Oct 2021 07:28:49 -0700 (PDT) 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=5H2hhzuRrvmA/4yp/fNI9riPBu8q3rix23PsNkWExX4=; b=EMOfL+zMR3n+voUDGnHpGA8hK7xhP9l2G8bv3uB/w1/ggpy9RAab8rmCLNjg+JMAKL shO2XE70RQJVyJMZh1GblHFGqx1aA9unr15AqjahO64JHvpYWLjt68wArBhL5KvS1wv0 nGEYMDqxG8yRuf5nJhmO/sDDorJeiXQXHRbSRFW0Hn0mTF0uHTShYR1w/ZqNh7oDKBks 2gg10Jp+HCWWSANx6TIBX0i3EExfT2L0xruyTQjPgiSsaAEL55rYU61aLNfhoXmw8z1W 9GYUJJGwH9ouxedT1vRxznnXwmt+IiZnmyi1sjxJQdNTUC6PL4+HHaor3TV5CVISMSBp b3dg== 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=5H2hhzuRrvmA/4yp/fNI9riPBu8q3rix23PsNkWExX4=; b=1BhoQSVjt4S7QBwc4GhS5QeBig2m+vIdWzGWmTfpmvCnyCpLiqBIaCJB/zaTumYAcc SRMxokiEgDUz4f7qwMsbwLHgG2DZWDQjioy19JTSKgYKZEdCOwuYHoEUWmpS/Tzsr5ew RfDMbAZbZ2MHGyzbL1LiTn/c0ef8Kd8PTTja9Q4nU95g5wKZzN6x7FPQZQlqest/opCi bCiIzyFfxZlp0e8+pXZnAjLscDwdOne41QJ90hsNcRDeC+yw4Qb2gDy9myXlIWhW4Pgx mGnPWQR0x3xmfoBl6YnUqiFIYECVkxWA3P8iADGXe+5qvXFmllqpOlYWSd+NPf4NBF4x 5ijA== X-Gm-Message-State: AOAM5332+0nz0dMhQtXU9O3fFpdreILzZlrZ46okhbOiTLW8z4Y6+O89 yUFE4YDHkanYLhYF/X9aVm0CQeBCkP++1Q== X-Google-Smtp-Source: ABdhPJzQuzaxNQ3bud8LujqNIFqGNFYw34jL1vJ2T8djA36YlLePQjxHnCPScXcjcWKOX+sPfv+trA== X-Received: by 2002:adf:bb12:: with SMTP id r18mr36073651wrg.313.1634567328043; Mon, 18 Oct 2021 07:28:48 -0700 (PDT) Received: from localhost.localdomain ([2001:861:44c0:66c0:2dd7:d5eb:6e87:f924]) by smtp.gmail.com with ESMTPSA id b3sm12908495wrp.52.2021.10.18.07.28.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 07:28:47 -0700 (PDT) From: Neil Armstrong To: tomba@kernel.org Cc: linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, Benoit Parrot , Neil Armstrong Subject: [PATCH v6 3/9] drm/omap: Add ovl checking funcs to dispc_ops Date: Mon, 18 Oct 2021 16:28:36 +0200 Message-Id: <20211018142842.2511200-4-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018142842.2511200-1-narmstrong@baylibre.com> References: <20211018142842.2511200-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2331; i=narmstrong@baylibre.com; h=from:subject; bh=koW8JWicC/ikxRWVypGZv81IJqBAw7vmCwy+5yAxnpw=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhbYSFU+lQsT2xLcINix4tQSeHdOJZ9AaFtpUCP2s/ W9Lto32JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYW2EhQAKCRB33NvayMhJ0aiPD/ 0UhV4dm089UmDROSLcsjGPn3RsOpemnxIiXeCTyg7MxV38TSWTqd96dG5hL5vs4kzy0ity7rtleZTN PP2XsOnBBdN9Ku0Aa1iVqDbSCbxoZm4CTnkhSLAYzrCG4f9xtd6PpXO5Upi5/Z7EOSAiiBZwk1a/dV VjSPtsY8kqOlO6rZqOmsR3hPAWVANl62bQF7i1FwL3QQqiSoHZDDS4r6jE1b10l7PknPB60IIqMVM3 wJ4Uin/8Me4nOt+uv4IM+c5WYjY1fzEZFNESsASnVRg5MvGHhEc0QiFOxhXQ62W7aE4/Ldn/51tEIb MnzDIX6Nl28Ahf9P8TpD/PnHwdg6nFP8xNHrSh0dMO1soUX7EwB9Z/3SH1HLk5yB9OS/tqYOaYYL6z W4IRbhNFvC74RmqJKEDTrE0bQ8QyfzXASQVwENHASIESK9q2NpRYQx1E7WJI0OvgDYzB37gTARXE8m PEfh5DCqeP0EGZS44ymX/5+8zza4H/UaHHN/DpRUepF81+vQeoC+YFWlMyj5FDCLrs+QjMASyulBw/ hXW1Hoh6pG4v2rixs27yKoFMjCR2txVGAQAuiDdyFTPM8U3U5vgyFs9I4QA4qHZwcgKXXFTwjYDOiZ rsDyzoq4+kF+J3PHI7/FcZLU5qkH4E6JpPHa7HXTm6/fOzuV/nBdxx3251nQ== 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: , 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 5ac90ba6b76d..dd36db75b4b4 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 Mon Oct 18 14:28:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12566667 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 ED5B2C433F5 for ; Mon, 18 Oct 2021 14:28:54 +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 A5B0A60FC2 for ; Mon, 18 Oct 2021 14:28:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A5B0A60FC2 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 E1ADF6E0C8; Mon, 18 Oct 2021 14:28:51 +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 E1FAF6E087 for ; Mon, 18 Oct 2021 14:28:50 +0000 (UTC) Received: by mail-wr1-x42b.google.com with SMTP id m22so41970341wrb.0 for ; Mon, 18 Oct 2021 07:28:50 -0700 (PDT) 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=hw2kEKR6GmnnBJZdGv76AQIzp59u7C1ygXfbc46hMPQ=; b=STRSn80K8xFeuDT1GUtZ23w28p8j9zCCXyyGsgatqj0XQZViCN0dQXkXWJZJ5ph6qp ukFV3XqBEOTCqouiKt8xVDL74UTn8EnPaHiZ0SyS6/NN7YlWkmqf+h+jsVq2g3LKaYsg bHt3xSZnt3fHBeAc94JT9wcVtaL05J8SefRltV7u35N5XX1ZBMu8LImdqI03dMlToVXm 8ZBzNLlo2ZkDB/xHGm72qOY3E/W0YuWU39gaRfxAHN86kGG/r6dvlG89WBZLKS5NEMsE lJd2Q0CMdBKuTA9F1EY8R87s0UrELaLNxIz+l9QzvGQPoF7moDkxXOaE5bCcZoWdg/p9 y06A== 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=hw2kEKR6GmnnBJZdGv76AQIzp59u7C1ygXfbc46hMPQ=; b=op1tUOgtGxElk4O+YeE+evBEZ+n39szYcY5Tvq/I1HIP1wbPmU+b0vfO0iRmEGzF/F p+/NIC1pg2VmIPxeFjdStMqZDKxAtN7rvygg/MpHfsgxEmjOjXrC2ts3jRUPVUuo/bqV nBNji3lIMhxBBpor9U6roMcMYXR5uowWt6zXfk6H1jhTeJ4df2VetNzWxx3RA3A2wQB8 nQZdlYhgUXtbGABH8VSqYbIPTrpNEgwf9sUFnDFEjO/9f1Y4/wB8z4qk/hWjnljL3YSx GVkAl5anW0saBSaRqKKAkzdNB/tToKPFlV4P5c9TARgRHI7+r5BGRmH8jW5xkLLkl0qq Dm1Q== X-Gm-Message-State: AOAM533K7oK/vUuqDP7jLRd0EDEJV5oVv0+Y8i19gjgUFM65l4mElUHn MFeZs6xbztIC01vNom2143o48w== X-Google-Smtp-Source: ABdhPJzJo0KXcw4cLD2aXyoy3q8sTwjyaiihQvTga6rkNUSQMX3jBs1oLWIx/lqUK4hM6/CwrwhtTg== X-Received: by 2002:adf:bc12:: with SMTP id s18mr36190044wrg.328.1634567329249; Mon, 18 Oct 2021 07:28:49 -0700 (PDT) Received: from localhost.localdomain ([2001:861:44c0:66c0:2dd7:d5eb:6e87:f924]) by smtp.gmail.com with ESMTPSA id b3sm12908495wrp.52.2021.10.18.07.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 07:28:48 -0700 (PDT) From: Neil Armstrong To: tomba@kernel.org Cc: linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, Benoit Parrot , Neil Armstrong Subject: [PATCH v6 4/9] drm/omap: introduce omap_hw_overlay Date: Mon, 18 Oct 2021 16:28:37 +0200 Message-Id: <20211018142842.2511200-5-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018142842.2511200-1-narmstrong@baylibre.com> References: <20211018142842.2511200-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=11087; i=narmstrong@baylibre.com; h=from:subject; bh=aEE0xUn7b5AAjVaKpKWX5+pDRvalC81eBzrYp9/xaPo=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhbYSFcKA21Y3ZS3pe5nf5a9h3Cz27EjCHpp/0XBFG G8eQ6NuJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYW2EhQAKCRB33NvayMhJ0V3iEA CYpyRojgjK/UbFxgoYQN9/s/DfsiQpD7h1tmEPuVqzoG7YWRrUEnwTQ7OMNE+hWbii9FY27E9jyUas U1NIF9NJ0AZ9cvPWlMoRBBT18rfHam5byW9Kxy8fxCRRLO2B4OBztX4nkg1O5UyrGzT1S8UfZGbBh0 sv1swmTXomdcO/9cjgDCpzObIdd5r0WJnCsx7RpWUKoTcweEWsW86fWgi0SsubVwT6oSLZD8AUPbHS jwinCoxbFzvJ7pAzhy5c3hZ/9kTZxkwl7PJbAeHrh6mOye5jc+mCPjVIZ5pznAjLcw7bAMYZrZgeYt B7WdtsL1/NbYyX5k9NqHEEwgYYTna0DudHluKm3UDrW+wHvYoChEViQ2Xva5RgTzZ/LTXDUDquXYzY nv6un/lSwYUrKnGHXoI3Eff4HvW3Wsu1DFvxTpVDa1zIZO1oFLb8PxbJhyFfGU+ndlJZrP1S+y1VoJ uetoVso507VsOMQYNIxsRBBqqG+nLf46nUzsZR/nwserkr+yZFUGYsxpPKyNNpPfwIN4CuP1/1iwWD /uNdXzk7ru3CO0gjm3y1SawkaToMK2rRQ2HkxCiyhwFWAaKVW8z0PO8RZtXkQYNp+JcJFKvoJBzwAI /C23vBE5ji01wxZ5M/A5Hd/CMYsNSHng57lFuS1Buxf/LmK+82lNO+HwzADg== 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: , 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 f86e20578143..b994014b22e8 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 Mon Oct 18 14:28:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12566681 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 1464DC43217 for ; Mon, 18 Oct 2021 14:29:16 +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 DADC760FC2 for ; Mon, 18 Oct 2021 14:29:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DADC760FC2 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 C26856EA50; Mon, 18 Oct 2021 14:29:10 +0000 (UTC) Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 01B3D6EA31 for ; Mon, 18 Oct 2021 14:28:51 +0000 (UTC) Received: by mail-wm1-x32d.google.com with SMTP id n7-20020a05600c4f8700b00323023159e1so1743512wmq.2 for ; Mon, 18 Oct 2021 07:28:51 -0700 (PDT) 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=3/mSGxFbVm/a8ejyNuBiipxCQCzsxcsH9EjmVlYfMM0=; b=cRT8bLGi1e7toixIcZGCNmcJmQreo8+2YKbEN+BweXLqXrfkr+AvURhS4HeZ6xx9wd 24+5wyItKG1Dx5BYwrlJ2iMC0Fng6suys/Kz+DavvLabeG8dzKd0qp1VqHBNIwVdqn7I VnZN75AdVaRZG4q3Ko76e1QWfB86wJrCfKZNGT1o2z+k9SYKQIBYPoEeLxg4+RnX8ayl Ypy5Bo9gyFArS3F1KFUJT7KMqo1pqASZPwi/MzUy5Hoym14LbsMhL4Nx7gSv68NBSLxl C+xHDtbP41c41lbhHDJzlOH08R+ryfTb0YQoS/WuCt5MvdRujI7tKYp9fVN7z5lS0vQj I68Q== 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=3/mSGxFbVm/a8ejyNuBiipxCQCzsxcsH9EjmVlYfMM0=; b=l1nYjrQmEjfZcEbOKSPwimR1OTvPo84PCnfXMmcw65qN4FflbHdV1Afmvp6JW6N/ut XjK4kCyf7woRPRjDgWR1Ltx4RHmuHbZvO3dq9+pDG7l865P1m/q1XNNklFEb/Yv5wxks UYIoDZEkuGD6yx2mfjfGr3vUq0tVzIyC8vqcIo2B4gI2QT9EbWpBS0nXqTppKwhePjvu sCMzy7Dkqa61HGOG3kxEfRIDo5CaHnR+3YZU2qTH2hErQqOG7kp3dri5/fFlcWEATDJh +a78LgwzYCgMkaQ/aVVwXea4rL0PIFPaKOaooqXqdG3shtEE0uDzqkFSf1jplP+2g4mx Z2Sg== X-Gm-Message-State: AOAM532kIUnC1TpYYPtFuejon7v6GeI4NGp+tGIS25FbEfZ9zVf3qQb4 IRS9fFa9OEYWwVlwRPnsgG9kkw== X-Google-Smtp-Source: ABdhPJyUhYqBjS5v/ZumIUOb8o7m7B3hz8jQP2s5SnSfcy3W2GIyQZ4PfRFJH/nsCBjvQqjlxOI+wA== X-Received: by 2002:a7b:c14b:: with SMTP id z11mr44719659wmi.67.1634567330357; Mon, 18 Oct 2021 07:28:50 -0700 (PDT) Received: from localhost.localdomain ([2001:861:44c0:66c0:2dd7:d5eb:6e87:f924]) by smtp.gmail.com with ESMTPSA id b3sm12908495wrp.52.2021.10.18.07.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 07:28:49 -0700 (PDT) From: Neil Armstrong To: tomba@kernel.org Cc: linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, Benoit Parrot , Neil Armstrong Subject: [PATCH v6 5/9] drm/omap: omap_plane: subclass drm_plane_state Date: Mon, 18 Oct 2021 16:28:38 +0200 Message-Id: <20211018142842.2511200-6-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018142842.2511200-1-narmstrong@baylibre.com> References: <20211018142842.2511200-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2794; i=narmstrong@baylibre.com; h=from:subject; bh=3BRMktYPv4ZG5ydHxi5L83LOPhqyPSOpuiBJIqTcuhg=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhbYSFehgxAvXwgTbPHgdb0WuZCU56tJWRQfNz3yjB /lA4aN+JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYW2EhQAKCRB33NvayMhJ0fUpD/ wJDK9FZARCijfdQxvyOp1GU7LcX7mBsUmJ4rS5HAezqR+YttHooAaWJXgJx4EDViSfT8Sj7z/l5Gyn Tj/7Lvgo9qEa5/jfSXQonuuWTZR401Emz4bqNizL55/f43abHvyya44vbS/zi4Z91t8UHLbL3ZGGXs FG7gTzLha8LyH1/4yzuS3iRtWWOlgmkrSrWu7T5WDw1p5xrLDUYX1ELRDz/wxrMyzu4AWrx1AFLLpp 2DZ3e4W0+Z3HfOu18AK1DF7WDJ6lqv06MLn3M7Opc53iW31VWZ8F3w3L0HRFWtwRuxy/JHH8IJXqeB uiHRplYt8xdKDkqoAKIHwA7Qzanid9WcrGzf3JvLiIUuZuBTM3oyLNFl8aq0p5BRlW7nvI+7qJTDCc JeloAXjUdJastZpSL8AOmyTdmz6OITHRo+trWYphYLmt2w7QCYWm7swOSyylhq9R2PJuj5HrIXXdfP lrnD+AgUn2RSWtTMFaAHntYTwi89u8BqxzWbntmvf9LIjwUWKzy7A+VHdHUodfICUOL1FtfejdbZQX vB2AchZV91RO6zYb7LNYgZ51EYpmLAoZJLBS0Gp3xpbifoBxHzq6tIi2GFoKedpyieYXaSMbq372xD afaGWf7mpTalguy3qyTipCoxZ7K18HQtnHx4h5CwuAzmTObs8mdXicPkshBg== 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: , 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 Mon Oct 18 14:28:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12566675 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 A3908C433EF for ; Mon, 18 Oct 2021 14:29:07 +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 7491460FC2 for ; Mon, 18 Oct 2021 14:29:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7491460FC2 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 F268F6EA46; Mon, 18 Oct 2021 14:28:58 +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 223546E087 for ; Mon, 18 Oct 2021 14:28:53 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id r7so41836126wrc.10 for ; Mon, 18 Oct 2021 07:28:52 -0700 (PDT) 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=xos3ri9U1H5jfjvfpqCdoDexrK3BD8+5TNiS9KWIjfA=; b=GLW3EEI9lukBqzBc/zyjjDzTIKDJ3eKjmMcbRO/8JpwkfZfesNYatflwlIj3vVvKOU sLxUFTlzKMYR8BgqG5jqZpK1+DNZjW2GTKafHXI/Cm8xfOuoiC02yx9HQsGtB24j5Bie 9fb7kLEH7gOmdzS0j6HR7C8gC0HsGyiNd2G3frJiC3+D6XmDce2yL5obD36/+j5iSpGA SptJT9PxrwqWwk6w76YbyBVqg1I3d6lusZyZdgVa4z9wWgp9RAgrM9spiGmOY4G5CpH1 eN3CzbloqRHQD98rYZSrzJgRxhbADDTryVc9LnTXidID1IcaFhrpvy0tFTyaIMOTVk5+ hh1Q== 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=xos3ri9U1H5jfjvfpqCdoDexrK3BD8+5TNiS9KWIjfA=; b=IMEBNJ9nAkl33SYkuqlGZ9njxvY+yQogItvOOl3/0vqGRz0tzq70ve39sUW3zzy67q dXVb0krOpd26rv8JrAzYt1TsxKfc57wimDgo7k0qLWAiCfYPEjkvtSxOym0eYjrX0wh8 rvV72wsP/NO/QFsnhgxD4ME9c5Ys7BIzeJ9nICN9xkF9zcuNJC8N8AE2K8XJprL+IVHp 7fTEK1MiZnAHVEOxSwjKX9qj9SIu4mjL4iBdOZVdKyA3So9WoUkdKzOVlC7KEP16OMYP /BmktFI8B37pzkGy40qxNQBhUiIhVmt5xOk5t38u02hAwJCcziLg5G5Wbib3EdxQsAGo rZVQ== X-Gm-Message-State: AOAM530/JQLNxIir0zvb0qu5nyFnsdQcNT7XSoK669n/EiInMxcFAWk0 f/3YeDHT+5+Ujdufm37l2ZHfAw== X-Google-Smtp-Source: ABdhPJyJrKVMY4U+6f9+E3SwdX8lIo6v9rUOYfVwSuyg0dVOL4VbjTOM6DJlPlDP52jI3pbKMSmQwg== X-Received: by 2002:adf:9c11:: with SMTP id f17mr36970821wrc.147.1634567331452; Mon, 18 Oct 2021 07:28:51 -0700 (PDT) Received: from localhost.localdomain ([2001:861:44c0:66c0:2dd7:d5eb:6e87:f924]) by smtp.gmail.com with ESMTPSA id b3sm12908495wrp.52.2021.10.18.07.28.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 07:28:50 -0700 (PDT) From: Neil Armstrong To: tomba@kernel.org Cc: linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, Benoit Parrot , Neil Armstrong Subject: [PATCH v6 6/9] drm/omap: Add global state as a private atomic object Date: Mon, 18 Oct 2021 16:28:39 +0200 Message-Id: <20211018142842.2511200-7-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018142842.2511200-1-narmstrong@baylibre.com> References: <20211018142842.2511200-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=Fvw9so5WoaGI+JrbPfR7R3ztRakTQgT6adrx2fLhJCE=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhbYSFDkEAMiQ6vpnQFtXgplKartZDABGPywqVCAu8 lmAkVNeJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYW2EhQAKCRB33NvayMhJ0VCmD/ oCgpOOPNnG6UYoUupvQyH9TpyMWGjszGCV2c2HmPBaH3WekKOXmEYcmyOgs5rKYtHK0qkDk5UK3XZR OQsvPyv5U3Sjw8m0HeFvD3K6AKmgGKhMb3r1g5iFo2ZqOrAH0osqR15Dn1/A0S36CBAHT0on4UGC7z t6GxO+qle95D/r8DEashEUSIzs6CtQFvD4Cryhk9H8aQv8AmNXCcC/3MB1He5jTTV+FVTElct21f6T 1Kx9KdTSPJuYwZ+9gKBpmlJmM5t0ClPgjfUj2xdg3Rv5zpgkZonqP2WDLgY/0kHr//YMdLRSv6shHG 15SjB2Jxq60y45GnKnxL7f7qLXDl/XXr6qdPQ4ZBSS5lmxTqbh2dKkek6RYRQ4e5Xgd5OmjGYBhaPn RqEwoHLG/n5V313kbCZIBO/TCVm6JoMnd6Vzyus2pWJfc6FS46srUMPICm82Qo6OShp/spDVLDen6G EPbCjP3aQqBvQ4I50PZiqxC+z8ZteDVwALHSC3rLpQs69oXOJXdmo0CPzCNYTfp62d9mtCg06RHMnp Kd7GaTtQIYz3KplOSivmQOgjvo/EDdjXftm5Z2fsIvGo1kdWzHMZbTda58MITazgzZ7dPrKt5jzrWC 3jbMBRbUrnCpKNUCLxheUmF40vle9deXCxzZRglaAyT8kUSl3DGG62XZ/7iA== 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: , 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 b994014b22e8..c7912374d393 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 Mon Oct 18 14:28:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12566671 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 8BF1FC433EF for ; Mon, 18 Oct 2021 14:29: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 62B0860F9D for ; Mon, 18 Oct 2021 14:29:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 62B0860F9D 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 E4D366EA31; Mon, 18 Oct 2021 14:28:58 +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 67D716E087 for ; Mon, 18 Oct 2021 14:28:54 +0000 (UTC) Received: by mail-wr1-x435.google.com with SMTP id i12so41686826wrb.7 for ; Mon, 18 Oct 2021 07:28:54 -0700 (PDT) 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=anf3kys7dWk6XgpnZE/Xv+mUBOQtQXkDDvhEycY2OckF0Lbt4h1a+WJdX5bQr5HdCC 50BccoyMJn7aTL02E82+BiWt3601j6hhR3NU01Jstgwbhse+QHVSJQ4U/hRWzxn3BBeD b6jPmDGVHGAa7JlM2fRpY7PhVdO3DFqzbKlqKlQnguLqjbPFxXWj4NkUC1op1o34rK6q XgfA9pnswX0V9rpBgcZQ0SP/I20Cd1E4jC6M9CeTfQuumudjPbzeLnBTEf6wgbi9J59/ gAvHmdE4JiJzoSIIQgnNkOffyXbFTGhfS1A9s95amydeyJc0aXk74Ix/Fcp3wLgORsRi vsUA== 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=HkSc3D/umXxe95D2gl5/8dc1e9aaxi+Bl+LlM1OT6P0w+/ppBbFErItaQvmPDYpiuX IBZ/YnsQXiGoM0hrRclByy9otYrv5n0B5LxvD2739nYP0B60dJhHqHwHHqk2rVGugStF WmkJrH5IvTyvD6RvMBcKawfkDelloSzYj6L+wXwl02bM4YznpLY2vqptxx90aXlL0bbB +ppcTJQg7wFtI+8Yk2u4itxzUwMJa4bGU2Qz2V2GXYGj3cPnlO9/tktgke0ZSOmzXHnh FFSMJxzcSdnS+59Rkny+koD4iGjOyMAIv08ImI0XBcHLddxyNnFgCJ5HnE8lt02OG8Hd vXog== X-Gm-Message-State: AOAM53125IxG5EKBf+i9IiQ2ZMpvED7QYTws+VOkP8i8tvQzLfeFMu91 wdpyCTtVbfIG4dPnuJ09Hwe7kA== X-Google-Smtp-Source: ABdhPJxhYJW8chRadXcOyKAOeV4+qebg/90G6lCSIYcRnZL6JT6leYexmkJLeXJfIlmOIIzOM7n5Cw== X-Received: by 2002:a5d:524c:: with SMTP id k12mr25827673wrc.88.1634567332738; Mon, 18 Oct 2021 07:28:52 -0700 (PDT) Received: from localhost.localdomain ([2001:861:44c0:66c0:2dd7:d5eb:6e87:f924]) by smtp.gmail.com with ESMTPSA id b3sm12908495wrp.52.2021.10.18.07.28.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 07:28:51 -0700 (PDT) From: Neil Armstrong To: tomba@kernel.org Cc: linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, Benoit Parrot , Neil Armstrong Subject: [PATCH v6 7/9] drm/omap: dynamically assign hw overlays to planes Date: Mon, 18 Oct 2021 16:28:40 +0200 Message-Id: <20211018142842.2511200-8-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018142842.2511200-1-narmstrong@baylibre.com> References: <20211018142842.2511200-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/ZANAwAKAXfc29rIyEnRAcsmYgBhbYSGuDZf6mWd4D5lFpvaKlbjn8CM3+i4HF8mhH+j e5T8JjKJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYW2EhgAKCRB33NvayMhJ0agSD/ sHO66und2Bd1+iTSSo9aiu65ETLfCH6GanGqma9TQVMYF+lTPm/7T+eJ2hse6An0yFPL0Qmt0lN1EG OUQBSvPBEMfhLdHTjytmFhSO7fxYzE99qvMZR+wCjGHDBSqCUE8Cz7U/EzCIEFvAT78r/LzWWOAMbX Va7pB2/nh/lCJCFD4pRpd00LHbmLyUK/7t28i3ly4c3G7qcn0Fjj3625JkRadCfJTsw1CbPCbuv5p1 5vDJqDhn8VMwhAkyAUqbwmKwZL3V5QLXFiCn5ZqL+xQFp5pl7gExqIQxlerA4kzJ27ZYJLNfnAGshB MgNZ5lcMl0jxlj4YTydwFKeJ4ihXDzb6reXh5g8baN04Skg6rvOuN8mKV2IJI28JNKJ4yhX25N2q4C Vt4z86J7VPdwkixgJYokY5dZsUdLXVisH4cofPPn2EDKAprrG+p44FOJDMPH3/t8Oj1apM5zwq43d1 7iLGlbkiS33JikaPDwdh5KK2d+qCRs00pdxoK3saZSGcUg5GKNfNxsZlfPISzJW9pcHAsocgPrQ6Gl wy2ODJMNYZoZwn24tqAz3QCit/H218EZz6Ns/xVBZHKSHjLzRZZrXcM7rmqkvJACqkFok/QocGCLAG gNqHg2Rzj5S/BmS6zKLKD96w06RjWdPjcCQzOeESO/kzbP1umUW0Upn3W2vQ== 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: , 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 Mon Oct 18 14:28:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12566669 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 DF39FC433F5 for ; Mon, 18 Oct 2021 14:28:58 +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 AFD3660F9F for ; Mon, 18 Oct 2021 14:28:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AFD3660F9F 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 24F9C6E087; Mon, 18 Oct 2021 14:28:58 +0000 (UTC) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by gabe.freedesktop.org (Postfix) with ESMTPS id 651586E087 for ; Mon, 18 Oct 2021 14:28:55 +0000 (UTC) Received: by mail-wr1-x434.google.com with SMTP id t2so41849247wrb.8 for ; Mon, 18 Oct 2021 07:28:55 -0700 (PDT) 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=lIVpyuu3eqZnfVh+BWlIEt1O3BS03uxO8GKG4EQyBdY=; b=gH/1sgob/dAMXDnK1Zij+GCFUd7n9iU8KyIM0JWJOd9CN13vDFG9eQWDrkNMfK3uee aA2hbaiFfVm3iyuF3xUh9Wq/RbP9LJb6zb+qACAsNEa3JW/b5VYklxKXGGMVZiMbjhDd lNmoC9znCiWNaDokDrt2ZQUmSU00CENQqlrAYHXiGGpIDZw60grXFUL+ZU8XGXZ7jIj7 SMMXcz6RZTdp6vEy7vHj/8IfDVggwPNisSYbJD4lspL5uMTQxTtzWD8ZOZ8JE1WzmVIY zaX+/DMnL1hV7cEKr6LfeM1e3EylhE/Y19tu8oMkSnODkXTevV1vxwoP6qAUZdjvSOSa gG+A== 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=lIVpyuu3eqZnfVh+BWlIEt1O3BS03uxO8GKG4EQyBdY=; b=bkkmBdNKPJIw4LiWaFJklyx90D1+giqXMdcW9kwd+9EZ+B3U/g3zn9yJXwluPmMxKc oRrhkRf1Lj7l0ETPsKgm8BnUaxo5P6TaLsYqgOw2TNkbH0mnDeeSfs9SCshZ96KT//6z aJ8/jlBK1QnTPZ/ipZZk4zUGdcb2g/5kjLw/1KXT1lg1MPIePmf5xSc9g8G42iEz6k7v SOzdtamsqBN0CqWCPkxv/ntb0da9Z9qQCGf0zrQaVfWPyLOcldmKYyzEqd7yFc8LhwnN bg3pgfd+59rCyRYLQGqMlc69dytXrSCRlRtvEp+24pp5GOUfbY79ya9vlQ7UnjEc0LbS PHpg== X-Gm-Message-State: AOAM530cWYsvif70wWaNyEtT//TsBL10CsfONvv8E5FnGEM0C/OIfYYm 8ibO67h2yhs620579amrRobQwg== X-Google-Smtp-Source: ABdhPJxGGGec7//1d18gIejeXLzf9z9AnspSnl4+KhhmZtXw6ffAjmmPO4j6D829yKFJcMoWll2JxQ== X-Received: by 2002:a05:6000:184c:: with SMTP id c12mr36506967wri.127.1634567333786; Mon, 18 Oct 2021 07:28:53 -0700 (PDT) Received: from localhost.localdomain ([2001:861:44c0:66c0:2dd7:d5eb:6e87:f924]) by smtp.gmail.com with ESMTPSA id b3sm12908495wrp.52.2021.10.18.07.28.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 07:28:53 -0700 (PDT) From: Neil Armstrong To: tomba@kernel.org Cc: linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, Benoit Parrot , Neil Armstrong Subject: [PATCH v6 8/9] drm/omap: add plane_atomic_print_state support Date: Mon, 18 Oct 2021 16:28:41 +0200 Message-Id: <20211018142842.2511200-9-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018142842.2511200-1-narmstrong@baylibre.com> References: <20211018142842.2511200-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1792; i=narmstrong@baylibre.com; h=from:subject; bh=WJUnfDMOqyIY/JyZJij5vnFH7gBqBRnpbS9bv6xbZYw=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhbYSGNhJeWiEgCa74ngEwWcJR2N3i4688rynOukR8 uHZQBLWJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYW2EhgAKCRB33NvayMhJ0bFAEA CZPKHg2+39aPe3f5tZvn5JlQz4R0qTMoABfNZbVbQfeOVaG4gzYlXccrk592IxEZ0xovQT5MySrA0C 96Ncrj3I11amYmcLbSHtW+9jI5IoHTMvO/2BXFqC/HeQdJZMfb+D7Rmuw9+EAMGyjA5SKTLA2pvjdV yEzWHdIh3X10E0Pi1MtFk2qRAbTwMfEO0Nb2RJdPdrfenTb8Tx1K4dmE7cFVhzDVXdJs9UxeZViNN9 oq0H2wxSBkqnB5yZEeOXuNW/8zv3QyEufxUitip0H6jTgUQm7pAYQ0UOSarrnW7OLtQbYYwzDuSHd7 +hXrPld4d7pujE+zAhZan4YmyvQFJxF18xOqnh6LANTsvgriz4mCFrv2ylN/v+RDONOkSFe2Z2tMnh rlDGaFUnkiULCtObooXMZk0s2odxgPFLEPX0QIZc354DTERybRWGQKfLB6Ft0FFbBc8DN9UXyLGyqz fK5pWZiCiw7MKLJ9LkFATzR285rBnv419Z7ZA6L8XPrNdbmEcJJ5ZWAsrzkR3BRjkdR5oDpl7aqTnO ajKHJcvA4Gyz+Mt5LOTCOGe0wFDMQMOIzFAe2/JTF0CPOzIZRgtRUOhNFvhaGfY3lh3M7EMooJDY06 Oer5vjgRzt/R1IHLToLhMXFFi+TltDRYqYPWRZixUxR1TmGwrF7lnvoNrEPg== 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: , 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index ce5ed45401fb..5001c8354e4f 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -348,6 +348,21 @@ 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); + + drm_printf(p, "\toverlay=%s\n", omap_state->overlay ? + omap_state->overlay->name : "(null)"); + if (omap_state->overlay) { + drm_printf(p, "\t\tidx=%d\n", omap_state->overlay->idx); + drm_printf(p, "\t\toverlay_id=%d\n", + omap_state->overlay->id); + drm_printf(p, "\t\tcaps=0x%x\n", omap_state->overlay->caps); + } +} + static int omap_plane_atomic_set_property(struct drm_plane *plane, struct drm_plane_state *state, struct drm_property *property, @@ -387,6 +402,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 Mon Oct 18 14:28:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12566679 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 3AA31C433F5 for ; Mon, 18 Oct 2021 14:29:13 +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 0EA0560F9D for ; Mon, 18 Oct 2021 14:29:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0EA0560F9D 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 C24676EA4A; Mon, 18 Oct 2021 14:29:01 +0000 (UTC) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 73A1D6E087 for ; Mon, 18 Oct 2021 14:28:56 +0000 (UTC) Received: by mail-wr1-x42d.google.com with SMTP id m22so41970870wrb.0 for ; Mon, 18 Oct 2021 07:28:56 -0700 (PDT) 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=aWfkRcI+Ad/dVg/7UcWT4R6pfcBLtf8s3+uKTB3IQa8=; b=0AYYR5YNUSxFfvg5k2h+0qkwCYjIFCYaHlFc+onvFNpoKcKAqCl6rIJ+oHXRe7ts2w rOsd/DbyuDkZOaT6qTNIWfXJcPZjMx+KAUvJMDp1KCiykytHYo7TEL3hem6b7u8NocXS k8gzdFLKJes/XV5vISsrOZrW/DekLV6XaDGQrZpgJ48dz/yQfm5n/vDNq+AprZqS83Xr bRl6YdOzpwXb/BIKkOWFA9J8Q+u+L9ld8S96pmef5UiRKhxrpNq/F0/AcBfks4nmaYIc CXGDGi9o10ijq++pjGFilidYHihdeM9bnmwPAia/y01tXlFmF0qcZYim/Z/KdJtan8yJ N5gQ== 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=aWfkRcI+Ad/dVg/7UcWT4R6pfcBLtf8s3+uKTB3IQa8=; b=2T5sIMSqUGyVNBNImSlTejYWuaBhIDGirJtvXGGnm0BnLJFxpYah01VNQAFJPZKT93 u/2SrWTNnA9xEw/ktrbbnGy4Q3fAJ1HNksZUR6RcaHLdqxtlFZUBSM0VXvpvlt9t4e0o bFafkJL8GomCoCMwlEHgV/S3j1Ttu5AmU2U/tyRq1BEODrg44hN1FlelEIpfhCCXUqwY wh0rtn9fHB6uPPR9plOCBU1dh8i1FZ3GGXGaiCPdCFcRrmSLCQEEYb76RupnPaOhNOw+ VpNOXnBmjQtVi1fXhCfbOnTyy2Gm9KMYsdmeP39aItCxO6DbYiB+sw6t6YS7+7jqkgnQ Qemg== X-Gm-Message-State: AOAM5331Z1WWt5xBjemxL7oRxrI5du5R8o6oiK7Wo49AJihBQTIMcvEX qc7jupjB4l4pxxvrSAbMoAY+zA== X-Google-Smtp-Source: ABdhPJxx6AM/k4crwQWhk86OqfcFBXcw76ma1X41luk9Gtj64lP9k3pWzSuQRw4J/m14WOduKFvkPA== X-Received: by 2002:adf:a29c:: with SMTP id s28mr34701675wra.116.1634567334729; Mon, 18 Oct 2021 07:28:54 -0700 (PDT) Received: from localhost.localdomain ([2001:861:44c0:66c0:2dd7:d5eb:6e87:f924]) by smtp.gmail.com with ESMTPSA id b3sm12908495wrp.52.2021.10.18.07.28.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 07:28:54 -0700 (PDT) From: Neil Armstrong To: tomba@kernel.org Cc: linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, khilman@baylibre.com, Benoit Parrot , Neil Armstrong Subject: [PATCH v6 9/9] drm/omap: Add a 'right overlay' to plane state Date: Mon, 18 Oct 2021 16:28:42 +0200 Message-Id: <20211018142842.2511200-10-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018142842.2511200-1-narmstrong@baylibre.com> References: <20211018142842.2511200-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=18684; i=narmstrong@baylibre.com; h=from:subject; bh=NC9+9hOFeR0NxyrDNJZ9woIRxQM6OE3ms9Jm/JeFkPs=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBhbYSGhOqWu0BZre/GQagvnP+4/wuLP5aHk6E7RfXe fh2tHBWJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCYW2EhgAKCRB33NvayMhJ0RK9EA DOeHutCJcap1KVxulMZa34ob/siR2deuFf3Hv/KrP+vnEmukpTPJ/IJYFzNfhrK1Q7RpknsqaBQfHN D+tBjvwOo3EjC4EQEC8sUDxWLx4AFUslGsdab+PkQ3D16t2rYP4AeihdwJlgHYUuIYRRHCIIIJ8bMM a5Y7XvPQdaA+xCUMmJJEuPWd8qt6p2wHnnhj2cZOc/0tuGxo5+/FbvoLNdyRjrcXf4o+QGjluJ+B98 BnQMHWNsUlNRPIMwd51j8n9vhyshISWESVJEULsocJ6VrnvHrUlpSwMy0hBlr3tEEfMl9Os9tge7+0 +ofPf0cAKhpn1wJPN6cq+d5uH+P0Xk3w/CbTHx8acpauffAtFNJ+z0fxbpGuc7EDYpblmgEWQQ/KcP 0k5wKTl2hR3Z5vf4i4YELpodMM/AhKF4yGvrheUxdZdtL31BV25leZfGgwqtx9zEwFyVX96b9CQC6p EhR24BcOa8VKA+onge6K+kIO0D99vXOmeUleNhP5DY6YEUmS8y6KOdfhGnc3SW6MCGchJ9KpaaZksU 4UIvpvS+oGnov6MFABxP3pYN0VcE0EtO8hNytUjWc+G57Jqu9A+JM9MIhQZn11rCpdkZWKLX7REAfI hysQJNVooyDTW4BISqPKEIQl4UHFoaGlqWv818VtK3lu2jFM4hJg3odMoRSQ== 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: , 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 | 91 ++++++++++++++++++- 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 | 120 +++++++++++++++++++++++-- drivers/gpu/drm/omapdrm/omap_plane.h | 1 + 7 files changed, 263 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index c7912374d393..f088b6313950 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -117,6 +117,95 @@ 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; +} + +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 +213,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 5001c8354e4f..15cdff988dbc 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; } @@ -361,6 +460,15 @@ static void omap_plane_atomic_print_state(struct drm_printer *p, omap_state->overlay->id); drm_printf(p, "\t\tcaps=0x%x\n", omap_state->overlay->caps); } + + drm_printf(p, "\tr_overlay=%s\n", omap_state->r_overlay ? + omap_state->r_overlay->name : "(null)"); + if (omap_state->r_overlay) { + drm_printf(p, "\t\tidx=%d\n", omap_state->r_overlay->idx); + drm_printf(p, "\t\toverlay_id=%d\n", + omap_state->r_overlay->id); + drm_printf(p, "\t\tcaps=0x%x\n", omap_state->r_overlay->caps); + } } 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__ */