Skip to content

Commit 80431c0

Browse files
committed
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
1 parent f6d9f39 commit 80431c0

6 files changed

Lines changed: 75 additions & 15 deletions

File tree

drivers/gpu/drm/ast/ast_dp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector
364364
struct drm_modeset_acquire_ctx *ctx,
365365
bool force)
366366
{
367+
struct ast_connector *ast_connector = to_ast_connector(connector);
367368
struct drm_device *dev = connector->dev;
368369
struct ast_device *ast = to_ast_device(connector->dev);
369370
enum drm_connector_status status = connector_status_disconnected;
@@ -392,6 +393,8 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector
392393

393394
mutex_unlock(&ast->modeset_lock);
394395

396+
ast_connector->physical_status = status;
397+
395398
return status;
396399
}
397400

@@ -432,7 +435,8 @@ int ast_astdp_output_init(struct ast_device *ast)
432435
struct drm_device *dev = &ast->base;
433436
struct drm_crtc *crtc = &ast->crtc;
434437
struct drm_encoder *encoder = &ast->output.astdp.encoder;
435-
struct drm_connector *connector = &ast->output.astdp.connector;
438+
struct ast_connector *ast_connector = &ast->output.astdp.connector;
439+
struct drm_connector *connector = &ast_connector->base;
436440
int ret;
437441

438442
ret = drm_encoder_init(dev, encoder, &ast_astdp_encoder_funcs,
@@ -446,6 +450,7 @@ int ast_astdp_output_init(struct ast_device *ast)
446450
ret = ast_astdp_connector_init(dev, connector);
447451
if (ret)
448452
return ret;
453+
ast_connector->physical_status = connector->status;
449454

450455
ret = drm_connector_attach_encoder(connector, encoder);
451456
if (ret)

drivers/gpu/drm/ast/ast_dp501.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,16 @@ static int ast_dp501_connector_helper_detect_ctx(struct drm_connector *connector
540540
struct drm_modeset_acquire_ctx *ctx,
541541
bool force)
542542
{
543+
struct ast_connector *ast_connector = to_ast_connector(connector);
543544
struct ast_device *ast = to_ast_device(connector->dev);
545+
enum drm_connector_status status = connector_status_disconnected;
544546

545547
if (ast_dp501_is_connected(ast))
546548
return connector_status_connected;
547-
return connector_status_disconnected;
549+
550+
ast_connector->physical_status = status;
551+
552+
return status;
548553
}
549554

550555
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)
584589
struct drm_device *dev = &ast->base;
585590
struct drm_crtc *crtc = &ast->crtc;
586591
struct drm_encoder *encoder = &ast->output.dp501.encoder;
587-
struct drm_connector *connector = &ast->output.dp501.connector;
592+
struct ast_connector *ast_connector = &ast->output.dp501.connector;
593+
struct drm_connector *connector = &ast_connector->base;
588594
int ret;
589595

590596
ret = drm_encoder_init(dev, encoder, &ast_dp501_encoder_funcs,
@@ -598,6 +604,7 @@ int ast_dp501_output_init(struct ast_device *ast)
598604
ret = ast_dp501_connector_init(dev, connector);
599605
if (ret)
600606
return ret;
607+
ast_connector->physical_status = connector->status;
601608

602609
ret = drm_connector_attach_encoder(connector, encoder);
603610
if (ret)

drivers/gpu/drm/ast/ast_drv.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,22 @@ static inline struct ast_plane *to_ast_plane(struct drm_plane *plane)
146146
return container_of(plane, struct ast_plane, base);
147147
}
148148

