Skip to content

Commit 5154417

Browse files
jernejskwens
authored andcommitted
drm/sun4i: layers: add physical index arg
This avoids plane mapping in layers code, which allows future refactoring, when layer code will move away from accessing mixer structure. 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-23-jernej.skrabec@gmail.com Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
1 parent 0bc7d54 commit 5154417

6 files changed

Lines changed: 23 additions & 11 deletions

File tree

drivers/gpu/drm/sun4i/sun8i_mixer.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,14 @@ static void sun8i_mixer_commit(struct sunxi_engine *engine,
284284
h = drm_rect_height(&plane_state->dst);
285285

286286
DRM_DEBUG_DRIVER(" plane %d: chan=%d ovl=%d en=%d zpos=%d x=%d y=%d w=%d h=%d\n",
287-
plane->base.id, layer->channel, layer->overlay,
287+
plane->base.id, layer->index, layer->overlay,
288288
enable, zpos, x, y, w, h);
289289

290290
if (!enable)
291291
continue;
292292

293293
/* Route layer to pipe based on zpos */
294-
route |= layer->channel << SUN8I_MIXER_BLEND_ROUTE_PIPE_SHIFT(zpos);
294+
route |= layer->index << SUN8I_MIXER_BLEND_ROUTE_PIPE_SHIFT(zpos);
295295
pipe_en |= SUN8I_MIXER_BLEND_PIPE_CTL_EN(zpos);
296296

297297
regmap_write(bld_regs,
@@ -318,6 +318,7 @@ static struct drm_plane **sun8i_layers_init(struct drm_device *drm,
318318
struct sun8i_mixer *mixer = engine_to_sun8i_mixer(engine);
319319
int plane_cnt = mixer->cfg->ui_num + mixer->cfg->vi_num;
320320
enum drm_plane_type type;
321+
unsigned int phy_index;
321322
int i;
322323

323324
planes = devm_kcalloc(drm->dev, plane_cnt, sizeof(*planes), GFP_KERNEL);
@@ -332,9 +333,13 @@ static struct drm_plane **sun8i_layers_init(struct drm_device *drm,
332333
else
333334
type = DRM_PLANE_TYPE_OVERLAY;
334335

336+
phy_index = i;
337+
if (mixer->cfg->de_type == SUN8I_MIXER_DE33)
338+
phy_index = mixer->cfg->map[i];
339+
335340
layer = sun8i_vi_layer_init_one(drm, mixer, type,
336341
mixer->engine.regs, i,
337-
plane_cnt);
342+
phy_index, plane_cnt);
338343
if (IS_ERR(layer)) {
339344
dev_err(drm->dev,
340345
"Couldn't initialize overlay plane\n");
@@ -353,9 +358,13 @@ static struct drm_plane **sun8i_layers_init(struct drm_device *drm,
353358
else
354359
type = DRM_PLANE_TYPE_OVERLAY;
355360

361+
phy_index = index;
362+
if (mixer->cfg->de_type == SUN8I_MIXER_DE33)
363+
phy_index = mixer->cfg->map[index];
364+
356365
layer = sun8i_ui_layer_init_one(drm, mixer, type,
357366
mixer->engine.regs, index,
358-
plane_cnt);
367+
phy_index, plane_cnt);
359368
if (IS_ERR(layer)) {
360369
dev_err(drm->dev, "Couldn't initialize %s plane\n",
361370
i ? "overlay" : "primary");

drivers/gpu/drm/sun4i/sun8i_mixer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ struct sun8i_layer {
212212
struct drm_plane plane;
213213
struct sun8i_mixer *mixer;
214214
int type;
215+
int index;
215216
int channel;
216217
int overlay;
217218
struct regmap *regs;
@@ -246,7 +247,7 @@ static inline u32
246247
sun8i_channel_base(struct sun8i_mixer *mixer, int channel)
247248
{
248249
if (mixer->cfg->de_type == SUN8I_MIXER_DE33)
249-
return DE33_CH_BASE + mixer->cfg->map[channel] * DE33_CH_SIZE;
250+
return DE33_CH_BASE + channel * DE33_CH_SIZE;
250251
else if (mixer->cfg->de_type == SUN8I_MIXER_DE3)
251252
return DE3_CH_BASE + channel * DE3_CH_SIZE;
252253
else

drivers/gpu/drm/sun4i/sun8i_ui_layer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_device *drm,
265265
struct sun8i_mixer *mixer,
266266
enum drm_plane_type type,
267267
struct regmap *regs,
268-
int index,
268+
int index, int phy_index,
269269
int plane_cnt)
270270
{
271271
struct sun8i_layer *layer;
@@ -277,7 +277,8 @@ struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_device *drm,
277277

278278
layer->mixer = mixer;
279279
layer->type = SUN8I_LAYER_TYPE_UI;
280-
layer->channel = index;
280+
layer->index = index;
281+
layer->channel = phy_index;
281282
layer->overlay = 0;
282283
layer->regs = regs;
283284

drivers/gpu/drm/sun4i/sun8i_ui_layer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_device *drm,
5353
struct sun8i_mixer *mixer,
5454
enum drm_plane_type type,
5555
struct regmap *regs,
56-
int index,
56+
int index, int phy_index,
5757
int plane_cnt);
5858
#endif /* _SUN8I_UI_LAYER_H_ */

drivers/gpu/drm/sun4i/sun8i_vi_layer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm,
411411
struct sun8i_mixer *mixer,
412412
enum drm_plane_type type,
413413
struct regmap *regs,
414-
int index,
414+
int index, int phy_index,
415415
int plane_cnt)
416416
{
417417
u32 supported_encodings, supported_ranges;
@@ -426,7 +426,8 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm,
426426

427427
layer->mixer = mixer;
428428
layer->type = SUN8I_LAYER_TYPE_VI;
429-
layer->channel = index;
429+
layer->index = index;
430+
layer->channel = phy_index;
430431
layer->overlay = 0;
431432
layer->regs = regs;
432433

drivers/gpu/drm/sun4i/sun8i_vi_layer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm,
5858
struct sun8i_mixer *mixer,
5959
enum drm_plane_type type,
6060
struct regmap *regs,
61-
int index,
61+
int index, int phy_index,
6262
int plane_cnt);
6363
#endif /* _SUN8I_VI_LAYER_H_ */

0 commit comments

Comments
 (0)