From: Algea Cao <algea.cao@rock-chips.com>
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 [thread overview]
Message-ID: <20200812083459.989-1-algea.cao@rock-chips.com> (raw)
In-Reply-To: <20200812083120.743-1-algea.cao@rock-chips.com>
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 <algea.cao@rock-chips.com>
---
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
next prev parent reply other threads:[~2020-08-12 8:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-12 8:31 [PATCH 0/6] Support change dw-hdmi output color Algea Cao
2020-08-12 8:34 ` [PATCH 1/6] drm: Add connector atomic_begin/atomic_flush Algea Cao
2020-08-12 9:26 ` Laurent Pinchart
2020-08-12 8:34 ` [PATCH 2/6] drm: bridge: dw-hdmi: Implement " Algea Cao
2020-08-12 9:22 ` Laurent Pinchart
2020-08-12 8:34 ` Algea Cao [this message]
2020-08-24 9:53 ` [PATCH 3/6] drm: bridge: dw-hdmi: Introduce previous_pixelclock/previous_tmdsclock Neil Armstrong
2020-08-12 8:35 ` [PATCH 4/6] drm/rockchip: dw_hdmi: Add vendor hdmi properties Algea Cao
2020-08-12 9:33 ` Laurent Pinchart
[not found] ` <52cca26d-b2b3-22b2-f371-a8086f2e6336@rock-chips.com>
2020-08-12 13:30 ` Laurent Pinchart
2020-08-13 7:42 ` Pekka Paalanen
2020-08-13 10:45 ` Laurent Pinchart
2020-08-14 8:23 ` Pekka Paalanen
2020-08-12 8:36 ` [PATCH 5/6] drm/rockchip: dw_hdmi: Add get_output_bus_format Algea Cao
2020-08-12 8:36 ` [PATCH 6/6] drm: bridge: dw-hdmi: Get output bus format when dw-hdmi is the only bridge Algea Cao
2020-08-24 9:50 ` Neil Armstrong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200812083459.989-1-algea.cao@rock-chips.com \
--to=algea.cao@rock-chips.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=a.hajda@samsung.com \
--cc=airlied@linux.ie \
--cc=cychiang@chromium.org \
--cc=daniel@ffwll.ch \
--cc=darekm@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=heiko@sntech.de \
--cc=hjc@rock-chips.com \
--cc=jbrunet@baylibre.com \
--cc=jernej.skrabec@siol.net \
--cc=jonas@kwiboo.se \
--cc=kuankuan.y@gmail.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=narmstrong@baylibre.com \
--cc=sam@ravnborg.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).