Lines Matching +full:config +full:- +full:cond
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2014-2015 The Linux Foundation. All rights reserved.
32 struct msm_drm_private *priv = plane->dev->dev_private; in get_kms()
33 return to_mdp5_kms(to_mdp_kms(priv->kms)); in get_kms()
38 return state->visible; in plane_enabled()
68 if (plane->type == DRM_PLANE_TYPE_PRIMARY) in mdp5_plane_install_properties()
80 struct mdp5_kms *mdp5_kms = get_kms(state->plane); in mdp5_plane_atomic_print_state()
82 drm_printf(p, "\thwpipe=%s\n", pstate->hwpipe ? in mdp5_plane_atomic_print_state()
83 pstate->hwpipe->name : "(null)"); in mdp5_plane_atomic_print_state()
84 if (mdp5_kms->caps & MDP_CAP_SRC_SPLIT) in mdp5_plane_atomic_print_state()
85 drm_printf(p, "\tright-hwpipe=%s\n", in mdp5_plane_atomic_print_state()
86 pstate->r_hwpipe ? pstate->r_hwpipe->name : in mdp5_plane_atomic_print_state()
88 drm_printf(p, "\tblend_mode=%u\n", pstate->base.pixel_blend_mode); in mdp5_plane_atomic_print_state()
89 drm_printf(p, "\tzpos=%u\n", pstate->base.zpos); in mdp5_plane_atomic_print_state()
90 drm_printf(p, "\tnormalized_zpos=%u\n", pstate->base.normalized_zpos); in mdp5_plane_atomic_print_state()
91 drm_printf(p, "\talpha=%u\n", pstate->base.alpha); in mdp5_plane_atomic_print_state()
92 drm_printf(p, "\tstage=%s\n", stage2name(pstate->stage)); in mdp5_plane_atomic_print_state()
99 if (plane->state) in mdp5_plane_reset()
100 __drm_atomic_helper_plane_destroy_state(plane->state); in mdp5_plane_reset()
102 kfree(to_mdp5_plane_state(plane->state)); in mdp5_plane_reset()
103 plane->state = NULL; in mdp5_plane_reset()
107 __drm_atomic_helper_plane_reset(plane, &mdp5_state->base); in mdp5_plane_reset()
115 if (WARN_ON(!plane->state)) in mdp5_plane_duplicate_state()
118 mdp5_state = kmemdup(to_mdp5_plane_state(plane->state), in mdp5_plane_duplicate_state()
123 __drm_atomic_helper_plane_duplicate_state(plane, &mdp5_state->base); in mdp5_plane_duplicate_state()
125 return &mdp5_state->base; in mdp5_plane_duplicate_state()
151 struct msm_drm_private *priv = plane->dev->dev_private; in mdp5_plane_prepare_fb()
152 struct msm_kms *kms = priv->kms; in mdp5_plane_prepare_fb()
153 bool needs_dirtyfb = to_mdp5_plane_state(new_state)->needs_dirtyfb; in mdp5_plane_prepare_fb()
155 if (!new_state->fb) in mdp5_plane_prepare_fb()
160 return msm_framebuffer_prepare(new_state->fb, kms->aspace, needs_dirtyfb); in mdp5_plane_prepare_fb()
167 struct msm_kms *kms = &mdp5_kms->base.base; in mdp5_plane_cleanup_fb()
168 struct drm_framebuffer *fb = old_state->fb; in mdp5_plane_cleanup_fb()
169 bool needed_dirtyfb = to_mdp5_plane_state(old_state)->needs_dirtyfb; in mdp5_plane_cleanup_fb()
174 DBG("%s: cleanup: FB[%u]", plane->name, fb->base.id); in mdp5_plane_cleanup_fb()
175 msm_framebuffer_cleanup(fb, kms->aspace, needed_dirtyfb); in mdp5_plane_cleanup_fb()
182 struct drm_plane *plane = state->plane; in mdp5_plane_atomic_check_with_state()
183 struct drm_plane_state *old_state = plane->state; in mdp5_plane_atomic_check_with_state()
184 struct mdp5_cfg *config = mdp5_cfg_get_config(get_kms(plane)->cfg); in mdp5_plane_atomic_check_with_state() local
193 DBG("%s: check (%d -> %d)", plane->name, in mdp5_plane_atomic_check_with_state()
196 max_width = config->hw->lm.max_width << 16; in mdp5_plane_atomic_check_with_state()
197 max_height = config->hw->lm.max_height << 16; in mdp5_plane_atomic_check_with_state()
200 if (state->src_h > max_height) in mdp5_plane_atomic_check_with_state()
203 if (state->src_w > max_width) { in mdp5_plane_atomic_check_with_state()
209 if (config->hw->mdp.caps & MDP_CAP_SRC_SPLIT && in mdp5_plane_atomic_check_with_state()
210 (state->src_w <= 2 * max_width)) in mdp5_plane_atomic_check_with_state()
220 return -ERANGE; in mdp5_plane_atomic_check_with_state()
238 format = to_mdp_format(msm_framebuffer_format(state->fb)); in mdp5_plane_atomic_check_with_state()
242 if (((state->src_w >> 16) != state->crtc_w) || in mdp5_plane_atomic_check_with_state()
243 ((state->src_h >> 16) != state->crtc_h)) in mdp5_plane_atomic_check_with_state()
246 rotation = drm_rotation_simplify(state->rotation, in mdp5_plane_atomic_check_with_state()
257 if (plane->type == DRM_PLANE_TYPE_CURSOR) in mdp5_plane_atomic_check_with_state()
260 /* (re)allocate hw pipe if we don't have one or caps-mismatch: */ in mdp5_plane_atomic_check_with_state()
261 if (!mdp5_state->hwpipe || (caps & ~mdp5_state->hwpipe->caps)) in mdp5_plane_atomic_check_with_state()
269 if ((need_right_hwpipe && !mdp5_state->r_hwpipe) || in mdp5_plane_atomic_check_with_state()
270 (!need_right_hwpipe && mdp5_state->r_hwpipe)) in mdp5_plane_atomic_check_with_state()
273 if (mdp5_kms->smp) { in mdp5_plane_atomic_check_with_state()
275 to_mdp_format(msm_framebuffer_format(state->fb)); in mdp5_plane_atomic_check_with_state()
277 blkcfg = mdp5_smp_calculate(mdp5_kms->smp, format, in mdp5_plane_atomic_check_with_state()
278 state->src_w >> 16, false); in mdp5_plane_atomic_check_with_state()
280 if (mdp5_state->hwpipe && (mdp5_state->hwpipe->blkcfg != blkcfg)) in mdp5_plane_atomic_check_with_state()
286 /* TODO maybe we want to re-assign hwpipe sometimes in mdp5_plane_atomic_check_with_state()
287 * in cases when we no-longer need some caps to make in mdp5_plane_atomic_check_with_state()
290 struct mdp5_hw_pipe *old_hwpipe = mdp5_state->hwpipe; in mdp5_plane_atomic_check_with_state()
292 mdp5_state->r_hwpipe; in mdp5_plane_atomic_check_with_state()
296 ret = mdp5_pipe_assign(state->state, plane, caps, in mdp5_plane_atomic_check_with_state()
302 plane->name); in mdp5_plane_atomic_check_with_state()
306 mdp5_state->hwpipe = new_hwpipe; in mdp5_plane_atomic_check_with_state()
308 mdp5_state->r_hwpipe = new_right_hwpipe; in mdp5_plane_atomic_check_with_state()
315 mdp5_state->r_hwpipe = NULL; in mdp5_plane_atomic_check_with_state()
318 ret = mdp5_pipe_release(state->state, old_hwpipe); in mdp5_plane_atomic_check_with_state()
322 ret = mdp5_pipe_release(state->state, old_right_hwpipe); in mdp5_plane_atomic_check_with_state()
328 ret = mdp5_pipe_release(state->state, mdp5_state->hwpipe); in mdp5_plane_atomic_check_with_state()
332 ret = mdp5_pipe_release(state->state, mdp5_state->r_hwpipe); in mdp5_plane_atomic_check_with_state()
336 mdp5_state->hwpipe = mdp5_state->r_hwpipe = NULL; in mdp5_plane_atomic_check_with_state()
352 crtc = new_plane_state->crtc ? new_plane_state->crtc : old_plane_state->crtc; in mdp5_plane_atomic_check()
359 return -EINVAL; in mdp5_plane_atomic_check()
370 DBG("%s: update", plane->name); in mdp5_plane_atomic_update()
376 new_state->crtc, new_state->fb, in mdp5_plane_atomic_update()
377 &new_state->src, &new_state->dst); in mdp5_plane_atomic_update()
394 new_plane_state->crtc); in mdp5_plane_atomic_async_check()
396 return -EINVAL; in mdp5_plane_atomic_async_check()
398 if (!crtc_state->active) in mdp5_plane_atomic_async_check()
399 return -EINVAL; in mdp5_plane_atomic_async_check()
402 if (!mdp5_state->hwpipe) in mdp5_plane_atomic_async_check()
403 return -EINVAL; in mdp5_plane_atomic_async_check()
406 if (plane->state->crtc != new_plane_state->crtc || in mdp5_plane_atomic_async_check()
407 plane->state->src_w != new_plane_state->src_w || in mdp5_plane_atomic_async_check()
408 plane->state->src_h != new_plane_state->src_h || in mdp5_plane_atomic_async_check()
409 plane->state->crtc_w != new_plane_state->crtc_w || in mdp5_plane_atomic_async_check()
410 plane->state->crtc_h != new_plane_state->crtc_h || in mdp5_plane_atomic_async_check()
411 !plane->state->fb || in mdp5_plane_atomic_async_check()
412 plane->state->fb != new_plane_state->fb) in mdp5_plane_atomic_async_check()
413 return -EINVAL; in mdp5_plane_atomic_async_check()
431 if (new_plane_state->visible != plane->state->visible) in mdp5_plane_atomic_async_check()
432 return -EINVAL; in mdp5_plane_atomic_async_check()
442 struct drm_framebuffer *old_fb = plane->state->fb; in mdp5_plane_atomic_async_update()
444 plane->state->src_x = new_state->src_x; in mdp5_plane_atomic_async_update()
445 plane->state->src_y = new_state->src_y; in mdp5_plane_atomic_async_update()
446 plane->state->crtc_x = new_state->crtc_x; in mdp5_plane_atomic_async_update()
447 plane->state->crtc_y = new_state->crtc_y; in mdp5_plane_atomic_async_update()
452 mdp5_crtc_get_pipeline(new_state->crtc); in mdp5_plane_atomic_async_update()
455 ret = mdp5_plane_mode_set(plane, new_state->crtc, new_state->fb, in mdp5_plane_atomic_async_update()
456 &new_state->src, &new_state->dst); in mdp5_plane_atomic_async_update()
459 ctl = mdp5_crtc_get_ctl(new_state->crtc); in mdp5_plane_atomic_async_update()
464 *to_mdp5_plane_state(plane->state) = in mdp5_plane_atomic_async_update()
467 new_state->fb = old_fb; in mdp5_plane_atomic_async_update()
483 struct msm_kms *kms = &mdp5_kms->base.base; in set_scanout_locked()
486 MDP5_PIPE_SRC_STRIDE_A_P0(fb->pitches[0]) | in set_scanout_locked()
487 MDP5_PIPE_SRC_STRIDE_A_P1(fb->pitches[1])); in set_scanout_locked()
490 MDP5_PIPE_SRC_STRIDE_B_P2(fb->pitches[2]) | in set_scanout_locked()
491 MDP5_PIPE_SRC_STRIDE_B_P3(fb->pitches[3])); in set_scanout_locked()
494 msm_framebuffer_iova(fb, kms->aspace, 0)); in set_scanout_locked()
496 msm_framebuffer_iova(fb, kms->aspace, 1)); in set_scanout_locked()
498 msm_framebuffer_iova(fb, kms->aspace, 2)); in set_scanout_locked()
500 msm_framebuffer_iova(fb, kms->aspace, 3)); in set_scanout_locked()
503 /* Note: mdp5_plane->pipe_lock must be locked */
512 /* Note: mdp5_plane->pipe_lock must be locked */
522 if ((csc->type == CSC_YUV2RGB) || (CSC_YUV2YUV == csc->type)) in csc_enable()
524 if ((csc->type == CSC_RGB2YUV) || (CSC_YUV2YUV == csc->type)) in csc_enable()
529 matrix = csc->matrix; in csc_enable()
545 for (i = 0; i < ARRAY_SIZE(csc->pre_bias); i++) { in csc_enable()
546 uint32_t *pre_clamp = csc->pre_clamp; in csc_enable()
547 uint32_t *post_clamp = csc->post_clamp; in csc_enable()
558 MDP5_PIPE_CSC_1_PRE_BIAS_REG_VALUE(csc->pre_bias[i])); in csc_enable()
561 MDP5_PIPE_CSC_1_POST_BIAS_REG_VALUE(csc->post_bias[i])); in csc_enable()
566 #define DOWN_SCALE_RATIO_MAX 32 /* 2^(26-21) */
573 return -EINVAL; in calc_phase_step()
577 * where 2^21 represents the unity "1" in fixed-point hardware design. in calc_phase_step()
579 * -> maximum downscale ratio = 0b1_1111 = 31 in calc_phase_step()
582 return -EOVERFLOW; in calc_phase_step()
596 struct device *dev = mdp5_kms->dev->dev; in calc_scalex_steps()
602 DRM_DEV_ERROR(dev, "X scaling (%d->%d) failed: %d\n", src, dest, ret); in calc_scalex_steps()
608 phasex_steps[COMP_1_2] = phasex_step / info->hsub; in calc_scalex_steps()
619 struct device *dev = mdp5_kms->dev->dev; in calc_scaley_steps()
625 DRM_DEV_ERROR(dev, "Y scaling (%d->%d) failed: %d\n", src, dest, ret); in calc_scaley_steps()
631 phasey_steps[COMP_1_2] = phasey_step / info->vsub; in calc_scaley_steps()
639 const struct drm_format_info *info = drm_format_info(format->base.pixel_format); in get_scale_config()
640 bool scaling = format->is_yuv ? true : (src != dst); in get_scale_config()
643 bool yuv = format->is_yuv; in get_scale_config()
649 sub = horz ? info->hsub : info->vsub; in get_scale_config()
659 COND(yuv, MDP5_PIPE_SCALE_CONFIG_SCALEX_FILTER_COMP_1_2(uv_filter)); in get_scale_config()
664 COND(yuv, MDP5_PIPE_SCALE_CONFIG_SCALEY_FILTER_COMP_1_2(uv_filter)); in get_scale_config()
672 bool scaling = format->is_yuv ? true : (src != dst); in calc_pixel_ext()
694 const struct drm_format_info *info = drm_format_info(format->base.pixel_format); in mdp5_write_pixel_ext()
702 if (format->is_yuv && i == COMP_1_2) { in mdp5_write_pixel_ext()
703 roi_w /= info->hsub; in mdp5_write_pixel_ext()
704 roi_h /= info->vsub; in mdp5_write_pixel_ext()
733 DBG("comp-%d (L/R): rpt=%d/%d, ovf=%d/%d, req=%d", i, in mdp5_write_pixel_ext()
740 DBG("comp-%d (T/B): rpt=%d/%d, ovf=%d/%d, req=%d", i, in mdp5_write_pixel_ext()
774 enum mdp5_pipe pipe = hwpipe->pipe; in mdp5_hwpipe_mode_set()
775 bool has_pe = hwpipe->caps & MDP_PIPE_CAP_SW_PIX_EXT; in mdp5_hwpipe_mode_set()
800 MDP5_PIPE_SRC_FORMAT_A_BPC(format->bpc_a) | in mdp5_hwpipe_mode_set()
801 MDP5_PIPE_SRC_FORMAT_R_BPC(format->bpc_r) | in mdp5_hwpipe_mode_set()
802 MDP5_PIPE_SRC_FORMAT_G_BPC(format->bpc_g) | in mdp5_hwpipe_mode_set()
803 MDP5_PIPE_SRC_FORMAT_B_BPC(format->bpc_b) | in mdp5_hwpipe_mode_set()
804 COND(format->alpha_enable, MDP5_PIPE_SRC_FORMAT_ALPHA_ENABLE) | in mdp5_hwpipe_mode_set()
805 MDP5_PIPE_SRC_FORMAT_CPP(format->cpp - 1) | in mdp5_hwpipe_mode_set()
806 MDP5_PIPE_SRC_FORMAT_UNPACK_COUNT(format->unpack_count - 1) | in mdp5_hwpipe_mode_set()
807 COND(format->unpack_tight, MDP5_PIPE_SRC_FORMAT_UNPACK_TIGHT) | in mdp5_hwpipe_mode_set()
808 MDP5_PIPE_SRC_FORMAT_FETCH_TYPE(format->fetch_type) | in mdp5_hwpipe_mode_set()
809 MDP5_PIPE_SRC_FORMAT_CHROMA_SAMP(format->chroma_sample)); in mdp5_hwpipe_mode_set()
812 MDP5_PIPE_SRC_UNPACK_ELEM0(format->unpack[0]) | in mdp5_hwpipe_mode_set()
813 MDP5_PIPE_SRC_UNPACK_ELEM1(format->unpack[1]) | in mdp5_hwpipe_mode_set()
814 MDP5_PIPE_SRC_UNPACK_ELEM2(format->unpack[2]) | in mdp5_hwpipe_mode_set()
815 MDP5_PIPE_SRC_UNPACK_ELEM3(format->unpack[3])); in mdp5_hwpipe_mode_set()
820 COND(has_pe, MDP5_PIPE_SRC_OP_MODE_SW_PIX_EXT_OVERRIDE) | in mdp5_hwpipe_mode_set()
826 if (hwpipe->caps & MDP_PIPE_CAP_SW_PIX_EXT) in mdp5_hwpipe_mode_set()
828 src_w, pe->left, pe->right, in mdp5_hwpipe_mode_set()
829 src_h, pe->top, pe->bottom); in mdp5_hwpipe_mode_set()
831 if (hwpipe->caps & MDP_PIPE_CAP_SCALE) { in mdp5_hwpipe_mode_set()
833 step->x[COMP_0]); in mdp5_hwpipe_mode_set()
835 step->y[COMP_0]); in mdp5_hwpipe_mode_set()
837 step->x[COMP_1_2]); in mdp5_hwpipe_mode_set()
839 step->y[COMP_1_2]); in mdp5_hwpipe_mode_set()
847 if (hwpipe->caps & MDP_PIPE_CAP_CSC) { in mdp5_hwpipe_mode_set()
862 struct drm_plane_state *pstate = plane->state; in mdp5_plane_mode_set()
863 struct mdp5_hw_pipe *hwpipe = to_mdp5_plane_state(pstate)->hwpipe; in mdp5_plane_mode_set()
865 enum mdp5_pipe pipe = hwpipe->pipe; in mdp5_plane_mode_set()
868 uint32_t nplanes, config = 0; in mdp5_plane_mode_set() local
882 nplanes = fb->format->num_planes; in mdp5_plane_mode_set()
886 return -EINVAL; in mdp5_plane_mode_set()
889 pix_format = format->base.pixel_format; in mdp5_plane_mode_set()
891 src_x = src->x1; in mdp5_plane_mode_set()
892 src_y = src->y1; in mdp5_plane_mode_set()
896 crtc_x = dest->x1; in mdp5_plane_mode_set()
897 crtc_y = dest->y1; in mdp5_plane_mode_set()
907 src_img_w = min(fb->width, src_w); in mdp5_plane_mode_set()
908 src_img_h = min(fb->height, src_h); in mdp5_plane_mode_set()
910 DBG("%s: FB[%u] %u,%u,%u,%u -> CRTC[%u] %d,%d,%u,%u", plane->name, in mdp5_plane_mode_set()
911 fb->base.id, src_x, src_y, src_w, src_h, in mdp5_plane_mode_set()
912 crtc->base.id, crtc_x, crtc_y, crtc_w, crtc_h); in mdp5_plane_mode_set()
914 right_hwpipe = to_mdp5_plane_state(pstate)->r_hwpipe; in mdp5_plane_mode_set()
934 if (hwpipe->caps & MDP_PIPE_CAP_SW_PIX_EXT) { in mdp5_plane_mode_set()
943 /* SCALE is used to both scale and up-sample chroma components */ in mdp5_plane_mode_set()
944 config |= get_scale_config(format, src_w, crtc_w, true); in mdp5_plane_mode_set()
945 config |= get_scale_config(format, src_h, crtc_h, false); in mdp5_plane_mode_set()
946 DBG("scale config = %x", config); in mdp5_plane_mode_set()
948 rotation = drm_rotation_simplify(pstate->rotation, in mdp5_plane_mode_set()
956 config, hdecm, vdecm, hflip, vflip, in mdp5_plane_mode_set()
962 config, hdecm, vdecm, hflip, vflip, in mdp5_plane_mode_set()
976 struct mdp5_plane_state *pstate = to_mdp5_plane_state(plane->state); in mdp5_plane_pipe()
978 if (WARN_ON(!pstate->hwpipe)) in mdp5_plane_pipe()
981 return pstate->hwpipe->pipe; in mdp5_plane_pipe()
986 struct mdp5_plane_state *pstate = to_mdp5_plane_state(plane->state); in mdp5_plane_right_pipe()
988 if (!pstate->r_hwpipe) in mdp5_plane_right_pipe()
991 return pstate->r_hwpipe->pipe; in mdp5_plane_right_pipe()
996 struct mdp5_plane_state *pstate = to_mdp5_plane_state(plane->state); in mdp5_plane_get_flush()
999 if (WARN_ON(!pstate->hwpipe)) in mdp5_plane_get_flush()
1002 mask = pstate->hwpipe->flush_mask; in mdp5_plane_get_flush()
1004 if (pstate->r_hwpipe) in mdp5_plane_get_flush()
1005 mask |= pstate->r_hwpipe->flush_mask; in mdp5_plane_get_flush()
1020 ret = -ENOMEM; in mdp5_plane_init()
1024 plane = &mdp5_plane->base; in mdp5_plane_init()
1026 mdp5_plane->nformats = mdp_get_formats(mdp5_plane->formats, in mdp5_plane_init()
1027 ARRAY_SIZE(mdp5_plane->formats), false); in mdp5_plane_init()
1030 mdp5_plane->formats, mdp5_plane->nformats, in mdp5_plane_init()
1037 mdp5_plane_install_properties(plane, &plane->base); in mdp5_plane_init()