drm/radeon,amdgpu,dc: enable ABGR and XBGR formats
Subsystems (3)
PATCH v3 1/1 drm/radeon,amdgpu,dc: enable ABGR and XBGR formats
Sending PATCH v3 series for support of {A,X}RGB pixel formats in DCE1/R5xx and later, with separated patches for amd dc, amdgpu and radeon, based on Alexander Deucher comments
Tested and working on R5xx (X1300), R6xx (HD2400), R7xx (HD4830), Juniper (HD5770), Turks (HD7600M), Tahiti (HD7950), Bonaire (HD7790), Tonga (R9 380), Polaris (RX560) and Vega RX
Legacy radeon crtc was left unchanged, because R3xx/R4xx chipsets do not support {A,X}BGR_8888 pixel formats natively, moreover the legacy code path is still based on KMS API
[PATCH v3 1/3] drm/amd/display: enable ABGR and XBGR formats (v4) [PATCH v3 2/3] drm/amdgpu: enable ABGR and XBGR formats (v2) [PATCH v3 3/3] drm/radeon: enable ABGR and XBGR formats (v2)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180812194303.21258-1-issor.oruam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH v3 1/3 drm/amd/display: enable ABGR and XBGR formats (v4)
SURFACE_PIXEL_FORMAT_GRPH_ABGR8888 is supported in amd/display/dc/dc_hw_types.h and the necessary crossbars register controls to swap red and blue channels are already implemented in drm/amd/display/dc/dce/dce_mem_input.c
(v4) Logic to handle new formats is added only in amdgpu_dm module.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +6 -0
@@ -1892,6 +1892,10 @@ static int fill_plane_attributes_from_fb(struct amdgpu_device *adev,case DRM_FORMAT_ABGR2101010 : plane_state->format =SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010 ;break ; +case DRM_FORMAT_XBGR8888 : +case DRM_FORMAT_ABGR8888 : + plane_state->format =SURFACE_PIXEL_FORMAT_GRPH_ABGR8888 ; +break ;case DRM_FORMAT_NV21 : plane_state->format = SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr;break ;
@@ -3190,6 +3194,8 @@ static const uint32_t rgb_formats[] = {DRM_FORMAT_XBGR2101010 ,DRM_FORMAT_ARGB2101010 ,DRM_FORMAT_ABGR2101010 , +DRM_FORMAT_XBGR8888 , + DRM_FORMAT_ABGR8888, }; static const uint32_t yuv_formats[] = {
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v3 2/3 drm/amdgpu: enable ABGR and XBGR formats (v2)
In reply to a message not in the archiveAdd support for DRM_FORMAT_{A,X}BGR8888 in amdgpu with amd dc disabled
(v2) Crossbar registers are defined and used to swap red and blue channels,
keeping the existing coding style in each of the dce modules. After setting crossbar bits in fb_swap, use bitwise OR for big endian where required in DCE6 and DCE8 which do not rely on REG_SET_FIELD()
--- drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 11 +++++++++++ drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 11 +++++++++++ drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/si_enums.h | 20 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/sid.h | 20 ++++++++++++++++++++ 6 files changed, 82 insertions(+)
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +11 -0
@@ -1941,6 +1941,17 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,/* Greater 8 bpc fb needs to bypass hw-lut to retain precision */ bypass_lut = true;break ; +case DRM_FORMAT_XBGR8888 : +case DRM_FORMAT_ABGR8888 : + fb_format =REG_SET_FIELD (0 ,GRPH_CONTROL ,GRPH_DEPTH ,2 ); + fb_format =REG_SET_FIELD (fb_format,GRPH_CONTROL ,GRPH_FORMAT ,0 ); + fb_swap =REG_SET_FIELD (fb_swap,GRPH_SWAP_CNTL ,GRPH_RED_CROSSBAR ,2 ); + fb_swap =REG_SET_FIELD (fb_swap,GRPH_SWAP_CNTL ,GRPH_BLUE_CROSSBAR ,2 ); +#ifdef __BIG_ENDIAN + fb_swap =REG_SET_FIELD (fb_swap,GRPH_SWAP_CNTL ,GRPH_ENDIAN_SWAP , +ENDIAN_8IN32 ); +#endif +break ;default :DRM_ERROR ("Unsupported screen format %s\n" ,drm_get_format_name (target_fb->format->format, &format_name));
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +11 -0
@@ -1983,6 +1983,17 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,/* Greater 8 bpc fb needs to bypass hw-lut to retain precision */ bypass_lut = true;break ; +case DRM_FORMAT_XBGR8888 : +case DRM_FORMAT_ABGR8888 : + fb_format =REG_SET_FIELD (0 ,GRPH_CONTROL ,GRPH_DEPTH ,2 ); + fb_format =REG_SET_FIELD (fb_format,GRPH_CONTROL ,GRPH_FORMAT ,0 ); + fb_swap =REG_SET_FIELD (fb_swap,GRPH_SWAP_CNTL ,GRPH_RED_CROSSBAR ,2 ); + fb_swap =REG_SET_FIELD (fb_swap,GRPH_SWAP_CNTL ,GRPH_BLUE_CROSSBAR ,2 ); +#ifdef __BIG_ENDIAN + fb_swap =REG_SET_FIELD (fb_swap,GRPH_SWAP_CNTL ,GRPH_ENDIAN_SWAP , +ENDIAN_8IN32 ); +#endif +break ;default :DRM_ERROR ("Unsupported screen format %s\n" ,drm_get_format_name (target_fb->format->format, &format_name));
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +10 -0
@@ -1888,6 +1888,16 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,/* Greater 8 bpc fb needs to bypass hw-lut to retain precision */ bypass_lut = true;break ; +case DRM_FORMAT_XBGR8888 : +case DRM_FORMAT_ABGR8888 : + fb_format = (GRPH_DEPTH (GRPH_DEPTH_32BPP ) | +GRPH_FORMAT (GRPH_FORMAT_ARGB8888 )); + fb_swap = (GRPH_RED_CROSSBAR (GRPH_RED_SEL_B ) | +GRPH_BLUE_CROSSBAR (GRPH_BLUE_SEL_R )); +#ifdef __BIG_ENDIAN + fb_swap |=GRPH_ENDIAN_SWAP (GRPH_ENDIAN_8IN32 ); +#endif +break ;default :DRM_ERROR ("Unsupported screen format %s\n" ,drm_get_format_name (target_fb->format->format, &format_name));
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +10 -0
@@ -1865,6 +1865,16 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,/* Greater 8 bpc fb needs to bypass hw-lut to retain precision */ bypass_lut = true;break ; +case DRM_FORMAT_XBGR8888 : +case DRM_FORMAT_ABGR8888 : + fb_format = ((GRPH_DEPTH_32BPP <<GRPH_CONTROL__GRPH_DEPTH__SHIFT ) | + (GRPH_FORMAT_ARGB8888 <<GRPH_CONTROL__GRPH_FORMAT__SHIFT )); + fb_swap = ((GRPH_RED_SEL_B <<GRPH_SWAP_CNTL__GRPH_RED_CROSSBAR__SHIFT ) | + (GRPH_BLUE_SEL_R <<GRPH_SWAP_CNTL__GRPH_BLUE_CROSSBAR__SHIFT )); +#ifdef __BIG_ENDIAN + fb_swap |= (GRPH_ENDIAN_8IN32 <<GRPH_SWAP_CNTL__GRPH_ENDIAN_SWAP__SHIFT ); +#endif +break ;default :DRM_ERROR ("Unsupported screen format %s\n" ,drm_get_format_name (target_fb->format->format, &format_name));
drivers/gpu/drm/amd/amdgpu/si_enums.h +20 -0
@@ -46,6 +46,26 @@#define GRPH_ENDIAN_8IN16 1#define GRPH_ENDIAN_8IN32 2#define GRPH_ENDIAN_8IN64 3 +#define GRPH_RED_CROSSBAR (x) (((x) & 0x3) << 4) +#define GRPH_RED_SEL_R 0 +#define GRPH_RED_SEL_G 1 +#define GRPH_RED_SEL_B 2 +#define GRPH_RED_SEL_A 3 +#define GRPH_GREEN_CROSSBAR (x) (((x) & 0x3) << 6) +#define GRPH_GREEN_SEL_G 0 +#define GRPH_GREEN_SEL_B 1 +#define GRPH_GREEN_SEL_A 2 +#define GRPH_GREEN_SEL_R 3 +#define GRPH_BLUE_CROSSBAR (x) (((x) & 0x3) << 8) +#define GRPH_BLUE_SEL_B 0 +#define GRPH_BLUE_SEL_A 1 +#define GRPH_BLUE_SEL_R 2 +#define GRPH_BLUE_SEL_G 3 +#define GRPH_ALPHA_CROSSBAR (x) (((x) & 0x3) << 10) +#define GRPH_ALPHA_SEL_A 0 +#define GRPH_ALPHA_SEL_R 1 +#define GRPH_ALPHA_SEL_G 2 +#define GRPH_ALPHA_SEL_B 3#define GRPH_DEPTH (x) (((x) & 0x3) << 0)#define GRPH_DEPTH_8BPP 0
drivers/gpu/drm/amd/amdgpu/sid.h +20 -0
@@ -2201,6 +2201,26 @@# define EVERGREEN_GRPH_ENDIAN_8IN16 1# define EVERGREEN_GRPH_ENDIAN_8IN32 2# define EVERGREEN_GRPH_ENDIAN_8IN64 3 +#define EVERGREEN_GRPH_RED_CROSSBAR (x) (((x) & 0x3) << 4) +# define EVERGREEN_GRPH_RED_SEL_R 0 +# define EVERGREEN_GRPH_RED_SEL_G 1 +# define EVERGREEN_GRPH_RED_SEL_B 2 +# define EVERGREEN_GRPH_RED_SEL_A 3 +#define EVERGREEN_GRPH_GREEN_CROSSBAR (x) (((x) & 0x3) << 6) +# define EVERGREEN_GRPH_GREEN_SEL_G 0 +# define EVERGREEN_GRPH_GREEN_SEL_B 1 +# define EVERGREEN_GRPH_GREEN_SEL_A 2 +# define EVERGREEN_GRPH_GREEN_SEL_R 3 +#define EVERGREEN_GRPH_BLUE_CROSSBAR (x) (((x) & 0x3) << 8) +# define EVERGREEN_GRPH_BLUE_SEL_B 0 +# define EVERGREEN_GRPH_BLUE_SEL_A 1 +# define EVERGREEN_GRPH_BLUE_SEL_R 2 +# define EVERGREEN_GRPH_BLUE_SEL_G 3 +#define EVERGREEN_GRPH_ALPHA_CROSSBAR (x) (((x) & 0x3) << 10) +# define EVERGREEN_GRPH_ALPHA_SEL_A 0 +# define EVERGREEN_GRPH_ALPHA_SEL_R 1 +# define EVERGREEN_GRPH_ALPHA_SEL_G 2 +# define EVERGREEN_GRPH_ALPHA_SEL_B 3#define EVERGREEN_D3VGA_CONTROL 0xf8#define EVERGREEN_D4VGA_CONTROL 0xf9
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v3 3/3 drm/radeon: enable ABGR and XBGR formats (v2)
In reply to a message not in the archiveAdd support for DRM_FORMAT_{A,X}BGR8888 in atombios_crtc Swapping of red and blue channels is implemented for radeon chipsets:
DCE2/R6xx and later - crossbar registers defined where needed and used DCE1/R5xx - AVIVO_D1GRPH_SWAP_RB bit is used
(v2) Set AVIVO_D1GRPH_SWAP_RB bit in fb_format, using bitwise OR for DCE1 path
Use bitwise OR where required for big endian settings in fb_swap Use existing code style CHIP_R600 condition, fix typo in R600 blue crossbar
--- drivers/gpu/drm/radeon/atombios_crtc.c | 25 +++++++++++++++++++++ drivers/gpu/drm/radeon/r600_reg.h | 31 +++++++++++++++++++++----- 2 files changed, 51 insertions(+), 5 deletions(-)
drivers/gpu/drm/radeon/atombios_crtc.c +25 -0
@@ -1254,6 +1254,16 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,/* Greater 8 bpc fb needs to bypass hw-lut to retain precision */ bypass_lut = true;break ; +case DRM_FORMAT_XBGR8888 : +case DRM_FORMAT_ABGR8888 : + fb_format = (EVERGREEN_GRPH_DEPTH (EVERGREEN_GRPH_DEPTH_32BPP ) | +EVERGREEN_GRPH_FORMAT (EVERGREEN_GRPH_FORMAT_ARGB8888 )); + fb_swap = (EVERGREEN_GRPH_RED_CROSSBAR (EVERGREEN_GRPH_RED_SEL_B ) | +EVERGREEN_GRPH_BLUE_CROSSBAR (EVERGREEN_GRPH_BLUE_SEL_R )); +#ifdef __BIG_ENDIAN + fb_swap |=EVERGREEN_GRPH_ENDIAN_SWAP (EVERGREEN_GRPH_ENDIAN_8IN32 ); +#endif +break ;default :DRM_ERROR ("Unsupported screen format %s\n" ,drm_get_format_name (target_fb->format->format, &format_name));
@@ -1551,6 +1561,21 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,/* Greater 8 bpc fb needs to bypass hw-lut to retain precision */ bypass_lut = true;break ; +case DRM_FORMAT_XBGR8888 : +case DRM_FORMAT_ABGR8888 : + fb_format = +AVIVO_D1GRPH_CONTROL_DEPTH_32BPP | +AVIVO_D1GRPH_CONTROL_32BPP_ARGB8888 ; +if (rdev->family >=CHIP_R600 ) + fb_swap = + (R600_D1GRPH_RED_CROSSBAR (R600_D1GRPH_RED_SEL_B ) | +R600_D1GRPH_BLUE_CROSSBAR (R600_D1GRPH_BLUE_SEL_R )); +else /* DCE1 (R5xx) */ + fb_format |=AVIVO_D1GRPH_SWAP_RB ; +#ifdef __BIG_ENDIAN + fb_swap |=R600_D1GRPH_SWAP_ENDIAN_32BIT ; +#endif +break ;default :DRM_ERROR ("Unsupported screen format %s\n" ,drm_get_format_name (target_fb->format->format, &format_name));
drivers/gpu/drm/radeon/r600_reg.h +26 -5
@@ -87,11 +87,32 @@#define R600_MEDIUM_VID_LOWER_GPIO_CNTL 0x720#define R600_LOW_VID_LOWER_GPIO_CNTL 0x724 -#define R600_D1GRPH_SWAP_CONTROL 0x610C -# define R600_D1GRPH_SWAP_ENDIAN_NONE (0 << 0) -# define R600_D1GRPH_SWAP_ENDIAN_16BIT (1 << 0) -# define R600_D1GRPH_SWAP_ENDIAN_32BIT (2 << 0) -# define R600_D1GRPH_SWAP_ENDIAN_64BIT (3 << 0) +#define R600_D1GRPH_SWAP_CONTROL 0x610C +# define R600_D1GRPH_ENDIAN_SWAP (x) (((x) & 0x3) << 0) +# define R600_D1GRPH_SWAP_ENDIAN_NONE 0 +# define R600_D1GRPH_SWAP_ENDIAN_16BIT 1 +# define R600_D1GRPH_SWAP_ENDIAN_32BIT 2 +# define R600_D1GRPH_SWAP_ENDIAN_64BIT 3 +# define R600_D1GRPH_RED_CROSSBAR (x) (((x) & 0x3) << 4) +# define R600_D1GRPH_RED_SEL_R 0 +# define R600_D1GRPH_RED_SEL_G 1 +# define R600_D1GRPH_RED_SEL_B 2 +# define R600_D1GRPH_RED_SEL_A 3 +# define R600_D1GRPH_GREEN_CROSSBAR (x) (((x) & 0x3) << 6) +# define R600_D1GRPH_GREEN_SEL_G 0 +# define R600_D1GRPH_GREEN_SEL_B 1 +# define R600_D1GRPH_GREEN_SEL_A 2 +# define R600_D1GRPH_GREEN_SEL_R 3 +# define R600_D1GRPH_BLUE_CROSSBAR (x) (((x) & 0x3) << 8) +# define R600_D1GRPH_BLUE_SEL_B 0 +# define R600_D1GRPH_BLUE_SEL_A 1 +# define R600_D1GRPH_BLUE_SEL_R 2 +# define R600_D1GRPH_BLUE_SEL_G 3 +# define R600_D1GRPH_ALPHA_CROSSBAR (x) (((x) & 0x3) << 10) +# define R600_D1GRPH_ALPHA_SEL_A 0 +# define R600_D1GRPH_ALPHA_SEL_R 1 +# define R600_D1GRPH_ALPHA_SEL_G 2 +# define R600_D1GRPH_ALPHA_SEL_B 3#define R600_HDP_NONSURFACE_BASE 0x2c04
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 9 lines · Mauro Rossi
Sending PATCH v3 series for support of {A,X}RGB pixel formats in DCE1/R5xx and later, with separated patches for amd dc, amdgpu and radeon, based on Alexander Deucher comments
Tested and working on R5xx (X1300), R6xx (HD2400), R7xx (HD4830), Juniper (HD5770), Turks (HD7600M), Tahiti (HD7950), Bonaire (HD7790), Tonga (R9 380), Polaris (RX560) and Vega RX
Quoted 7 lines
Legacy radeon crtc was left unchanged, because R3xx/R4xx chipsets do not support {A,X}BGR_8888 pixel formats natively, moreover the legacy code path is still based on KMS API
[PATCH v3 1/3] drm/amd/display: enable ABGR and XBGR formats (v4) [PATCH v3 2/3] drm/amdgpu: enable ABGR and XBGR formats (v2) [PATCH v3 3/3] drm/radeon: enable ABGR and XBGR formats (v2)
Applied the series!
Thanks,
Alex
Quoted 5 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx