Skip to content

Commit 9aed3a4

Browse files
author
Thomas Zimmermann
committed
drm/ast: astdp: Store mode index in connector state
Look up the mode index for the astdp transmitter ship in the encoder's atomic check and report an error if the display mode is not supported. The lookup uses the DRM display mode instead of the driver's internal VBIOS mode. Both are equivalent. The modesetting code later reads the calculated index from the connector state to avoid recalculating it. v2: - fix typo in commit message (Jocelyn) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250204133209.403327-4-tzimmermann@suse.de
1 parent 8c3b7d2 commit 9aed3a4

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

drivers/gpu/drm/ast/ast_dp.c

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <linux/firmware.h>
66
#include <linux/delay.h>
77

8+
#include <drm/drm_atomic.h>
89
#include <drm/drm_atomic_state_helper.h>
910
#include <drm/drm_edid.h>
1011
#include <drm/drm_modeset_helper_vtables.h>
@@ -44,6 +45,8 @@ static const struct ast_astdp_mode_index_table_entry ast_astdp_mode_index_table[
4445

4546
struct ast_astdp_connector_state {
4647
struct drm_connector_state base;
48+
49+
int mode_index;
4750
};
4851

4952
static struct ast_astdp_connector_state *
@@ -305,14 +308,12 @@ static void ast_astdp_encoder_helper_atomic_mode_set(struct drm_encoder *encoder
305308
struct ast_device *ast = to_ast_device(dev);
306309
struct ast_crtc_state *ast_crtc_state = to_ast_crtc_state(crtc_state);
307310
const struct ast_vbios_enhtable *vmode = ast_crtc_state->vmode;
308-
int mode_index;
311+
struct ast_astdp_connector_state *astdp_conn_state =
312+
to_ast_astdp_connector_state(conn_state);
313+
int mode_index = astdp_conn_state->mode_index;
309314
u8 refresh_rate_index;
310315
u8 vgacre0, vgacre1, vgacre2;
311316

312-
mode_index = ast_astdp_get_mode_index(vmode->hde, vmode->vde);
313-
if (drm_WARN_ON(dev, mode_index < 0))
314-
return;
315-
316317
if (drm_WARN_ON(dev, vmode->refresh_rate_index < 1 || vmode->refresh_rate_index > 255))
317318
return;
318319
refresh_rate_index = vmode->refresh_rate_index - 1;
@@ -368,10 +369,30 @@ static void ast_astdp_encoder_helper_atomic_disable(struct drm_encoder *encoder,
368369
ast_dp_set_phy_sleep(ast, true);
369370
}
370371

372+
static int ast_astdp_encoder_helper_atomic_check(struct drm_encoder *encoder,
373+
struct drm_crtc_state *crtc_state,
374+
struct drm_connector_state *conn_state)
375+
{
376+
const struct drm_display_mode *mode = &crtc_state->mode;
377+
struct ast_astdp_connector_state *astdp_conn_state =
378+
to_ast_astdp_connector_state(conn_state);
379+
int res;
380+
381+
if (drm_atomic_crtc_needs_modeset(crtc_state)) {
382+
res = ast_astdp_get_mode_index(mode->hdisplay, mode->vdisplay);
383+
if (res < 0)
384+
return res;
385+
astdp_conn_state->mode_index = res;
386+
}
387+
388+
return 0;
389+
}
390+
371391
static const struct drm_encoder_helper_funcs ast_astdp_encoder_helper_funcs = {
372392
.atomic_mode_set = ast_astdp_encoder_helper_atomic_mode_set,
373393
.atomic_enable = ast_astdp_encoder_helper_atomic_enable,
374394
.atomic_disable = ast_astdp_encoder_helper_atomic_disable,
395+
.atomic_check = ast_astdp_encoder_helper_atomic_check,
375396
};
376397

377398
/*
@@ -459,7 +480,7 @@ static void ast_astdp_connector_reset(struct drm_connector *connector)
459480
static struct drm_connector_state *
460481
ast_astdp_connector_atomic_duplicate_state(struct drm_connector *connector)
461482
{
462-
struct ast_astdp_connector_state *new_astdp_state;
483+
struct ast_astdp_connector_state *new_astdp_state, *astdp_state;
463484
struct drm_device *dev = connector->dev;
464485

465486
if (drm_WARN_ON(dev, !connector->state))
@@ -470,6 +491,10 @@ ast_astdp_connector_atomic_duplicate_state(struct drm_connector *connector)
470491
return NULL;
471492
__drm_atomic_helper_connector_duplicate_state(connector, &new_astdp_state->base);
472493

494+
astdp_state = to_ast_astdp_connector_state(connector->state);
495+
496+
new_astdp_state->mode_index = astdp_state->mode_index;
497+
473498
return &new_astdp_state->base;
474499
}
475500

0 commit comments

Comments
 (0)