149+
/*
150+
* Connector
151+
*/
152+
153+
struct ast_connector {
154+
struct drm_connector base;
155+
156+
enum drm_connector_status physical_status;
157+
};
158+
159+
static inline struct ast_connector *
160+
to_ast_connector(struct drm_connector *connector)
161+
{
162+
return container_of(connector, struct ast_connector, base);
163+
}
164+
149165
/*
150166
* BMC
151167
*/
@@ -192,19 +208,19 @@ struct ast_device {
192208
struct {
193209
struct {
194210
struct drm_encoder encoder;
195-
struct drm_connector connector;
211+
struct ast_connector connector;
196212
} vga;
197213
struct {
198214
struct drm_encoder encoder;
199-
struct drm_connector connector;
215+
struct ast_connector connector;
200216
} sil164;
201217
struct {
202218
struct drm_encoder encoder;
203-
struct drm_connector connector;
219+
struct ast_connector connector;
204220
} dp501;
205221
struct {
206222
struct drm_encoder encoder;
207-
struct drm_connector connector;
223+
struct ast_connector connector;
208224
} astdp;
209225
struct {
210226
struct drm_encoder encoder;

drivers/gpu/drm/ast/ast_mode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,25 +1502,25 @@ int ast_mode_config_init(struct ast_device *ast)
15021502
ret = ast_vga_output_init(ast);
15031503
if (ret)
15041504
return ret;
1505-
physical_connector = &ast->output.vga.connector;
1505+
physical_connector = &ast->output.vga.connector.base;
15061506
}
15071507
if (ast->tx_chip_types & AST_TX_SIL164_BIT) {
15081508
ret = ast_sil164_output_init(ast);
15091509
if (ret)
15101510
return ret;
1511-
physical_connector = &ast->output.sil164.connector;
1511+
physical_connector = &ast->output.sil164.connector.base;
15121512
}
15131513
if (ast->tx_chip_types & AST_TX_DP501_BIT) {
15141514
ret = ast_dp501_output_init(ast);
15151515
if (ret)
15161516
return ret;
1517-
physical_connector = &ast->output.dp501.connector;
1517+
physical_connector = &ast->output.dp501.connector.base;
15181518
}
15191519
if (ast->tx_chip_types & AST_TX_ASTDP_BIT) {
15201520
ret = ast_astdp_output_init(ast);
15211521
if (ret)
15221522
return ret;
1523-
physical_connector = &ast->output.astdp.connector;
1523+
physical_connector = &ast->output.astdp.connector.base;
15241524
}
15251525
ret = ast_bmc_output_init(ast, physical_connector);
15261526
if (ret)

drivers/gpu/drm/ast/ast_sil164.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,23 @@ static const struct drm_encoder_funcs ast_sil164_encoder_funcs = {
2121
* Connector
2222
*/
2323

24+
static int ast_sil164_connector_helper_detect_ctx(struct drm_connector *connector,
25+
struct drm_modeset_acquire_ctx *ctx,
26+
bool force)
27+
{
28+
struct ast_connector *ast_connector = to_ast_connector(connector);
29+
enum drm_connector_status status;
30+
31+
status = drm_connector_helper_detect_from_ddc(connector, ctx, force);
32+
33+
ast_connector->physical_status = status;
34+
35+
return status;
36+
}
37+
2438
static const struct drm_connector_helper_funcs ast_sil164_connector_helper_funcs = {
2539
.get_modes = drm_connector_helper_get_modes,
26-
.detect_ctx = drm_connector_helper_detect_from_ddc,
40+
.detect_ctx = ast_sil164_connector_helper_detect_ctx,
2741
};
2842

2943
static const struct drm_connector_funcs ast_sil164_connector_funcs = {
@@ -67,7 +81,8 @@ int ast_sil164_output_init(struct ast_device *ast)
6781
struct drm_device *dev = &ast->base;
6882
struct drm_crtc *crtc = &ast->crtc;
6983
struct drm_encoder *encoder = &ast->output.sil164.encoder;
70-
struct drm_connector *connector = &ast->output.sil164.connector;
84+
struct ast_connector *ast_connector = &ast->output.sil164.connector;
85+
struct drm_connector *connector = &ast_connector->base;
7186
int ret;
7287

7388
ret = drm_encoder_init(dev, encoder, &ast_sil164_encoder_funcs,
@@ -79,6 +94,7 @@ int ast_sil164_output_init(struct ast_device *ast)
7994
ret = ast_sil164_connector_init(dev, connector);
8095
if (ret)
8196
return ret;
97+
ast_connector->physical_status = connector->status;
8298

8399
ret = drm_connector_attach_encoder(connector, encoder);
84100
if (ret)

drivers/gpu/drm/ast/ast_vga.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,23 @@ static const struct drm_encoder_funcs ast_vga_encoder_funcs = {
2121
* Connector
2222
*/
2323

24+
static int ast_vga_connector_helper_detect_ctx(struct drm_connector *connector,
25+
struct drm_modeset_acquire_ctx *ctx,
26+
bool force)
27+
{
28+
struct ast_connector *ast_connector = to_ast_connector(connector);
29+
enum drm_connector_status status;
30+
31+
status = drm_connector_helper_detect_from_ddc(connector, ctx, force);
32+
33+
ast_connector->physical_status = status;
34+
35+
return status;
36+
}
37+
2438
static const struct drm_connector_helper_funcs ast_vga_connector_helper_funcs = {
2539
.get_modes = drm_connector_helper_get_modes,
26-
.detect_ctx = drm_connector_helper_detect_from_ddc,
40+
.detect_ctx = ast_vga_connector_helper_detect_ctx,
2741
};
2842

2943
static const struct drm_connector_funcs ast_vga_connector_funcs = {
@@ -67,7 +81,8 @@ int ast_vga_output_init(struct ast_device *ast)
6781
struct drm_device *dev = &ast->base;
6882
struct drm_crtc *crtc = &ast->crtc;
6983
struct drm_encoder *encoder = &ast->output.vga.encoder;
70-
struct drm_connector *connector = &ast->output.vga.connector;
84+
struct ast_connector *ast_connector = &ast->output.vga.connector;
85+
struct drm_connector *connector = &ast_connector->base;
7186
int ret;
7287

7388
ret = drm_encoder_init(dev, encoder, &ast_vga_encoder_funcs,
@@ -79,6 +94,7 @@ int ast_vga_output_init(struct ast_device *ast)
7994
ret = ast_vga_connector_init(dev, connector);
8095
if (ret)
8196
return ret;
97+
ast_connector->physical_status = connector->status;
8298

8399
ret = drm_connector_attach_encoder(connector, encoder);
84100
if (ret)

0 commit comments

Comments
 (0)