]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/sun4i: ui_layer: use layer struct instead of multiple args
authorJernej Skrabec <jernej.skrabec@gmail.com>
Tue, 4 Nov 2025 18:09:28 +0000 (19:09 +0100)
committerChen-Yu Tsai <wens@kernel.org>
Wed, 12 Nov 2025 09:18:23 +0000 (17:18 +0800)
This change is equally a cleanup (less arguments) and preparation for
DE33 separate plane driver. It will introduce additional register space.

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-17-jernej.skrabec@gmail.com
Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
drivers/gpu/drm/sun4i/sun8i_ui_layer.c

index e5f73060e3f1c052fbab8a4b63978d5c5d6cb48b..29b555132b1992fc92116892261bbaada1eabfaf 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)
+static void sun8i_ui_layer_disable(struct sun8i_layer *layer)
 {
-       u32 ch_base = sun8i_channel_base(mixer, channel);
+       struct sun8i_mixer *mixer = layer->mixer;
+       u32 ch_base = sun8i_channel_base(mixer, layer->channel);
 
        regmap_write(mixer->engine.regs,
-                    SUN8I_MIXER_CHAN_UI_LAYER_ATTR(ch_base, overlay), 0);
+                    SUN8I_MIXER_CHAN_UI_LAYER_ATTR(ch_base, layer->overlay), 0);
 }
 
-static void sun8i_ui_layer_update_attributes(struct sun8i_mixer *mixer,
-                                            int channel, int overlay,
+static void sun8i_ui_layer_update_attributes(struct sun8i_layer *layer,
                                             struct drm_plane *plane)
 {
        struct drm_plane_state *state = plane->state;
+       struct sun8i_mixer *mixer = layer->mixer;
        const struct drm_format_info *fmt;
        u32 val, ch_base, hw_fmt;
 
-       ch_base = sun8i_channel_base(mixer, channel);
+       ch_base = sun8i_channel_base(mixer, layer->channel);
        fmt = state->fb->format;
        sun8i_mixer_drm_format_to_hw(fmt->format, &hw_fmt);
 
@@ -55,22 +55,23 @@ static void sun8i_ui_layer_update_attributes(struct sun8i_mixer *mixer,
        val |= SUN8I_MIXER_CHAN_UI_LAYER_ATTR_EN;
 
        regmap_write(mixer->engine.regs,
-                    SUN8I_MIXER_CHAN_UI_LAYER_ATTR(ch_base, overlay), val);
+                    SUN8I_MIXER_CHAN_UI_LAYER_ATTR(ch_base, layer->overlay), val);
 }
 
-static void sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel,
-                                       int overlay, struct drm_plane *plane)
+static void sun8i_ui_layer_update_coord(struct sun8i_layer *layer,
+                                       struct drm_plane *plane)
 {
        struct drm_plane_state *state = plane->state;
+       struct sun8i_mixer *mixer = layer->mixer;
        u32 src_w, src_h, dst_w, dst_h;
        u32 outsize, insize;
        u32 hphase, vphase;
        u32 ch_base;
 
        DRM_DEBUG_DRIVER("Updating UI channel %d overlay %d\n",
-                        channel, overlay);
+                        layer->channel, layer->overlay);
 
-       ch_base = sun8i_channel_base(mixer, channel);
+       ch_base = sun8i_channel_base(mixer, layer->channel);
 
        src_w = drm_rect_width(&state->src) >> 16;
        src_h = drm_rect_height(&state->src) >> 16;
