linux-rockchip.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Jonas Karlman <jonas@kwiboo.se>
To: Heiko Stuebner <heiko@sntech.de>, Sandy Huang <hjc@rock-chips.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Jonas Karlman <jonas@kwiboo.se>, David Airlie <airlied@linux.ie>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	"linux-rockchip@lists.infradead.org"
	<linux-rockchip@lists.infradead.org>,
	Rob Herring <robh+dt@kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	Zheng Yang <zhengyang@rock-chips.com>
Subject: [PATCH 08/15] drm/rockchip: dw-hdmi: require valid vpll clock rate on rk3228/rk3328
Date: Mon, 6 Jan 2020 20:48:28 +0000	[thread overview]
Message-ID: <HE1PR06MB40113EA5E91DEEE586D39815AC3C0@HE1PR06MB4011.eurprd06.prod.outlook.com> (raw)
In-Reply-To: <20200106204812.5944-1-jonas@kwiboo.se>

RK3228/RK3328 can only support clock rates defined in the pre pll table.
Lets validate the mode clock rate against the pre pll config and filter
out any mode with a clock rate returning error from clk_round_rate().

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
index fae38b323a0c..45fcdce3f27f 100644
--- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
@@ -245,6 +245,22 @@ static void dw_hdmi_rockchip_encoder_disable(struct drm_encoder *encoder)
 {
 }
 
+static enum drm_mode_status
+dw_hdmi_rockchip_encoder_mode_valid(struct drm_encoder *encoder,
+				    const struct drm_display_mode *mode)
+{
+	struct rockchip_hdmi *hdmi = to_rockchip_hdmi(encoder);
+	long rate;
+
+	if (hdmi->vpll_clk) {
+		rate = clk_round_rate(hdmi->vpll_clk, mode->clock * 1000);
+		if (rate < 0)
+			return MODE_CLOCK_RANGE;
+	}
+
+	return MODE_OK;
+}
+
 static bool
 dw_hdmi_rockchip_encoder_mode_fixup(struct drm_encoder *encoder,
 				    const struct drm_display_mode *mode,
@@ -306,6 +322,7 @@ dw_hdmi_rockchip_encoder_atomic_check(struct drm_encoder *encoder,
 }
 
 static const struct drm_encoder_helper_funcs dw_hdmi_rockchip_encoder_helper_funcs = {
+	.mode_valid = dw_hdmi_rockchip_encoder_mode_valid,
 	.mode_fixup = dw_hdmi_rockchip_encoder_mode_fixup,
 	.mode_set   = dw_hdmi_rockchip_encoder_mode_set,
 	.enable     = dw_hdmi_rockchip_encoder_enable,
-- 
2.17.1

  parent reply	other threads:[~2020-01-06 20:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-06 20:46 [PATCH 00/15] Support more HDMI modes on RK3228/RK3328 Jonas Karlman
2020-01-06 20:47 ` [PATCH 01/15] phy/rockchip: inno-hdmi: use correct vco_div_5 macro on rk3328 Jonas Karlman
     [not found] ` <20200106204723.5889-1-jonas@kwiboo.se>
2020-01-06 20:47   ` [PATCH 02/15] phy/rockchip: inno-hdmi: round fractal pixclock in rk3328 recalc_rate Jonas Karlman
2020-01-06 20:47   ` [PATCH 03/15] phy/rockchip: inno-hdmi: remove unused no_c from " Jonas Karlman
2020-01-06 20:47   ` [PATCH 04/15] phy/rockchip: inno-hdmi: do not power on rk3328 post pll on reg write Jonas Karlman
2020-01-06 20:48 ` [PATCH 05/15] phy/rockchip: inno-hdmi: force set_rate on power_on Jonas Karlman
     [not found] ` <20200106204812.5944-1-jonas@kwiboo.se>
2020-01-06 20:48   ` [PATCH 06/15] drm/rockchip: vop: limit resolution width to 3840 Jonas Karlman
2020-01-06 21:18     ` Heiko Stübner
2020-01-06 21:34       ` Jonas Karlman
2020-01-06 20:48   ` [PATCH 07/15] drm/rockchip: dw-hdmi: allow high tmds bit rates Jonas Karlman
2020-01-06 20:48   ` Jonas Karlman [this message]
2020-01-06 20:49 ` [PATCH 09/15] clk: rockchip: set parent rate for DCLK_VOP clock on rk3228 Jonas Karlman
     [not found] ` <20200106204914.6001-1-jonas@kwiboo.se>
2020-01-06 20:49   ` [PATCH 10/15] arm64: dts: rockchip: increase vop clock rate on rk3328 Jonas Karlman
2020-01-06 20:49   ` [PATCH 11/15] arm64: dts: rockchip: add vpll clock to hdmi node " Jonas Karlman
2020-01-06 20:49   ` [PATCH 12/15] ARM: dts: rockchip: add vpll clock to hdmi node on rk3228 Jonas Karlman
2020-01-06 20:50 ` [PATCH 13/15] drm/rockchip: dw-hdmi: limit tmds to 340mhz on rk3228/rk3328 Jonas Karlman
     [not found] ` <20200106204951.6060-1-jonas@kwiboo.se>
2020-01-06 20:50   ` [PATCH 14/15] drm/rockchip: dw-hdmi: remove unused plat_data " Jonas Karlman
2020-01-06 20:50   ` [PATCH 15/15] phy/rockchip: inno-hdmi: Support more pre-pll configuration Jonas Karlman
2020-01-06 21:33     ` Heiko Stübner

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=HE1PR06MB40113EA5E91DEEE586D39815AC3C0@HE1PR06MB4011.eurprd06.prod.outlook.com \
    --to=jonas@kwiboo.se \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=heiko@sntech.de \
    --cc=hjc@rock-chips.com \
    --cc=kishon@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=zhengyang@rock-chips.com \
    /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).