]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/sun4i: Move blender config from layers to mixer
authorJernej Skrabec <jernej.skrabec@gmail.com>
Tue, 4 Nov 2025 18:09:19 +0000 (19:09 +0100)
committerChen-Yu Tsai <wens@kernel.org>
Wed, 12 Nov 2025 09:18:22 +0000 (17:18 +0800)
With upcoming DE33 support, layer management must be decoupled from
other operations like blender configuration. There are two reasons:
- DE33 will have separate driver for planes and thus it will be harder
  to manage different register spaces
- Architecturaly it's better to split access by modules. Blender is now
  exclusively managed by mixer.

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-8-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 a0382a970e8e7d66901e8c8ab8f5ed60df5363ba..c06c11137d31ab9708e49beeeb9837ee1c4752c2 100644 (file)
@@ -284,8 +284,8 @@ static void sun8i_mixer_commit(struct sunxi_engine *engine,
 
        drm_for_each_plane(plane, state->dev) {
                struct sun8i_layer *layer = plane_to_sun8i_layer(plane);
+               int w, h, x, y, zpos;
                bool enable;
-               int zpos;
 
                if (!(plane->possible_crtcs & drm_crtc_mask(crtc)) || layer->mixer != mixer)
                        continue;
@@ -296,10 +296,14 @@ static void sun8i_mixer_commit(struct sunxi_engine *engine,
 
                enable = plane_state->crtc && plane_state->visible;
                zpos = plane_state->normalized_zpos;
+               x = plane_state->dst.x1;
+               y = plane_state->dst.y1;
+               w = drm_rect_width(&plane_state->dst);
+               h = drm_rect_height(&plane_state->dst);
 
-               DRM_DEBUG_DRIVER("  plane %d: chan=%d ovl=%d en=%d zpos=%d\n",
+               DRM_DEBUG_DRIVER("  plane %d: chan=%d ovl=%d en=%d zpos=%d x=%d y=%d w=%d h=%d\n",
                                 plane->base.id, layer->channel, layer->overlay,
-                                enable, zpos);
+                                enable, zpos, x, y, w, h);
 
                /*
                 * We always update the layer enable bit, because it can clear
@@ -313,6 +317,13 @@ static void sun8i_mixer_commit(struct sunxi_engine *engine,
                /* Route layer to pipe based on zpos */
                route |= layer->channel << SUN8I_MIXER_BLEND_ROUTE_PIPE_SHIFT(zpos);
                pipe_en |= SUN8I_MIXER_BLEND_PIPE_CTL_EN(zpos);
+
+               regmap_write(bld_regs,
+                            SUN8I_MIXER_BLEND_ATTR_COORD(bld_base, zpos),
+                            SUN8I_MIXER_COORD(x, y));
+               regmap_write(bld_regs,
+                            SUN8I_MIXER_BLEND_ATTR_INSIZE(bld_base, zpos),
+                            SUN8I_MIXER_SIZE(w, h));
        }
 
        regmap_write(bld_regs, SUN8I_MIXER_BLEND_ROUTE(bld_base), route);
index 3c86e890b06c047ae380ff5433b64ffcd95bdc7b..bf9cce262745407e2870457343a30b16ea9f9cfb 100644 (file)
@@ -48,21 +48,17 @@ static void sun8i_ui_layer_update_alpha(struct sun8i_mixer *mixer, int channel,
 }
 
 static void sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel,
-                                       int overlay, struct drm_plane *plane,
-                                       unsigned int zpos)
+                                       int overlay, struct drm_plane *plane)
 {
        struct drm_plane_state *state = plane->state;
        u32 src_w, src_h, dst_w, dst_h;
-       struct regmap *bld_regs;
-       u32 bld_base, ch_base;
        u32 outsize, insize;
        u32 hphase, vphase;
+       u32 ch_base;
 
        DRM_DEBUG_DRIVER("Updating UI channel %d overlay %d\n",
                         channel, overlay);
 
-       bld_base = sun8i_blender_base(mixer);
-       bld_regs = sun8i_blender_regmap(mixer);
        ch_base = sun8i_channel_base(mixer, channel);
 
        src_w = drm_rect_width(&state->src) >> 16;
@@ -114,17 +110,6 @@ static void sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel,
                else
                        sun8i_ui_scaler_enable(mixer, channel, false);
        }
