diff options
| author | Jernej Skrabec <jernej.skrabec@gmail.com> | 2025-11-04 19:09:40 +0100 |
|---|---|---|
| committer | Chen-Yu Tsai <wens@kernel.org> | 2025-11-12 17:18:25 +0800 |
| commit | bb1d2ddee5c45017e6b6e50c9eda02cb2bd600b6 (patch) | |
| tree | ab9b1e2155aa7cc90710c581bf11b14fc0a0a15c /drivers/gpu/drm/sun4i/sun8i_vi_layer.c | |
| parent | d1fe2639425c121f811f73fd948dea2477ad9a19 (diff) | |
drm/sun4i: layer: replace mixer with layer struct
This allows to almost completely decouple layer code from mixer. This is
important for DE33.
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-29-jernej.skrabec@gmail.com
Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
Diffstat (limited to 'drivers/gpu/drm/sun4i/sun8i_vi_layer.c')
| -rw-r--r-- | drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c index 84ca7a37f14c..5f91011425bf 100644 --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c @@ -21,10 +21,9 @@ static void sun8i_vi_layer_disable(struct sun8i_layer *layer) { - struct sun8i_mixer *mixer = layer->mixer; - u32 ch_base = sun8i_channel_base(mixer, layer->channel); + u32 ch_base = sun8i_channel_base(layer); - regmap_write(mixer->engine.regs, + regmap_write(layer->regs, SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, layer->overlay), 0); } @@ -32,11 +31,10 @@ static void sun8i_vi_layer_update_attributes(struct sun8i_layer *layer, struct drm_plane *plane) { struct drm_plane_state *state = plane->state; - struct sun8i_mixer *mixer = layer->mixer; const struct drm_format_info *fmt; u32 val, ch_base, hw_fmt; - ch_base = sun8i_channel_base(mixer, layer->channel); + ch_base = sun8i_channel_base(layer); fmt = state->fb->format; sun8i_mixer_drm_format_to_hw(fmt->format, &hw_fmt); @@ -44,7 +42,7 @@ static void sun8i_vi_layer_update_attributes(struct sun8i_layer *layer, if (!fmt->is_yuv) val |= SUN8I_MIXER_CHAN_VI_LAYER_ATTR_RGB_MODE; val |= SUN8I_MIXER_CHAN_VI_LAYER_ATTR_EN; - if (mixer->cfg->de_type >= SUN8I_MIXER_DE3) { + if (layer->cfg->de_type >= SUN8I_MIXER_DE3) { val |= SUN50I_MIXER_CHAN_VI_LAYER_ATTR_ALPHA(state->alpha >> 8); val |= (state->alpha == DRM_BLEND_ALPHA_OPAQUE) ? SUN50I_MIXER_CHAN_VI_LAYER_ATTR_ALPHA_MODE_PIXEL : @@ -54,7 +52,7 @@ static void sun8i_vi_layer_update_attributes(struct sun8i_layer *layer, regmap_write(layer->regs, SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, layer->overlay), val); - if (mixer->cfg->lay_cfg.de2_fcc_alpha) { + if (layer->cfg->de2_fcc_alpha) { regmap_write(layer->regs, SUN8I_MIXER_FCC_GLOBAL_ALPHA_REG, SUN8I_MIXER_FCC_GLOBAL_ALPHA(state->alpha >> 8)); @@ -78,7 +76,7 @@ static void sun8i_vi_layer_update_coord(struct sun8i_layer *layer, DRM_DEBUG_DRIVER("Updating VI channel %d overlay %d\n", layer->channel, layer->overlay); - ch_base = sun8i_channel_base(mixer, layer->channel); + ch_base = sun8i_channel_base(layer); src_w = drm_rect_width(&state->src) >> 16; src_h = drm_rect_height(&state->src) >> 16; @@ -153,7 +151,7 @@ static void sun8i_vi_layer_update_coord(struct sun8i_layer *layer, } /* it seems that every RGB scaler has buffer for 2048 pixels */ - scanline = subsampled ? mixer->cfg->lay_cfg.scanline_yuv : 2048; + scanline = subsampled ? layer->cfg->scanline_yuv : 2048; if (src_w > scanline) { DRM_DEBUG_DRIVER("Using horizontal coarse scaling\n"); @@ -195,7 +193,6 @@ static void sun8i_vi_layer_update_buffer(struct sun8i_layer *layer, struct drm_plane *plane) { struct drm_plane_state *state = plane->state; - struct sun8i_mixer *mixer = layer->mixer; struct drm_framebuffer *fb = state->fb; const struct drm_format_info *format = fb->format; struct drm_gem_dma_object *gem; @@ -204,7 +201,7 @@ static void sun8i_vi_layer_update_buffer(struct sun8i_layer *layer, u32 ch_base; int i; - ch_base = sun8i_channel_base(mixer, layer->channel); + ch_base = sun8i_channel_base(layer); /* Adjust x and y to be dividable by subsampling factor */ src_x = (state->src.x1 >> 16) & ~(format->hsub - 1); @@ -278,7 +275,7 @@ static int sun8i_vi_layer_atomic_check(struct drm_plane *plane, min_scale = DRM_PLANE_NO_SCALING; max_scale = DRM_PLANE_NO_SCALING; - if (layer->mixer->cfg->lay_cfg.scaler_mask & BIT(layer->channel)) { + if (layer->cfg->scaler_mask & BIT(layer->channel)) { min_scale = SUN8I_VI_SCALER_SCALE_MIN; max_scale = SUN8I_VI_SCALER_SCALE_MAX; } @@ -414,7 +411,8 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm, enum drm_plane_type type, struct regmap *regs, int index, int phy_index, - int plane_cnt) + int plane_cnt, + const struct sun8i_layer_cfg *cfg) { u32 supported_encodings, supported_ranges; unsigned int format_count; @@ -432,8 +430,9 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm, layer->channel = phy_index; layer->overlay = 0; layer->regs = regs; + layer->cfg = cfg; - if (mixer->cfg->de_type >= SUN8I_MIXER_DE3) { + if (layer->cfg->de_type >= SUN8I_MIXER_DE3) { formats = sun8i_vi_layer_de3_formats; format_count = ARRAY_SIZE(sun8i_vi_layer_de3_formats); } else { @@ -452,7 +451,7 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm, return ERR_PTR(ret); } - if (mixer->cfg->lay_cfg.de2_fcc_alpha || mixer->cfg->de_type >= SUN8I_MIXER_DE3) { + if (layer->cfg->de2_fcc_alpha || layer->cfg->de_type >= SUN8I_MIXER_DE3) { ret = drm_plane_create_alpha_property(&layer->plane); if (ret) { dev_err(drm->dev, "Couldn't add alpha property\n"); @@ -469,7 +468,7 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm, supported_encodings = BIT(DRM_COLOR_YCBCR_BT601) | BIT(DRM_COLOR_YCBCR_BT709); - if (mixer->cfg->de_type >= SUN8I_MIXER_DE3) + if (layer->cfg->de_type >= SUN8I_MIXER_DE3) supported_encodings |= BIT(DRM_COLOR_YCBCR_BT2020); supported_ranges = BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) | |