From patchwork Tue Jul 10 07:03:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10516247 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 CF2F36020F for ; Tue, 10 Jul 2018 07:03:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCB9128C51 for ; Tue, 10 Jul 2018 07:03:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B077028C56; Tue, 10 Jul 2018 07:03:57 +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, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 7C89328C51 for ; Tue, 10 Jul 2018 07:03:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C85806E78A; Tue, 10 Jul 2018 07:03:55 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5FB336E78A for ; Tue, 10 Jul 2018 07:03:54 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id z6-v6so12741748wma.0 for ; Tue, 10 Jul 2018 00:03:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=IZDmYH0GC2iQVlU5vZCIH5/LOyP745cwCQkc5OW1p7M=; b=MdoT9/1q8UBMl3iWZ9L6jEKR9+vuJv1yKJadYqL5ZO7HZSlNYvmxrjSXjvfa8AnDZ7 972XXuXJ2VMQ4CA7bYzPPcwgIEtijrnrie+uqX1HDAOGF/cP8gSLMYenS3QyXmE5D3MW a7HZX8wVgZ4jpZITH60ZWSXOhsdK5UPp6nkdPW+PGk1FueAD1ZyphbcURILiG7ryWzC2 AOs7SHWOjgrBhbCb/Sl3FSM6Q/fa5OOG8kIef2bM8SzhQ9okVK1Dgu/9xDUevELemC2T GxUSK3p9gn7/Ehzqx8mMw9FXWlKDWrq8lSTyEXHtSiJyeywitMmwYZnH/dWoHb7ALOxb emsA== X-Gm-Message-State: AOUpUlEJxTfTCRJJi2LMM6RtclP8NhoX3LTo6n777eZj5IHgj4DA7Oop if4aYR6pr1pjrns7is0qOQ0Pzw== X-Google-Smtp-Source: AAOMgpf04LzfEqMry2E9RKNDI8HRtX6jGX9KXSWHMbKZtSkb16risWcFb2hSXYPm97F1rqK5Kwh8GA== X-Received: by 2002:a1c:5e48:: with SMTP id s69-v6mr2763491wmb.19.1531206233022; Tue, 10 Jul 2018 00:03:53 -0700 (PDT) Received: from localhost.localdomain (static-83-135-130-217.ipcom.comunitel.net. [217.130.135.83]) by smtp.gmail.com with ESMTPSA id h8-v6sm12793917wmb.32.2018.07.10.00.03.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jul 2018 00:03:52 -0700 (PDT) To: =?UTF-8?B?VmlsbGUgU3lyasOkbMOk?= References: <20180619201827.4257-1-hdegoede@redhat.com> <20180619201827.4257-5-hdegoede@redhat.com> <20180706141652.GK5565@intel.com> <20180709181425.GT5565@intel.com> From: Hans de Goede Message-ID: Date: Tue, 10 Jul 2018 09:03:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180709181425.GT5565@intel.com> Content-Language: en-US Subject: Re: [Intel-gfx] [PATCH 4/4] drm/i915/intel_dsi: Read back pclk set by GOP and use that as pclk X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans de Goede , intel-gfx , dri-devel@lists.freedesktop.org, Rodrigo Vivi Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Hi, On 07/09/2018 08:14 PM, Ville Syrjälä wrote: > On Sat, Jul 07, 2018 at 08:32:16AM +0200, Hans de Goede wrote: >>> Any kind of hack that involves reading out the hardware state should go >>> into something like intel_sanitize_encoder(). Actually by that time we >>> have already read out the hw state, so it shouldn't require any >>> modifications to the existing dsi code itself. >> >> I do not think that intel_sanitize encoder is the right place to do this: >> >> * I don't want to modify the read-back state, I want to modify our >> calculated "new/ideal" state to match the read-back state > > I wasn't suggesting that. What I meant is that you already have the > state there to look so you don't have to hack the readout functions > to function without a state being around. > > That said, we do already have intel_encoder_current_mode() which is doing > something similar to what you're proposing. So probably should just > try to reuse that. Ah yes that should work and will allow me to drop 2 of the 3 preparation patches (I still need the patch which initializes the encoder enough that it can be passed to get_hw_state() from intel_dsi_init_vbt(). So something like this ? : From 82db375919be9b95e680dc5b1f660d5ef1efcc94 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 10 Jul 2018 08:59:27 +0200 Subject: [PATCH] drm/i915/intel_dsi: Read back pclk set by GOP and use that as pclk On BYT and CHT the GOP sometimes initializes the pclk at a (slightly) different frequency then the pclk which we've calculated. This commit makes the DSI code read-back the pclk set by the GOP and if that is within a reasonable margin of the calculated pclk, uses that instead. This fixes the first modeset being a full modeset instead of a fast modeset on systems where the GOP pclk is different. Changes in v2: -Use intel_encoder_current_mode() to get the pclk setup by the GOP Signed-off-by: Hans de Goede --- drivers/gpu/drm/i915/intel_dsi_vbt.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) Note this is untested as I'm travelling at the moment. I will test this when I'm back home and send out a v2. Regards, Hans diff --git a/drivers/gpu/drm/i915/intel_dsi_vbt.c b/drivers/gpu/drm/i915/intel_dsi_vbt.c index 4d6ffa7b3e7b..828d5ac0dfef 100644 --- a/drivers/gpu/drm/i915/intel_dsi_vbt.c +++ b/drivers/gpu/drm/i915/intel_dsi_vbt.c @@ -506,6 +506,7 @@ bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 panel_id) struct mipi_config *mipi_config = dev_priv->vbt.dsi.config; struct mipi_pps_data *pps = dev_priv->vbt.dsi.pps; struct drm_display_mode *mode = dev_priv->vbt.lfp_lvds_vbt_mode; + struct drm_display_mode *curr; u32 bpp; u32 tlpx_ns, extra_byte_count, bitrate, tlpx_ui; u32 ui_num, ui_den; @@ -583,6 +584,23 @@ bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 panel_id) } else burst_mode_ratio = 100; + /* + * On BYT / CRC the GOP sometimes picks a slightly different pclk, + * read back the GOP configured pclk and prefer it over ours. + */ + if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { + curr = intel_encoder_current_mode(&intel_dsi->base); + if (curr) { + DRM_DEBUG_KMS("Calculated pclk %d GOP %d\n", + pclk, curr->clock); + if (curr->clock >= (pclk * 9 / 10) && + curr->clock <= (pclk * 11 / 10)) + pclk = curr->clock; + + kfree(curr); + } + } + intel_dsi->burst_mode_ratio = burst_mode_ratio; intel_dsi->pclk = pclk;