Lines Matching +full:mali +full:- +full:dp650
1 // SPDX-License-Identifier: GPL-2.0-only
6 * ARM Mali DP500/DP550/DP650 driver (crtc operations)
29 struct malidp_hw_device *hwdev = malidp->dev; in malidp_crtc_mode_valid()
35 long rate, req_rate = mode->crtc_clock * 1000; in malidp_crtc_mode_valid()
38 rate = clk_round_rate(hwdev->pxlclk, req_rate); in malidp_crtc_mode_valid()
53 struct malidp_hw_device *hwdev = malidp->dev; in malidp_crtc_atomic_enable()
55 int err = pm_runtime_get_sync(crtc->dev->dev); in malidp_crtc_atomic_enable()
62 drm_display_mode_to_videomode(&crtc->state->adjusted_mode, &vm); in malidp_crtc_atomic_enable()
63 clk_prepare_enable(hwdev->pxlclk); in malidp_crtc_atomic_enable()
66 clk_set_rate(hwdev->pxlclk, crtc->state->adjusted_mode.crtc_clock * 1000); in malidp_crtc_atomic_enable()
68 hwdev->hw->modeset(hwdev, &vm); in malidp_crtc_atomic_enable()
69 hwdev->hw->leave_config_mode(hwdev); in malidp_crtc_atomic_enable()
79 struct malidp_hw_device *hwdev = malidp->dev; in malidp_crtc_atomic_disable()
86 hwdev->hw->enter_config_mode(hwdev); in malidp_crtc_atomic_disable()
88 clk_disable_unprepare(hwdev->pxlclk); in malidp_crtc_atomic_disable()
90 err = pm_runtime_put(crtc->dev->dev); in malidp_crtc_atomic_disable()
130 struct drm_color_lut *lut = (struct drm_color_lut *)lut_blob->data; in malidp_generate_gamma_table()
136 delta_in = segments[i].end - segments[i].start; in malidp_generate_gamma_table()
137 /* DP has 12-bit internal precision for its LUTs. */ in malidp_generate_gamma_table()
141 a = (delta_in == 0) ? 0 : ((out_end - out_start) * 256) / delta_in; in malidp_generate_gamma_table()
159 if (!state->color_mgmt_changed || !state->gamma_lut) in malidp_crtc_atomic_check_gamma()
162 if (crtc->state->gamma_lut && in malidp_crtc_atomic_check_gamma()
163 (crtc->state->gamma_lut->base.id == state->gamma_lut->base.id)) in malidp_crtc_atomic_check_gamma()
166 if (state->gamma_lut->length % sizeof(struct drm_color_lut)) in malidp_crtc_atomic_check_gamma()
167 return -EINVAL; in malidp_crtc_atomic_check_gamma()
169 lut_size = state->gamma_lut->length / sizeof(struct drm_color_lut); in malidp_crtc_atomic_check_gamma()
171 return -EINVAL; in malidp_crtc_atomic_check_gamma()
173 lut = (struct drm_color_lut *)state->gamma_lut->data; in malidp_crtc_atomic_check_gamma()
177 return -EINVAL; in malidp_crtc_atomic_check_gamma()
179 if (!state->mode_changed) { in malidp_crtc_atomic_check_gamma()
182 state->mode_changed = true; in malidp_crtc_atomic_check_gamma()
185 * it be invoked when the driver sets ->mode_changed. Since in malidp_crtc_atomic_check_gamma()
189 ret = drm_atomic_helper_check_modeset(crtc->dev, state->state); in malidp_crtc_atomic_check_gamma()
194 malidp_generate_gamma_table(state->gamma_lut, mc->gamma_coeffs); in malidp_crtc_atomic_check_gamma()
212 if (!state->color_mgmt_changed) in malidp_crtc_atomic_check_ctm()
215 if (!state->ctm) in malidp_crtc_atomic_check_ctm()
218 if (crtc->state->ctm && (crtc->state->ctm->base.id == in malidp_crtc_atomic_check_ctm()
219 state->ctm->base.id)) in malidp_crtc_atomic_check_ctm()
226 ctm = (struct drm_color_ctm *)state->ctm->data; in malidp_crtc_atomic_check_ctm()
227 for (i = 0; i < ARRAY_SIZE(ctm->matrix); ++i) { in malidp_crtc_atomic_check_ctm()
229 s64 val = ctm->matrix[i]; in malidp_crtc_atomic_check_ctm()
243 return -EINVAL; in malidp_crtc_atomic_check_ctm()
244 mc->coloradj_coeffs[i] = mag; in malidp_crtc_atomic_check_ctm()
254 struct malidp_hw_device *hwdev = malidp->dev; in malidp_crtc_atomic_check_scaling()
256 struct malidp_se_config *s = &cs->scaler_config; in malidp_crtc_atomic_check_scaling()
262 u8 scaling = cs->scaled_planes_mask; in malidp_crtc_atomic_check_scaling()
266 s->scale_enable = false; in malidp_crtc_atomic_check_scaling()
271 if (scaling & (scaling - 1)) in malidp_crtc_atomic_check_scaling()
272 return -EINVAL; in malidp_crtc_atomic_check_scaling()
278 if (!(mp->layer->id & scaling)) in malidp_crtc_atomic_check_scaling()
285 h_upscale_factor = div_u64((u64)pstate->crtc_w << 32, in malidp_crtc_atomic_check_scaling()
286 pstate->src_w); in malidp_crtc_atomic_check_scaling()
287 v_upscale_factor = div_u64((u64)pstate->crtc_h << 32, in malidp_crtc_atomic_check_scaling()
288 pstate->src_h); in malidp_crtc_atomic_check_scaling()
290 s->enhancer_enable = ((h_upscale_factor >> 16) >= 2 || in malidp_crtc_atomic_check_scaling()
293 if (pstate->rotation & MALIDP_ROTATED_MASK) { in malidp_crtc_atomic_check_scaling()
294 s->input_w = pstate->src_h >> 16; in malidp_crtc_atomic_check_scaling()
295 s->input_h = pstate->src_w >> 16; in malidp_crtc_atomic_check_scaling()
297 s->input_w = pstate->src_w >> 16; in malidp_crtc_atomic_check_scaling()
298 s->input_h = pstate->src_h >> 16; in malidp_crtc_atomic_check_scaling()
301 s->output_w = pstate->crtc_w; in malidp_crtc_atomic_check_scaling()
302 s->output_h = pstate->crtc_h; in malidp_crtc_atomic_check_scaling()
307 phase = s->input_w; in malidp_crtc_atomic_check_scaling()
308 s->h_init_phase = in malidp_crtc_atomic_check_scaling()
309 ((phase << SE_N_PHASE) / s->output_w + 1) / 2; in malidp_crtc_atomic_check_scaling()
311 phase = s->input_w; in malidp_crtc_atomic_check_scaling()
313 s->h_delta_phase = phase / s->output_w; in malidp_crtc_atomic_check_scaling()
316 phase = s->input_h; in malidp_crtc_atomic_check_scaling()
317 s->v_init_phase = in malidp_crtc_atomic_check_scaling()
318 ((phase << SE_N_PHASE) / s->output_h + 1) / 2; in malidp_crtc_atomic_check_scaling()
320 phase = s->input_h; in malidp_crtc_atomic_check_scaling()
322 s->v_delta_phase = phase / s->output_h; in malidp_crtc_atomic_check_scaling()
325 s->plane_src_id = mp->layer->id; in malidp_crtc_atomic_check_scaling()
328 s->scale_enable = true; in malidp_crtc_atomic_check_scaling()
329 s->hcoeff = malidp_se_select_coeffs(h_upscale_factor); in malidp_crtc_atomic_check_scaling()
330 s->vcoeff = malidp_se_select_coeffs(v_upscale_factor); in malidp_crtc_atomic_check_scaling()
333 drm_display_mode_to_videomode(&state->adjusted_mode, &vm); in malidp_crtc_atomic_check_scaling()
334 ret = hwdev->hw->se_calc_mclk(hwdev, s, &vm); in malidp_crtc_atomic_check_scaling()
336 return -EINVAL; in malidp_crtc_atomic_check_scaling()
346 struct malidp_hw_device *hwdev = malidp->dev; in malidp_crtc_atomic_check()
356 * Each plane has set its required memory size in the ->plane_check() in malidp_crtc_atomic_check()
375 * changes, we need to pre-sort the planes before validation. in malidp_crtc_atomic_check()
380 struct drm_framebuffer *fb = pstate->fb; in malidp_crtc_atomic_check()
382 if ((pstate->rotation & MALIDP_ROTATED_MASK) || fb->modifier) in malidp_crtc_atomic_check()
386 rot_mem_free = hwdev->rotation_memory[0]; in malidp_crtc_atomic_check()
392 rot_mem_free += hwdev->rotation_memory[1]; in malidp_crtc_atomic_check()
398 struct drm_framebuffer *fb = pstate->fb; in malidp_crtc_atomic_check()
400 if ((pstate->rotation & MALIDP_ROTATED_MASK) || fb->modifier) { in malidp_crtc_atomic_check()
402 rotated_planes--; in malidp_crtc_atomic_check()
408 if ((mp->layer->id != DE_VIDEO1) || in malidp_crtc_atomic_check()
409 (hwdev->rotation_memory[1] == 0)) in malidp_crtc_atomic_check()
412 rot_mem_usable = hwdev->rotation_memory[0]; in malidp_crtc_atomic_check()
415 rot_mem_free -= rot_mem_usable; in malidp_crtc_atomic_check()
417 if (ms->rotmem_size > rot_mem_usable) in malidp_crtc_atomic_check()
418 return -EINVAL; in malidp_crtc_atomic_check()
423 if (crtc_state->connectors_changed) { in malidp_crtc_atomic_check()
424 u32 old_mask = crtc->state->connector_mask; in malidp_crtc_atomic_check()
425 u32 new_mask = crtc_state->connector_mask; in malidp_crtc_atomic_check()
428 (1 << drm_connector_index(&malidp->mw_connector.base))) in malidp_crtc_atomic_check()
429 crtc_state->connectors_changed = false; in malidp_crtc_atomic_check()
450 if (WARN_ON(!crtc->state)) in malidp_crtc_duplicate_state()
453 old_state = to_malidp_crtc_state(crtc->state); in malidp_crtc_duplicate_state()
458 __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base); in malidp_crtc_duplicate_state()
459 memcpy(state->gamma_coeffs, old_state->gamma_coeffs, in malidp_crtc_duplicate_state()
460 sizeof(state->gamma_coeffs)); in malidp_crtc_duplicate_state()
461 memcpy(state->coloradj_coeffs, old_state->coloradj_coeffs, in malidp_crtc_duplicate_state()
462 sizeof(state->coloradj_coeffs)); in malidp_crtc_duplicate_state()
463 memcpy(&state->scaler_config, &old_state->scaler_config, in malidp_crtc_duplicate_state()
464 sizeof(state->scaler_config)); in malidp_crtc_duplicate_state()
465 state->scaled_planes_mask = 0; in malidp_crtc_duplicate_state()
467 return &state->base; in malidp_crtc_duplicate_state()
488 if (crtc->state) in malidp_crtc_reset()
489 malidp_crtc_destroy_state(crtc, crtc->state); in malidp_crtc_reset()
492 __drm_atomic_helper_crtc_reset(crtc, &state->base); in malidp_crtc_reset()
500 struct malidp_hw_device *hwdev = malidp->dev; in malidp_crtc_enable_vblank()
503 hwdev->hw->map.de_irq_map.vsync_irq); in malidp_crtc_enable_vblank()
510 struct malidp_hw_device *hwdev = malidp->dev; in malidp_crtc_disable_vblank()
513 hwdev->hw->map.de_irq_map.vsync_irq); in malidp_crtc_disable_vblank()
539 if (plane->type == DRM_PLANE_TYPE_PRIMARY) { in malidp_crtc_init()
547 return -EINVAL; in malidp_crtc_init()
550 ret = drmm_crtc_init_with_planes(drm, &malidp->crtc, primary, NULL, in malidp_crtc_init()
555 drm_crtc_helper_add(&malidp->crtc, &malidp_crtc_helper_funcs); in malidp_crtc_init()
556 drm_mode_crtc_set_gamma_size(&malidp->crtc, MALIDP_GAMMA_LUT_SIZE); in malidp_crtc_init()
557 /* No inverse-gamma: it is per-plane. */ in malidp_crtc_init()
558 drm_crtc_enable_color_mgmt(&malidp->crtc, 0, true, MALIDP_GAMMA_LUT_SIZE); in malidp_crtc_init()
560 malidp_se_set_enh_coeffs(malidp->dev); in malidp_crtc_init()