drm/ast: Add struct ast_connector

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>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240815151953.184679-3-tzimmermann@suse.de
This commit is contained in:
Thomas Zimmermann 2024-08-15 17:18:44 +02:00
parent f6d9f39f8d
commit 80431c017f
6 changed files with 75 additions and 15 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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)

View File

@ -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)

View File

@ -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)