Message ID | 20250129095840.20629-7-tzimmermann@suse.de (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | drm/ast: Clean up display-mode detection and validation | expand |
On 29/01/2025 10:54, Thomas Zimmermann wrote: > Detect support for 1920x1200 (WUXGA) in ast_detect_widescreen(). The > flag is cleared by default. The test logic has been taken from existing > code in ast_crtc_helper_mode_valid(). The code in that function is being > replaced by the new flag. > > v2: > - move shared detection code into helper (Jocelyn) Thanks, it looks good to me. Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> > > Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> > --- > drivers/gpu/drm/ast/ast_drv.h | 1 + > drivers/gpu/drm/ast/ast_main.c | 27 +++++++++++++++++++++++++++ > drivers/gpu/drm/ast/ast_mode.c | 8 +++----- > drivers/gpu/drm/ast/ast_reg.h | 1 + > 4 files changed, 32 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h > index 01ef0c0d5db7d..4e3a88f8a85ca 100644 > --- a/drivers/gpu/drm/ast/ast_drv.h > +++ b/drivers/gpu/drm/ast/ast_drv.h > @@ -207,6 +207,7 @@ struct ast_device { > > bool support_wsxga_p; /* 1680x1050 */ > bool support_fullhd; /* 1920x1080 */ > + bool support_wuxga; /* 1920x1200 */ > > u8 *dp501_fw_addr; > const struct firmware *dp501_fw; /* dp501 fw */ > diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c > index 6e964a0714b4b..44b9b5f659fc8 100644 > --- a/drivers/gpu/drm/ast/ast_main.c > +++ b/drivers/gpu/drm/ast/ast_main.c > @@ -49,14 +49,31 @@ static bool __ast_2100_detect_wsxga_p(struct ast_device *ast) > return false; > } > > +/* Try to detect WUXGA on Gen2+ */ > +static bool __ast_2100_detect_wuxga(struct ast_device *ast) > +{ > + u8 vgacrd1; > + > + if (ast->support_fullhd) { > + vgacrd1 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xd1); > + if (!(vgacrd1 & AST_IO_VGACRD1_SUPPORTS_WUXGA)) > + return true; > + } > + > + return false; > +} > + > static void ast_detect_widescreen(struct ast_device *ast) > { > ast->support_wsxga_p = false; > ast->support_fullhd = false; > + ast->support_wuxga = false; > > if (AST_GEN(ast) >= 7) { > ast->support_wsxga_p = true; > ast->support_fullhd = true; > + if (__ast_2100_detect_wuxga(ast)) > + ast->support_wuxga = true; > } else if (AST_GEN(ast) >= 6) { > if (__ast_2100_detect_wsxga_p(ast)) > ast->support_wsxga_p = true; > @@ -64,6 +81,8 @@ static void ast_detect_widescreen(struct ast_device *ast) > ast->support_wsxga_p = true; > if (ast->support_wsxga_p) > ast->support_fullhd = true; > + if (__ast_2100_detect_wuxga(ast)) > + ast->support_wuxga = true; > } else if (AST_GEN(ast) >= 5) { > if (__ast_2100_detect_wsxga_p(ast)) > ast->support_wsxga_p = true; > @@ -71,6 +90,8 @@ static void ast_detect_widescreen(struct ast_device *ast) > ast->support_wsxga_p = true; > if (ast->support_wsxga_p) > ast->support_fullhd = true; > + if (__ast_2100_detect_wuxga(ast)) > + ast->support_wuxga = true; > } else if (AST_GEN(ast) >= 4) { > if (__ast_2100_detect_wsxga_p(ast)) > ast->support_wsxga_p = true; > @@ -78,6 +99,8 @@ static void ast_detect_widescreen(struct ast_device *ast) > ast->support_wsxga_p = true; > if (ast->support_wsxga_p) > ast->support_fullhd = true; > + if (__ast_2100_detect_wuxga(ast)) > + ast->support_wuxga = true; > } else if (AST_GEN(ast) >= 3) { > if (__ast_2100_detect_wsxga_p(ast)) > ast->support_wsxga_p = true; > @@ -85,6 +108,8 @@ static void ast_detect_widescreen(struct ast_device *ast) > if (ast->chip == AST2200) > ast->support_fullhd = true; > } > + if (__ast_2100_detect_wuxga(ast)) > + ast->support_wuxga = true; > } else if (AST_GEN(ast) >= 2) { > if (__ast_2100_detect_wsxga_p(ast)) > ast->support_wsxga_p = true; > @@ -92,6 +117,8 @@ static void ast_detect_widescreen(struct ast_device *ast) > if (ast->chip == AST2100) > ast->support_fullhd = true; > } > + if (__ast_2100_detect_wuxga(ast)) > + ast->support_wuxga = true; > } > } > > diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c > index dda2c4fb0a48b..bc0c7db5ad46e 100644 > --- a/drivers/gpu/drm/ast/ast_mode.c > +++ b/drivers/gpu/drm/ast/ast_mode.c > @@ -1022,7 +1022,6 @@ ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode > { > struct ast_device *ast = to_ast_device(crtc->dev); > enum drm_mode_status status; > - uint32_t jtemp; > > if (ast->support_wsxga_p) { > if ((mode->hdisplay == 1680) && (mode->vdisplay == 1050)) > @@ -1041,11 +1040,10 @@ ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode > return MODE_OK; > > if ((mode->hdisplay == 1920) && (mode->vdisplay == 1200)) { > - jtemp = ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xd1, 0xff); > - if (jtemp & 0x01) > - return MODE_NOMODE; > - else > + if (ast->support_wuxga) > return MODE_OK; > + else > + return MODE_NOMODE; > } > } > } > diff --git a/drivers/gpu/drm/ast/ast_reg.h b/drivers/gpu/drm/ast/ast_reg.h > index b4ff38949a565..9db0d584652a4 100644 > --- a/drivers/gpu/drm/ast/ast_reg.h > +++ b/drivers/gpu/drm/ast/ast_reg.h > @@ -55,6 +55,7 @@ > #define AST_IO_VGACRD1_TX_ANX9807_VBIOS 0x0a > #define AST_IO_VGACRD1_TX_FW_EMBEDDED_FW 0x0c /* special case of DP501 */ > #define AST_IO_VGACRD1_TX_ASTDP 0x0e > +#define AST_IO_VGACRD1_SUPPORTS_WUXGA BIT(0) > > #define AST_IO_VGACRD7_EDID_VALID_FLAG BIT(0) > #define AST_IO_VGACRDC_LINK_SUCCESS BIT(0)
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index 01ef0c0d5db7d..4e3a88f8a85ca 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -207,6 +207,7 @@ struct ast_device { bool support_wsxga_p; /* 1680x1050 */ bool support_fullhd; /* 1920x1080 */ + bool support_wuxga; /* 1920x1200 */ u8 *dp501_fw_addr; const struct firmware *dp501_fw; /* dp501 fw */ diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index 6e964a0714b4b..44b9b5f659fc8 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -49,14 +49,31 @@ static bool __ast_2100_detect_wsxga_p(struct ast_device *ast) return false; } +/* Try to detect WUXGA on Gen2+ */ +static bool __ast_2100_detect_wuxga(struct ast_device *ast) +{ + u8 vgacrd1; + + if (ast->support_fullhd) { + vgacrd1 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xd1); + if (!(vgacrd1 & AST_IO_VGACRD1_SUPPORTS_WUXGA)) + return true; + } + + return false; +} + static void ast_detect_widescreen(struct ast_device *ast) { ast->support_wsxga_p = false; ast->support_fullhd = false; + ast->support_wuxga = false; if (AST_GEN(ast) >= 7) { ast->support_wsxga_p = true; ast->support_fullhd = true; + if (__ast_2100_detect_wuxga(ast)) + ast->support_wuxga = true; } else if (AST_GEN(ast) >= 6) { if (__ast_2100_detect_wsxga_p(ast)) ast->support_wsxga_p = true; @@ -64,6 +81,8 @@ static void ast_detect_widescreen(struct ast_device *ast) ast->support_wsxga_p = true; if (ast->support_wsxga_p) ast->support_fullhd = true; + if (__ast_2100_detect_wuxga(ast)) + ast->support_wuxga = true; } else if (AST_GEN(ast) >= 5) { if (__ast_2100_detect_wsxga_p(ast)) ast->support_wsxga_p = true; @@ -71,6 +90,8 @@ static void ast_detect_widescreen(struct ast_device *ast) ast->support_wsxga_p = true; if (ast->support_wsxga_p) ast->support_fullhd = true; + if (__ast_2100_detect_wuxga(ast)) + ast->support_wuxga = true; } else if (AST_GEN(ast) >= 4) { if (__ast_2100_detect_wsxga_p(ast)) ast->support_wsxga_p = true; @@ -78,6 +99,8 @@ static void ast_detect_widescreen(struct ast_device *ast) ast->support_wsxga_p = true; if (ast->support_wsxga_p) ast->support_fullhd = true; + if (__ast_2100_detect_wuxga(ast)) + ast->support_wuxga = true; } else if (AST_GEN(ast) >= 3) { if (__ast_2100_detect_wsxga_p(ast)) ast->support_wsxga_p = true; @@ -85,6 +108,8 @@ static void ast_detect_widescreen(struct ast_device *ast) if (ast->chip == AST2200) ast->support_fullhd = true; } + if (__ast_2100_detect_wuxga(ast)) + ast->support_wuxga = true; } else if (AST_GEN(ast) >= 2) { if (__ast_2100_detect_wsxga_p(ast)) ast->support_wsxga_p = true; @@ -92,6 +117,8 @@ static void ast_detect_widescreen(struct ast_device *ast) if (ast->chip == AST2100) ast->support_fullhd = true; } + if (__ast_2100_detect_wuxga(ast)) + ast->support_wuxga = true; } } diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c index dda2c4fb0a48b..bc0c7db5ad46e 100644 --- a/drivers/gpu/drm/ast/ast_mode.c +++ b/drivers/gpu/drm/ast/ast_mode.c @@ -1022,7 +1022,6 @@ ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode { struct ast_device *ast = to_ast_device(crtc->dev); enum drm_mode_status status; - uint32_t jtemp; if (ast->support_wsxga_p) { if ((mode->hdisplay == 1680) && (mode->vdisplay == 1050)) @@ -1041,11 +1040,10 @@ ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode return MODE_OK; if ((mode->hdisplay == 1920) && (mode->vdisplay == 1200)) { - jtemp = ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xd1, 0xff); - if (jtemp & 0x01) - return MODE_NOMODE; - else + if (ast->support_wuxga) return MODE_OK; + else + return MODE_NOMODE; } } } diff --git a/drivers/gpu/drm/ast/ast_reg.h b/drivers/gpu/drm/ast/ast_reg.h index b4ff38949a565..9db0d584652a4 100644 --- a/drivers/gpu/drm/ast/ast_reg.h +++ b/drivers/gpu/drm/ast/ast_reg.h @@ -55,6 +55,7 @@ #define AST_IO_VGACRD1_TX_ANX9807_VBIOS 0x0a #define AST_IO_VGACRD1_TX_FW_EMBEDDED_FW 0x0c /* special case of DP501 */ #define AST_IO_VGACRD1_TX_ASTDP 0x0e +#define AST_IO_VGACRD1_SUPPORTS_WUXGA BIT(0) #define AST_IO_VGACRD7_EDID_VALID_FLAG BIT(0) #define AST_IO_VGACRDC_LINK_SUCCESS BIT(0)
Detect support for 1920x1200 (WUXGA) in ast_detect_widescreen(). The flag is cleared by default. The test logic has been taken from existing code in ast_crtc_helper_mode_valid(). The code in that function is being replaced by the new flag. v2: - move shared detection code into helper (Jocelyn) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> --- drivers/gpu/drm/ast/ast_drv.h | 1 + drivers/gpu/drm/ast/ast_main.c | 27 +++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_mode.c | 8 +++----- drivers/gpu/drm/ast/ast_reg.h | 1 + 4 files changed, 32 insertions(+), 5 deletions(-)