Skip to content

Commit f10a801

Browse files
jernejskwens
authored andcommitted
drm/sun4i: vi_layer: use layer struct instead of multiple args
This change is equally a cleanup (less arguments) and preparation for DE33 separate plane driver. It will introduce additional register space. No functional changes. 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-18-jernej.skrabec@gmail.com Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
1 parent 7d126c6 commit f10a801

1 file changed

Lines changed: 28 additions & 30 deletions

File tree

drivers/gpu/drm/sun4i/sun8i_vi_layer.c

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@
1919
#include "sun8i_vi_layer.h"
2020
#include "sun8i_vi_scaler.h"
2121

22-
static void sun8i_vi_layer_disable(struct sun8i_mixer *mixer,
23-
int channel, int overlay)
22+
static void sun8i_vi_layer_disable(struct sun8i_layer *layer)
2423
{
25-
u32 ch_base = sun8i_channel_base(mixer, channel);
24+
struct sun8i_mixer *mixer = layer->mixer;
25+
u32 ch_base = sun8i_channel_base(mixer, layer->channel);
2626

2727
regmap_write(mixer->engine.regs,
28-
SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, overlay), 0);
28+
SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, layer->overlay), 0);
2929
}
3030

31-
static void sun8i_vi_layer_update_attributes(struct sun8i_mixer *mixer,
32-
int channel, int overlay,
31+
static void sun8i_vi_layer_update_attributes(struct sun8i_layer *layer,
3332
struct drm_plane *plane)
3433
{
3534
struct drm_plane_state *state = plane->state;
35+
struct sun8i_mixer *mixer = layer->mixer;
3636
const struct drm_format_info *fmt;
3737
u32 val, ch_base, hw_fmt;
3838

39-
ch_base = sun8i_channel_base(mixer, channel);
39+
ch_base = sun8i_channel_base(mixer, layer->channel);
4040
fmt = state->fb->format;
4141
sun8i_mixer_drm_format_to_hw(fmt->format, &hw_fmt);
4242

@@ -56,14 +56,15 @@ static void sun8i_vi_layer_update_attributes(struct sun8i_mixer *mixer,
5656
}
5757

5858
regmap_write(mixer->engine.regs,
59-
SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, overlay), val);
59+
SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, layer->overlay), val);
6060
}
6161

62-
static void sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel,
63-
int overlay, struct drm_plane *plane)
62+
static void sun8i_vi_layer_update_coord(struct sun8i_layer *layer,
63+
struct drm_plane *plane)
6464
{
6565
struct drm_plane_state *state = plane->state;
6666
const struct drm_format_info *format = state->fb->format;
67+
struct sun8i_mixer *mixer = layer->mixer;
6768
u32 src_w, src_h, dst_w, dst_h;
6869
u32 outsize, insize;
6970
u32 hphase, vphase;
@@ -73,9 +74,9 @@ static void sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel,
7374
u32 ch_base;
7475

7576
DRM_DEBUG_DRIVER("Updating VI channel %d overlay %d\n",
76-
channel, overlay);
77+
layer->channel, layer->overlay);
7778

78-
ch_base = sun8i_channel_base(mixer, channel);
79+
ch_base = sun8i_channel_base(mixer, layer->channel);
7980

8081
src_w = drm_rect_width(&state->src) >> 16;
8182
src_h = drm_rect_height(&state->src) >> 16;
@@ -113,7 +114,7 @@ static void sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel,
113114
(state->src.y1 >> 16) & ~(format->vsub - 1));
114115
DRM_DEBUG_DRIVER("Layer source size W: %d H: %d\n", src_w, src_h);
115116
regmap_write(mixer->engine.regs,
116-
SUN8I_MIXER_CHAN_VI_LAYER_SIZE(ch_base, overlay),
117+
SUN8I_MIXER_CHAN_VI_LAYER_SIZE(ch_base, layer->overlay),
117118
insize);
118119
regmap_write(mixer->engine.regs,
119120
SUN8I_MIXER_CHAN_VI_OVL_SIZE(ch_base),
@@ -162,13 +163,13 @@ static void sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel,
162163
hscale = (src_w << 16) / dst_w;
163164
vscale = (src_h << 16) / dst_h;
164165

165-
sun8i_vi_scaler_setup(mixer, channel, src_w, src_h, dst_w,
166+
sun8i_vi_scaler_setup(mixer, layer->channel, src_w, src_h, dst_w,
166167
dst_h, hscale, vscale, hphase, vphase,
167168
format);
168-
sun8i_vi_scaler_enable(mixer, channel, true);
169+
sun8i_vi_scaler_enable(mixer, layer->channel, true);
169170
} else {
170171
DRM_DEBUG_DRIVER("HW scaling is not needed\n");
171-
sun8i_vi_scaler_enable(mixer, channel, false);
172+
sun8i_vi_scaler_enable(mixer, layer->channel, false);
172173
}
173174

174175
regmap_write(mixer->engine.regs,
@@ -189,10 +190,11 @@ static void sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel,
189190
SUN8I_MIXER_CHAN_VI_DS_M(vm));
190191
}
191192

