* [PATCH v3 1/3] drm/rockchip: dw_hdmi: relax mode_valid hook
2023-01-18 13:22 [PATCH v3 0/3] drm/rockchip: dw_hdmi: Add 4k@30 support Sascha Hauer
@ 2023-01-18 13:22 ` Sascha Hauer
2023-01-18 13:22 ` [PATCH v3 2/3] drm/rockchip: dw_hdmi: Add support for 4k@30 resolution Sascha Hauer
` (5 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2023-01-18 13:22 UTC (permalink / raw)
To: dri-devel
Cc: Dan Johansen, Sascha Hauer, Sandy Huang, linux-rockchip,
Michael Riesch, kernel, Robin Murphy
The driver checks if the pixel clock of the given mode matches an entry
in the mpll config table. At least for the Synopsys phy the frequencies
in the mpll table are meant as a frequency range up to which the entry
works, not as a frequency that must match the pixel clock. Return
MODE_OK when the pixelclock is smaller than one of the mpll frequencies
to allow for more display resolutions.
Limit this behaviour to the Synopsys phy at the moment and keep the
current behaviour of forcing exact pixelclock rates for the other phys
until it has been sorted out how and if the vendor specific phys work
with non standard clock rates.
Tested-by: Michael Riesch <michael.riesch@wolfvision.net>
Link: https://lore.kernel.org/r/20220926080435.259617-2-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 26 +++++++++++++++------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
index 2f4b8f64cbad3..7d8bf292fedce 100644
--- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
@@ -74,6 +74,7 @@ struct rockchip_hdmi {
struct regmap *regmap;
struct rockchip_encoder encoder;
const struct rockchip_hdmi_chip_data *chip_data;
+ const struct dw_hdmi_plat_data *plat_data;
struct clk *ref_clk;
struct clk *grf_clk;
struct dw_hdmi *hdmi;
@@ -241,23 +242,32 @@ static int rockchip_hdmi_parse_dt(struct rockchip_hdmi *hdmi)
}
static enum drm_mode_status
-dw_hdmi_rockchip_mode_valid(struct dw_hdmi *hdmi, void *data,
+dw_hdmi_rockchip_mode_valid(struct dw_hdmi *dw_hdmi, void *data,
const struct drm_display_info *info,
const struct drm_display_mode *mode)
{
+ struct rockchip_hdmi *hdmi = data;
const struct dw_hdmi_mpll_config *mpll_cfg = rockchip_mpll_cfg;
int pclk = mode->clock * 1000;
- bool valid = false;
+ bool exact_match = hdmi->plat_data->phy_force_vendor;
int i;
for (i = 0; mpll_cfg[i].mpixelclock != (~0UL); i++) {
- if (pclk == mpll_cfg[i].mpixelclock) {
- valid = true;
- break;
- }
+ /*
+ * For vendor specific phys force an exact match of the pixelclock
+ * to preserve the original behaviour of the driver.
+ */
+ if (exact_match && pclk == mpll_cfg[i].mpixelclock)
+ return MODE_OK;
+ /*
+ * The Synopsys phy can work with pixelclocks up to the value given
+ * in the corresponding mpll_cfg entry.
+ */
+ if (!exact_match && pclk <= mpll_cfg[i].mpixelclock)
+ return MODE_OK;
}
- return (valid) ? MODE_OK : MODE_BAD;
+ return MODE_BAD;
}
static void dw_hdmi_rockchip_encoder_disable(struct drm_encoder *encoder)
@@ -546,8 +556,10 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,
return -ENOMEM;
hdmi->dev = &pdev->dev;
+ hdmi->plat_data = plat_data;
hdmi->chip_data = plat_data->phy_data;
plat_data->phy_data = hdmi;
+ plat_data->priv_data = hdmi;
encoder = &hdmi->encoder.encoder;
encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node);
--
2.30.2
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v3 2/3] drm/rockchip: dw_hdmi: Add support for 4k@30 resolution
2023-01-18 13:22 [PATCH v3 0/3] drm/rockchip: dw_hdmi: Add 4k@30 support Sascha Hauer
2023-01-18 13:22 ` [PATCH v3 1/3] drm/rockchip: dw_hdmi: relax mode_valid hook Sascha Hauer
@ 2023-01-18 13:22 ` Sascha Hauer
2023-01-18 13:22 ` [PATCH v3 3/3] drm/rockchip: dw_hdmi: discard modes with unachievable pixelclocks Sascha Hauer
` (4 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2023-01-18 13:22 UTC (permalink / raw)
To: dri-devel
Cc: Dan Johansen, Sascha Hauer, Sandy Huang, linux-rockchip,
Michael Riesch, kernel, Robin Murphy
This adds the PLL/phy settings to support higher resolutions like 4k@30.
The values were taken from the Rockchip downstream Kernel.
Tested-by: Michael Riesch <michael.riesch@wolfvision.net>
Link: https://lore.kernel.org/r/20220926080435.259617-3-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Notes:
Changes since v2:
- Use correct mpll_cfg values, previously the 420 values were used
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
index 7d8bf292fedce..feba6b9becd6c 100644
--- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
@@ -161,6 +161,12 @@ static const struct dw_hdmi_mpll_config rockchip_mpll_cfg[] = {
{ 0x214c, 0x0003},
{ 0x4064, 0x0003}
},
+ }, {
+ 340000000, {
+ { 0x0040, 0x0003 },
+ { 0x3b4c, 0x0003 },
+ { 0x5a64, 0x0003 },
+ },
}, {
~0UL, {
{ 0x00a0, 0x000a },
@@ -186,6 +192,8 @@ static const struct dw_hdmi_curr_ctrl rockchip_cur_ctr[] = {
146250000, { 0x0038, 0x0038, 0x0038 },
}, {
148500000, { 0x0000, 0x0038, 0x0038 },
+ }, {
+ 600000000, { 0x0000, 0x0000, 0x0000 },
}, {
~0UL, { 0x0000, 0x0000, 0x0000},
}
--
2.30.2
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v3 3/3] drm/rockchip: dw_hdmi: discard modes with unachievable pixelclocks
2023-01-18 13:22 [PATCH v3 0/3] drm/rockchip: dw_hdmi: Add 4k@30 support Sascha Hauer
2023-01-18 13:22 ` [PATCH v3 1/3] drm/rockchip: dw_hdmi: relax mode_valid hook Sascha Hauer
2023-01-18 13:22 ` [PATCH v3 2/3] drm/rockchip: dw_hdmi: Add support for 4k@30 resolution Sascha Hauer
@ 2023-01-18 13:22 ` Sascha Hauer
2023-01-18 14:10 ` [PATCH v3 0/3] drm/rockchip: dw_hdmi: Add 4k@30 support Dan Johansen
` (3 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2023-01-18 13:22 UTC (permalink / raw)
To: dri-devel
Cc: Dan Johansen, Sascha Hauer, Sandy Huang, linux-rockchip,
Michael Riesch, kernel, Robin Murphy
The Rockchip PLL drivers are currently table based and support only
the most common pixelclocks. Discard all modes we cannot achieve
at all. Normally the desired pixelclocks have an exact match in the
PLL driver, nevertheless allow for a 0.1% error just in case.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Notes:
Changes since v2:
- new patch
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
index feba6b9becd6c..725952811752b 100644
--- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
@@ -256,10 +256,14 @@ dw_hdmi_rockchip_mode_valid(struct dw_hdmi *dw_hdmi, void *data,
{
struct rockchip_hdmi *hdmi = data;
const struct dw_hdmi_mpll_config *mpll_cfg = rockchip_mpll_cfg;
- int pclk = mode->clock * 1000;
+ int rpclk, pclk = mode->clock * 1000;
bool exact_match = hdmi->plat_data->phy_force_vendor;
int i;
+ rpclk = clk_round_rate(hdmi->ref_clk, pclk);
+ if (abs(rpclk - pclk) > pclk / 1000)
+ return MODE_NOCLOCK;
+
for (i = 0; mpll_cfg[i].mpixelclock != (~0UL); i++) {
/*
* For vendor specific phys force an exact match of the pixelclock
--
2.30.2
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v3 0/3] drm/rockchip: dw_hdmi: Add 4k@30 support
2023-01-18 13:22 [PATCH v3 0/3] drm/rockchip: dw_hdmi: Add 4k@30 support Sascha Hauer
` (2 preceding siblings ...)
2023-01-18 13:22 ` [PATCH v3 3/3] drm/rockchip: dw_hdmi: discard modes with unachievable pixelclocks Sascha Hauer
@ 2023-01-18 14:10 ` Dan Johansen
2023-01-18 14:24 ` Michael Riesch
` (2 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Dan Johansen @ 2023-01-18 14:10 UTC (permalink / raw)
To: Sascha Hauer, dri-devel
Cc: linux-rockchip, Robin Murphy, Sandy Huang, kernel, Michael Riesch
Tested the whole series on my Rock 3A, with my 1440p monitor. Works wonders!
Thank you.
Tested-by: Dan Johansen <strit@manjaro.org>
Den 18.01.2023 kl. 14.22 skrev Sascha Hauer:
> It's been some time since I last sent this series. This version fixes
> a regression Dan Johansen reported. The reason turned out to be simple,
> I used the YUV420 register values instead of the RGB ones.
>
> I realized that we cannot achieve several modes offered by my monitor
> as these require pixelclocks that are slightly below the standard
> pixelclocks. As these are lower than the standard clock rates the PLL
> driver offers the clk driver falls back to a way lower frequency
> which results in something the monitor can't display, so this series
> now contains a patch to discard these unachievable modes.
>
> Sascha
>
> Changes since v2:
> - Use correct register values for mpll_cfg
> - Add patch to discard modes we cannot achieve
>
> Changes since v1:
> - Allow non standard clock rates only on Synopsys phy as suggested by
> Robin Murphy
>
> Sascha Hauer (3):
> drm/rockchip: dw_hdmi: relax mode_valid hook
> drm/rockchip: dw_hdmi: Add support for 4k@30 resolution
> drm/rockchip: dw_hdmi: discard modes with unachievable pixelclocks
>
> drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 40 ++++++++++++++++-----
> 1 file changed, 32 insertions(+), 8 deletions(-)
>
--
Kind regards
*Dan Johansen*
Project lead of the *Manjaro ARM* project
Manjaro-ARM <https://manjaro.org>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v3 0/3] drm/rockchip: dw_hdmi: Add 4k@30 support
2023-01-18 13:22 [PATCH v3 0/3] drm/rockchip: dw_hdmi: Add 4k@30 support Sascha Hauer
` (3 preceding siblings ...)
2023-01-18 14:10 ` [PATCH v3 0/3] drm/rockchip: dw_hdmi: Add 4k@30 support Dan Johansen
@ 2023-01-18 14:24 ` Michael Riesch
2023-01-18 18:42 ` Nicolas Frattaroli
2023-01-31 8:09 ` Sascha Hauer
6 siblings, 0 replies; 13+ messages in thread
From: Michael Riesch @ 2023-01-18 14:24 UTC (permalink / raw)
To: Sascha Hauer, dri-devel
Cc: linux-rockchip, Robin Murphy, Sandy Huang, kernel, Dan Johansen
Hi Sascha,
Thanks a lot for the v3, works great in my setup!
On 1/18/23 14:22, Sascha Hauer wrote:
> It's been some time since I last sent this series. This version fixes
> a regression Dan Johansen reported. The reason turned out to be simple,
> I used the YUV420 register values instead of the RGB ones.
>
> I realized that we cannot achieve several modes offered by my monitor
> as these require pixelclocks that are slightly below the standard
> pixelclocks. As these are lower than the standard clock rates the PLL
> driver offers the clk driver falls back to a way lower frequency
> which results in something the monitor can't display, so this series
> now contains a patch to discard these unachievable modes.
>
> Sascha
>
> Changes since v2:
> - Use correct register values for mpll_cfg
> - Add patch to discard modes we cannot achieve
>
> Changes since v1:
> - Allow non standard clock rates only on Synopsys phy as suggested by
> Robin Murphy
>
> Sascha Hauer (3):
> drm/rockchip: dw_hdmi: relax mode_valid hook
> drm/rockchip: dw_hdmi: Add support for 4k@30 resolution
> drm/rockchip: dw_hdmi: discard modes with unachievable pixelclocks
For the complete series
Tested-by: Michael Riesch <michael.riesch@wolfvision.net>
Best regards,
Michael
>
> drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 40 ++++++++++++++++-----
> 1 file changed, 32 insertions(+), 8 deletions(-)
>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v3 0/3] drm/rockchip: dw_hdmi: Add 4k@30 support
2023-01-18 13:22 [PATCH v3 0/3] drm/rockchip: dw_hdmi: Add 4k@30 support Sascha Hauer
` (4 preceding siblings ...)
2023-01-18 14:24 ` Michael Riesch
@ 2023-01-18 18:42 ` Nicolas Frattaroli
2023-01-31 8:09 ` Sascha Hauer
6 siblings, 0 replies; 13+ messages in thread
From: Nicolas Frattaroli @ 2023-01-18 18:42 UTC (permalink / raw)
To: dri-devel, linux-rockchip
Cc: Dan Johansen, Sascha Hauer, Sandy Huang, linux-rockchip,
Michael Riesch, kernel, Robin Murphy
On Wednesday, 18 January 2023 14:22:10 CET Sascha Hauer wrote:
> It's been some time since I last sent this series. This version fixes
> a regression Dan Johansen reported. The reason turned out to be simple,
> I used the YUV420 register values instead of the RGB ones.
>
> I realized that we cannot achieve several modes offered by my monitor
> as these require pixelclocks that are slightly below the standard
> pixelclocks. As these are lower than the standard clock rates the PLL
> driver offers the clk driver falls back to a way lower frequency
> which results in something the monitor can't display, so this series
> now contains a patch to discard these unachievable modes.
>
> Sascha
>
> Changes since v2:
> - Use correct register values for mpll_cfg
> - Add patch to discard modes we cannot achieve
>
> Changes since v1:
> - Allow non standard clock rates only on Synopsys phy as suggested by
> Robin Murphy
>
> Sascha Hauer (3):
> drm/rockchip: dw_hdmi: relax mode_valid hook
> drm/rockchip: dw_hdmi: Add support for 4k@30 resolution
> drm/rockchip: dw_hdmi: discard modes with unachievable pixelclocks
>
> drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 40 ++++++++++++++++-----
> 1 file changed, 32 insertions(+), 8 deletions(-)
For the whole series:
Tested-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
Tested on two monitors:
Monitor 1 was an Iiyama ProLite G2773HS, which only does 1080p60 over HDMI.
Testing on it, I found no regressions; all the old modes still showed up
and the 1080p60 mode worked as expected.
Monitor 2 was a Philips 328P, which does 4K30 over HDMI. Without the patches,
the 4K modes were absent. With the patchset, the 4K modes are present,
functional and picked by default.
Great work!
Cheers,
Nicolas Frattaroli
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v3 0/3] drm/rockchip: dw_hdmi: Add 4k@30 support
2023-01-18 13:22 [PATCH v3 0/3] drm/rockchip: dw_hdmi: Add 4k@30 support Sascha Hauer
` (5 preceding siblings ...)
2023-01-18 18:42 ` Nicolas Frattaroli
@ 2023-01-31 8:09 ` Sascha Hauer
[not found] ` <3C4B67628F8D73D6+63ea74ac-b8a2-45b1-5f92-8c7868906687@radxa.com>
6 siblings, 1 reply; 13+ messages in thread
From: Sascha Hauer @ 2023-01-31 8:09 UTC (permalink / raw)
To: Sandy Huang, Heiko Stübner
Cc: Dan Johansen, dri-devel, linux-rockchip, Michael Riesch, kernel,
Robin Murphy
Heiko, Sandy,
Ok to apply these patches?
Sascha
On Wed, Jan 18, 2023 at 02:22:10PM +0100, Sascha Hauer wrote:
> It's been some time since I last sent this series. This version fixes
> a regression Dan Johansen reported. The reason turned out to be simple,
> I used the YUV420 register values instead of the RGB ones.
>
> I realized that we cannot achieve several modes offered by my monitor
> as these require pixelclocks that are slightly below the standard
> pixelclocks. As these are lower than the standard clock rates the PLL
> driver offers the clk driver falls back to a way lower frequency
> which results in something the monitor can't display, so this series
> now contains a patch to discard these unachievable modes.
>
> Sascha
>
> Changes since v2:
> - Use correct register values for mpll_cfg
> - Add patch to discard modes we cannot achieve
>
> Changes since v1:
> - Allow non standard clock rates only on Synopsys phy as suggested by
> Robin Murphy
>
> Sascha Hauer (3):
> drm/rockchip: dw_hdmi: relax mode_valid hook
> drm/rockchip: dw_hdmi: Add support for 4k@30 resolution
> drm/rockchip: dw_hdmi: discard modes with unachievable pixelclocks
>
> drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 40 ++++++++++++++++-----
> 1 file changed, 32 insertions(+), 8 deletions(-)
>
> --
> 2.30.2
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 13+ messages in thread