]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/sun4i: layers: add physical index arg
authorJernej Skrabec <jernej.skrabec@gmail.com>
Tue, 4 Nov 2025 18:09:34 +0000 (19:09 +0100)
committerChen-Yu Tsai <wens@kernel.org>
Wed, 12 Nov 2025 09:18:23 +0000 (17:18 +0800)
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>
drivers/gpu/drm/sun4i/sun8i_mixer.c
drivers/gpu/drm/sun4i/sun8i_mixer.h
drivers/gpu/drm/sun4i/sun8i_ui_layer.c
drivers/gpu/drm/sun4i/sun8i_ui_layer.h
drivers/gpu/drm/sun4i/sun8i_vi_layer.c
drivers/gpu/drm/sun4i/sun8i_vi_layer.h

index f8af959e5d66d0608bd357fe1ef08488770c539d..ceb9bd92015139175110cdc53dc500d78abb7566 100644 (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");
index 2e3689008b506cd377ff589e74bbec458c5c0d20..d14188cdfab31f879047b1ec8eb4e45093131ce5 100644 (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
index a038c170680392a2bae1342c77bc29a30f2399fd..2bbd00f595f7038f0eb4ef1e616f116b9098529c 100644 (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;
 
index e0b2cfa02749167b3fea35569b56a6ffb18cfdd0..9383c3364df3dd3b64f6d7edc017c471d5998ac6 100644 (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_ */
index 78df7836099fda6f23aa2c65d819c103a056c28b..ce4b270e503be9ca4524751fd36272923e5197bf 100644 (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;
 
index 70766d752fa65d2bc974d421c1f97018b42b0896..89d0c32e63cf8f0eb7f1cf17b146741e53d4969d 100644 (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_ */