From patchwork Thu Jul 27 12:47:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Gusakov X-Patchwork-Id: 9866735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D833F60382 for ; Thu, 27 Jul 2017 12:46:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAC3528817 for ; Thu, 27 Jul 2017 12:46:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFDFA2881A; Thu, 27 Jul 2017 12:46:35 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B917928821 for ; Thu, 27 Jul 2017 12:46:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D50866ECDB; Thu, 27 Jul 2017 12:46:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x22a.google.com (mail-lf0-x22a.google.com [IPv6:2a00:1450:4010:c07::22a]) by gabe.freedesktop.org (Postfix) with ESMTPS id A41B96ECD8 for ; Thu, 27 Jul 2017 12:46:16 +0000 (UTC) Received: by mail-lf0-x22a.google.com with SMTP id g25so75909371lfh.1 for ; Thu, 27 Jul 2017 05:46:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=358uz8n8jd7BR52Tri5vTGPMBpjoBZ3SXcnV9NrARow=; b=wR3iaNIGkKdVJgBm8xjgSX7XV/ZumtuWyS1DQJVnnCNkdNNbSuc5ja/HNkpGhtN305 fCOjDxiDOFV6eFTJSvFMnLTL23rU2C1dYaAotBfy7kycCVrS4Ijn8iNSBXqc0sPM3WEQ kaXQDua51Mwr/XOXkHwSO1UM1pwMhCt/GADN4n0SuddsJIrqru3WP9S2GIQcqQZDSnZc aubAFLQtQ6gNOcwu6327Ihugy+lFGWa31uqBdGZTnRyNCUJ1JrraG9nRSPRJ0/kRaL45 cohUB/SQ7NjQoe3ceyuwNoLwkUlc/25kd1d69r+TGOeTrwpulz50zgpXC+WoBGJ/GcVb UwOg== 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:in-reply-to :references; bh=358uz8n8jd7BR52Tri5vTGPMBpjoBZ3SXcnV9NrARow=; b=JMt5xCtDgo/TOnupPUuXsIqcp6EBGe+6ov6TnBQri8RX5VfCM8IU8eJ1gASJrdDYT2 v5ctz1D+SAOcSkzEOxOcHx87sp6NvTEqO7r2PlOfP57awst8gpHLz6sjgnXTX1rpaMqu trSA7qfBbZqM03AEQ4xjLHgtoghttb4nVzqQ3OBHpwT+DPkZRSezjLF8pqlqyyub3J2D oezwpB6FXDlWc6VnuoLU+LfBRNru7bs3zeeLI0RdQwvZIV7w5Gs80/u6OLE/S0242kBd bpZhuAX2NXMftv2IrAnB9J6s26CIn5456q/0YLt2i1j8RsOKvoE8qo7KBLR0PTxpafUs 852g== X-Gm-Message-State: AIVw112KROA5qIPwlE6atDRq+R3oG2nYxPOtsthVvmiIEveAacsB51CU f9+7uKu5DTFgMGlNoEgR/g== X-Received: by 10.46.84.93 with SMTP id y29mr1772665ljd.150.1501159574866; Thu, 27 Jul 2017 05:46:14 -0700 (PDT) Received: from localhost.localdomain (178-16-155-142.obit.ru. [178.16.155.142]) by smtp.gmail.com with ESMTPSA id y10sm3889518lja.49.2017.07.27.05.46.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Jul 2017 05:46:14 -0700 (PDT) From: Andrey Gusakov To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/6] drm/bridge: tc358767: fix timing calculations Date: Thu, 27 Jul 2017 15:47:34 +0300 Message-Id: <20170727124736.3854-5-andrey.gusakov@cogentembedded.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170727124736.3854-1-andrey.gusakov@cogentembedded.com> References: <20170727124736.3854-1-andrey.gusakov@cogentembedded.com> Cc: Andrey Gusakov , cphealy@gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Fields in HTIM01 and HTIM02 regs should be even. Recomended thresh_dly value is max_tu_symbol. Signed-off-by: Andrey Gusakov Acked-by: Philipp Zabel --- drivers/gpu/drm/bridge/tc358767.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 4aee6178d889..c657a00af508 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -659,6 +659,14 @@ static int tc_set_video_mode(struct tc_data *tc, struct drm_display_mode *mode) int lower_margin = mode->vsync_start - mode->vdisplay; int vsync_len = mode->vsync_end - mode->vsync_start; + /* + * Recommended maximum number of symbols transferred in a transfer unit: + * DIV_ROUND_UP((input active video bandwidth in bytes) * tu_size, + * (output active video bandwidth in bytes)) + * Must be less than tu_size. + */ + max_tu_symbol = TU_SIZE_RECOMMENDED - 1; + dev_dbg(tc->dev, "set mode %dx%d\n", mode->hdisplay, mode->vdisplay); dev_dbg(tc->dev, "H margin %d,%d sync %d\n", @@ -668,13 +676,18 @@ static int tc_set_video_mode(struct tc_data *tc, struct drm_display_mode *mode) dev_dbg(tc->dev, "total: %dx%d\n", mode->htotal, mode->vtotal); - /* LCD Ctl Frame Size */ - tc_write(VPCTRL0, (0x40 << 20) /* VSDELAY */ | + /* + * LCD Ctl Frame Size + * datasheet is not clear of vsdelay in case of DPI + * assume we do not need any delay when DPI is a source of + * sync signals + */ + tc_write(VPCTRL0, (0 << 20) /* VSDELAY */ | OPXLFMT_RGB888 | FRMSYNC_DISABLED | MSF_DISABLED); - tc_write(HTIM01, (left_margin << 16) | /* H back porch */ - (hsync_len << 0)); /* Hsync */ - tc_write(HTIM02, (right_margin << 16) | /* H front porch */ - (mode->hdisplay << 0)); /* width */ + tc_write(HTIM01, (ALIGN(left_margin, 2) << 16) | /* H back porch */ + (ALIGN(hsync_len, 2) << 0)); /* Hsync */ + tc_write(HTIM02, (ALIGN(right_margin, 2) << 16) | /* H front porch */ + (ALIGN(mode->hdisplay, 2) << 0)); /* width */ tc_write(VTIM01, (upper_margin << 16) | /* V back porch */ (vsync_len << 0)); /* Vsync */ tc_write(VTIM02, (lower_margin << 16) | /* V front porch */ @@ -693,7 +706,7 @@ static int tc_set_video_mode(struct tc_data *tc, struct drm_display_mode *mode) /* DP Main Stream Attributes */ vid_sync_dly = hsync_len + left_margin + mode->hdisplay; tc_write(DP0_VIDSYNCDELAY, - (0x003e << 16) | /* thresh_dly */ + (max_tu_symbol << 16) | /* thresh_dly */ (vid_sync_dly << 0)); tc_write(DP0_TOTALVAL, (mode->vtotal << 16) | (mode->htotal)); @@ -709,13 +722,6 @@ static int tc_set_video_mode(struct tc_data *tc, struct drm_display_mode *mode) tc_write(DPIPXLFMT, VS_POL_ACTIVE_LOW | HS_POL_ACTIVE_LOW | DE_POL_ACTIVE_HIGH | SUB_CFG_TYPE_CONFIG1 | DPI_BPP_RGB888); - /* - * Recommended maximum number of symbols transferred in a transfer unit: - * DIV_ROUND_UP((input active video bandwidth in bytes) * tu_size, - * (output active video bandwidth in bytes)) - * Must be less than tu_size. - */ - max_tu_symbol = TU_SIZE_RECOMMENDED - 1; tc_write(DP0_MISC, (max_tu_symbol << 23) | (TU_SIZE_RECOMMENDED << 16) | BPC_8);