[PATCH v2 18/30] drm/sun4i: ui_scaler: use layer instead of mixer for args

Jernej Skrabec
2025-11-04T18:10:26Z

Layer related peripherals should take layer struct as a input. This
looks cleaner and also necessary for proper DE33 support later.

Reviewed-by: Chen-Yu Tsai <wens@kernel.org>
Tested-by: Ryan Walklin <ryan@testtoast.com>
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
---
drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 9 ++++-----
drivers/gpu/drm/sun4i/sun8i_ui_scaler.c | 14 ++++++++------
drivers/gpu/drm/sun4i/sun8i_ui_scaler.h | 4 ++--
3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
index d5b7241acdea..9b938e3dae9c 100644
--- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
@@ -109,17 +109,16 @@ static void sun8i_ui_layer_update_coord(struct sun8i_layer *layer,
state->fb->format);
sun8i_vi_scaler_enable(mixer, layer->channel, true);
} else {
- sun8i_ui_scaler_setup(mixer, layer->channel, src_w, src_h,
- dst_w, dst_h, hscale, vscale,
- hphase, vphase);
- sun8i_ui_scaler_enable(mixer, layer->channel, true);
+ sun8i_ui_scaler_setup(layer, src_w, src_h, dst_w, dst_h,
+ hscale, vscale, hphase, vphase);
+ sun8i_ui_scaler_enable(layer, true);
}
} else {
DRM_DEBUG_DRIVER("HW scaling is not needed\n");
if (mixer->cfg->de_type == SUN8I_MIXER_DE33)
sun8i_vi_scaler_enable(mixer, layer->channel, false);
else
- sun8i_ui_scaler_enable(mixer, layer->channel, false);
+ sun8i_ui_scaler_enable(layer, false);
}
}

diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_scaler.c b/drivers/gpu/drm/sun4i/sun8i_ui_scaler.c
index 8b7a58e27517..fcd72c4fd49a 100644
--- a/drivers/gpu/drm/sun4i/sun8i_ui_scaler.c
+++ b/drivers/gpu/drm/sun4i/sun8i_ui_scaler.c
@@ -127,14 +127,15 @@ static int sun8i_ui_scaler_coef_index(unsigned int step)
}
}

-void sun8i_ui_scaler_enable(struct sun8i_mixer *mixer, int layer, bool enable)
+void sun8i_ui_scaler_enable(struct sun8i_layer *layer, bool enable)
{
+ struct sun8i_mixer *mixer = layer->mixer;
u32 val, base;

- if (WARN_ON(layer < mixer->cfg->vi_num))
+ if (WARN_ON(layer->channel < mixer->cfg->vi_num))
return;

- base = sun8i_ui_scaler_base(mixer, layer);
+ base = sun8i_ui_scaler_base(mixer, layer->channel);

if (enable)
val = SUN8I_SCALER_GSU_CTRL_EN |
@@ -145,18 +146,19 @@ void sun8i_ui_scaler_enable(struct sun8i_mixer *mixer, int layer, bool enable)
regmap_write(mixer->engine.regs, SUN8I_SCALER_GSU_CTRL(base), val);
}

-void sun8i_ui_scaler_setup(struct sun8i_mixer *mixer, int layer,
+void sun8i_ui_scaler_setup(struct sun8i_layer *layer,
u32 src_w, u32 src_h, u32 dst_w, u32 dst_h,
u32 hscale, u32 vscale, u32 hphase, u32 vphase)
{
+ struct sun8i_mixer *mixer = layer->mixer;
u32 insize, outsize;
int i, offset;
u32 base;

- if (WARN_ON(layer < mixer->cfg->vi_num))
+ if (WARN_ON(layer->channel < mixer->cfg->vi_num))
return;

- base = sun8i_ui_scaler_base(mixer, layer);
+ base = sun8i_ui_scaler_base(mixer, layer->channel);

hphase <<= SUN8I_UI_SCALER_PHASE_FRAC - 16;
vphase <<= SUN8I_UI_SCALER_PHASE_FRAC - 16;
diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_scaler.h b/drivers/gpu/drm/sun4i/sun8i_ui_scaler.h
index 1ef4bd6f2718..872d88a58e7e 100644
--- a/drivers/gpu/drm/sun4i/sun8i_ui_scaler.h
+++ b/drivers/gpu/drm/sun4i/sun8i_ui_scaler.h
@@ -35,8 +35,8 @@
#define SUN8I_SCALER_GSU_CTRL_EN BIT(0)
#define SUN8I_SCALER_GSU_CTRL_COEFF_RDY BIT(4)

-void sun8i_ui_scaler_enable(struct sun8i_mixer *mixer, int layer, bool enable);
-void sun8i_ui_scaler_setup(struct sun8i_mixer *mixer, int layer,
+void sun8i_ui_scaler_enable(struct sun8i_layer *layer, bool enable);
+void sun8i_ui_scaler_setup(struct sun8i_layer *layer,
u32 src_w, u32 src_h, u32 dst_w, u32 dst_h,
u32 hscale, u32 vscale, u32 hphase, u32 vphase);

--
2.51.2