Lines Matching refs:tu
296 struct tu_algo_data *tu) in dp_panel_update_tu_timings() argument
314 tu->lclk_fp = drm_fixp_from_fraction(in->lclk, 1); in dp_panel_update_tu_timings()
315 tu->pclk_fp = drm_fixp_from_fraction(in->pclk_khz, 1000); in dp_panel_update_tu_timings()
316 tu->lwidth = in->hactive; in dp_panel_update_tu_timings()
317 tu->hbp_relative_to_pclk = in->hporch; in dp_panel_update_tu_timings()
318 tu->nlanes = in->nlanes; in dp_panel_update_tu_timings()
319 tu->bpp = in->bpp; in dp_panel_update_tu_timings()
320 tu->pixelEnc = in->pixel_enc; in dp_panel_update_tu_timings()
321 tu->dsc_en = in->dsc_en; in dp_panel_update_tu_timings()
322 tu->async_en = in->async_en; in dp_panel_update_tu_timings()
323 tu->lwidth_fp = drm_fixp_from_fraction(in->hactive, 1); in dp_panel_update_tu_timings()
324 tu->hbp_relative_to_pclk_fp = drm_fixp_from_fraction(in->hporch, 1); in dp_panel_update_tu_timings()
326 if (tu->pixelEnc == 420) { in dp_panel_update_tu_timings()
328 tu->pclk_fp = drm_fixp_div(tu->pclk_fp, temp1_fp); in dp_panel_update_tu_timings()
329 tu->lwidth_fp = drm_fixp_div(tu->lwidth_fp, temp1_fp); in dp_panel_update_tu_timings()
330 tu->hbp_relative_to_pclk_fp = in dp_panel_update_tu_timings()
331 drm_fixp_div(tu->hbp_relative_to_pclk_fp, 2); in dp_panel_update_tu_timings()
334 if (tu->pixelEnc == 422) { in dp_panel_update_tu_timings()
335 switch (tu->bpp) { in dp_panel_update_tu_timings()
337 tu->bpp = 16; in dp_panel_update_tu_timings()
338 tu->bpc = 8; in dp_panel_update_tu_timings()
341 tu->bpp = 20; in dp_panel_update_tu_timings()
342 tu->bpc = 10; in dp_panel_update_tu_timings()
345 tu->bpp = 16; in dp_panel_update_tu_timings()
346 tu->bpc = 8; in dp_panel_update_tu_timings()
350 tu->bpc = tu->bpp/3; in dp_panel_update_tu_timings()
359 temp2_fp = drm_fixp_mul(tu->lwidth_fp, temp3_fp); in dp_panel_update_tu_timings()
381 temp2_fp = drm_fixp_mul(tu->pclk_fp, dwidth_dsc_fp); in dp_panel_update_tu_timings()
382 temp1_fp = drm_fixp_div(temp2_fp, tu->lwidth_fp); in dp_panel_update_tu_timings()
385 temp1_fp = drm_fixp_div(pclk_dsc_fp, tu->pclk_fp); in dp_panel_update_tu_timings()
386 temp2_fp = drm_fixp_mul(tu->hbp_relative_to_pclk_fp, temp1_fp); in dp_panel_update_tu_timings()
390 tu->pclk_fp = pclk_dsc_fp; in dp_panel_update_tu_timings()
391 tu->lwidth_fp = dwidth_dsc_fp; in dp_panel_update_tu_timings()
392 tu->hbp_relative_to_pclk_fp = hbp_dsc_fp; in dp_panel_update_tu_timings()
397 tu->lclk_fp = drm_fixp_mul(tu->lclk_fp, temp1_fp); in dp_panel_update_tu_timings()
401 static void _tu_valid_boundary_calc(struct tu_algo_data *tu) in _tu_valid_boundary_calc() argument
406 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
407 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
409 tu->new_valid_boundary_link = drm_fixp2int_ceil(temp2_fp); in _tu_valid_boundary_calc()
411 temp = (tu->i_upper_boundary_count * in _tu_valid_boundary_calc()
412 tu->new_valid_boundary_link + in _tu_valid_boundary_calc()
413 tu->i_lower_boundary_count * in _tu_valid_boundary_calc()
414 (tu->new_valid_boundary_link-1)); in _tu_valid_boundary_calc()
415 tu->average_valid2_fp = drm_fixp_from_fraction(temp, in _tu_valid_boundary_calc()
416 (tu->i_upper_boundary_count + in _tu_valid_boundary_calc()
417 tu->i_lower_boundary_count)); in _tu_valid_boundary_calc()
419 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _tu_valid_boundary_calc()
420 temp2_fp = tu->lwidth_fp; in _tu_valid_boundary_calc()
422 temp2_fp = drm_fixp_div(temp1_fp, tu->average_valid2_fp); in _tu_valid_boundary_calc()
423 tu->n_tus = drm_fixp2int(temp2_fp); in _tu_valid_boundary_calc()
425 tu->n_tus += 1; in _tu_valid_boundary_calc()
427 temp1_fp = drm_fixp_from_fraction(tu->n_tus, 1); in _tu_valid_boundary_calc()
428 temp2_fp = drm_fixp_mul(temp1_fp, tu->average_valid2_fp); in _tu_valid_boundary_calc()
429 temp1_fp = drm_fixp_from_fraction(tu->n_symbols, 1); in _tu_valid_boundary_calc()
431 temp1_fp = drm_fixp_from_fraction(tu->nlanes, 1); in _tu_valid_boundary_calc()
433 tu->n_remainder_symbols_per_lane_fp = temp2_fp; in _tu_valid_boundary_calc()
435 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
436 tu->last_partial_tu_fp = in _tu_valid_boundary_calc()
437 drm_fixp_div(tu->n_remainder_symbols_per_lane_fp, in _tu_valid_boundary_calc()
440 if (tu->n_remainder_symbols_per_lane_fp != 0) in _tu_valid_boundary_calc()
441 tu->remainder_symbols_exist = 1; in _tu_valid_boundary_calc()
443 tu->remainder_symbols_exist = 0; in _tu_valid_boundary_calc()
445 temp1_fp = drm_fixp_from_fraction(tu->n_tus, tu->nlanes); in _tu_valid_boundary_calc()
446 tu->n_tus_per_lane = drm_fixp2int(temp1_fp); in _tu_valid_boundary_calc()
448 tu->paired_tus = (int)((tu->n_tus_per_lane) / in _tu_valid_boundary_calc()
449 (tu->i_upper_boundary_count + in _tu_valid_boundary_calc()
450 tu->i_lower_boundary_count)); in _tu_valid_boundary_calc()
452 tu->remainder_tus = tu->n_tus_per_lane - tu->paired_tus * in _tu_valid_boundary_calc()
453 (tu->i_upper_boundary_count + in _tu_valid_boundary_calc()
454 tu->i_lower_boundary_count); in _tu_valid_boundary_calc()
456 if ((tu->remainder_tus - tu->i_upper_boundary_count) > 0) { in _tu_valid_boundary_calc()
457 tu->remainder_tus_upper = tu->i_upper_boundary_count; in _tu_valid_boundary_calc()
458 tu->remainder_tus_lower = tu->remainder_tus - in _tu_valid_boundary_calc()
459 tu->i_upper_boundary_count; in _tu_valid_boundary_calc()
461 tu->remainder_tus_upper = tu->remainder_tus; in _tu_valid_boundary_calc()
462 tu->remainder_tus_lower = 0; in _tu_valid_boundary_calc()
465 temp = tu->paired_tus * (tu->i_upper_boundary_count * in _tu_valid_boundary_calc()
466 tu->new_valid_boundary_link + in _tu_valid_boundary_calc()
467 tu->i_lower_boundary_count * in _tu_valid_boundary_calc()
468 (tu->new_valid_boundary_link - 1)) + in _tu_valid_boundary_calc()
469 (tu->remainder_tus_upper * in _tu_valid_boundary_calc()
470 tu->new_valid_boundary_link) + in _tu_valid_boundary_calc()
471 (tu->remainder_tus_lower * in _tu_valid_boundary_calc()
472 (tu->new_valid_boundary_link - 1)); in _tu_valid_boundary_calc()
473 tu->total_valid_fp = drm_fixp_from_fraction(temp, 1); in _tu_valid_boundary_calc()
475 if (tu->remainder_symbols_exist) { in _tu_valid_boundary_calc()
476 temp1_fp = tu->total_valid_fp + in _tu_valid_boundary_calc()
477 tu->n_remainder_symbols_per_lane_fp; in _tu_valid_boundary_calc()
478 temp2_fp = drm_fixp_from_fraction(tu->n_tus_per_lane, 1); in _tu_valid_boundary_calc()
479 temp2_fp = temp2_fp + tu->last_partial_tu_fp; in _tu_valid_boundary_calc()
482 temp2_fp = drm_fixp_from_fraction(tu->n_tus_per_lane, 1); in _tu_valid_boundary_calc()
483 temp1_fp = drm_fixp_div(tu->total_valid_fp, temp2_fp); in _tu_valid_boundary_calc()
485 tu->effective_valid_fp = temp1_fp; in _tu_valid_boundary_calc()
487 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
488 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
489 tu->n_n_err_fp = tu->effective_valid_fp - temp2_fp; in _tu_valid_boundary_calc()
491 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
492 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
493 tu->n_err_fp = tu->average_valid2_fp - temp2_fp; in _tu_valid_boundary_calc()
495 tu->even_distribution = tu->n_tus % tu->nlanes == 0 ? 1 : 0; in _tu_valid_boundary_calc()
497 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _tu_valid_boundary_calc()
498 temp2_fp = tu->lwidth_fp; in _tu_valid_boundary_calc()
500 temp2_fp = drm_fixp_div(temp1_fp, tu->average_valid2_fp); in _tu_valid_boundary_calc()
503 tu->n_tus_incl_last_incomplete_tu = drm_fixp2int_ceil(temp2_fp); in _tu_valid_boundary_calc()
505 tu->n_tus_incl_last_incomplete_tu = 0; in _tu_valid_boundary_calc()
508 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
509 temp2_fp = drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
510 temp1_fp = tu->average_valid2_fp - temp2_fp; in _tu_valid_boundary_calc()
511 temp2_fp = drm_fixp_from_fraction(tu->n_tus_incl_last_incomplete_tu, 1); in _tu_valid_boundary_calc()
517 temp = tu->i_upper_boundary_count * tu->nlanes; in _tu_valid_boundary_calc()
518 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
519 temp2_fp = drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
520 temp1_fp = drm_fixp_from_fraction(tu->new_valid_boundary_link, 1); in _tu_valid_boundary_calc()
529 tu->extra_required_bytes_new_tmp = (int)(temp1 + temp2); in _tu_valid_boundary_calc()
531 temp1_fp = drm_fixp_from_fraction(8, tu->bpp); in _tu_valid_boundary_calc()
533 tu->extra_required_bytes_new_tmp, 1); in _tu_valid_boundary_calc()
537 tu->extra_pclk_cycles_tmp = drm_fixp2int_ceil(temp1_fp); in _tu_valid_boundary_calc()
539 tu->extra_pclk_cycles_tmp = 0; in _tu_valid_boundary_calc()
541 temp1_fp = drm_fixp_from_fraction(tu->extra_pclk_cycles_tmp, 1); in _tu_valid_boundary_calc()
542 temp2_fp = drm_fixp_div(tu->lclk_fp, tu->pclk_fp); in _tu_valid_boundary_calc()
546 tu->extra_pclk_cycles_in_link_clk_tmp = in _tu_valid_boundary_calc()
549 tu->extra_pclk_cycles_in_link_clk_tmp = 0; in _tu_valid_boundary_calc()
551 tu->filler_size_tmp = tu->tu_size - tu->new_valid_boundary_link; in _tu_valid_boundary_calc()
553 tu->lower_filler_size_tmp = tu->filler_size_tmp + 1; in _tu_valid_boundary_calc()
555 tu->delay_start_link_tmp = tu->extra_pclk_cycles_in_link_clk_tmp + in _tu_valid_boundary_calc()
556 tu->lower_filler_size_tmp + in _tu_valid_boundary_calc()
557 tu->extra_buffer_margin; in _tu_valid_boundary_calc()
559 temp1_fp = drm_fixp_from_fraction(tu->delay_start_link_tmp, 1); in _tu_valid_boundary_calc()
560 tu->delay_start_time_fp = drm_fixp_div(temp1_fp, tu->lclk_fp); in _tu_valid_boundary_calc()
562 compare_result_1 = _tu_param_compare(tu->n_n_err_fp, tu->diff_abs_fp); in _tu_valid_boundary_calc()
568 compare_result_2 = _tu_param_compare(tu->n_n_err_fp, tu->err_fp); in _tu_valid_boundary_calc()
574 compare_result_3 = _tu_param_compare(tu->hbp_time_fp, in _tu_valid_boundary_calc()
575 tu->delay_start_time_fp); in _tu_valid_boundary_calc()
581 if (((tu->even_distribution == 1) || in _tu_valid_boundary_calc()
582 ((tu->even_distribution_BF == 0) && in _tu_valid_boundary_calc()
583 (tu->even_distribution_legacy == 0))) && in _tu_valid_boundary_calc()
584 tu->n_err_fp >= 0 && tu->n_n_err_fp >= 0 && in _tu_valid_boundary_calc()
586 (compare_result_1 || (tu->min_hblank_violated == 1)) && in _tu_valid_boundary_calc()
587 (tu->new_valid_boundary_link - 1) > 0 && in _tu_valid_boundary_calc()
589 (tu->delay_start_link_tmp <= 1023)) { in _tu_valid_boundary_calc()
590 tu->upper_boundary_count = tu->i_upper_boundary_count; in _tu_valid_boundary_calc()
591 tu->lower_boundary_count = tu->i_lower_boundary_count; in _tu_valid_boundary_calc()
592 tu->err_fp = tu->n_n_err_fp; in _tu_valid_boundary_calc()
593 tu->boundary_moderation_en = true; in _tu_valid_boundary_calc()
594 tu->tu_size_desired = tu->tu_size; in _tu_valid_boundary_calc()
595 tu->valid_boundary_link = tu->new_valid_boundary_link; in _tu_valid_boundary_calc()
596 tu->effective_valid_recorded_fp = tu->effective_valid_fp; in _tu_valid_boundary_calc()
597 tu->even_distribution_BF = 1; in _tu_valid_boundary_calc()
598 tu->delay_start_link = tu->delay_start_link_tmp; in _tu_valid_boundary_calc()
599 } else if (tu->boundary_mod_lower_err == 0) { in _tu_valid_boundary_calc()
600 compare_result_1 = _tu_param_compare(tu->n_n_err_fp, in _tu_valid_boundary_calc()
601 tu->diff_abs_fp); in _tu_valid_boundary_calc()
603 tu->boundary_mod_lower_err = 1; in _tu_valid_boundary_calc()
611 struct tu_algo_data *tu; in _dp_ctrl_calc_tu() local
626 tu = kzalloc(sizeof(*tu), GFP_KERNEL); in _dp_ctrl_calc_tu()
627 if (!tu) in _dp_ctrl_calc_tu()
630 dp_panel_update_tu_timings(in, tu); in _dp_ctrl_calc_tu()
632 tu->err_fp = drm_fixp_from_fraction(1000, 1); /* 1000 */ in _dp_ctrl_calc_tu()
635 temp2_fp = drm_fixp_mul(temp1_fp, tu->lclk_fp); in _dp_ctrl_calc_tu()
636 temp_fp = drm_fixp_div(temp2_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
637 tu->extra_buffer_margin = drm_fixp2int_ceil(temp_fp); in _dp_ctrl_calc_tu()
639 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
640 temp2_fp = drm_fixp_mul(tu->pclk_fp, temp1_fp); in _dp_ctrl_calc_tu()
641 temp1_fp = drm_fixp_from_fraction(tu->nlanes, 1); in _dp_ctrl_calc_tu()
643 tu->ratio_fp = drm_fixp_div(temp2_fp, tu->lclk_fp); in _dp_ctrl_calc_tu()
645 tu->original_ratio_fp = tu->ratio_fp; in _dp_ctrl_calc_tu()
646 tu->boundary_moderation_en = false; in _dp_ctrl_calc_tu()
647 tu->upper_boundary_count = 0; in _dp_ctrl_calc_tu()
648 tu->lower_boundary_count = 0; in _dp_ctrl_calc_tu()
649 tu->i_upper_boundary_count = 0; in _dp_ctrl_calc_tu()
650 tu->i_lower_boundary_count = 0; in _dp_ctrl_calc_tu()
651 tu->valid_lower_boundary_link = 0; in _dp_ctrl_calc_tu()
652 tu->even_distribution_BF = 0; in _dp_ctrl_calc_tu()
653 tu->even_distribution_legacy = 0; in _dp_ctrl_calc_tu()
654 tu->even_distribution = 0; in _dp_ctrl_calc_tu()
655 tu->delay_start_time_fp = 0; in _dp_ctrl_calc_tu()
657 tu->err_fp = drm_fixp_from_fraction(1000, 1); in _dp_ctrl_calc_tu()
658 tu->n_err_fp = 0; in _dp_ctrl_calc_tu()
659 tu->n_n_err_fp = 0; in _dp_ctrl_calc_tu()
661 tu->ratio = drm_fixp2int(tu->ratio_fp); in _dp_ctrl_calc_tu()
662 temp1_fp = drm_fixp_from_fraction(tu->nlanes, 1); in _dp_ctrl_calc_tu()
663 div64_u64_rem(tu->lwidth_fp, temp1_fp, &temp2_fp); in _dp_ctrl_calc_tu()
665 !tu->ratio && tu->dsc_en == 0) { in _dp_ctrl_calc_tu()
666 tu->ratio_fp = drm_fixp_mul(tu->ratio_fp, RATIO_SCALE_fp); in _dp_ctrl_calc_tu()
667 tu->ratio = drm_fixp2int(tu->ratio_fp); in _dp_ctrl_calc_tu()
668 if (tu->ratio) in _dp_ctrl_calc_tu()
669 tu->ratio_fp = drm_fixp_from_fraction(1, 1); in _dp_ctrl_calc_tu()
672 if (tu->ratio > 1) in _dp_ctrl_calc_tu()
673 tu->ratio = 1; in _dp_ctrl_calc_tu()
675 if (tu->ratio == 1) in _dp_ctrl_calc_tu()
678 compare_result_1 = _tu_param_compare(tu->ratio_fp, const_p49_fp); in _dp_ctrl_calc_tu()
684 compare_result_2 = _tu_param_compare(tu->ratio_fp, const_p56_fp); in _dp_ctrl_calc_tu()
690 if (tu->dsc_en && compare_result_1 && compare_result_2) { in _dp_ctrl_calc_tu()
697 for (tu->tu_size = 32; tu->tu_size <= 64; tu->tu_size++) { in _dp_ctrl_calc_tu()
698 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _dp_ctrl_calc_tu()
699 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
702 tu->n_err_fp = temp1_fp - temp2_fp; in _dp_ctrl_calc_tu()
704 if (tu->n_err_fp < tu->err_fp) { in _dp_ctrl_calc_tu()
705 tu->err_fp = tu->n_err_fp; in _dp_ctrl_calc_tu()
706 tu->tu_size_desired = tu->tu_size; in _dp_ctrl_calc_tu()
710 tu->tu_size_minus1 = tu->tu_size_desired - 1; in _dp_ctrl_calc_tu()
712 temp1_fp = drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
713 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
714 tu->valid_boundary_link = drm_fixp2int_ceil(temp2_fp); in _dp_ctrl_calc_tu()
716 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
717 temp2_fp = tu->lwidth_fp; in _dp_ctrl_calc_tu()
720 temp1_fp = drm_fixp_from_fraction(tu->valid_boundary_link, 1); in _dp_ctrl_calc_tu()
722 tu->n_tus = drm_fixp2int(temp2_fp); in _dp_ctrl_calc_tu()
724 tu->n_tus += 1; in _dp_ctrl_calc_tu()
726 tu->even_distribution_legacy = tu->n_tus % tu->nlanes == 0 ? 1 : 0; in _dp_ctrl_calc_tu()
730 tu->valid_boundary_link, tu->n_tus); in _dp_ctrl_calc_tu()
732 temp1_fp = drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
733 temp2_fp = drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
734 temp1_fp = drm_fixp_from_fraction(tu->valid_boundary_link, 1); in _dp_ctrl_calc_tu()
736 temp1_fp = drm_fixp_from_fraction(tu->n_tus + 1, 1); in _dp_ctrl_calc_tu()
741 tu->extra_bytes = drm_fixp2int_ceil(temp2_fp); in _dp_ctrl_calc_tu()
743 tu->extra_bytes = 0; in _dp_ctrl_calc_tu()
745 temp1_fp = drm_fixp_from_fraction(tu->extra_bytes, 1); in _dp_ctrl_calc_tu()
746 temp2_fp = drm_fixp_from_fraction(8, tu->bpp); in _dp_ctrl_calc_tu()
750 tu->extra_pclk_cycles = drm_fixp2int_ceil(temp1_fp); in _dp_ctrl_calc_tu()
752 tu->extra_pclk_cycles = drm_fixp2int(temp1_fp); in _dp_ctrl_calc_tu()
754 temp1_fp = drm_fixp_div(tu->lclk_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
755 temp2_fp = drm_fixp_from_fraction(tu->extra_pclk_cycles, 1); in _dp_ctrl_calc_tu()
759 tu->extra_pclk_cycles_in_link_clk = drm_fixp2int_ceil(temp1_fp); in _dp_ctrl_calc_tu()
761 tu->extra_pclk_cycles_in_link_clk = drm_fixp2int(temp1_fp); in _dp_ctrl_calc_tu()
763 tu->filler_size = tu->tu_size_desired - tu->valid_boundary_link; in _dp_ctrl_calc_tu()
765 temp1_fp = drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
766 tu->ratio_by_tu_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
768 tu->delay_start_link = tu->extra_pclk_cycles_in_link_clk + in _dp_ctrl_calc_tu()
769 tu->filler_size + tu->extra_buffer_margin; in _dp_ctrl_calc_tu()
771 tu->resulting_valid_fp = in _dp_ctrl_calc_tu()
772 drm_fixp_from_fraction(tu->valid_boundary_link, 1); in _dp_ctrl_calc_tu()
774 temp1_fp = drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
775 temp2_fp = drm_fixp_div(tu->resulting_valid_fp, temp1_fp); in _dp_ctrl_calc_tu()
776 tu->TU_ratio_err_fp = temp2_fp - tu->original_ratio_fp; in _dp_ctrl_calc_tu()
779 temp1_fp = tu->hbp_relative_to_pclk_fp - temp1_fp; in _dp_ctrl_calc_tu()
780 tu->hbp_time_fp = drm_fixp_div(temp1_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
782 temp1_fp = drm_fixp_from_fraction(tu->delay_start_link, 1); in _dp_ctrl_calc_tu()
783 tu->delay_start_time_fp = drm_fixp_div(temp1_fp, tu->lclk_fp); in _dp_ctrl_calc_tu()
785 compare_result_1 = _tu_param_compare(tu->hbp_time_fp, in _dp_ctrl_calc_tu()
786 tu->delay_start_time_fp); in _dp_ctrl_calc_tu()
788 tu->min_hblank_violated = 1; in _dp_ctrl_calc_tu()
790 tu->hactive_time_fp = drm_fixp_div(tu->lwidth_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
792 compare_result_2 = _tu_param_compare(tu->hactive_time_fp, in _dp_ctrl_calc_tu()
793 tu->delay_start_time_fp); in _dp_ctrl_calc_tu()
795 tu->min_hblank_violated = 1; in _dp_ctrl_calc_tu()
797 tu->delay_start_time_fp = 0; in _dp_ctrl_calc_tu()
801 tu->delay_start_link_extra_pixclk = EXTRA_PIXCLK_CYCLE_DELAY; in _dp_ctrl_calc_tu()
802 tu->diff_abs_fp = tu->resulting_valid_fp - tu->ratio_by_tu_fp; in _dp_ctrl_calc_tu()
804 temp = drm_fixp2int(tu->diff_abs_fp); in _dp_ctrl_calc_tu()
805 if (!temp && tu->diff_abs_fp <= 0xffff) in _dp_ctrl_calc_tu()
806 tu->diff_abs_fp = 0; in _dp_ctrl_calc_tu()
809 if (tu->diff_abs_fp < 0) in _dp_ctrl_calc_tu()
810 tu->diff_abs_fp = drm_fixp_mul(tu->diff_abs_fp, -1); in _dp_ctrl_calc_tu()
812 tu->boundary_mod_lower_err = 0; in _dp_ctrl_calc_tu()
813 if ((tu->diff_abs_fp != 0 && in _dp_ctrl_calc_tu()
814 ((tu->diff_abs_fp > BRUTE_FORCE_THRESHOLD_fp) || in _dp_ctrl_calc_tu()
815 (tu->even_distribution_legacy == 0) || in _dp_ctrl_calc_tu()
817 (tu->min_hblank_violated == 1)) { in _dp_ctrl_calc_tu()
819 tu->err_fp = drm_fixp_from_fraction(1000, 1); in _dp_ctrl_calc_tu()
821 temp1_fp = drm_fixp_div(tu->lclk_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
823 tu->delay_start_link_extra_pixclk, 1); in _dp_ctrl_calc_tu()
827 tu->extra_buffer_margin = in _dp_ctrl_calc_tu()
830 tu->extra_buffer_margin = 0; in _dp_ctrl_calc_tu()
832 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
833 temp1_fp = drm_fixp_mul(tu->lwidth_fp, temp1_fp); in _dp_ctrl_calc_tu()
836 tu->n_symbols = drm_fixp2int_ceil(temp1_fp); in _dp_ctrl_calc_tu()
838 tu->n_symbols = 0; in _dp_ctrl_calc_tu()
840 for (tu->tu_size = 32; tu->tu_size <= 64; tu->tu_size++) { in _dp_ctrl_calc_tu()
841 for (tu->i_upper_boundary_count = 1; in _dp_ctrl_calc_tu()
842 tu->i_upper_boundary_count <= 15; in _dp_ctrl_calc_tu()
843 tu->i_upper_boundary_count++) { in _dp_ctrl_calc_tu()
844 for (tu->i_lower_boundary_count = 1; in _dp_ctrl_calc_tu()
845 tu->i_lower_boundary_count <= 15; in _dp_ctrl_calc_tu()
846 tu->i_lower_boundary_count++) { in _dp_ctrl_calc_tu()
847 _tu_valid_boundary_calc(tu); in _dp_ctrl_calc_tu()
851 tu->delay_start_link_extra_pixclk--; in _dp_ctrl_calc_tu()
852 } while (tu->boundary_moderation_en != true && in _dp_ctrl_calc_tu()
853 tu->boundary_mod_lower_err == 1 && in _dp_ctrl_calc_tu()
854 tu->delay_start_link_extra_pixclk != 0); in _dp_ctrl_calc_tu()
856 if (tu->boundary_moderation_en == true) { in _dp_ctrl_calc_tu()
858 (tu->upper_boundary_count * in _dp_ctrl_calc_tu()
859 tu->valid_boundary_link + in _dp_ctrl_calc_tu()
860 tu->lower_boundary_count * in _dp_ctrl_calc_tu()
861 (tu->valid_boundary_link - 1)), 1); in _dp_ctrl_calc_tu()
863 (tu->upper_boundary_count + in _dp_ctrl_calc_tu()
864 tu->lower_boundary_count), 1); in _dp_ctrl_calc_tu()
865 tu->resulting_valid_fp = in _dp_ctrl_calc_tu()
869 tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
870 tu->ratio_by_tu_fp = in _dp_ctrl_calc_tu()
871 drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
873 tu->valid_lower_boundary_link = in _dp_ctrl_calc_tu()
874 tu->valid_boundary_link - 1; in _dp_ctrl_calc_tu()
876 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
877 temp1_fp = drm_fixp_mul(tu->lwidth_fp, temp1_fp); in _dp_ctrl_calc_tu()
879 tu->resulting_valid_fp); in _dp_ctrl_calc_tu()
880 tu->n_tus = drm_fixp2int(temp2_fp); in _dp_ctrl_calc_tu()
882 tu->tu_size_minus1 = tu->tu_size_desired - 1; in _dp_ctrl_calc_tu()
883 tu->even_distribution_BF = 1; in _dp_ctrl_calc_tu()
886 drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
888 drm_fixp_div(tu->resulting_valid_fp, temp1_fp); in _dp_ctrl_calc_tu()
889 tu->TU_ratio_err_fp = temp2_fp - tu->original_ratio_fp; in _dp_ctrl_calc_tu()
893 temp2_fp = drm_fixp_mul(LCLK_FAST_SKEW_fp, tu->lwidth_fp); in _dp_ctrl_calc_tu()
900 temp1_fp = drm_fixp_from_fraction(tu->nlanes, 1); in _dp_ctrl_calc_tu()
901 temp2_fp = drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
902 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
908 if (tu->async_en) in _dp_ctrl_calc_tu()
909 tu->delay_start_link += (int)temp; in _dp_ctrl_calc_tu()
911 temp1_fp = drm_fixp_from_fraction(tu->delay_start_link, 1); in _dp_ctrl_calc_tu()
912 tu->delay_start_time_fp = drm_fixp_div(temp1_fp, tu->lclk_fp); in _dp_ctrl_calc_tu()
915 tu_table->valid_boundary_link = tu->valid_boundary_link; in _dp_ctrl_calc_tu()
916 tu_table->delay_start_link = tu->delay_start_link; in _dp_ctrl_calc_tu()
917 tu_table->boundary_moderation_en = tu->boundary_moderation_en; in _dp_ctrl_calc_tu()
918 tu_table->valid_lower_boundary_link = tu->valid_lower_boundary_link; in _dp_ctrl_calc_tu()
919 tu_table->upper_boundary_count = tu->upper_boundary_count; in _dp_ctrl_calc_tu()
920 tu_table->lower_boundary_count = tu->lower_boundary_count; in _dp_ctrl_calc_tu()
921 tu_table->tu_size_minus1 = tu->tu_size_minus1; in _dp_ctrl_calc_tu()
938 kfree(tu); in _dp_ctrl_calc_tu()