-
-       /* Set base coordinates */
-       DRM_DEBUG_DRIVER("Layer destination coordinates X: %d Y: %d\n",
-                        state->dst.x1, state->dst.y1);
-       DRM_DEBUG_DRIVER("Layer destination size W: %d H: %d\n", dst_w, dst_h);
-       regmap_write(bld_regs,
-                    SUN8I_MIXER_BLEND_ATTR_COORD(bld_base, zpos),
-                    SUN8I_MIXER_COORD(state->dst.x1, state->dst.y1));
-       regmap_write(bld_regs,
-                    SUN8I_MIXER_BLEND_ATTR_INSIZE(bld_base, zpos),
-                    outsize);
 }
 
 static void sun8i_ui_layer_update_formats(struct sun8i_mixer *mixer, int channel,
@@ -230,14 +215,13 @@ static void sun8i_ui_layer_atomic_update(struct drm_plane *plane,
        struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
                                                                           plane);
        struct sun8i_layer *layer = plane_to_sun8i_layer(plane);
-       unsigned int zpos = new_state->normalized_zpos;
        struct sun8i_mixer *mixer = layer->mixer;
 
        if (!new_state->crtc || !new_state->visible)
                return;
 
        sun8i_ui_layer_update_coord(mixer, layer->channel,
-                                   layer->overlay, plane, zpos);
+                                   layer->overlay, plane);
        sun8i_ui_layer_update_alpha(mixer, layer->channel,
                                    layer->overlay, plane);
        sun8i_ui_layer_update_formats(mixer, layer->channel,
index 02e8ef1b137c4f64b60ff87d18a400c253ec1953..25d4e1710c1a186317a50e9a13427a88ef0cf01a 100644 (file)
@@ -50,25 +50,21 @@ static void sun8i_vi_layer_update_alpha(struct sun8i_mixer *mixer, int channel,
 }
 
 static void sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel,
-                                       int overlay, struct drm_plane *plane,
-                                       unsigned int zpos)
+                                       int overlay, struct drm_plane *plane)
 {
        struct drm_plane_state *state = plane->state;
        const struct drm_format_info *format = state->fb->format;
        u32 src_w, src_h, dst_w, dst_h;
-       struct regmap *bld_regs;
-       u32 bld_base, ch_base;
        u32 outsize, insize;
        u32 hphase, vphase;
        u32 hn = 0, hm = 0;
        u32 vn = 0, vm = 0;
        bool subsampled;
+       u32 ch_base;
 
        DRM_DEBUG_DRIVER("Updating VI channel %d overlay %d\n",
                         channel, overlay);
 
-       bld_base = sun8i_blender_base(mixer);
-       bld_regs = sun8i_blender_regmap(mixer);
        ch_base = sun8i_channel_base(mixer, channel);
 
        src_w = drm_rect_width(&state->src) >> 16;
@@ -181,17 +177,6 @@ static void sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel,
                     SUN8I_MIXER_CHAN_VI_VDS_UV(ch_base),
                     SUN8I_MIXER_CHAN_VI_DS_N(vn) |
                     SUN8I_MIXER_CHAN_VI_DS_M(vm));
-
-       /* Set base coordinates */
-       DRM_DEBUG_DRIVER("Layer destination coordinates X: %d Y: %d\n",
-                        state->dst.x1, state->dst.y1);
-       DRM_DEBUG_DRIVER("Layer destination size W: %d H: %d\n", dst_w, dst_h);
-       regmap_write(bld_regs,
-                    SUN8I_MIXER_BLEND_ATTR_COORD(bld_base, zpos),
-                    SUN8I_MIXER_COORD(state->dst.x1, state->dst.y1));
-       regmap_write(bld_regs,
-                    SUN8I_MIXER_BLEND_ATTR_INSIZE(bld_base, zpos),
-                    outsize);
 }
 
 static u32 sun8i_vi_layer_get_csc_mode(const struct drm_format_info *format)
@@ -350,14 +335,13 @@ static void sun8i_vi_layer_atomic_update(struct drm_plane *plane,
        struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
                                                                           plane);
        struct sun8i_layer *layer = plane_to_sun8i_layer(plane);
-       unsigned int zpos = new_state->normalized_zpos;
        struct sun8i_mixer *mixer = layer->mixer;
 
        if (!new_state->crtc || !new_state->visible)
                return;
 
        sun8i_vi_layer_update_coord(mixer, layer->channel,
-                                   layer->overlay, plane, zpos);
+                                   layer->overlay, plane);
        sun8i_vi_layer_update_alpha(mixer, layer->channel,
                                    layer->overlay, plane);
        sun8i_vi_layer_update_formats(mixer, layer->channel,