@@ -88,7 +89,7 @@ static void sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel,
                         state->src.x1 >> 16, state->src.y1 >> 16);
        DRM_DEBUG_DRIVER("Layer source size W: %d H: %d\n", src_w, src_h);
        regmap_write(mixer->engine.regs,
-                    SUN8I_MIXER_CHAN_UI_LAYER_SIZE(ch_base, overlay),
+                    SUN8I_MIXER_CHAN_UI_LAYER_SIZE(ch_base, layer->overlay),
                     insize);
        regmap_write(mixer->engine.regs,
                     SUN8I_MIXER_CHAN_UI_OVL_SIZE(ch_base),
@@ -103,37 +104,38 @@ static void sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel,
                vscale = state->src_h / state->crtc_h;
 
                if (mixer->cfg->de_type == SUN8I_MIXER_DE33) {
-                       sun8i_vi_scaler_setup(mixer, channel, src_w, src_h,
+                       sun8i_vi_scaler_setup(mixer, layer->channel, src_w, src_h,
                                              dst_w, dst_h, hscale, vscale,
                                              hphase, vphase,
                                              state->fb->format);
-                       sun8i_vi_scaler_enable(mixer, channel, true);
+                       sun8i_vi_scaler_enable(mixer, layer->channel, true);
                } else {
-                       sun8i_ui_scaler_setup(mixer, channel, src_w, src_h,
+                       sun8i_ui_scaler_setup(mixer, layer->channel, src_w, src_h,
                                              dst_w, dst_h, hscale, vscale,
                                              hphase, vphase);
-                       sun8i_ui_scaler_enable(mixer, channel, true);
+                       sun8i_ui_scaler_enable(mixer, layer->channel, true);
                }
        } else {
                DRM_DEBUG_DRIVER("HW scaling is not needed\n");
                if (mixer->cfg->de_type == SUN8I_MIXER_DE33)
-                       sun8i_vi_scaler_enable(mixer, channel, false);
+                       sun8i_vi_scaler_enable(mixer, layer->channel, false);
                else
-                       sun8i_ui_scaler_enable(mixer, channel, false);
+                       sun8i_ui_scaler_enable(mixer, layer->channel, false);
        }
 }
 
-static void sun8i_ui_layer_update_buffer(struct sun8i_mixer *mixer, int channel,
-                                        int overlay, struct drm_plane *plane)
+static void sun8i_ui_layer_update_buffer(struct sun8i_layer *layer,
+                                        struct drm_plane *plane)
 {
        struct drm_plane_state *state = plane->state;
+       struct sun8i_mixer *mixer = layer->mixer;
        struct drm_framebuffer *fb = state->fb;
        struct drm_gem_dma_object *gem;
        dma_addr_t dma_addr;
        u32 ch_base;
        int bpp;
 
-       ch_base = sun8i_channel_base(mixer, channel);
+       ch_base = sun8i_channel_base(mixer, layer->channel);
 
        /* Get the physical address of the buffer in memory */
        gem = drm_fb_dma_get_gem_obj(fb, 0);
@@ -151,13 +153,13 @@ static void sun8i_ui_layer_update_buffer(struct sun8i_mixer *mixer, int channel,
        /* Set the line width */
        DRM_DEBUG_DRIVER("Layer line width: %d bytes\n", fb->pitches[0]);
        regmap_write(mixer->engine.regs,
-                    SUN8I_MIXER_CHAN_UI_LAYER_PITCH(ch_base, overlay),
+                    SUN8I_MIXER_CHAN_UI_LAYER_PITCH(ch_base, layer->overlay),
                     fb->pitches[0]);
 
        DRM_DEBUG_DRIVER("Setting buffer address to %pad\n", &dma_addr);
 
        regmap_write(mixer->engine.regs,
-                    SUN8I_MIXER_CHAN_UI_LAYER_TOP_LADDR(ch_base, overlay),
+                    SUN8I_MIXER_CHAN_UI_LAYER_TOP_LADDR(ch_base, layer->overlay),
                     lower_32_bits(dma_addr));
 }
 
@@ -208,19 +210,15 @@ 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);
-       struct sun8i_mixer *mixer = layer->mixer;
 
        if (!new_state->crtc || !new_state->visible) {
-               sun8i_ui_layer_disable(mixer, layer->channel, layer->overlay);
+               sun8i_ui_layer_disable(layer);
                return;
        }
 
-       sun8i_ui_layer_update_attributes(mixer, layer->channel,
-                                        layer->overlay, plane);
-       sun8i_ui_layer_update_coord(mixer, layer->channel,
-                                   layer->overlay, plane);
-       sun8i_ui_layer_update_buffer(mixer, layer->channel,
-                                    layer->overlay, plane);
+       sun8i_ui_layer_update_attributes(layer, plane);
+       sun8i_ui_layer_update_coord(layer, plane);
+       sun8i_ui_layer_update_buffer(layer, plane);
 }
 
 static const struct drm_plane_helper_funcs sun8i_ui_layer_helper_funcs = {