The display snapshot code calls msm_dsi_snapshot() and msm_dp_snapshot() directly, so it has to know the concrete sub-block type of each entry.
Add a mandatory snapshot() callback to struct msm_display_funcs and turn the DSI and DP snapshot helpers into implementations of it. HDMI did not have a snapshot helper before; give it an empty implementation for now (a following patch fills it in). The snapshot code now dispatches through the interface for all three sub-blocks. No functional change intended. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Dmitry Baryshkov <[email protected]> --- drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c | 19 +++++++++++-------- drivers/gpu/drm/msm/dp/dp_display.c | 5 ++++- drivers/gpu/drm/msm/dsi/dsi.c | 16 ++++++++++------ drivers/gpu/drm/msm/hdmi/hdmi.c | 6 ++++++ drivers/gpu/drm/msm/msm_drv.h | 14 +++++--------- 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c b/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c index 850246fc89e1..b42a92c2ffad 100644 --- a/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +++ b/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c @@ -131,6 +131,7 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state) { struct msm_drm_private *priv; struct drm_device *drm_dev; + struct msm_display *display; struct msm_kms *kms; int i; @@ -139,19 +140,21 @@ void msm_disp_snapshot_capture_state(struct msm_disp_state *disp_state) kms = priv->kms; for (i = 0; i < ARRAY_SIZE(kms->dp); i++) { - if (!kms->dp[i]) - continue; - - msm_dp_snapshot(disp_state, kms->dp[i]); + display = msm_dp_get_display(kms->dp[i]); + if (display) + display->funcs->snapshot(display, disp_state); } for (i = 0; i < ARRAY_SIZE(kms->dsi); i++) { - if (!kms->dsi[i]) - continue; - - msm_dsi_snapshot(disp_state, kms->dsi[i]); + display = msm_dsi_get_display(kms->dsi[i]); + if (display) + display->funcs->snapshot(display, disp_state); } + display = msm_hdmi_get_display(kms->hdmi); + if (display) + display->funcs->snapshot(display, disp_state); + if (kms->funcs->snapshot) kms->funcs->snapshot(disp_state, kms); diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 79dd556e96c2..f4fa86d1b9c7 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -783,8 +783,10 @@ int msm_dp_display_get_test_bpp(struct msm_dp *dp) msm_dp_display->link->test_video.test_bit_depth); } -void msm_dp_snapshot(struct msm_disp_state *disp_state, struct msm_dp *dp) +static void msm_dp_snapshot(struct msm_display *display, + struct msm_disp_state *disp_state) { + struct msm_dp *dp = container_of(display, struct msm_dp, display); struct msm_dp_display_private *msm_dp_display; msm_dp_display = container_of(dp, struct msm_dp_display_private, msm_dp_display); @@ -1354,6 +1356,7 @@ static int msm_dp_modeset_init(struct msm_display *display, static const struct msm_display_funcs msm_dp_display_funcs = { .modeset_init = msm_dp_modeset_init, + .snapshot = msm_dp_snapshot, }; struct msm_display *msm_dp_get_display(struct msm_dp *msm_dp_display) diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c index 6cd844d08733..c86142f66237 100644 --- a/drivers/gpu/drm/msm/dsi/dsi.c +++ b/drivers/gpu/drm/msm/dsi/dsi.c @@ -267,8 +267,18 @@ static int msm_dsi_modeset_init(struct msm_display *display, return 0; } +static void msm_dsi_snapshot(struct msm_display *display, + struct msm_disp_state *disp_state) +{ + struct msm_dsi *msm_dsi = container_of(display, struct msm_dsi, display); + + msm_dsi_host_snapshot(disp_state, msm_dsi->host); + msm_dsi_phy_snapshot(disp_state, msm_dsi->phy); +} + static const struct msm_display_funcs msm_dsi_display_funcs = { .modeset_init = msm_dsi_modeset_init, + .snapshot = msm_dsi_snapshot, }; struct msm_display *msm_dsi_get_display(struct msm_dsi *msm_dsi) @@ -276,9 +286,3 @@ struct msm_display *msm_dsi_get_display(struct msm_dsi *msm_dsi) return msm_dsi ? &msm_dsi->display : NULL; } -void msm_dsi_snapshot(struct msm_disp_state *disp_state, struct msm_dsi *msm_dsi) -{ - msm_dsi_host_snapshot(disp_state, msm_dsi->host); - msm_dsi_phy_snapshot(disp_state, msm_dsi->phy); -} - diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c index 03367c6ba428..350867ada0cf 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c @@ -211,8 +211,14 @@ static int msm_hdmi_modeset_init(struct msm_display *display, return ret; } +static void msm_hdmi_snapshot(struct msm_display *display, + struct msm_disp_state *disp_state) +{ +} + static const struct msm_display_funcs msm_hdmi_display_funcs = { .modeset_init = msm_hdmi_modeset_init, + .snapshot = msm_hdmi_snapshot, }; struct msm_display *msm_hdmi_get_display(struct hdmi *hdmi) diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index dbd955091ce7..d25d783b4f11 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -275,15 +275,20 @@ int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper, #endif struct msm_display; +struct msm_disp_state; /** * struct msm_display_funcs - ops provided by a display sub-block (DSI/DP/HDMI) * @modeset_init: create the bridge and connector for the sub-block, attaching * to @encoder. + * @snapshot: capture the sub-block's state for a display snapshot; + * mandatory. */ struct msm_display_funcs { int (*modeset_init)(struct msm_display *display, struct drm_device *dev, struct drm_encoder *encoder); + void (*snapshot)(struct msm_display *display, + struct msm_disp_state *disp_state); }; /** @@ -319,7 +324,6 @@ void dsi_dev_detach(struct platform_device *pdev); void __init msm_dsi_register(void); void __exit msm_dsi_unregister(void); struct msm_display *msm_dsi_get_display(struct msm_dsi *msm_dsi); -void msm_dsi_snapshot(struct msm_disp_state *disp_state, struct msm_dsi *msm_dsi); bool msm_dsi_is_cmd_mode(struct msm_dsi *msm_dsi); bool msm_dsi_is_bonded_dsi(struct msm_dsi *msm_dsi); bool msm_dsi_is_master_dsi(struct msm_dsi *msm_dsi); @@ -337,9 +341,6 @@ static inline struct msm_display *msm_dsi_get_display(struct msm_dsi *msm_dsi) { return NULL; } -static inline void msm_dsi_snapshot(struct msm_disp_state *disp_state, struct msm_dsi *msm_dsi) -{ -} static inline bool msm_dsi_is_cmd_mode(struct msm_dsi *msm_dsi) { return false; @@ -373,7 +374,6 @@ struct msm_dp; int __init msm_dp_register(void); void __exit msm_dp_unregister(void); struct msm_display *msm_dp_get_display(struct msm_dp *dp_display); -void msm_dp_snapshot(struct msm_disp_state *disp_state, struct msm_dp *dp_display); bool msm_dp_needs_periph_flush(const struct msm_dp *dp_display, const struct drm_display_mode *mode); bool msm_dp_wide_bus_available(const struct msm_dp *dp_display); @@ -391,10 +391,6 @@ static inline struct msm_display *msm_dp_get_display(struct msm_dp *dp_display) return NULL; } -static inline void msm_dp_snapshot(struct msm_disp_state *disp_state, struct msm_dp *dp_display) -{ -} - static inline bool msm_dp_needs_periph_flush(const struct msm_dp *dp_display, const struct drm_display_mode *mode) { -- 2.47.3
