diff options
author | Thomas Zimmermann <tzimmermann@suse.de> | 2025-02-04 14:26:38 +0100 |
---|---|---|
committer | Thomas Zimmermann <tzimmermann@suse.de> | 2025-02-11 08:28:30 +0100 |
commit | 8c3b7d278ffc4d30b0809d1b7066a94963a0d2ca (patch) | |
tree | ba02705f1db30bb38a3edebf8b191b09502eb568 | |
parent | 3214403cf99e20d8ee7df9cd639e6a152b0659fc (diff) |
drm/ast: astdp: Inline mode-index calculation
Programming the astdp transmitter chip requires a magic value for
individual modes. Inline the helper for calculating the value into
its only caller (i.e., the encoder's atomic_mode_set).
With further refactoring, the atomic check will be able to detect
invalid modes before attempting to program them.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250204133209.403327-3-tzimmermann@suse.de
-rw-r--r-- | drivers/gpu/drm/ast/ast_dp.c | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c index a9c20b3fc190..c03bd400949a 100644 --- a/drivers/gpu/drm/ast/ast_dp.c +++ b/drivers/gpu/drm/ast/ast_dp.c @@ -52,7 +52,7 @@ to_ast_astdp_connector_state(const struct drm_connector_state *state) return container_of(state, struct ast_astdp_connector_state, base); } -static int __ast_astdp_get_mode_index(unsigned int hdisplay, unsigned int vdisplay) +static int ast_astdp_get_mode_index(unsigned int hdisplay, unsigned int vdisplay) { const struct ast_astdp_mode_index_table_entry *entry = ast_astdp_mode_index_table; @@ -65,35 +65,6 @@ static int __ast_astdp_get_mode_index(unsigned int hdisplay, unsigned int vdispl return -EINVAL; } -static int ast_astdp_get_mode_index(const struct ast_vbios_enhtable *vmode) -{ - int mode_index; - u8 refresh_rate_index; - - mode_index = __ast_astdp_get_mode_index(vmode->hde, vmode->vde); - if (mode_index < 0) - return mode_index; - - if (vmode->refresh_rate_index < 1 || vmode->refresh_rate_index > 255) - return -EINVAL; - refresh_rate_index = vmode->refresh_rate_index - 1; - - /* FIXME: Why are we doing this? */ - switch (mode_index) { - case ASTDP_1280x800_60_RB: - case ASTDP_1440x900_60_RB: - case ASTDP_1600x900_60_RB: - case ASTDP_1680x1050_60_RB: - mode_index = (u8)(mode_index - (u8)refresh_rate_index); - break; - default: - mode_index = (u8)(mode_index + (u8)refresh_rate_index); - break; - } - - return mode_index; -} - static bool ast_astdp_is_connected(struct ast_device *ast) { if (!ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDF, AST_IO_VGACRDF_HPD)) @@ -333,13 +304,32 @@ static void ast_astdp_encoder_helper_atomic_mode_set(struct drm_encoder *encoder struct drm_device *dev = encoder->dev; struct ast_device *ast = to_ast_device(dev); struct ast_crtc_state *ast_crtc_state = to_ast_crtc_state(crtc_state); + const struct ast_vbios_enhtable *vmode = ast_crtc_state->vmode; int mode_index; + u8 refresh_rate_index; u8 vgacre0, vgacre1, vgacre2; - mode_index = ast_astdp_get_mode_index(ast_crtc_state->vmode); + mode_index = ast_astdp_get_mode_index(vmode->hde, vmode->vde); if (drm_WARN_ON(dev, mode_index < 0)) return; + if (drm_WARN_ON(dev, vmode->refresh_rate_index < 1 || vmode->refresh_rate_index > 255)) + return; + refresh_rate_index = vmode->refresh_rate_index - 1; + + /* FIXME: Why are we doing this? */ + switch (mode_index) { + case ASTDP_1280x800_60_RB: + case ASTDP_1440x900_60_RB: + case ASTDP_1600x900_60_RB: + case ASTDP_1680x1050_60_RB: + mode_index = (u8)(mode_index - (u8)refresh_rate_index); + break; + default: + mode_index = (u8)(mode_index + (u8)refresh_rate_index); + break; + } + /* * CRE0[7:0]: MISC0 ((0x00: 18-bpp) or (0x20: 24-bpp) * CRE1[7:0]: MISC1 (default: 0x00) |