Lines Matching +full:pre +full:- +full:scaling
1 // SPDX-License-Identifier: GPL-2.0-only
28 struct malidp_hw_device *hwdev = malidp->dev; in malidp_crtc_mode_valid()
34 long rate, req_rate = mode->crtc_clock * 1000; in malidp_crtc_mode_valid()
37 rate = clk_round_rate(hwdev->pxlclk, req_rate); in malidp_crtc_mode_valid()
52 struct malidp_hw_device *hwdev = malidp->dev; in malidp_crtc_atomic_enable()
54 int err = pm_runtime_get_sync(crtc->dev->dev); in malidp_crtc_atomic_enable()
61 drm_display_mode_to_videomode(&crtc->state->adjusted_mode, &vm); in malidp_crtc_atomic_enable()
62 clk_prepare_enable(hwdev->pxlclk); in malidp_crtc_atomic_enable()
65 clk_set_rate(hwdev->pxlclk, crtc->state->adjusted_mode.crtc_clock * 1000); in malidp_crtc_atomic_enable()
67 hwdev->hw->modeset(hwdev, &vm); in malidp_crtc_atomic_enable()
68 hwdev->hw->leave_config_mode(hwdev); in malidp_crtc_atomic_enable()
76 struct malidp_hw_device *hwdev = malidp->dev; in malidp_crtc_atomic_disable()
83 hwdev->hw->enter_config_mode(hwdev); in malidp_crtc_atomic_disable()
85 clk_disable_unprepare(hwdev->pxlclk); in malidp_crtc_atomic_disable()
87 err = pm_runtime_put(crtc->dev->dev); in malidp_crtc_atomic_disable()
127 struct drm_color_lut *lut = (struct drm_color_lut *)lut_blob->data; in malidp_generate_gamma_table()
133 delta_in = segments[i].end - segments[i].start; in malidp_generate_gamma_table()
134 /* DP has 12-bit internal precision for its LUTs. */ in malidp_generate_gamma_table()
138 a = (delta_in == 0) ? 0 : ((out_end - out_start) * 256) / delta_in; in malidp_generate_gamma_table()
156 if (!state->color_mgmt_changed || !state->gamma_lut) in malidp_crtc_atomic_check_gamma()
159 if (crtc->state->gamma_lut && in malidp_crtc_atomic_check_gamma()
160 (crtc->state->gamma_lut->base.id == state->gamma_lut->base.id)) in malidp_crtc_atomic_check_gamma()
163 if (state->gamma_lut->length % sizeof(struct drm_color_lut)) in malidp_crtc_atomic_check_gamma()
164 return -EINVAL; in malidp_crtc_atomic_check_gamma()
166 lut_size = state->gamma_lut->length / sizeof(struct drm_color_lut); in malidp_crtc_atomic_check_gamma()
168 return -EINVAL; in malidp_crtc_atomic_check_gamma()
170 lut = (struct drm_color_lut *)state->gamma_lut->data; in malidp_crtc_atomic_check_gamma()
174 return -EINVAL; in malidp_crtc_atomic_check_gamma()
176 if (!state->mode_changed) { in malidp_crtc_atomic_check_gamma()
179 state->mode_changed = true; in malidp_crtc_atomic_check_gamma()
182 * it be invoked when the driver sets ->mode_changed. Since in malidp_crtc_atomic_check_gamma()
186 ret = drm_atomic_helper_check_modeset(crtc->dev, state->state); in malidp_crtc_atomic_check_gamma()
191 malidp_generate_gamma_table(state->gamma_lut, mc->gamma_coeffs); in malidp_crtc_atomic_check_gamma()
209 if (!state->color_mgmt_changed) in malidp_crtc_atomic_check_ctm()
212 if (!state->ctm) in malidp_crtc_atomic_check_ctm()
215 if (crtc->state->ctm && (crtc->state->ctm->base.id == in malidp_crtc_atomic_check_ctm()
216 state->ctm->base.id)) in malidp_crtc_atomic_check_ctm()
223 ctm = (struct drm_color_ctm *)state->ctm->data; in malidp_crtc_atomic_check_ctm()
224 for (i = 0; i < ARRAY_SIZE(ctm->matrix); ++i) { in malidp_crtc_atomic_check_ctm()
226 s64 val = ctm->matrix[i]; in malidp_crtc_atomic_check_ctm()
240 return -EINVAL; in malidp_crtc_atomic_check_ctm()
241 mc->coloradj_coeffs[i] = mag; in malidp_crtc_atomic_check_ctm()
251 struct malidp_hw_device *hwdev = malidp->dev; in malidp_crtc_atomic_check_scaling()
253 struct malidp_se_config *s = &cs->scaler_config; in malidp_crtc_atomic_check_scaling()
259 u8 scaling = cs->scaled_planes_mask; in malidp_crtc_atomic_check_scaling() local
262 if (!scaling) { in malidp_crtc_atomic_check_scaling()
263 s->scale_enable = false; in malidp_crtc_atomic_check_scaling()
267 /* The scaling engine can only handle one plane at a time. */ in malidp_crtc_atomic_check_scaling()
268 if (scaling & (scaling - 1)) in malidp_crtc_atomic_check_scaling()
269 return -EINVAL; in malidp_crtc_atomic_check_scaling()
275 if (!(mp->layer->id & scaling)) in malidp_crtc_atomic_check_scaling()
282 h_upscale_factor = div_u64((u64)pstate->crtc_w << 32, in malidp_crtc_atomic_check_scaling()
283 pstate->src_w); in malidp_crtc_atomic_check_scaling()
284 v_upscale_factor = div_u64((u64)pstate->crtc_h << 32, in malidp_crtc_atomic_check_scaling()
285 pstate->src_h); in malidp_crtc_atomic_check_scaling()
287 s->enhancer_enable = ((h_upscale_factor >> 16) >= 2 || in malidp_crtc_atomic_check_scaling()
290 if (pstate->rotation & MALIDP_ROTATED_MASK) { in malidp_crtc_atomic_check_scaling()
291 s->input_w = pstate->src_h >> 16; in malidp_crtc_atomic_check_scaling()
292 s->input_h = pstate->src_w >> 16; in malidp_crtc_atomic_check_scaling()
294 s->input_w = pstate->src_w >> 16; in malidp_crtc_atomic_check_scaling()
295 s->input_h = pstate->src_h >> 16; in malidp_crtc_atomic_check_scaling()
298 s->output_w = pstate->crtc_w; in malidp_crtc_atomic_check_scaling()
299 s->output_h = pstate->crtc_h; in malidp_crtc_atomic_check_scaling()
304 phase = s->input_w; in malidp_crtc_atomic_check_scaling()
305 s->h_init_phase = in malidp_crtc_atomic_check_scaling()
306 ((phase << SE_N_PHASE) / s->output_w + 1) / 2; in malidp_crtc_atomic_check_scaling()
308 phase = s->input_w; in malidp_crtc_atomic_check_scaling()
310 s->h_delta_phase = phase / s->output_w; in malidp_crtc_atomic_check_scaling()
313 phase = s->input_h; in malidp_crtc_atomic_check_scaling()
314 s->v_init_phase = in malidp_crtc_atomic_check_scaling()
315 ((phase << SE_N_PHASE) / s->output_h + 1) / 2; in malidp_crtc_atomic_check_scaling()
317 phase = s->input_h; in malidp_crtc_atomic_check_scaling()
319 s->v_delta_phase = phase / s->output_h; in malidp_crtc_atomic_check_scaling()
322 s->plane_src_id = mp->layer->id; in malidp_crtc_atomic_check_scaling()
325 s->scale_enable = true; in malidp_crtc_atomic_check_scaling()
326 s->hcoeff = malidp_se_select_coeffs(h_upscale_factor); in malidp_crtc_atomic_check_scaling()
327 s->vcoeff = malidp_se_select_coeffs(v_upscale_factor); in malidp_crtc_atomic_check_scaling()
330 drm_display_mode_to_videomode(&state->adjusted_mode, &vm); in malidp_crtc_atomic_check_scaling()
331 ret = hwdev->hw->se_calc_mclk(hwdev, s, &vm); in malidp_crtc_atomic_check_scaling()
333 return -EINVAL; in malidp_crtc_atomic_check_scaling()
341 struct malidp_hw_device *hwdev = malidp->dev; in malidp_crtc_atomic_check()
351 * Each plane has set its required memory size in the ->plane_check() in malidp_crtc_atomic_check()
370 * changes, we need to pre-sort the planes before validation. in malidp_crtc_atomic_check()
375 struct drm_framebuffer *fb = pstate->fb; in malidp_crtc_atomic_check()
377 if ((pstate->rotation & MALIDP_ROTATED_MASK) || fb->modifier) in malidp_crtc_atomic_check()
381 rot_mem_free = hwdev->rotation_memory[0]; in malidp_crtc_atomic_check()
387 rot_mem_free += hwdev->rotation_memory[1]; in malidp_crtc_atomic_check()
393 struct drm_framebuffer *fb = pstate->fb; in malidp_crtc_atomic_check()
395 if ((pstate->rotation & MALIDP_ROTATED_MASK) || fb->modifier) { in malidp_crtc_atomic_check()
397 rotated_planes--; in malidp_crtc_atomic_check()
403 if ((mp->layer->id != DE_VIDEO1) || in malidp_crtc_atomic_check()
404 (hwdev->rotation_memory[1] == 0)) in malidp_crtc_atomic_check()
407 rot_mem_usable = hwdev->rotation_memory[0]; in malidp_crtc_atomic_check()
410 rot_mem_free -= rot_mem_usable; in malidp_crtc_atomic_check()
412 if (ms->rotmem_size > rot_mem_usable) in malidp_crtc_atomic_check()
413 return -EINVAL; in malidp_crtc_atomic_check()
418 if (state->connectors_changed) { in malidp_crtc_atomic_check()
419 u32 old_mask = crtc->state->connector_mask; in malidp_crtc_atomic_check()
420 u32 new_mask = state->connector_mask; in malidp_crtc_atomic_check()
423 (1 << drm_connector_index(&malidp->mw_connector.base))) in malidp_crtc_atomic_check()
424 state->connectors_changed = false; in malidp_crtc_atomic_check()
445 if (WARN_ON(!crtc->state)) in malidp_crtc_duplicate_state()
448 old_state = to_malidp_crtc_state(crtc->state); in malidp_crtc_duplicate_state()
453 __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base); in malidp_crtc_duplicate_state()
454 memcpy(state->gamma_coeffs, old_state->gamma_coeffs, in malidp_crtc_duplicate_state()
455 sizeof(state->gamma_coeffs)); in malidp_crtc_duplicate_state()
456 memcpy(state->coloradj_coeffs, old_state->coloradj_coeffs, in malidp_crtc_duplicate_state()
457 sizeof(state->coloradj_coeffs)); in malidp_crtc_duplicate_state()
458 memcpy(&state->scaler_config, &old_state->scaler_config, in malidp_crtc_duplicate_state()
459 sizeof(state->scaler_config)); in malidp_crtc_duplicate_state()
460 state->scaled_planes_mask = 0; in malidp_crtc_duplicate_state()
462 return &state->base; in malidp_crtc_duplicate_state()
483 if (crtc->state) in malidp_crtc_reset()
484 malidp_crtc_destroy_state(crtc, crtc->state); in malidp_crtc_reset()
486 __drm_atomic_helper_crtc_reset(crtc, &state->base); in malidp_crtc_reset()
492 struct malidp_hw_device *hwdev = malidp->dev; in malidp_crtc_enable_vblank()
495 hwdev->hw->map.de_irq_map.vsync_irq); in malidp_crtc_enable_vblank()
502 struct malidp_hw_device *hwdev = malidp->dev; in malidp_crtc_disable_vblank()
505 hwdev->hw->map.de_irq_map.vsync_irq); in malidp_crtc_disable_vblank()
522 struct malidp_drm *malidp = drm->dev_private; in malidp_crtc_init()
533 if (plane->type == DRM_PLANE_TYPE_PRIMARY) { in malidp_crtc_init()
541 return -EINVAL; in malidp_crtc_init()
544 ret = drm_crtc_init_with_planes(drm, &malidp->crtc, primary, NULL, in malidp_crtc_init()
549 drm_crtc_helper_add(&malidp->crtc, &malidp_crtc_helper_funcs); in malidp_crtc_init()
550 drm_mode_crtc_set_gamma_size(&malidp->crtc, MALIDP_GAMMA_LUT_SIZE); in malidp_crtc_init()
551 /* No inverse-gamma: it is per-plane. */ in malidp_crtc_init()
552 drm_crtc_enable_color_mgmt(&malidp->crtc, 0, true, MALIDP_GAMMA_LUT_SIZE); in malidp_crtc_init()
554 malidp_se_set_enh_coeffs(malidp->dev); in malidp_crtc_init()