drm/bridge/panel: Add drm_bridge_get_panel to extract panel from last bridge
Subsystems (3)
PATCH v2 1/2 drm/bridge/panel: Add drm_bridge_get_panel to extract panel from last bridge
Add drm_bridge_get_panel() function to extract drm_panel pointer from panel_bridge. This can be used by bridges in the middle to look up and access drm_panel at the end, and e.g. extract display_timings from it.
---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
---
V2: - New patch
--- drivers/gpu/drm/bridge/panel.c | 18 ++++++++++++++++++ include/drm/drm_bridge.h | 6 ++++++ 2 files changed, 24 insertions(+)
drivers/gpu/drm/bridge/panel.c +18 -0
@@ -235,6 +235,24 @@ bool drm_bridge_is_panel(const struct drm_bridge *bridge) }EXPORT_SYMBOL (drm_bridge_is_panel); +/** +* drm_bridge_get_panel - Return panel if a drm_bridge is a panel_bridge. +* +* @bridge: The drm_bridge. +* +* Returns drm_panel pointer if the bridge is a panel bridge, or NULL otherwise. +*/ +struct drm_panel *drm_bridge_get_panel (struct drm_bridge *bridge) +{ +struct panel_bridge *panel_bridge =drm_bridge_to_panel_bridge (bridge); + +if (!drm_bridge_is_panel (bridge)) +return NULL ; + +return panel_bridge->panel; +} +EXPORT_SYMBOL (drm_bridge_get_panel); +/** * drm_panel_bridge_add - Creates a &drm_bridge and &drm_connector that * just calls the appropriate functions from &drm_panel.
include/drm/drm_bridge.h +6 -0
@@ -984,6 +984,7 @@ void drm_bridge_hpd_notify(struct drm_bridge *bridge,#ifdef CONFIG_DRM_PANEL_BRIDGE bool drm_bridge_is_panel (const struct drm_bridge *bridge); +struct drm_panel *drm_bridge_get_panel (struct drm_bridge *bridge);struct drm_bridge *drm_panel_bridge_add (struct drm_panel *panel);struct drm_bridge *drm_panel_bridge_add_typed (struct drm_panel *panel,u32 connector_type);
@@ -1004,6 +1005,11 @@ static inline bool drm_bridge_is_panel(const struct drm_bridge *bridge)return false; } +static struct drm_panel *drm_bridge_get_panel (struct drm_bridge *bridge) +{ +return NULL ; +} +static inline int drm_panel_bridge_set_orientation (struct drm_connector *connector,struct drm_bridge *bridge) {
Signature · 1 line
2.45.2
PATCH v2 2/2 drm/bridge: tc358767: Improve DPI output pixel clock accuracy
The Pixel PLL is not very capable and may come up with wildly inaccurate clock. Since DPI panels are often tolerant to slightly higher pixel clock without being operated outside of specification, calculate two Pixel PLL from either mode clock or display_timing .pixelclock.max , whichever is higher. Since the Pixel PLL output clock frequency calculation always returns lower frequency than the requested clock frequency, passing in the higher clock frequency should result in output clock frequency which is closer to the expected pixel clock.
For the Chefree CH101 panel with 13 MHz Xtal input clock, the frequency without this patch is 65 MHz which is out of the panel specification of 68.9..73.4 MHz, while with this patch it is 71.5 MHz which is well within the specification and far more accurate.
Keep the change isolated to DPI output.
---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
---
V2: - Isolate the change to DPI only, split tc_bridge_mode_set()
- Look up display_timings and use .pixelclock.max as input into the PLL calculation if available. That should yield more accurate results for DPI panels.
--- drivers/gpu/drm/bridge/tc358767.c | 47 +++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 8 deletions(-)
drivers/gpu/drm/bridge/tc358767.c +39 -8
@@ -39,6 +39,8 @@#include <drm/drm_print.h> #include <drm/drm_probe_helper.h> +#include <video/display_timing.h> +/* Registers */ /* DSI D-PHY Layer registers */
@@ -1681,13 +1683,33 @@ static int tc_dpi_atomic_check(struct drm_bridge *bridge,struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { + u32 mode_clock = crtc_state->mode.clock * 1000;struct tc_data *tc =bridge_to_tc (bridge); -int adjusted_clock =0 ; +struct drm_bridge *nb = bridge; +struct display_timing timings; +struct drm_panel *panel; +int adjusted_clock;int ret; +do { +if (!drm_bridge_is_panel (nb)) +continue ; + + panel =drm_bridge_get_panel (nb); +if (!panel || !panel->funcs || !panel->funcs->get_timings) +continue ; + + ret = panel->funcs->get_timings (panel,1 , &timings); +if (ret <=0 ) +break ; + +if (timings.pixelclock.max > mode_clock) + mode_clock = timings.pixelclock.max; +break ; + }while ((nb =drm_bridge_get_next_bridge (nb))); + ret =tc_pxl_pll_calc (tc,clk_get_rate (tc->refclk), - crtc_state->mode.clock *1000 , - &adjusted_clock,NULL ); + mode_clock, &adjusted_clock,NULL );if (ret)return ret;
@@ -1758,9 +1780,18 @@ tc_edp_mode_valid(struct drm_bridge *bridge,return MODE_OK ; } -static void tc_bridge_mode_set (struct drm_bridge *bridge, -const struct drm_display_mode *mode, -const struct drm_display_mode *adj) +static void tc_dpi_bridge_mode_set (struct drm_bridge *bridge, +const struct drm_display_mode *mode, +const struct drm_display_mode *adj) +{ +struct tc_data *tc =bridge_to_tc (bridge); + +drm_mode_copy (&tc->mode, adj); +} + +static void tc_edp_bridge_mode_set (struct drm_bridge *bridge, +const struct drm_display_mode *mode, +const struct drm_display_mode *adj) {struct tc_data *tc =bridge_to_tc (bridge);
@@ -1977,7 +2008,7 @@ tc_edp_atomic_get_output_bus_fmts(struct drm_bridge *bridge,static const struct drm_bridge_funcs tc_dpi_bridge_funcs = { .attach = tc_dpi_bridge_attach, .mode_valid = tc_dpi_mode_valid, - .mode_set = tc_bridge_mode_set, + .mode_set = tc_dpi_bridge_mode_set, .atomic_check = tc_dpi_atomic_check, .atomic_enable = tc_dpi_bridge_atomic_enable, .atomic_disable = tc_dpi_bridge_atomic_disable,
@@ -1991,7 +2022,7 @@ static const struct drm_bridge_funcs tc_edp_bridge_funcs = { .attach = tc_edp_bridge_attach, .detach = tc_edp_bridge_detach, .mode_valid = tc_edp_mode_valid, - .mode_set = tc_bridge_mode_set, + .mode_set = tc_edp_bridge_mode_set, .atomic_check = tc_edp_atomic_check, .atomic_enable = tc_edp_bridge_atomic_enable, .atomic_disable = tc_edp_bridge_atomic_disable,
Signature · 1 line
2.45.2
Laurent Pinchart
reviewerRe: [PATCH v2 2/2] drm/bridge: tc358767: Improve DPI output pixel clock accuracy
Hi Marek,
Thank you for the patch.
Quoted 5 lines · Marek Vasut
The Pixel PLL is not very capable and may come up with wildly inaccurate clock. Since DPI panels are often tolerant to slightly higher pixel clock without being operated outside of specification, calculate two Pixel PLL from either mode clock or
display_timing.pixelclock.max , whichever is higher.
Maybe this is a leftover from v1 in the commit message, but I don't think the code computes two pixel PLL.
Quoted 4 lines
Since the Pixel PLL output clock frequency calculation always returns lower frequency than the requested clock frequency, passing in the higher clock frequency should result in output clock frequency which is closer to the expected pixel clock.
Is that guaranteed ?
Quoted 4 lines
For the Chefree CH101 panel with 13 MHz Xtal input clock, the frequency without this patch is 65 MHz which is out of the panel specification of 68.9..73.4 MHz, while with this patch it is 71.5 MHz which is well within the specification and far more accurate.
I'm a bit concerned that this patch is quite a bit of a hack, but fixing the problem correctly would be too much yak shaving :-S
Quoted 44 lines
Keep the change isolated to DPI output.
Signed-off-by Marek Vasut <[email protected]>---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
---
V2: - Isolate the change to DPI only, splittc_bridge_mode_set()
- Look updisplay_timingsand use .pixelclock.max as input into the PLL calculation if available. That should yield more accurate results for DPI panels.--- drivers/gpu/drm/bridge/tc358767.c | 47 +++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 8 deletions(-)drivers/gpu/drm/bridge/tc358767.c +3
-0@@ -39,6 +39,8 @@#include <drm/drm_print.h> #include <drm/drm_probe_helper.h> +#include <video/display_timing.h> +/* Registers */ /* DSI D-PHY Layer registers */ @@ -1681,13 +1683,33 @@ static int tc_dpi_atomic_check(struct drm_bridge *bridge,struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { + u32 mode_clock = crtc_state->mode.clock * 1000;
drivers/gpu/drm/bridge/tc358767.c static int tc_dpi_atomic_check(struct drm_bridge *bridge, · line 1695
Quoted 10 lines
drivers/gpu/drm/bridge/tc358767.c +6
-1struct tc_data *tc =bridge_to_tc (bridge); -int adjusted_clock =0 ; +struct drm_bridge *nb = bridge; +struct display_timing timings; +struct drm_panel *panel; +int adjusted_clock;int ret; + do { + if (!drm_bridge_is_panel(nb))
drm_bridge_get_panel() already checks if the bridge is related to a panel, so I think you can drop this check.
Quoted 4 lines
drivers/gpu/drm/bridge/tc358767.c +4
-0+continue ; + + panel =drm_bridge_get_panel (nb); +if (!panel || !panel->funcs || !panel->funcs->get_timings)
drivers/gpu/drm/bridge/tc358767.c static int tc_dpi_atomic_check(struct drm_bridge *bridge, · line 1709
Quoted 10 lines
drivers/gpu/drm/bridge/tc358767.c +10
-0+continue ; + + ret = panel->funcs->get_timings (panel,1 , &timings); +if (ret <=0 ) +break ; + +if (timings.pixelclock.max > mode_clock) + mode_clock = timings.pixelclock.max; +break ; + }while ((nb =drm_bridge_get_next_bridge (nb)));
Can the panel be anything that the last bridge in the chain ?
Quoted 48 lines
drivers/gpu/drm/bridge/tc358767.c +16
-7+ ret =tc_pxl_pll_calc (tc,clk_get_rate (tc->refclk), - crtc_state->mode.clock *1000 , - &adjusted_clock,NULL ); + mode_clock, &adjusted_clock,NULL );if (ret)return ret;@@ -1758,9 +1780,18 @@ tc_edp_mode_valid(struct drm_bridge *bridge,return MODE_OK ; } -static void tc_bridge_mode_set (struct drm_bridge *bridge, -const struct drm_display_mode *mode, -const struct drm_display_mode *adj) +static void tc_dpi_bridge_mode_set (struct drm_bridge *bridge, +const struct drm_display_mode *mode, +const struct drm_display_mode *adj) +{ +struct tc_data *tc =bridge_to_tc (bridge); + +drm_mode_copy (&tc->mode, adj); +} + +static void tc_edp_bridge_mode_set (struct drm_bridge *bridge, +const struct drm_display_mode *mode, +const struct drm_display_mode *adj) {struct tc_data *tc =bridge_to_tc (bridge);@@ -1977,7 +2008,7 @@ tc_edp_atomic_get_output_bus_fmts(struct drm_bridge *bridge,static const struct drm_bridge_funcs tc_dpi_bridge_funcs = { .attach = tc_dpi_bridge_attach, .mode_valid = tc_dpi_mode_valid, - .mode_set = tc_bridge_mode_set, + .mode_set = tc_dpi_bridge_mode_set, .atomic_check = tc_dpi_atomic_check, .atomic_enable = tc_dpi_bridge_atomic_enable, .atomic_disable = tc_dpi_bridge_atomic_disable,@@ -1991,7 +2022,7 @@ static const struct drm_bridge_funcs tc_edp_bridge_funcs = { .attach = tc_edp_bridge_attach, .detach = tc_edp_bridge_detach, .mode_valid = tc_edp_mode_valid, - .mode_set = tc_bridge_mode_set, + .mode_set = tc_edp_bridge_mode_set, .atomic_check = tc_edp_atomic_check, .atomic_enable = tc_edp_bridge_atomic_enable, .atomic_disable = tc_edp_bridge_atomic_disable,
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 2/2] drm/bridge: tc358767: Improve DPI output pixel clock accuracy
In reply to Marek VasutQuoted 9 lines · Marek Vasut
The Pixel PLL is not very capable and may come up with wildly inaccurate clock. Since DPI panels are often tolerant to slightly higher pixel clock without being operated outside of specification, calculate two Pixel PLL from either mode clock or
display_timing.pixelclock.max , whichever is higher. Since the Pixel PLL output clock frequency calculation always returns lower frequency than the requested clock frequency, passing in the higher clock frequency should result in output clock frequency which is closer to the expected pixel clock.
Quoted 4 lines
For the Chefree CH101 panel with 13 MHz Xtal input clock, the frequency without this patch is 65 MHz which is out of the panel specification of 68.9..73.4 MHz, while with this patch it is 71.5 MHz which is well within the specification and far more accurate.
Granted that most of the panel drivers do not implement get_timings() and granted that there are no current users of that interface, I think we should move away from it (and maybe even drop it completely from drm_panel).
What about achieving the same via slightly different approach: register a non-preferred mode with the clock equal to the max clock allowed. The bridge driver can then use the default and the "max" mode to select PLL clock.
I understand that this suggestion doesn't follow the DPI panel specifics, which are closer to the continuous timings rather than fixed set of modes, however I really don't think that it's worth keeping the interface for the sake of a single driver. Original commit 2938931f3732 ("drm/panel: Add display timing support") from 2014 mentions using those timings for .mode_fixup(), but I couldn't find a trace of the corresponding implementation.
Another possible option might be to impletent adjusting modes in .atomic_check() / .mode_fixup().
Quoted 119 lines
Keep the change isolated to DPI output.
Signed-off-by Marek Vasut <[email protected]>---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
---
V2: - Isolate the change to DPI only, splittc_bridge_mode_set()
- Look updisplay_timingsand use .pixelclock.max as input into the PLL calculation if available. That should yield more accurate results for DPI panels.--- drivers/gpu/drm/bridge/tc358767.c | 47 +++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 8 deletions(-)drivers/gpu/drm/bridge/tc358767.c +39
-8@@ -39,6 +39,8 @@#include <drm/drm_print.h> #include <drm/drm_probe_helper.h> +#include <video/display_timing.h> +/* Registers */ /* DSI D-PHY Layer registers */ @@ -1681,13 +1683,33 @@ static int tc_dpi_atomic_check(struct drm_bridge *bridge,struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { + u32 mode_clock = crtc_state->mode.clock * 1000;struct tc_data *tc =bridge_to_tc (bridge); -int adjusted_clock =0 ; +struct drm_bridge *nb = bridge; +struct display_timing timings; +struct drm_panel *panel; +int adjusted_clock;int ret; +do { +if (!drm_bridge_is_panel (nb)) +continue ; + + panel =drm_bridge_get_panel (nb); +if (!panel || !panel->funcs || !panel->funcs->get_timings) +continue ; + + ret = panel->funcs->get_timings (panel,1 , &timings); +if (ret <=0 ) +break ; + +if (timings.pixelclock.max > mode_clock) + mode_clock = timings.pixelclock.max; +break ; + }while ((nb =drm_bridge_get_next_bridge (nb))); + ret =tc_pxl_pll_calc (tc,clk_get_rate (tc->refclk), - crtc_state->mode.clock *1000 , - &adjusted_clock,NULL ); + mode_clock, &adjusted_clock,NULL );if (ret)return ret;@@ -1758,9 +1780,18 @@ tc_edp_mode_valid(struct drm_bridge *bridge,return MODE_OK ; } -static void tc_bridge_mode_set (struct drm_bridge *bridge, -const struct drm_display_mode *mode, -const struct drm_display_mode *adj) +static void tc_dpi_bridge_mode_set (struct drm_bridge *bridge, +const struct drm_display_mode *mode, +const struct drm_display_mode *adj) +{ +struct tc_data *tc =bridge_to_tc (bridge); + +drm_mode_copy (&tc->mode, adj); +} + +static void tc_edp_bridge_mode_set (struct drm_bridge *bridge, +const struct drm_display_mode *mode, +const struct drm_display_mode *adj) {struct tc_data *tc =bridge_to_tc (bridge);@@ -1977,7 +2008,7 @@ tc_edp_atomic_get_output_bus_fmts(struct drm_bridge *bridge,static const struct drm_bridge_funcs tc_dpi_bridge_funcs = { .attach = tc_dpi_bridge_attach, .mode_valid = tc_dpi_mode_valid, - .mode_set = tc_bridge_mode_set, + .mode_set = tc_dpi_bridge_mode_set, .atomic_check = tc_dpi_atomic_check, .atomic_enable = tc_dpi_bridge_atomic_enable, .atomic_disable = tc_dpi_bridge_atomic_disable,@@ -1991,7 +2022,7 @@ static const struct drm_bridge_funcs tc_edp_bridge_funcs = { .attach = tc_edp_bridge_attach, .detach = tc_edp_bridge_detach, .mode_valid = tc_edp_mode_valid, - .mode_set = tc_bridge_mode_set, + .mode_set = tc_edp_bridge_mode_set, .atomic_check = tc_edp_atomic_check, .atomic_enable = tc_edp_bridge_atomic_enable, .atomic_disable = tc_edp_bridge_atomic_disable,Signature · 1 line
2.45.2
Signature · 2 lines
With best wishes Dmitry
Maxime Ripard
maintainerRe: [PATCH v2 2/2] drm/bridge: tc358767: Improve DPI output pixel clock accuracy
Quoted 15 lines · Dmitry Baryshkov
Quoted 9 lines · Marek Vasut
The Pixel PLL is not very capable and may come up with wildly inaccurate clock. Since DPI panels are often tolerant to slightly higher pixel clock without being operated outside of specification, calculate two Pixel PLL from either mode clock or
display_timing.pixelclock.max , whichever is higher. Since the Pixel PLL output clock frequency calculation always returns lower frequency than the requested clock frequency, passing in the higher clock frequency should result in output clock frequency which is closer to the expected pixel clock.Quoted 4 lines
For the Chefree CH101 panel with 13 MHz Xtal input clock, the frequency without this patch is 65 MHz which is out of the panel specification of 68.9..73.4 MHz, while with this patch it is 71.5 MHz which is well within the specification and far more accurate.
Quoted 4 lines
Granted that most of the panel drivers do not implement
get_timings()and granted that there are no current users of that interface, I think we should move away from it (and maybe even drop it completely fromdrm_panel).
I think we should do the opposite :)
Panels usually have a pretty large operating window, and the current construct only works because nobody really uses the same panels (or we're hiding that behind different compatibles) across SoCs or generation. Or we're working around it.
It's kind of a mess, and it gets messy in encoders too: some will filter out panel modes, some won't. Some will adjust timings to fit their clocks, some won't. etc.
Going forward, switching everyone to a timing-like interface and providing a set of helpers to adjust timings within possible boundaries to fit a clock rate is doable and should be done imo.
Quoted 13 lines
What about achieving the same via slightly different approach: register a non-preferred mode with the clock equal to the max clock allowed. The bridge driver can then use the default and the "max" mode to select PLL clock.
I understand that this suggestion doesn't follow the DPI panel specifics, which are closer to the continuous timings rather than fixed set of modes, however I really don't think that it's worth keeping the interface for the sake of a single driver. Original commit
2938931f3732("drm/panel: Add display timing support") from 2014 mentions using those timings for .mode_fixup(), but I couldn't find a trace of the corresponding implementation.
Quoted 2 lines
Another possible option might be to impletent adjusting modes in .atomic_check() / .mode_fixup().
It's unused because we don't have an easy API for encoders to use it. We should fix *that*.
Maxime
Re: [PATCH v2 2/2] drm/bridge: tc358767: Improve DPI output pixel clock accuracy
Quoted 24 lines · Maxime Ripard
Quoted 15 lines · Dmitry Baryshkov
Quoted 9 lines · Marek Vasut
The Pixel PLL is not very capable and may come up with wildly inaccurate clock. Since DPI panels are often tolerant to slightly higher pixel clock without being operated outside of specification, calculate two Pixel PLL from either mode clock or
display_timing.pixelclock.max , whichever is higher. Since the Pixel PLL output clock frequency calculation always returns lower frequency than the requested clock frequency, passing in the higher clock frequency should result in output clock frequency which is closer to the expected pixel clock.Quoted 4 lines
For the Chefree CH101 panel with 13 MHz Xtal input clock, the frequency without this patch is 65 MHz which is out of the panel specification of 68.9..73.4 MHz, while with this patch it is 71.5 MHz which is well within the specification and far more accurate.
Quoted 4 lines
Granted that most of the panel drivers do not implement
get_timings()and granted that there are no current users of that interface, I think we should move away from it (and maybe even drop it completely fromdrm_panel).I think we should do the opposite :)
Quoted 8 lines
Panels usually have a pretty large operating window, and the current construct only works because nobody really uses the same panels (or we're hiding that behind different compatibles) across SoCs or generation. Or we're working around it.
It's kind of a mess, and it gets messy in encoders too: some will filter out panel modes, some won't. Some will adjust timings to fit their clocks, some won't. etc.
Well... I think it's messy because we have so many different interfaces. Some encoders can poke directly into the panel, some drivers use bridge chains and panel bridge. Some do even a messier thing and try both at the same time.
I think that in the long-term nobody should be using the drm_panel interface directly.
Quoted 4 lines
Going forward, switching everyone to a timing-like interface and providing a set of helpers to adjust timings within possible boundaries to fit a clock rate is doable and should be done imo.
... and then it might help with the command-mode DSI panels with DSC...
Quoted 14 lines
Quoted 14 lines
What about achieving the same via slightly different approach: register a non-preferred mode with the clock equal to the max clock allowed. The bridge driver can then use the default and the "max" mode to select PLL clock.
I understand that this suggestion doesn't follow the DPI panel specifics, which are closer to the continuous timings rather than fixed set of modes, however I really don't think that it's worth keeping the interface for the sake of a single driver. Original commit
2938931f3732("drm/panel: Add display timing support") from 2014 mentions using those timings for .mode_fixup(), but I couldn't find a trace of the corresponding implementation.
Quoted 5 lines
Quoted 2 lines
Another possible option might be to impletent adjusting modes in .atomic_check() / .mode_fixup().
It's unused because we don't have an easy API for encoders to use it. We should fix *that*.
Sounds good to me too.
I'm not sure what it should look like though. We barely scratched our heads when looking at the DSC / CMD stuff, but nothing came out of it.
Ideally... there should be some kind of get_timings being available through the full bridge chain, so that the encoders can use it. But I'm not sure how that should work, because some bridges would like to manipulate those timings. And some bridges will completely drop get_timings() and produce raw modes even after consuming the timings set.
Signature · 2 lines
With best wishes Dmitry
Maxime Ripard
maintainerRe: [PATCH v2 2/2] drm/bridge: tc358767: Improve DPI output pixel clock accuracy
Quoted 34 lines · Dmitry Baryshkov
Quoted 24 lines · Maxime Ripard
Quoted 15 lines · Dmitry Baryshkov
Quoted 9 lines · Marek Vasut
The Pixel PLL is not very capable and may come up with wildly inaccurate clock. Since DPI panels are often tolerant to slightly higher pixel clock without being operated outside of specification, calculate two Pixel PLL from either mode clock or
display_timing.pixelclock.max , whichever is higher. Since the Pixel PLL output clock frequency calculation always returns lower frequency than the requested clock frequency, passing in the higher clock frequency should result in output clock frequency which is closer to the expected pixel clock.Quoted 4 lines
For the Chefree CH101 panel with 13 MHz Xtal input clock, the frequency without this patch is 65 MHz which is out of the panel specification of 68.9..73.4 MHz, while with this patch it is 71.5 MHz which is well within the specification and far more accurate.
Quoted 4 lines
Granted that most of the panel drivers do not implement
get_timings()and granted that there are no current users of that interface, I think we should move away from it (and maybe even drop it completely fromdrm_panel).I think we should do the opposite :)
Quoted 8 lines
Panels usually have a pretty large operating window, and the current construct only works because nobody really uses the same panels (or we're hiding that behind different compatibles) across SoCs or generation. Or we're working around it.
It's kind of a mess, and it gets messy in encoders too: some will filter out panel modes, some won't. Some will adjust timings to fit their clocks, some won't. etc.
Quoted 6 lines
Well... I think it's messy because we have so many different interfaces. Some encoders can poke directly into the panel, some drivers use bridge chains and panel bridge. Some do even a messier thing and try both at the same time.
I think that in the long-term nobody should be using thedrm_panelinterface directly.
There's a few corner cases that are doable with the panel API that aren't possible with the bridge API still. Being able to get the pixel clock you're going to get from the encoder and adjust the timings to match the panel tolerance is one for example, and we have a couple of drivers doing that.
Quoted 5 lines
Quoted 3 lines
Going forward, switching everyone to a timing-like interface and providing a set of helpers to adjust timings within possible boundaries to fit a clock rate is doable and should be done imo.
... and then it might help with the command-mode DSI panels with DSC...
How so?
Quoted 24 lines
Quoted 14 lines
Quoted 14 lines
What about achieving the same via slightly different approach: register a non-preferred mode with the clock equal to the max clock allowed. The bridge driver can then use the default and the "max" mode to select PLL clock.
I understand that this suggestion doesn't follow the DPI panel specifics, which are closer to the continuous timings rather than fixed set of modes, however I really don't think that it's worth keeping the interface for the sake of a single driver. Original commit
2938931f3732("drm/panel: Add display timing support") from 2014 mentions using those timings for .mode_fixup(), but I couldn't find a trace of the corresponding implementation.Quoted 5 lines
Quoted 2 lines
Another possible option might be to impletent adjusting modes in .atomic_check() / .mode_fixup().
It's unused because we don't have an easy API for encoders to use it. We should fix *that*.
Sounds good to me too.
I'm not sure what it should look like though. We barely scratched our heads when looking at the DSC / CMD stuff, but nothing came out of it.
Quoted 6 lines
Ideally... there should be some kind of
get_timingsbeing available through the full bridge chain, so that the encoders can use it. But I'm not sure how that should work, because some bridges would like to manipulate those timings. And some bridges will completely dropget_timings()and produce raw modes even after consuming the timings set.
the drm_display_mode -> timings conversion is fairly easy to do: just use the same values for min, typ and max.
Maxime
Re: [PATCH v2 2/2] drm/bridge: tc358767: Improve DPI output pixel clock accuracy
Quoted 43 lines · Maxime Ripard
Quoted 34 lines · Dmitry Baryshkov
Quoted 24 lines · Maxime Ripard
Quoted 15 lines · Dmitry Baryshkov
Quoted 9 lines · Marek Vasut
The Pixel PLL is not very capable and may come up with wildly inaccurate clock. Since DPI panels are often tolerant to slightly higher pixel clock without being operated outside of specification, calculate two Pixel PLL from either mode clock or
display_timing.pixelclock.max , whichever is higher. Since the Pixel PLL output clock frequency calculation always returns lower frequency than the requested clock frequency, passing in the higher clock frequency should result in output clock frequency which is closer to the expected pixel clock.Quoted 4 lines
For the Chefree CH101 panel with 13 MHz Xtal input clock, the frequency without this patch is 65 MHz which is out of the panel specification of 68.9..73.4 MHz, while with this patch it is 71.5 MHz which is well within the specification and far more accurate.
Quoted 4 lines
Granted that most of the panel drivers do not implement
get_timings()and granted that there are no current users of that interface, I think we should move away from it (and maybe even drop it completely fromdrm_panel).I think we should do the opposite :)
Quoted 8 lines
Panels usually have a pretty large operating window, and the current construct only works because nobody really uses the same panels (or we're hiding that behind different compatibles) across SoCs or generation. Or we're working around it.
It's kind of a mess, and it gets messy in encoders too: some will filter out panel modes, some won't. Some will adjust timings to fit their clocks, some won't. etc.
Quoted 6 lines
Well... I think it's messy because we have so many different interfaces. Some encoders can poke directly into the panel, some drivers use bridge chains and panel bridge. Some do even a messier thing and try both at the same time.
I think that in the long-term nobody should be using thedrm_panelinterface directly.
Quoted 5 lines
There's a few corner cases that are doable with the panel API that aren't possible with the bridge API still. Being able to get the pixel clock you're going to get from the encoder and adjust the timings to match the panel tolerance is one for example, and we have a couple of drivers doing that.
My initial point was that only panel-simple (and panel-edp) implement the get_timings().
And for the existing encoder drivers I think we should be migrating to using bridge API instead of panel API.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Going forward, switching everyone to a timing-like interface and providing a set of helpers to adjust timings within possible boundaries to fit a clock rate is doable and should be done imo.
... and then it might help with the command-mode DSI panels with DSC...
How so?
We had troubles with CMD panels, because we need to get the mode timings based on FPS and compression ratio (so it can not be pregrorammed, like we usually do for most of the panels).
Quoted 34 lines
Quoted 25 lines
Quoted 15 lines
Quoted 15 lines
What about achieving the same via slightly different approach: register a non-preferred mode with the clock equal to the max clock allowed. The bridge driver can then use the default and the "max" mode to select PLL clock.
I understand that this suggestion doesn't follow the DPI panel specifics, which are closer to the continuous timings rather than fixed set of modes, however I really don't think that it's worth keeping the interface for the sake of a single driver. Original commit
2938931f3732("drm/panel: Add display timing support") from 2014 mentions using those timings for .mode_fixup(), but I couldn't find a trace of the corresponding implementation.Quoted 5 lines
Quoted 2 lines
Another possible option might be to impletent adjusting modes in .atomic_check() / .mode_fixup().
It's unused because we don't have an easy API for encoders to use it. We should fix *that*.
Sounds good to me too.
I'm not sure what it should look like though. We barely scratched our heads when looking at the DSC / CMD stuff, but nothing came out of it.Quoted 6 lines
Ideally... there should be some kind of
get_timingsbeing available through the full bridge chain, so that the encoders can use it. But I'm not sure how that should work, because some bridges would like to manipulate those timings. And some bridges will completely dropget_timings()and produce raw modes even after consuming the timings set.the
drm_display_mode-> timings conversion is fairly easy to do: just use the same values for min, typ and max.
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v2 2/2] drm/bridge: tc358767: Improve DPI output pixel clock accuracy
In reply to Maxime RipardQuoted 21 lines · Maxime Ripard
Quoted 15 lines · Dmitry Baryshkov
Quoted 9 lines · Marek Vasut
The Pixel PLL is not very capable and may come up with wildly inaccurate clock. Since DPI panels are often tolerant to slightly higher pixel clock without being operated outside of specification, calculate two Pixel PLL from either mode clock or
display_timing.pixelclock.max , whichever is higher. Since the Pixel PLL output clock frequency calculation always returns lower frequency than the requested clock frequency, passing in the higher clock frequency should result in output clock frequency which is closer to the expected pixel clock.Quoted 4 lines
For the Chefree CH101 panel with 13 MHz Xtal input clock, the frequency without this patch is 65 MHz which is out of the panel specification of 68.9..73.4 MHz, while with this patch it is 71.5 MHz which is well within the specification and far more accurate.
Quoted 4 lines
Granted that most of the panel drivers do not implement
get_timings()and granted that there are no current users of that interface, I think we should move away from it (and maybe even drop it completely fromdrm_panel).
Quoted 6 lines
I think we should do the opposite :)
Panels usually have a pretty large operating window, and the current construct only works because nobody really uses the same panels (or we're hiding that behind different compatibles) across SoCs or generation. Or we're working around it.
I am using the same panels on NXP MX6/MX8 and STM32MP1 with wildly different pipeline setups too.
Quoted 7 lines
It's kind of a mess, and it gets messy in encoders too: some will filter out panel modes, some won't. Some will adjust timings to fit their clocks, some won't. etc.
Going forward, switching everyone to a timing-like interface and providing a set of helpers to adjust timings within possible boundaries to fit a clock rate is doable and should be done imo.
Maybe it would be better to have multiple modes and mark them with MIN/TYP/MAX flag , so at least there wouldn't be two sets of structures describing the same thing, but only one structure (drm_display_mode) ?
Re: [PATCH v2 2/2] drm/bridge: tc358767: Improve DPI output pixel clock accuracy
In reply to Dmitry BaryshkovQuoted 15 lines · Dmitry Baryshkov
Quoted 9 lines · Marek Vasut
The Pixel PLL is not very capable and may come up with wildly inaccurate clock. Since DPI panels are often tolerant to slightly higher pixel clock without being operated outside of specification, calculate two Pixel PLL from either mode clock or
display_timing.pixelclock.max , whichever is higher. Since the Pixel PLL output clock frequency calculation always returns lower frequency than the requested clock frequency, passing in the higher clock frequency should result in output clock frequency which is closer to the expected pixel clock.Quoted 4 lines
For the Chefree CH101 panel with 13 MHz Xtal input clock, the frequency without this patch is 65 MHz which is out of the panel specification of 68.9..73.4 MHz, while with this patch it is 71.5 MHz which is well within the specification and far more accurate.
Quoted 4 lines
Granted that most of the panel drivers do not implement
get_timings()and granted that there are no current users of that interface, I think we should move away from it (and maybe even drop it completely fromdrm_panel).
It does fit DPI and LVDS panels and their descriptions in datasheets the best.
Quoted 13 lines
What about achieving the same via slightly different approach: register a non-preferred mode with the clock equal to the max clock allowed. The bridge driver can then use the default and the "max" mode to select PLL clock.
I understand that this suggestion doesn't follow the DPI panel specifics, which are closer to the continuous timings rather than fixed set of modes, however I really don't think that it's worth keeping the interface for the sake of a single driver. Original commit
2938931f3732("drm/panel: Add display timing support") from 2014 mentions using those timings for .mode_fixup(), but I couldn't find a trace of the corresponding implementation.
Quoted 2 lines
Another possible option might be to impletent adjusting modes in .atomic_check() / .mode_fixup().
Something like this ?
static const struct display_timing chefree_ch101olhlwh_002_timing = {
.pixelclock = { 68900000, 71100000, 73400000 },
...
};
static const struct panel_desc chefree_ch101olhlwh_002 = {
.timings = &chefree_ch101olhlwh_002_timing, .num_timings = 1,
...
};
... would turn into ...
static const struct drm_display_mode chefree_ch101olhlwh_002_mode[3] = {
{
.clock = 68900000,
...
}, {
.clock = 71100000,
...
}, {
.clock = 73400000,
... }
};
static const struct panel_desc chefree_ch101olhlwh_002 = {
.modes = &chefree_ch101olhlwh_002_mode, .num_timings = 3,
...
};
?
Maybe some mode flag to specify which mode is MIN/TYP/MAX would be useful with that change too ?
Finally, the TC358767 driver would test all modes and find the most accurate one ?
Maxime Ripard
maintainerRe: [PATCH v2 2/2] drm/bridge: tc358767: Improve DPI output pixel clock accuracy
Quoted 67 lines · Marek Vasut
Quoted 15 lines · Dmitry Baryshkov
Quoted 9 lines · Marek Vasut
The Pixel PLL is not very capable and may come up with wildly inaccurate clock. Since DPI panels are often tolerant to slightly higher pixel clock without being operated outside of specification, calculate two Pixel PLL from either mode clock or
display_timing.pixelclock.max , whichever is higher. Since the Pixel PLL output clock frequency calculation always returns lower frequency than the requested clock frequency, passing in the higher clock frequency should result in output clock frequency which is closer to the expected pixel clock.Quoted 4 lines
For the Chefree CH101 panel with 13 MHz Xtal input clock, the frequency without this patch is 65 MHz which is out of the panel specification of 68.9..73.4 MHz, while with this patch it is 71.5 MHz which is well within the specification and far more accurate.
Quoted 4 lines
Granted that most of the panel drivers do not implement
get_timings()and granted that there are no current users of that interface, I think we should move away from it (and maybe even drop it completely fromdrm_panel).It does fit DPI and LVDS panels and their descriptions in datasheets the best.
Quoted 13 lines
What about achieving the same via slightly different approach: register a non-preferred mode with the clock equal to the max clock allowed. The bridge driver can then use the default and the "max" mode to select PLL clock.
I understand that this suggestion doesn't follow the DPI panel specifics, which are closer to the continuous timings rather than fixed set of modes, however I really don't think that it's worth keeping the interface for the sake of a single driver. Original commit
2938931f3732("drm/panel: Add display timing support") from 2014 mentions using those timings for .mode_fixup(), but I couldn't find a trace of the corresponding implementation.Quoted 2 lines
Another possible option might be to impletent adjusting modes in .atomic_check() / .mode_fixup().
Something like this ?
static const struct
display_timingchefree_ch101olhlwh_002_timing= {
.pixelclock = { 68900000, 71100000, 73400000 },
...
};static const struct
panel_descchefree_ch101olhlwh_002= {
.timings =&chefree_ch101olhlwh_002_timing, .num_timings = 1,
...
};... would turn into ...
static const struct
drm_display_modechefree_ch101olhlwh_002_mode[3] = {{ .clock = 68900000, ... }, { .clock = 71100000, ... }, { .clock = 73400000, ...}
};
Quoted 7 lines
static const struct
panel_descchefree_ch101olhlwh_002= {
.modes =&chefree_ch101olhlwh_002_mode, .num_timings = 3,
...
};?
Except that doesn't work if you want to keep your driver at the expected framerate. To reduce the pixel clock, you also need to reduce the blanking period within the acceptable boundaries if you want to keep the same framerate.
Maxime
Re: [PATCH v2 2/2] drm/bridge: tc358767: Improve DPI output pixel clock accuracy
Quoted 74 lines · Maxime Ripard
Quoted 73 lines · Marek Vasut
Quoted 15 lines · Dmitry Baryshkov
Quoted 9 lines · Marek Vasut
The Pixel PLL is not very capable and may come up with wildly inaccurate clock. Since DPI panels are often tolerant to slightly higher pixel clock without being operated outside of specification, calculate two Pixel PLL from either mode clock or
display_timing.pixelclock.max , whichever is higher. Since the Pixel PLL output clock frequency calculation always returns lower frequency than the requested clock frequency, passing in the higher clock frequency should result in output clock frequency which is closer to the expected pixel clock.Quoted 4 lines
For the Chefree CH101 panel with 13 MHz Xtal input clock, the frequency without this patch is 65 MHz which is out of the panel specification of 68.9..73.4 MHz, while with this patch it is 71.5 MHz which is well within the specification and far more accurate.
Quoted 4 lines
Granted that most of the panel drivers do not implement
get_timings()and granted that there are no current users of that interface, I think we should move away from it (and maybe even drop it completely fromdrm_panel).It does fit DPI and LVDS panels and their descriptions in datasheets the best.
Quoted 13 lines
What about achieving the same via slightly different approach: register a non-preferred mode with the clock equal to the max clock allowed. The bridge driver can then use the default and the "max" mode to select PLL clock.
I understand that this suggestion doesn't follow the DPI panel specifics, which are closer to the continuous timings rather than fixed set of modes, however I really don't think that it's worth keeping the interface for the sake of a single driver. Original commit
2938931f3732("drm/panel: Add display timing support") from 2014 mentions using those timings for .mode_fixup(), but I couldn't find a trace of the corresponding implementation.Quoted 2 lines
Another possible option might be to impletent adjusting modes in .atomic_check() / .mode_fixup().
Something like this ?
static const struct display_timing chefree_ch101olhlwh_002_timing = { .pixelclock = { 68900000, 71100000, 73400000 }, ... };static const struct panel_desc chefree_ch101olhlwh_002 = { .timings = &chefree_ch101olhlwh_002_timing, .num_timings = 1, ... };... would turn into ...
static const struct drm_display_mode chefree_ch101olhlwh_002_mode[3] = { { .clock = 68900000, ... }, { .clock = 71100000, ... }, { .clock = 73400000, ... } };static const struct panel_desc chefree_ch101olhlwh_002 = { .modes = &chefree_ch101olhlwh_002_mode, .num_timings = 3, ... };
Quoted 6 lines
Quoted 1 line
?
Except that doesn't work if you want to keep your driver at the expected framerate. To reduce the pixel clock, you also need to reduce the blanking period within the acceptable boundaries if you want to keep the same framerate.
Each mode entry would have to have its own full set of timings of course, not just .clock . Those can be converted from display_timing just like clock.