Lines Matching refs:tu

294 					struct tu_algo_data *tu)  in dp_panel_update_tu_timings()  argument
312 tu->lclk_fp = drm_fixp_from_fraction(in->lclk, 1); in dp_panel_update_tu_timings()
313 tu->pclk_fp = drm_fixp_from_fraction(in->pclk_khz, 1000); in dp_panel_update_tu_timings()
314 tu->lwidth = in->hactive; in dp_panel_update_tu_timings()
315 tu->hbp_relative_to_pclk = in->hporch; in dp_panel_update_tu_timings()
316 tu->nlanes = in->nlanes; in dp_panel_update_tu_timings()
317 tu->bpp = in->bpp; in dp_panel_update_tu_timings()
318 tu->pixelEnc = in->pixel_enc; in dp_panel_update_tu_timings()
319 tu->dsc_en = in->dsc_en; in dp_panel_update_tu_timings()
320 tu->async_en = in->async_en; in dp_panel_update_tu_timings()
321 tu->lwidth_fp = drm_fixp_from_fraction(in->hactive, 1); in dp_panel_update_tu_timings()
322 tu->hbp_relative_to_pclk_fp = drm_fixp_from_fraction(in->hporch, 1); in dp_panel_update_tu_timings()
324 if (tu->pixelEnc == 420) { in dp_panel_update_tu_timings()
326 tu->pclk_fp = drm_fixp_div(tu->pclk_fp, temp1_fp); in dp_panel_update_tu_timings()
327 tu->lwidth_fp = drm_fixp_div(tu->lwidth_fp, temp1_fp); in dp_panel_update_tu_timings()
328 tu->hbp_relative_to_pclk_fp = in dp_panel_update_tu_timings()
329 drm_fixp_div(tu->hbp_relative_to_pclk_fp, 2); in dp_panel_update_tu_timings()
332 if (tu->pixelEnc == 422) { in dp_panel_update_tu_timings()
333 switch (tu->bpp) { in dp_panel_update_tu_timings()
335 tu->bpp = 16; in dp_panel_update_tu_timings()
336 tu->bpc = 8; in dp_panel_update_tu_timings()
339 tu->bpp = 20; in dp_panel_update_tu_timings()
340 tu->bpc = 10; in dp_panel_update_tu_timings()
343 tu->bpp = 16; in dp_panel_update_tu_timings()
344 tu->bpc = 8; in dp_panel_update_tu_timings()
348 tu->bpc = tu->bpp/3; in dp_panel_update_tu_timings()
357 temp2_fp = drm_fixp_mul(tu->lwidth_fp, temp3_fp); in dp_panel_update_tu_timings()
379 temp2_fp = drm_fixp_mul(tu->pclk_fp, dwidth_dsc_fp); in dp_panel_update_tu_timings()
380 temp1_fp = drm_fixp_div(temp2_fp, tu->lwidth_fp); in dp_panel_update_tu_timings()
383 temp1_fp = drm_fixp_div(pclk_dsc_fp, tu->pclk_fp); in dp_panel_update_tu_timings()
384 temp2_fp = drm_fixp_mul(tu->hbp_relative_to_pclk_fp, temp1_fp); in dp_panel_update_tu_timings()
388 tu->pclk_fp = pclk_dsc_fp; in dp_panel_update_tu_timings()
389 tu->lwidth_fp = dwidth_dsc_fp; in dp_panel_update_tu_timings()
390 tu->hbp_relative_to_pclk_fp = hbp_dsc_fp; in dp_panel_update_tu_timings()
395 tu->lclk_fp = drm_fixp_mul(tu->lclk_fp, temp1_fp); in dp_panel_update_tu_timings()
399 static void _tu_valid_boundary_calc(struct tu_algo_data *tu) in _tu_valid_boundary_calc() argument
404 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
405 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
407 tu->new_valid_boundary_link = drm_fixp2int_ceil(temp2_fp); in _tu_valid_boundary_calc()
409 temp = (tu->i_upper_boundary_count * in _tu_valid_boundary_calc()
410 tu->new_valid_boundary_link + in _tu_valid_boundary_calc()
411 tu->i_lower_boundary_count * in _tu_valid_boundary_calc()
412 (tu->new_valid_boundary_link-1)); in _tu_valid_boundary_calc()
413 tu->average_valid2_fp = drm_fixp_from_fraction(temp, in _tu_valid_boundary_calc()
414 (tu->i_upper_boundary_count + in _tu_valid_boundary_calc()
415 tu->i_lower_boundary_count)); in _tu_valid_boundary_calc()
417 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _tu_valid_boundary_calc()
418 temp2_fp = tu->lwidth_fp; in _tu_valid_boundary_calc()
420 temp2_fp = drm_fixp_div(temp1_fp, tu->average_valid2_fp); in _tu_valid_boundary_calc()
421 tu->n_tus = drm_fixp2int(temp2_fp); in _tu_valid_boundary_calc()
423 tu->n_tus += 1; in _tu_valid_boundary_calc()
425 temp1_fp = drm_fixp_from_fraction(tu->n_tus, 1); in _tu_valid_boundary_calc()
426 temp2_fp = drm_fixp_mul(temp1_fp, tu->average_valid2_fp); in _tu_valid_boundary_calc()
427 temp1_fp = drm_fixp_from_fraction(tu->n_symbols, 1); in _tu_valid_boundary_calc()
429 temp1_fp = drm_fixp_from_fraction(tu->nlanes, 1); in _tu_valid_boundary_calc()
431 tu->n_remainder_symbols_per_lane_fp = temp2_fp; in _tu_valid_boundary_calc()
433 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
434 tu->last_partial_tu_fp = in _tu_valid_boundary_calc()
435 drm_fixp_div(tu->n_remainder_symbols_per_lane_fp, in _tu_valid_boundary_calc()
438 if (tu->n_remainder_symbols_per_lane_fp != 0) in _tu_valid_boundary_calc()
439 tu->remainder_symbols_exist = 1; in _tu_valid_boundary_calc()
441 tu->remainder_symbols_exist = 0; in _tu_valid_boundary_calc()
443 temp1_fp = drm_fixp_from_fraction(tu->n_tus, tu->nlanes); in _tu_valid_boundary_calc()
444 tu->n_tus_per_lane = drm_fixp2int(temp1_fp); in _tu_valid_boundary_calc()
446 tu->paired_tus = (int)((tu->n_tus_per_lane) / in _tu_valid_boundary_calc()
447 (tu->i_upper_boundary_count + in _tu_valid_boundary_calc()
448 tu->i_lower_boundary_count)); in _tu_valid_boundary_calc()
450 tu->remainder_tus = tu->n_tus_per_lane - tu->paired_tus * in _tu_valid_boundary_calc()
451 (tu->i_upper_boundary_count + in _tu_valid_boundary_calc()
452 tu->i_lower_boundary_count); in _tu_valid_boundary_calc()
454 if ((tu->remainder_tus - tu->i_upper_boundary_count) > 0) { in _tu_valid_boundary_calc()
455 tu->remainder_tus_upper = tu->i_upper_boundary_count; in _tu_valid_boundary_calc()
456 tu->remainder_tus_lower = tu->remainder_tus - in _tu_valid_boundary_calc()
457 tu->i_upper_boundary_count; in _tu_valid_boundary_calc()
459 tu->remainder_tus_upper = tu->remainder_tus; in _tu_valid_boundary_calc()
460 tu->remainder_tus_lower = 0; in _tu_valid_boundary_calc()
463 temp = tu->paired_tus * (tu->i_upper_boundary_count * in _tu_valid_boundary_calc()
464 tu->new_valid_boundary_link + in _tu_valid_boundary_calc()
465 tu->i_lower_boundary_count * in _tu_valid_boundary_calc()
466 (tu->new_valid_boundary_link - 1)) + in _tu_valid_boundary_calc()
467 (tu->remainder_tus_upper * in _tu_valid_boundary_calc()
468 tu->new_valid_boundary_link) + in _tu_valid_boundary_calc()
469 (tu->remainder_tus_lower * in _tu_valid_boundary_calc()
470 (tu->new_valid_boundary_link - 1)); in _tu_valid_boundary_calc()
471 tu->total_valid_fp = drm_fixp_from_fraction(temp, 1); in _tu_valid_boundary_calc()
473 if (tu->remainder_symbols_exist) { in _tu_valid_boundary_calc()
474 temp1_fp = tu->total_valid_fp + in _tu_valid_boundary_calc()
475 tu->n_remainder_symbols_per_lane_fp; in _tu_valid_boundary_calc()
476 temp2_fp = drm_fixp_from_fraction(tu->n_tus_per_lane, 1); in _tu_valid_boundary_calc()
477 temp2_fp = temp2_fp + tu->last_partial_tu_fp; in _tu_valid_boundary_calc()
480 temp2_fp = drm_fixp_from_fraction(tu->n_tus_per_lane, 1); in _tu_valid_boundary_calc()
481 temp1_fp = drm_fixp_div(tu->total_valid_fp, temp2_fp); in _tu_valid_boundary_calc()
483 tu->effective_valid_fp = temp1_fp; in _tu_valid_boundary_calc()
485 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
486 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
487 tu->n_n_err_fp = tu->effective_valid_fp - temp2_fp; in _tu_valid_boundary_calc()
489 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
490 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
491 tu->n_err_fp = tu->average_valid2_fp - temp2_fp; in _tu_valid_boundary_calc()
493 tu->even_distribution = tu->n_tus % tu->nlanes == 0 ? 1 : 0; in _tu_valid_boundary_calc()
495 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _tu_valid_boundary_calc()
496 temp2_fp = tu->lwidth_fp; in _tu_valid_boundary_calc()
498 temp2_fp = drm_fixp_div(temp1_fp, tu->average_valid2_fp); in _tu_valid_boundary_calc()
501 tu->n_tus_incl_last_incomplete_tu = drm_fixp2int_ceil(temp2_fp); in _tu_valid_boundary_calc()
503 tu->n_tus_incl_last_incomplete_tu = 0; in _tu_valid_boundary_calc()
506 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
507 temp2_fp = drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
508 temp1_fp = tu->average_valid2_fp - temp2_fp; in _tu_valid_boundary_calc()
509 temp2_fp = drm_fixp_from_fraction(tu->n_tus_incl_last_incomplete_tu, 1); in _tu_valid_boundary_calc()
515 temp = tu->i_upper_boundary_count * tu->nlanes; in _tu_valid_boundary_calc()
516 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _tu_valid_boundary_calc()
517 temp2_fp = drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _tu_valid_boundary_calc()
518 temp1_fp = drm_fixp_from_fraction(tu->new_valid_boundary_link, 1); in _tu_valid_boundary_calc()
527 tu->extra_required_bytes_new_tmp = (int)(temp1 + temp2); in _tu_valid_boundary_calc()
529 temp1_fp = drm_fixp_from_fraction(8, tu->bpp); in _tu_valid_boundary_calc()
531 tu->extra_required_bytes_new_tmp, 1); in _tu_valid_boundary_calc()
535 tu->extra_pclk_cycles_tmp = drm_fixp2int_ceil(temp1_fp); in _tu_valid_boundary_calc()
537 tu->extra_pclk_cycles_tmp = 0; in _tu_valid_boundary_calc()
539 temp1_fp = drm_fixp_from_fraction(tu->extra_pclk_cycles_tmp, 1); in _tu_valid_boundary_calc()
540 temp2_fp = drm_fixp_div(tu->lclk_fp, tu->pclk_fp); in _tu_valid_boundary_calc()
544 tu->extra_pclk_cycles_in_link_clk_tmp = in _tu_valid_boundary_calc()
547 tu->extra_pclk_cycles_in_link_clk_tmp = 0; in _tu_valid_boundary_calc()
549 tu->filler_size_tmp = tu->tu_size - tu->new_valid_boundary_link; in _tu_valid_boundary_calc()
551 tu->lower_filler_size_tmp = tu->filler_size_tmp + 1; in _tu_valid_boundary_calc()
553 tu->delay_start_link_tmp = tu->extra_pclk_cycles_in_link_clk_tmp + in _tu_valid_boundary_calc()
554 tu->lower_filler_size_tmp + in _tu_valid_boundary_calc()
555 tu->extra_buffer_margin; in _tu_valid_boundary_calc()
557 temp1_fp = drm_fixp_from_fraction(tu->delay_start_link_tmp, 1); in _tu_valid_boundary_calc()
558 tu->delay_start_time_fp = drm_fixp_div(temp1_fp, tu->lclk_fp); in _tu_valid_boundary_calc()
560 compare_result_1 = _tu_param_compare(tu->n_n_err_fp, tu->diff_abs_fp); in _tu_valid_boundary_calc()
566 compare_result_2 = _tu_param_compare(tu->n_n_err_fp, tu->err_fp); in _tu_valid_boundary_calc()
572 compare_result_3 = _tu_param_compare(tu->hbp_time_fp, in _tu_valid_boundary_calc()
573 tu->delay_start_time_fp); in _tu_valid_boundary_calc()
579 if (((tu->even_distribution == 1) || in _tu_valid_boundary_calc()
580 ((tu->even_distribution_BF == 0) && in _tu_valid_boundary_calc()
581 (tu->even_distribution_legacy == 0))) && in _tu_valid_boundary_calc()
582 tu->n_err_fp >= 0 && tu->n_n_err_fp >= 0 && in _tu_valid_boundary_calc()
584 (compare_result_1 || (tu->min_hblank_violated == 1)) && in _tu_valid_boundary_calc()
585 (tu->new_valid_boundary_link - 1) > 0 && in _tu_valid_boundary_calc()
587 (tu->delay_start_link_tmp <= 1023)) { in _tu_valid_boundary_calc()
588 tu->upper_boundary_count = tu->i_upper_boundary_count; in _tu_valid_boundary_calc()
589 tu->lower_boundary_count = tu->i_lower_boundary_count; in _tu_valid_boundary_calc()
590 tu->err_fp = tu->n_n_err_fp; in _tu_valid_boundary_calc()
591 tu->boundary_moderation_en = true; in _tu_valid_boundary_calc()
592 tu->tu_size_desired = tu->tu_size; in _tu_valid_boundary_calc()
593 tu->valid_boundary_link = tu->new_valid_boundary_link; in _tu_valid_boundary_calc()
594 tu->effective_valid_recorded_fp = tu->effective_valid_fp; in _tu_valid_boundary_calc()
595 tu->even_distribution_BF = 1; in _tu_valid_boundary_calc()
596 tu->delay_start_link = tu->delay_start_link_tmp; in _tu_valid_boundary_calc()
597 } else if (tu->boundary_mod_lower_err == 0) { in _tu_valid_boundary_calc()
598 compare_result_1 = _tu_param_compare(tu->n_n_err_fp, in _tu_valid_boundary_calc()
599 tu->diff_abs_fp); in _tu_valid_boundary_calc()
601 tu->boundary_mod_lower_err = 1; in _tu_valid_boundary_calc()
608 struct tu_algo_data *tu; in _dp_ctrl_calc_tu() local
623 tu = kzalloc(sizeof(*tu), GFP_KERNEL); in _dp_ctrl_calc_tu()
624 if (!tu) in _dp_ctrl_calc_tu()
627 dp_panel_update_tu_timings(in, tu); in _dp_ctrl_calc_tu()
629 tu->err_fp = drm_fixp_from_fraction(1000, 1); /* 1000 */ in _dp_ctrl_calc_tu()
632 temp2_fp = drm_fixp_mul(temp1_fp, tu->lclk_fp); in _dp_ctrl_calc_tu()
633 temp_fp = drm_fixp_div(temp2_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
634 tu->extra_buffer_margin = drm_fixp2int_ceil(temp_fp); in _dp_ctrl_calc_tu()
636 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
637 temp2_fp = drm_fixp_mul(tu->pclk_fp, temp1_fp); in _dp_ctrl_calc_tu()
638 temp1_fp = drm_fixp_from_fraction(tu->nlanes, 1); in _dp_ctrl_calc_tu()
640 tu->ratio_fp = drm_fixp_div(temp2_fp, tu->lclk_fp); in _dp_ctrl_calc_tu()
642 tu->original_ratio_fp = tu->ratio_fp; in _dp_ctrl_calc_tu()
643 tu->boundary_moderation_en = false; in _dp_ctrl_calc_tu()
644 tu->upper_boundary_count = 0; in _dp_ctrl_calc_tu()
645 tu->lower_boundary_count = 0; in _dp_ctrl_calc_tu()
646 tu->i_upper_boundary_count = 0; in _dp_ctrl_calc_tu()
647 tu->i_lower_boundary_count = 0; in _dp_ctrl_calc_tu()
648 tu->valid_lower_boundary_link = 0; in _dp_ctrl_calc_tu()
649 tu->even_distribution_BF = 0; in _dp_ctrl_calc_tu()
650 tu->even_distribution_legacy = 0; in _dp_ctrl_calc_tu()
651 tu->even_distribution = 0; in _dp_ctrl_calc_tu()
652 tu->delay_start_time_fp = 0; in _dp_ctrl_calc_tu()
654 tu->err_fp = drm_fixp_from_fraction(1000, 1); in _dp_ctrl_calc_tu()
655 tu->n_err_fp = 0; in _dp_ctrl_calc_tu()
656 tu->n_n_err_fp = 0; in _dp_ctrl_calc_tu()
658 tu->ratio = drm_fixp2int(tu->ratio_fp); in _dp_ctrl_calc_tu()
659 temp1_fp = drm_fixp_from_fraction(tu->nlanes, 1); in _dp_ctrl_calc_tu()
660 div64_u64_rem(tu->lwidth_fp, temp1_fp, &temp2_fp); in _dp_ctrl_calc_tu()
662 !tu->ratio && tu->dsc_en == 0) { in _dp_ctrl_calc_tu()
663 tu->ratio_fp = drm_fixp_mul(tu->ratio_fp, RATIO_SCALE_fp); in _dp_ctrl_calc_tu()
664 tu->ratio = drm_fixp2int(tu->ratio_fp); in _dp_ctrl_calc_tu()
665 if (tu->ratio) in _dp_ctrl_calc_tu()
666 tu->ratio_fp = drm_fixp_from_fraction(1, 1); in _dp_ctrl_calc_tu()
669 if (tu->ratio > 1) in _dp_ctrl_calc_tu()
670 tu->ratio = 1; in _dp_ctrl_calc_tu()
672 if (tu->ratio == 1) in _dp_ctrl_calc_tu()
675 compare_result_1 = _tu_param_compare(tu->ratio_fp, const_p49_fp); in _dp_ctrl_calc_tu()
681 compare_result_2 = _tu_param_compare(tu->ratio_fp, const_p56_fp); in _dp_ctrl_calc_tu()
687 if (tu->dsc_en && compare_result_1 && compare_result_2) { in _dp_ctrl_calc_tu()
694 for (tu->tu_size = 32; tu->tu_size <= 64; tu->tu_size++) { in _dp_ctrl_calc_tu()
695 temp1_fp = drm_fixp_from_fraction(tu->tu_size, 1); in _dp_ctrl_calc_tu()
696 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
699 tu->n_err_fp = temp1_fp - temp2_fp; in _dp_ctrl_calc_tu()
701 if (tu->n_err_fp < tu->err_fp) { in _dp_ctrl_calc_tu()
702 tu->err_fp = tu->n_err_fp; in _dp_ctrl_calc_tu()
703 tu->tu_size_desired = tu->tu_size; in _dp_ctrl_calc_tu()
707 tu->tu_size_minus1 = tu->tu_size_desired - 1; in _dp_ctrl_calc_tu()
709 temp1_fp = drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
710 temp2_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
711 tu->valid_boundary_link = drm_fixp2int_ceil(temp2_fp); in _dp_ctrl_calc_tu()
713 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
714 temp2_fp = tu->lwidth_fp; in _dp_ctrl_calc_tu()
717 temp1_fp = drm_fixp_from_fraction(tu->valid_boundary_link, 1); in _dp_ctrl_calc_tu()
719 tu->n_tus = drm_fixp2int(temp2_fp); in _dp_ctrl_calc_tu()
721 tu->n_tus += 1; in _dp_ctrl_calc_tu()
723 tu->even_distribution_legacy = tu->n_tus % tu->nlanes == 0 ? 1 : 0; in _dp_ctrl_calc_tu()
725 tu->valid_boundary_link, tu->n_tus); in _dp_ctrl_calc_tu()
727 temp1_fp = drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
728 temp2_fp = drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
729 temp1_fp = drm_fixp_from_fraction(tu->valid_boundary_link, 1); in _dp_ctrl_calc_tu()
731 temp1_fp = drm_fixp_from_fraction(tu->n_tus + 1, 1); in _dp_ctrl_calc_tu()
736 tu->extra_bytes = drm_fixp2int_ceil(temp2_fp); in _dp_ctrl_calc_tu()
738 tu->extra_bytes = 0; in _dp_ctrl_calc_tu()
740 temp1_fp = drm_fixp_from_fraction(tu->extra_bytes, 1); in _dp_ctrl_calc_tu()
741 temp2_fp = drm_fixp_from_fraction(8, tu->bpp); in _dp_ctrl_calc_tu()
745 tu->extra_pclk_cycles = drm_fixp2int_ceil(temp1_fp); in _dp_ctrl_calc_tu()
747 tu->extra_pclk_cycles = drm_fixp2int(temp1_fp); in _dp_ctrl_calc_tu()
749 temp1_fp = drm_fixp_div(tu->lclk_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
750 temp2_fp = drm_fixp_from_fraction(tu->extra_pclk_cycles, 1); in _dp_ctrl_calc_tu()
754 tu->extra_pclk_cycles_in_link_clk = drm_fixp2int_ceil(temp1_fp); in _dp_ctrl_calc_tu()
756 tu->extra_pclk_cycles_in_link_clk = drm_fixp2int(temp1_fp); in _dp_ctrl_calc_tu()
758 tu->filler_size = tu->tu_size_desired - tu->valid_boundary_link; in _dp_ctrl_calc_tu()
760 temp1_fp = drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
761 tu->ratio_by_tu_fp = drm_fixp_mul(tu->ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
763 tu->delay_start_link = tu->extra_pclk_cycles_in_link_clk + in _dp_ctrl_calc_tu()
764 tu->filler_size + tu->extra_buffer_margin; in _dp_ctrl_calc_tu()
766 tu->resulting_valid_fp = in _dp_ctrl_calc_tu()
767 drm_fixp_from_fraction(tu->valid_boundary_link, 1); in _dp_ctrl_calc_tu()
769 temp1_fp = drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
770 temp2_fp = drm_fixp_div(tu->resulting_valid_fp, temp1_fp); in _dp_ctrl_calc_tu()
771 tu->TU_ratio_err_fp = temp2_fp - tu->original_ratio_fp; in _dp_ctrl_calc_tu()
774 temp1_fp = tu->hbp_relative_to_pclk_fp - temp1_fp; in _dp_ctrl_calc_tu()
775 tu->hbp_time_fp = drm_fixp_div(temp1_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
777 temp1_fp = drm_fixp_from_fraction(tu->delay_start_link, 1); in _dp_ctrl_calc_tu()
778 tu->delay_start_time_fp = drm_fixp_div(temp1_fp, tu->lclk_fp); in _dp_ctrl_calc_tu()
780 compare_result_1 = _tu_param_compare(tu->hbp_time_fp, in _dp_ctrl_calc_tu()
781 tu->delay_start_time_fp); in _dp_ctrl_calc_tu()
783 tu->min_hblank_violated = 1; in _dp_ctrl_calc_tu()
785 tu->hactive_time_fp = drm_fixp_div(tu->lwidth_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
787 compare_result_2 = _tu_param_compare(tu->hactive_time_fp, in _dp_ctrl_calc_tu()
788 tu->delay_start_time_fp); in _dp_ctrl_calc_tu()
790 tu->min_hblank_violated = 1; in _dp_ctrl_calc_tu()
792 tu->delay_start_time_fp = 0; in _dp_ctrl_calc_tu()
796 tu->delay_start_link_extra_pixclk = EXTRA_PIXCLK_CYCLE_DELAY; in _dp_ctrl_calc_tu()
797 tu->diff_abs_fp = tu->resulting_valid_fp - tu->ratio_by_tu_fp; in _dp_ctrl_calc_tu()
799 temp = drm_fixp2int(tu->diff_abs_fp); in _dp_ctrl_calc_tu()
800 if (!temp && tu->diff_abs_fp <= 0xffff) in _dp_ctrl_calc_tu()
801 tu->diff_abs_fp = 0; in _dp_ctrl_calc_tu()
804 if (tu->diff_abs_fp < 0) in _dp_ctrl_calc_tu()
805 tu->diff_abs_fp = drm_fixp_mul(tu->diff_abs_fp, -1); in _dp_ctrl_calc_tu()
807 tu->boundary_mod_lower_err = 0; in _dp_ctrl_calc_tu()
808 if ((tu->diff_abs_fp != 0 && in _dp_ctrl_calc_tu()
809 ((tu->diff_abs_fp > BRUTE_FORCE_THRESHOLD_fp) || in _dp_ctrl_calc_tu()
810 (tu->even_distribution_legacy == 0) || in _dp_ctrl_calc_tu()
812 (tu->min_hblank_violated == 1)) { in _dp_ctrl_calc_tu()
814 tu->err_fp = drm_fixp_from_fraction(1000, 1); in _dp_ctrl_calc_tu()
816 temp1_fp = drm_fixp_div(tu->lclk_fp, tu->pclk_fp); in _dp_ctrl_calc_tu()
818 tu->delay_start_link_extra_pixclk, 1); in _dp_ctrl_calc_tu()
822 tu->extra_buffer_margin = in _dp_ctrl_calc_tu()
825 tu->extra_buffer_margin = 0; in _dp_ctrl_calc_tu()
827 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
828 temp1_fp = drm_fixp_mul(tu->lwidth_fp, temp1_fp); in _dp_ctrl_calc_tu()
831 tu->n_symbols = drm_fixp2int_ceil(temp1_fp); in _dp_ctrl_calc_tu()
833 tu->n_symbols = 0; in _dp_ctrl_calc_tu()
835 for (tu->tu_size = 32; tu->tu_size <= 64; tu->tu_size++) { in _dp_ctrl_calc_tu()
836 for (tu->i_upper_boundary_count = 1; in _dp_ctrl_calc_tu()
837 tu->i_upper_boundary_count <= 15; in _dp_ctrl_calc_tu()
838 tu->i_upper_boundary_count++) { in _dp_ctrl_calc_tu()
839 for (tu->i_lower_boundary_count = 1; in _dp_ctrl_calc_tu()
840 tu->i_lower_boundary_count <= 15; in _dp_ctrl_calc_tu()
841 tu->i_lower_boundary_count++) { in _dp_ctrl_calc_tu()
842 _tu_valid_boundary_calc(tu); in _dp_ctrl_calc_tu()
846 tu->delay_start_link_extra_pixclk--; in _dp_ctrl_calc_tu()
847 } while (tu->boundary_moderation_en != true && in _dp_ctrl_calc_tu()
848 tu->boundary_mod_lower_err == 1 && in _dp_ctrl_calc_tu()
849 tu->delay_start_link_extra_pixclk != 0); in _dp_ctrl_calc_tu()
851 if (tu->boundary_moderation_en == true) { in _dp_ctrl_calc_tu()
853 (tu->upper_boundary_count * in _dp_ctrl_calc_tu()
854 tu->valid_boundary_link + in _dp_ctrl_calc_tu()
855 tu->lower_boundary_count * in _dp_ctrl_calc_tu()
856 (tu->valid_boundary_link - 1)), 1); in _dp_ctrl_calc_tu()
858 (tu->upper_boundary_count + in _dp_ctrl_calc_tu()
859 tu->lower_boundary_count), 1); in _dp_ctrl_calc_tu()
860 tu->resulting_valid_fp = in _dp_ctrl_calc_tu()
864 tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
865 tu->ratio_by_tu_fp = in _dp_ctrl_calc_tu()
866 drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
868 tu->valid_lower_boundary_link = in _dp_ctrl_calc_tu()
869 tu->valid_boundary_link - 1; in _dp_ctrl_calc_tu()
871 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
872 temp1_fp = drm_fixp_mul(tu->lwidth_fp, temp1_fp); in _dp_ctrl_calc_tu()
874 tu->resulting_valid_fp); in _dp_ctrl_calc_tu()
875 tu->n_tus = drm_fixp2int(temp2_fp); in _dp_ctrl_calc_tu()
877 tu->tu_size_minus1 = tu->tu_size_desired - 1; in _dp_ctrl_calc_tu()
878 tu->even_distribution_BF = 1; in _dp_ctrl_calc_tu()
881 drm_fixp_from_fraction(tu->tu_size_desired, 1); in _dp_ctrl_calc_tu()
883 drm_fixp_div(tu->resulting_valid_fp, temp1_fp); in _dp_ctrl_calc_tu()
884 tu->TU_ratio_err_fp = temp2_fp - tu->original_ratio_fp; in _dp_ctrl_calc_tu()
888 temp2_fp = drm_fixp_mul(LCLK_FAST_SKEW_fp, tu->lwidth_fp); in _dp_ctrl_calc_tu()
895 temp1_fp = drm_fixp_from_fraction(tu->nlanes, 1); in _dp_ctrl_calc_tu()
896 temp2_fp = drm_fixp_mul(tu->original_ratio_fp, temp1_fp); in _dp_ctrl_calc_tu()
897 temp1_fp = drm_fixp_from_fraction(tu->bpp, 8); in _dp_ctrl_calc_tu()
903 if (tu->async_en) in _dp_ctrl_calc_tu()
904 tu->delay_start_link += (int)temp; in _dp_ctrl_calc_tu()
906 temp1_fp = drm_fixp_from_fraction(tu->delay_start_link, 1); in _dp_ctrl_calc_tu()
907 tu->delay_start_time_fp = drm_fixp_div(temp1_fp, tu->lclk_fp); in _dp_ctrl_calc_tu()
910 tu_table->valid_boundary_link = tu->valid_boundary_link; in _dp_ctrl_calc_tu()
911 tu_table->delay_start_link = tu->delay_start_link; in _dp_ctrl_calc_tu()
912 tu_table->boundary_moderation_en = tu->boundary_moderation_en; in _dp_ctrl_calc_tu()
913 tu_table->valid_lower_boundary_link = tu->valid_lower_boundary_link; in _dp_ctrl_calc_tu()
914 tu_table->upper_boundary_count = tu->upper_boundary_count; in _dp_ctrl_calc_tu()
915 tu_table->lower_boundary_count = tu->lower_boundary_count; in _dp_ctrl_calc_tu()
916 tu_table->tu_size_minus1 = tu->tu_size_minus1; in _dp_ctrl_calc_tu()
932 kfree(tu); in _dp_ctrl_calc_tu()