drm/rockchip: vop: Dither down to RGB666 if output bpc is 6
Subsystems (4)
PATCH 1/1 drm/rockchip: vop: Dither down to RGB666 if output bpc is 6
Tested to fix banding on the 6-bit panel of the ASUS C201.
--- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +10 -4
@@ -896,6 +896,7 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc,u16 vsync_len = adjusted_mode->vsync_end - adjusted_mode->vsync_start;u16 vact_st = adjusted_mode->vtotal - adjusted_mode->vsync_start;u16 vact_end = vact_st + vdisplay; +uint32_t dither_bits =0 ;uint32_t pin_pol, val;int ret;
@@ -951,10 +952,15 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc, !(vop_data->feature & VOP_FEATURE_OUTPUT_RGB10)) s->output_mode = ROCKCHIP_OUT_MODE_P888; -if (s->output_mode ==ROCKCHIP_OUT_MODE_AAAA && s->output_bpc ==8 ) -VOP_REG_SET (vop, common, pre_dither_down,1 ); -else -VOP_REG_SET (vop, common, pre_dither_down,0 ); +/* dither_down includes the bit for pre_dither_down */ +if (s->output_bpc) {/* Only dither if bpc known. */ +if (s->output_mode ==ROCKCHIP_OUT_MODE_AAAA && s->output_bpc <=8 ) + dither_bits =0x1 ; +/* Enable allegro dither to RGB666 */ +if (s->output_bpc ==6 ) + dither_bits |=0x6 ; + } +VOP_REG_SET (vop, common, dither_down, dither_bits);VOP_REG_SET (vop, common, out_mode, s->output_mode);
Signature · 1 line
2.20.1
Heiko Stuebner
maintainerHi,
Am Sonntag, 17. Februar 2019, 14:42:27 CET schrieb Urja Rannikko:
Quoted 26 lines
Tested to fix banding on the 6-bit panel of the ASUS C201.
Signed-off-by Urja Rannikko <[email protected]>--- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/gpu/drm/rockchip/rockchip_drm_vop.c +1
-3@@ -896,6 +896,7 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc,u16 vsync_len = adjusted_mode->vsync_end - adjusted_mode->vsync_start;u16 vact_st = adjusted_mode->vtotal - adjusted_mode->vsync_start;u16 vact_end = vact_st + vdisplay; +uint32_t dither_bits =0 ;uint32_t pin_pol, val;int ret;@@ -951,10 +952,15 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc, !(vop_data->feature & VOP_FEATURE_OUTPUT_RGB10)) s->output_mode = ROCKCHIP_OUT_MODE_P888; -if (s->output_mode ==ROCKCHIP_OUT_MODE_AAAA && s->output_bpc ==8 ) -VOP_REG_SET (vop, common, pre_dither_down,1 ); -else
drivers/gpu/drm/rockchip/rockchip_drm_vop.c static void vop_crtc_atomic_enable(struct drm_crtc *crtc, · line 963
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9
-1-VOP_REG_SET (vop, common, pre_dither_down,0 ); +/* dither_down includes the bit for pre_dither_down */ +if (s->output_bpc) {/* Only dither if bpc known. */ +if (s->output_mode ==ROCKCHIP_OUT_MODE_AAAA && s->output_bpc <=8 ) + dither_bits =0x1 ; +/* Enable allegro dither to RGB666 */ +if (s->output_bpc ==6 ) + dither_bits |=0x6 ; + } +VOP_REG_SET (vop, common, dither_down, dither_bits);
That won't work in this form. The vops change way to much in each iteration, so that these "bits" are not guaranteed to stay the same order for example.
Another caveat is that the "pre_dither_down" option is even only available on rk3288 and rk3328 and right now pre_dither_down and dither_down options seem to overlay each other.
In the vendor-kernel they seem to have changed how they handle dithering, including splitting up the dither-bits [0]. Sadly nobody from Rockchip seems to have found the time to upstream any of this.
In any case, I'd suggest to get inspiration from there (including the constants) to get dithering in mainline into a nice state.
Heiko
PATCH v2 1/1 drm/rockchip: vop: Support dithering to RGB666
In reply to Urja RannikkoSplits out the dither register bits and introduces the same config enumerations as in the rockchip kernel tree. Tested to fix the banding on my ASUS C201.
---
This is a version of the patch that is quite inspired by the rockchip kernel tree (that i hadn't looked at enough), but still keeps to just implementing RGB666 dithering because more changes are needed to get the information in place for detecting RGB565, but adding that should be easier afterwards.
drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 25 +++++++++++++++++---- drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 14 +++++++++++- drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 18 +++++++++++++-- 3 files changed, 50 insertions(+), 7 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +21 -4
@@ -951,10 +951,27 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc, !(vop_data->feature & VOP_FEATURE_OUTPUT_RGB10)) s->output_mode = ROCKCHIP_OUT_MODE_P888; -if (s->output_mode ==ROCKCHIP_OUT_MODE_AAAA && s->output_bpc ==8 ) -VOP_REG_SET (vop, common, pre_dither_down,1 ); -else -VOP_REG_SET (vop, common, pre_dither_down,0 ); +if (s->output_bpc) {/* Only dither if bpc known. */ +if (vop_data->feature &VOP_FEATURE_OUTPUT_RGB10 ) { +if (s->output_mode ==ROCKCHIP_OUT_MODE_AAAA && s->output_bpc <=8 ) +VOP_REG_SET (vop, common, pre_dither_down,1 ); +else +VOP_REG_SET (vop, common, pre_dither_down,0 ); + } +if (s->output_bpc ==6 ) { +/* Enable allegro dither to RGB666 */ +VOP_REG_SET (vop, common, dither_down_sel,DITHER_DOWN_ALLEGRO ); +VOP_REG_SET (vop, common, dither_down_mode,RGB888_TO_RGB666 ); +VOP_REG_SET (vop, common, dither_down_en,1 ); + }else { +VOP_REG_SET (vop, common, dither_down_en,0 ); + } + }else { +if (vop_data->feature &VOP_FEATURE_OUTPUT_RGB10 ) +VOP_REG_SET (vop, common, pre_dither_down,0 ); + +VOP_REG_SET (vop, common, dither_down_en,0 ); + }VOP_REG_SET (vop, common, out_mode, s->output_mode);
drivers/gpu/drm/rockchip/rockchip_drm_vop.h +13 -1
@@ -68,7 +68,9 @@ struct vop_common {struct vop_reg dsp_blank;struct vop_reg data_blank;struct vop_reg pre_dither_down; -struct vop_reg dither_down; +struct vop_reg dither_down_sel; +struct vop_reg dither_down_mode; +struct vop_reg dither_down_en;struct vop_reg dither_up;struct vop_reg gate_en;struct vop_reg mmu_en;
@@ -268,6 +270,16 @@ enum scale_down_mode {SCALE_DOWN_AVG =0x1 }; +enum dither_down_mode { +RGB888_TO_RGB565 =0x0 , +RGB888_TO_RGB666 =0x1 +}; + +enum dither_down_mode_sel { +DITHER_DOWN_ALLEGRO =0x0 , +DITHER_DOWN_FRC =0x1 +}; +enum vop_pol {HSYNC_POSITIVE =0 ,VSYNC_POSITIVE =1 ,
drivers/gpu/drm/rockchip/rockchip_vop_reg.c +16 -2
@@ -137,6 +137,9 @@ static const struct vop_common rk3036_common = { .standby = VOP_REG_SYNC(RK3036_SYS_CTRL, 0x1, 30), .out_mode = VOP_REG(RK3036_DSP_CTRL0, 0xf, 0), .dsp_blank = VOP_REG(RK3036_DSP_CTRL1, 0x1, 24), + .dither_down_sel = VOP_REG(RK3036_DSP_CTRL0, 0x1, 27), + .dither_down_en = VOP_REG(RK3036_DSP_CTRL0, 0x1, 11), + .dither_down_mode = VOP_REG(RK3036_DSP_CTRL0, 0x1, 10), .cfg_done = VOP_REG_SYNC(RK3036_REG_CFG_DONE, 0x1, 0), };
@@ -200,6 +203,9 @@ static const struct vop_common px30_common = { .standby = VOP_REG_SYNC(PX30_SYS_CTRL2, 0x1, 1), .out_mode = VOP_REG(PX30_DSP_CTRL2, 0xf, 16), .dsp_blank = VOP_REG(PX30_DSP_CTRL2, 0x1, 14), + .dither_down_en = VOP_REG(PX30_DSP_CTRL2, 0x1, 8), + .dither_down_sel = VOP_REG(PX30_DSP_CTRL2, 0x1, 7), + .dither_down_mode = VOP_REG(PX30_DSP_CTRL2, 0x1, 6), .cfg_done = VOP_REG_SYNC(PX30_REG_CFG_DONE, 0x1, 0), };
@@ -350,6 +356,9 @@ static const struct vop_common rk3188_common = { .standby = VOP_REG(RK3188_SYS_CTRL, 0x1, 30), .out_mode = VOP_REG(RK3188_DSP_CTRL0, 0xf, 0), .cfg_done = VOP_REG(RK3188_REG_CFG_DONE, 0x1, 0), + .dither_down_sel = VOP_REG(RK3188_DSP_CTRL0, 0x1, 27), + .dither_down_en = VOP_REG(RK3188_DSP_CTRL0, 0x1, 11), + .dither_down_mode = VOP_REG(RK3188_DSP_CTRL0, 0x1, 10), .dsp_blank = VOP_REG(RK3188_DSP_CTRL1, 0x3, 24), };
@@ -473,8 +482,10 @@ static const struct vop_common rk3288_common = { .standby = VOP_REG_SYNC(RK3288_SYS_CTRL, 0x1, 22), .gate_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 23), .mmu_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 20), + .dither_down_sel = VOP_REG(RK3288_DSP_CTRL1, 0x1, 4), + .dither_down_mode = VOP_REG(RK3288_DSP_CTRL1, 0x1, 3), + .dither_down_en = VOP_REG(RK3288_DSP_CTRL1, 0x1, 2), .pre_dither_down = VOP_REG(RK3288_DSP_CTRL1, 0x1, 1), - .dither_down = VOP_REG(RK3288_DSP_CTRL1, 0xf, 1), .dither_up = VOP_REG(RK3288_DSP_CTRL1, 0x1, 6), .data_blank = VOP_REG(RK3288_DSP_CTRL0, 0x1, 19), .dsp_blank = VOP_REG(RK3288_DSP_CTRL0, 0x3, 18),
@@ -707,7 +718,10 @@ static const struct vop_misc rk3328_misc = {static const struct vop_common rk3328_common = { .standby =VOP_REG_SYNC (RK3328_SYS_CTRL ,0x1 ,22 ), - .dither_down =VOP_REG (RK3328_DSP_CTRL1 ,0xf ,1 ), + .dither_down_sel =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,4 ), + .dither_down_mode =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,3 ), + .dither_down_en =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,2 ), + .pre_dither_down =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,1 ), .dither_up =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,6 ), .dsp_blank =VOP_REG (RK3328_DSP_CTRL0 ,0x3 ,18 ), .out_mode =VOP_REG (RK3328_DSP_CTRL0 ,0xf ,0 ),
Signature · 1 line
2.20.1
Re: [PATCH v2] drm/rockchip: vop: Support dithering to RGB666
Hi,
Umm, Ping?
Signature · 1 line
Urja Rannikko
A message that is not in the archive (sent off-list or not yet received): CAPCnQJnDB5Z=xNCdBw0R3k18GDKdUeZ__2fBA_YKYzZ6Rdny2Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: Re: [PATCH v2] drm/rockchip: vop: Support dithering to RGB666
How about RK3066? See/use linux-next.
A message that is not in the archive (sent off-list or not yet received): 223cf04e-5b35-4194-33c2-5614b329ec4b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: Re: [PATCH v2] drm/rockchip: vop: Support dithering to RGB666
Quoted 2 lines · Johan Jonker
How about RK3066? See/use linux-next.
Hi and thanks for the notice. The rest of this mail "addressed" for anyone interested.
I've added the dither bits for RK3066 - it doesnt have the bit for Allegro/FRC (sel)
which really isnt a problem, but brought up a question for me:
Should the code avoid calling vop_reg_write with unsupported registers/bits? I assumed a yes, but based on my tests it already does it on RK3288.. (atleast x/y_mir_en and act_info iirc).
This only results in a "Warning: not support reg_name" print in drm debug output,
but to me printing warnings during normal operations (even if they're only in debug output)
seems wrong.
I'll be sending a v3 of the patch after this mail, and i did avoid the unnecessary
write for now, but i expect to be changing that line of code :P
Signature · 1 line
Urja Rannikko
A message that is not in the archive (sent off-list or not yet received): CAPCnQJ=V32yJ01NZr0EO8hjjs=-zj+0MGddS+qd6txWqFs0mvg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH v2] drm/rockchip: vop: Support dithering to RGB666
Hi Urja,
Am Montag, 18. März 2019, 14:47:37 CET schrieb Urja Rannikko:
Quoted 5 lines · Johan Jonker
Quoted 1 line
How about RK3066? See/use linux-next.
Hi and thanks for the notice. The rest of this mail "addressed" for anyone interested.
would be me I guess ;-) .
And I was also just looking at the v2 today.
DRM tends to be difficult, as I'm not _that_ confident in spotting all things while just looking at the patch, that I want to do a roundtrip of testing on the Rockchip boards I have in my farm.
And finding that time is surprisingly difficult, especially as I haven't yet managed to export graphical output - in contrast I can do all non- graphic testing from everywhere with an internet connection.
So in any case, sorry about letting this sit for waaaay to long.
Quoted 11 lines
I've added the dither bits for RK3066 - it doesnt have the bit for Allegro/FRC (sel)
which really isnt a problem, but brought up a question for me:
Should the code avoid callingvop_reg_writewith unsupported registers/bits? I assumed a yes, but based on my tests it already does it on RK3288.. (atleast x/y_mir_en andact_infoiirc).This only results in a "Warning: not support
reg_name" print in drm debug output,
but to me printing warnings during normal operations (even if they're only in debug output) seems wrong.
Rockchip VOPs have the issue, that it seems soc designers make it a game to move as much registers around as possible between each implementation.
So I guess the silently ignoring of non-existent registers was somehow the easiest way of dealing with that gracefully.
PATCH v3 1/1 drm/rockchip: vop: Support dithering to RGB666
In reply to Urja RannikkoSplits out the dither register bits and introduces the same config enumerations as in the rockchip kernel tree. Tested to fix the banding on my ASUS C201.
---
v3: Support RK3066 which doesnt have the sel bit, thus question:
should we avoid that vop_reg_write call if the bit isnt supported as i did? If yes should i add a macro for the test?
(Since that doesnt yet exist in this version of the driver) -
This is a version of the patch that is quite inspired by the rockchip kernel tree (that i hadn't looked at enough), but still keeps to just implementing RGB666 dithering because more changes are needed to get the information in place for detecting RGB565, but adding that should be easier afterwards.
drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 26 +++++++++++++++++---- drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 14 ++++++++++- drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 20 ++++++++++++++-- 3 files changed, 53 insertions(+), 7 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +22 -4
@@ -1086,10 +1086,28 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc, !(vop_data->feature & VOP_FEATURE_OUTPUT_RGB10)) s->output_mode = ROCKCHIP_OUT_MODE_P888; -if (s->output_mode ==ROCKCHIP_OUT_MODE_AAAA && s->output_bpc ==8 ) -VOP_REG_SET (vop, common, pre_dither_down,1 ); -else -VOP_REG_SET (vop, common, pre_dither_down,0 ); +if (s->output_bpc) {/* Only dither if bpc known. */ +if (vop_data->feature &VOP_FEATURE_OUTPUT_RGB10 ) { +if (s->output_mode ==ROCKCHIP_OUT_MODE_AAAA && s->output_bpc <=8 ) +VOP_REG_SET (vop, common, pre_dither_down,1 ); +else +VOP_REG_SET (vop, common, pre_dither_down,0 ); + } +if (s->output_bpc ==6 ) { +if (&vop->data->common->dither_down_sel.mask) +VOP_REG_SET (vop, common, dither_down_sel,DITHER_DOWN_ALLEGRO ); + +VOP_REG_SET (vop, common, dither_down_mode,RGB888_TO_RGB666 ); +VOP_REG_SET (vop, common, dither_down_en,1 ); + }else { +VOP_REG_SET (vop, common, dither_down_en,0 ); + } + }else { +if (vop_data->feature &VOP_FEATURE_OUTPUT_RGB10 ) +VOP_REG_SET (vop, common, pre_dither_down,0 ); + +VOP_REG_SET (vop, common, dither_down_en,0 ); + }VOP_REG_SET (vop, common, out_mode, s->output_mode);
drivers/gpu/drm/rockchip/rockchip_drm_vop.h +13 -1
@@ -71,7 +71,9 @@ struct vop_common {struct vop_reg dsp_blank;struct vop_reg data_blank;struct vop_reg pre_dither_down; -struct vop_reg dither_down; +struct vop_reg dither_down_sel; +struct vop_reg dither_down_mode; +struct vop_reg dither_down_en;struct vop_reg dither_up;struct vop_reg gate_en;struct vop_reg mmu_en;
@@ -287,6 +289,16 @@ enum scale_down_mode {SCALE_DOWN_AVG =0x1 }; +enum dither_down_mode { +RGB888_TO_RGB565 =0x0 , +RGB888_TO_RGB666 =0x1 +}; + +enum dither_down_mode_sel { +DITHER_DOWN_ALLEGRO =0x0 , +DITHER_DOWN_FRC =0x1 +}; +enum vop_pol {HSYNC_POSITIVE =0 ,VSYNC_POSITIVE =1 ,
drivers/gpu/drm/rockchip/rockchip_vop_reg.c +18 -2
@@ -137,6 +137,9 @@ static const struct vop_common rk3036_common = { .standby = VOP_REG_SYNC(RK3036_SYS_CTRL, 0x1, 30), .out_mode = VOP_REG(RK3036_DSP_CTRL0, 0xf, 0), .dsp_blank = VOP_REG(RK3036_DSP_CTRL1, 0x1, 24), + .dither_down_sel = VOP_REG(RK3036_DSP_CTRL0, 0x1, 27), + .dither_down_en = VOP_REG(RK3036_DSP_CTRL0, 0x1, 11), + .dither_down_mode = VOP_REG(RK3036_DSP_CTRL0, 0x1, 10), .cfg_done = VOP_REG_SYNC(RK3036_REG_CFG_DONE, 0x1, 0), };
@@ -200,6 +203,9 @@ static const struct vop_common px30_common = { .standby = VOP_REG_SYNC(PX30_SYS_CTRL2, 0x1, 1), .out_mode = VOP_REG(PX30_DSP_CTRL2, 0xf, 16), .dsp_blank = VOP_REG(PX30_DSP_CTRL2, 0x1, 14), + .dither_down_en = VOP_REG(PX30_DSP_CTRL2, 0x1, 8), + .dither_down_sel = VOP_REG(PX30_DSP_CTRL2, 0x1, 7), + .dither_down_mode = VOP_REG(PX30_DSP_CTRL2, 0x1, 6), .cfg_done = VOP_REG_SYNC(PX30_REG_CFG_DONE, 0x1, 0), };
@@ -365,6 +371,8 @@ static const struct vop_common rk3066_common = { .standby = VOP_REG(RK3066_SYS_CTRL0, 0x1, 1), .out_mode = VOP_REG(RK3066_DSP_CTRL0, 0xf, 0), .cfg_done = VOP_REG(RK3066_REG_CFG_DONE, 0x1, 0), + .dither_down_en = VOP_REG(RK3066_DSP_CTRL0, 0x1, 11), + .dither_down_mode = VOP_REG(RK3066_DSP_CTRL0, 0x1, 10), .dsp_blank = VOP_REG(RK3066_DSP_CTRL1, 0x1, 24), };
@@ -458,6 +466,9 @@ static const struct vop_common rk3188_common = { .standby = VOP_REG(RK3188_SYS_CTRL, 0x1, 30), .out_mode = VOP_REG(RK3188_DSP_CTRL0, 0xf, 0), .cfg_done = VOP_REG(RK3188_REG_CFG_DONE, 0x1, 0), + .dither_down_sel = VOP_REG(RK3188_DSP_CTRL0, 0x1, 27), + .dither_down_en = VOP_REG(RK3188_DSP_CTRL0, 0x1, 11), + .dither_down_mode = VOP_REG(RK3188_DSP_CTRL0, 0x1, 10), .dsp_blank = VOP_REG(RK3188_DSP_CTRL1, 0x3, 24), };
@@ -585,8 +596,10 @@ static const struct vop_common rk3288_common = { .standby = VOP_REG_SYNC(RK3288_SYS_CTRL, 0x1, 22), .gate_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 23), .mmu_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 20), + .dither_down_sel = VOP_REG(RK3288_DSP_CTRL1, 0x1, 4), + .dither_down_mode = VOP_REG(RK3288_DSP_CTRL1, 0x1, 3), + .dither_down_en = VOP_REG(RK3288_DSP_CTRL1, 0x1, 2), .pre_dither_down = VOP_REG(RK3288_DSP_CTRL1, 0x1, 1), - .dither_down = VOP_REG(RK3288_DSP_CTRL1, 0xf, 1), .dither_up = VOP_REG(RK3288_DSP_CTRL1, 0x1, 6), .data_blank = VOP_REG(RK3288_DSP_CTRL0, 0x1, 19), .dsp_blank = VOP_REG(RK3288_DSP_CTRL0, 0x3, 18),
@@ -878,7 +891,10 @@ static const struct vop_misc rk3328_misc = {static const struct vop_common rk3328_common = { .standby =VOP_REG_SYNC (RK3328_SYS_CTRL ,0x1 ,22 ), - .dither_down =VOP_REG (RK3328_DSP_CTRL1 ,0xf ,1 ), + .dither_down_sel =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,4 ), + .dither_down_mode =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,3 ), + .dither_down_en =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,2 ), + .pre_dither_down =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,1 ), .dither_up =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,6 ), .dsp_blank =VOP_REG (RK3328_DSP_CTRL0 ,0x3 ,18 ), .out_mode =VOP_REG (RK3328_DSP_CTRL0 ,0xf ,0 ),
Signature · 1 line
2.21.0
PATCH v4 1/1 drm/rockchip: vop: Support dithering to RGB666
Splits out the dither register bits and introduces the same config enumerations as in the rockchip kernel tree. Tested to fix the banding on my ASUS C201.
---
v4: Simplified the code flow and allow vop_write_reg to deal with unsupported bits - maybe clean up the debug output later.. -
v3: Support RK3066
-
This is a version of the patch that is quite inspired by the rockchip kernel tree (that i hadn't looked at enough), but still keeps to just implementing RGB666 dithering because more changes are needed to get the information in place for detecting RGB565, but adding that should be easier afterwards.
-
drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 11 ++++++++++- drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 14 +++++++++++++- drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 20 ++++++++++++++++++-- 3 files changed, 41 insertions(+), 4 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +10 -1
@@ -1029,6 +1029,7 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc,u16 vact_st = adjusted_mode->vtotal - adjusted_mode->vsync_start;u16 vact_end = vact_st + vdisplay;uint32_t pin_pol, val; +int dither_bpc = s->output_bpc ? s->output_bpc :10 ;int ret;mutex_lock (&vop->vop_lock);
@@ -1086,11 +1087,19 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc, !(vop_data->feature & VOP_FEATURE_OUTPUT_RGB10)) s->output_mode = ROCKCHIP_OUT_MODE_P888; -if (s->output_mode ==ROCKCHIP_OUT_MODE_AAAA && s->output_bpc ==8 ) +if (s->output_mode ==ROCKCHIP_OUT_MODE_AAAA && dither_bpc <=8 )VOP_REG_SET (vop, common, pre_dither_down,1 );else VOP_REG_SET (vop, common, pre_dither_down,0 ); +if (dither_bpc ==6 ) { +VOP_REG_SET (vop, common, dither_down_sel,DITHER_DOWN_ALLEGRO ); +VOP_REG_SET (vop, common, dither_down_mode,RGB888_TO_RGB666 ); +VOP_REG_SET (vop, common, dither_down_en,1 ); + }else { +VOP_REG_SET (vop, common, dither_down_en,0 ); + } +VOP_REG_SET (vop, common, out_mode, s->output_mode);VOP_REG_SET (vop, modeset, htotal_pw, (htotal <<16 ) | hsync_len);
drivers/gpu/drm/rockchip/rockchip_drm_vop.h +13 -1
@@ -71,7 +71,9 @@ struct vop_common {struct vop_reg dsp_blank;struct vop_reg data_blank;struct vop_reg pre_dither_down; -struct vop_reg dither_down; +struct vop_reg dither_down_sel; +struct vop_reg dither_down_mode; +struct vop_reg dither_down_en;struct vop_reg dither_up;struct vop_reg gate_en;struct vop_reg mmu_en;
@@ -287,6 +289,16 @@ enum scale_down_mode {SCALE_DOWN_AVG =0x1 }; +enum dither_down_mode { +RGB888_TO_RGB565 =0x0 , +RGB888_TO_RGB666 =0x1 +}; + +enum dither_down_mode_sel { +DITHER_DOWN_ALLEGRO =0x0 , +DITHER_DOWN_FRC =0x1 +}; +enum vop_pol {HSYNC_POSITIVE =0 ,VSYNC_POSITIVE =1 ,
drivers/gpu/drm/rockchip/rockchip_vop_reg.c +18 -2
@@ -137,6 +137,9 @@ static const struct vop_common rk3036_common = { .standby = VOP_REG_SYNC(RK3036_SYS_CTRL, 0x1, 30), .out_mode = VOP_REG(RK3036_DSP_CTRL0, 0xf, 0), .dsp_blank = VOP_REG(RK3036_DSP_CTRL1, 0x1, 24), + .dither_down_sel = VOP_REG(RK3036_DSP_CTRL0, 0x1, 27), + .dither_down_en = VOP_REG(RK3036_DSP_CTRL0, 0x1, 11), + .dither_down_mode = VOP_REG(RK3036_DSP_CTRL0, 0x1, 10), .cfg_done = VOP_REG_SYNC(RK3036_REG_CFG_DONE, 0x1, 0), };
@@ -200,6 +203,9 @@ static const struct vop_common px30_common = { .standby = VOP_REG_SYNC(PX30_SYS_CTRL2, 0x1, 1), .out_mode = VOP_REG(PX30_DSP_CTRL2, 0xf, 16), .dsp_blank = VOP_REG(PX30_DSP_CTRL2, 0x1, 14), + .dither_down_en = VOP_REG(PX30_DSP_CTRL2, 0x1, 8), + .dither_down_sel = VOP_REG(PX30_DSP_CTRL2, 0x1, 7), + .dither_down_mode = VOP_REG(PX30_DSP_CTRL2, 0x1, 6), .cfg_done = VOP_REG_SYNC(PX30_REG_CFG_DONE, 0x1, 0), };
@@ -365,6 +371,8 @@ static const struct vop_common rk3066_common = { .standby = VOP_REG(RK3066_SYS_CTRL0, 0x1, 1), .out_mode = VOP_REG(RK3066_DSP_CTRL0, 0xf, 0), .cfg_done = VOP_REG(RK3066_REG_CFG_DONE, 0x1, 0), + .dither_down_en = VOP_REG(RK3066_DSP_CTRL0, 0x1, 11), + .dither_down_mode = VOP_REG(RK3066_DSP_CTRL0, 0x1, 10), .dsp_blank = VOP_REG(RK3066_DSP_CTRL1, 0x1, 24), };
@@ -458,6 +466,9 @@ static const struct vop_common rk3188_common = { .standby = VOP_REG(RK3188_SYS_CTRL, 0x1, 30), .out_mode = VOP_REG(RK3188_DSP_CTRL0, 0xf, 0), .cfg_done = VOP_REG(RK3188_REG_CFG_DONE, 0x1, 0), + .dither_down_sel = VOP_REG(RK3188_DSP_CTRL0, 0x1, 27), + .dither_down_en = VOP_REG(RK3188_DSP_CTRL0, 0x1, 11), + .dither_down_mode = VOP_REG(RK3188_DSP_CTRL0, 0x1, 10), .dsp_blank = VOP_REG(RK3188_DSP_CTRL1, 0x3, 24), };
@@ -585,8 +596,10 @@ static const struct vop_common rk3288_common = { .standby = VOP_REG_SYNC(RK3288_SYS_CTRL, 0x1, 22), .gate_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 23), .mmu_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 20), + .dither_down_sel = VOP_REG(RK3288_DSP_CTRL1, 0x1, 4), + .dither_down_mode = VOP_REG(RK3288_DSP_CTRL1, 0x1, 3), + .dither_down_en = VOP_REG(RK3288_DSP_CTRL1, 0x1, 2), .pre_dither_down = VOP_REG(RK3288_DSP_CTRL1, 0x1, 1), - .dither_down = VOP_REG(RK3288_DSP_CTRL1, 0xf, 1), .dither_up = VOP_REG(RK3288_DSP_CTRL1, 0x1, 6), .data_blank = VOP_REG(RK3288_DSP_CTRL0, 0x1, 19), .dsp_blank = VOP_REG(RK3288_DSP_CTRL0, 0x3, 18),
@@ -878,7 +891,10 @@ static const struct vop_misc rk3328_misc = {static const struct vop_common rk3328_common = { .standby =VOP_REG_SYNC (RK3328_SYS_CTRL ,0x1 ,22 ), - .dither_down =VOP_REG (RK3328_DSP_CTRL1 ,0xf ,1 ), + .dither_down_sel =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,4 ), + .dither_down_mode =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,3 ), + .dither_down_en =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,2 ), + .pre_dither_down =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,1 ), .dither_up =VOP_REG (RK3328_DSP_CTRL1 ,0x1 ,6 ), .dsp_blank =VOP_REG (RK3328_DSP_CTRL0 ,0x3 ,18 ), .out_mode =VOP_REG (RK3328_DSP_CTRL0 ,0xf ,0 ),
Signature · 1 line
2.21.0
Re: [PATCH v4] drm/rockchip: vop: Support dithering to RGB666
Am Montag, 18. März 2019, 16:44:12 CET schrieb Urja Rannikko:
Quoted 5 lines
Splits out the dither register bits and introduces the same config enumerations as in the rockchip kernel tree. Tested to fix the banding on my ASUS C201.
Signed-off-by Urja Rannikko <[email protected]>
applied to drm-misc-next ... so for 5.2
Thanks
Heiko