From patchwork Wed Nov 28 10:07:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 10702249 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4F89815A8 for ; Wed, 28 Nov 2018 10:07:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D47E2CC93 for ; Wed, 28 Nov 2018 10:07:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3191B2CF58; Wed, 28 Nov 2018 10:07:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9CDEB2CC93 for ; Wed, 28 Nov 2018 10:07:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=yK4QloBzA6aiswLDeEzOZjP/QALufZ64Osq4aQfdiZU=; b=ZDhFvkg5sSXQeb i9RuiOzhFYu6XfW32/LrdG1KJ6oIVcIOZ6MO9kLGE+lHZ25iQiCorkWWZ4WTbwkRb0K0XrGqDTvwm KokC9Tw6Mzb4KpN4u8nYzEAn+UIR/JAupJri33bMugsmTZrAOAKhvDDdcyV7RyNYX+nN41QUjmMYc iX+k3qzr2a/n3pzrD+xJdTdN7E1YHU8yA/8UHmYLWzXgm535/bVhIqgsxD0NMNP5RaY/iXD4L4F0a 4iDly1lVrn9E/F+VoRF00Izm3bnokUMyKQp4VB50ewSK1H6kG1Vs8tOLkLCLvIeW2o8aG6OIbbGrM QBWQeXAgCo5e9xH1L9yg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gRwl9-0005ie-1s; Wed, 28 Nov 2018 10:07:55 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gRwl5-0005gv-L2 for linux-amlogic@lists.infradead.org; Wed, 28 Nov 2018 10:07:53 +0000 Received: by mail-wm1-x343.google.com with SMTP id r11-v6so1930536wmb.2 for ; Wed, 28 Nov 2018 02:07:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dQVMuqWbkOH065zM1K32Q1gjaQprT4aEQt0Rzogauk4=; b=e7n3oRUB1ZyD44xI8MMESz8QwfVdrQ26WbOo38xr+JCBgBUHsX3RNe48bKJ42WuMHk QWCPMPskffkm2KIbExgbYOCd7MG2tllnqk5F+lJlFyE36t/DZTu82BKkEtxNhNqwxpiO BOc2sIk1ztDdT+m2Z2LFOOhqj8MSfqpUjsGr8l8+WLuZZXVHmytWTzUIri0uv5YSQpCs +4N/P2Qj4iQ79yPRlZjl4epbZZPAjcZBfPa/nO3x5uNl62Jd8eJIrcLXAtGi34GXylqE 2QASYg34bx1ocyZFiWJSsUGss6mioPafbD9v4rtO1QKOqQqAr1ZQdyNJTQfdle6ktLYc XtOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dQVMuqWbkOH065zM1K32Q1gjaQprT4aEQt0Rzogauk4=; b=aBZX8SaHnl+hBnxEU7111GCXwvcFj0C3YcbmBXxFUxu5FNHk4K2qaNU6snZv01284V 9gUItd9j3ZuiT3gzjw7QyRB/FmQOdopH/2ij3665Jd9UqTMUB9MRundJTEb5c0vBs6n3 UyKR8WXxyQGnMNDigyagHnr212PRwXq5iYIKe0JG1XPRSLNek9vagWoou0ziRoOAY3Oa BXgq37DosNW847Is6Ex50Am9WCc5w+be1u7oAzOx/pYGe6pZJF3XEeSs4G8N8K9oqYo7 V7LGE7B0twMvxSjKMFClL8rGHvRFUg86ltKXET2Ikzk3Oeg90ppQFjGPGrxWfoZgW9LN qfNg== X-Gm-Message-State: AA+aEWa90GSQRzjRiIT/6d0iQb74u7HPC12SwWlsgypZk8ssVaxuAw0/ ANWCZ/ydMbpVYJ1slceHLo5FRg== X-Google-Smtp-Source: AFSGD/Vjhqiggcz3PrCJoGl45HoP1SV7K/tR+VX1RXHpxeYihi9TSG8DKatXtr5GZjsB95EOAO27AA== X-Received: by 2002:a1c:e046:: with SMTP id x67mr2063914wmg.122.1543399659575; Wed, 28 Nov 2018 02:07:39 -0800 (PST) Received: from bender.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id h16sm5509730wrs.60.2018.11.28.02.07.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 02:07:38 -0800 (PST) From: Neil Armstrong To: dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/meson: Fix an Alpha Primary Plane bug on Meson GXL/GXM SoCs Date: Wed, 28 Nov 2018 11:07:34 +0100 Message-Id: <20181128100734.6536-1-narmstrong@baylibre.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181128_020751_691627_847D9642 X-CRM114-Status: GOOD ( 13.80 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, Neil Armstrong Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On the Amlogic GXL & GXM SoCs, a bug occurs on the primary plane when alpha is used where the alpha is not aligned with the pixel content. The woraround Amlogic implemented is to reset the OSD1 plane hardware block each time the plane is (re)enabled, solving the issue. In the reset, we still need to save the content of 2 registers which depends on the status of the plane, in addition to reload the scaler conversion matrix at the same time. Signed-off-by: Neil Armstrong Tested-by: Maxime Jourdan Reviewed-by: Maxime Jourdan --- Changes since v1 at [1]: - Fix flickering and shaking by moving reset when plane is disabled [1] https://patchwork.freedesktop.org/patch/263550/ drivers/gpu/drm/meson/meson_plane.c | 12 ++++++++++++ drivers/gpu/drm/meson/meson_viu.c | 27 +++++++++++++++++++++++++++ drivers/gpu/drm/meson/meson_viu.h | 1 + 3 files changed, 40 insertions(+) diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c index 12a47b4f65a5..8e27f275ece8 100644 --- a/drivers/gpu/drm/meson/meson_plane.c +++ b/drivers/gpu/drm/meson/meson_plane.c @@ -79,6 +79,7 @@ struct meson_plane { struct drm_plane base; struct meson_drm *priv; + bool enabled; }; #define to_meson_plane(x) container_of(x, struct meson_plane, base) @@ -303,6 +304,15 @@ static void meson_plane_atomic_update(struct drm_plane *plane, priv->viu.osd1_stride = fb->pitches[0]; priv->viu.osd1_height = fb->height; + if (!meson_plane->enabled) { + /* Reset OSD1 before enabling it on GXL+ SoCs */ + if (meson_vpu_is_compatible(priv, "amlogic,meson-gxm-vpu") || + meson_vpu_is_compatible(priv, "amlogic,meson-gxl-vpu")) + meson_viu_osd1_reset(priv); + + meson_plane->enabled = true; + } + spin_unlock_irqrestore(&priv->drm->event_lock, flags); } @@ -316,6 +326,8 @@ static void meson_plane_atomic_disable(struct drm_plane *plane, writel_bits_relaxed(VPP_OSD1_POSTBLEND, 0, priv->io_base + _REG(VPP_MISC)); + meson_plane->enabled = false; + } static const struct drm_plane_helper_funcs meson_plane_helper_funcs = { diff --git a/drivers/gpu/drm/meson/meson_viu.c b/drivers/gpu/drm/meson/meson_viu.c index 2dffb987ec65..0ba87ff95530 100644 --- a/drivers/gpu/drm/meson/meson_viu.c +++ b/drivers/gpu/drm/meson/meson_viu.c @@ -296,6 +296,33 @@ static void meson_viu_load_matrix(struct meson_drm *priv) true); } +/* VIU OSD1 Reset as workaround for GXL+ Alpha OSD Bug */ +void meson_viu_osd1_reset(struct meson_drm *priv) +{ + uint32_t osd1_fifo_ctrl_stat, osd1_ctrl_stat2; + + /* Save these 2 registers state */ + osd1_fifo_ctrl_stat = readl_relaxed( + priv->io_base + _REG(VIU_OSD1_FIFO_CTRL_STAT)); + osd1_ctrl_stat2 = readl_relaxed( + priv->io_base + _REG(VIU_OSD1_CTRL_STAT2)); + + /* Reset OSD1 */ + writel_bits_relaxed(BIT(0), BIT(0), + priv->io_base + _REG(VIU_SW_RESET)); + writel_bits_relaxed(BIT(0), 0, + priv->io_base + _REG(VIU_SW_RESET)); + + /* Rewrite these registers state lost in the reset */ + writel_relaxed(osd1_fifo_ctrl_stat, + priv->io_base + _REG(VIU_OSD1_FIFO_CTRL_STAT)); + writel_relaxed(osd1_ctrl_stat2, + priv->io_base + _REG(VIU_OSD1_CTRL_STAT2)); + + /* Reload the conversion matrix */ + meson_viu_load_matrix(priv); +} + void meson_viu_init(struct meson_drm *priv) { uint32_t reg; diff --git a/drivers/gpu/drm/meson/meson_viu.h b/drivers/gpu/drm/meson/meson_viu.h index 073b1910bd1b..0f84bddd2ff0 100644 --- a/drivers/gpu/drm/meson/meson_viu.h +++ b/drivers/gpu/drm/meson/meson_viu.h @@ -59,6 +59,7 @@ #define OSD_REPLACE_EN BIT(14) #define OSD_REPLACE_SHIFT 6 +void meson_viu_osd1_reset(struct meson_drm *priv); void meson_viu_init(struct meson_drm *priv); #endif /* __MESON_VIU_H */