The panel bridge assumes the panel is enabled whenever its pipeline was read out as active, since a panel has no state that can be read out of the hardware.
However, the drm_panel itself still considers the panel powered down. The next commit won't prepare and enable it if it doesn't need a modeset, so the panel driver never acquires its supplies, GPIOs or backlight, and the next disable of the pipeline skips the panel teardown with a warning since the panel was never prepared. Implement the bridge atomic_sro_install_state hook to call drm_panel_prepare() and drm_panel_enable() for those panels, so that the drm_panel state matches the hardware state. This is a hack: drm_panel_prepare() and drm_panel_enable() don't take over a running panel, they run the full power up sequence of the panel driver on a panel the firmware has already lit. Depending on the driver, that can mean toggling the reset GPIO, waiting for the power-up delays, or sending the whole DSI initialization sequence again, which might blank or glitch the display, and thus defeats the purpose of the state readout. It also notifies the panel followers as if the panel had just been powered up. Doing this properly requires a drm_panel operation to take over a panel that is already running, acquiring its resources without reprogramming it, which doesn't exist yet. Signed-off-by: Maxime Ripard <[email protected]> --- drivers/gpu/drm/drm_panel.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index 9c60942de90b..1dd5c1011b02 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -350,10 +350,32 @@ panel_bridge_connector_readout(struct drm_bridge *bridge, conn_state->best_encoder = encoder; return 0; } +/* + * The pipeline was read out as active, so the firmware left the panel + * powered up and enabled. Prepare and enable it so that the panel + * driver acquires its resources and its state matches the hardware, + * since the next commit won't do it if it doesn't need a modeset, and + * the next disable of the pipeline will release them. + */ +static void +panel_bridge_install_state(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) +{ + struct drm_panel *panel = drm_bridge_to_panel(bridge); + + if (!panel->prepared) + drm_panel_prepare(panel); + + if (!panel->enabled) + drm_panel_enable(panel); +} + static const struct drm_bridge_funcs panel_bridge_bridge_funcs = { .attach = panel_bridge_attach, .detach = panel_bridge_detach, .atomic_pre_enable = panel_bridge_atomic_pre_enable, .atomic_enable = panel_bridge_atomic_enable, @@ -365,10 +387,11 @@ static const struct drm_bridge_funcs panel_bridge_bridge_funcs = { .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, .atomic_get_input_bus_fmts = drm_atomic_helper_bridge_propagate_bus_fmt, .debugfs_init = panel_bridge_debugfs_init, .atomic_sro_readout_state = panel_bridge_readout_state, .atomic_sro_compare_state = drm_atomic_helper_bridge_compare_state, + .atomic_sro_install_state = panel_bridge_install_state, .atomic_sro_connector_readout = panel_bridge_connector_readout, }; /** * drm_bridge_is_panel - Checks if a drm_bridge is a panel_bridge. -- 2.56.1
