Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp284008pxa; Wed, 12 Aug 2020 01:43:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwi5lJIFhX0VvhchToSHgblx9AwghEEjLM3Zl+MtAVUUmWhCTkNGV/LEDVPgi2CYt1OOIzz X-Received: by 2002:a05:6402:c0a:: with SMTP id co10mr30972387edb.342.1597221788872; Wed, 12 Aug 2020 01:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597221788; cv=none; d=google.com; s=arc-20160816; b=J5hUnK2/XbfmYHzrCvLDlI7qUtXHzjqtu/NwntpS41/3l0k4zs+LjhbYz9M8qPcoc4 RG1cSlKN35VHhc2zugc4AjMSBN0jzWJEbxMZU9Qo1F/O42uLKzpOLmLXNZ3WibRIft5L Ke6787Vt5g0jP8+Zie5aZJxv6QqwHj38b04ZszjDJNeOccBrMalXd1d/TChZTEpVJCu4 g2smN1KePJWrorWXUGl5jd5iFbq5nYP2ql3B58mDr1+WKY3JOJWeNbL1PmPu1EEyFIza AHW21O2mkIVLl/qWpxru2AJmtYcB6nsOFwjvqwk9251HBGtuf3ABuBk3BwMmD5mYNFzf PhXw== 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:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=0zC4uQelaA5F8yBe9dkM3HHJWc2mHoLKzO4NOu3HriI=; b=DVRFNC3tEYfyY/ageW+rN0AngOcsIjvvHYBTE8D91ESAk2yLo6ADhx+sol5GMNnb4Y 7bjPnRLcJ36cWYIhONeUBNpQlHwwi6472P9Ev994rLBTM9pChjy2L8CTGpQVkYhWonpw jrTtLvktrdPKSlu7vXt7cv8D0Fbs4m/BbxRZeH4wAmFqd3kzWD21bwxZ1ULXDv2KmyHG 6ah3CQ8nK/J7xzDwlpoWxWa7wQIiHK+4S3/Yt0rBxmk0xd7OEokO/7H6mqLv/SJK6/00 +ciRaZxV+oB/P8JbsDFUAQjl7GHZhwhrSqv15f/VVgm4GnjKOYD5DmLSxX9zhFSWLRGu 6wVA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cq22si810790edb.609.2020.08.12.01.42.46; Wed, 12 Aug 2020 01:43:08 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726695AbgHLImF (ORCPT + 99 others); Wed, 12 Aug 2020 04:42:05 -0400 Received: from lucky1.263xmail.com ([211.157.147.133]:49916 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726565AbgHLImF (ORCPT ); Wed, 12 Aug 2020 04:42:05 -0400 Received: from localhost (unknown [192.168.167.235]) by lucky1.263xmail.com (Postfix) with ESMTP id 4CFACC5B3D; Wed, 12 Aug 2020 16:35:07 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED: 0 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [103.29.142.67]) by smtp.263.net (postfix) whith ESMTP id P12148T140383044482816S1597221301879174_; Wed, 12 Aug 2020 16:35:06 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <9b940f70c8aae58a528400653cfcd4ec> X-RL-SENDER: algea.cao@rock-chips.com X-SENDER: algea.cao@rock-chips.com X-LOGIN-NAME: algea.cao@rock-chips.com X-FST-TO: a.hajda@samsung.com X-SENDER-IP: 103.29.142.67 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: Algea Cao To: a.hajda@samsung.com, kuankuan.y@gmail.com, hjc@rock-chips.com, tzimmermann@suse.de, dri-devel@lists.freedesktop.org, sam@ravnborg.org, airlied@linux.ie, heiko@sntech.de, jernej.skrabec@siol.net, algea.cao@rock-chips.com, Laurent.pinchart@ideasonboard.com, laurent.pinchart+renesas@ideasonboard.com, jonas@kwiboo.se, mripard@kernel.org, darekm@google.com, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, cychiang@chromium.org, linux-kernel@vger.kernel.org, narmstrong@baylibre.com, jbrunet@baylibre.com, maarten.lankhorst@linux.intel.com, daniel@ffwll.ch Subject: [PATCH 3/6] drm: bridge: dw-hdmi: Introduce previous_pixelclock/previous_tmdsclock Date: Wed, 12 Aug 2020 16:34:59 +0800 Message-Id: <20200812083459.989-1-algea.cao@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200812083120.743-1-algea.cao@rock-chips.com> References: <20200812083120.743-1-algea.cao@rock-chips.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce previous_pixelclock/previous_tmdsclock to determine whether PHY needs initialization. If phy is power off, or mpixelclock/mtmdsclock is different to previous value, phy is neet to be reinitialized. Signed-off-by: Algea Cao --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 50 +++++++++++++++++++---- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index a1a81fc768c2..1eb4736b9b59 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -101,6 +101,8 @@ static const u16 csc_coeff_rgb_full_to_rgb_limited[3][4] = { struct hdmi_vmode { bool mdataenablepolarity; + unsigned int previous_pixelclock; + unsigned int previous_tmdsclock; unsigned int mpixelclock; unsigned int mpixelrepetitioninput; unsigned int mpixelrepetitionoutput; @@ -890,6 +892,32 @@ static int hdmi_bus_fmt_color_depth(unsigned int bus_format) } } +static unsigned int +hdmi_get_tmdsclock(struct dw_hdmi *hdmi, unsigned long mpixelclock) +{ + unsigned int tmdsclock = mpixelclock; + unsigned int depth = + hdmi_bus_fmt_color_depth(hdmi->hdmi_data.enc_out_bus_format); + + if (!hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_out_bus_format)) { + switch (depth) { + case 16: + tmdsclock = mpixelclock * 2; + break; + case 12: + tmdsclock = mpixelclock * 3 / 2; + break; + case 10: + tmdsclock = mpixelclock * 5 / 4; + break; + default: + break; + } + } + + return tmdsclock; +} + /* * this submodule is responsible for the video data synchronization. * for example, for RGB 4:4:4 input, the data map is defined as @@ -1861,11 +1889,13 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi, int hblank, vblank, h_de_hs, v_de_vs, hsync_len, vsync_len; unsigned int vdisplay, hdisplay; + vmode->previous_pixelclock = vmode->mpixelclock; vmode->mpixelclock = mode->clock * 1000; dev_dbg(hdmi->dev, "final pixclk = %d\n", vmode->mpixelclock); - vmode->mtmdsclock = vmode->mpixelclock; + vmode->previous_tmdsclock = vmode->mtmdsclock; + vmode->mtmdsclock = hdmi_get_tmdsclock(hdmi, vmode->mpixelclock); if (!hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_out_bus_format)) { switch (hdmi_bus_fmt_color_depth( @@ -2172,12 +2202,18 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, hdmi_av_composer(hdmi, &connector->display_info, mode); /* HDMI Initializateion Step B.2 */ - ret = hdmi->phy.ops->init(hdmi, hdmi->phy.data, - &connector->display_info, - &hdmi->previous_mode); - if (ret) - return ret; - hdmi->phy.enabled = true; + if (!hdmi->phy.enabled || + hdmi->hdmi_data.video_mode.previous_pixelclock != + hdmi->hdmi_data.video_mode.mpixelclock || + hdmi->hdmi_data.video_mode.previous_tmdsclock != + hdmi->hdmi_data.video_mode.mtmdsclock) { + ret = hdmi->phy.ops->init(hdmi, hdmi->phy.data, + &connector->display_info, + &hdmi->previous_mode); + if (ret) + return ret; + hdmi->phy.enabled = true; + } /* HDMI Initialization Step B.3 */ dw_hdmi_enable_video_path(hdmi); -- 2.25.1