198 lines
7.4 KiB
Diff
198 lines
7.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jernej Skrabec <[email protected]>
|
|
Date: Sun, 12 Oct 2025 21:23:07 +0200
|
|
Subject: drm/sun4i: Move blender config from layers to mixer
|
|
|
|
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 <[email protected]>
|
|
Tested-by: Ryan Walklin <[email protected]>
|
|
Signed-off-by: Jernej Skrabec <[email protected]>
|
|
---
|
|
drivers/gpu/drm/sun4i/sun8i_mixer.c | 17 +++++--
|
|
drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 22 ++--------
|
|
drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 22 ++--------
|
|
3 files changed, 20 insertions(+), 41 deletions(-)
|
|
|
|
diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c
|
|
index 111111111111..222222222222 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun8i_mixer.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c
|
|
@@ -283,8 +283,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;
|
|
@@ -295,10 +295,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
|
|
@@ -312,6 +316,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);
|
|
diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
|
|
index 111111111111..222222222222 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
|
|
@@ -47,21 +47,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;
|
|
@@ -113,17 +109,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,
|
|
diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
|
|
index 111111111111..222222222222 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
|
|
@@ -49,25 +49,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;
|
|
@@ -180,17 +176,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,
|
|
--
|
|
Armbian
|
|
|