public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] drm/sun4i: sun8i: Add the ability to keep scaler enabled for VI layer
@ 2022-06-02 18:01 Roman Stratiienko
  2022-06-02 21:55 ` Ondřej Jirman
  2022-06-03  8:24 ` Maxime Ripard
  0 siblings, 2 replies; 6+ messages in thread
From: Roman Stratiienko @ 2022-06-02 18:01 UTC (permalink / raw)
  To: mripard, wens, jernej.skrabec, airlied, daniel, samuel, dri-devel,
	linux-arm-kernel, linux-sunxi, linux-kernel, megi
  Cc: Roman Stratiienko

According to DE2.0/DE3.0 manual VI scaler enable register is double
buffered, but de facto it doesn't, or the hardware has the shadow
register latching issues which causes single-frame picture corruption
after changing the state of scaler enable register.

Allow the user to keep the scaler always enabled, preventing the UI
glitches on the transition from scaled to unscaled state.

NOTE:
UI layer scaler has more registers with double-buffering issue and can't
be workarounded in the same manner.

You may find a python test and a demo video for this issue at [1]

[1]: https://github.com/GloDroid/glodroid_tests/issues/4
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
---
 drivers/gpu/drm/sun4i/sun8i_mixer.c    | 12 ++++++++++++
 drivers/gpu/drm/sun4i/sun8i_vi_layer.c |  4 +++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c
index 71ab0a00b4de..15cad0330f66 100644
--- a/drivers/gpu/drm/sun4i/sun8i_mixer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c
@@ -27,6 +27,18 @@
 #include "sun8i_vi_layer.h"
 #include "sunxi_engine.h"
 
+/* According to DE2.0/DE3.0 manual VI scaler enable register is double
+ * buffered, but de facto it doesn't, or the hardware has the shadow
+ * register latching issues which causes single-frame picture corruption
+ * after changing the state of scaler enable register.
+ * Allow the user to keep the scaler always enabled, preventing the UI
+ * glitches on the transition from scaled to unscaled state.
+ */
+int sun8i_vi_keep_scaler_enabled;
+MODULE_PARM_DESC(keep_vi_scaler_enabled,
+		 "Keep VI scaler enabled (1 = enabled, 0 = disabled (default))");
+module_param_named(keep_vi_scaler_enabled, sun8i_vi_keep_scaler_enabled, int, 0644);
+
 struct de2_fmt_info {
 	u32	drm_fmt;
 	u32	de2_fmt;
diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
index 662ba1018cc4..f005ab883503 100644
--- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
@@ -17,6 +17,8 @@
 #include "sun8i_vi_layer.h"
 #include "sun8i_vi_scaler.h"
 
+extern int sun8i_vi_keep_scaler_enabled;
+
 static void sun8i_vi_layer_enable(struct sun8i_mixer *mixer, int channel,
 				  int overlay, bool enable, unsigned int zpos)
 {
@@ -149,7 +151,7 @@ static int sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel,
 	 */
 	subsampled = format->hsub > 1 || format->vsub > 1;
 
-	if (insize != outsize || subsampled || hphase || vphase) {
+	if (insize != outsize || subsampled || hphase || vphase || sun8i_vi_keep_scaler_enabled) {
 		unsigned int scanline, required;
 		struct drm_display_mode *mode;
 		u32 hscale, vscale, fps;
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-03 14:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-02 18:01 [PATCH] drm/sun4i: sun8i: Add the ability to keep scaler enabled for VI layer Roman Stratiienko
2022-06-02 21:55 ` Ondřej Jirman
2022-06-03  7:16   ` Roman Stratiienko
2022-06-03  8:24 ` Maxime Ripard
2022-06-03  8:57   ` Roman Stratiienko
2022-06-03 14:19     ` Maxime Ripard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox