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>
This commit is contained in:
Jernej Skrabec 2025-11-04 19:09:34 +01:00 committed by Chen-Yu Tsai
parent 0bc7d54dcc
commit 515441734c
6 changed files with 23 additions and 11 deletions

View File

@ -284,14 +284,14 @@ static void sun8i_mixer_commit(struct sunxi_engine *engine,
h = drm_rect_height(&plane_state->dst);
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,
plane->base.id, layer->index, layer->overlay,
enable, zpos, x, y, w, h);
if (!enable)
continue;
/* Route layer to pipe based on zpos */
route |= layer->channel << SUN8I_MIXER_BLEND_ROUTE_PIPE_SHIFT(zpos);
route |= layer->index << SUN8I_MIXER_BLEND_ROUTE_PIPE_SHIFT(zpos);
pipe_en |= SUN8I_MIXER_BLEND_PIPE_CTL_EN(zpos);
regmap_write(bld_regs,
@ -318,6 +318,7 @@ static struct drm_plane **sun8i_layers_init(struct drm_device *drm,
struct sun8i_mixer *mixer = engine_to_sun8i_mixer(engine);
int plane_cnt = mixer->cfg->ui_num + mixer->cfg->vi_num;
enum drm_plane_type type;
unsigned int phy_index;
int i;
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,
else
type = DRM_PLANE_TYPE_OVERLAY;
phy_index = i;
if (mixer->cfg->de_type == SUN8I_MIXER_DE33)
phy_index = mixer->cfg->map[i];
layer = sun8i_vi_layer_init_one(drm, mixer, type,
mixer->engine.regs, i,
plane_cnt);
phy_index, plane_cnt);
if (IS_ERR(layer)) {
dev_err(drm->dev,
"Couldn't initialize overlay plane\n");
@ -353,9 +358,13 @@ static struct drm_plane **sun8i_layers_init(struct drm_device *drm,
else
type = DRM_PLANE_TYPE_OVERLAY;
phy_index = index;
if (mixer->cfg->de_type == SUN8I_MIXER_DE33)
phy_index = mixer->cfg->map[index];
layer = sun8i_ui_layer_init_one(drm, mixer, type,
mixer->engine.regs, index,
plane_cnt);
phy_index, plane_cnt);
if (IS_ERR(layer)) {
dev_err(drm->dev, "Couldn't initialize %s plane\n",
i ? "overlay" : "primary");

View File

@ -212,6 +212,7 @@ struct sun8i_layer {
struct drm_plane plane;
struct sun8i_mixer *mixer;
int type;
int index;
int channel;
int overlay;
struct regmap *regs;
@ -246,7 +247,7 @@ static inline u32
sun8i_channel_base(struct sun8i_mixer *mixer, int channel)
{
if (mixer->cfg->de_type == SUN8I_MIXER_DE33)
return DE33_CH_BASE + mixer->cfg->map[channel] * DE33_CH_SIZE;
return DE33_CH_BASE + channel * DE33_CH_SIZE;
else if (mixer->cfg->de_type == SUN8I_MIXER_DE3)
return DE3_CH_BASE + channel * DE3_CH_SIZE;
else

View File

@ -265,7 +265,7 @@ struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_device *drm,
struct sun8i_mixer *mixer,
enum drm_plane_type type,
struct regmap *regs,
int index,
int index, int phy_index,
int plane_cnt)
{
struct sun8i_layer *layer;
@ -277,7 +277,8 @@ struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_device *drm,
layer->mixer = mixer;
layer->type = SUN8I_LAYER_TYPE_UI;
layer->channel = index;
layer->index = index;
layer->channel = phy_index;
layer->overlay = 0;
layer->regs = regs;

View File

@ -53,6 +53,6 @@ struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_device *drm,
struct sun8i_mixer *mixer,
enum drm_plane_type type,
struct regmap *regs,
int index,
int index, int phy_index,
int plane_cnt);
#endif /* _SUN8I_UI_LAYER_H_ */

View File

@ -411,7 +411,7 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm,
struct sun8i_mixer *mixer,
enum drm_plane_type type,
struct regmap *regs,
int index,
int index, int phy_index,
int plane_cnt)
{
u32 supported_encodings, supported_ranges;
@ -426,7 +426,8 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm,
layer->mixer = mixer;
layer->type = SUN8I_LAYER_TYPE_VI;
layer->channel = index;
layer->index = index;
layer->channel = phy_index;
layer->overlay = 0;
layer->regs = regs;

View File

@ -58,6 +58,6 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm,
struct sun8i_mixer *mixer,
enum drm_plane_type type,
struct regmap *regs,
int index,
int index, int phy_index,
int plane_cnt);
#endif /* _SUN8I_VI_LAYER_H_ */