drm/ast: Clean up display-mode detection and validation
Subsystems (3)
Thomas Zimmermann
maintainercover drm/ast: Clean up display-mode detection and validation
The ast driver detects support for display modes from hardware features and internal mode tables. Streamline the detection code and put all validation into a single place.
Patches 1 to 6 refactor the code for detecting support for widescreen modes. Regular 4:3 modes are supported by all hardware Gens; support for widescreen modes differs among hardware Gens and individual boards. The series moves all hardware-related code into a single helper function that set state flags accordingly. Other places within the driver then refer to these flags.
Building up this, patches 7 to 15 refactor display-mode validation. The ast driver contains a list of display modes supported by the VBIOS. The series changes the driver to validate DRM display modes against the VBIOS modes.
Tested on various hardware Gens and display modes.
Thomas Zimmermann (15):
drm/ast: Remove 1152x864 from list of widescreen resolutions drm/ast: Align naming in widescreen detection code to manual drm/ast: Reorganize widescreen test around hardware Gens drm/ast: Rename support_widescreen to support_wsxga_p drm/ast: Add support_fullhd flag to struct ast_device drm/ast: Add support_wuxga flag to struct ast_device drm/ast: Always validate H/V sync flags
drm/ast: Find VBIOS mode from regular display size drm/ast: Add empty initializer for VBIOS modes drm/ast: Add helpers for VBIOS mode lookup drm/ast: Validate DRM display modes against VBIOS modes drm/ast: Inline ast_get_vbios_mode_info()
drm/ast: astdp: Rework display-mode setting drm/ast: Remove struct ast_vbios_mode_info drm/ast: Only look up VBIOS mode on full modesets
drivers/gpu/drm/ast/Makefile | 1 + drivers/gpu/drm/ast/ast_dp.c | 174 +++++++++-------- drivers/gpu/drm/ast/ast_drv.c | 2 +- drivers/gpu/drm/ast/ast_drv.h | 30 +-- drivers/gpu/drm/ast/ast_main.c | 108 ++++++++--- drivers/gpu/drm/ast/ast_mode.c | 308 +++++++++---------------------- drivers/gpu/drm/ast/ast_post.c | 2 +- drivers/gpu/drm/ast/ast_reg.h | 30 ++- drivers/gpu/drm/ast/ast_tables.h | 187 +------------------ drivers/gpu/drm/ast/ast_vbios.c | 261 ++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_vbios.h | 108 +++++++++++ 11 files changed, 659 insertions(+), 552 deletions(-) create mode 100644 drivers/gpu/drm/ast/ast_vbios.c create mode 100644 drivers/gpu/drm/ast/ast_vbios.h
base-commit: 9afc49c1b29a25d9efba5e29e43c9ce3986e569c
Signature · 1 line
2.47.1
Thomas Zimmermann
maintainerPATCH 1/15 drm/ast: Remove 1152x864 from list of widescreen resolutions
The resolution 1152x864 has a ratio of 4:3 and is already handled as such. Remove it from the list of widescreen resolutions.
--- drivers/gpu/drm/ast/ast_mode.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +0 -2
@@ -1035,8 +1035,6 @@ ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_modereturn MODE_OK ;if ((mode->hdisplay ==1600 ) && (mode->vdisplay ==900 ))return MODE_OK ; -if ((mode->hdisplay ==1152 ) && (mode->vdisplay ==864 )) -return MODE_OK ; if ((ast->chip == AST2100) || // GEN2, but not AST1100 (?) (ast->chip == AST2200) || // GEN3, but not AST2150 (?)
Signature · 1 line
2.47.1
Re: [PATCH 01/15] drm/ast: Remove 1152x864 from list of widescreen resolutions
Quoted 2 lines · Thomas Zimmermann
The resolution 1152x864 has a ratio of 4:3 and is already handled as such. Remove it from the list of widescreen resolutions.
Thanks, yes it's redundant.
Quoted 19 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 2 -- 1 file changed, 2 deletions(-)drivers/gpu/drm/ast/ast_mode.c +0
-2@@ -1035,8 +1035,6 @@ ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_modereturn MODE_OK ;if ((mode->hdisplay ==1600 ) && (mode->vdisplay ==900 ))return MODE_OK ; -if ((mode->hdisplay ==1152 ) && (mode->vdisplay ==864 )) -return MODE_OK ; if ((ast->chip == AST2100) || // GEN2, but not AST1100 (?) (ast->chip == AST2200) || // GEN3, but not AST2150 (?)
Thomas Zimmermann
maintainerPATCH 2/15 drm/ast: Align naming in widescreen detection code to manual
In reply to Thomas ZimmermannRename variables and register constants to align with the programming manual. Add new constants where necessary.
--- drivers/gpu/drm/ast/ast_drv.c | 2 +- drivers/gpu/drm/ast/ast_main.c | 8 ++++---- drivers/gpu/drm/ast/ast_post.c | 2 +- drivers/gpu/drm/ast/ast_reg.h | 11 ++++++----- 4 files changed, 12 insertions(+), 11 deletions(-)
drivers/gpu/drm/ast/ast_drv.c +1 -1
@@ -170,7 +170,7 @@ static int ast_detect_chip(struct pci_dev *pdev,/* Patch AST2500/AST2510 */ if ((pdev->revision &0xf0 ) ==0x40 ) { -if (!(vgacrd0 &AST_VRAM_INIT_STATUS_MASK )) +if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_STATUS_MASK ))ast_patch_ahb_2500 (regs); }
drivers/gpu/drm/ast/ast_main.c +4 -4
@@ -38,7 +38,7 @@static void ast_detect_widescreen (struct ast_device *ast) { -u8 jreg; +u8 vgacrd0;/* Check if we support wide screen */ switch (AST_GEN (ast)) {
@@ -46,10 +46,10 @@ static void ast_detect_widescreen(struct ast_device *ast) ast->support_wide_screen = false;break ;default : - jreg =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xd0 ,0xff ); -if (!(jreg &0x80 )) + vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 ); +if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) ast->support_wide_screen = true; -else if (jreg &0x01 ) +else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) ast->support_wide_screen = true;else { ast->support_wide_screen = false;
drivers/gpu/drm/ast/ast_post.c +1 -1
@@ -2062,7 +2062,7 @@ void ast_post_chip_2500(struct ast_device *ast)u8 reg; reg =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xd0 ,0xff ); -if ((reg &AST_VRAM_INIT_STATUS_MASK ) ==0 ) {/* vga only */ +if ((reg &AST_IO_VGACRD0_VRAM_INIT_STATUS_MASK ) ==0 ) {/* vga only */ /* Clear bus lock condition */ ast_patch_ahb_2500 (ast->regs);
drivers/gpu/drm/ast/ast_reg.h +6 -5
@@ -38,6 +38,12 @@#define AST_IO_VGACRCB_HWC_16BPP BIT(0)/* set: ARGB4444, cleared: 2bpp palette */ #define AST_IO_VGACRCB_HWC_ENABLED BIT(1) +/* mirrors SCU100[7:0] */ +#define AST_IO_VGACRD0_VRAM_INIT_STATUS_MASK GENMASK(7, 6) +#define AST_IO_VGACRD0_VRAM_INIT_BY_BMC BIT(7) +#define AST_IO_VGACRD0_VRAM_INIT_READY BIT(6) +#define AST_IO_VGACRD0_IKVM_WIDESCREEN BIT(0) +#define AST_IO_VGACRD1_MCU_FW_EXECUTING BIT(5)/* Display Transmitter Type */ #define AST_IO_VGACRD1_TX_TYPE_MASK GENMASK(3, 1)
@@ -61,11 +67,6 @@#define AST_IO_VGAIR1_R (0x5A)#define AST_IO_VGAIR1_VREFRESH BIT(3) - -#define AST_VRAM_INIT_STATUS_MASK GENMASK(7, 6) -//#define AST_VRAM_INIT_BY_BMC BIT(7) -//#define AST_VRAM_INIT_READY BIT(6) -/* * AST DisplayPort */
Signature · 1 line
2.47.1
Re: [PATCH 02/15] drm/ast: Align naming in widescreen detection code to manual
Quoted 2 lines · Thomas Zimmermann
Rename variables and register constants to align with the programming manual. Add new constants where necessary.
Thanks, it looks good to me.
Quoted 91 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_drv.c | 2 +- drivers/gpu/drm/ast/ast_main.c | 8 ++++---- drivers/gpu/drm/ast/ast_post.c | 2 +- drivers/gpu/drm/ast/ast_reg.h | 11 ++++++----- 4 files changed, 12 insertions(+), 11 deletions(-)drivers/gpu/drm/ast/ast_drv.c +1
-1@@ -170,7 +170,7 @@ static int ast_detect_chip(struct pci_dev *pdev,/* Patch AST2500/AST2510 */ if ((pdev->revision &0xf0 ) ==0x40 ) { -if (!(vgacrd0 &AST_VRAM_INIT_STATUS_MASK )) +if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_STATUS_MASK ))ast_patch_ahb_2500 (regs); }drivers/gpu/drm/ast/ast_main.c +4
-4@@ -38,7 +38,7 @@static void ast_detect_widescreen (struct ast_device *ast) { -u8 jreg; +u8 vgacrd0;/* Check if we support wide screen */ switch (AST_GEN (ast)) {@@ -46,10 +46,10 @@ static void ast_detect_widescreen(struct ast_device *ast) ast->support_wide_screen = false;break ;default : - jreg =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xd0 ,0xff ); -if (!(jreg &0x80 )) + vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 ); +if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) ast->support_wide_screen = true; -else if (jreg &0x01 ) +else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) ast->support_wide_screen = true;else { ast->support_wide_screen = false;drivers/gpu/drm/ast/ast_post.c +1
-1@@ -2062,7 +2062,7 @@ void ast_post_chip_2500(struct ast_device *ast)u8 reg; reg =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xd0 ,0xff ); -if ((reg &AST_VRAM_INIT_STATUS_MASK ) ==0 ) {/* vga only */ +if ((reg &AST_IO_VGACRD0_VRAM_INIT_STATUS_MASK ) ==0 ) {/* vga only */ /* Clear bus lock condition */ ast_patch_ahb_2500 (ast->regs);drivers/gpu/drm/ast/ast_reg.h +6
-5@@ -38,6 +38,12 @@#define AST_IO_VGACRCB_HWC_16BPP BIT(0)/* set: ARGB4444, cleared: 2bpp palette */ #define AST_IO_VGACRCB_HWC_ENABLED BIT(1) +/* mirrors SCU100[7:0] */ +#define AST_IO_VGACRD0_VRAM_INIT_STATUS_MASK GENMASK(7, 6) +#define AST_IO_VGACRD0_VRAM_INIT_BY_BMC BIT(7) +#define AST_IO_VGACRD0_VRAM_INIT_READY BIT(6) +#define AST_IO_VGACRD0_IKVM_WIDESCREEN BIT(0) +#define AST_IO_VGACRD1_MCU_FW_EXECUTING BIT(5)/* Display Transmitter Type */ #define AST_IO_VGACRD1_TX_TYPE_MASK GENMASK(3, 1)@@ -61,11 +67,6 @@#define AST_IO_VGAIR1_R (0x5A)#define AST_IO_VGAIR1_VREFRESH BIT(3) - -#define AST_VRAM_INIT_STATUS_MASK GENMASK(7, 6) -//#define AST_VRAM_INIT_BY_BMC BIT(7) -//#define AST_VRAM_INIT_READY BIT(6) -/* * AST DisplayPort */
Thomas Zimmermann
maintainerPATCH 3/15 drm/ast: Reorganize widescreen test around hardware Gens
In reply to Thomas ZimmermannTesting for support of widescreen modes mixes up various hardware Gens. First branch by hardware Gen, then do specific tests for each Gen. By default, widesscreen support is disabled.
Later patches will add more specific tests for each Gen.
--- drivers/gpu/drm/ast/ast_main.c | 47 +++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 18 deletions(-)
drivers/gpu/drm/ast/ast_main.c +29 -18
@@ -40,29 +40,40 @@ static void ast_detect_widescreen(struct ast_device *ast) {u8 vgacrd0; -/* Check if we support wide screen */ -switch (AST_GEN (ast)) { -case 1 : - ast->support_wide_screen = false; -break ; -default : + ast->support_wide_screen = false; + +if (AST_GEN (ast) >=7 ) { + ast->support_wide_screen = true; + }else if (AST_GEN (ast) >=6 ) { + vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 ); +if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) + ast->support_wide_screen = true; +else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) + ast->support_wide_screen = true; +else if (ast->chip ==AST2510 ) + ast->support_wide_screen = true; + }else if (AST_GEN (ast) >=5 ) { + vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 ); +if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) + ast->support_wide_screen = true; +else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) + ast->support_wide_screen = true; +else if (ast->chip ==AST1400 ) + ast->support_wide_screen = true; + }else if (AST_GEN (ast) >=4 ) { + vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 ); +if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) + ast->support_wide_screen = true; +else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) + ast->support_wide_screen = true; +else if (ast->chip ==AST1300 ) + ast->support_wide_screen = true; + }else if (AST_GEN (ast) >=2 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) ast->support_wide_screen = true;else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) ast->support_wide_screen = true; -else { - ast->support_wide_screen = false; -if (ast->chip ==AST1300 ) - ast->support_wide_screen = true; -if (ast->chip ==AST1400 ) - ast->support_wide_screen = true; -if (ast->chip ==AST2510 ) - ast->support_wide_screen = true; -if (IS_AST_GEN7 (ast)) - ast->support_wide_screen = true; - } -break ; } }
Signature · 1 line
2.47.1
Jocelyn Falempe
reviewerRe: [PATCH 03/15] drm/ast: Reorganize widescreen test around hardware Gens
Quoted 5 lines · Thomas Zimmermann
Testing for support of widescreen modes mixes up various hardware Gens. First branch by hardware Gen, then do specific tests for each Gen. By default, widesscreen support is disabled.
Later patches will add more specific tests for each Gen.
I think it introduces a bit too much repeated code.
Maybe adding a small helper like this would help?
static bool ast_vgacrd0_support_wuxga(struct ast_device *ast) {
u8 vgacrd0;
vgacrd0 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xd0);
return !(vgacrd0 & AST_IO_VGACRD0_VRAM_INIT_BY_BMC) ||
(vgacrd0 & AST_IO_VGACRD0_IKVM_WIDESCREEN));
}Signature · 1 line
Jocelyn
Quoted 69 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_main.c | 47 +++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 18 deletions(-)drivers/gpu/drm/ast/ast_main.c +29
-18@@ -40,29 +40,40 @@ static void ast_detect_widescreen(struct ast_device *ast) {u8 vgacrd0; -/* Check if we support wide screen */ -switch (AST_GEN (ast)) { -case 1 : - ast->support_wide_screen = false; -break ; -default : + ast->support_wide_screen = false; + +if (AST_GEN (ast) >=7 ) { + ast->support_wide_screen = true; + }else if (AST_GEN (ast) >=6 ) { + vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 ); +if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) + ast->support_wide_screen = true; +else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) + ast->support_wide_screen = true; +else if (ast->chip ==AST2510 ) + ast->support_wide_screen = true; + }else if (AST_GEN (ast) >=5 ) { + vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 ); +if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) + ast->support_wide_screen = true; +else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) + ast->support_wide_screen = true; +else if (ast->chip ==AST1400 ) + ast->support_wide_screen = true; + }else if (AST_GEN (ast) >=4 ) { + vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 ); +if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) + ast->support_wide_screen = true; +else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) + ast->support_wide_screen = true; +else if (ast->chip ==AST1300 ) + ast->support_wide_screen = true; + }else if (AST_GEN (ast) >=2 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) ast->support_wide_screen = true;else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) ast->support_wide_screen = true; -else { - ast->support_wide_screen = false; -if (ast->chip ==AST1300 ) - ast->support_wide_screen = true; -if (ast->chip ==AST1400 ) - ast->support_wide_screen = true; -if (ast->chip ==AST2510 ) - ast->support_wide_screen = true; -if (IS_AST_GEN7 (ast)) - ast->support_wide_screen = true; - } -break ; } }
Thomas Zimmermann
maintainerRe: [PATCH 03/15] drm/ast: Reorganize widescreen test around hardware Gens
Hi Jocelyn
Am 27.01.25 um 15:26 schrieb Jocelyn Falempe:
Quoted 10 lines · Thomas Zimmermann
Quoted 5 lines
Testing for support of widescreen modes mixes up various hardware Gens. First branch by hardware Gen, then do specific tests for each Gen. By default, widesscreen support is disabled.
Later patches will add more specific tests for each Gen.
I think it introduces a bit too much repeated code.
Maybe adding a small helper like this would help?
I'll add a helper here and for the code in patch 6
Best regards
Thomas
Quoted 8 lines
static bool
ast_vgacrd0_support_wuxga(struct ast_device *ast){ u8 vgacrd0;
vgacrd0 =ast_get_index_reg(ast, AST_IO_VGACRI, 0xd0); return !(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC) || (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN)); }
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Thomas Zimmermann
maintainerPATCH 4/15 drm/ast: Rename support_widescreen to support_wsxga_p
In reply to Thomas ZimmermannThe flag support_widescreen in struct ast_device selects devices that support resolutions of at least 1680x1050 (WSXGA+). Name it accordingly.
--- drivers/gpu/drm/ast/ast_drv.h | 2 +- drivers/gpu/drm/ast/ast_main.c | 26 +++++++++++++------------- drivers/gpu/drm/ast/ast_mode.c | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-)
drivers/gpu/drm/ast/ast_drv.h +1 -1
@@ -205,7 +205,7 @@ struct ast_device { } astdp; } output; -bool support_wide_screen; +bool support_wsxga_p;/* 1680x1050 */ u8 *dp501_fw_addr;const struct firmware *dp501_fw;/* dp501 fw */
drivers/gpu/drm/ast/ast_main.c +13 -13
@@ -40,40 +40,40 @@ static void ast_detect_widescreen(struct ast_device *ast) {u8 vgacrd0; - ast->support_wide_screen = false; + ast->support_wsxga_p = false;if (AST_GEN (ast) >=7 ) { - ast->support_wide_screen = true; + ast->support_wsxga_p = true; }else if (AST_GEN (ast) >=6 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) - ast->support_wide_screen = true; + ast->support_wsxga_p = true;else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) - ast->support_wide_screen = true; + ast->support_wsxga_p = true;else if (ast->chip ==AST2510 ) - ast->support_wide_screen = true; + ast->support_wsxga_p = true; }else if (AST_GEN (ast) >=5 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) - ast->support_wide_screen = true; + ast->support_wsxga_p = true;else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) - ast->support_wide_screen = true; + ast->support_wsxga_p = true;else if (ast->chip ==AST1400 ) - ast->support_wide_screen = true; + ast->support_wsxga_p = true; }else if (AST_GEN (ast) >=4 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) - ast->support_wide_screen = true; + ast->support_wsxga_p = true;else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) - ast->support_wide_screen = true; + ast->support_wsxga_p = true;else if (ast->chip ==AST1300 ) - ast->support_wide_screen = true; + ast->support_wsxga_p = true; }else if (AST_GEN (ast) >=2 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) - ast->support_wide_screen = true; + ast->support_wsxga_p = true;else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) - ast->support_wide_screen = true; + ast->support_wsxga_p = true; } }
drivers/gpu/drm/ast/ast_mode.c +1 -1
@@ -1024,7 +1024,7 @@ ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_modeenum drm_mode_status status;uint32_t jtemp; -if (ast->support_wide_screen) { +if (ast->support_wsxga_p) {if ((mode->hdisplay ==1680 ) && (mode->vdisplay ==1050 ))return MODE_OK ;if ((mode->hdisplay ==1280 ) && (mode->vdisplay ==800 ))
Signature · 1 line
2.47.1
Re: [PATCH 04/15] drm/ast: Rename support_widescreen to support_wsxga_p
Quoted 2 lines · Thomas Zimmermann
The flag
support_widescreenin structast_deviceselects devices that support resolutions of at least 1680x1050 (WSXGA+). Name it accordingly.
Thanks, it looks good to me.
Quoted 92 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_drv.h | 2 +- drivers/gpu/drm/ast/ast_main.c | 26 +++++++++++++------------- drivers/gpu/drm/ast/ast_mode.c | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-)drivers/gpu/drm/ast/ast_drv.h +1
-1@@ -205,7 +205,7 @@ struct ast_device { } astdp; } output; -bool support_wide_screen; +bool support_wsxga_p;/* 1680x1050 */ u8 *dp501_fw_addr;const struct firmware *dp501_fw;/* dp501 fw */ drivers/gpu/drm/ast/ast_main.c +13
-13@@ -40,40 +40,40 @@ static void ast_detect_widescreen(struct ast_device *ast) {u8 vgacrd0; - ast->support_wide_screen = false; + ast->support_wsxga_p = false;if (AST_GEN (ast) >=7 ) { - ast->support_wide_screen = true; + ast->support_wsxga_p = true; }else if (AST_GEN (ast) >=6 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) - ast->support_wide_screen = true; + ast->support_wsxga_p = true;else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) - ast->support_wide_screen = true; + ast->support_wsxga_p = true;else if (ast->chip ==AST2510 ) - ast->support_wide_screen = true; + ast->support_wsxga_p = true; }else if (AST_GEN (ast) >=5 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) - ast->support_wide_screen = true; + ast->support_wsxga_p = true;else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) - ast->support_wide_screen = true; + ast->support_wsxga_p = true;else if (ast->chip ==AST1400 ) - ast->support_wide_screen = true; + ast->support_wsxga_p = true; }else if (AST_GEN (ast) >=4 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) - ast->support_wide_screen = true; + ast->support_wsxga_p = true;else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) - ast->support_wide_screen = true; + ast->support_wsxga_p = true;else if (ast->chip ==AST1300 ) - ast->support_wide_screen = true; + ast->support_wsxga_p = true; }else if (AST_GEN (ast) >=2 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) - ast->support_wide_screen = true; + ast->support_wsxga_p = true;else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) - ast->support_wide_screen = true; + ast->support_wsxga_p = true; } }drivers/gpu/drm/ast/ast_mode.c +1
-1@@ -1024,7 +1024,7 @@ ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_modeenum drm_mode_status status;uint32_t jtemp; -if (ast->support_wide_screen) { +if (ast->support_wsxga_p) {if ((mode->hdisplay ==1680 ) && (mode->vdisplay ==1050 ))return MODE_OK ;if ((mode->hdisplay ==1280 ) && (mode->vdisplay ==800 ))
Thomas Zimmermann
maintainerPATCH 5/15 drm/ast: Add support_fullhd flag to struct ast_device
In reply to Thomas ZimmermannDetect support for 1920x1080 (FullHD) 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.
For Gen3, a new branch duplicates the Gen2 logic and adds a test for AST2200. Gen2 adds a test for AST2100.
--- drivers/gpu/drm/ast/ast_drv.h | 1 + drivers/gpu/drm/ast/ast_main.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/ast/ast_mode.c | 5 +---- 3 files changed, 24 insertions(+), 4 deletions(-)
drivers/gpu/drm/ast/ast_drv.h +1 -0
@@ -206,6 +206,7 @@ struct ast_device { } output;bool support_wsxga_p;/* 1680x1050 */ +bool support_fullhd;/* 1920x1080 */ u8 *dp501_fw_addr;const struct firmware *dp501_fw;/* dp501 fw */
drivers/gpu/drm/ast/ast_main.c +22 -0
@@ -41,9 +41,11 @@ static void ast_detect_widescreen(struct ast_device *ast)u8 vgacrd0; ast->support_wsxga_p = false; + ast->support_fullhd = false;if (AST_GEN (ast) >=7 ) { ast->support_wsxga_p = true; + ast->support_fullhd = true; }else if (AST_GEN (ast) >=6 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))
@@ -52,6 +54,8 @@ static void ast_detect_widescreen(struct ast_device *ast) ast->support_wsxga_p = true; else if (ast->chip == AST2510) ast->support_wsxga_p = true; +if (ast->support_wsxga_p) + ast->support_fullhd = true; }else if (AST_GEN (ast) >=5 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))
@@ -60,6 +64,8 @@ static void ast_detect_widescreen(struct ast_device *ast) ast->support_wsxga_p = true; else if (ast->chip == AST1400) ast->support_wsxga_p = true; +if (ast->support_wsxga_p) + ast->support_fullhd = true; }else if (AST_GEN (ast) >=4 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))
@@ -68,12 +74,28 @@ static void ast_detect_widescreen(struct ast_device *ast) ast->support_wsxga_p = true; else if (ast->chip == AST1300) ast->support_wsxga_p = true; +if (ast->support_wsxga_p) + ast->support_fullhd = true; + }else if (AST_GEN (ast) >=3 ) { + vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 ); +if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) + ast->support_wsxga_p = true; +else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) + ast->support_wsxga_p = true; +if (ast->support_wsxga_p) { +if (ast->chip ==AST2200 ) + ast->support_fullhd = true; + } }else if (AST_GEN (ast) >=2 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) ast->support_wsxga_p = true;else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) ast->support_wsxga_p = true; +if (ast->support_wsxga_p) { +if (ast->chip ==AST2100 ) + ast->support_fullhd = true; + } } }
drivers/gpu/drm/ast/ast_mode.c +1 -4
@@ -1036,10 +1036,7 @@ ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_modeif ((mode->hdisplay ==1600 ) && (mode->vdisplay ==900 ))return MODE_OK ; -if ((ast->chip ==AST2100 ) ||// GEN2, but not AST1100 (?) - (ast->chip ==AST2200 ) ||// GEN3, but not AST2150 (?) -IS_AST_GEN4 (ast) ||IS_AST_GEN5 (ast) || -IS_AST_GEN6 (ast) ||IS_AST_GEN7 (ast)) { +if (ast->support_fullhd) {if ((mode->hdisplay ==1920 ) && (mode->vdisplay ==1080 ))return MODE_OK ;
Signature · 1 line
2.47.1
Re: [PATCH 05/15] drm/ast: Add support_fullhd flag to struct ast_device
Quoted 7 lines · Thomas Zimmermann
Detect support for 1920x1080 (FullHD) in
ast_detect_widescreen(). The flag is cleared by default. The test logic has been taken from existing code inast_crtc_helper_mode_valid(). The code in that function is being replaced by the new flag.For Gen3, a new branch duplicates the Gen2 logic and adds a test for AST2200. Gen2 adds a test for AST2100.
Thanks, it looks good to me.
Quoted 99 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_drv.h | 1 + drivers/gpu/drm/ast/ast_main.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/ast/ast_mode.c | 5 +---- 3 files changed, 24 insertions(+), 4 deletions(-)drivers/gpu/drm/ast/ast_drv.h +1
-0@@ -206,6 +206,7 @@ struct ast_device { } output;bool support_wsxga_p;/* 1680x1050 */ +bool support_fullhd;/* 1920x1080 */ u8 *dp501_fw_addr;const struct firmware *dp501_fw;/* dp501 fw */ drivers/gpu/drm/ast/ast_main.c +22
-0@@ -41,9 +41,11 @@ static void ast_detect_widescreen(struct ast_device *ast)u8 vgacrd0; ast->support_wsxga_p = false; + ast->support_fullhd = false;if (AST_GEN (ast) >=7 ) { ast->support_wsxga_p = true; + ast->support_fullhd = true; }else if (AST_GEN (ast) >=6 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))@@ -52,6 +54,8 @@ static void ast_detect_widescreen(struct ast_device *ast) ast->support_wsxga_p = true; else if (ast->chip == AST2510) ast->support_wsxga_p = true; +if (ast->support_wsxga_p) + ast->support_fullhd = true; }else if (AST_GEN (ast) >=5 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))@@ -60,6 +64,8 @@ static void ast_detect_widescreen(struct ast_device *ast) ast->support_wsxga_p = true; else if (ast->chip == AST1400) ast->support_wsxga_p = true; +if (ast->support_wsxga_p) + ast->support_fullhd = true; }else if (AST_GEN (ast) >=4 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))@@ -68,12 +74,28 @@ static void ast_detect_widescreen(struct ast_device *ast) ast->support_wsxga_p = true; else if (ast->chip == AST1300) ast->support_wsxga_p = true; +if (ast->support_wsxga_p) + ast->support_fullhd = true; + }else if (AST_GEN (ast) >=3 ) { + vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 ); +if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) + ast->support_wsxga_p = true; +else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) + ast->support_wsxga_p = true; +if (ast->support_wsxga_p) { +if (ast->chip ==AST2200 ) + ast->support_fullhd = true; + } }else if (AST_GEN (ast) >=2 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC )) ast->support_wsxga_p = true;else if (vgacrd0 &AST_IO_VGACRD0_IKVM_WIDESCREEN ) ast->support_wsxga_p = true; +if (ast->support_wsxga_p) { +if (ast->chip ==AST2100 ) + ast->support_fullhd = true; + } } }drivers/gpu/drm/ast/ast_mode.c +1
-4@@ -1036,10 +1036,7 @@ ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_modeif ((mode->hdisplay ==1600 ) && (mode->vdisplay ==900 ))return MODE_OK ; -if ((ast->chip ==AST2100 ) ||// GEN2, but not AST1100 (?) - (ast->chip ==AST2200 ) ||// GEN3, but not AST2150 (?) -IS_AST_GEN4 (ast) ||IS_AST_GEN5 (ast) || -IS_AST_GEN6 (ast) ||IS_AST_GEN7 (ast)) { +if (ast->support_fullhd) {if ((mode->hdisplay ==1920 ) && (mode->vdisplay ==1080 ))return MODE_OK ;
Thomas Zimmermann
maintainerPATCH 6/15 drm/ast: Add support_wuxga flag to struct ast_device
In reply to Thomas ZimmermannDetect 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.
--- drivers/gpu/drm/ast/ast_drv.h | 1 + drivers/gpu/drm/ast/ast_main.c | 31 ++++++++++++++++++++++++++++++- drivers/gpu/drm/ast/ast_mode.c | 8 +++----- drivers/gpu/drm/ast/ast_reg.h | 1 + 4 files changed, 35 insertions(+), 6 deletions(-)
drivers/gpu/drm/ast/ast_drv.h +1 -0
@@ -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 */
drivers/gpu/drm/ast/ast_main.c +30 -1
@@ -38,14 +38,18 @@static void ast_detect_widescreen (struct ast_device *ast) { -u8 vgacrd0; +u8 vgacrd0, vgacrd1; 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; + vgacrd1 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd1 ); +if (!(vgacrd1 &AST_IO_VGACRD1_SUPPORTS_WUXGA )) + ast->support_wuxga = true; }else if (AST_GEN (ast) >=6 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))
@@ -56,6 +60,11 @@ 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->support_fullhd) { + vgacrd1 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd1 ); +if (!(vgacrd1 &AST_IO_VGACRD1_SUPPORTS_WUXGA )) + ast->support_wuxga = true; + } }else if (AST_GEN (ast) >=5 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))
@@ -66,6 +75,11 @@ 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->support_fullhd) { + vgacrd1 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd1 ); +if (!(vgacrd1 &AST_IO_VGACRD1_SUPPORTS_WUXGA )) + ast->support_wuxga = true; + } }else if (AST_GEN (ast) >=4 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))
@@ -76,6 +90,11 @@ 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->support_fullhd) { + vgacrd1 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd1 ); +if (!(vgacrd1 &AST_IO_VGACRD1_SUPPORTS_WUXGA )) + ast->support_wuxga = true; + } }else if (AST_GEN (ast) >=3 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))
@@ -86,6 +105,11 @@ static void ast_detect_widescreen(struct ast_device *ast)if (ast->chip ==AST2200 ) ast->support_fullhd = true; } +if (ast->support_fullhd) { + vgacrd1 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd1 ); +if (!(vgacrd1 &AST_IO_VGACRD1_SUPPORTS_WUXGA )) + ast->support_wuxga = true; + } }else if (AST_GEN (ast) >=2 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))
@@ -96,6 +120,11 @@ static void ast_detect_widescreen(struct ast_device *ast)if (ast->chip ==AST2100 ) ast->support_fullhd = true; } +if (ast->support_fullhd) { + vgacrd1 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd1 ); +if (!(vgacrd1 &AST_IO_VGACRD1_SUPPORTS_WUXGA )) + ast->support_wuxga = true; + } } }
drivers/gpu/drm/ast/ast_mode.c +3 -5
@@ -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_modereturn 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 ; } } }
drivers/gpu/drm/ast/ast_reg.h +1 -0
@@ -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)
Signature · 1 line
2.47.1
Jocelyn Falempe
reviewerRe: [PATCH 06/15] drm/ast: Add support_wuxga flag to struct ast_device
Quoted 4 lines · Thomas Zimmermann
Detect support for 1920x1200 (WUXGA) in
ast_detect_widescreen(). The flag is cleared by default. The test logic has been taken from existing code inast_crtc_helper_mode_valid(). The code in that function is being replaced by the new flag.
I think adding a small helper would help here too:
static bool ast_vgacrd1_support_wuxga(struct ast_device *ast) {
u8 vgacrd1;
vgacrd1 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xd1);
return !(vgacrd1 & AST_IO_VGACRD1_SUPPORTS_WUXGA);
}Best regards,
Signature · 1 line
Jocelyn
Quoted 144 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_drv.h | 1 + drivers/gpu/drm/ast/ast_main.c | 31 ++++++++++++++++++++++++++++++- drivers/gpu/drm/ast/ast_mode.c | 8 +++----- drivers/gpu/drm/ast/ast_reg.h | 1 + 4 files changed, 35 insertions(+), 6 deletions(-)drivers/gpu/drm/ast/ast_drv.h +1
-0@@ -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 */ drivers/gpu/drm/ast/ast_main.c +30
-1@@ -38,14 +38,18 @@static void ast_detect_widescreen (struct ast_device *ast) { -u8 vgacrd0; +u8 vgacrd0, vgacrd1; 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; + vgacrd1 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd1 ); +if (!(vgacrd1 &AST_IO_VGACRD1_SUPPORTS_WUXGA )) + ast->support_wuxga = true; }else if (AST_GEN (ast) >=6 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))@@ -56,6 +60,11 @@ 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->support_fullhd) { + vgacrd1 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd1 ); +if (!(vgacrd1 &AST_IO_VGACRD1_SUPPORTS_WUXGA )) + ast->support_wuxga = true; + } }else if (AST_GEN (ast) >=5 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))@@ -66,6 +75,11 @@ 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->support_fullhd) { + vgacrd1 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd1 ); +if (!(vgacrd1 &AST_IO_VGACRD1_SUPPORTS_WUXGA )) + ast->support_wuxga = true; + } }else if (AST_GEN (ast) >=4 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))@@ -76,6 +90,11 @@ 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->support_fullhd) { + vgacrd1 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd1 ); +if (!(vgacrd1 &AST_IO_VGACRD1_SUPPORTS_WUXGA )) + ast->support_wuxga = true; + } }else if (AST_GEN (ast) >=3 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))@@ -86,6 +105,11 @@ static void ast_detect_widescreen(struct ast_device *ast)if (ast->chip ==AST2200 ) ast->support_fullhd = true; } +if (ast->support_fullhd) { + vgacrd1 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd1 ); +if (!(vgacrd1 &AST_IO_VGACRD1_SUPPORTS_WUXGA )) + ast->support_wuxga = true; + } }else if (AST_GEN (ast) >=2 ) { vgacrd0 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd0 );if (!(vgacrd0 &AST_IO_VGACRD0_VRAM_INIT_BY_BMC ))@@ -96,6 +120,11 @@ static void ast_detect_widescreen(struct ast_device *ast)if (ast->chip ==AST2100 ) ast->support_fullhd = true; } +if (ast->support_fullhd) { + vgacrd1 =ast_get_index_reg (ast,AST_IO_VGACRI ,0xd1 ); +if (!(vgacrd1 &AST_IO_VGACRD1_SUPPORTS_WUXGA )) + ast->support_wuxga = true; + } } }drivers/gpu/drm/ast/ast_mode.c +3
-5@@ -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_modereturn 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 ; } } }drivers/gpu/drm/ast/ast_reg.h +1
-0@@ -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)
Thomas Zimmermann
maintainerPATCH 7/15 drm/ast: Always validate H/V sync flags
In reply to Thomas ZimmermannThe ast driver matches DRM display modes against an internal list of modes supported by the VBIOS. Matching H/V sync flags between modes is preferred, but optional. If sync flags are not matching, the driver would program the VBIOS settings to hardware and let the display handle the difference.
DRM modes are generated from attached displays or standard mode lines. Therefore differences to the VBIOS modes are not just cosmetical, but signal possible incompatibility with the display hardware.
Hence make matching H/V sync flags mandatory. If the VBIOS does not support a certain mode, we should report it as unsupported. Note that the VBIOS mode tables all appear to refer to standard modes.
(If sync flags really make no difference to the VBIOS, the ast driver shouldn't match them in the first place.)
--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++-------------------- 1 file changed, 18 insertions(+), 27 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +18 -27
@@ -113,8 +113,8 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, {u32 refresh_rate_index =0 , refresh_rate;const struct ast_vbios_enhtable *best =NULL ; +const struct ast_vbios_enhtable *loop;u32 hborder, vborder; -bool check_sync;switch (format->cpp[0 ] *8 ) {case 8 :
@@ -176,36 +176,27 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, } refresh_rate =drm_mode_vrefresh (mode); - check_sync = vbios_mode->enh_table->flags & WideScreenMode; - -while (1 ) { -const struct ast_vbios_enhtable *loop = vbios_mode->enh_table; - -while (loop->refresh_rate !=0xff ) { -if ((check_sync) && - (((mode->flags &DRM_MODE_FLAG_NVSYNC ) && - (loop->flags & PVSync)) || - ((mode->flags &DRM_MODE_FLAG_PVSYNC ) && - (loop->flags & NVSync)) || - ((mode->flags &DRM_MODE_FLAG_NHSYNC ) && - (loop->flags & PHSync)) || - ((mode->flags &DRM_MODE_FLAG_PHSYNC ) && - (loop->flags & NHSync)))) { - loop++; -continue ; - } -if (loop->refresh_rate <= refresh_rate - && (!best || loop->refresh_rate > best->refresh_rate)) - best = loop; + + loop = vbios_mode->enh_table; + +while (loop->refresh_rate !=0xff ) { +if (((mode->flags &DRM_MODE_FLAG_NVSYNC ) && (loop->flags & PVSync)) || + ((mode->flags &DRM_MODE_FLAG_PVSYNC ) && (loop->flags & NVSync)) || + ((mode->flags &DRM_MODE_FLAG_NHSYNC ) && (loop->flags & PHSync)) || + ((mode->flags &DRM_MODE_FLAG_PHSYNC ) && (loop->flags & NHSync))) { loop++; +continue ; } -if (best || !check_sync) -break ; - check_sync =0 ; +if (loop->refresh_rate <= refresh_rate && + (!best || loop->refresh_rate > best->refresh_rate)) + best = loop; + loop++; } -if (best) - vbios_mode->enh_table = best; +if (!best) +return false; + + vbios_mode->enh_table = best; hborder = (vbios_mode->enh_table->flags & HBorder) ?8 :0 ; vborder = (vbios_mode->enh_table->flags & VBorder) ?8 :0 ;
Signature · 1 line
2.47.1
Re: [PATCH 07/15] drm/ast: Always validate H/V sync flags
Quoted 10 lines · Thomas Zimmermann
The ast driver matches DRM display modes against an internal list of modes supported by the VBIOS. Matching H/V sync flags between modes is preferred, but optional. If sync flags are not matching, the driver would program the VBIOS settings to hardware and let the display handle the difference.
DRM modes are generated from attached displays or standard mode lines. Therefore differences to the VBIOS modes are not just cosmetical, but signal possible incompatibility with the display hardware.
Quoted 6 lines
Hence make matching H/V sync flags mandatory. If the VBIOS does not support a certain mode, we should report it as unsupported. Note that the VBIOS mode tables all appear to refer to standard modes.
(If sync flags really make no difference to the VBIOS, the ast driver shouldn't match them in the first place.)
Thanks, it looks good to me.
Signature · 1 line
Jocelyn
Quoted 74 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++-------------------- 1 file changed, 18 insertions(+), 27 deletions(-)drivers/gpu/drm/ast/ast_mode.c +18
-27@@ -113,8 +113,8 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, {u32 refresh_rate_index =0 , refresh_rate;const struct ast_vbios_enhtable *best =NULL ; +const struct ast_vbios_enhtable *loop;u32 hborder, vborder; -bool check_sync;switch (format->cpp[0 ] *8 ) {case 8 :@@ -176,36 +176,27 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, } refresh_rate =drm_mode_vrefresh (mode); - check_sync = vbios_mode->enh_table->flags & WideScreenMode; - -while (1 ) { -const struct ast_vbios_enhtable *loop = vbios_mode->enh_table; - -while (loop->refresh_rate !=0xff ) { -if ((check_sync) && - (((mode->flags &DRM_MODE_FLAG_NVSYNC ) && - (loop->flags & PVSync)) || - ((mode->flags &DRM_MODE_FLAG_PVSYNC ) && - (loop->flags & NVSync)) || - ((mode->flags &DRM_MODE_FLAG_NHSYNC ) && - (loop->flags & PHSync)) || - ((mode->flags &DRM_MODE_FLAG_PHSYNC ) && - (loop->flags & NHSync)))) { - loop++; -continue ; - } -if (loop->refresh_rate <= refresh_rate - && (!best || loop->refresh_rate > best->refresh_rate)) - best = loop; + + loop = vbios_mode->enh_table; + +while (loop->refresh_rate !=0xff ) { +if (((mode->flags &DRM_MODE_FLAG_NVSYNC ) && (loop->flags & PVSync)) || + ((mode->flags &DRM_MODE_FLAG_PVSYNC ) && (loop->flags & NVSync)) || + ((mode->flags &DRM_MODE_FLAG_NHSYNC ) && (loop->flags & PHSync)) || + ((mode->flags &DRM_MODE_FLAG_PHSYNC ) && (loop->flags & NHSync))) { loop++; +continue ; } -if (best || !check_sync) -break ; - check_sync =0 ; +if (loop->refresh_rate <= refresh_rate && + (!best || loop->refresh_rate > best->refresh_rate)) + best = loop; + loop++; } -if (best) - vbios_mode->enh_table = best; +if (!best) +return false; + + vbios_mode->enh_table = best; hborder = (vbios_mode->enh_table->flags & HBorder) ?8 :0 ; vborder = (vbios_mode->enh_table->flags & VBorder) ?8 :0 ;
Thomas Zimmermann
maintainerPATCH 8/15 drm/ast: Find VBIOS mode from regular display size
In reply to Thomas ZimmermannThe ast driver looks up supplied display modes from an internal list of display modes supported by the VBIOS.
Do not use the crtc_-prefixed display values from struct drm_display_mode for looking up the VBIOS mode. The fields contain raw values that the driver programs to hardware. They are affected by display settings like double-scan or interlace.
Instead use the regular vdisplay and hdisplay fields for lookup. As the programmed values can now differ from the values used for lookup, set struct drm_display_mode.crtc_vdisplay and .crtc_hdisplay from the VBIOS mode.
--- drivers/gpu/drm/ast/ast_mode.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +6 -4
@@ -131,7 +131,7 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format,return false; } -switch (mode->crtc_hdisplay) { +switch (mode->hdisplay) {case 640 : vbios_mode->enh_table = &res_640x480[refresh_rate_index];break ;
@@ -145,7 +145,7 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, vbios_mode->enh_table = &res_1152x864[refresh_rate_index];break ;case 1280 : -if (mode->crtc_vdisplay ==800 ) +if (mode->vdisplay ==800 ) vbios_mode->enh_table = &res_1280x800[refresh_rate_index];else vbios_mode->enh_table = &res_1280x1024[refresh_rate_index];
@@ -157,7 +157,7 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, vbios_mode->enh_table = &res_1440x900[refresh_rate_index];break ;case 1600 : -if (mode->crtc_vdisplay ==900 ) +if (mode->vdisplay ==900 ) vbios_mode->enh_table = &res_1600x900[refresh_rate_index];else vbios_mode->enh_table = &res_1600x1200[refresh_rate_index];
@@ -166,7 +166,7 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, vbios_mode->enh_table = &res_1680x1050[refresh_rate_index];break ;case 1920 : -if (mode->crtc_vdisplay ==1080 ) +if (mode->vdisplay ==1080 ) vbios_mode->enh_table = &res_1920x1080[refresh_rate_index];else vbios_mode->enh_table = &res_1920x1200[refresh_rate_index];
@@ -201,6 +201,7 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, hborder = (vbios_mode->enh_table->flags & HBorder) ?8 :0 ; vborder = (vbios_mode->enh_table->flags & VBorder) ?8 :0 ; + adjusted_mode->crtc_hdisplay = vbios_mode->enh_table->hde; adjusted_mode->crtc_htotal = vbios_mode->enh_table->ht; adjusted_mode->crtc_hblank_start = vbios_mode->enh_table->hde + hborder; adjusted_mode->crtc_hblank_end = vbios_mode->enh_table->ht - hborder;
@@ -210,6 +211,7 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, vbios_mode->enh_table->hfp + vbios_mode->enh_table->hsync); + adjusted_mode->crtc_vdisplay = vbios_mode->enh_table->vde; adjusted_mode->crtc_vtotal = vbios_mode->enh_table->vt; adjusted_mode->crtc_vblank_start = vbios_mode->enh_table->vde + vborder; adjusted_mode->crtc_vblank_end = vbios_mode->enh_table->vt - vborder;
Signature · 1 line
2.47.1
Re: [PATCH 08/15] drm/ast: Find VBIOS mode from regular display size
Quoted 8 lines · Thomas Zimmermann
The ast driver looks up supplied display modes from an internal list of display modes supported by the VBIOS.
Do not use the crtc_-prefixed display values from struct
drm_display_modefor looking up the VBIOS mode. The fields contain raw values that the driver programs to hardware. They are affected by display settings like double-scan or interlace.
Quoted 4 lines
Instead use the regular vdisplay and hdisplay fields for lookup. As the programmed values can now differ from the values used for lookup, set struct drm_display_mode.crtc_vdisplay and .crtc_hdisplay from the VBIOS mode.
Thanks, it looks good to me.
Signature · 1 line
Jocelyn
Quoted 62 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/gpu/drm/ast/ast_mode.c +6
-4@@ -131,7 +131,7 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format,return false; } -switch (mode->crtc_hdisplay) { +switch (mode->hdisplay) {case 640 : vbios_mode->enh_table = &res_640x480[refresh_rate_index];break ;@@ -145,7 +145,7 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, vbios_mode->enh_table = &res_1152x864[refresh_rate_index];break ;case 1280 : -if (mode->crtc_vdisplay ==800 ) +if (mode->vdisplay ==800 ) vbios_mode->enh_table = &res_1280x800[refresh_rate_index];else vbios_mode->enh_table = &res_1280x1024[refresh_rate_index];@@ -157,7 +157,7 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, vbios_mode->enh_table = &res_1440x900[refresh_rate_index];break ;case 1600 : -if (mode->crtc_vdisplay ==900 ) +if (mode->vdisplay ==900 ) vbios_mode->enh_table = &res_1600x900[refresh_rate_index];else vbios_mode->enh_table = &res_1600x1200[refresh_rate_index];@@ -166,7 +166,7 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, vbios_mode->enh_table = &res_1680x1050[refresh_rate_index];break ;case 1920 : -if (mode->crtc_vdisplay ==1080 ) +if (mode->vdisplay ==1080 ) vbios_mode->enh_table = &res_1920x1080[refresh_rate_index];else vbios_mode->enh_table = &res_1920x1200[refresh_rate_index];@@ -201,6 +201,7 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, hborder = (vbios_mode->enh_table->flags & HBorder) ?8 :0 ; vborder = (vbios_mode->enh_table->flags & VBorder) ?8 :0 ; + adjusted_mode->crtc_hdisplay = vbios_mode->enh_table->hde; adjusted_mode->crtc_htotal = vbios_mode->enh_table->ht; adjusted_mode->crtc_hblank_start = vbios_mode->enh_table->hde + hborder; adjusted_mode->crtc_hblank_end = vbios_mode->enh_table->ht - hborder;@@ -210,6 +211,7 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, vbios_mode->enh_table->hfp + vbios_mode->enh_table->hsync); + adjusted_mode->crtc_vdisplay = vbios_mode->enh_table->vde; adjusted_mode->crtc_vtotal = vbios_mode->enh_table->vt; adjusted_mode->crtc_vblank_start = vbios_mode->enh_table->vde + vborder; adjusted_mode->crtc_vblank_end = vbios_mode->enh_table->vt - vborder;
Thomas Zimmermann
maintainerPATCH 9/15 drm/ast: Add empty initializer for VBIOS modes
In reply to Thomas ZimmermannVBIOS mode tables are terminated by an entry with a refresh rate of 0xff. The code is hard to read and fragile to use. Therefore create an empty entry with AST_VBIOS_MODE_INVALID to terminate each mode list.
Stop at the invalid entry when searching for modes in the tables. Instead of testing for refresh == 0xff, test with a helper function if the mode's size and refresh have meaningful values.
--- drivers/gpu/drm/ast/ast_mode.c | 2 +- drivers/gpu/drm/ast/ast_tables.h | 52 ++++++++++++++------------------ 2 files changed, 24 insertions(+), 30 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +1 -1
@@ -179,7 +179,7 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, loop = vbios_mode->enh_table; -while (loop->refresh_rate !=0xff ) { +while (ast_vbios_mode_is_valid (loop)) { if (((mode->flags & DRM_MODE_FLAG_NVSYNC) && (loop->flags & PVSync)) || ((mode->flags & DRM_MODE_FLAG_PVSYNC) && (loop->flags & NVSync)) || ((mode->flags & DRM_MODE_FLAG_NHSYNC) && (loop->flags & PHSync)) ||
drivers/gpu/drm/ast/ast_tables.h +23 -29
140 lines not on this page · raw message
Signature · 1 line
2.47.1
Re: [PATCH 09/15] drm/ast: Add empty initializer for VBIOS modes
Quoted 7 lines · Thomas Zimmermann
VBIOS mode tables are terminated by an entry with a refresh rate of
0xff. The code is hard to read and fragile to use. Therefore create an empty entry withAST_VBIOS_MODE_INVALIDto terminate each mode list.Stop at the invalid entry when searching for modes in the tables. Instead of testing for refresh ==
0xff, test with a helper function if the mode's size and refresh have meaningful values.
Thanks, it looks good to me.
Signature · 1 line
Jocelyn
Quoted 174 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 2 +- drivers/gpu/drm/ast/ast_tables.h | 52 ++++++++++++++------------------ 2 files changed, 24 insertions(+), 30 deletions(-)drivers/gpu/drm/ast/ast_mode.c +1
-1@@ -179,7 +179,7 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format, loop = vbios_mode->enh_table; -while (loop->refresh_rate !=0xff ) { +while (ast_vbios_mode_is_valid (loop)) { if (((mode->flags & DRM_MODE_FLAG_NVSYNC) && (loop->flags & PVSync)) || ((mode->flags & DRM_MODE_FLAG_PVSYNC) && (loop->flags & NVSync)) || ((mode->flags & DRM_MODE_FLAG_NHSYNC) && (loop->flags & PHSync)) ||drivers/gpu/drm/ast/ast_tables.h +23
-29@@ -24,6 +24,8 @@#ifndef AST_TABLES_H #define AST_TABLES_H +#include "ast_drv.h" +/* Std. Table Index Definition */ #define TextModeIndex 0#define EGAModeIndex 1@@ -212,6 +214,14 @@ static const struct ast_vbios_stdtable vbios_stdtable[] = { }, }; +#define AST_VBIOS_INVALID_MODE \ + {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u} + +static inline bool ast_vbios_mode_is_valid (const struct ast_vbios_enhtable *vmode) +{ +return vmode->ht && vmode->vt && vmode->refresh_rate; +} +static const struct ast_vbios_enhtable res_640x480[] = { {800 ,640 ,8 ,96 ,525 ,480 ,2 ,2 ,VCLK25_175 ,/* 60Hz */ (SyncNN | HBorder | VBorder | Charx8Dot),60 ,1 ,0x2E },@@ -221,8 +231,7 @@ static const struct ast_vbios_enhtable res_640x480[] = { (SyncNN | Charx8Dot) , 75, 3, 0x2E }, {832 ,640 ,56 ,56 ,509 ,480 ,1 ,3 ,VCLK36 ,/* 85Hz */ (SyncNN | Charx8Dot) , 85, 4, 0x2E }, - { 832, 640, 56, 56, 509, 480, 1, 3, VCLK36, /* end */ - (SyncNN | Charx8Dot) , 0xFF, 4, 0x2E }, + AST_VBIOS_INVALID_MODE, /* end */ }; static const struct ast_vbios_enhtable res_800x600[] = {@@ -236,8 +245,7 @@ static const struct ast_vbios_enhtable res_800x600[] = { (SyncPP | Charx8Dot), 75, 4, 0x30 }, {1048 ,800 ,32 ,64 ,631 ,600 ,1 ,3 ,VCLK56_25 ,/* 85Hz */ (SyncPP | Charx8Dot), 84, 5, 0x30 }, - {1048, 800, 32, 64, 631, 600, 1, 3, VCLK56_25, /* end */ - (SyncPP | Charx8Dot), 0xFF, 5, 0x30 }, + AST_VBIOS_INVALID_MODE, /* end */ };@@ -250,8 +258,7 @@ static const struct ast_vbios_enhtable res_1024x768[] = { (SyncPP | Charx8Dot), 75, 3, 0x31 }, {1376 ,1024 ,48 ,96 ,808 ,768 ,1 ,3 ,VCLK94_5 ,/* 85Hz */ (SyncPP | Charx8Dot), 84, 4, 0x31 }, - {1376, 1024, 48, 96, 808, 768, 1, 3, VCLK94_5, /* end */ - (SyncPP | Charx8Dot), 0xFF, 4, 0x31 }, + AST_VBIOS_INVALID_MODE, /* end */ }; static const struct ast_vbios_enhtable res_1280x1024[] = {@@ -261,31 +268,26 @@ static const struct ast_vbios_enhtable res_1280x1024[] = { (SyncPP | Charx8Dot), 75, 2, 0x32 }, {1728 ,1280 ,64 ,160 ,1072 ,1024 ,1 ,3 ,VCLK157_5 ,/* 85Hz */ (SyncPP | Charx8Dot), 85, 3, 0x32 }, - {1728, 1280, 64, 160, 1072, 1024, 1, 3, VCLK157_5, /* end */ - (SyncPP | Charx8Dot), 0xFF, 3, 0x32 }, + AST_VBIOS_INVALID_MODE, /* end */ };static const struct ast_vbios_enhtable res_1600x1200[] = { {2160 ,1600 ,64 ,192 ,1250 ,1200 ,1 ,3 ,VCLK162 ,/* 60Hz */ (SyncPP | Charx8Dot),60 ,1 ,0x33 }, - {2160 ,1600 ,64 ,192 ,1250 ,1200 ,1 ,3 ,VCLK162 ,/* end */ - (SyncPP | Charx8Dot),0xFF ,1 ,0x33 }, +AST_VBIOS_INVALID_MODE ,/* end */ };static const struct ast_vbios_enhtable res_1152x864[] = { {1600 ,1152 ,64 ,128 ,900 ,864 ,1 ,3 ,VCLK108 ,/* 75Hz */ (SyncPP | Charx8Dot | NewModeInfo),75 ,1 ,0x3B }, - {1600 ,1152 ,64 ,128 ,900 ,864 ,1 ,3 ,VCLK108 ,/* end */ - (SyncPP | Charx8Dot | NewModeInfo),0xFF ,1 ,0x3B }, +AST_VBIOS_INVALID_MODE ,/* end */ };/* 16:9 */ static const struct ast_vbios_enhtable res_1360x768[] = { {1792 ,1360 ,64 ,112 ,795 ,768 ,3 ,6 ,VCLK85_5 ,/* 60Hz */ (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo),60 ,1 ,0x39 }, - {1792 ,1360 ,64 ,112 ,795 ,768 ,3 ,6 ,VCLK85_5 ,/* end */ - (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | - AST2500PreCatchCRT),0xFF ,1 ,0x39 }, +AST_VBIOS_INVALID_MODE ,/* end */ }; static const struct ast_vbios_enhtable res_1600x900[] = {@@ -294,17 +296,14 @@ static const struct ast_vbios_enhtable res_1600x900[] = { AST2500PreCatchCRT), 60, 1, 0x3A }, {2112 ,1600 ,88 ,168 ,934 ,900 ,3 ,5 ,VCLK118_25 ,/* 60Hz CVT */ (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x3A }, - {2112, 1600, 88, 168, 934, 900, 3, 5, VCLK118_25, /* 60Hz CVT */ - (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x3A }, + AST_VBIOS_INVALID_MODE, /* end */ };static const struct ast_vbios_enhtable res_1920x1080[] = { {2200 ,1920 ,88 ,44 ,1125 ,1080 ,4 ,5 ,VCLK148_5 ,/* 60Hz */ (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | AST2500PreCatchCRT),60 ,1 ,0x38 }, - {2200 ,1920 ,88 ,44 ,1125 ,1080 ,4 ,5 ,VCLK148_5 ,/* 60Hz */ - (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | - AST2500PreCatchCRT),0xFF ,1 ,0x38 }, +AST_VBIOS_INVALID_MODE ,/* end */ };@@ -315,8 +314,7 @@ static const struct ast_vbios_enhtable res_1280x800[] = { AST2500PreCatchCRT), 60, 1, 0x35 }, {1680 ,1280 ,72 ,128 ,831 ,800 ,3 ,6 ,VCLK83_5 ,/* 60Hz */ (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x35 }, - {1680, 1280, 72,128, 831, 800, 3, 6, VCLK83_5, /* 60Hz */ - (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x35 }, + AST_VBIOS_INVALID_MODE, /* end */ };@@ -326,8 +324,7 @@ static const struct ast_vbios_enhtable res_1440x900[] = { AST2500PreCatchCRT), 60, 1, 0x36 }, {1904 ,1440 ,80 ,152 ,934 ,900 ,3 ,6 ,VCLK106_5 ,/* 60Hz */ (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x36 }, - {1904, 1440, 80,152, 934, 900, 3, 6, VCLK106_5, /* 60Hz */ - (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x36 }, + AST_VBIOS_INVALID_MODE, /* end */ }; static const struct ast_vbios_enhtable res_1680x1050[] = {@@ -336,17 +333,14 @@ static const struct ast_vbios_enhtable res_1680x1050[] = { AST2500PreCatchCRT), 60, 1, 0x37 }, {2240, 1680,104,176, 1089, 1050, 3, 6, VCLK146_25, /* 60Hz */ (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x37 }, - {2240, 1680,104,176, 1089, 1050, 3, 6, VCLK146_25, /* 60Hz */ - (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x37 }, + AST_VBIOS_INVALID_MODE, /* end */ };static const struct ast_vbios_enhtable res_1920x1200[] = { {2080 ,1920 ,48 ,32 ,1235 ,1200 ,3 ,6 ,VCLK154 ,/* 60Hz RB*/ (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | AST2500PreCatchCRT),60 ,1 ,0x34 }, - {2080 ,1920 ,48 ,32 ,1235 ,1200 ,3 ,6 ,VCLK154 ,/* 60Hz RB */ - (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | - AST2500PreCatchCRT),0xFF ,1 ,0x34 }, +AST_VBIOS_INVALID_MODE ,/* end */ };#endif
Thomas Zimmermann
maintainerPATCH 10/15 drm/ast: Add helpers for VBIOS mode lookup
In reply to Thomas ZimmermannMode lines are independent from hardware Gen or TX chip, so hide all VBIOS mode tables in ast_vbios.c.
Move the look-up code for VBIOS modes from ast_vbios_get_mode_info() to ast_vbios_find_mode(). The new look-up function respects the supported-mode flags in struct ast_device. For example, if a device does not have struct ast_device.support_fullhd set, the helper does not return a valid mode for 1920x1080. Taking the supported-mode flags into account allows for making the VBIOS tables the single reference for validating and setting display modes against hardware capabilities.
--- drivers/gpu/drm/ast/Makefile | 1 + drivers/gpu/drm/ast/ast_dp.c | 1 + drivers/gpu/drm/ast/ast_drv.h | 18 +-- drivers/gpu/drm/ast/ast_mode.c | 77 +-------- drivers/gpu/drm/ast/ast_tables.h | 177 --------------------- drivers/gpu/drm/ast/ast_vbios.c | 261 +++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_vbios.h | 108 +++++++++++++ 7 files changed, 380 insertions(+), 263 deletions(-) create mode 100644 drivers/gpu/drm/ast/ast_vbios.c create mode 100644 drivers/gpu/drm/ast/ast_vbios.h
drivers/gpu/drm/ast/Makefile +1 -0
@@ -13,6 +13,7 @@ ast-y := \ ast_mode.o \ ast_post.o \ ast_sil164.o \ + ast_vbios.o \ ast_vga.o obj-$(CONFIG_DRM_AST) := ast.o
drivers/gpu/drm/ast/ast_dp.c +1 -0
@@ -12,6 +12,7 @@#include <drm/drm_probe_helper.h> #include "ast_drv.h" +#include "ast_vbios.h" static bool ast_astdp_is_connected (struct ast_device *ast) {
drivers/gpu/drm/ast/ast_drv.h +2 -16
@@ -39,6 +39,8 @@#include "ast_reg.h" +struct ast_vbios_enhtable ; +#define DRIVER_AUTHOR "Dave Airlie"#define DRIVER_NAME "ast"
@@ -350,22 +352,6 @@ struct ast_vbios_stdtable {u8 gr[9 ]; }; -struct ast_vbios_enhtable { -u32 ht; -u32 hde; -u32 hfp; -u32 hsync; -u32 vt; -u32 vde; -u32 vfp; -u32 vsync; -u32 dclk_index; -u32 flags; -u32 refresh_rate; -u32 refresh_rate_index; -u32 mode_id; -}; -struct ast_vbios_dclk_info {u8 param1;u8 param2;
drivers/gpu/drm/ast/ast_mode.c +7 -70
113 lines not on this page · raw message
drivers/gpu/drm/ast/ast_tables.h +0 -177
187 lines not on this page · raw message
drivers/gpu/drm/ast/ast_vbios.c new file +261 -0
261 lines not on this page · raw message
drivers/gpu/drm/ast/ast_vbios.h new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
2.47.1
Re: [PATCH 10/15] drm/ast: Add helpers for VBIOS mode lookup
Quoted 10 lines · Thomas Zimmermann
Mode lines are independent from hardware Gen or TX chip, so hide all VBIOS mode tables in
ast_vbios.c.Move the look-up code for VBIOS modes from
ast_vbios_get_mode_info()toast_vbios_find_mode(). The new look-up function respects the supported-mode flags in structast_device. For example, if a device does not have struct ast_device.support_fullhd set, the helper does not return a valid mode for 1920x1080. Taking the supported-mode flags into account allows for making the VBIOS tables the single reference for validating and setting display modes against hardware capabilities.
Thanks, it looks good to me.
Quoted 770 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/Makefile | 1 + drivers/gpu/drm/ast/ast_dp.c | 1 + drivers/gpu/drm/ast/ast_drv.h | 18 +-- drivers/gpu/drm/ast/ast_mode.c | 77 +-------- drivers/gpu/drm/ast/ast_tables.h | 177 --------------------- drivers/gpu/drm/ast/ast_vbios.c | 261 +++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_vbios.h | 108 +++++++++++++ 7 files changed, 380 insertions(+), 263 deletions(-)create mode 100644
drivers/gpu/drm/ast/ast_vbios.ccreate mode 100644drivers/gpu/drm/ast/ast_vbios.hdrivers/gpu/drm/ast/Makefile +1
-0@@ -13,6 +13,7 @@ ast-y := \ ast_mode.o \ ast_post.o \ ast_sil164.o \ + ast_vbios.o \ ast_vga.o obj-$(CONFIG_DRM_AST) := ast.odrivers/gpu/drm/ast/ast_dp.c +1
-0@@ -12,6 +12,7 @@#include <drm/drm_probe_helper.h> #include "ast_drv.h" +#include "ast_vbios.h" static bool ast_astdp_is_connected (struct ast_device *ast) {drivers/gpu/drm/ast/ast_drv.h +2
-16@@ -39,6 +39,8 @@#include "ast_reg.h" +struct ast_vbios_enhtable ; +#define DRIVER_AUTHOR "Dave Airlie"#define DRIVER_NAME "ast"@@ -350,22 +352,6 @@ struct ast_vbios_stdtable {u8 gr[9 ]; }; -struct ast_vbios_enhtable { -u32 ht; -u32 hde; -u32 hfp; -u32 hsync; -u32 vt; -u32 vde; -u32 vfp; -u32 vsync; -u32 dclk_index; -u32 flags; -u32 refresh_rate; -u32 refresh_rate_index; -u32 mode_id; -}; -struct ast_vbios_dclk_info {u8 param1;u8 param2;drivers/gpu/drm/ast/ast_mode.c +7
-70@@ -47,6 +47,7 @@#include "ast_drv.h" #include "ast_tables.h" +#include "ast_vbios.h" #define AST_LUT_SIZE 256@@ -106,14 +107,12 @@ static void ast_crtc_set_gamma(struct ast_device *ast, } } -static bool ast_get_vbios_mode_info (const struct drm_format_info *format, +static bool ast_get_vbios_mode_info (struct ast_device *ast, +const struct drm_format_info *format,const struct drm_display_mode *mode,struct drm_display_mode *adjusted_mode,struct ast_vbios_mode_info *vbios_mode) { -u32 refresh_rate_index =0 , refresh_rate; -const struct ast_vbios_enhtable *best =NULL ; -const struct ast_vbios_enhtable *loop;u32 hborder, vborder;switch (format->cpp[0 ] *8 ) {@@ -131,73 +130,10 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format,return false; } -switch (mode->hdisplay) { -case 640 : - vbios_mode->enh_table = &res_640x480[refresh_rate_index]; -break ; -case 800 : - vbios_mode->enh_table = &res_800x600[refresh_rate_index]; -break ; -case 1024 : - vbios_mode->enh_table = &res_1024x768[refresh_rate_index]; -break ; -case 1152 : - vbios_mode->enh_table = &res_1152x864[refresh_rate_index]; -break ; -case 1280 : -if (mode->vdisplay ==800 ) - vbios_mode->enh_table = &res_1280x800[refresh_rate_index]; -else - vbios_mode->enh_table = &res_1280x1024[refresh_rate_index]; -break ; -case 1360 : - vbios_mode->enh_table = &res_1360x768[refresh_rate_index]; -break ; -case 1440 : - vbios_mode->enh_table = &res_1440x900[refresh_rate_index]; -break ; -case 1600 : -if (mode->vdisplay ==900 ) - vbios_mode->enh_table = &res_1600x900[refresh_rate_index]; -else - vbios_mode->enh_table = &res_1600x1200[refresh_rate_index]; -break ; -case 1680 : - vbios_mode->enh_table = &res_1680x1050[refresh_rate_index]; -break ; -case 1920 : -if (mode->vdisplay ==1080 ) - vbios_mode->enh_table = &res_1920x1080[refresh_rate_index]; -else - vbios_mode->enh_table = &res_1920x1200[refresh_rate_index]; -break ; -default : -return false; - } - - refresh_rate =drm_mode_vrefresh (mode); - - loop = vbios_mode->enh_table; - -while (ast_vbios_mode_is_valid (loop)) { -if (((mode->flags &DRM_MODE_FLAG_NVSYNC ) && (loop->flags & PVSync)) || - ((mode->flags &DRM_MODE_FLAG_PVSYNC ) && (loop->flags & NVSync)) || - ((mode->flags &DRM_MODE_FLAG_NHSYNC ) && (loop->flags & PHSync)) || - ((mode->flags &DRM_MODE_FLAG_PHSYNC ) && (loop->flags & NHSync))) { - loop++; -continue ; - } -if (loop->refresh_rate <= refresh_rate && - (!best || loop->refresh_rate > best->refresh_rate)) - best = loop; - loop++; - } - -if (!best) + vbios_mode->enh_table =ast_vbios_find_mode (ast, mode); +if (!vbios_mode->enh_table)return false; - vbios_mode->enh_table = best; - hborder = (vbios_mode->enh_table->flags & HBorder) ?8 :0 ; vborder = (vbios_mode->enh_table->flags & VBorder) ?8 :0 ;@@ -1109,6 +1045,7 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,struct drm_crtc_state *old_crtc_state =drm_atomic_get_old_crtc_state (state, crtc);struct ast_crtc_state *old_ast_crtc_state =to_ast_crtc_state (old_crtc_state);struct drm_device *dev = crtc->dev; +struct ast_device *ast =to_ast_device (dev);struct ast_crtc_state *ast_state;const struct drm_format_info *format;bool succ;@@ -1143,7 +1080,7 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc, } } - succ =ast_get_vbios_mode_info (format, &crtc_state->mode, + succ =ast_get_vbios_mode_info (ast, format, &crtc_state->mode, &crtc_state->adjusted_mode, &ast_state->vbios_mode_info);if (!succ)drivers/gpu/drm/ast/ast_tables.h +0
-177@@ -33,54 +33,6 @@#define HiCModeIndex 3#define TrueCModeIndex 4 -#define Charx8Dot 0x00000001 -#define HalfDCLK 0x00000002 -#define DoubleScanMode 0x00000004 -#define LineCompareOff 0x00000008 -#define HBorder 0x00000020 -#define VBorder 0x00000010 -#define WideScreenMode 0x00000100 -#define NewModeInfo 0x00000200 -#define NHSync 0x00000400 -#define PHSync 0x00000800 -#define NVSync 0x00001000 -#define PVSync 0x00002000 -#define SyncPP (PVSync | PHSync) -#define SyncPN (PVSync | NHSync) -#define SyncNP (NVSync | PHSync) -#define SyncNN (NVSync | NHSync) -#define AST2500PreCatchCRT 0x00004000 - -/* DCLK Index */ -#define VCLK25_175 0x00 -#define VCLK28_322 0x01 -#define VCLK31_5 0x02 -#define VCLK36 0x03 -#define VCLK40 0x04 -#define VCLK49_5 0x05 -#define VCLK50 0x06 -#define VCLK56_25 0x07 -#define VCLK65 0x08 -#define VCLK75 0x09 -#define VCLK78_75 0x0A -#define VCLK94_5 0x0B -#define VCLK108 0x0C -#define VCLK135 0x0D -#define VCLK157_5 0x0E -#define VCLK162 0x0F -/* #define VCLK193_25 0x10 */ -#define VCLK154 0x10 -#define VCLK83_5 0x11 -#define VCLK106_5 0x12 -#define VCLK146_25 0x13 -#define VCLK148_5 0x14 -#define VCLK71 0x15 -#define VCLK88_75 0x16 -#define VCLK119 0x17 -#define VCLK85_5 0x18 -#define VCLK97_75 0x19 -#define VCLK118_25 0x1A -static const struct ast_vbios_dclk_info dclk_table[] = { {0x2C ,0xE7 ,0x03 },/* 00: VCLK25_175 */ {0x95 ,0x62 ,0x03 },/* 01: VCLK28_322 */ @@ -214,133 +166,4 @@ static const struct ast_vbios_stdtable vbios_stdtable[] = { }, }; -#define AST_VBIOS_INVALID_MODE \ - {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u} - -static inline bool ast_vbios_mode_is_valid (const struct ast_vbios_enhtable *vmode) -{ -return vmode->ht && vmode->vt && vmode->refresh_rate; -} - -static const struct ast_vbios_enhtable res_640x480[] = { - {800 ,640 ,8 ,96 ,525 ,480 ,2 ,2 ,VCLK25_175 ,/* 60Hz */ - (SyncNN | HBorder | VBorder | Charx8Dot),60 ,1 ,0x2E }, - {832 ,640 ,16 ,40 ,520 ,480 ,1 ,3 ,VCLK31_5 ,/* 72Hz */ - (SyncNN | HBorder | VBorder | Charx8Dot),72 ,2 ,0x2E }, - {840 ,640 ,16 ,64 ,500 ,480 ,1 ,3 ,VCLK31_5 ,/* 75Hz */ - (SyncNN | Charx8Dot) ,75 ,3 ,0x2E }, - {832 ,640 ,56 ,56 ,509 ,480 ,1 ,3 ,VCLK36 ,/* 85Hz */ - (SyncNN | Charx8Dot) ,85 ,4 ,0x2E }, -AST_VBIOS_INVALID_MODE ,/* end */ -}; - -static const struct ast_vbios_enhtable res_800x600[] = { - {1024 ,800 ,24 ,72 ,625 ,600 ,1 ,2 ,VCLK36 ,/* 56Hz */ - (SyncPP | Charx8Dot),56 ,1 ,0x30 }, - {1056 ,800 ,40 ,128 ,628 ,600 ,1 ,4 ,VCLK40 ,/* 60Hz */ - (SyncPP | Charx8Dot),60 ,2 ,0x30 }, - {1040 ,800 ,56 ,120 ,666 ,600 ,37 ,6 ,VCLK50 ,/* 72Hz */ - (SyncPP | Charx8Dot),72 ,3 ,0x30 }, - {1056 ,800 ,16 ,80 ,625 ,600 ,1 ,3 ,VCLK49_5 ,/* 75Hz */ - (SyncPP | Charx8Dot),75 ,4 ,0x30 }, - {1048 ,800 ,32 ,64 ,631 ,600 ,1 ,3 ,VCLK56_25 ,/* 85Hz */ - (SyncPP | Charx8Dot),84 ,5 ,0x30 }, -AST_VBIOS_INVALID_MODE ,/* end */ -}; - - -static const struct ast_vbios_enhtable res_1024x768[] = { - {1344 ,1024 ,24 ,136 ,806 ,768 ,3 ,6 ,VCLK65 ,/* 60Hz */ - (SyncNN | Charx8Dot),60 ,1 ,0x31 }, - {1328 ,1024 ,24 ,136 ,806 ,768 ,3 ,6 ,VCLK75 ,/* 70Hz */ - (SyncNN | Charx8Dot),70 ,2 ,0x31 }, - {1312 ,1024 ,16 ,96 ,800 ,768 ,1 ,3 ,VCLK78_75 ,/* 75Hz */ - (SyncPP | Charx8Dot),75 ,3 ,0x31 }, - {1376 ,1024 ,48 ,96 ,808 ,768 ,1 ,3 ,VCLK94_5 ,/* 85Hz */ - (SyncPP | Charx8Dot),84 ,4 ,0x31 }, -AST_VBIOS_INVALID_MODE ,/* end */ -}; - -static const struct ast_vbios_enhtable res_1280x1024[] = { - {1688 ,1280 ,48 ,112 ,1066 ,1024 ,1 ,3 ,VCLK108 ,/* 60Hz */ - (SyncPP | Charx8Dot),60 ,1 ,0x32 }, - {1688 ,1280 ,16 ,144 ,1066 ,1024 ,1 ,3 ,VCLK135 ,/* 75Hz */ - (SyncPP | Charx8Dot),75 ,2 ,0x32 }, - {1728 ,1280 ,64 ,160 ,1072 ,1024 ,1 ,3 ,VCLK157_5 ,/* 85Hz */ - (SyncPP | Charx8Dot),85 ,3 ,0x32 }, -AST_VBIOS_INVALID_MODE ,/* end */ -}; - -static const struct ast_vbios_enhtable res_1600x1200[] = { - {2160 ,1600 ,64 ,192 ,1250 ,1200 ,1 ,3 ,VCLK162 ,/* 60Hz */ - (SyncPP | Charx8Dot),60 ,1 ,0x33 }, -AST_VBIOS_INVALID_MODE ,/* end */ -}; - -static const struct ast_vbios_enhtable res_1152x864[] = { - {1600 ,1152 ,64 ,128 ,900 ,864 ,1 ,3 ,VCLK108 ,/* 75Hz */ - (SyncPP | Charx8Dot | NewModeInfo),75 ,1 ,0x3B }, -AST_VBIOS_INVALID_MODE ,/* end */ -}; - -/* 16:9 */ -static const struct ast_vbios_enhtable res_1360x768[] = { - {1792 ,1360 ,64 ,112 ,795 ,768 ,3 ,6 ,VCLK85_5 ,/* 60Hz */ - (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo),60 ,1 ,0x39 }, -AST_VBIOS_INVALID_MODE ,/* end */ -}; - -static const struct ast_vbios_enhtable res_1600x900[] = { - {1760 ,1600 ,48 ,32 ,926 ,900 ,3 ,5 ,VCLK97_75 ,/* 60Hz CVT RB */ - (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | - AST2500PreCatchCRT),60 ,1 ,0x3A }, - {2112 ,1600 ,88 ,168 ,934 ,900 ,3 ,5 ,VCLK118_25 ,/* 60Hz CVT */ - (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo),60 ,2 ,0x3A }, -AST_VBIOS_INVALID_MODE ,/* end */ -}; - -static const struct ast_vbios_enhtable res_1920x1080[] = { - {2200 ,1920 ,88 ,44 ,1125 ,1080 ,4 ,5 ,VCLK148_5 ,/* 60Hz */ - (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | - AST2500PreCatchCRT),60 ,1 ,0x38 }, -AST_VBIOS_INVALID_MODE ,/* end */ -}; - - -/* 16:10 */ -static const struct ast_vbios_enhtable res_1280x800[] = { - {1440 ,1280 ,48 ,32 ,823 ,800 ,3 ,6 ,VCLK71 ,/* 60Hz RB */ - (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | - AST2500PreCatchCRT),60 ,1 ,0x35 }, - {1680 ,1280 ,72 ,128 ,831 ,800 ,3 ,6 ,VCLK83_5 ,/* 60Hz */ - (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo),60 ,2 ,0x35 }, -AST_VBIOS_INVALID_MODE ,/* end */ - -}; - -static const struct ast_vbios_enhtable res_1440x900[] = { - {1600 ,1440 ,48 ,32 ,926 ,900 ,3 ,6 ,VCLK88_75 ,/* 60Hz RB */ - (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | - AST2500PreCatchCRT),60 ,1 ,0x36 }, - {1904 ,1440 ,80 ,152 ,934 ,900 ,3 ,6 ,VCLK106_5 ,/* 60Hz */ - (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo),60 ,2 ,0x36 }, -AST_VBIOS_INVALID_MODE ,/* end */ -}; - -static const struct ast_vbios_enhtable res_1680x1050[] = { - {1840 ,1680 ,48 ,32 ,1080 ,1050 ,3 ,6 ,VCLK119 ,/* 60Hz RB */ - (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | - AST2500PreCatchCRT),60 ,1 ,0x37 }, - {2240 ,1680 ,104 ,176 ,1089 ,1050 ,3 ,6 ,VCLK146_25 ,/* 60Hz */ - (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo),60 ,2 ,0x37 }, -AST_VBIOS_INVALID_MODE ,/* end */ -}; - -static const struct ast_vbios_enhtable res_1920x1200[] = { - {2080 ,1920 ,48 ,32 ,1235 ,1200 ,3 ,6 ,VCLK154 ,/* 60Hz RB*/ - (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | - AST2500PreCatchCRT),60 ,1 ,0x34 }, -AST_VBIOS_INVALID_MODE ,/* end */ -}; -#endif drivers/gpu/drm/ast/ast_vbios.c new file +261
-0@@ -0,0 +1,261 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright (c) 2005 ASPEED Technology Inc. +* +* Permission to use, copy, modify, distribute, and sell this software and its +* documentation for any purpose is hereby granted without fee, provided that +* the above copyright notice appear in all copies and that both that +* copyright notice and this permission notice appear in supporting +* documentation, and that the name of the authors not be used in +* advertising or publicity pertaining to distribution of the software without +* specific, written prior permission. The authors makes no representations +* about the suitability of this software for any purpose. It is provided +* "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR +* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +* PERFORMANCE OF THIS SOFTWARE. +*/ + +#include "ast_drv.h" +#include "ast_vbios.h" + +/* 4:3 */ + +static const struct ast_vbios_enhtable res_640x480[] = { + {800 ,640 ,8 ,96 ,525 ,480 ,2 ,2 ,VCLK25_175 ,/* 60 Hz */ + (SyncNN | HBorder | VBorder | Charx8Dot),60 ,1 ,0x2e }, + {832 ,640 ,16 ,40 ,520 ,480 ,1 ,3 ,VCLK31_5 ,/* 72 Hz */ + (SyncNN | HBorder | VBorder | Charx8Dot),72 ,2 ,0x2e }, + {840 ,640 ,16 ,64 ,500 ,480 ,1 ,3 ,VCLK31_5 ,/* 75 Hz */ + (SyncNN | Charx8Dot),75 ,3 ,0x2e }, + {832 ,640 ,56 ,56 ,509 ,480 ,1 ,3 ,VCLK36 ,/* 85 Hz */ + (SyncNN | Charx8Dot),85 ,4 ,0x2e }, +AST_VBIOS_INVALID_MODE ,/* end */ +}; + +static const struct ast_vbios_enhtable res_800x600[] = { + {1024 ,800 ,24 ,72 ,625 ,600 ,1 ,2 ,VCLK36 ,/* 56 Hz */ + (SyncPP | Charx8Dot),56 ,1 ,0x30 }, + {1056 ,800 ,40 ,128 ,628 ,600 ,1 ,4 ,VCLK40 ,/* 60 Hz */ + (SyncPP | Charx8Dot),60 ,2 ,0x30 }, + {1040 ,800 ,56 ,120 ,666 ,600 ,37 ,6 ,VCLK50 ,/* 72 Hz */ + (SyncPP | Charx8Dot),72 ,3 ,0x30 }, + {1056 ,800 ,16 ,80 ,625 ,600 ,1 ,3 ,VCLK49_5 ,/* 75 Hz */ + (SyncPP | Charx8Dot),75 ,4 ,0x30 }, + {1048 ,800 ,32 ,64 ,631 ,600 ,1 ,3 ,VCLK56_25 ,/* 85 Hz */ + (SyncPP | Charx8Dot),84 ,5 ,0x30 }, +AST_VBIOS_INVALID_MODE ,/* end */ +}; + +static const struct ast_vbios_enhtable res_1024x768[] = { + {1344 ,1024 ,24 ,136 ,806 ,768 ,3 ,6 ,VCLK65 ,/* 60 Hz */ + (SyncNN | Charx8Dot),60 ,1 ,0x31 }, + {1328 ,1024 ,24 ,136 ,806 ,768 ,3 ,6 ,VCLK75 ,/* 70 Hz */ + (SyncNN | Charx8Dot),70 ,2 ,0x31 }, + {1312 ,1024 ,16 ,96 ,800 ,768 ,1 ,3 ,VCLK78_75 ,/* 75 Hz */ + (SyncPP | Charx8Dot),75 ,3 ,0x31 }, + {1376 ,1024 ,48 ,96 ,808 ,768 ,1 ,3 ,VCLK94_5 ,/* 85 Hz */ + (SyncPP | Charx8Dot),84 ,4 ,0x31 }, +AST_VBIOS_INVALID_MODE ,/* end */ +}; + +static const struct ast_vbios_enhtable res_1152x864[] = { + {1600 ,1152 ,64 ,128 ,900 ,864 ,1 ,3 ,VCLK108 ,/* 75 Hz */ + (SyncPP | Charx8Dot | NewModeInfo),75 ,1 ,0x3b }, +AST_VBIOS_INVALID_MODE ,/* end */ +}; + +static const struct ast_vbios_enhtable res_1280x1024[] = { + {1688 ,1280 ,48 ,112 ,1066 ,1024 ,1 ,3 ,VCLK108 ,/* 60 Hz */ + (SyncPP | Charx8Dot),60 ,1 ,0x32 }, + {1688 ,1280 ,16 ,144 ,1066 ,1024 ,1 ,3 ,VCLK135 ,/* 75 Hz */ + (SyncPP | Charx8Dot),75 ,2 ,0x32 }, + {1728 ,1280 ,64 ,160 ,1072 ,1024 ,1 ,3 ,VCLK157_5 ,/* 85 Hz */ + (SyncPP | Charx8Dot),85 ,3 ,0x32 }, +AST_VBIOS_INVALID_MODE ,/* end */ +}; + +static const struct ast_vbios_enhtable res_1600x1200[] = { + {2160 ,1600 ,64 ,192 ,1250 ,1200 ,1 ,3 ,VCLK162 ,/* 60 Hz */ + (SyncPP | Charx8Dot),60 ,1 ,0x33 }, +AST_VBIOS_INVALID_MODE ,/* end */ +}; + +/* 16:9 */ + +static const struct ast_vbios_enhtable res_1360x768[] = { + {1792 ,1360 ,64 ,112 ,795 ,768 ,3 ,6 ,VCLK85_5 ,/* 60 Hz */ + (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo),60 ,1 ,0x39 }, +AST_VBIOS_INVALID_MODE ,/* end */ +}; + +static const struct ast_vbios_enhtable res_1600x900[] = { + {1760 ,1600 ,48 ,32 ,926 ,900 ,3 ,5 ,VCLK97_75 ,/* 60 Hz CVT RB */ + (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | + AST2500PreCatchCRT),60 ,1 ,0x3a }, + {2112 ,1600 ,88 ,168 ,934 ,900 ,3 ,5 ,VCLK118_25 ,/* 60 Hz CVT */ + (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo),60 ,2 ,0x3a }, +AST_VBIOS_INVALID_MODE ,/* end */ +}; + +static const struct ast_vbios_enhtable res_1920x1080[] = { + {2200 ,1920 ,88 ,44 ,1125 ,1080 ,4 ,5 ,VCLK148_5 ,/* 60 Hz */ + (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | + AST2500PreCatchCRT),60 ,1 ,0x38 }, +AST_VBIOS_INVALID_MODE ,/* end */ +}; + +/* 16:10 */ + +static const struct ast_vbios_enhtable res_1280x800[] = { + {1440 ,1280 ,48 ,32 ,823 ,800 ,3 ,6 ,VCLK71 ,/* 60 Hz RB */ + (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | + AST2500PreCatchCRT),60 ,1 ,0x35 }, + {1680 ,1280 ,72 ,128 ,831 ,800 ,3 ,6 ,VCLK83_5 ,/* 60 Hz */ + (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo),60 ,2 ,0x35 }, +AST_VBIOS_INVALID_MODE ,/* end */ +}; + +static const struct ast_vbios_enhtable res_1440x900[] = { + {1600 ,1440 ,48 ,32 ,926 ,900 ,3 ,6 ,VCLK88_75 ,/* 60 Hz RB */ + (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | + AST2500PreCatchCRT),60 ,1 ,0x36 }, + {1904 ,1440 ,80 ,152 ,934 ,900 ,3 ,6 ,VCLK106_5 ,/* 60 Hz */ + (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo),60 ,2 ,0x36 }, +AST_VBIOS_INVALID_MODE ,/* end */ +}; + +static const struct ast_vbios_enhtable res_1680x1050[] = { + {1840 ,1680 ,48 ,32 ,1080 ,1050 ,3 ,6 ,VCLK119 ,/* 60 Hz RB */ + (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | + AST2500PreCatchCRT),60 ,1 ,0x37 }, + {2240 ,1680 ,104 ,176 ,1089 ,1050 ,3 ,6 ,VCLK146_25 ,/* 60 Hz */ + (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo),60 ,2 ,0x37 }, +AST_VBIOS_INVALID_MODE ,/* end */ +}; + +static const struct ast_vbios_enhtable res_1920x1200[] = { + {2080 ,1920 ,48 ,32 ,1235 ,1200 ,3 ,6 ,VCLK154 ,/* 60 Hz RB*/ + (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo | + AST2500PreCatchCRT),60 ,1 ,0x34 }, +AST_VBIOS_INVALID_MODE ,/* end */ +}; + +static const struct ast_vbios_enhtable *ast_vbios_find_mode_table (const struct ast_device *ast, +unsigned int hdisplay, +unsigned int vdisplay) +{ +if (ast->support_wuxga) { +switch (hdisplay) { +case 1920 : +if (vdisplay ==1200 ) +return &res_1920x1200[0 ]; +break ; +default : +break ; + } + } + +if (ast->support_fullhd) { +switch (hdisplay) { +case 1920 : +if (vdisplay ==1080 ) +return &res_1920x1080[0 ]; +break ; +default : +break ; + } + } + +if (ast->support_wsxga_p) { +switch (hdisplay) { +case 1280 : +if (vdisplay ==800 ) +return &res_1280x800[0 ]; +break ; +case 1360 : +if (vdisplay ==768 ) +return &res_1360x768[0 ]; +break ; +case 1440 : +if (vdisplay ==900 ) +return &res_1440x900[0 ]; +break ; +case 1600 : +if (vdisplay ==900 ) +return &res_1600x900[0 ]; +break ; +case 1680 : +if (vdisplay ==1050 ) +return &res_1680x1050[0 ]; +break ; +default : +break ; + } + } + +switch (hdisplay) { +case 640 : +if (vdisplay ==480 ) +return &res_640x480[0 ]; +break ; +case 800 : +if (vdisplay ==600 ) +return &res_800x600[0 ]; +break ; +case 1024 : +if (vdisplay ==768 ) +return &res_1024x768[0 ]; +break ; +case 1152 : +if (vdisplay ==864 ) +return &res_1152x864[0 ]; +break ; +case 1280 : +if (vdisplay ==1024 ) +return &res_1280x1024[0 ]; +break ; +case 1600 : +if (vdisplay ==1200 ) +return &res_1600x1200[0 ]; +break ; +default : +break ; + } + +return NULL ; +} + +const struct ast_vbios_enhtable *ast_vbios_find_mode (const struct ast_device *ast, +const struct drm_display_mode *mode) +{ +const struct ast_vbios_enhtable *best_vmode =NULL ; +const struct ast_vbios_enhtable *vmode_table; +const struct ast_vbios_enhtable *vmode; +u32 refresh_rate; + + vmode_table =ast_vbios_find_mode_table (ast, mode->hdisplay, mode->vdisplay); +if (!vmode_table) +return NULL ; + + refresh_rate =drm_mode_vrefresh (mode); + +for (vmode = vmode_table;ast_vbios_mode_is_valid (vmode); ++vmode) { +if (((mode->flags &DRM_MODE_FLAG_NVSYNC ) && (vmode->flags & PVSync)) || + ((mode->flags &DRM_MODE_FLAG_PVSYNC ) && (vmode->flags & NVSync)) || + ((mode->flags &DRM_MODE_FLAG_NHSYNC ) && (vmode->flags & PHSync)) || + ((mode->flags &DRM_MODE_FLAG_PHSYNC ) && (vmode->flags & NHSync))) { +continue ; + } +if (vmode->refresh_rate <= refresh_rate && + (!best_vmode || vmode->refresh_rate > best_vmode->refresh_rate)) + best_vmode = vmode; + } + +return best_vmode; +}drivers/gpu/drm/ast/ast_vbios.h new file +108
-0@@ -0,0 +1,108 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright (c) 2005 ASPEED Technology Inc. +* +* Permission to use, copy, modify, distribute, and sell this software and its +* documentation for any purpose is hereby granted without fee, provided that +* the above copyright notice appear in all copies and that both that +* copyright notice and this permission notice appear in supporting +* documentation, and that the name of the authors not be used in +* advertising or publicity pertaining to distribution of the software without +* specific, written prior permission. The authors makes no representations +* about the suitability of this software for any purpose. It is provided +* "as is" without express or implied warranty. +* +* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR +* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +* PERFORMANCE OF THIS SOFTWARE. +*/ +/* Ported from xf86-video-ast driver */ + +#ifndef AST_VBIOS_H +#define AST_VBIOS_H + +#include <linux/types.h> + +struct ast_device ; +struct drm_display_mode ; + +#define Charx8Dot 0x00000001 +#define HalfDCLK 0x00000002 +#define DoubleScanMode 0x00000004 +#define LineCompareOff 0x00000008 +#define HBorder 0x00000020 +#define VBorder 0x00000010 +#define WideScreenMode 0x00000100 +#define NewModeInfo 0x00000200 +#define NHSync 0x00000400 +#define PHSync 0x00000800 +#define NVSync 0x00001000 +#define PVSync 0x00002000 +#define SyncPP (PVSync | PHSync) +#define SyncPN (PVSync | NHSync) +#define SyncNP (NVSync | PHSync) +#define SyncNN (NVSync | NHSync) +#define AST2500PreCatchCRT 0x00004000 + +/* DCLK Index */ +#define VCLK25_175 0x00 +#define VCLK28_322 0x01 +#define VCLK31_5 0x02 +#define VCLK36 0x03 +#define VCLK40 0x04 +#define VCLK49_5 0x05 +#define VCLK50 0x06 +#define VCLK56_25 0x07 +#define VCLK65 0x08 +#define VCLK75 0x09 +#define VCLK78_75 0x0a +#define VCLK94_5 0x0b +#define VCLK108 0x0c +#define VCLK135 0x0d +#define VCLK157_5 0x0e +#define VCLK162 0x0f +/* #define VCLK193_25 0x10 */ +#define VCLK154 0x10 +#define VCLK83_5 0x11 +#define VCLK106_5 0x12 +#define VCLK146_25 0x13 +#define VCLK148_5 0x14 +#define VCLK71 0x15 +#define VCLK88_75 0x16 +#define VCLK119 0x17 +#define VCLK85_5 0x18 +#define VCLK97_75 0x19 +#define VCLK118_25 0x1a + +struct ast_vbios_enhtable { +u32 ht; +u32 hde; +u32 hfp; +u32 hsync; +u32 vt; +u32 vde; +u32 vfp; +u32 vsync; +u32 dclk_index; +u32 flags; +u32 refresh_rate; +u32 refresh_rate_index; +u32 mode_id; +}; + +#define AST_VBIOS_INVALID_MODE \ + {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u} + +static inline bool ast_vbios_mode_is_valid (const struct ast_vbios_enhtable *vmode) +{ +return vmode->ht && vmode->vt && vmode->refresh_rate; +} + +const struct ast_vbios_enhtable *ast_vbios_find_mode (const struct ast_device *ast, +const struct drm_display_mode *mode); + +#endif
Thomas Zimmermann
maintainerPATCH 11/15 drm/ast: Validate DRM display modes against VBIOS modes
In reply to Thomas ZimmermannTest DRM display modes against the list of modes supported by the VBIOS. The helper will respect the supported-modes flags in struct ast_device. Hence only DRM display modes supported by the VBIOS will be reported; without the current duplication of this information.
--- drivers/gpu/drm/ast/ast_mode.c | 62 +++------------------------------- 1 file changed, 5 insertions(+), 57 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +5 -57
@@ -950,65 +950,13 @@ static enum drm_mode_status ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode) { struct ast_device *ast = to_ast_device(crtc->dev); -enum drm_mode_status status; - -if (ast->support_wsxga_p) { -if ((mode->hdisplay ==1680 ) && (mode->vdisplay ==1050 )) -return MODE_OK ; -if ((mode->hdisplay ==1280 ) && (mode->vdisplay ==800 )) -return MODE_OK ; -if ((mode->hdisplay ==1440 ) && (mode->vdisplay ==900 )) -return MODE_OK ; -if ((mode->hdisplay ==1360 ) && (mode->vdisplay ==768 )) -return MODE_OK ; -if ((mode->hdisplay ==1600 ) && (mode->vdisplay ==900 )) -return MODE_OK ; - -if (ast->support_fullhd) { -if ((mode->hdisplay ==1920 ) && (mode->vdisplay ==1080 )) -return MODE_OK ; - -if ((mode->hdisplay ==1920 ) && (mode->vdisplay ==1200 )) { -if (ast->support_wuxga) -return MODE_OK ; -else -return MODE_NOMODE ; - } - } - } +const struct ast_vbios_enhtable *vmode; - status =MODE_NOMODE ; + vmode =ast_vbios_find_mode (ast, mode); +if (!vmode) +return MODE_NOMODE ; -switch (mode->hdisplay) { -case 640 : -if (mode->vdisplay ==480 ) - status =MODE_OK ; -break ; -case 800 : -if (mode->vdisplay ==600 ) - status =MODE_OK ; -break ; -case 1024 : -if (mode->vdisplay ==768 ) - status =MODE_OK ; -break ; -case 1152 : -if (mode->vdisplay ==864 ) - status =MODE_OK ; -break ; -case 1280 : -if (mode->vdisplay ==1024 ) - status =MODE_OK ; -break ; -case 1600 : -if (mode->vdisplay ==1200 ) - status =MODE_OK ; -break ; -default : -break ; - } - -return status; +return MODE_OK ; }static void ast_crtc_helper_mode_set_nofb (struct drm_crtc *crtc)
Signature · 1 line
2.47.1
Re: [PATCH 11/15] drm/ast: Validate DRM display modes against VBIOS modes
Quoted 4 lines · Thomas Zimmermann
Test DRM display modes against the list of modes supported by the VBIOS. The helper will respect the supported-modes flags in struct
ast_device. Hence only DRM display modes supported by the VBIOS will be reported; without the current duplication of this information.
Thanks, it looks good to me.
Quoted 81 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 62 +++------------------------------- 1 file changed, 5 insertions(+), 57 deletions(-)drivers/gpu/drm/ast/ast_mode.c +5
-57@@ -950,65 +950,13 @@ static enum drm_mode_status ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode) { struct ast_device *ast = to_ast_device(crtc->dev); -enum drm_mode_status status; - -if (ast->support_wsxga_p) { -if ((mode->hdisplay ==1680 ) && (mode->vdisplay ==1050 )) -return MODE_OK ; -if ((mode->hdisplay ==1280 ) && (mode->vdisplay ==800 )) -return MODE_OK ; -if ((mode->hdisplay ==1440 ) && (mode->vdisplay ==900 )) -return MODE_OK ; -if ((mode->hdisplay ==1360 ) && (mode->vdisplay ==768 )) -return MODE_OK ; -if ((mode->hdisplay ==1600 ) && (mode->vdisplay ==900 )) -return MODE_OK ; - -if (ast->support_fullhd) { -if ((mode->hdisplay ==1920 ) && (mode->vdisplay ==1080 )) -return MODE_OK ; - -if ((mode->hdisplay ==1920 ) && (mode->vdisplay ==1200 )) { -if (ast->support_wuxga) -return MODE_OK ; -else -return MODE_NOMODE ; - } - } - } +const struct ast_vbios_enhtable *vmode; - status =MODE_NOMODE ; + vmode =ast_vbios_find_mode (ast, mode); +if (!vmode) +return MODE_NOMODE ; -switch (mode->hdisplay) { -case 640 : -if (mode->vdisplay ==480 ) - status =MODE_OK ; -break ; -case 800 : -if (mode->vdisplay ==600 ) - status =MODE_OK ; -break ; -case 1024 : -if (mode->vdisplay ==768 ) - status =MODE_OK ; -break ; -case 1152 : -if (mode->vdisplay ==864 ) - status =MODE_OK ; -break ; -case 1280 : -if (mode->vdisplay ==1024 ) - status =MODE_OK ; -break ; -case 1600 : -if (mode->vdisplay ==1200 ) - status =MODE_OK ; -break ; -default : -break ; - } - -return status; +return MODE_OK ; }static void ast_crtc_helper_mode_set_nofb (struct drm_crtc *crtc)
Thomas Zimmermann
maintainerPATCH 12/15 drm/ast: Inline ast_get_vbios_mode_info()
In reply to Thomas ZimmermannThe helper ast_get_vbios_mode_info() retrieves hardware-specific format and display-mode information. Inline the function into its only caller.
While at it, also replace a use of struct drm_format_info.cpp with the correct DRM 4CC codes.
--- drivers/gpu/drm/ast/ast_mode.c | 112 ++++++++++++++++----------------- 1 file changed, 54 insertions(+), 58 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +54 -58
@@ -107,59 +107,6 @@ static void ast_crtc_set_gamma(struct ast_device *ast, } } -static bool ast_get_vbios_mode_info (struct ast_device *ast, -const struct drm_format_info *format, -const struct drm_display_mode *mode, -struct drm_display_mode *adjusted_mode, -struct ast_vbios_mode_info *vbios_mode) -{ -u32 hborder, vborder; - -switch (format->cpp[0 ] *8 ) { -case 8 : - vbios_mode->std_table = &vbios_stdtable[VGAModeIndex]; -break ; -case 16 : - vbios_mode->std_table = &vbios_stdtable[HiCModeIndex]; -break ; -case 24 : -case 32 : - vbios_mode->std_table = &vbios_stdtable[TrueCModeIndex]; -break ; -default : -return false; - } - - vbios_mode->enh_table =ast_vbios_find_mode (ast, mode); -if (!vbios_mode->enh_table) -return false; - - hborder = (vbios_mode->enh_table->flags & HBorder) ?8 :0 ; - vborder = (vbios_mode->enh_table->flags & VBorder) ?8 :0 ; - - adjusted_mode->crtc_hdisplay = vbios_mode->enh_table->hde; - adjusted_mode->crtc_htotal = vbios_mode->enh_table->ht; - adjusted_mode->crtc_hblank_start = vbios_mode->enh_table->hde + hborder; - adjusted_mode->crtc_hblank_end = vbios_mode->enh_table->ht - hborder; - adjusted_mode->crtc_hsync_start = vbios_mode->enh_table->hde + hborder + - vbios_mode->enh_table->hfp; - adjusted_mode->crtc_hsync_end = (vbios_mode->enh_table->hde + hborder + - vbios_mode->enh_table->hfp + - vbios_mode->enh_table->hsync); - - adjusted_mode->crtc_vdisplay = vbios_mode->enh_table->vde; - adjusted_mode->crtc_vtotal = vbios_mode->enh_table->vt; - adjusted_mode->crtc_vblank_start = vbios_mode->enh_table->vde + vborder; - adjusted_mode->crtc_vblank_end = vbios_mode->enh_table->vt - vborder; - adjusted_mode->crtc_vsync_start = vbios_mode->enh_table->vde + vborder + - vbios_mode->enh_table->vfp; - adjusted_mode->crtc_vsync_end = (vbios_mode->enh_table->vde + vborder + - vbios_mode->enh_table->vfp + - vbios_mode->enh_table->vsync); - -return true; -} -static void ast_set_vbios_color_reg (struct ast_device *ast,const struct drm_format_info *format,const struct ast_vbios_mode_info *vbios_mode)
@@ -990,13 +937,17 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state) {struct drm_crtc_state *crtc_state =drm_atomic_get_new_crtc_state (state, crtc); +struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;struct drm_crtc_state *old_crtc_state =drm_atomic_get_old_crtc_state (state, crtc);struct ast_crtc_state *old_ast_crtc_state =to_ast_crtc_state (old_crtc_state);struct drm_device *dev = crtc->dev;struct ast_device *ast =to_ast_device (dev);struct ast_crtc_state *ast_state;const struct drm_format_info *format; -bool succ; +struct ast_vbios_mode_info *vbios_mode; +const struct ast_vbios_enhtable *vmode; +unsigned int hborder =0 ; +unsigned int vborder =0 ;int ret;if (!crtc_state->enable)
@@ -1028,11 +979,56 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc, } } - succ =ast_get_vbios_mode_info (ast, format, &crtc_state->mode, - &crtc_state->adjusted_mode, - &ast_state->vbios_mode_info); -if (!succ) + vbios_mode = &ast_state->vbios_mode_info; + +/* +* Set register tables. +* +* TODO: These tables mix all kinds of fields and should +* probably be resolved into various helper functions. +*/ +switch (format->format) { +case DRM_FORMAT_C8 : + vbios_mode->std_table = &vbios_stdtable[VGAModeIndex]; +break ; +case DRM_FORMAT_RGB565 : + vbios_mode->std_table = &vbios_stdtable[HiCModeIndex]; +break ; +case DRM_FORMAT_RGB888 : +case DRM_FORMAT_XRGB8888 : + vbios_mode->std_table = &vbios_stdtable[TrueCModeIndex]; +break ; +default : +return -EINVAL ; + } + +/* +* Find the VBIOS mode and adjust the DRM display mode accordingly. +*/ + + vmode =ast_vbios_find_mode (ast, &crtc_state->mode); +if (!vmode)return -EINVAL ; + ast_state->vbios_mode_info.enh_table = vmode; + +if (vmode->flags & HBorder) + hborder =8 ; +if (vmode->flags & VBorder) + vborder =8 ; + + adjusted_mode->crtc_hdisplay = vmode->hde; + adjusted_mode->crtc_hblank_start = vmode->hde + hborder; + adjusted_mode->crtc_hblank_end = vmode->ht - hborder; + adjusted_mode->crtc_hsync_start = vmode->hde + hborder + vmode->hfp; + adjusted_mode->crtc_hsync_end = vmode->hde + hborder + vmode->hfp + vmode->hsync; + adjusted_mode->crtc_htotal = vmode->ht; + + adjusted_mode->crtc_vdisplay = vmode->vde; + adjusted_mode->crtc_vblank_start = vmode->vde + vborder; + adjusted_mode->crtc_vblank_end = vmode->vt - vborder; + adjusted_mode->crtc_vsync_start = vmode->vde + vborder + vmode->vfp; + adjusted_mode->crtc_vsync_end = vmode->vde + vborder + vmode->vfp + vmode->vsync; + adjusted_mode->crtc_vtotal = vmode->vt;return 0 ; }
Signature · 1 line
2.47.1
Re: [PATCH 12/15] drm/ast: Inline ast_get_vbios_mode_info()
Quoted 5 lines · Thomas Zimmermann
The helper
ast_get_vbios_mode_info()retrieves hardware-specific format and display-mode information. Inline the function into its only caller.While at it, also replace a use of struct drm_format_info.cpp with the correct DRM 4CC codes.
Thanks, it looks good to me.
Signature · 1 line
Jocelyn
Quoted 150 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 112 ++++++++++++++++----------------- 1 file changed, 54 insertions(+), 58 deletions(-)drivers/gpu/drm/ast/ast_mode.c +54
-58@@ -107,59 +107,6 @@ static void ast_crtc_set_gamma(struct ast_device *ast, } } -static bool ast_get_vbios_mode_info (struct ast_device *ast, -const struct drm_format_info *format, -const struct drm_display_mode *mode, -struct drm_display_mode *adjusted_mode, -struct ast_vbios_mode_info *vbios_mode) -{ -u32 hborder, vborder; - -switch (format->cpp[0 ] *8 ) { -case 8 : - vbios_mode->std_table = &vbios_stdtable[VGAModeIndex]; -break ; -case 16 : - vbios_mode->std_table = &vbios_stdtable[HiCModeIndex]; -break ; -case 24 : -case 32 : - vbios_mode->std_table = &vbios_stdtable[TrueCModeIndex]; -break ; -default : -return false; - } - - vbios_mode->enh_table =ast_vbios_find_mode (ast, mode); -if (!vbios_mode->enh_table) -return false; - - hborder = (vbios_mode->enh_table->flags & HBorder) ?8 :0 ; - vborder = (vbios_mode->enh_table->flags & VBorder) ?8 :0 ; - - adjusted_mode->crtc_hdisplay = vbios_mode->enh_table->hde; - adjusted_mode->crtc_htotal = vbios_mode->enh_table->ht; - adjusted_mode->crtc_hblank_start = vbios_mode->enh_table->hde + hborder; - adjusted_mode->crtc_hblank_end = vbios_mode->enh_table->ht - hborder; - adjusted_mode->crtc_hsync_start = vbios_mode->enh_table->hde + hborder + - vbios_mode->enh_table->hfp; - adjusted_mode->crtc_hsync_end = (vbios_mode->enh_table->hde + hborder + - vbios_mode->enh_table->hfp + - vbios_mode->enh_table->hsync); - - adjusted_mode->crtc_vdisplay = vbios_mode->enh_table->vde; - adjusted_mode->crtc_vtotal = vbios_mode->enh_table->vt; - adjusted_mode->crtc_vblank_start = vbios_mode->enh_table->vde + vborder; - adjusted_mode->crtc_vblank_end = vbios_mode->enh_table->vt - vborder; - adjusted_mode->crtc_vsync_start = vbios_mode->enh_table->vde + vborder + - vbios_mode->enh_table->vfp; - adjusted_mode->crtc_vsync_end = (vbios_mode->enh_table->vde + vborder + - vbios_mode->enh_table->vfp + - vbios_mode->enh_table->vsync); - -return true; -} -static void ast_set_vbios_color_reg (struct ast_device *ast,const struct drm_format_info *format,const struct ast_vbios_mode_info *vbios_mode)@@ -990,13 +937,17 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state) {struct drm_crtc_state *crtc_state =drm_atomic_get_new_crtc_state (state, crtc); +struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;struct drm_crtc_state *old_crtc_state =drm_atomic_get_old_crtc_state (state, crtc);struct ast_crtc_state *old_ast_crtc_state =to_ast_crtc_state (old_crtc_state);struct drm_device *dev = crtc->dev;struct ast_device *ast =to_ast_device (dev);struct ast_crtc_state *ast_state;const struct drm_format_info *format; -bool succ; +struct ast_vbios_mode_info *vbios_mode; +const struct ast_vbios_enhtable *vmode; +unsigned int hborder =0 ; +unsigned int vborder =0 ;int ret;if (!crtc_state->enable)@@ -1028,11 +979,56 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc, } } - succ =ast_get_vbios_mode_info (ast, format, &crtc_state->mode, - &crtc_state->adjusted_mode, - &ast_state->vbios_mode_info); -if (!succ) + vbios_mode = &ast_state->vbios_mode_info; + +/* +* Set register tables. +* +* TODO: These tables mix all kinds of fields and should +* probably be resolved into various helper functions. +*/ +switch (format->format) { +case DRM_FORMAT_C8 : + vbios_mode->std_table = &vbios_stdtable[VGAModeIndex]; +break ; +case DRM_FORMAT_RGB565 : + vbios_mode->std_table = &vbios_stdtable[HiCModeIndex]; +break ; +case DRM_FORMAT_RGB888 : +case DRM_FORMAT_XRGB8888 : + vbios_mode->std_table = &vbios_stdtable[TrueCModeIndex]; +break ; +default : +return -EINVAL ; + } + +/* +* Find the VBIOS mode and adjust the DRM display mode accordingly. +*/ + + vmode =ast_vbios_find_mode (ast, &crtc_state->mode); +if (!vmode)return -EINVAL ; + ast_state->vbios_mode_info.enh_table = vmode; + +if (vmode->flags & HBorder) + hborder =8 ; +if (vmode->flags & VBorder) + vborder =8 ; + + adjusted_mode->crtc_hdisplay = vmode->hde; + adjusted_mode->crtc_hblank_start = vmode->hde + hborder; + adjusted_mode->crtc_hblank_end = vmode->ht - hborder; + adjusted_mode->crtc_hsync_start = vmode->hde + hborder + vmode->hfp; + adjusted_mode->crtc_hsync_end = vmode->hde + hborder + vmode->hfp + vmode->hsync; + adjusted_mode->crtc_htotal = vmode->ht; + + adjusted_mode->crtc_vdisplay = vmode->vde; + adjusted_mode->crtc_vblank_start = vmode->vde + vborder; + adjusted_mode->crtc_vblank_end = vmode->vt - vborder; + adjusted_mode->crtc_vsync_start = vmode->vde + vborder + vmode->vfp; + adjusted_mode->crtc_vsync_end = vmode->vde + vborder + vmode->vfp + vmode->vsync; + adjusted_mode->crtc_vtotal = vmode->vt;return 0 ; }
Thomas Zimmermann
maintainerPATCH 13/15 drm/ast: astdp: Rework display-mode setting
In reply to Thomas ZimmermannASTDP requires a mode index, depending on the resolution. Move the look-up code from ast_dp_set_mode() into a separate helper. Inline the rest of the function into its only caller. Rename the variable names and register constants to match the programming manual.
As before, the mode-index lookup still happens during the update's atomic commit. Right now, there's no way of doing it during the atomic check. The lookup requires the VBIOS mode, which is not available at the atomic check's invocation. At least warn now if the mode index could not be found.
--- drivers/gpu/drm/ast/ast_dp.c | 172 +++++++++++++++++++--------------- drivers/gpu/drm/ast/ast_reg.h | 18 +--- 2 files changed, 100 insertions(+), 90 deletions(-)
drivers/gpu/drm/ast/ast_dp.c +96 -76
@@ -14,6 +14,82 @@#include "ast_drv.h" #include "ast_vbios.h" +static int ast_astdp_get_mode_index (const struct ast_vbios_enhtable *vmode) +{ +u8 refresh_rate_index; + +if (vmode->refresh_rate_index <1 || vmode->refresh_rate_index >255 ) +return -EINVAL ; + + refresh_rate_index = vmode->refresh_rate_index -1 ; + +switch (vmode->hde) { +case 320 : +if (vmode->vde ==240 ) +return ASTDP_320x240_60; +break ; +case 400 : +if (vmode->vde ==300 ) +return ASTDP_400x300_60; +break ; +case 512 : +if (vmode->vde ==384 ) +return ASTDP_512x384_60; +break ; +case 640 : +if (vmode->vde ==480 ) +return (u8)(ASTDP_640x480_60 + (u8 )refresh_rate_index); +break ; +case 800 : +if (vmode->vde ==600 ) +return (u8)(ASTDP_800x600_56 + (u8 )refresh_rate_index); +break ; +case 1024 : +if (vmode->vde ==768 ) +return (u8)(ASTDP_1024x768_60 + (u8 )refresh_rate_index); +break ; +case 1152 : +if (vmode->vde ==864 ) +return ASTDP_1152x864_75; +break ; +case 1280 : +if (vmode->vde ==800 ) +return (u8)(ASTDP_1280x800_60_RB - (u8 )refresh_rate_index); +if (vmode->vde ==1024 ) +return (u8)(ASTDP_1280x1024_60 + (u8 )refresh_rate_index); +break ; +case 1360 : +case 1366 : +if (vmode->vde ==768 ) +return ASTDP_1366x768_60; +break ; +case 1440 : +if (vmode->vde ==900 ) +return (u8)(ASTDP_1440x900_60_RB - (u8 )refresh_rate_index); +break ; +case 1600 : +if (vmode->vde ==900 ) +return (u8)(ASTDP_1600x900_60_RB - (u8 )refresh_rate_index); +if (vmode->vde ==1200 ) +return ASTDP_1600x1200_60; +break ; +case 1680 : +if (vmode->vde ==1050 ) +return (u8)(ASTDP_1680x1050_60_RB - (u8 )refresh_rate_index); +break ; +case 1920 : +if (vmode->vde ==1080 ) +return ASTDP_1920x1080_60; +if (vmode->vde ==1200 ) +return ASTDP_1920x1200_60; +break ; +default : +break ; + } + +return -EINVAL ; +} +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 ))
@@ -222,80 +298,6 @@ static void ast_dp_set_enable(struct ast_device *ast, bool enabled)drm_WARN_ON (dev, !__ast_dp_wait_enable (ast, enabled)); } -static void ast_dp_set_mode (struct drm_crtc *crtc,struct ast_vbios_mode_info *vbios_mode) -{ -struct ast_device *ast =to_ast_device (crtc->dev); - -u32 ulRefreshRateIndex; -u8 ModeIdx; - - ulRefreshRateIndex = vbios_mode->enh_table->refresh_rate_index -1 ; - -switch (crtc->mode.crtc_hdisplay) { -case 320 : - ModeIdx = ASTDP_320x240_60; -break ; -case 400 : - ModeIdx = ASTDP_400x300_60; -break ; -case 512 : - ModeIdx = ASTDP_512x384_60; -break ; -case 640 : - ModeIdx = (ASTDP_640x480_60 + (u8 ) ulRefreshRateIndex); -break ; -case 800 : - ModeIdx = (ASTDP_800x600_56 + (u8 ) ulRefreshRateIndex); -break ; -case 1024 : - ModeIdx = (ASTDP_1024x768_60 + (u8 ) ulRefreshRateIndex); -break ; -case 1152 : - ModeIdx = ASTDP_1152x864_75; -break ; -case 1280 : -if (crtc->mode.crtc_vdisplay ==800 ) - ModeIdx = (ASTDP_1280x800_60_RB - (u8 ) ulRefreshRateIndex); -else // 1024 - ModeIdx = (ASTDP_1280x1024_60 + (u8 ) ulRefreshRateIndex); -break ; -case 1360 : -case 1366 : - ModeIdx = ASTDP_1366x768_60; -break ; -case 1440 : - ModeIdx = (ASTDP_1440x900_60_RB - (u8 ) ulRefreshRateIndex); -break ; -case 1600 : -if (crtc->mode.crtc_vdisplay ==900 ) - ModeIdx = (ASTDP_1600x900_60_RB - (u8 ) ulRefreshRateIndex); -else //1200 - ModeIdx = ASTDP_1600x1200_60; -break ; -case 1680 : - ModeIdx = (ASTDP_1680x1050_60_RB - (u8 ) ulRefreshRateIndex); -break ; -case 1920 : -if (crtc->mode.crtc_vdisplay ==1080 ) - ModeIdx = ASTDP_1920x1080_60; -else //1200 - ModeIdx = ASTDP_1920x1200_60; -break ; -default : -return ; - } - -/* -* CRE0[7:0]: MISC0 ((0x00: 18-bpp) or (0x20: 24-bpp) -* CRE1[7:0]: MISC1 (default: 0x00) -* CRE2[7:0]: video format index (0x00 ~ 0x20 or 0x40 ~ 0x50) -*/ -ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xE0 ,ASTDP_AND_CLEAR_MASK , - ASTDP_MISC0_24bpp); -ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xE1 ,ASTDP_AND_CLEAR_MASK ,ASTDP_MISC1 ); -ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xE2 ,ASTDP_AND_CLEAR_MASK , ModeIdx); -} -static void ast_wait_for_vretrace (struct ast_device *ast) {unsigned long timeout = jiffies +HZ ;
@@ -318,11 +320,29 @@ static void ast_astdp_encoder_helper_atomic_mode_set(struct drm_encoder *encoderstruct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { - struct drm_crtc *crtc = crtc_state->crtc; + 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);struct ast_vbios_mode_info *vbios_mode_info = &ast_crtc_state->vbios_mode_info; +int mode_index; +u8 vgacre0, vgacre1, vgacre2; + + mode_index =ast_astdp_get_mode_index (vbios_mode_info->enh_table); +if (drm_WARN_ON (dev, mode_index <0 )) +return ; + +/* +* CRE0[7:0]: MISC0 ((0x00: 18-bpp) or (0x20: 24-bpp) +* CRE1[7:0]: MISC1 (default: 0x00) +* CRE2[7:0]: video format index (0x00 ~ 0x20 or 0x40 ~ 0x50) +*/ + vgacre0 =AST_IO_VGACRE0_24BPP ; + vgacre1 =0x00 ; + vgacre2 = mode_index &0xff ; -ast_dp_set_mode (crtc, vbios_mode_info); +ast_set_index_reg (ast,AST_IO_VGACRI ,0xe0 , vgacre0); +ast_set_index_reg (ast,AST_IO_VGACRI ,0xe1 , vgacre1); +ast_set_index_reg (ast,AST_IO_VGACRI ,0xe2 , vgacre2); } static void ast_astdp_encoder_helper_atomic_enable(struct drm_encoder *encoder,
drivers/gpu/drm/ast/ast_reg.h +4 -14
@@ -57,10 +57,14 @@#define AST_IO_VGACRD1_TX_ASTDP 0x0e#define AST_IO_VGACRD1_SUPPORTS_WUXGA BIT(0) +/* +* AST DisplayPort +*/ #define AST_IO_VGACRD7_EDID_VALID_FLAG BIT(0)#define AST_IO_VGACRDC_LINK_SUCCESS BIT(0)#define AST_IO_VGACRDF_HPD BIT(0)#define AST_IO_VGACRDF_DP_VIDEO_ENABLE BIT(4)/* mirrors AST_IO_VGACRE3_DP_VIDEO_ENABLE */ +#define AST_IO_VGACRE0_24BPP BIT(5)/* 18 bpp, if unset */ #define AST_IO_VGACRE3_DP_VIDEO_ENABLE BIT(0)#define AST_IO_VGACRE3_DP_PHY_SLEEP BIT(4)#define AST_IO_VGACRE5_EDID_READ_DONE BIT(0)
@@ -68,18 +72,4 @@#define AST_IO_VGAIR1_R (0x5A)#define AST_IO_VGAIR1_VREFRESH BIT(3) -/* -* AST DisplayPort -*/ - -/* -* ASTDP setmode registers: -* CRE0[7:0]: MISC0 ((0x00: 18-bpp) or (0x20: 24-bpp) -* CRE1[7:0]: MISC1 (default: 0x00) -* CRE2[7:0]: video format index (0x00 ~ 0x20 or 0x40 ~ 0x50) -*/ -#define ASTDP_MISC0_24bpp BIT(5) -#define ASTDP_MISC1 0 -#define ASTDP_AND_CLEAR_MASK 0x00 -#endif
Signature · 1 line
2.47.1
Re: [PATCH 13/15] drm/ast: astdp: Rework display-mode setting
Quoted 10 lines · Thomas Zimmermann
ASTDP requires a mode index, depending on the resolution. Move the look-up code from
ast_dp_set_mode()into a separate helper. Inline the rest of the function into its only caller. Rename the variable names and register constants to match the programming manual.As before, the mode-index lookup still happens during the update's atomic commit. Right now, there's no way of doing it during the atomic check. The lookup requires the VBIOS mode, which is not available at the atomic check's invocation. At least warn now if the mode index could not be found.
It looks good to me, I have one small comment below.
Quoted 19 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_dp.c | 172 +++++++++++++++++++--------------- drivers/gpu/drm/ast/ast_reg.h | 18 +--- 2 files changed, 100 insertions(+), 90 deletions(-)drivers/gpu/drm/ast/ast_dp.c +4
-0@@ -14,6 +14,82 @@#include "ast_drv.h" #include "ast_vbios.h" +static int ast_astdp_get_mode_index (const struct ast_vbios_enhtable *vmode) +{ +u8 refresh_rate_index; +
drivers/gpu/drm/ast/ast_dp.c line 30
Quoted 10 lines
drivers/gpu/drm/ast/ast_dp.c +10
-0+if (vmode->refresh_rate_index <1 || vmode->refresh_rate_index >255 ) +return -EINVAL ; + + refresh_rate_index = vmode->refresh_rate_index -1 ; + +switch (vmode->hde) { +case 320 : +if (vmode->vde ==240 ) +return ASTDP_320x240_60; +break ;
I find the switch() code introduces a lot of useless verbosity. I would prefer something like this:
if (vmode->hde == 240 && vmode->vde == 240)
return ASTDP_320x240_60; else if (vmode->hde == 400 && vmode->vde == 300) return ASTDP_400x300_60;
Quoted 216 lines
drivers/gpu/drm/ast/ast_dp.c +82
-76+case 400 : +if (vmode->vde ==300 ) +return ASTDP_400x300_60; +break ; +case 512 : +if (vmode->vde ==384 ) +return ASTDP_512x384_60; +break ; +case 640 : +if (vmode->vde ==480 ) +return (u8)(ASTDP_640x480_60 + (u8 )refresh_rate_index); +break ; +case 800 : +if (vmode->vde ==600 ) +return (u8)(ASTDP_800x600_56 + (u8 )refresh_rate_index); +break ; +case 1024 : +if (vmode->vde ==768 ) +return (u8)(ASTDP_1024x768_60 + (u8 )refresh_rate_index); +break ; +case 1152 : +if (vmode->vde ==864 ) +return ASTDP_1152x864_75; +break ; +case 1280 : +if (vmode->vde ==800 ) +return (u8)(ASTDP_1280x800_60_RB - (u8 )refresh_rate_index); +if (vmode->vde ==1024 ) +return (u8)(ASTDP_1280x1024_60 + (u8 )refresh_rate_index); +break ; +case 1360 : +case 1366 : +if (vmode->vde ==768 ) +return ASTDP_1366x768_60; +break ; +case 1440 : +if (vmode->vde ==900 ) +return (u8)(ASTDP_1440x900_60_RB - (u8 )refresh_rate_index); +break ; +case 1600 : +if (vmode->vde ==900 ) +return (u8)(ASTDP_1600x900_60_RB - (u8 )refresh_rate_index); +if (vmode->vde ==1200 ) +return ASTDP_1600x1200_60; +break ; +case 1680 : +if (vmode->vde ==1050 ) +return (u8)(ASTDP_1680x1050_60_RB - (u8 )refresh_rate_index); +break ; +case 1920 : +if (vmode->vde ==1080 ) +return ASTDP_1920x1080_60; +if (vmode->vde ==1200 ) +return ASTDP_1920x1200_60; +break ; +default : +break ; + } + +return -EINVAL ; +} +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 ))@@ -222,80 +298,6 @@ static void ast_dp_set_enable(struct ast_device *ast, bool enabled)drm_WARN_ON (dev, !__ast_dp_wait_enable (ast, enabled)); } -static void ast_dp_set_mode (struct drm_crtc *crtc,struct ast_vbios_mode_info *vbios_mode) -{ -struct ast_device *ast =to_ast_device (crtc->dev); - -u32 ulRefreshRateIndex; -u8 ModeIdx; - - ulRefreshRateIndex = vbios_mode->enh_table->refresh_rate_index -1 ; - -switch (crtc->mode.crtc_hdisplay) { -case 320 : - ModeIdx = ASTDP_320x240_60; -break ; -case 400 : - ModeIdx = ASTDP_400x300_60; -break ; -case 512 : - ModeIdx = ASTDP_512x384_60; -break ; -case 640 : - ModeIdx = (ASTDP_640x480_60 + (u8 ) ulRefreshRateIndex); -break ; -case 800 : - ModeIdx = (ASTDP_800x600_56 + (u8 ) ulRefreshRateIndex); -break ; -case 1024 : - ModeIdx = (ASTDP_1024x768_60 + (u8 ) ulRefreshRateIndex); -break ; -case 1152 : - ModeIdx = ASTDP_1152x864_75; -break ; -case 1280 : -if (crtc->mode.crtc_vdisplay ==800 ) - ModeIdx = (ASTDP_1280x800_60_RB - (u8 ) ulRefreshRateIndex); -else // 1024 - ModeIdx = (ASTDP_1280x1024_60 + (u8 ) ulRefreshRateIndex); -break ; -case 1360 : -case 1366 : - ModeIdx = ASTDP_1366x768_60; -break ; -case 1440 : - ModeIdx = (ASTDP_1440x900_60_RB - (u8 ) ulRefreshRateIndex); -break ; -case 1600 : -if (crtc->mode.crtc_vdisplay ==900 ) - ModeIdx = (ASTDP_1600x900_60_RB - (u8 ) ulRefreshRateIndex); -else //1200 - ModeIdx = ASTDP_1600x1200_60; -break ; -case 1680 : - ModeIdx = (ASTDP_1680x1050_60_RB - (u8 ) ulRefreshRateIndex); -break ; -case 1920 : -if (crtc->mode.crtc_vdisplay ==1080 ) - ModeIdx = ASTDP_1920x1080_60; -else //1200 - ModeIdx = ASTDP_1920x1200_60; -break ; -default : -return ; - } - -/* -* CRE0[7:0]: MISC0 ((0x00: 18-bpp) or (0x20: 24-bpp) -* CRE1[7:0]: MISC1 (default: 0x00) -* CRE2[7:0]: video format index (0x00 ~ 0x20 or 0x40 ~ 0x50) -*/ -ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xE0 ,ASTDP_AND_CLEAR_MASK , - ASTDP_MISC0_24bpp); -ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xE1 ,ASTDP_AND_CLEAR_MASK ,ASTDP_MISC1 ); -ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xE2 ,ASTDP_AND_CLEAR_MASK , ModeIdx); -} -static void ast_wait_for_vretrace (struct ast_device *ast) {unsigned long timeout = jiffies +HZ ;@@ -318,11 +320,29 @@ static void ast_astdp_encoder_helper_atomic_mode_set(struct drm_encoder *encoderstruct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { - struct drm_crtc *crtc = crtc_state->crtc; + 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);struct ast_vbios_mode_info *vbios_mode_info = &ast_crtc_state->vbios_mode_info; +int mode_index; +u8 vgacre0, vgacre1, vgacre2; + + mode_index =ast_astdp_get_mode_index (vbios_mode_info->enh_table); +if (drm_WARN_ON (dev, mode_index <0 )) +return ; + +/* +* CRE0[7:0]: MISC0 ((0x00: 18-bpp) or (0x20: 24-bpp) +* CRE1[7:0]: MISC1 (default: 0x00) +* CRE2[7:0]: video format index (0x00 ~ 0x20 or 0x40 ~ 0x50) +*/ + vgacre0 =AST_IO_VGACRE0_24BPP ; + vgacre1 =0x00 ; + vgacre2 = mode_index &0xff ; -ast_dp_set_mode (crtc, vbios_mode_info); +ast_set_index_reg (ast,AST_IO_VGACRI ,0xe0 , vgacre0); +ast_set_index_reg (ast,AST_IO_VGACRI ,0xe1 , vgacre1); +ast_set_index_reg (ast,AST_IO_VGACRI ,0xe2 , vgacre2); } static void ast_astdp_encoder_helper_atomic_enable(struct drm_encoder *encoder,drivers/gpu/drm/ast/ast_reg.h +4
-14@@ -57,10 +57,14 @@#define AST_IO_VGACRD1_TX_ASTDP 0x0e#define AST_IO_VGACRD1_SUPPORTS_WUXGA BIT(0) +/* +* AST DisplayPort +*/ #define AST_IO_VGACRD7_EDID_VALID_FLAG BIT(0)#define AST_IO_VGACRDC_LINK_SUCCESS BIT(0)#define AST_IO_VGACRDF_HPD BIT(0)#define AST_IO_VGACRDF_DP_VIDEO_ENABLE BIT(4)/* mirrors AST_IO_VGACRE3_DP_VIDEO_ENABLE */ +#define AST_IO_VGACRE0_24BPP BIT(5)/* 18 bpp, if unset */ #define AST_IO_VGACRE3_DP_VIDEO_ENABLE BIT(0)#define AST_IO_VGACRE3_DP_PHY_SLEEP BIT(4)#define AST_IO_VGACRE5_EDID_READ_DONE BIT(0)@@ -68,18 +72,4 @@#define AST_IO_VGAIR1_R (0x5A)#define AST_IO_VGAIR1_VREFRESH BIT(3) -/* -* AST DisplayPort -*/ - -/* -* ASTDP setmode registers: -* CRE0[7:0]: MISC0 ((0x00: 18-bpp) or (0x20: 24-bpp) -* CRE1[7:0]: MISC1 (default: 0x00) -* CRE2[7:0]: video format index (0x00 ~ 0x20 or 0x40 ~ 0x50) -*/ -#define ASTDP_MISC0_24bpp BIT(5) -#define ASTDP_MISC1 0 -#define ASTDP_AND_CLEAR_MASK 0x00 -#endif
Thomas Zimmermann
maintainerPATCH 14/15 drm/ast: Remove struct ast_vbios_mode_info
In reply to Thomas ZimmermannThe type struct ast_vbios_mode_info used to store information about the color format and display mode. It has outlived its purpose. Inline its fields into struct ast_crtc_state and replace all instances.
--- drivers/gpu/drm/ast/ast_dp.c | 3 +- drivers/gpu/drm/ast/ast_drv.h | 8 ++--- drivers/gpu/drm/ast/ast_mode.c | 65 +++++++++++++++------------------- 3 files changed, 32 insertions(+), 44 deletions(-)
drivers/gpu/drm/ast/ast_dp.c +1 -2
@@ -323,11 +323,10 @@ static void ast_astdp_encoder_helper_atomic_mode_set(struct drm_encoder *encoderstruct 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); -struct ast_vbios_mode_info *vbios_mode_info = &ast_crtc_state->vbios_mode_info;int mode_index;u8 vgacre0, vgacre1, vgacre2; - mode_index =ast_astdp_get_mode_index (vbios_mode_info->enh_table); + mode_index =ast_astdp_get_mode_index (ast_crtc_state->vmode);if (drm_WARN_ON (dev, mode_index <0 ))return ;
drivers/gpu/drm/ast/ast_drv.h +2 -6
@@ -358,18 +358,14 @@ struct ast_vbios_dclk_info {u8 param3; }; -struct ast_vbios_mode_info { -const struct ast_vbios_stdtable *std_table; -const struct ast_vbios_enhtable *enh_table; -}; -struct ast_crtc_state {struct drm_crtc_state base;/* Last known format of primary plane */ const struct drm_format_info *format; -struct ast_vbios_mode_info vbios_mode_info; +const struct ast_vbios_stdtable *std_table; +const struct ast_vbios_enhtable *vmode; };#define to_ast_crtc_state (state) container_of(state, struct ast_crtc_state, base)
drivers/gpu/drm/ast/ast_mode.c +29 -36
193 lines not on this page · raw message
Signature · 1 line
2.47.1
Re: [PATCH 14/15] drm/ast: Remove struct ast_vbios_mode_info
Quoted 3 lines · Thomas Zimmermann
The type struct
ast_vbios_mode_infoused to store information about the color format and display mode. It has outlived its purpose. Inline its fields into structast_crtc_stateand replace all instances.
Thanks, it looks good to me.
Quoted 262 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_dp.c | 3 +- drivers/gpu/drm/ast/ast_drv.h | 8 ++--- drivers/gpu/drm/ast/ast_mode.c | 65 +++++++++++++++------------------- 3 files changed, 32 insertions(+), 44 deletions(-)drivers/gpu/drm/ast/ast_dp.c +1
-2@@ -323,11 +323,10 @@ static void ast_astdp_encoder_helper_atomic_mode_set(struct drm_encoder *encoderstruct 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); -struct ast_vbios_mode_info *vbios_mode_info = &ast_crtc_state->vbios_mode_info;int mode_index;u8 vgacre0, vgacre1, vgacre2; - mode_index =ast_astdp_get_mode_index (vbios_mode_info->enh_table); + mode_index =ast_astdp_get_mode_index (ast_crtc_state->vmode);if (drm_WARN_ON (dev, mode_index <0 ))return ;drivers/gpu/drm/ast/ast_drv.h +2
-6@@ -358,18 +358,14 @@ struct ast_vbios_dclk_info {u8 param3; }; -struct ast_vbios_mode_info { -const struct ast_vbios_stdtable *std_table; -const struct ast_vbios_enhtable *enh_table; -}; -struct ast_crtc_state {struct drm_crtc_state base;/* Last known format of primary plane */ const struct drm_format_info *format; -struct ast_vbios_mode_info vbios_mode_info; +const struct ast_vbios_stdtable *std_table; +const struct ast_vbios_enhtable *vmode; };#define to_ast_crtc_state (state) container_of(state, struct ast_crtc_state, base)drivers/gpu/drm/ast/ast_mode.c +29
-36@@ -109,7 +109,7 @@ static void ast_crtc_set_gamma(struct ast_device *ast,static void ast_set_vbios_color_reg (struct ast_device *ast,const struct drm_format_info *format, -const struct ast_vbios_mode_info *vbios_mode) +const struct ast_vbios_enhtable *vmode) {u32 color_index;@@ -132,7 +132,7 @@ static void ast_set_vbios_color_reg(struct ast_device *ast,ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,0x00 ); -if (vbios_mode->enh_table->flags & NewModeInfo) { +if (vmode->flags & NewModeInfo) {ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,0xa8 );ast_set_index_reg (ast,AST_IO_VGACRI ,0x92 , format->cpp[0 ] *8 ); }@@ -140,19 +140,19 @@ static void ast_set_vbios_color_reg(struct ast_device *ast,static void ast_set_vbios_mode_reg (struct ast_device *ast,const struct drm_display_mode *adjusted_mode, -const struct ast_vbios_mode_info *vbios_mode) +const struct ast_vbios_enhtable *vmode) {u32 refresh_rate_index, mode_id; - refresh_rate_index = vbios_mode->enh_table->refresh_rate_index; - mode_id = vbios_mode->enh_table->mode_id; + refresh_rate_index = vmode->refresh_rate_index; + mode_id = vmode->mode_id;ast_set_index_reg (ast,AST_IO_VGACRI ,0x8d , refresh_rate_index &0xff );ast_set_index_reg (ast,AST_IO_VGACRI ,0x8e , mode_id &0xff );ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,0x00 ); -if (vbios_mode->enh_table->flags & NewModeInfo) { +if (vmode->flags & NewModeInfo) {ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,0xa8 );ast_set_index_reg (ast,AST_IO_VGACRI ,0x93 , adjusted_mode->clock /1000 );ast_set_index_reg (ast,AST_IO_VGACRI ,0x94 , adjusted_mode->crtc_hdisplay);@@ -164,14 +164,11 @@ static void ast_set_vbios_mode_reg(struct ast_device *ast,static void ast_set_std_reg (struct ast_device *ast,struct drm_display_mode *mode, -struct ast_vbios_mode_info *vbios_mode) +const struct ast_vbios_stdtable *stdtable) { -const struct ast_vbios_stdtable *stdtable;u32 i;u8 jreg; - stdtable = vbios_mode->std_table; - jreg = stdtable->misc;ast_io_write8 (ast,AST_IO_VGAMR_W , jreg);@@ -212,13 +209,13 @@ static void ast_set_std_reg(struct ast_device *ast,static void ast_set_crtc_reg (struct ast_device *ast,struct drm_display_mode *mode, -struct ast_vbios_mode_info *vbios_mode) +const struct ast_vbios_enhtable *vmode) {u8 jreg05 =0 , jreg07 =0 , jreg09 =0 , jregAC =0 , jregAD =0 , jregAE =0 ;u16 temp, precache =0 ;if ((IS_AST_GEN6 (ast) ||IS_AST_GEN7 (ast)) && - (vbios_mode->enh_table->flags & AST2500PreCatchCRT)) + (vmode->flags & AST2500PreCatchCRT)) precache =40 ;ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0x11 ,0x7f ,0x00 );@@ -337,14 +334,14 @@ static void ast_set_offset_reg(struct ast_device *ast,static void ast_set_dclk_reg (struct ast_device *ast,struct drm_display_mode *mode, -struct ast_vbios_mode_info *vbios_mode) +const struct ast_vbios_enhtable *vmode) {const struct ast_vbios_dclk_info *clk_info;if (IS_AST_GEN6 (ast) ||IS_AST_GEN7 (ast)) - clk_info = &dclk_table_ast2500[vbios_mode->enh_table->dclk_index]; + clk_info = &dclk_table_ast2500[vmode->dclk_index];else - clk_info = &dclk_table[vbios_mode->enh_table->dclk_index]; + clk_info = &dclk_table[vmode->dclk_index];ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xc0 ,0x00 , clk_info->param1);ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xc1 ,0x00 , clk_info->param2);@@ -402,15 +399,15 @@ static void ast_set_crtthd_reg(struct ast_device *ast)static void ast_set_sync_reg (struct ast_device *ast,struct drm_display_mode *mode, -struct ast_vbios_mode_info *vbios_mode) +const struct ast_vbios_enhtable *vmode) {u8 jreg; jreg =ast_io_read8 (ast,AST_IO_VGAMR_R ); jreg &= ~0xC0 ; -if (vbios_mode->enh_table->flags & NVSync) +if (vmode->flags & NVSync) jreg |=0x80 ; -if (vbios_mode->enh_table->flags & NHSync) +if (vmode->flags & NHSync) jreg |=0x40 ;ast_io_write8 (ast,AST_IO_VGAMR_W , jreg); }@@ -530,10 +527,9 @@ static void ast_primary_plane_helper_atomic_update(struct drm_plane *plane,if (!old_fb || (fb->format != old_fb->format) || crtc_state->mode_changed) {struct ast_crtc_state *ast_crtc_state =to_ast_crtc_state (crtc_state); -struct ast_vbios_mode_info *vbios_mode_info = &ast_crtc_state->vbios_mode_info;ast_set_color_reg (ast, fb->format); -ast_set_vbios_color_reg (ast, fb->format, vbios_mode_info); +ast_set_vbios_color_reg (ast, fb->format, ast_crtc_state->vmode); }drm_atomic_helper_damage_iter_init (&iter, old_plane_state, plane_state);@@ -912,8 +908,8 @@ static void ast_crtc_helper_mode_set_nofb(struct drm_crtc *crtc)struct ast_device *ast =to_ast_device (dev);struct drm_crtc_state *crtc_state = crtc->state;struct ast_crtc_state *ast_crtc_state =to_ast_crtc_state (crtc_state); -struct ast_vbios_mode_info *vbios_mode_info = - &ast_crtc_state->vbios_mode_info; +const struct ast_vbios_stdtable *std_table = ast_crtc_state->std_table; +const struct ast_vbios_enhtable *vmode = ast_crtc_state->vmode;struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;/* @@ -924,13 +920,13 @@ static void ast_crtc_helper_mode_set_nofb(struct drm_crtc *crtc)*/ ast_wait_for_vretrace (ast); -ast_set_vbios_mode_reg (ast, adjusted_mode, vbios_mode_info); +ast_set_vbios_mode_reg (ast, adjusted_mode, vmode);ast_set_index_reg (ast,AST_IO_VGACRI ,0xa1 ,0x06 ); -ast_set_std_reg (ast, adjusted_mode, vbios_mode_info); -ast_set_crtc_reg (ast, adjusted_mode, vbios_mode_info); -ast_set_dclk_reg (ast, adjusted_mode, vbios_mode_info); +ast_set_std_reg (ast, adjusted_mode, std_table); +ast_set_crtc_reg (ast, adjusted_mode, vmode); +ast_set_dclk_reg (ast, adjusted_mode, vmode);ast_set_crtthd_reg (ast); -ast_set_sync_reg (ast, adjusted_mode, vbios_mode_info); +ast_set_sync_reg (ast, adjusted_mode, vmode); } static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,@@ -944,7 +940,6 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,struct ast_device *ast =to_ast_device (dev);struct ast_crtc_state *ast_state;const struct drm_format_info *format; -struct ast_vbios_mode_info *vbios_mode;const struct ast_vbios_enhtable *vmode;unsigned int hborder =0 ;unsigned int vborder =0 ;@@ -979,8 +974,6 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc, } } - vbios_mode = &ast_state->vbios_mode_info; -/* * Set register tables. * @@ -989,14 +982,14 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,*/ switch (format->format) {case DRM_FORMAT_C8 : - vbios_mode->std_table = &vbios_stdtable[VGAModeIndex]; + ast_state->std_table = &vbios_stdtable[VGAModeIndex];break ;case DRM_FORMAT_RGB565 : - vbios_mode->std_table = &vbios_stdtable[HiCModeIndex]; + ast_state->std_table = &vbios_stdtable[HiCModeIndex];break ;case DRM_FORMAT_RGB888 :case DRM_FORMAT_XRGB8888 : - vbios_mode->std_table = &vbios_stdtable[TrueCModeIndex]; + ast_state->std_table = &vbios_stdtable[TrueCModeIndex];break ;default :return -EINVAL ;@@ -1009,7 +1002,7 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc, vmode =ast_vbios_find_mode (ast, &crtc_state->mode);if (!vmode)return -EINVAL ; - ast_state->vbios_mode_info.enh_table = vmode; + ast_state->vmode = vmode;if (vmode->flags & HBorder) hborder =8 ;@@ -1130,8 +1123,8 @@ ast_crtc_atomic_duplicate_state(struct drm_crtc *crtc) ast_state =to_ast_crtc_state (crtc->state); new_ast_state->format = ast_state->format; -memcpy (&new_ast_state->vbios_mode_info, &ast_state->vbios_mode_info, -sizeof (new_ast_state->vbios_mode_info)); + new_ast_state->std_table = ast_state->std_table; + new_ast_state->vmode = ast_state->vmode;return &new_ast_state->base; }
Thomas Zimmermann
maintainerPATCH 15/15 drm/ast: Only look up VBIOS mode on full modesets
In reply to Thomas ZimmermannOnly look up the VBIOS mode during atomic_check if the display mode changes. For page flips, the previous settings still apply. Avoids the runtime overhead of looking up the VBIOS mode on each page flip.
--- drivers/gpu/drm/ast/ast_mode.c | 52 ++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 25 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +27 -25
@@ -996,32 +996,34 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc, }/* -* Find the VBIOS mode and adjust the DRM display mode accordingly. +* Find the VBIOS mode and adjust the DRM display mode accordingly +* if a full modeset is required. Otherwise keep the existing values. */ - - vmode =ast_vbios_find_mode (ast, &crtc_state->mode); -if (!vmode) -return -EINVAL ; - ast_state->vmode = vmode; - -if (vmode->flags & HBorder) - hborder =8 ; -if (vmode->flags & VBorder) - vborder =8 ; - - adjusted_mode->crtc_hdisplay = vmode->hde; - adjusted_mode->crtc_hblank_start = vmode->hde + hborder; - adjusted_mode->crtc_hblank_end = vmode->ht - hborder; - adjusted_mode->crtc_hsync_start = vmode->hde + hborder + vmode->hfp; - adjusted_mode->crtc_hsync_end = vmode->hde + hborder + vmode->hfp + vmode->hsync; - adjusted_mode->crtc_htotal = vmode->ht; - - adjusted_mode->crtc_vdisplay = vmode->vde; - adjusted_mode->crtc_vblank_start = vmode->vde + vborder; - adjusted_mode->crtc_vblank_end = vmode->vt - vborder; - adjusted_mode->crtc_vsync_start = vmode->vde + vborder + vmode->vfp; - adjusted_mode->crtc_vsync_end = vmode->vde + vborder + vmode->vfp + vmode->vsync; - adjusted_mode->crtc_vtotal = vmode->vt; +if (drm_atomic_crtc_needs_modeset (crtc_state)) { + vmode =ast_vbios_find_mode (ast, &crtc_state->mode); +if (!vmode) +return -EINVAL ; + ast_state->vmode = vmode; + +if (vmode->flags & HBorder) + hborder =8 ; +if (vmode->flags & VBorder) + vborder =8 ; + + adjusted_mode->crtc_hdisplay = vmode->hde; + adjusted_mode->crtc_hblank_start = vmode->hde + hborder; + adjusted_mode->crtc_hblank_end = vmode->ht - hborder; + adjusted_mode->crtc_hsync_start = vmode->hde + hborder + vmode->hfp; + adjusted_mode->crtc_hsync_end = vmode->hde + hborder + vmode->hfp + vmode->hsync; + adjusted_mode->crtc_htotal = vmode->ht; + + adjusted_mode->crtc_vdisplay = vmode->vde; + adjusted_mode->crtc_vblank_start = vmode->vde + vborder; + adjusted_mode->crtc_vblank_end = vmode->vt - vborder; + adjusted_mode->crtc_vsync_start = vmode->vde + vborder + vmode->vfp; + adjusted_mode->crtc_vsync_end = vmode->vde + vborder + vmode->vfp + vmode->vsync; + adjusted_mode->crtc_vtotal = vmode->vt; + }return 0 ; }
Signature · 1 line
2.47.1
Re: [PATCH 15/15] drm/ast: Only look up VBIOS mode on full modesets
Quoted 3 lines · Thomas Zimmermann
Only look up the VBIOS mode during
atomic_checkif the display mode changes. For page flips, the previous settings still apply. Avoids the runtime overhead of looking up the VBIOS mode on each page flip.
Thanks, it's a nice optimization.
Signature · 1 line
Jocelyn
Quoted 70 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 52 ++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 25 deletions(-)drivers/gpu/drm/ast/ast_mode.c +27
-25@@ -996,32 +996,34 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc, }/* -* Find the VBIOS mode and adjust the DRM display mode accordingly. +* Find the VBIOS mode and adjust the DRM display mode accordingly +* if a full modeset is required. Otherwise keep the existing values. */ - - vmode =ast_vbios_find_mode (ast, &crtc_state->mode); -if (!vmode) -return -EINVAL ; - ast_state->vmode = vmode; - -if (vmode->flags & HBorder) - hborder =8 ; -if (vmode->flags & VBorder) - vborder =8 ; - - adjusted_mode->crtc_hdisplay = vmode->hde; - adjusted_mode->crtc_hblank_start = vmode->hde + hborder; - adjusted_mode->crtc_hblank_end = vmode->ht - hborder; - adjusted_mode->crtc_hsync_start = vmode->hde + hborder + vmode->hfp; - adjusted_mode->crtc_hsync_end = vmode->hde + hborder + vmode->hfp + vmode->hsync; - adjusted_mode->crtc_htotal = vmode->ht; - - adjusted_mode->crtc_vdisplay = vmode->vde; - adjusted_mode->crtc_vblank_start = vmode->vde + vborder; - adjusted_mode->crtc_vblank_end = vmode->vt - vborder; - adjusted_mode->crtc_vsync_start = vmode->vde + vborder + vmode->vfp; - adjusted_mode->crtc_vsync_end = vmode->vde + vborder + vmode->vfp + vmode->vsync; - adjusted_mode->crtc_vtotal = vmode->vt; +if (drm_atomic_crtc_needs_modeset (crtc_state)) { + vmode =ast_vbios_find_mode (ast, &crtc_state->mode); +if (!vmode) +return -EINVAL ; + ast_state->vmode = vmode; + +if (vmode->flags & HBorder) + hborder =8 ; +if (vmode->flags & VBorder) + vborder =8 ; + + adjusted_mode->crtc_hdisplay = vmode->hde; + adjusted_mode->crtc_hblank_start = vmode->hde + hborder; + adjusted_mode->crtc_hblank_end = vmode->ht - hborder; + adjusted_mode->crtc_hsync_start = vmode->hde + hborder + vmode->hfp; + adjusted_mode->crtc_hsync_end = vmode->hde + hborder + vmode->hfp + vmode->hsync; + adjusted_mode->crtc_htotal = vmode->ht; + + adjusted_mode->crtc_vdisplay = vmode->vde; + adjusted_mode->crtc_vblank_start = vmode->vde + vborder; + adjusted_mode->crtc_vblank_end = vmode->vt - vborder; + adjusted_mode->crtc_vsync_start = vmode->vde + vborder + vmode->vfp; + adjusted_mode->crtc_vsync_end = vmode->vde + vborder + vmode->vfp + vmode->vsync; + adjusted_mode->crtc_vtotal = vmode->vt; + }return 0 ; }