Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3956008pxb; Mon, 8 Feb 2021 04:35:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJweb2HXzMITEssYUgHknmg5HtmUX4wxjX2vjRByGpBj98iIq5DYotnr9kfOh7CULczOWKzE X-Received: by 2002:a05:6402:35ca:: with SMTP id z10mr16888323edc.186.1612787745746; Mon, 08 Feb 2021 04:35:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612787745; cv=none; d=google.com; s=arc-20160816; b=qsBEYgI96FQ66Yl+eWpdT3BaNvcEcR1LA/E9EpZDzQkmLcTIu9FfGb9vXYyd8auGZS Z08E1KS16RsnH2bx4X2qwp1NSG5+n5p9ZOEQkXODXzeqZMS7ff7kXwAjpkwsPPo7CUpW kVKbsz6wT9/Wy+G5Tr+I7AjLJmHoUZ4qXo9ZvObmk+H8ys75AgJYE9qnZtMIkGMcwSXV cQKKF+t4dS1AMDa1TfZ2CMfM9BVBNY8YkaDfCU3Nng7fvXOrXcXDyDhLCJS8070zxCwE rXztP/tcC14PeR8gXhz/aNElyiiF5w8wWMJ5Mba1aYjVtsRQeLbqVtUI/2Y8OQX1Iba3 ugxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=dHR+LeYmCRA3E972nW3KRU6Bcr4UevlIConeWqCCm0k=; b=hGaepPO3gx2ggE5+ulovPKs/k2VeZMmDAOFpvPGWqIOAi/pu3Jhly4IH1tuJ4JHfaI VV2l0v/QOtgBxqt7PeiklTaG8i4wqK6DWF1S+xaKxDVO8roNu4Qd/qdV5GHEYhOlZjcK +AVaZRImgtOkRlkP+QF7Q0fgevZkVPI0OMZxF4QARHrgJ4V4xCxSUPGHyWuizAl++qnD 7pMwKr4q0Eid0nqpFOKu6sGdjQk26bSgLT3kk02ClKt1GYjZdHEHW9pLs5By16bciqlO O8FyZ98vq6eddhV4nMaKupiDbCpEWLpUh3trnQ5+PGWM8oHKpSo2mm9L9zqU1DQNkcEw 9Lbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=siol.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k27si11036912eje.568.2021.02.08.04.35.18; Mon, 08 Feb 2021 04:35:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=siol.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232430AbhBHMdM (ORCPT + 99 others); Mon, 8 Feb 2021 07:33:12 -0500 Received: from mailoutvs3.siol.net ([185.57.226.194]:52962 "EHLO mail.siol.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231237AbhBHMT7 (ORCPT ); Mon, 8 Feb 2021 07:19:59 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.siol.net (Zimbra) with ESMTP id 79EEC522491; Mon, 8 Feb 2021 13:18:05 +0100 (CET) X-Virus-Scanned: amavisd-new at psrvmta12.zcs-production.pri Received: from mail.siol.net ([127.0.0.1]) by localhost (psrvmta12.zcs-production.pri [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Hwh0HxeK9ffR; Mon, 8 Feb 2021 13:18:05 +0100 (CET) Received: from mail.siol.net (localhost [127.0.0.1]) by mail.siol.net (Zimbra) with ESMTPS id 2861252234E; Mon, 8 Feb 2021 13:18:05 +0100 (CET) Received: from kista.localdomain (cpe-86-58-58-53.static.triera.net [86.58.58.53]) (Authenticated sender: 031275009) by mail.siol.net (Zimbra) with ESMTPSA id BDF1B5224F8; Mon, 8 Feb 2021 13:18:02 +0100 (CET) From: Jernej Skrabec To: mripard@kernel.org, wens@csie.org Cc: mturquette@baylibre.com, sboyd@kernel.org, airlied@linux.ie, daniel@ffwll.ch, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-sunxi@googlegroups.com, Andre Heider Subject: [PATCH v2 2/5] drm/sun4i: tcon: set sync polarity for tcon1 channel Date: Mon, 8 Feb 2021 13:17:49 +0100 Message-Id: <20210208121752.2255465-3-jernej.skrabec@siol.net> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208121752.2255465-1-jernej.skrabec@siol.net> References: <20210208121752.2255465-1-jernej.skrabec@siol.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Channel 1 has polarity bits for vsync and hsync signals but driver never sets them. It turns out that with pre-HDMI2 controllers seemingly there is no issue if polarity is not set. However, with HDMI2 controllers (H6) there often comes to de-synchronization due to phase shift. This causes flickering screen. It's safe to assume that similar issues might happen also with pre-HDMI2 controllers. Solve issue with setting vsync and hsync polarity. Note that display stacks with tcon top have polarity bits actually in tcon0 polarity register. Fixes: 9026e0d122ac ("drm: Add Allwinner A10 Display Engine support") Reviewed-by: Chen-Yu Tsai Tested-by: Andre Heider Signed-off-by: Jernej Skrabec --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/sun4i/sun4i_tcon.h | 6 ++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/s= un4i_tcon.c index 6b9af4c08cd6..9f06dec0fc61 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -672,6 +672,30 @@ static void sun4i_tcon1_mode_set(struct sun4i_tcon *= tcon, SUN4I_TCON1_BASIC5_V_SYNC(vsync) | SUN4I_TCON1_BASIC5_H_SYNC(hsync)); =20 + /* Setup the polarity of multiple signals */ + if (tcon->quirks->polarity_in_ch0) { + val =3D 0; + + if (mode->flags & DRM_MODE_FLAG_PHSYNC) + val |=3D SUN4I_TCON0_IO_POL_HSYNC_POSITIVE; + + if (mode->flags & DRM_MODE_FLAG_PVSYNC) + val |=3D SUN4I_TCON0_IO_POL_VSYNC_POSITIVE; + + regmap_write(tcon->regs, SUN4I_TCON0_IO_POL_REG, val); + } else { + /* according to vendor driver, this bit must be always set */ + val =3D SUN4I_TCON1_IO_POL_UNKNOWN; + + if (mode->flags & DRM_MODE_FLAG_PHSYNC) + val |=3D SUN4I_TCON1_IO_POL_HSYNC_POSITIVE; + + if (mode->flags & DRM_MODE_FLAG_PVSYNC) + val |=3D SUN4I_TCON1_IO_POL_VSYNC_POSITIVE; + + regmap_write(tcon->regs, SUN4I_TCON1_IO_POL_REG, val); + } + /* Map output pins to channel 1 */ regmap_update_bits(tcon->regs, SUN4I_TCON_GCTL_REG, SUN4I_TCON_GCTL_IOMAP_MASK, @@ -1500,6 +1524,7 @@ static const struct sun4i_tcon_quirks sun8i_a83t_tv= _quirks =3D { =20 static const struct sun4i_tcon_quirks sun8i_r40_tv_quirks =3D { .has_channel_1 =3D true, + .polarity_in_ch0 =3D true, .set_mux =3D sun8i_r40_tcon_tv_set_mux, }; =20 diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/s= un4i_tcon.h index c5ac1b02482c..e624f6977eb8 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h @@ -154,6 +154,11 @@ #define SUN4I_TCON1_BASIC5_V_SYNC(height) (((height) - 1) & 0x3ff) =20 #define SUN4I_TCON1_IO_POL_REG 0xf0 +/* there is no documentation about this bit */ +#define SUN4I_TCON1_IO_POL_UNKNOWN BIT(26) +#define SUN4I_TCON1_IO_POL_HSYNC_POSITIVE BIT(25) +#define SUN4I_TCON1_IO_POL_VSYNC_POSITIVE BIT(24) + #define SUN4I_TCON1_IO_TRI_REG 0xf4 =20 #define SUN4I_TCON_ECC_FIFO_REG 0xf8 @@ -236,6 +241,7 @@ struct sun4i_tcon_quirks { bool needs_de_be_mux; /* sun6i needs mux to select backend */ bool needs_edp_reset; /* a80 edp reset needed for tcon0 access */ bool supports_lvds; /* Does the TCON support an LVDS output? */ + bool polarity_in_ch0; /* some tcon1 channels have polarity bits in tcon= 0 pol register */ u8 dclk_min_div; /* minimum divider for TCON0 DCLK */ =20 /* callback to handle tcon muxing options */ --=20 2.30.0