]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/sun4i: mixer: Move layer enabling to atomic_update
authorJernej Skrabec <jernej.skrabec@gmail.com>
Tue, 4 Nov 2025 18:09:22 +0000 (19:09 +0100)
committerChen-Yu Tsai <wens@kernel.org>
Wed, 12 Nov 2025 09:18:22 +0000 (17:18 +0800)
Enable or disable layer only in layer atomic update callback. Doing so
will enable having separate layer driver later for DE33.

There is no fear that enable bit would be set incorrectly, as all
read-modify-write sequences for that register are now eliminated.

Reviewed-by: Chen-Yu Tsai <wens@kernel.org>
Tested-by: Ryan Walklin <ryan@testtoast.com>
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Link: https://patch.msgid.link/20251104180942.61538-11-jernej.skrabec@gmail.com
Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
drivers/gpu/drm/sun4i/sun8i_mixer.c
drivers/gpu/drm/sun4i/sun8i_ui_layer.c
drivers/gpu/drm/sun4i/sun8i_vi_layer.c

index c06c11137d31ab9708e49beeeb9837ee1c4752c2..091ea109713bd542752b6d3aae22ef9a868041f8 100644 (file)
@@ -251,24 +251,6 @@ int sun8i_mixer_drm_format_to_hw(u32 format, u32 *hw_format)
        return -EINVAL;
 }
 
-static void sun8i_layer_enable(struct sun8i_layer *layer, bool enable)
-{
-       u32 ch_base = sun8i_channel_base(layer->mixer, layer->channel);
-       u32 val, reg, mask;
-
-       if (layer->type == SUN8I_LAYER_TYPE_UI) {
-               val = enable ? SUN8I_MIXER_CHAN_UI_LAYER_ATTR_EN : 0;
-               mask = SUN8I_MIXER_CHAN_UI_LAYER_ATTR_EN;
-               reg = SUN8I_MIXER_CHAN_UI_LAYER_ATTR(ch_base, layer->overlay);
-       } else {
-               val = enable ? SUN8I_MIXER_CHAN_VI_LAYER_ATTR_EN : 0;
-               mask = SUN8I_MIXER_CHAN_VI_LAYER_ATTR_EN;
-               reg = SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, layer->overlay);
-       }
-
-       regmap_update_bits(layer->mixer->engine.regs, reg, mask, val);
-}
-
 static void sun8i_mixer_commit(struct sunxi_engine *engine,
                               struct drm_crtc *crtc,
                               struct drm_atomic_state *state)
@@ -305,12 +287,6 @@ static void sun8i_mixer_commit(struct sunxi_engine *engine,
                                 plane->base.id, layer->channel, layer->overlay,
                                 enable, zpos, x, y, w, h);
 
-               /*
-                * We always update the layer enable bit, because it can clear
-                * spontaneously for unknown reasons.
-                */
-               sun8i_layer_enable(layer, enable);
-
                if (!enable)
                        continue;
 
index 3a20be01ed4f339d5b3dc45d5e5d646b0e0acf97..939a704917a608cfe2982407a520a2423b1c6bd0 100644 (file)
 #include "sun8i_ui_scaler.h"
 #include "sun8i_vi_scaler.h"
 
+static void sun8i_ui_layer_disable(struct sun8i_mixer *mixer,
+                                  int channel, int overlay)
+{
+       u32 ch_base = sun8i_channel_base(mixer, channel);
+
+       regmap_write(mixer->engine.regs,
+                    SUN8I_MIXER_CHAN_UI_LAYER_ATTR(ch_base, overlay), 0);
+}
+
 static void sun8i_ui_layer_update_attributes(struct sun8i_mixer *mixer,
                                             int channel, int overlay,
                                             struct drm_plane *plane)
@@ -201,8 +210,10 @@ static void sun8i_ui_layer_atomic_update(struct drm_plane *plane,
        struct sun8i_layer *layer = plane_to_sun8i_layer(plane);
        struct sun8i_mixer *mixer = layer->mixer;
 
-       if (!new_state->crtc || !new_state->visible)
+       if (!new_state->crtc || !new_state->visible) {
+               sun8i_ui_layer_disable(mixer, layer->channel, layer->overlay);
                return;
+       }
 
        sun8i_ui_layer_update_attributes(mixer, layer->channel,
                                         layer->overlay, plane);
index 18f2df30f40ebdab1178312e8835c073c2de7d3e..03e55de3850eb1d18b21f3b87cae3789fd4a67af 100644 (file)
 #include "sun8i_vi_layer.h"
 #include "sun8i_vi_scaler.h"
 
+static void sun8i_vi_layer_disable(struct sun8i_mixer *mixer,
+                                  int channel, int overlay)
+{
+       u32 ch_base = sun8i_channel_base(mixer, channel);
+
+       regmap_write(mixer->engine.regs,
+                    SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, overlay), 0);
+}
+
 static void sun8i_vi_layer_update_attributes(struct sun8i_mixer *mixer,
                                             int channel, int overlay,
                                             struct drm_plane *plane)
@@ -320,8 +329,10 @@ static void sun8i_vi_layer_atomic_update(struct drm_plane *plane,
        struct sun8i_layer *layer = plane_to_sun8i_layer(plane);
        struct sun8i_mixer *mixer = layer->mixer;
 
-       if (!new_state->crtc || !new_state->visible)
+       if (!new_state->crtc || !new_state->visible) {
+               sun8i_vi_layer_disable(mixer, layer->channel, layer->overlay);
                return;
+       }
 
        sun8i_vi_layer_update_attributes(mixer, layer->channel,
                                         layer->overlay, plane);