192-
static void sun8i_vi_layer_update_buffer(struct sun8i_mixer *mixer, int channel,
193-
int overlay, struct drm_plane *plane)
193+
static void sun8i_vi_layer_update_buffer(struct sun8i_layer *layer,
194+
struct drm_plane *plane)
194195
{
195196
struct drm_plane_state *state = plane->state;
197+
struct sun8i_mixer *mixer = layer->mixer;
196198
struct drm_framebuffer *fb = state->fb;
197199
const struct drm_format_info *format = fb->format;
198200
struct drm_gem_dma_object *gem;
@@ -201,7 +203,7 @@ static void sun8i_vi_layer_update_buffer(struct sun8i_mixer *mixer, int channel,
201203
u32 ch_base;
202204
int i;
203205

204-
ch_base = sun8i_channel_base(mixer, channel);
206+
ch_base = sun8i_channel_base(mixer, layer->channel);
205207

206208
/* Adjust x and y to be dividable by subsampling factor */
207209
src_x = (state->src.x1 >> 16) & ~(format->hsub - 1);
@@ -233,15 +235,15 @@ static void sun8i_vi_layer_update_buffer(struct sun8i_mixer *mixer, int channel,
233235
i + 1, fb->pitches[i]);
234236
regmap_write(mixer->engine.regs,
235237
SUN8I_MIXER_CHAN_VI_LAYER_PITCH(ch_base,
236-
overlay, i),
238+
layer->overlay, i),
237239
fb->pitches[i]);
238240

239241
DRM_DEBUG_DRIVER("Setting %d. buffer address to %pad\n",
240242
i + 1, &dma_addr);
241243

242244
regmap_write(mixer->engine.regs,
243245
SUN8I_MIXER_CHAN_VI_LAYER_TOP_LADDR(ch_base,
244-
overlay, i),
246+
layer->overlay, i),
245247
lower_32_bits(dma_addr));
246248
}
247249
}
@@ -292,20 +294,16 @@ static void sun8i_vi_layer_atomic_update(struct drm_plane *plane,
292294
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
293295
plane);
294296
struct sun8i_layer *layer = plane_to_sun8i_layer(plane);
295-
struct sun8i_mixer *mixer = layer->mixer;
296297

297298
if (!new_state->crtc || !new_state->visible) {
298-
sun8i_vi_layer_disable(mixer, layer->channel, layer->overlay);
299+
sun8i_vi_layer_disable(layer);
299300
return;
300301
}
301302

302-
sun8i_vi_layer_update_attributes(mixer, layer->channel,
303-
layer->overlay, plane);
304-
sun8i_vi_layer_update_coord(mixer, layer->channel,
305-
layer->overlay, plane);
306-
sun8i_csc_config(mixer, layer->channel, new_state);
307-
sun8i_vi_layer_update_buffer(mixer, layer->channel,
308-
layer->overlay, plane);
303+
sun8i_vi_layer_update_attributes(layer, plane);
304+
sun8i_vi_layer_update_coord(layer, plane);
305+
sun8i_csc_config(layer->mixer, layer->channel, new_state);
306+
sun8i_vi_layer_update_buffer(layer, plane);
309307
}
310308

311309
static const struct drm_plane_helper_funcs sun8i_vi_layer_helper_funcs = {

0 commit comments

Comments
 (0)