drm/ast: Fix color formats
Subsystems (3)
Thomas Zimmermann
maintainercover drm/ast: Fix color formats
Fix various issues with ast's handling of color formats. Remove the deprecated cpp field form the code and add support for XRGB1555.
Tested on AST26000 hardware by running fbcon and Xorg with the supported color formats.
Thomas Zimmermann (4):
drm/ast: Add constant for VGACR91
drm/ast: Remove traces of DRM_FORMAT_RGB888 handling drm/ast: Replace references to struct drm_format_info.cpp drm/ast: Support DRM_FORMAT_XRGB1555 on the primary plane
drivers/gpu/drm/ast/ast_mode.c | 86 ++++++++++++++++++++-------------- drivers/gpu/drm/ast/ast_reg.h | 55 +++++++++++++++++----- 2 files changed, 93 insertions(+), 48 deletions(-)
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH 1/4 drm/ast: Add constant for VGACR91
Register VGACR91 receives a password that enables the new mode-info header in other registers. Replace the password's magic value with a constant.
--- drivers/gpu/drm/ast/ast_mode.c | 4 ++-- drivers/gpu/drm/ast/ast_reg.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +2 -2
@@ -168,7 +168,7 @@ static void ast_set_vbios_color_reg(struct ast_device *ast,ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,0x00 );if (vmode->flags & NewModeInfo) { -ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,0xa8 ); +ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,AST_IO_VGACR91_PASSWORD );ast_set_index_reg (ast,AST_IO_VGACRI ,0x92 , format->cpp[0 ] *8 ); } }
@@ -188,7 +188,7 @@ static void ast_set_vbios_mode_reg(struct ast_device *ast,ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,0x00 );if (vmode->flags & NewModeInfo) { -ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,0xa8 ); +ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,AST_IO_VGACR91_PASSWORD );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);ast_set_index_reg (ast,AST_IO_VGACRI ,0x95 , adjusted_mode->crtc_hdisplay >>8 );
drivers/gpu/drm/ast/ast_reg.h +1 -0
@@ -31,6 +31,7 @@#define AST_IO_VGACRI (0x54)#define AST_IO_VGACR17_SYNC_ENABLE BIT(7)/* called "Hardware reset" in docs */ #define AST_IO_VGACR80_PASSWORD (0xa8) +#define AST_IO_VGACR91_PASSWORD (0xa8)#define AST_IO_VGACR99_VGAMEM_RSRV_MASK GENMASK(1, 0)#define AST_IO_VGACRA1_VGAIO_DISABLED BIT(1)#define AST_IO_VGACRA1_MMIO_ENABLED BIT(2)
Signature · 1 line
2.53.0
Re: [PATCH 1/4] drm/ast: Add constant for VGACR91
Quoted 3 lines · Thomas Zimmermann
Register VGACR91 receives a password that enables the new mode-info header in other registers. Replace the password's magic value with a constant.
Thanks, it looks good to me.
Quoted 41 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 4 ++-- drivers/gpu/drm/ast/ast_reg.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/ast/ast_mode.c +2
-2@@ -168,7 +168,7 @@ static void ast_set_vbios_color_reg(struct ast_device *ast,ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,0x00 );if (vmode->flags & NewModeInfo) { -ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,0xa8 ); +ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,AST_IO_VGACR91_PASSWORD );ast_set_index_reg (ast,AST_IO_VGACRI ,0x92 , format->cpp[0 ] *8 ); } }@@ -188,7 +188,7 @@ static void ast_set_vbios_mode_reg(struct ast_device *ast,ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,0x00 );if (vmode->flags & NewModeInfo) { -ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,0xa8 ); +ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,AST_IO_VGACR91_PASSWORD );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);ast_set_index_reg (ast,AST_IO_VGACRI ,0x95 , adjusted_mode->crtc_hdisplay >>8 );drivers/gpu/drm/ast/ast_reg.h +1
-0@@ -31,6 +31,7 @@#define AST_IO_VGACRI (0x54)#define AST_IO_VGACR17_SYNC_ENABLE BIT(7)/* called "Hardware reset" in docs */ #define AST_IO_VGACR80_PASSWORD (0xa8) +#define AST_IO_VGACR91_PASSWORD (0xa8)#define AST_IO_VGACR99_VGAMEM_RSRV_MASK GENMASK(1, 0)#define AST_IO_VGACRA1_VGAIO_DISABLED BIT(1)#define AST_IO_VGACRA1_MMIO_ENABLED BIT(2)
Thomas Zimmermann
maintainerPATCH 2/4 drm/ast: Remove traces of DRM_FORMAT_RGB888 handling
In reply to Thomas ZimmermannThere's some incomplete handling for DRM_FORMAT_RGB888 in the mode- setting code. It was added by ast's original commit, which imported the code from the user-space Xorg driver. But the hardware doesn't support 24-bit pixel sizes. Hence remove the traces of RGB888 from ast.
--- drivers/gpu/drm/ast/ast_mode.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +0 -2
@@ -155,7 +155,6 @@ static void ast_set_vbios_color_reg(struct ast_device *ast,case 2 : color_index = HiCModeIndex;break ; -case 3 :case 4 : color_index = TrueCModeIndex;break ;
@@ -765,7 +764,6 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,case DRM_FORMAT_RGB565 : ast_state->std_table = &vbios_stdtable[HiCModeIndex];break ; -case DRM_FORMAT_RGB888 :case DRM_FORMAT_XRGB8888 : ast_state->std_table = &vbios_stdtable[TrueCModeIndex];break ;
Signature · 1 line
2.53.0
Re: [PATCH 2/4] drm/ast: Remove traces of DRM_FORMAT_RGB888 handling
Quoted 5 lines · Thomas Zimmermann
There's some incomplete handling for
DRM_FORMAT_RGB888in the mode- setting code. It was added by ast's original commit, which imported the code from the user-space Xorg driver. But the hardware doesn't support 24-bit pixel sizes. Hence remove the traces of RGB888 from ast.
Thanks, it looks good to me.
Quoted 26 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@@ -155,7 +155,6 @@ static void ast_set_vbios_color_reg(struct ast_device *ast,case 2 : color_index = HiCModeIndex;break ; -case 3 :case 4 : color_index = TrueCModeIndex;break ;@@ -765,7 +764,6 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,case DRM_FORMAT_RGB565 : ast_state->std_table = &vbios_stdtable[HiCModeIndex];break ; -case DRM_FORMAT_RGB888 :case DRM_FORMAT_XRGB8888 : ast_state->std_table = &vbios_stdtable[TrueCModeIndex];break ;
Thomas Zimmermann
maintainerPATCH 3/4 drm/ast: Replace references to struct drm_format_info.cpp
In reply to Thomas ZimmermannReplace all uses of struct drm_format_info.cpp with the corresponding 4CC constant. Color-mode selection uses switch statements that branch by cpp in several places. While at it, also name the involved variables according to register names and replace magic values with constants.
Replace the use of *ModeIndex constants in ast_set_vbios_color_reg() with correct register constants. The former are array indices and do not belong into registers.
In ast_set_color_reg(), vgacra0 is independent from the color format, so move it out from the switch statements.
There is also a flag for gamma correction in vgacra8, which currently ast_set_color_reg() handles as part of the primary plane. The gamma LUT and its programming is located in the CRTC. A future update should consolidate gamma correction in the primary plane and implement the functionality with DRM's colorop helpers.
--- drivers/gpu/drm/ast/ast_mode.c | 65 ++++++++++++++++++---------------- drivers/gpu/drm/ast/ast_reg.h | 55 +++++++++++++++++++++------- 2 files changed, 77 insertions(+), 43 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +35 -30
@@ -146,29 +146,31 @@ static void ast_set_vbios_color_reg(struct ast_device *ast,const struct drm_format_info *format, const struct ast_vbios_enhtable *vmode) { - u32 color_index; + u8 vgacr8c = 0x00; +u8 vgacr92 =0x00 ; -switch (format->cpp[0 ]) { -case 1 : - color_index = VGAModeIndex -1 ; +switch (format->format) { +case DRM_FORMAT_C8 : + vgacr8c |=AST_IO_VGACR8C_CUR_MODE_VGA ; + vgacr92 =8 ;break ; -case 2 : - color_index = HiCModeIndex; +case DRM_FORMAT_RGB565 : + vgacr8c |=AST_IO_VGACR8C_CUR_MODE_16_BPP ; + vgacr92 =16 ;break ; -case 4 : - color_index = TrueCModeIndex; +case DRM_FORMAT_XRGB8888 : + vgacr8c |=AST_IO_VGACR8C_CUR_MODE_32_BPP ; + vgacr92 =32 ;break ; -default : -return ; } -ast_set_index_reg (ast,AST_IO_VGACRI ,0x8c , (u8)((color_index &0x0f ) <<4 )); +ast_set_index_reg (ast,AST_IO_VGACRI ,0x8c , vgacr8c);ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,0x00 );if (vmode->flags & NewModeInfo) {ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,AST_IO_VGACR91_PASSWORD ); -ast_set_index_reg (ast,AST_IO_VGACRI ,0x92 , format->cpp[0 ] *8 ); +ast_set_index_reg (ast,AST_IO_VGACRI ,0x92 , vgacr92); } }
@@ -380,30 +382,33 @@ static void ast_set_dclk_reg(struct ast_device *ast,static void ast_set_color_reg (struct ast_device *ast,const struct drm_format_info *format) { -u8 jregA0 =0 , jregA3 =0 , jregA8 =0 ; +u8 vgacra0 =0x00 ; +u8 vgacra3 =0x00 ; +u8 vgacra8 =0x00 ; -switch (format->cpp[0 ] *8 ) { -case 8 : - jregA0 =0x70 ; - jregA3 =0x01 ; - jregA8 =0x00 ; + vgacra0 |=AST_IO_VGACRA0_MEMORY_CHAIN4_MODE | +AST_IO_VGACRA0_LINEAR_EXT_ACCESS | +AST_IO_VGACRA0_SEGMENTED_EXT_ACCESS ; + +switch (format->format) { +case DRM_FORMAT_C8 : + vgacra3 |=AST_IO_VGACRA3_256_COLORS ; + vgacra8 &= ~AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED ;break ; -case 15 : -case 16 : - jregA0 =0x70 ; - jregA3 =0x04 ; - jregA8 =0x02 ; +case DRM_FORMAT_XRGB1555 : +case DRM_FORMAT_RGB565 : + vgacra3 |=AST_IO_VGACRA3_16_BPP ; + vgacra8 |=AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED ;break ; -case 32 : - jregA0 =0x70 ; - jregA3 =0x08 ; - jregA8 =0x02 ; +case DRM_FORMAT_XRGB8888 : + vgacra3 |=AST_IO_VGACRA3_32_BPP ; + vgacra8 |=AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED ;break ; } -ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa0 ,0x8f , jregA0); -ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa3 ,0xf0 , jregA3); -ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa8 ,0xfd , jregA8); +ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa0 ,0x8f , vgacra0); +ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa3 ,0xf0 , vgacra3); +ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa8 ,0xfd , vgacra8); }static void ast_set_crtthd_reg (struct ast_device *ast)
drivers/gpu/drm/ast/ast_reg.h +42 -13
61 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH 3/4] drm/ast: Replace references to struct drm_format_info.cpp
Quoted 9 lines · Thomas Zimmermann
Replace all uses of struct drm_format_info.cpp with the corresponding 4CC constant. Color-mode selection uses switch statements that branch by cpp in several places. While at it, also name the involved variables according to register names and replace magic values with constants.
Replace the use of *ModeIndex constants in
ast_set_vbios_color_reg()with correct register constants. The former are array indices and do not belong into registers.
Quoted 8 lines
In
ast_set_color_reg(), vgacra0 is independent from the color format, so move it out from the switch statements.There is also a flag for gamma correction in vgacra8, which currently
ast_set_color_reg()handles as part of the primary plane. The gamma LUT and its programming is located in the CRTC. A future update should consolidate gamma correction in the primary plane and implement the functionality with DRM's colorop helpers.
Thanks, it looks good to me.
Quoted 173 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 65 ++++++++++++++++++---------------- drivers/gpu/drm/ast/ast_reg.h | 55 +++++++++++++++++++++------- 2 files changed, 77 insertions(+), 43 deletions(-)drivers/gpu/drm/ast/ast_mode.c +35
-30@@ -146,29 +146,31 @@ static void ast_set_vbios_color_reg(struct ast_device *ast,const struct drm_format_info *format, const struct ast_vbios_enhtable *vmode) { - u32 color_index; + u8 vgacr8c = 0x00; +u8 vgacr92 =0x00 ; -switch (format->cpp[0 ]) { -case 1 : - color_index = VGAModeIndex -1 ; +switch (format->format) { +case DRM_FORMAT_C8 : + vgacr8c |=AST_IO_VGACR8C_CUR_MODE_VGA ; + vgacr92 =8 ;break ; -case 2 : - color_index = HiCModeIndex; +case DRM_FORMAT_RGB565 : + vgacr8c |=AST_IO_VGACR8C_CUR_MODE_16_BPP ; + vgacr92 =16 ;break ; -case 4 : - color_index = TrueCModeIndex; +case DRM_FORMAT_XRGB8888 : + vgacr8c |=AST_IO_VGACR8C_CUR_MODE_32_BPP ; + vgacr92 =32 ;break ; -default : -return ; } -ast_set_index_reg (ast,AST_IO_VGACRI ,0x8c , (u8)((color_index &0x0f ) <<4 )); +ast_set_index_reg (ast,AST_IO_VGACRI ,0x8c , vgacr8c);ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,0x00 );if (vmode->flags & NewModeInfo) {ast_set_index_reg (ast,AST_IO_VGACRI ,0x91 ,AST_IO_VGACR91_PASSWORD ); -ast_set_index_reg (ast,AST_IO_VGACRI ,0x92 , format->cpp[0 ] *8 ); +ast_set_index_reg (ast,AST_IO_VGACRI ,0x92 , vgacr92); } }@@ -380,30 +382,33 @@ static void ast_set_dclk_reg(struct ast_device *ast,static void ast_set_color_reg (struct ast_device *ast,const struct drm_format_info *format) { -u8 jregA0 =0 , jregA3 =0 , jregA8 =0 ; +u8 vgacra0 =0x00 ; +u8 vgacra3 =0x00 ; +u8 vgacra8 =0x00 ; -switch (format->cpp[0 ] *8 ) { -case 8 : - jregA0 =0x70 ; - jregA3 =0x01 ; - jregA8 =0x00 ; + vgacra0 |=AST_IO_VGACRA0_MEMORY_CHAIN4_MODE | +AST_IO_VGACRA0_LINEAR_EXT_ACCESS | +AST_IO_VGACRA0_SEGMENTED_EXT_ACCESS ; + +switch (format->format) { +case DRM_FORMAT_C8 : + vgacra3 |=AST_IO_VGACRA3_256_COLORS ; + vgacra8 &= ~AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED ;break ; -case 15 : -case 16 : - jregA0 =0x70 ; - jregA3 =0x04 ; - jregA8 =0x02 ; +case DRM_FORMAT_XRGB1555 : +case DRM_FORMAT_RGB565 : + vgacra3 |=AST_IO_VGACRA3_16_BPP ; + vgacra8 |=AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED ;break ; -case 32 : - jregA0 =0x70 ; - jregA3 =0x08 ; - jregA8 =0x02 ; +case DRM_FORMAT_XRGB8888 : + vgacra3 |=AST_IO_VGACRA3_32_BPP ; + vgacra8 |=AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED ;break ; } -ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa0 ,0x8f , jregA0); -ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa3 ,0xf0 , jregA3); -ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa8 ,0xfd , jregA8); +ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa0 ,0x8f , vgacra0); +ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa3 ,0xf0 , vgacra3); +ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa8 ,0xfd , vgacra8); }static void ast_set_crtthd_reg (struct ast_device *ast)drivers/gpu/drm/ast/ast_reg.h +42
-13@@ -28,19 +28,48 @@#define AST_IO_VGAPDR (0x49)#define AST_IO_VGAGRI (0x4E) -#define AST_IO_VGACRI (0x54) -#define AST_IO_VGACR17_SYNC_ENABLE BIT(7)/* called "Hardware reset" in docs */ -#define AST_IO_VGACR80_PASSWORD (0xa8) -#define AST_IO_VGACR91_PASSWORD (0xa8) -#define AST_IO_VGACR99_VGAMEM_RSRV_MASK GENMASK(1, 0) -#define AST_IO_VGACRA1_VGAIO_DISABLED BIT(1) -#define AST_IO_VGACRA1_MMIO_ENABLED BIT(2) -#define AST_IO_VGACRA3_DVO_ENABLED BIT(7) -#define AST_IO_VGACRAA_VGAMEM_SIZE_MASK GENMASK(1, 0) -#define AST_IO_VGACRB6_HSYNC_OFF BIT(0) -#define AST_IO_VGACRB6_VSYNC_OFF BIT(1) -#define AST_IO_VGACRCB_HWC_16BPP BIT(0)/* set: ARGB4444, cleared: 2bpp palette */ -#define AST_IO_VGACRCB_HWC_ENABLED BIT(1) +#define AST_IO_VGACRI (0x54) +#define AST_IO_VGACR17_SYNC_ENABLE BIT(7)/* called "Hardware reset" in docs */ +#define AST_IO_VGACR80_PASSWORD (0xa8) + +#define AST_IO_VGACR8C_NEW_MODE_MASK GENMASK(3, 0) +#define AST_IO_VGACR8C_NEW_MODE_EGA (0x00) +#define AST_IO_VGACR8C_NEW_MODE_VGA (0x01) +#define AST_IO_VGACR8C_NEW_MODE_15_BPP (0x02) +#define AST_IO_VGACR8C_NEW_MODE_16_BPP (0x03) +#define AST_IO_VGACR8C_NEW_MODE_32_BPP (0x04) +#define AST_IO_VGACR8C_NEW_MODE_CGA (0x0f) +#define AST_IO_VGACR8C_NEW_MODE_TEXT (0x0e) +#define AST_IO_VGACR8C_CUR_MODE_MASK GENMASK(7, 4) +#define AST_IO_VGACR8C_CUR_MODE_EGA (0x00) +#define AST_IO_VGACR8C_CUR_MODE_VGA (0x10) +#define AST_IO_VGACR8C_CUR_MODE_15_BPP (0x20) +#define AST_IO_VGACR8C_CUR_MODE_16_BPP (0x30) +#define AST_IO_VGACR8C_CUR_MODE_32_BPP (0x40) +#define AST_IO_VGACR8C_CUR_MODE_CGA (0xf0) +#define AST_IO_VGACR8C_CUR_MODE_TEXT (0xe0) + +#define AST_IO_VGACR91_PASSWORD (0xa8) +#define AST_IO_VGACR99_VGAMEM_RSRV_MASK GENMASK(1, 0) + +#define AST_IO_VGACRA0_MEMORY_CHAIN4_MODE BIT(6) +#define AST_IO_VGACRA0_LINEAR_EXT_ACCESS BIT(5) +#define AST_IO_VGACRA0_SEGMENTED_EXT_ACCESS BIT(4) + +#define AST_IO_VGACRA1_VGAIO_DISABLED BIT(1) +#define AST_IO_VGACRA1_MMIO_ENABLED BIT(2) + +#define AST_IO_VGACRA3_DVO_ENABLED BIT(7) +#define AST_IO_VGACRA3_32_BPP BIT(3) +#define AST_IO_VGACRA3_16_BPP BIT(2) +#define AST_IO_VGACRA3_256_COLORS BIT(0) + +#define AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED BIT(1) +#define AST_IO_VGACRAA_VGAMEM_SIZE_MASK GENMASK(1, 0) +#define AST_IO_VGACRB6_HSYNC_OFF BIT(0) +#define AST_IO_VGACRB6_VSYNC_OFF BIT(1) +#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)
Thomas Zimmermann
maintainerPATCH 4/4 drm/ast: Support DRM_FORMAT_XRGB1555 on the primary plane
In reply to Thomas ZimmermannExport DRM_FORMAT_XRGB1555 in the primary plane's format array and handle the format in the color-format updates. With this, ast is now feature complete wrt. color-format support.
Also update the comments in the gamma-LUT code to reflect the ast manual's terminology.
--- drivers/gpu/drm/ast/ast_mode.c | 15 +++++++++++++-- drivers/gpu/drm/ast/ast_reg.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +13 -2
@@ -105,8 +105,9 @@ static void ast_crtc_fill_gamma(struct ast_device *ast,/* gamma table is used as color palette */ drm_crtc_fill_palette_8 (crtc, ast_set_gamma_lut);break ; +case DRM_FORMAT_XRGB1555 :case DRM_FORMAT_RGB565 : -/* also uses 8-bit gamma ramp on low-color modes */ +/* also uses 24-bit gamma correction on high-color modes */ fallthrough;case DRM_FORMAT_XRGB8888 :drm_crtc_fill_gamma_888 (crtc, ast_set_gamma_lut);
@@ -129,8 +130,9 @@ static void ast_crtc_load_gamma(struct ast_device *ast,/* gamma table is used as color palette */ drm_crtc_load_palette_8 (crtc, lut, ast_set_gamma_lut);break ; +case DRM_FORMAT_XRGB1555 :case DRM_FORMAT_RGB565 : -/* also uses 8-bit gamma ramp on low-color modes */ +/* also uses 24-bit gamma correction on high-color modes */ fallthrough;case DRM_FORMAT_XRGB8888 :drm_crtc_load_gamma_888 (crtc, lut, ast_set_gamma_lut);
@@ -154,6 +156,10 @@ static void ast_set_vbios_color_reg(struct ast_device *ast, vgacr8c |=AST_IO_VGACR8C_CUR_MODE_VGA ; vgacr92 =8 ;break ; +case DRM_FORMAT_XRGB1555 : + vgacr8c |=AST_IO_VGACR8C_CUR_MODE_15_BPP ; + vgacr92 =15 ; +break ;case DRM_FORMAT_RGB565 : vgacr8c |=AST_IO_VGACR8C_CUR_MODE_16_BPP ; vgacr92 =16 ;
@@ -396,6 +402,9 @@ static void ast_set_color_reg(struct ast_device *ast, vgacra8 &= ~AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED ;break ;case DRM_FORMAT_XRGB1555 : + vgacra3 |=AST_IO_VGACRA3_15_BPP ; + vgacra8 |=AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED ; +break ;case DRM_FORMAT_RGB565 : vgacra3 |=AST_IO_VGACRA3_16_BPP ; vgacra8 |=AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED ;
@@ -493,6 +502,7 @@ void __iomem *ast_plane_vaddr(struct ast_plane *ast_plane)static const uint32_t ast_primary_plane_formats[] = {DRM_FORMAT_XRGB8888 ,DRM_FORMAT_RGB565 , +DRM_FORMAT_XRGB1555 ,DRM_FORMAT_C8 , };
@@ -766,6 +776,7 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,case DRM_FORMAT_C8 : ast_state->std_table = &vbios_stdtable[VGAModeIndex];break ; +case DRM_FORMAT_XRGB1555 :case DRM_FORMAT_RGB565 : ast_state->std_table = &vbios_stdtable[HiCModeIndex];break ;
drivers/gpu/drm/ast/ast_reg.h +1 -0
@@ -62,6 +62,7 @@#define AST_IO_VGACRA3_DVO_ENABLED BIT(7)#define AST_IO_VGACRA3_32_BPP BIT(3)#define AST_IO_VGACRA3_16_BPP BIT(2) +#define AST_IO_VGACRA3_15_BPP BIT(1)#define AST_IO_VGACRA3_256_COLORS BIT(0)#define AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED BIT(1)
Signature · 1 line
2.53.0
Re: [PATCH 4/4] drm/ast: Support DRM_FORMAT_XRGB1555 on the primary plane
Quoted 6 lines · Thomas Zimmermann
Export
DRM_FORMAT_XRGB1555in the primary plane's format array and handle the format in the color-format updates. With this, ast is now feature complete wrt. color-format support.Also update the comments in the gamma-LUT code to reflect the ast manual's terminology.
Thanks, it looks good to me.
Quoted 82 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 15 +++++++++++++-- drivers/gpu/drm/ast/ast_reg.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-)drivers/gpu/drm/ast/ast_mode.c +13
-2@@ -105,8 +105,9 @@ static void ast_crtc_fill_gamma(struct ast_device *ast,/* gamma table is used as color palette */ drm_crtc_fill_palette_8 (crtc, ast_set_gamma_lut);break ; +case DRM_FORMAT_XRGB1555 :case DRM_FORMAT_RGB565 : -/* also uses 8-bit gamma ramp on low-color modes */ +/* also uses 24-bit gamma correction on high-color modes */ fallthrough;case DRM_FORMAT_XRGB8888 :drm_crtc_fill_gamma_888 (crtc, ast_set_gamma_lut);@@ -129,8 +130,9 @@ static void ast_crtc_load_gamma(struct ast_device *ast,/* gamma table is used as color palette */ drm_crtc_load_palette_8 (crtc, lut, ast_set_gamma_lut);break ; +case DRM_FORMAT_XRGB1555 :case DRM_FORMAT_RGB565 : -/* also uses 8-bit gamma ramp on low-color modes */ +/* also uses 24-bit gamma correction on high-color modes */ fallthrough;case DRM_FORMAT_XRGB8888 :drm_crtc_load_gamma_888 (crtc, lut, ast_set_gamma_lut);@@ -154,6 +156,10 @@ static void ast_set_vbios_color_reg(struct ast_device *ast, vgacr8c |=AST_IO_VGACR8C_CUR_MODE_VGA ; vgacr92 =8 ;break ; +case DRM_FORMAT_XRGB1555 : + vgacr8c |=AST_IO_VGACR8C_CUR_MODE_15_BPP ; + vgacr92 =15 ; +break ;case DRM_FORMAT_RGB565 : vgacr8c |=AST_IO_VGACR8C_CUR_MODE_16_BPP ; vgacr92 =16 ;@@ -396,6 +402,9 @@ static void ast_set_color_reg(struct ast_device *ast, vgacra8 &= ~AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED ;break ;case DRM_FORMAT_XRGB1555 : + vgacra3 |=AST_IO_VGACRA3_15_BPP ; + vgacra8 |=AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED ; +break ;case DRM_FORMAT_RGB565 : vgacra3 |=AST_IO_VGACRA3_16_BPP ; vgacra8 |=AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED ;@@ -493,6 +502,7 @@ void __iomem *ast_plane_vaddr(struct ast_plane *ast_plane)static const uint32_t ast_primary_plane_formats[] = {DRM_FORMAT_XRGB8888 ,DRM_FORMAT_RGB565 , +DRM_FORMAT_XRGB1555 ,DRM_FORMAT_C8 , };@@ -766,6 +776,7 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,case DRM_FORMAT_C8 : ast_state->std_table = &vbios_stdtable[VGAModeIndex];break ; +case DRM_FORMAT_XRGB1555 :case DRM_FORMAT_RGB565 : ast_state->std_table = &vbios_stdtable[HiCModeIndex];break ;drivers/gpu/drm/ast/ast_reg.h +1
-0@@ -62,6 +62,7 @@#define AST_IO_VGACRA3_DVO_ENABLED BIT(7)#define AST_IO_VGACRA3_32_BPP BIT(3)#define AST_IO_VGACRA3_16_BPP BIT(2) +#define AST_IO_VGACRA3_15_BPP BIT(1)#define AST_IO_VGACRA3_256_COLORS BIT(0)#define AST_IO_VGACRA8_GAMMA_CORRECTION_ENABLED BIT(1)