diff --git a/msm/sde/sde_crtc.c b/msm/sde/sde_crtc.c index f1d1e5410f..ca0bf301a0 100644 --- a/msm/sde/sde_crtc.c +++ b/msm/sde/sde_crtc.c @@ -7505,16 +7505,28 @@ static void sde_cp_crtc_apply_noise(struct drm_crtc *crtc, struct sde_hw_mixer *lm; int i; struct sde_hw_noise_layer_cfg cfg; + struct sde_kms *kms; if (!test_bit(SDE_CRTC_NOISE_LAYER, cstate->dirty)) return; + kms = _sde_crtc_get_kms(crtc); + if (!kms || !kms->catalog) { + SDE_ERROR("Invalid kms\n"); + return; + } + cfg.flags = cstate->layer_cfg.flags; cfg.alpha_noise = cstate->layer_cfg.alpha_noise; cfg.attn_factor = cstate->layer_cfg.attn_factor; cfg.strength = cstate->layer_cfg.strength; - cfg.zposn = cstate->layer_cfg.zposn; - cfg.zposattn = cstate->layer_cfg.zposattn; + if (!kms->catalog->has_base_layer) { + cfg.noise_blend_stage = cstate->layer_cfg.zposn + SDE_STAGE_0; + cfg.attn_blend_stage = cstate->layer_cfg.zposattn + SDE_STAGE_0; + } else { + cfg.noise_blend_stage = cstate->layer_cfg.zposn; + cfg.attn_blend_stage = cstate->layer_cfg.zposattn; + } for (i = 0; i < scrtc->num_mixers; i++) { lm = scrtc->mixers[i].hw_lm; diff --git a/msm/sde/sde_hw_lm.c b/msm/sde/sde_hw_lm.c index 3a18646a91..cb1c1b6aff 100644 --- a/msm/sde/sde_hw_lm.c +++ b/msm/sde/sde_hw_lm.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. */ #include @@ -316,16 +316,18 @@ static int sde_hw_lm_setup_noise_layer(struct sde_hw_mixer *ctx, if (!cfg) return 0; - if (cfg->zposn == SDE_STAGE_BASE || cfg->zposn + 1 != cfg->zposattn || - cfg->zposattn >= sblk->maxblendstages) { - SDE_ERROR("invalid zposn %d zposattn %d max stage %d\n", - cfg->zposn, cfg->zposattn, sblk->maxblendstages); + if (cfg->noise_blend_stage == SDE_STAGE_BASE || + cfg->noise_blend_stage + 1 != cfg->attn_blend_stage || + cfg->attn_blend_stage >= sblk->maxblendstages) { + SDE_ERROR("invalid noise_blend_stage %d attn_blend_stage %d max stage %d\n", + cfg->noise_blend_stage, cfg->attn_blend_stage, sblk->maxblendstages); return -EINVAL; } - stage_off = _stage_offset(ctx, cfg->zposn); + + stage_off = _stage_offset(ctx, cfg->noise_blend_stage); if (stage_off < 0) { - SDE_ERROR("invalid stage_off:%d for noise layer stage_off %d\n", - cfg->zposn, stage_off); + SDE_ERROR("invalid stage_off:%d for noise layer blend stage:%d\n", + stage_off, cfg->noise_blend_stage); return -EINVAL; } val = BIT(18) | BIT(31); @@ -336,13 +338,13 @@ static int sde_hw_lm_setup_noise_layer(struct sde_hw_mixer *ctx, val = ctx->cfg.out_width | (ctx->cfg.out_height << 16); SDE_REG_WRITE(c, LM_FG_COLOR_FILL_SIZE + stage_off, val); val = SDE_REG_READ(c, LM_OP_MODE); - val = (1 << cfg->zposn) | val; + val = (1 << cfg->noise_blend_stage) | val; SDE_REG_WRITE(c, LM_OP_MODE, val); - stage_off = _stage_offset(ctx, cfg->zposattn); + stage_off = _stage_offset(ctx, cfg->attn_blend_stage); if (stage_off < 0) { - SDE_ERROR("invalid stage_off:%d for noise layer\n", - cfg->zposattn); + SDE_ERROR("invalid stage_off:%d for atten layer blend stage:%d\n", + stage_off, cfg->attn_blend_stage); sde_hw_clear_noise_layer(ctx); return -EINVAL; } @@ -353,7 +355,7 @@ static int sde_hw_lm_setup_noise_layer(struct sde_hw_mixer *ctx, SDE_REG_WRITE(c, LM_BLEND0_OP + stage_off, val); SDE_REG_WRITE(c, LM_BLEND0_CONST_ALPHA + stage_off, alpha); val = SDE_REG_READ(c, LM_OP_MODE); - val = (1 << cfg->zposattn) | val; + val = (1 << cfg->attn_blend_stage) | val; SDE_REG_WRITE(c, LM_OP_MODE, val); val = ctx->cfg.out_width | (ctx->cfg.out_height << 16); SDE_REG_WRITE(c, LM_FG_COLOR_FILL_SIZE + stage_off, val); diff --git a/msm/sde/sde_hw_mdss.h b/msm/sde/sde_hw_mdss.h index 1b041c79ce..3dd39343d4 100644 --- a/msm/sde/sde_hw_mdss.h +++ b/msm/sde/sde_hw_mdss.h @@ -771,16 +771,16 @@ struct sde_hw_pp_vsync_info { /** * struct sde_hw_noise_layer_cfg: Payload to enable/disable noise blend * @flags: operation control flags, for future use - * @zposn: zorder required for noise - * @zposattn: zorder required for noise + * @noise_blend_stage: blend stage required for noise layer + * @attn_blend_stage: blend stage required for attn layer * @attn_factor: factor in range of 1 to 255 * @stength: strength in range of 0 to 6 * @alpha_noise: factor in range of 1 to 255 */ struct sde_hw_noise_layer_cfg { u64 flags; - u32 zposn; - u32 zposattn; + u32 noise_blend_stage; + u32 attn_blend_stage; u32 attn_factor; u32 strength; u32 alpha_noise;