]> git.baikalelectronics.ru Git - kernel.git/commitdiff
sun4i/drm: sun8i: use mode_set engine callback
authorJernej Skrabec <jernej.skrabec@gmail.com>
Sun, 24 Apr 2022 16:26:26 +0000 (11:26 -0500)
committerMaxime Ripard <maxime@cerno.tech>
Tue, 26 Apr 2022 12:24:47 +0000 (14:24 +0200)
Newly introduced mode_set callback in engine structure is a much better
place for setting mixer output size and interlace mode for the following
reasons:
1. Aforementioned properties change only when mode changes, so it's
   enough to be set only once per mode set. Currently it's done whenever
   properties of primary plane are changed.
2. It's assumed that primary plane will always cover whole screen. While
   this is true most of the time, it's not always. DE2/3 planes are
   universal and mostly equal in functionality. There is no reason to
   add artificial limitation to primary planes.
3. The current code only works for UI layers, but some mixers do not
   have any UI layers.

Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
[Samuel: update commit message]
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20220424162633.12369-9-samuel@sholland.org
drivers/gpu/drm/sun4i/sun8i_mixer.c
drivers/gpu/drm/sun4i/sun8i_ui_layer.c

index f5e8aeaa3cdf802675299685585a292fd9ab5c0d..6b1711a9a71f20475721f5bf82bee8a77d4ceccf 100644 (file)
@@ -298,9 +298,39 @@ static struct drm_plane **sun8i_layers_init(struct drm_device *drm,
        return planes;
 }
 
+static void sun8i_mixer_mode_set(struct sunxi_engine *engine,
+                                const struct drm_display_mode *mode)
+{
+       struct sun8i_mixer *mixer = engine_to_sun8i_mixer(engine);
+       u32 bld_base, size, val;
+       bool interlaced;
+
+       bld_base = sun8i_blender_base(mixer);
+       interlaced = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
+       size = SUN8I_MIXER_SIZE(mode->hdisplay, mode->vdisplay);
+
+       DRM_DEBUG_DRIVER("Updating global size W: %u H: %u\n",
+                        mode->hdisplay, mode->vdisplay);
+
+       regmap_write(engine->regs, SUN8I_MIXER_GLOBAL_SIZE, size);
+       regmap_write(engine->regs, SUN8I_MIXER_BLEND_OUTSIZE(bld_base), size);
+
+       if (interlaced)
+               val = SUN8I_MIXER_BLEND_OUTCTL_INTERLACED;
+       else
+               val = 0;
+
+       regmap_update_bits(engine->regs, SUN8I_MIXER_BLEND_OUTCTL(bld_base),
+                          SUN8I_MIXER_BLEND_OUTCTL_INTERLACED, val);
+
+       DRM_DEBUG_DRIVER("Switching display mixer interlaced mode %s\n",
+                        interlaced ? "on" : "off");
+}
+
 static const struct sunxi_engine_ops sun8i_engine_ops = {
        .commit         = sun8i_mixer_commit,
        .layers_init    = sun8i_layers_init,
+       .mode_set       = sun8i_mixer_mode_set,
 };
 
 static const struct regmap_config sun8i_mixer_regmap_config = {
index 7845c2a53a7fb52f0ff4c0e83988f6f076485cda..4632dea2dc1e76201a26d878d284dac46fb27d38 100644 (file)
@@ -120,36 +120,6 @@ static int sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel,
        insize = SUN8I_MIXER_SIZE(src_w, src_h);
        outsize = SUN8I_MIXER_SIZE(dst_w, dst_h);
 
-       if (plane->type == DRM_PLANE_TYPE_PRIMARY) {
-               bool interlaced = false;
-               u32 val;
-
-               DRM_DEBUG_DRIVER("Primary layer, updating global size W: %u H: %u\n",
-                                dst_w, dst_h);
-               regmap_write(mixer->engine.regs,
-                            SUN8I_MIXER_GLOBAL_SIZE,
-                            outsize);
-               regmap_write(mixer->engine.regs,
-                            SUN8I_MIXER_BLEND_OUTSIZE(bld_base), outsize);
-
-               if (state->crtc)
-                       interlaced = state->crtc->state->adjusted_mode.flags
-                               & DRM_MODE_FLAG_INTERLACE;
-
-               if (interlaced)
-                       val = SUN8I_MIXER_BLEND_OUTCTL_INTERLACED;
-               else
-                       val = 0;
-
-               regmap_update_bits(mixer->engine.regs,
-                                  SUN8I_MIXER_BLEND_OUTCTL(bld_base),
-                                  SUN8I_MIXER_BLEND_OUTCTL_INTERLACED,
-                                  val);
-
-               DRM_DEBUG_DRIVER("Switching display mixer interlaced mode %s\n",
-                                interlaced ? "on" : "off");
-       }
-
        /* Set height and width */
        DRM_DEBUG_DRIVER("Layer source offset X: %d Y: %d\n",
                         state->src.x1 >> 16, state->src.y1 >> 16);