Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp781469imu; Thu, 13 Dec 2018 04:29:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/VLWSI/M7wO0tCJwpB5eLq4MDc4KPcwhQP/6991MZaWwe0lqgx3G49XCVoXPs0uqLasm2b9 X-Received: by 2002:a17:902:7687:: with SMTP id m7mr10516476pll.187.1544704181610; Thu, 13 Dec 2018 04:29:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544704181; cv=none; d=google.com; s=arc-20160816; b=nuw3kgws974Y86VAX5TOr79m/yA48pn8kgpty6uygBY7wlXhLntWDiqZ9GpUCUB18i 7DyPo9zLrsqntvYvIlIcaVxnRjAKiRFNM7T/hFxqwG3cuiJlGoDOu2iVHzbwfeqZnsiI I34bz9iYYXpQ8Yq/lY7Gu8fynasVlCRUvHln/VF1HlNmAUW2xqvYZunxwXb6kiL9UEgs fP8AHGcFog8xIZu6ny7GfePsBIn9R6t7dyKSp7L5zXfP55orO0EjAkcq5Ira0da6SaGb 4VBkEBGNzFzIfp9sN0Lo4Fo4UVRP4tWyhhDbctb3S/PkBCUj93sTNKvNKbBHfCgodcst qjNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=ndleblPc/wY1vR4Zn8vauIUrTfySizldfFJ3w6JYkiA=; b=jIRh9Vq7G2ESnIPF/8dbHpTN6Ty5wesCJOY7f4c9LoqMeg+IDrWFY8Bjj7I604618D edVzdXpDwT4hJ6OtH1PFQ2hH+O25Ox8UgF3LQLBHgp+/C5BUiR6rV3VQdm3iQjhO4V4U Ik69FswbpZkzv8biU1Ko+s+jaPd+WQBKQPKCKuUza7rKi/CbGyRK4MGhgoSRM5isPmEm DReWBJzedn7njdG7Hnnf2PlSY5pqLMFppiE3n5F2v2TQ/nVkYqlF211bM6iR7cCgq+Zt x5s6QHbk4PGZkeM6Cz7cfQOHMW+fHsNbLWnoF1qAPzymkrXz8vdI1SEWWhtwhEG/fraY 7BQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=RQzViI0U; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si1442715pgl.350.2018.12.13.04.29.25; Thu, 13 Dec 2018 04:29:41 -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=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=RQzViI0U; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728842AbeLML65 (ORCPT + 99 others); Thu, 13 Dec 2018 06:58:57 -0500 Received: from mail.micronovasrl.com ([212.103.203.10]:60614 "EHLO mail.micronovasrl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728770AbeLML64 (ORCPT ); Thu, 13 Dec 2018 06:58:56 -0500 Received: from mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) by mail.micronovasrl.com (Postfix) with ESMTP id E41BEB01968 for ; Thu, 13 Dec 2018 12:58:54 +0100 (CET) Authentication-Results: mail.micronovasrl.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=micronovasrl.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=micronovasrl.com; h=content-transfer-encoding:content-language:content-type :content-type:in-reply-to:mime-version:user-agent:date:date :message-id:from:from:references:to:subject:subject; s=dkim; t= 1544702333; x=1545566334; bh=Bx8meC0FWDSHNC6fJ6mJV61gPaVubU8oonO /vQEzoys=; b=RQzViI0Ufi8nAnkjiy8slEtjCIekZ4JaR8rZYtYL0rvXBNgNqZf MLC7Bx8S5XGwsGxHVNp8GbZfECyMcC26yRdh0eHo4agay80qFoW1BeZFinMztPhF B5IFYMl/5wfAnru7ZCeGSR0HO9pGInvgeW1EP2a2dnzoXFQvsUPWQoPw= X-Virus-Scanned: Debian amavisd-new at mail.micronovasrl.com X-Spam-Flag: NO X-Spam-Score: -2.89 X-Spam-Level: X-Spam-Status: No, score=-2.89 tagged_above=-10 required=4.5 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, T_MIXED_ES=0.01] autolearn=ham autolearn_force=no Received: from mail.micronovasrl.com ([127.0.0.1]) by mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id y5BPS7GCtLxM for ; Thu, 13 Dec 2018 12:58:53 +0100 (CET) Received: from [192.168.178.33] (host180-21-dynamic.5-87-r.retail.telecomitalia.it [87.5.21.180]) by mail.micronovasrl.com (Postfix) with ESMTPSA id 107B4B01928; Thu, 13 Dec 2018 12:58:52 +0100 (CET) Subject: Re: [PATCH] drm/sun4i: fix HSYNC and VSYNC polarity To: Jonathan Liu Cc: Maxime Ripard , Chen-Yu Tsai , linux-arm-kernel , dri-devel , linux-kernel 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> From: Giulio Benetti Message-ID: Date: Thu, 13 Dec 2018 12:58:58 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: it Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Il 13/12/2018 04:08, Jonathan Liu ha scritto: > 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. mode->flags is correct, just checked with debugger. >> > > 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, mode->flags is 0xa(DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) by default if not specified different in panel-simple.c so the signals must be active LOW(IO_POL_REG = 0x00000000). > 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). And it was wrong, because as I've pointed you above, especially in the Thread with all the scope captures, 0x03000000 means active HIGH H/Vsync, while 0x00000000 means active LOW H/Vsync. > 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). If mode->flags is 0x5(DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) i.e. specified in panel-simple.c the signals must be active HIGH(IO_POL_REG = 0x03000000). IO_POL_REG = 0x03000000 is active HIGH IO_POL_REG = 0x00000000 is active LOW as I've checked many times and rechecked today lot of times too. >>> 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 At this point the only way to make it working is to specify DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC in panel-simple.c and check. Can you do a check and tell me if this solves the problem? Also, it's not sufficient to submit a patch for that display in panel-simple.c (IMHO) because I would check with scope if it is the way wou're describing. I don't know how to describe it better than this and IMHO the scope can give us the final answer. Hope I've been helpful. Best regards -- Giulio Benetti CTO MICRONOVA SRL Sede: Via A. Niedda 3 - 35010 Vigonza (PD) Tel. 049/8931563 - Fax 049/8931346 Cod.Fiscale - P.IVA 02663420285 Capitale Sociale € 26.000 i.v. Iscritta al Reg. Imprese di Padova N. 02663420285 Numero R.E.A. 258642