Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp377631imu; Wed, 12 Dec 2018 19:12:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/WFz+PqZCBC5rAdyNmaA3yg3qxt+jynnrvyyNL8yI2APiCq08kFUsiqLr5GXHgxPv6nWGm8 X-Received: by 2002:a63:193:: with SMTP id 141mr20595995pgb.136.1544670748486; Wed, 12 Dec 2018 19:12:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544670748; cv=none; d=google.com; s=arc-20160816; b=BV21XtL0UVsLx+6LqUFZCehoJ5o1ISw4m4qJ9spYdhwRayDyNUC5k1nwRnUzwqgclW cZKHBeFBVXmGwPuHshIyxWNDtXjxvzQ76Y1rOnNpGb/PzTMBKDtEzfTGqKMt0A/MRjN6 5VV53UNL3fEfrCLF23kmZObqG05x3A9mCgZiV0ZSiqLOJcv+6x29ru/HR/SkDzSTqxS2 UO+wiVPv8OSuCkYcP7ZwKS5hZIg/GA9eRppGKofH5PAY+5FFCa7ey+cjlYv7S2WOxQTy MaDi7aNds8n0gsJ8wJXlS/+bo4V/2CSafJzif9su7vbUvqY/mPY2sfE2j9s/c7sRPdfh e+dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Pa3pitxVOIgccMX4WhlRVlf6/PcJdehLwmQVlxKOIC0=; b=xddwpG2EVjfuAZwG1/1voZ5MgjdN3EqsXXGdDY+8iCM0Qp+O4tGuADb/BGInb3lw5G PBFgORNXkxYJjEgGhWP2/MMmu5t35TBALt1LZ+i8DWB2JspPEkH6/lWal5W2OdAuR3su tlwQsiyUorDDzqEQ8LOxGatzoMQRU+3z9A48NSYrQzZ05zqT5E9Bz135HfQi2nKjE2al Pn/0z/jVUwU0OmcgzHVTkxuT14135Z/ePpC86Nzu11GukLDbVvMI2d9IC7+tkeZpq1nT kRg8NfsCiQCdtGEvzPdjnCsIqii4IudB3PfmCBR+3Eo9LP9z1KxUw4/50q9GTnZis5sA gWDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B14On8VR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w14si457207plq.145.2018.12.12.19.11.50; Wed, 12 Dec 2018 19:12:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B14On8VR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726725AbeLMDIv (ORCPT + 99 others); Wed, 12 Dec 2018 22:08:51 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46673 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726396AbeLMDIv (ORCPT ); Wed, 12 Dec 2018 22:08:51 -0500 Received: by mail-pg1-f194.google.com with SMTP id w7so307265pgp.13 for ; Wed, 12 Dec 2018 19:08:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Pa3pitxVOIgccMX4WhlRVlf6/PcJdehLwmQVlxKOIC0=; b=B14On8VRotF6Py4iOBoKUhgHDv+qIx2hFkNfOFtWcDpSdDcTeUCWvSPRU7CChUWKaQ F8YUDI+eUdH+Nf+1zOehAzVDlbf7LATH7YNePclmpdVOfW6N8URyWxfUivTgRSI/yAjW 01fHzcB/lEaPRC/S/UP+t62tWg+Ps/3WDkPgOpWRTGy49hHg8ioG6rtA+gctZGE9S+GL ret/r6mwNImVA/my0MdN59El7saYPg5BZpkC5h3uqqIfyfUJF1zOF2I5y4gYcNulI5yB k9KfCjNoK/6KZrtuC5BUo62diCoKG3CzkU5WykFq3o/C1Fd+urdFV4uHfKYUnt/V4wgD yhWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Pa3pitxVOIgccMX4WhlRVlf6/PcJdehLwmQVlxKOIC0=; b=AXYa1yNV8laop3rAZ9HKf6tFSXcNxmrYHPFChMUciwd4p+q9NF9RwOuhho7way0Q5R KHsha+W2cci3LH7Qt8AWXoNF7beSMSdCXAm4UR7Cd9HZ+xOqgpFQD1qaqk79jJYU+iN7 B3UGsvVgSM4VwTGVOmRTXuVKaJuzt7G+g9thoAf71pjWwjf9IpqR208G9XlURlHe2m6I JYVmdIES2yoOn3IY5AjOz0DREGcP2ywPBpSpEs4WiFYXl2r2S9Dv3nAfBGcHseIp87j1 uK4y35rGBXKOwBapSxv9p6YyuDp9Ob0MqrWYIEYUu5ANxW/Au6ubcUseVtbGsQuVZLzW xLfw== X-Gm-Message-State: AA+aEWZu2YI7csnZ98+9yFs5hjUDOQ3POpXGkUYmqPVaQZuhZEG2fhe7 9Wy9K9ZTNezJkgU+Jq63gCNc6WYPJ85QVibcTVpkozzjX9g= X-Received: by 2002:a62:184e:: with SMTP id 75mr22138899pfy.28.1544670529717; Wed, 12 Dec 2018 19:08:49 -0800 (PST) MIME-Version: 1.0 References: <1518717288-123578-1-git-send-email-giulio.benetti@micronovasrl.com> <57d929cf-4458-dae4-36d4-4e89170eba4a@micronovasrl.com> <05786c98-6bc9-44f1-91ea-14452448cced@micronovasrl.com> In-Reply-To: <05786c98-6bc9-44f1-91ea-14452448cced@micronovasrl.com> From: Jonathan Liu Date: Thu, 13 Dec 2018 14:08:18 +1100 Message-ID: Subject: Re: [PATCH] drm/sun4i: fix HSYNC and VSYNC polarity To: Giulio Benetti Cc: Maxime Ripard , Chen-Yu Tsai , linux-arm-kernel , dri-devel , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Giulio, On Wed, 12 Dec 2018 at 04:20, Giulio Benetti wrote: > > Hi Jonathan, > > Il 11/12/2018 11:49, Jonathan Liu ha scritto: > > Hi Giulio, > > > > On Thu, 6 Dec 2018 at 22:00, Giulio Benetti > > wrote: > >> > >> Hi Jonathan, > >> > >> Il 06/12/2018 08:29, Jonathan Liu ha scritto: > >>> Hi Giulio, > >>> > >>> On Thu, 15 Feb 2018 at 17:54, Giulio Benetti > >>> wrote: > >>>> > >>>> Differently from other Lcd signals, HSYNC and VSYNC signals > >>>> result inverted if their bits are cleared to 0. > >>>> > >>>> Invert their settings of IO_POL register. > >>>> > >>>> Signed-off-by: Giulio Benetti > >>>> --- > >>>> drivers/gpu/drm/sun4i/sun4i_tcon.c | 4 ++-- > >>>> 1 file changed, 2 insertions(+), 2 deletions(-) > >>>> > >>>> diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c > >>>> index 3c15cf2..aaf911a 100644 > >>>> --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c > >>>> +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c > >>>> @@ -389,10 +389,10 @@ static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon, > >>>> SUN4I_TCON0_BASIC3_H_SYNC(hsync)); > >>>> > >>>> /* Setup the polarity of the various signals */ > >>>> - if (!(mode->flags & DRM_MODE_FLAG_PHSYNC)) > >>>> + if (mode->flags & DRM_MODE_FLAG_PHSYNC) > >>>> val |= SUN4I_TCON0_IO_POL_HSYNC_POSITIVE; > >>>> > >>>> - if (!(mode->flags & DRM_MODE_FLAG_PVSYNC)) > >>>> + if (mode->flags & DRM_MODE_FLAG_PVSYNC) > >>>> val |= SUN4I_TCON0_IO_POL_VSYNC_POSITIVE; > >>>> > >>>> regmap_update_bits(tcon->regs, SUN4I_TCON0_IO_POL_REG, > >>> > >>> I am running Linux 4.19.6 and noticed with Olimex LCD-OLinuXino-7TS 7" > >>> LCD touchscreen (Innolux AT070TN92) connected to Olimex > >>> A20-OLinuXino-MICRO that the image does not display correctly after > >>> this change. > >>> The image is shifted to the right. > >>> > >>> Reverting the change results in the image being displayed correctly on > >>> the screen. > >>> > >>> I have in the device tree a "panel" node with compatible = > >>> "innolux,at070tn92" which uses the timings in > >>> drivers/gpu/drm/panel/panel-simple.c. > >>> > >>> Any ideas? > > > >> > >> Checking Display Datasheet: > >> https://www.olimex.com/Products/Retired/A13-LCD7-TS/resources/S700-AT070TN92.pdf > >> > >> Page 13 section 3.3.2 you can see it needs active low VS and HS. > >> > >> You can refer to this Thread and check scope captures about VS and HS > >> versus TCON0_IOPOL register: > >> https://lists.freedesktop.org/archives/dri-devel/2018-January/163874.html > >> > >> There should be something that wrongly sets one of these or both: > >> mode->flags |= DRM_MODE_FLAG_PHSYNC; > >> and/or > >> mode->flags |= DRM_MODE_FLAG_PVSYNC; > >> > >> Checked in panel-simple.c but it's not there. > > > > flags is 0 because it is not assigned in the struct definition for the panel. > > I don't think it is 0, because otherwise IO_POL_REG wouldn't be set to > 0x03000000 but to 0. > What is checked is exactly mode->flags, so the problem seems to be upstream. > > This is my doubt, it seems mode->flags is not initialized or overriden > at a certain point, this is why I want to debug it with Jtag tomorrow. > If you look at the change made by your patch: --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -389,10 +389,10 @@ static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon, SUN4I_TCON0_BASIC3_H_SYNC(hsync)); /* Setup the polarity of the various signals */ - if (!(mode->flags & DRM_MODE_FLAG_PHSYNC)) + if (mode->flags & DRM_MODE_FLAG_PHSYNC) val |= SUN4I_TCON0_IO_POL_HSYNC_POSITIVE; - if (!(mode->flags & DRM_MODE_FLAG_PVSYNC)) + if (mode->flags & DRM_MODE_FLAG_PVSYNC) val |= SUN4I_TCON0_IO_POL_VSYNC_POSITIVE; regmap_update_bits(tcon->regs, SUN4I_TCON0_IO_POL_REG, If mode->flags is 0, then before your change it would set SUN4I_TCON0_IO_POL_HSYNC_POSITIVE and SUN4I_TCON0_IO_POL_VSYNC_POSITIVE bits to 1 (resulting in 0x03000000). If mode->flags is not 0, then after your change it would not set SUN4I_TCON0_IO_POL_HSYNC_POSITIVE and SUN4I_TCON0_IO_POL_VSYNC_POSITIVE bits to 1 (resulting in 0x00000000). > > Before this change, TCON0_IO_POL_REG would be 0x03000000 (both bits > > set to 1) and image displays correctly > After this change, TCON0_IO_POL_REG is 0x00000000 (both bits set to 0) > > and image doesn't display correctly. > > > > Checked using "devmem2 0x01c0c088" on A20-OLinuXino-MICRO Rev J. > > 0x03000000 as I've triple checked with scope means Positive H/Vsync, > and 0x00000000 Negative H/VSync. > > Please check on the Thread I've pointed you above where there are all > the links to the scope captures. > > Are you completely sure you're using the correct panel? Yes, I am sure I am using the correct panel. It has the following marking on sticker: AT070TN92V.X 89A070ZZ-0K1 > This is because if with 0x03000000 it works correctly, it means that > you're using Positive VS and HS but on datasheet on Figure 3.2 it shows > that they must be negative. > > Do you have any chance to measure those signals with a scope? No. > > Tomorrow, while debugging, I'll re-check H/Vsync signals again. > Thanks. Regards, Jonathan