Lines Matching refs:tu

314 					struct tu_algo_data *tu)  in dp_panel_update_tu_timings()  argument
332 tu->lclk_fp = drm_fixp_from_fraction(in->lclk, 1); in dp_panel_update_tu_timings()
333 tu->pclk_fp = drm_fixp_from_fraction(in->pclk_khz, 1000); in dp_panel_update_tu_timings()
334 tu->lwidth = in->hactive; in dp_panel_update_tu_timings()
335 tu->hbp_relative_to_pclk = in->hporch; in dp_panel_update_tu_timings()
336 tu->nlanes = in->nlanes; in dp_panel_update_tu_timings()
337 tu->bpp = in->bpp; in dp_panel_update_tu_timings()
338 tu->pixelEnc = in->pixel_enc; in dp_panel_update_tu_timings()
339 tu->dsc_en = in->dsc_en; in dp_panel_update_tu_timings()
340 tu->async_en = in->async_en; in dp_panel_update_tu_timings()
341 tu->lwidth_fp = drm_fixp_from_fraction(in->hactive, 1); in dp_panel_update_tu_timings()
342 tu->hbp_relative_to_pclk_fp = drm_fixp_from_fraction(in->hporch, 1); in dp_panel_update_tu_timings()
344 if (tu->pixelEnc == 420) { in dp_panel_update_tu_timings()
346 tu->pclk_fp = drm_fixp_div(tu->pclk_fp, temp1_fp); in dp_panel_update_tu_timings()
347 tu->lwidth_fp = drm_fixp_div(tu->lwidth_fp, temp1_fp); in dp_panel_update_tu_timings()
348 tu->hbp_relative_to_pclk_fp = in dp_panel_update_tu_timings()
349 drm_fixp_div(tu->hbp_relative_to_pclk_fp, 2); in dp_panel_update_tu_timings()
352 if (tu->pixelEnc == 422) { in dp_panel_update_tu_timings()
353 switch (tu->bpp) { in dp_panel_update_tu_timings()
355 tu->bpp = 16; in dp_panel_update_tu_timings()
356 tu->bpc = 8; in dp_panel_update_tu_timings()
359 tu->bpp = 20; in dp_panel_update_tu_timings()
360 tu->bpc = 10; in dp_panel_update_tu_timings()
363 tu->bpp = 16; in dp_panel_update_tu_timings()
364 tu->bpc = 8; in dp_panel_update_tu_timings()
368 tu->bpc = tu->bpp/3; in dp_panel_update_tu_timings()
377 temp2_fp = drm_fixp_mul(tu->lwidth_fp, temp3_fp); in dp_panel_update_tu_timings()
399 temp2_fp = drm_fixp_mul(tu->pclk_fp, dwidth_dsc_fp); in dp_panel_update_tu_timings()
400 temp1_fp = drm_fixp_div(temp2_fp, tu->lwidth_fp); in dp_panel_update_tu_timings()
403 temp1_fp = drm_fixp_div(pclk_dsc_fp, tu->pclk_fp); in dp_panel_update_tu_timings()
404 temp2_fp = drm_fixp_mul(tu->hbp_relative_to_pclk_fp, temp1_fp); in dp_panel_update_tu_timings()
408 tu->pclk_fp = pclk_dsc_fp; in dp_panel_update_tu_timings()
409 tu->lwidth_fp = dwidth_dsc_fp; in dp_panel_update_tu_timings()
410 tu->hbp_relative_to_pclk_fp = hbp_dsc_fp; in dp_panel_update_tu_timings()
415 tu->lclk_fp = drm_fixp_mul(tu->lclk_fp, temp1_fp); in dp_panel_update_tu_timings()
419 static void _tu_valid_boundary_calc(struct tu_algo_data *tu) in _tu_valid_boundary_calc() argument
424 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
425 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
427 tu->new_valid_boundary_link = drm_fixp2int_ceil(temp2_fp); in _tu_valid_boundary_calc()
429 temp = (tu->i_upper_boundary_count * in _tu_valid_boundary_calc()
430 tu->new_valid_boundary_link + in _tu_valid_boundary_calc()
431 tu->i_lower_boundary_count * in _tu_valid_boundary_calc()
432 (tu->new_valid_boundary_link-1)); in _tu_valid_boundary_calc()
433 tu->average_valid2_fp = drm_fixp_from_fraction(temp, in _tu_valid_boundary_calc()
434 (tu->i_upper_boundary_count + in _tu_valid_boundary_calc()
435 tu->i_lower_boundary_count)); in _tu_valid_boundary_calc()
437 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _tu_valid_boundary_calc()
438 temp2_fp = tu->lwidth_fp; in _tu_valid_boundary_calc()
440 temp2_fp = drm_fixp_div(temp1_fp, tu->average_valid2_fp); in _tu_valid_boundary_calc()
441 tu->n_tus = drm_fixp2int(temp2_fp); in _tu_valid_boundary_calc()
443 tu->n_tus += 1; in _tu_valid_boundary_calc()
445 temp1_fp = drm_fixp_from_fraction(tu->n_tus, 1); in _tu_valid_boundary_calc()
446 temp2_fp = drm_fixp_mul(temp1_fp, tu->average_valid2_fp); in _tu_valid_boundary_calc()
447 temp1_fp = drm_fixp_from_fraction(tu->n_symbols, 1); in _tu_valid_boundary_calc()
449 temp1_fp = drm_fixp_from_fraction(tu->nlanes, 1); in _tu_valid_boundary_calc()
451 tu->n_remainder_symbols_per_lane_fp = temp2_fp; in _tu_valid_boundary_calc()
453 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
454 tu->last_partial_tu_fp = in _tu_valid_boundary_calc()
455 drm_fixp_div(tu->n_remainder_symbols_per_lane_fp, in _tu_valid_boundary_calc()
458 if (tu->n_remainder_symbols_per_lane_fp != 0) in _tu_valid_boundary_calc()
459 tu->remainder_symbols_exist = 1; in _tu_valid_boundary_calc()
461 tu->remainder_symbols_exist = 0; in _tu_valid_boundary_calc()
463 temp1_fp = drm_fixp_from_fraction(tu->n_tus, tu->nlanes); in _tu_valid_boundary_calc()
464 tu->n_tus_per_lane = drm_fixp2int(temp1_fp); in _tu_valid_boundary_calc()
466 tu->paired_tus = (int)((tu->n_tus_per_lane) / in _tu_valid_boundary_calc()
467 (tu->i_upper_boundary_count + in _tu_valid_boundary_calc()
468 tu->i_lower_boundary_count)); in _tu_valid_boundary_calc()
470 tu->remainder_tus = tu->n_tus_per_lane - tu->paired_tus * in _tu_valid_boundary_calc()
471 (tu->i_upper_boundary_count + in _tu_valid_boundary_calc()
472 tu->i_lower_boundary_count); in _tu_valid_boundary_calc()
474 if ((tu->remainder_tus - tu->i_upper_boundary_count) > 0) { in _tu_valid_boundary_calc()
475 tu->remainder_tus_upper = tu->i_upper_boundary_count; in _tu_valid_boundary_calc()
476 tu->remainder_tus_lower = tu->remainder_tus - in _tu_valid_boundary_calc()
477 tu->i_upper_boundary_count; in _tu_valid_boundary_calc()
479 tu->remainder_tus_upper = tu->remainder_tus; in _tu_valid_boundary_calc()
480 tu->remainder_tus_lower = 0; in _tu_valid_boundary_calc()
483 temp = tu->paired_tus * (tu->i_upper_boundary_count * in _tu_valid_boundary_calc()
484 tu->new_valid_boundary_link + in _tu_valid_boundary_calc()
485 tu->i_lower_boundary_count * in _tu_valid_boundary_calc()
486 (tu->new_valid_boundary_link - 1)) + in _tu_valid_boundary_calc()
487 (tu->remainder_tus_upper * in _tu_valid_boundary_calc()
488 tu->new_valid_boundary_link) + in _tu_valid_boundary_calc()
489 (tu->remainder_tus_lower * in _tu_valid_boundary_calc()
490 (tu->new_valid_boundary_link - 1)); in _tu_valid_boundary_calc()
491 tu->total_valid_fp = drm_fixp_from_fraction(temp, 1); in _tu_valid_boundary_calc()
493 if (tu->remainder_symbols_exist) { in _tu_valid_boundary_calc()
494 temp1_fp = tu->total_valid_fp + in _tu_valid_boundary_calc()
495 tu->n_remainder_symbols_per_lane_fp; in _tu_valid_boundary_calc()
496 temp2_fp = drm_fixp_from_fraction(tu->n_tus_per_lane, 1); in _tu_valid_boundary_calc()
497 temp2_fp = temp2_fp + tu->last_partial_tu_fp; in _tu_valid_boundary_calc()
500 temp2_fp = drm_fixp_from_fraction(tu->n_tus_per_lane, 1); in _tu_valid_boundary_calc()
501 temp1_fp = drm_fixp_div(tu->total_valid_fp, temp2_fp); in _tu_valid_boundary_calc()
503 tu->effective_valid_fp = temp1_fp; in _tu_valid_boundary_calc()
505 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
506 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
507 tu->n_n_err_fp = tu->effective_valid_fp - temp2_fp; in _tu_valid_boundary_calc()
509 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
510 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
511 tu->n_err_fp = tu->average_valid2_fp - temp2_fp; in _tu_valid_boundary_calc()
513 tu->even_distribution = tu->n_tus % tu->nlanes == 0 ? 1 : 0; in _tu_valid_boundary_calc()
515 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _tu_valid_boundary_calc()
516 temp2_fp = tu->lwidth_fp; in _tu_valid_boundary_calc()
518 temp2_fp = drm_fixp_div(temp1_fp, tu->average_valid2_fp); in _tu_valid_boundary_calc()
521 tu->n_tus_incl_last_incomplete_tu = drm_fixp2int_ceil(temp2_fp); in _tu_valid_boundary_calc()
523 tu->n_tus_incl_last_incomplete_tu = 0; in _tu_valid_boundary_calc()
526 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
527 temp2_fp = drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
528 temp1_fp = tu->average_valid2_fp - temp2_fp; in _tu_valid_boundary_calc()
529 temp2_fp = drm_fixp_from_fraction(tu->n_tus_incl_last_incomplete_tu, 1); in _tu_valid_boundary_calc()
535 temp = tu->i_upper_boundary_count * tu->nlanes; in _tu_valid_boundary_calc()
536 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
537 temp2_fp = drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
538 temp1_fp = drm_fixp_from_fraction(tu->new_valid_boundary_link, 1); in _tu_valid_boundary_calc()
547 tu->extra_required_bytes_new_tmp = (int)(temp1 + temp2); in _tu_valid_boundary_calc()
549 temp1_fp = drm_fixp_from_fraction(8, tu->bpp); in _tu_valid_boundary_calc()
551 tu->extra_required_bytes_new_tmp, 1); in _tu_valid_boundary_calc()
555 tu->extra_pclk_cycles_tmp = drm_fixp2int_ceil(temp1_fp); in _tu_valid_boundary_calc()
557 tu->extra_pclk_cycles_tmp = 0; in _tu_valid_boundary_calc()
559 temp1_fp = drm_fixp_from_fraction(tu->extra_pclk_cycles_tmp, 1); in _tu_valid_boundary_calc()
560 temp2_fp = drm_fixp_div(tu->lclk_fp, tu->pclk_fp); in _tu_valid_boundary_calc()
564 tu->extra_pclk_cycles_in_link_clk_tmp = in _tu_valid_boundary_calc()
567 tu->extra_pclk_cycles_in_link_clk_tmp = 0; in _tu_valid_boundary_calc()
569 tu->filler_size_tmp = tu->tu_size - tu->new_valid_boundary_link; in _tu_valid_boundary_calc()
571 tu->lower_filler_size_tmp = tu->filler_size_tmp + 1; in _tu_valid_boundary_calc()
573 tu->delay_start_link_tmp = tu->extra_pclk_cycles_in_link_clk_tmp + in _tu_valid_boundary_calc()
574 tu->lower_filler_size_tmp + in _tu_valid_boundary_calc()
575 tu->extra_buffer_margin; in _tu_valid_boundary_calc()
577 temp1_fp = drm_fixp_from_fraction(tu->delay_start_link_tmp, 1); in _tu_valid_boundary_calc()
578 tu->delay_start_time_fp = drm_fixp_div(temp1_fp, tu->lclk_fp); in _tu_valid_boundary_calc()
580 compare_result_1 = _tu_param_compare(tu->n_n_err_fp, tu->diff_abs_fp); in _tu_valid_boundary_calc()
586 compare_result_2 = _tu_param_compare(tu->n_n_err_fp, tu->err_fp); in _tu_valid_boundary_calc()
592 compare_result_3 = _tu_param_compare(tu->hbp_time_fp, in _tu_valid_boundary_calc()
593 tu->delay_start_time_fp); in _tu_valid_boundary_calc()
599 if (((tu->even_distribution == 1) || in _tu_valid_boundary_calc()
600 ((tu->even_distribution_BF == 0) && in _tu_valid_boundary_calc()
601 (tu->even_distribution_legacy == 0))) && in _tu_valid_boundary_calc()
602 tu->n_err_fp >= 0 && tu->n_n_err_fp >= 0 && in _tu_valid_boundary_calc()
604 (compare_result_1 || (tu->min_hblank_violated == 1)) && in _tu_valid_boundary_calc()
605 (tu->new_valid_boundary_link - 1) > 0 && in _tu_valid_boundary_calc()
607 (tu->delay_start_link_tmp <= 1023)) { in _tu_valid_boundary_calc()
608 tu->upper_boundary_count = tu->i_upper_boundary_count; in _tu_valid_boundary_calc()
609 tu->lower_boundary_count = tu->i_lower_boundary_count; in _tu_valid_boundary_calc()
610 tu->err_fp = tu->n_n_err_fp; in _tu_valid_boundary_calc()
611 tu->boundary_moderation_en = true; in _tu_valid_boundary_calc()
612 tu->tu_size_desired = tu->tu_size; in _tu_valid_boundary_calc()
613 tu->valid_boundary_link = tu->new_valid_boundary_link; in _tu_valid_boundary_calc()
614 tu->effective_valid_recorded_fp = tu->effective_valid_fp; in _tu_valid_boundary_calc()
615 tu->even_distribution_BF = 1; in _tu_valid_boundary_calc()
616 tu->delay_start_link = tu->delay_start_link_tmp; in _tu_valid_boundary_calc()
617 } else if (tu->boundary_mod_lower_err == 0) { in _tu_valid_boundary_calc()
618 compare_result_1 = _tu_param_compare(tu->n_n_err_fp, in _tu_valid_boundary_calc()
619 tu->diff_abs_fp); in _tu_valid_boundary_calc()
621 tu->boundary_mod_lower_err = 1; in _tu_valid_boundary_calc()
629 struct tu_algo_data *tu; in _dp_ctrl_calc_tu() local
644 tu = kzalloc(sizeof(*tu), GFP_KERNEL); in _dp_ctrl_calc_tu()
645 if (!tu) in _dp_ctrl_calc_tu()
648 dp_panel_update_tu_timings(in, tu); in _dp_ctrl_calc_tu()
650 tu->err_fp = drm_fixp_from_fraction(1000, 1); /* 1000 */ in _dp_ctrl_calc_tu()
653 temp2_fp = drm_fixp_mul(temp1_fp, tu->lclk_fp); in _dp_ctrl_calc_tu()
654 temp_fp = drm_fixp_div(temp2_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
655 tu->extra_buffer_margin = drm_fixp2int_ceil(temp_fp); in _dp_ctrl_calc_tu()
657 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
658 temp2_fp = drm_fixp_mul(tu->pclk_fp, temp1_fp); in _dp_ctrl_calc_tu()
659 temp1_fp = drm_fixp_from_fraction(tu->nlanes, 1); in _dp_ctrl_calc_tu()
661 tu->ratio_fp = drm_fixp_div(temp2_fp, tu->lclk_fp); in _dp_ctrl_calc_tu()
663 tu->original_ratio_fp = tu->ratio_fp; in _dp_ctrl_calc_tu()
664 tu->boundary_moderation_en = false; in _dp_ctrl_calc_tu()
665 tu->upper_boundary_count = 0; in _dp_ctrl_calc_tu()
666 tu->lower_boundary_count = 0; in _dp_ctrl_calc_tu()
667 tu->i_upper_boundary_count = 0; in _dp_ctrl_calc_tu()
668 tu->i_lower_boundary_count = 0; in _dp_ctrl_calc_tu()
669 tu->valid_lower_boundary_link = 0; in _dp_ctrl_calc_tu()
670 tu->even_distribution_BF = 0; in _dp_ctrl_calc_tu()
671 tu->even_distribution_legacy = 0; in _dp_ctrl_calc_tu()
672 tu->even_distribution = 0; in _dp_ctrl_calc_tu()
673 tu->delay_start_time_fp = 0; in _dp_ctrl_calc_tu()
675 tu->err_fp = drm_fixp_from_fraction(1000, 1); in _dp_ctrl_calc_tu()
676 tu->n_err_fp = 0; in _dp_ctrl_calc_tu()
677 tu->n_n_err_fp = 0; in _dp_ctrl_calc_tu()
679 tu->ratio = drm_fixp2int(tu->ratio_fp); in _dp_ctrl_calc_tu()
680 temp1_fp = drm_fixp_from_fraction(tu->nlanes, 1); in _dp_ctrl_calc_tu()
681 div64_u64_rem(tu->lwidth_fp, temp1_fp, &temp2_fp); in _dp_ctrl_calc_tu()
683 !tu->ratio && tu->dsc_en == 0) { in _dp_ctrl_calc_tu()
684 tu->ratio_fp = drm_fixp_mul(tu->ratio_fp, RATIO_SCALE_fp); in _dp_ctrl_calc_tu()
685 tu->ratio = drm_fixp2int(tu->ratio_fp); in _dp_ctrl_calc_tu()
686 if (tu->ratio) in _dp_ctrl_calc_tu()
687 tu->ratio_fp = drm_fixp_from_fraction(1, 1); in _dp_ctrl_calc_tu()
690 if (tu->ratio > 1) in _dp_ctrl_calc_tu()
691 tu->ratio = 1; in _dp_ctrl_calc_tu()
693 if (tu->ratio == 1) in _dp_ctrl_calc_tu()
696 compare_result_1 = _tu_param_compare(tu->ratio_fp, const_p49_fp); in _dp_ctrl_calc_tu()
702 compare_result_2 = _tu_param_compare(tu->ratio_fp, const_p56_fp); in _dp_ctrl_calc_tu()
708 if (tu->dsc_en && compare_result_1 && compare_result_2) { in _dp_ctrl_calc_tu()
715 for (tu->tu_size = 32; tu->tu_size <= 64; tu->tu_size++) { in _dp_ctrl_calc_tu()
716 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _dp_ctrl_calc_tu()
717 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
720 tu->n_err_fp = temp1_fp - temp2_fp; in _dp_ctrl_calc_tu()
722 if (tu->n_err_fp < tu->err_fp) { in _dp_ctrl_calc_tu()
723 tu->err_fp = tu->n_err_fp; in _dp_ctrl_calc_tu()
724 tu->tu_size_desired = tu->tu_size; in _dp_ctrl_calc_tu()
728 tu->tu_size_minus1 = tu->tu_size_desired - 1; in _dp_ctrl_calc_tu()
730 temp1_fp = drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
731 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
732 tu->valid_boundary_link = drm_fixp2int_ceil(temp2_fp); in _dp_ctrl_calc_tu()
734 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
735 temp2_fp = tu->lwidth_fp; in _dp_ctrl_calc_tu()
738 temp1_fp = drm_fixp_from_fraction(tu->valid_boundary_link, 1); in _dp_ctrl_calc_tu()
740 tu->n_tus = drm_fixp2int(temp2_fp); in _dp_ctrl_calc_tu()
742 tu->n_tus += 1; in _dp_ctrl_calc_tu()
744 tu->even_distribution_legacy = tu->n_tus % tu->nlanes == 0 ? 1 : 0; in _dp_ctrl_calc_tu()
748 tu->valid_boundary_link, tu->n_tus); in _dp_ctrl_calc_tu()
750 temp1_fp = drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
751 temp2_fp = drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
752 temp1_fp = drm_fixp_from_fraction(tu->valid_boundary_link, 1); in _dp_ctrl_calc_tu()
754 temp1_fp = drm_fixp_from_fraction(tu->n_tus + 1, 1); in _dp_ctrl_calc_tu()
759 tu->extra_bytes = drm_fixp2int_ceil(temp2_fp); in _dp_ctrl_calc_tu()
761 tu->extra_bytes = 0; in _dp_ctrl_calc_tu()
763 temp1_fp = drm_fixp_from_fraction(tu->extra_bytes, 1); in _dp_ctrl_calc_tu()
764 temp2_fp = drm_fixp_from_fraction(8, tu->bpp); in _dp_ctrl_calc_tu()
768 tu->extra_pclk_cycles = drm_fixp2int_ceil(temp1_fp); in _dp_ctrl_calc_tu()
770 tu->extra_pclk_cycles = drm_fixp2int(temp1_fp); in _dp_ctrl_calc_tu()
772 temp1_fp = drm_fixp_div(tu->lclk_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
773 temp2_fp = drm_fixp_from_fraction(tu->extra_pclk_cycles, 1); in _dp_ctrl_calc_tu()
777 tu->extra_pclk_cycles_in_link_clk = drm_fixp2int_ceil(temp1_fp); in _dp_ctrl_calc_tu()
779 tu->extra_pclk_cycles_in_link_clk = drm_fixp2int(temp1_fp); in _dp_ctrl_calc_tu()
781 tu->filler_size = tu->tu_size_desired - tu->valid_boundary_link; in _dp_ctrl_calc_tu()
783 temp1_fp = drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
784 tu->ratio_by_tu_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
786 tu->delay_start_link = tu->extra_pclk_cycles_in_link_clk + in _dp_ctrl_calc_tu()
787 tu->filler_size + tu->extra_buffer_margin; in _dp_ctrl_calc_tu()
789 tu->resulting_valid_fp = in _dp_ctrl_calc_tu()
790 drm_fixp_from_fraction(tu->valid_boundary_link, 1); in _dp_ctrl_calc_tu()
792 temp1_fp = drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
793 temp2_fp = drm_fixp_div(tu->resulting_valid_fp, temp1_fp); in _dp_ctrl_calc_tu()
794 tu->TU_ratio_err_fp = temp2_fp - tu->original_ratio_fp; in _dp_ctrl_calc_tu()
797 temp1_fp = tu->hbp_relative_to_pclk_fp - temp1_fp; in _dp_ctrl_calc_tu()
798 tu->hbp_time_fp = drm_fixp_div(temp1_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
800 temp1_fp = drm_fixp_from_fraction(tu->delay_start_link, 1); in _dp_ctrl_calc_tu()
801 tu->delay_start_time_fp = drm_fixp_div(temp1_fp, tu->lclk_fp); in _dp_ctrl_calc_tu()
803 compare_result_1 = _tu_param_compare(tu->hbp_time_fp, in _dp_ctrl_calc_tu()
804 tu->delay_start_time_fp); in _dp_ctrl_calc_tu()
806 tu->min_hblank_violated = 1; in _dp_ctrl_calc_tu()
808 tu->hactive_time_fp = drm_fixp_div(tu->lwidth_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
810 compare_result_2 = _tu_param_compare(tu->hactive_time_fp, in _dp_ctrl_calc_tu()
811 tu->delay_start_time_fp); in _dp_ctrl_calc_tu()
813 tu->min_hblank_violated = 1; in _dp_ctrl_calc_tu()
815 tu->delay_start_time_fp = 0; in _dp_ctrl_calc_tu()
819 tu->delay_start_link_extra_pixclk = EXTRA_PIXCLK_CYCLE_DELAY; in _dp_ctrl_calc_tu()
820 tu->diff_abs_fp = tu->resulting_valid_fp - tu->ratio_by_tu_fp; in _dp_ctrl_calc_tu()
822 temp = drm_fixp2int(tu->diff_abs_fp); in _dp_ctrl_calc_tu()
823 if (!temp && tu->diff_abs_fp <= 0xffff) in _dp_ctrl_calc_tu()
824 tu->diff_abs_fp = 0; in _dp_ctrl_calc_tu()
827 if (tu->diff_abs_fp < 0) in _dp_ctrl_calc_tu()
828 tu->diff_abs_fp = drm_fixp_mul(tu->diff_abs_fp, -1); in _dp_ctrl_calc_tu()
830 tu->boundary_mod_lower_err = 0; in _dp_ctrl_calc_tu()
831 if ((tu->diff_abs_fp != 0 && in _dp_ctrl_calc_tu()
832 ((tu->diff_abs_fp > BRUTE_FORCE_THRESHOLD_fp) || in _dp_ctrl_calc_tu()
833 (tu->even_distribution_legacy == 0) || in _dp_ctrl_calc_tu()
835 (tu->min_hblank_violated == 1)) { in _dp_ctrl_calc_tu()
837 tu->err_fp = drm_fixp_from_fraction(1000, 1); in _dp_ctrl_calc_tu()
839 temp1_fp = drm_fixp_div(tu->lclk_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
841 tu->delay_start_link_extra_pixclk, 1); in _dp_ctrl_calc_tu()
845 tu->extra_buffer_margin = in _dp_ctrl_calc_tu()
848 tu->extra_buffer_margin = 0; in _dp_ctrl_calc_tu()
850 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
851 temp1_fp = drm_fixp_mul(tu->lwidth_fp, temp1_fp); in _dp_ctrl_calc_tu()
854 tu->n_symbols = drm_fixp2int_ceil(temp1_fp); in _dp_ctrl_calc_tu()
856 tu->n_symbols = 0; in _dp_ctrl_calc_tu()
858 for (tu->tu_size = 32; tu->tu_size <= 64; tu->tu_size++) { in _dp_ctrl_calc_tu()
859 for (tu->i_upper_boundary_count = 1; in _dp_ctrl_calc_tu()
860 tu->i_upper_boundary_count <= 15; in _dp_ctrl_calc_tu()
861 tu->i_upper_boundary_count++) { in _dp_ctrl_calc_tu()
862 for (tu->i_lower_boundary_count = 1; in _dp_ctrl_calc_tu()
863 tu->i_lower_boundary_count <= 15; in _dp_ctrl_calc_tu()
864 tu->i_lower_boundary_count++) { in _dp_ctrl_calc_tu()
865 _tu_valid_boundary_calc(tu); in _dp_ctrl_calc_tu()
869 tu->delay_start_link_extra_pixclk--; in _dp_ctrl_calc_tu()
870 } while (tu->boundary_moderation_en != true && in _dp_ctrl_calc_tu()
871 tu->boundary_mod_lower_err == 1 && in _dp_ctrl_calc_tu()
872 tu->delay_start_link_extra_pixclk != 0); in _dp_ctrl_calc_tu()
874 if (tu->boundary_moderation_en == true) { in _dp_ctrl_calc_tu()
876 (tu->upper_boundary_count * in _dp_ctrl_calc_tu()
877 tu->valid_boundary_link + in _dp_ctrl_calc_tu()
878 tu->lower_boundary_count * in _dp_ctrl_calc_tu()
879 (tu->valid_boundary_link - 1)), 1); in _dp_ctrl_calc_tu()
881 (tu->upper_boundary_count + in _dp_ctrl_calc_tu()
882 tu->lower_boundary_count), 1); in _dp_ctrl_calc_tu()
883 tu->resulting_valid_fp = in _dp_ctrl_calc_tu()
887 tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
888 tu->ratio_by_tu_fp = in _dp_ctrl_calc_tu()
889 drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
891 tu->valid_lower_boundary_link = in _dp_ctrl_calc_tu()
892 tu->valid_boundary_link - 1; in _dp_ctrl_calc_tu()
894 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
895 temp1_fp = drm_fixp_mul(tu->lwidth_fp, temp1_fp); in _dp_ctrl_calc_tu()
897 tu->resulting_valid_fp); in _dp_ctrl_calc_tu()
898 tu->n_tus = drm_fixp2int(temp2_fp); in _dp_ctrl_calc_tu()
900 tu->tu_size_minus1 = tu->tu_size_desired - 1; in _dp_ctrl_calc_tu()
901 tu->even_distribution_BF = 1; in _dp_ctrl_calc_tu()
904 drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
906 drm_fixp_div(tu->resulting_valid_fp, temp1_fp); in _dp_ctrl_calc_tu()
907 tu->TU_ratio_err_fp = temp2_fp - tu->original_ratio_fp; in _dp_ctrl_calc_tu()
911 temp2_fp = drm_fixp_mul(LCLK_FAST_SKEW_fp, tu->lwidth_fp); in _dp_ctrl_calc_tu()
918 temp1_fp = drm_fixp_from_fraction(tu->nlanes, 1); in _dp_ctrl_calc_tu()
919 temp2_fp = drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
920 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
926 if (tu->async_en) in _dp_ctrl_calc_tu()
927 tu->delay_start_link += (int)temp; in _dp_ctrl_calc_tu()
929 temp1_fp = drm_fixp_from_fraction(tu->delay_start_link, 1); in _dp_ctrl_calc_tu()
930 tu->delay_start_time_fp = drm_fixp_div(temp1_fp, tu->lclk_fp); in _dp_ctrl_calc_tu()
933 tu_table->valid_boundary_link = tu->valid_boundary_link; in _dp_ctrl_calc_tu()
934 tu_table->delay_start_link = tu->delay_start_link; in _dp_ctrl_calc_tu()
935 tu_table->boundary_moderation_en = tu->boundary_moderation_en; in _dp_ctrl_calc_tu()
936 tu_table->valid_lower_boundary_link = tu->valid_lower_boundary_link; in _dp_ctrl_calc_tu()
937 tu_table->upper_boundary_count = tu->upper_boundary_count; in _dp_ctrl_calc_tu()
938 tu_table->lower_boundary_count = tu->lower_boundary_count; in _dp_ctrl_calc_tu()
939 tu_table->tu_size_minus1 = tu->tu_size_minus1; in _dp_ctrl_calc_tu()
956 kfree(tu); in _dp_ctrl_calc_tu()