drm/sun4i: frontend: Rework a bit the phase data
PATCH 1/3 drm/sun4i: frontend: Rework a bit the phase data
The scaler filter phase setup in the allwinner kernel has two different cases for setting up the scaler filter, the first one using different phase parameters for the two channels, and the second one reusing the first channel parameters on the second channel.
The allwinner kernel has a third option where the horizontal phase of the second channel will be set to a different value than the vertical one (and seems like it's the same value than one used on the first channel). However, that code path seems to never be taken, so we can ignore it for now, and it's essentially what we're doing so far as well.
Since we will have always the same values across each components of the filter setup for a given channel, we can simplify a bit our frontend structure by only storing the phase value we want to apply to a given channel.
--- drivers/gpu/drm/sun4i/sun4i_frontend.c | 34 ++++++-------------------- drivers/gpu/drm/sun4i/sun4i_frontend.h | 6 +---- 2 files changed, 9 insertions(+), 31 deletions(-)
drivers/gpu/drm/sun4i/sun4i_frontend.c +8 -26
@@ -443,17 +443,17 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend,* related to the scaler FIR filter phase parameters. */ regmap_write (frontend->regs,SUN4I_FRONTEND_CH0_HORZPHASE_REG , - frontend->data->ch_phase[0 ].horzphase); + frontend->data->ch_phase[0 ]);regmap_write (frontend->regs,SUN4I_FRONTEND_CH1_HORZPHASE_REG , - frontend->data->ch_phase[1 ].horzphase); + frontend->data->ch_phase[1 ]);regmap_write (frontend->regs,SUN4I_FRONTEND_CH0_VERTPHASE0_REG , - frontend->data->ch_phase[0 ].vertphase[0 ]); + frontend->data->ch_phase[0 ]);regmap_write (frontend->regs,SUN4I_FRONTEND_CH1_VERTPHASE0_REG , - frontend->data->ch_phase[1 ].vertphase[0 ]); + frontend->data->ch_phase[1 ]);regmap_write (frontend->regs,SUN4I_FRONTEND_CH0_VERTPHASE1_REG , - frontend->data->ch_phase[0 ].vertphase[1 ]); + frontend->data->ch_phase[0 ]);regmap_write (frontend->regs,SUN4I_FRONTEND_CH1_VERTPHASE1_REG , - frontend->data->ch_phase[1 ].vertphase[1 ]); + frontend->data->ch_phase[1 ]);/* * Checking the input format is sufficient since we currently only
@@ -687,30 +687,12 @@ static const struct dev_pm_ops sun4i_frontend_pm_ops = { };static const struct sun4i_frontend_data sun4i_a10_frontend = { - .ch_phase = { - { - .horzphase =0 , - .vertphase = {0 ,0 }, - }, - { - .horzphase =0xfc000 , - .vertphase = {0xfc000 ,0xfc000 }, - }, - }, + .ch_phase = {0x000 ,0xfc000 }, .has_coef_rdy = true, };static const struct sun4i_frontend_data sun8i_a33_frontend = { - .ch_phase = { - { - .horzphase =0x400 , - .vertphase = {0x400 ,0x400 }, - }, - { - .horzphase =0x400 , - .vertphase = {0x400 ,0x400 }, - }, - }, + .ch_phase = {0x400 ,0x400 }, .has_coef_access_ctrl = true, };
drivers/gpu/drm/sun4i/sun4i_frontend.h +1 -5
@@ -115,11 +115,7 @@ struct reset_control;struct sun4i_frontend_data {bool has_coef_access_ctrl;bool has_coef_rdy; - -struct { -u32 horzphase; -u32 vertphase[2 ]; - } ch_phase[2 ]; +u32 ch_phase[2 ]; };struct sun4i_frontend {
Signature · 7 lines
2.26.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/3 drm/sun4i: frontend: Reuse the ch0 phase for RGB formats
When using the scaler on the A10-like frontend with single-planar formats, the current code will setup the channel 0 filter (used for the R or Y component) with a different phase parameter than the channel 1 filter (used for the G/B or U/V components).
This creates a bleed out that keeps repeating on of the last line of the RGB plane across the rest of the display. The Allwinner BSP either applies the same phase parameter over both channels or use a separate one, the condition being whether the input format is YUV420 or not.
Since YUV420 is both subsampled and multi-planar, and since YUYV is subsampled but single-planar, we can rule out the subsampling and assume that the condition is actually whether the format is single or multi-planar. And it looks like applying the same phase parameter over both channels for single-planar formats fixes our issue, while we keep the multi-planar formats working properly.
--- drivers/gpu/drm/sun4i/sun4i_frontend.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/sun4i/sun4i_frontend.c +5 -3
@@ -407,6 +407,7 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend,struct drm_framebuffer *fb = state->fb;const struct drm_format_info *format = fb->format;uint64_t modifier = fb->modifier; +unsigned ch1_phase_idx;u32 out_fmt_val;u32 in_fmt_val, in_mod_val, in_ps_val;unsigned int i;
@@ -442,18 +443,19 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend,* I have no idea what this does exactly, but it seems to be * related to the scaler FIR filter phase parameters. */ + ch1_phase_idx = (format->num_planes >1 ) ?1 :0 ;regmap_write (frontend->regs,SUN4I_FRONTEND_CH0_HORZPHASE_REG , frontend->data->ch_phase[0 ]);regmap_write (frontend->regs,SUN4I_FRONTEND_CH1_HORZPHASE_REG , - frontend->data->ch_phase[1 ]); + frontend->data->ch_phase[ch1_phase_idx]);regmap_write (frontend->regs,SUN4I_FRONTEND_CH0_VERTPHASE0_REG , frontend->data->ch_phase[0 ]);regmap_write (frontend->regs,SUN4I_FRONTEND_CH1_VERTPHASE0_REG , - frontend->data->ch_phase[1 ]); + frontend->data->ch_phase[ch1_phase_idx]);regmap_write (frontend->regs,SUN4I_FRONTEND_CH0_VERTPHASE1_REG , frontend->data->ch_phase[0 ]);regmap_write (frontend->regs,SUN4I_FRONTEND_CH1_VERTPHASE1_REG , - frontend->data->ch_phase[1 ]); + frontend->data->ch_phase[ch1_phase_idx]);/* * Checking the input format is sufficient since we currently only
Signature · 7 lines
2.26.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 2/3] drm/sun4i: frontend: Reuse the ch0 phase for RGB formats
Hi!
Dne četrtek, 15. oktober 2020 ob 11:36:41 CEST je Maxime Ripard napisal(a):
Quoted 17 lines
When using the scaler on the A10-like frontend with single-planar formats, the current code will setup the channel 0 filter (used for the R or Y component) with a different phase parameter than the channel 1 filter (used for the G/B or U/V components).
This creates a bleed out that keeps repeating on of the last line of the RGB plane across the rest of the display. The Allwinner BSP either applies the same phase parameter over both channels or use a separate one, the condition being whether the input format is YUV420 or not.
Since YUV420 is both subsampled and multi-planar, and since YUYV is subsampled but single-planar, we can rule out the subsampling and assume that the condition is actually whether the format is single or multi-planar. And it looks like applying the same phase parameter over both channels for single-planar formats fixes our issue, while we keep the multi-planar formats working properly.
Quoted 2 lines
Reported-by Taras Galchenko <[email protected]>Signed-off-by Maxime Ripard <[email protected]>
Best regards,
Jernej
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 3/3 drm/sun4i: frontend: Fix the scaler phase on A33
In reply to Maxime RipardThe A33 has a different phase parameter in the Allwinner BSP on the channel1 than the one currently applied. Fix this.
--- drivers/gpu/drm/sun4i/sun4i_frontend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun4i_frontend.c +1 -1
@@ -694,7 +694,7 @@ static const struct sun4i_frontend_data sun4i_a10_frontend = { };static const struct sun4i_frontend_data sun8i_a33_frontend = { - .ch_phase = {0x400 ,0x400 }, + .ch_phase = {0x400 ,0xfc400 }, .has_coef_access_ctrl = true, };
Signature · 7 lines
2.26.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 3/3] drm/sun4i: frontend: Fix the scaler phase on A33
Hi!
Dne četrtek, 15. oktober 2020 ob 11:36:42 CEST je Maxime Ripard napisal(a):
Quoted 4 lines
The A33 has a different phase parameter in the Allwinner BSP on the channel1 than the one currently applied. Fix this.
Signed-off-by Maxime Ripard <[email protected]>
Best regards,
Jernej
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 3/3] drm/sun4i: frontend: Fix the scaler phase on A33
Quoted 9 lines · Jernej Škrabec
Hi!
Dne četrtek, 15. oktober 2020 ob 11:36:42 CEST je Maxime Ripard napisal(a):
Quoted 4 lines
The A33 has a different phase parameter in the Allwinner BSP on the channel1 than the one currently applied. Fix this.
Signed-off-by Maxime Ripard <[email protected]>Acked-by Jernej Skrabec <[email protected]>
Thanks for reviewing those patches, I've merged them
Maxime
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi!
Dne četrtek, 15. oktober 2020 ob 11:36:40 CEST je Maxime Ripard napisal(a):
Quoted 11 lines
The scaler filter phase setup in the allwinner kernel has two different cases for setting up the scaler filter, the first one using different phase parameters for the two channels, and the second one reusing the first channel parameters on the second channel.
The allwinner kernel has a third option where the horizontal phase of the second channel will be set to a different value than the vertical one (and seems like it's the same value than one used on the first channel). However, that code path seems to never be taken, so we can ignore it for now, and it's essentially what we're doing so far as well.
Quoted 6 lines
Since we will have always the same values across each components of the filter setup for a given channel, we can simplify a bit our frontend structure by only storing the phase value we want to apply to a given channel.
Signed-off-by Maxime Ripard <[email protected]>
Best regards,
Jernej
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel