Message ID | 20240815151953.184679-3-tzimmermann@suse.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/ast: Transparently handle BMC in outputs | expand |
On 15/08/2024 17:18, Thomas Zimmermann wrote: > Add struct ast_connector to track a connector's physical status. With > the upcoming BMC support, the physical status can be different from the > reported status. Thanks for this, as we fake the connector to be always connected with BMC, it has to know internally if there is something plugged. Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> > > Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> > --- > drivers/gpu/drm/ast/ast_dp.c | 7 ++++++- > drivers/gpu/drm/ast/ast_dp501.c | 11 +++++++++-- > drivers/gpu/drm/ast/ast_drv.h | 24 ++++++++++++++++++++---- > drivers/gpu/drm/ast/ast_mode.c | 8 ++++---- > drivers/gpu/drm/ast/ast_sil164.c | 20 ++++++++++++++++++-- > drivers/gpu/drm/ast/ast_vga.c | 20 ++++++++++++++++++-- > 6 files changed, 75 insertions(+), 15 deletions(-) > > diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c > index 549c823c9529..c7f0f9b5dc3a 100644 > --- a/drivers/gpu/drm/ast/ast_dp.c > +++ b/drivers/gpu/drm/ast/ast_dp.c > @@ -364,6 +364,7 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector > struct drm_modeset_acquire_ctx *ctx, > bool force) > { > + struct ast_connector *ast_connector = to_ast_connector(connector); > struct drm_device *dev = connector->dev; > struct ast_device *ast = to_ast_device(connector->dev); > enum drm_connector_status status = connector_status_disconnected; > @@ -392,6 +393,8 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector > > mutex_unlock(&ast->modeset_lock); > > + ast_connector->physical_status = status; > + > return status; > } > > @@ -432,7 +435,8 @@ int ast_astdp_output_init(struct ast_device *ast) > struct drm_device *dev = &ast->base; > struct drm_crtc *crtc = &ast->crtc; > struct drm_encoder *encoder = &ast->output.astdp.encoder; > - struct drm_connector *connector = &ast->output.astdp.connector; > + struct ast_connector *ast_connector = &ast->output.astdp.connector; > + struct drm_connector *connector = &ast_connector->base; > int ret; > > ret = drm_encoder_init(dev, encoder, &ast_astdp_encoder_funcs, > @@ -446,6 +450,7 @@ int ast_astdp_output_init(struct ast_device *ast) > ret = ast_astdp_connector_init(dev, connector); > if (ret) > return ret; > + ast_connector->physical_status = connector->status; > > ret = drm_connector_attach_encoder(connector, encoder); > if (ret) > diff --git a/drivers/gpu/drm/ast/ast_dp501.c b/drivers/gpu/drm/ast/ast_dp501.c > index 478efa226170..3904f98ef846 100644 > --- a/drivers/gpu/drm/ast/ast_dp501.c > +++ b/drivers/gpu/drm/ast/ast_dp501.c > @@ -540,11 +540,16 @@ static int ast_dp501_connector_helper_detect_ctx(struct drm_connector *connector > struct drm_modeset_acquire_ctx *ctx, > bool force) > { > + struct ast_connector *ast_connector = to_ast_connector(connector); > struct ast_device *ast = to_ast_device(connector->dev); > + enum drm_connector_status status = connector_status_disconnected; > > if (ast_dp501_is_connected(ast)) > return connector_status_connected; > - return connector_status_disconnected; > + > + ast_connector->physical_status = status; > + > + return status; > } > > static const struct drm_connector_helper_funcs ast_dp501_connector_helper_funcs = { > @@ -584,7 +589,8 @@ int ast_dp501_output_init(struct ast_device *ast) > struct drm_device *dev = &ast->base; > struct drm_crtc *crtc = &ast->crtc; > struct drm_encoder *encoder = &ast->output.dp501.encoder; > - struct drm_connector *connector = &ast->output.dp501.connector; > + struct ast_connector *ast_connector = &ast->output.dp501.connector; > + struct drm_connector *connector = &ast_connector->base; > int ret; > > ret = drm_encoder_init(dev, encoder, &ast_dp501_encoder_funcs, > @@ -598,6 +604,7 @@ int ast_dp501_output_init(struct ast_device *ast) > ret = ast_dp501_connector_init(dev, connector); > if (ret) > return ret; > + ast_connector->physical_status = connector->status; > > ret = drm_connector_attach_encoder(connector, encoder); > if (ret) > diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h > index 3a4f80cb5c0f..b29625d45a11 100644 > --- a/drivers/gpu/drm/ast/ast_drv.h > +++ b/drivers/gpu/drm/ast/ast_drv.h > @@ -146,6 +146,22 @@ static inline struct ast_plane *to_ast_plane(struct drm_plane *plane) > return container_of(plane, struct ast_plane, base); > } > > +/* > + * Connector > + */ > + > +struct ast_connector { > + struct drm_connector base; > + > + enum drm_connector_status physical_status; > +}; > + > +static inline struct ast_connector * > +to_ast_connector(struct drm_connector *connector) > +{ > + return container_of(connector, struct ast_connector, base); > +} > + > /* > * BMC > */ > @@ -192,19 +208,19 @@ struct ast_device { > struct { > struct { > struct drm_encoder encoder; > - struct drm_connector connector; > + struct ast_connector connector; > } vga; > struct { > struct drm_encoder encoder; > - struct drm_connector connector; > + struct ast_connector connector; > } sil164; > struct { > struct drm_encoder encoder; > - struct drm_connector connector; > + struct ast_connector connector; > } dp501; > struct { > struct drm_encoder encoder; > - struct drm_connector connector; > + struct ast_connector connector; > } astdp; > struct { > struct drm_encoder encoder; > diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c > index d823e9d85b04..8ce1637268e1 100644 > --- a/drivers/gpu/drm/ast/ast_mode.c > +++ b/drivers/gpu/drm/ast/ast_mode.c > @@ -1502,25 +1502,25 @@ int ast_mode_config_init(struct ast_device *ast) > ret = ast_vga_output_init(ast); > if (ret) > return ret; > - physical_connector = &ast->output.vga.connector; > + physical_connector = &ast->output.vga.connector.base; > } > if (ast->tx_chip_types & AST_TX_SIL164_BIT) { > ret = ast_sil164_output_init(ast); > if (ret) > return ret; > - physical_connector = &ast->output.sil164.connector; > + physical_connector = &ast->output.sil164.connector.base; > } > if (ast->tx_chip_types & AST_TX_DP501_BIT) { > ret = ast_dp501_output_init(ast); > if (ret) > return ret; > - physical_connector = &ast->output.dp501.connector; > + physical_connector = &ast->output.dp501.connector.base; > } > if (ast->tx_chip_types & AST_TX_ASTDP_BIT) { > ret = ast_astdp_output_init(ast); > if (ret) > return ret; > - physical_connector = &ast->output.astdp.connector; > + physical_connector = &ast->output.astdp.connector.base; > } > ret = ast_bmc_output_init(ast, physical_connector); > if (ret) > diff --git a/drivers/gpu/drm/ast/ast_sil164.c b/drivers/gpu/drm/ast/ast_sil164.c > index 6e17d84f994e..05f991aa34ca 100644 > --- a/drivers/gpu/drm/ast/ast_sil164.c > +++ b/drivers/gpu/drm/ast/ast_sil164.c > @@ -21,9 +21,23 @@ static const struct drm_encoder_funcs ast_sil164_encoder_funcs = { > * Connector > */ > > +static int ast_sil164_connector_helper_detect_ctx(struct drm_connector *connector, > + struct drm_modeset_acquire_ctx *ctx, > + bool force) > +{ > + struct ast_connector *ast_connector = to_ast_connector(connector); > + enum drm_connector_status status; > + > + status = drm_connector_helper_detect_from_ddc(connector, ctx, force); > + > + ast_connector->physical_status = status; > + > + return status; > +} > + > static const struct drm_connector_helper_funcs ast_sil164_connector_helper_funcs = { > .get_modes = drm_connector_helper_get_modes, > - .detect_ctx = drm_connector_helper_detect_from_ddc, > + .detect_ctx = ast_sil164_connector_helper_detect_ctx, > }; > > static const struct drm_connector_funcs ast_sil164_connector_funcs = { > @@ -67,7 +81,8 @@ int ast_sil164_output_init(struct ast_device *ast) > struct drm_device *dev = &ast->base; > struct drm_crtc *crtc = &ast->crtc; > struct drm_encoder *encoder = &ast->output.sil164.encoder; > - struct drm_connector *connector = &ast->output.sil164.connector; > + struct ast_connector *ast_connector = &ast->output.sil164.connector; > + struct drm_connector *connector = &ast_connector->base; > int ret; > > ret = drm_encoder_init(dev, encoder, &ast_sil164_encoder_funcs, > @@ -79,6 +94,7 @@ int ast_sil164_output_init(struct ast_device *ast) > ret = ast_sil164_connector_init(dev, connector); > if (ret) > return ret; > + ast_connector->physical_status = connector->status; > > ret = drm_connector_attach_encoder(connector, encoder); > if (ret) > diff --git a/drivers/gpu/drm/ast/ast_vga.c b/drivers/gpu/drm/ast/ast_vga.c > index 2ea0763844f3..fdbd0daca7dc 100644 > --- a/drivers/gpu/drm/ast/ast_vga.c > +++ b/drivers/gpu/drm/ast/ast_vga.c > @@ -21,9 +21,23 @@ static const struct drm_encoder_funcs ast_vga_encoder_funcs = { > * Connector > */ > > +static int ast_vga_connector_helper_detect_ctx(struct drm_connector *connector, > + struct drm_modeset_acquire_ctx *ctx, > + bool force) > +{ > + struct ast_connector *ast_connector = to_ast_connector(connector); > + enum drm_connector_status status; > + > + status = drm_connector_helper_detect_from_ddc(connector, ctx, force); > + > + ast_connector->physical_status = status; > + > + return status; > +} > + > static const struct drm_connector_helper_funcs ast_vga_connector_helper_funcs = { > .get_modes = drm_connector_helper_get_modes, > - .detect_ctx = drm_connector_helper_detect_from_ddc, > + .detect_ctx = ast_vga_connector_helper_detect_ctx, > }; > > static const struct drm_connector_funcs ast_vga_connector_funcs = { > @@ -67,7 +81,8 @@ int ast_vga_output_init(struct ast_device *ast) > struct drm_device *dev = &ast->base; > struct drm_crtc *crtc = &ast->crtc; > struct drm_encoder *encoder = &ast->output.vga.encoder; > - struct drm_connector *connector = &ast->output.vga.connector; > + struct ast_connector *ast_connector = &ast->output.vga.connector; > + struct drm_connector *connector = &ast_connector->base; > int ret; > > ret = drm_encoder_init(dev, encoder, &ast_vga_encoder_funcs, > @@ -79,6 +94,7 @@ int ast_vga_output_init(struct ast_device *ast) > ret = ast_vga_connector_init(dev, connector); > if (ret) > return ret; > + ast_connector->physical_status = connector->status; > > ret = drm_connector_attach_encoder(connector, encoder); > if (ret)
diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c index 549c823c9529..c7f0f9b5dc3a 100644 --- a/drivers/gpu/drm/ast/ast_dp.c +++ b/drivers/gpu/drm/ast/ast_dp.c @@ -364,6 +364,7 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector struct drm_modeset_acquire_ctx *ctx, bool force) { + struct ast_connector *ast_connector = to_ast_connector(connector); struct drm_device *dev = connector->dev; struct ast_device *ast = to_ast_device(connector->dev); enum drm_connector_status status = connector_status_disconnected; @@ -392,6 +393,8 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector mutex_unlock(&ast->modeset_lock); + ast_connector->physical_status = status; + return status; } @@ -432,7 +435,8 @@ int ast_astdp_output_init(struct ast_device *ast) struct drm_device *dev = &ast->base; struct drm_crtc *crtc = &ast->crtc; struct drm_encoder *encoder = &ast->output.astdp.encoder; - struct drm_connector *connector = &ast->output.astdp.connector; + struct ast_connector *ast_connector = &ast->output.astdp.connector; + struct drm_connector *connector = &ast_connector->base; int ret; ret = drm_encoder_init(dev, encoder, &ast_astdp_encoder_funcs, @@ -446,6 +450,7 @@ int ast_astdp_output_init(struct ast_device *ast) ret = ast_astdp_connector_init(dev, connector); if (ret) return ret; + ast_connector->physical_status = connector->status; ret = drm_connector_attach_encoder(connector, encoder); if (ret) diff --git a/drivers/gpu/drm/ast/ast_dp501.c b/drivers/gpu/drm/ast/ast_dp501.c index 478efa226170..3904f98ef846 100644 --- a/drivers/gpu/drm/ast/ast_dp501.c +++ b/drivers/gpu/drm/ast/ast_dp501.c @@ -540,11 +540,16 @@ static int ast_dp501_connector_helper_detect_ctx(struct drm_connector *connector struct drm_modeset_acquire_ctx *ctx, bool force) { + struct ast_connector *ast_connector = to_ast_connector(connector); struct ast_device *ast = to_ast_device(connector->dev); + enum drm_connector_status status = connector_status_disconnected; if (ast_dp501_is_connected(ast)) return connector_status_connected; - return connector_status_disconnected; + + ast_connector->physical_status = status; + + return status; } static const struct drm_connector_helper_funcs ast_dp501_connector_helper_funcs = { @@ -584,7 +589,8 @@ int ast_dp501_output_init(struct ast_device *ast) struct drm_device *dev = &ast->base; struct drm_crtc *crtc = &ast->crtc; struct drm_encoder *encoder = &ast->output.dp501.encoder; - struct drm_connector *connector = &ast->output.dp501.connector; + struct ast_connector *ast_connector = &ast->output.dp501.connector; + struct drm_connector *connector = &ast_connector->base; int ret; ret = drm_encoder_init(dev, encoder, &ast_dp501_encoder_funcs, @@ -598,6 +604,7 @@ int ast_dp501_output_init(struct ast_device *ast) ret = ast_dp501_connector_init(dev, connector); if (ret) return ret; + ast_connector->physical_status = connector->status; ret = drm_connector_attach_encoder(connector, encoder); if (ret) diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index 3a4f80cb5c0f..b29625d45a11 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -146,6 +146,22 @@ static inline struct ast_plane *to_ast_plane(struct drm_plane *plane) return container_of(plane, struct ast_plane, base); } +/* + * Connector + */ + +struct ast_connector { + struct drm_connector base; + + enum drm_connector_status physical_status; +}; + +static inline struct ast_connector * +to_ast_connector(struct drm_connector *connector) +{ + return container_of(connector, struct ast_connector, base); +} + /* * BMC */ @@ -192,19 +208,19 @@ struct ast_device { struct { struct { struct drm_encoder encoder; - struct drm_connector connector; + struct ast_connector connector; } vga; struct { struct drm_encoder encoder; - struct drm_connector connector; + struct ast_connector connector; } sil164; struct { struct drm_encoder encoder; - struct drm_connector connector; + struct ast_connector connector; } dp501; struct { struct drm_encoder encoder; - struct drm_connector connector; + struct ast_connector connector; } astdp; struct { struct drm_encoder encoder; diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c index d823e9d85b04..8ce1637268e1 100644 --- a/drivers/gpu/drm/ast/ast_mode.c +++ b/drivers/gpu/drm/ast/ast_mode.c @@ -1502,25 +1502,25 @@ int ast_mode_config_init(struct ast_device *ast) ret = ast_vga_output_init(ast); if (ret) return ret; - physical_connector = &ast->output.vga.connector; + physical_connector = &ast->output.vga.connector.base; } if (ast->tx_chip_types & AST_TX_SIL164_BIT) { ret = ast_sil164_output_init(ast); if (ret) return ret; - physical_connector = &ast->output.sil164.connector; + physical_connector = &ast->output.sil164.connector.base; } if (ast->tx_chip_types & AST_TX_DP501_BIT) { ret = ast_dp501_output_init(ast); if (ret) return ret; - physical_connector = &ast->output.dp501.connector; + physical_connector = &ast->output.dp501.connector.base; } if (ast->tx_chip_types & AST_TX_ASTDP_BIT) { ret = ast_astdp_output_init(ast); if (ret) return ret; - physical_connector = &ast->output.astdp.connector; + physical_connector = &ast->output.astdp.connector.base; } ret = ast_bmc_output_init(ast, physical_connector); if (ret) diff --git a/drivers/gpu/drm/ast/ast_sil164.c b/drivers/gpu/drm/ast/ast_sil164.c index 6e17d84f994e..05f991aa34ca 100644 --- a/drivers/gpu/drm/ast/ast_sil164.c +++ b/drivers/gpu/drm/ast/ast_sil164.c @@ -21,9 +21,23 @@ static const struct drm_encoder_funcs ast_sil164_encoder_funcs = { * Connector */ +static int ast_sil164_connector_helper_detect_ctx(struct drm_connector *connector, + struct drm_modeset_acquire_ctx *ctx, + bool force) +{ + struct ast_connector *ast_connector = to_ast_connector(connector); + enum drm_connector_status status; + + status = drm_connector_helper_detect_from_ddc(connector, ctx, force); + + ast_connector->physical_status = status; + + return status; +} + static const struct drm_connector_helper_funcs ast_sil164_connector_helper_funcs = { .get_modes = drm_connector_helper_get_modes, - .detect_ctx = drm_connector_helper_detect_from_ddc, + .detect_ctx = ast_sil164_connector_helper_detect_ctx, }; static const struct drm_connector_funcs ast_sil164_connector_funcs = { @@ -67,7 +81,8 @@ int ast_sil164_output_init(struct ast_device *ast) struct drm_device *dev = &ast->base; struct drm_crtc *crtc = &ast->crtc; struct drm_encoder *encoder = &ast->output.sil164.encoder; - struct drm_connector *connector = &ast->output.sil164.connector; + struct ast_connector *ast_connector = &ast->output.sil164.connector; + struct drm_connector *connector = &ast_connector->base; int ret; ret = drm_encoder_init(dev, encoder, &ast_sil164_encoder_funcs, @@ -79,6 +94,7 @@ int ast_sil164_output_init(struct ast_device *ast) ret = ast_sil164_connector_init(dev, connector); if (ret) return ret; + ast_connector->physical_status = connector->status; ret = drm_connector_attach_encoder(connector, encoder); if (ret) diff --git a/drivers/gpu/drm/ast/ast_vga.c b/drivers/gpu/drm/ast/ast_vga.c index 2ea0763844f3..fdbd0daca7dc 100644 --- a/drivers/gpu/drm/ast/ast_vga.c +++ b/drivers/gpu/drm/ast/ast_vga.c @@ -21,9 +21,23 @@ static const struct drm_encoder_funcs ast_vga_encoder_funcs = { * Connector */ +static int ast_vga_connector_helper_detect_ctx(struct drm_connector *connector, + struct drm_modeset_acquire_ctx *ctx, + bool force) +{ + struct ast_connector *ast_connector = to_ast_connector(connector); + enum drm_connector_status status; + + status = drm_connector_helper_detect_from_ddc(connector, ctx, force); + + ast_connector->physical_status = status; + + return status; +} + static const struct drm_connector_helper_funcs ast_vga_connector_helper_funcs = { .get_modes = drm_connector_helper_get_modes, - .detect_ctx = drm_connector_helper_detect_from_ddc, + .detect_ctx = ast_vga_connector_helper_detect_ctx, }; static const struct drm_connector_funcs ast_vga_connector_funcs = { @@ -67,7 +81,8 @@ int ast_vga_output_init(struct ast_device *ast) struct drm_device *dev = &ast->base; struct drm_crtc *crtc = &ast->crtc; struct drm_encoder *encoder = &ast->output.vga.encoder; - struct drm_connector *connector = &ast->output.vga.connector; + struct ast_connector *ast_connector = &ast->output.vga.connector; + struct drm_connector *connector = &ast_connector->base; int ret; ret = drm_encoder_init(dev, encoder, &ast_vga_encoder_funcs, @@ -79,6 +94,7 @@ int ast_vga_output_init(struct ast_device *ast) ret = ast_vga_connector_init(dev, connector); if (ret) return ret; + ast_connector->physical_status = connector->status; ret = drm_connector_attach_encoder(connector, encoder); if (ret)
Add struct ast_connector to track a connector's physical status. With the upcoming BMC support, the physical status can be different from the reported status. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> --- drivers/gpu/drm/ast/ast_dp.c | 7 ++++++- drivers/gpu/drm/ast/ast_dp501.c | 11 +++++++++-- drivers/gpu/drm/ast/ast_drv.h | 24 ++++++++++++++++++++---- drivers/gpu/drm/ast/ast_mode.c | 8 ++++---- drivers/gpu/drm/ast/ast_sil164.c | 20 ++++++++++++++++++-- drivers/gpu/drm/ast/ast_vga.c | 20 ++++++++++++++++++-- 6 files changed, 75 insertions(+), 15 deletions(-)