2 * Copyright 2015 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 #include <linux/delay.h>
28 #include "dm_services.h"
30 #include "dc_bios_types.h"
31 #include "core_types.h"
32 #include "core_status.h"
34 #include "dm_helpers.h"
35 #include "dce110_hw_sequencer.h"
36 #include "dce110_timing_generator.h"
37 #include "dce/dce_hwseq.h"
38 #include "gpio_service_interface.h"
40 #include "dce110_compressor.h"
42 #include "bios/bios_parser_helper.h"
43 #include "timing_generator.h"
44 #include "mem_input.h"
47 #include "transform.h"
48 #include "stream_encoder.h"
49 #include "link_encoder.h"
50 #include "link_hwss.h"
51 #include "dc_link_dp.h"
52 #include "clock_source.h"
56 #include "reg_helper.h"
57 #include "panel_cntl.h"
59 /* include DCE11 register header files */
60 #include "dce/dce_11_0_d.h"
61 #include "dce/dce_11_0_sh_mask.h"
62 #include "custom_float.h"
64 #include "atomfirmware.h"
66 #include "dce110_hw_sequencer.h"
67 #include "dcn10/dcn10_hw_sequencer.h"
69 #define GAMMA_HW_POINTS_NUM 256
72 * All values are in milliseconds;
73 * For eDP, after power-up/power/down,
74 * 300/500 msec max. delay from LCDVCC to black video generation
76 #define PANEL_POWER_UP_TIMEOUT 300
77 #define PANEL_POWER_DOWN_TIMEOUT 500
78 #define HPD_CHECK_INTERVAL 10
79 #define OLED_POST_T7_DELAY 100
80 #define OLED_PRE_T11_DELAY 150
85 #define DC_LOGGER_INIT()
91 #define FN(reg_name, field_name) \
92 hws->shifts->field_name, hws->masks->field_name
94 struct dce110_hw_seq_reg_offsets {
98 static const struct dce110_hw_seq_reg_offsets reg_offsets[] = {
100 .crtc = (mmCRTC0_CRTC_GSL_CONTROL - mmCRTC_GSL_CONTROL),
103 .crtc = (mmCRTC1_CRTC_GSL_CONTROL - mmCRTC_GSL_CONTROL),
106 .crtc = (mmCRTC2_CRTC_GSL_CONTROL - mmCRTC_GSL_CONTROL),
109 .crtc = (mmCRTCV_GSL_CONTROL - mmCRTC_GSL_CONTROL),
113 #define HW_REG_BLND(reg, id)\
114 (reg + reg_offsets[id].blnd)
116 #define HW_REG_CRTC(reg, id)\
117 (reg + reg_offsets[id].crtc)
119 #define MAX_WATERMARK 0xFFFF
120 #define SAFE_NBP_MARK 0x7FFF
122 /*******************************************************************************
123 * Private definitions
124 ******************************************************************************/
125 /***************************PIPE_CONTROL***********************************/
126 static void dce110_init_pte(struct dc_context *ctx)
130 uint32_t chunk_int = 0;
131 uint32_t chunk_mul = 0;
133 addr = mmUNP_DVMM_PTE_CONTROL;
134 value = dm_read_reg(ctx, addr);
140 DVMM_USE_SINGLE_PTE);
146 DVMM_PTE_BUFFER_MODE0);
152 DVMM_PTE_BUFFER_MODE1);
154 dm_write_reg(ctx, addr, value);
156 addr = mmDVMM_PTE_REQ;
157 value = dm_read_reg(ctx, addr);
159 chunk_int = get_reg_field_value(
162 HFLIP_PTEREQ_PER_CHUNK_INT);
164 chunk_mul = get_reg_field_value(
167 HFLIP_PTEREQ_PER_CHUNK_MULTIPLIER);
169 if (chunk_int != 0x4 || chunk_mul != 0x4) {
175 MAX_PTEREQ_TO_ISSUE);
181 HFLIP_PTEREQ_PER_CHUNK_INT);
187 HFLIP_PTEREQ_PER_CHUNK_MULTIPLIER);
189 dm_write_reg(ctx, addr, value);
192 /**************************************************************************/
194 static void enable_display_pipe_clock_gating(
195 struct dc_context *ctx,
201 static bool dce110_enable_display_power_gating(
203 uint8_t controller_id,
205 enum pipe_gating_control power_gating)
207 enum bp_result bp_result = BP_RESULT_OK;
208 enum bp_pipe_control_action cntl;
209 struct dc_context *ctx = dc->ctx;
210 unsigned int underlay_idx = dc->res_pool->underlay_pipe_index;
212 if (IS_FPGA_MAXIMUS_DC(ctx->dce_environment))
215 if (power_gating == PIPE_GATING_CONTROL_INIT)
216 cntl = ASIC_PIPE_INIT;
217 else if (power_gating == PIPE_GATING_CONTROL_ENABLE)
218 cntl = ASIC_PIPE_ENABLE;
220 cntl = ASIC_PIPE_DISABLE;
222 if (controller_id == underlay_idx)
223 controller_id = CONTROLLER_ID_UNDERLAY0 - 1;
225 if (power_gating != PIPE_GATING_CONTROL_INIT || controller_id == 0){
227 bp_result = dcb->funcs->enable_disp_power_gating(
228 dcb, controller_id + 1, cntl);
230 /* Revert MASTER_UPDATE_MODE to 0 because bios sets it 2
231 * by default when command table is called
233 * Bios parser accepts controller_id = 6 as indicative of
234 * underlay pipe in dce110. But we do not support more
237 if (controller_id < CONTROLLER_ID_MAX - 1)
239 HW_REG_CRTC(mmCRTC_MASTER_UPDATE_MODE, controller_id),
243 if (power_gating != PIPE_GATING_CONTROL_ENABLE)
244 dce110_init_pte(ctx);
246 if (bp_result == BP_RESULT_OK)
252 static void build_prescale_params(struct ipp_prescale_params *prescale_params,
253 const struct dc_plane_state *plane_state)
255 prescale_params->mode = IPP_PRESCALE_MODE_FIXED_UNSIGNED;
257 switch (plane_state->format) {
258 case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
259 prescale_params->scale = 0x2082;
261 case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
262 case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
263 prescale_params->scale = 0x2020;
265 case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
266 case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
267 prescale_params->scale = 0x2008;
269 case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
270 case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
271 case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
272 prescale_params->scale = 0x2000;
281 dce110_set_input_transfer_func(struct dc *dc, struct pipe_ctx *pipe_ctx,
282 const struct dc_plane_state *plane_state)
284 struct input_pixel_processor *ipp = pipe_ctx->plane_res.ipp;
285 const struct dc_transfer_func *tf = NULL;
286 struct ipp_prescale_params prescale_params = { 0 };
292 if (plane_state->in_transfer_func)
293 tf = plane_state->in_transfer_func;
295 build_prescale_params(&prescale_params, plane_state);
296 ipp->funcs->ipp_program_prescale(ipp, &prescale_params);
298 if (plane_state->gamma_correction &&
299 !plane_state->gamma_correction->is_identity &&
300 dce_use_lut(plane_state->format))
301 ipp->funcs->ipp_program_input_lut(ipp, plane_state->gamma_correction);
304 /* Default case if no input transfer function specified */
305 ipp->funcs->ipp_set_degamma(ipp, IPP_DEGAMMA_MODE_HW_sRGB);
306 } else if (tf->type == TF_TYPE_PREDEFINED) {
308 case TRANSFER_FUNCTION_SRGB:
309 ipp->funcs->ipp_set_degamma(ipp, IPP_DEGAMMA_MODE_HW_sRGB);
311 case TRANSFER_FUNCTION_BT709:
312 ipp->funcs->ipp_set_degamma(ipp, IPP_DEGAMMA_MODE_HW_xvYCC);
314 case TRANSFER_FUNCTION_LINEAR:
315 ipp->funcs->ipp_set_degamma(ipp, IPP_DEGAMMA_MODE_BYPASS);
317 case TRANSFER_FUNCTION_PQ:
322 } else if (tf->type == TF_TYPE_BYPASS) {
323 ipp->funcs->ipp_set_degamma(ipp, IPP_DEGAMMA_MODE_BYPASS);
325 /*TF_TYPE_DISTRIBUTED_POINTS - Not supported in DCE 11*/
332 static bool convert_to_custom_float(struct pwl_result_data *rgb_resulted,
333 struct curve_points *arr_points,
334 uint32_t hw_points_num)
336 struct custom_float_format fmt;
338 struct pwl_result_data *rgb = rgb_resulted;
342 fmt.exponenta_bits = 6;
343 fmt.mantissa_bits = 12;
346 if (!convert_to_custom_float_format(arr_points[0].x, &fmt,
347 &arr_points[0].custom_float_x)) {
352 if (!convert_to_custom_float_format(arr_points[0].offset, &fmt,
353 &arr_points[0].custom_float_offset)) {
358 if (!convert_to_custom_float_format(arr_points[0].slope, &fmt,
359 &arr_points[0].custom_float_slope)) {
364 fmt.mantissa_bits = 10;
367 if (!convert_to_custom_float_format(arr_points[1].x, &fmt,
368 &arr_points[1].custom_float_x)) {
373 if (!convert_to_custom_float_format(arr_points[1].y, &fmt,
374 &arr_points[1].custom_float_y)) {
379 if (!convert_to_custom_float_format(arr_points[1].slope, &fmt,
380 &arr_points[1].custom_float_slope)) {
385 fmt.mantissa_bits = 12;
388 while (i != hw_points_num) {
389 if (!convert_to_custom_float_format(rgb->red, &fmt,
395 if (!convert_to_custom_float_format(rgb->green, &fmt,
401 if (!convert_to_custom_float_format(rgb->blue, &fmt,
407 if (!convert_to_custom_float_format(rgb->delta_red, &fmt,
408 &rgb->delta_red_reg)) {
413 if (!convert_to_custom_float_format(rgb->delta_green, &fmt,
414 &rgb->delta_green_reg)) {
419 if (!convert_to_custom_float_format(rgb->delta_blue, &fmt,
420 &rgb->delta_blue_reg)) {
432 #define MAX_LOW_POINT 25
433 #define NUMBER_REGIONS 16
434 #define NUMBER_SW_SEGMENTS 16
437 dce110_translate_regamma_to_hw_format(const struct dc_transfer_func *output_tf,
438 struct pwl_params *regamma_params)
440 struct curve_points *arr_points;
441 struct pwl_result_data *rgb_resulted;
442 struct pwl_result_data *rgb;
443 struct pwl_result_data *rgb_plus_1;
444 struct fixed31_32 y_r;
445 struct fixed31_32 y_g;
446 struct fixed31_32 y_b;
447 struct fixed31_32 y1_min;
448 struct fixed31_32 y3_max;
450 int32_t region_start, region_end;
451 uint32_t i, j, k, seg_distr[NUMBER_REGIONS], increment, start_index, hw_points;
453 if (output_tf == NULL || regamma_params == NULL || output_tf->type == TF_TYPE_BYPASS)
456 arr_points = regamma_params->arr_points;
457 rgb_resulted = regamma_params->rgb_resulted;
460 memset(regamma_params, 0, sizeof(struct pwl_params));
462 if (output_tf->tf == TRANSFER_FUNCTION_PQ) {
464 * segments are from 2^-11 to 2^5
467 region_end = region_start + NUMBER_REGIONS;
469 for (i = 0; i < NUMBER_REGIONS; i++)
474 * segment is from 2^-10 to 2^1
475 * We include an extra segment for range [2^0, 2^1). This is to
476 * ensure that colors with normalized values of 1 don't miss the
500 for (k = 0; k < 16; k++) {
501 if (seg_distr[k] != -1)
502 hw_points += (1 << seg_distr[k]);
506 for (k = 0; k < (region_end - region_start); k++) {
507 increment = NUMBER_SW_SEGMENTS / (1 << seg_distr[k]);
508 start_index = (region_start + k + MAX_LOW_POINT) *
510 for (i = start_index; i < start_index + NUMBER_SW_SEGMENTS;
512 if (j == hw_points - 1)
514 rgb_resulted[j].red = output_tf->tf_pts.red[i];
515 rgb_resulted[j].green = output_tf->tf_pts.green[i];
516 rgb_resulted[j].blue = output_tf->tf_pts.blue[i];
522 start_index = (region_end + MAX_LOW_POINT) * NUMBER_SW_SEGMENTS;
523 rgb_resulted[hw_points - 1].red = output_tf->tf_pts.red[start_index];
524 rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index];
525 rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index];
527 arr_points[0].x = dc_fixpt_pow(dc_fixpt_from_int(2),
528 dc_fixpt_from_int(region_start));
529 arr_points[1].x = dc_fixpt_pow(dc_fixpt_from_int(2),
530 dc_fixpt_from_int(region_end));
532 y_r = rgb_resulted[0].red;
533 y_g = rgb_resulted[0].green;
534 y_b = rgb_resulted[0].blue;
536 y1_min = dc_fixpt_min(y_r, dc_fixpt_min(y_g, y_b));
538 arr_points[0].y = y1_min;
539 arr_points[0].slope = dc_fixpt_div(arr_points[0].y,
542 y_r = rgb_resulted[hw_points - 1].red;
543 y_g = rgb_resulted[hw_points - 1].green;
544 y_b = rgb_resulted[hw_points - 1].blue;
546 /* see comment above, m_arrPoints[1].y should be the Y value for the
547 * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1)
549 y3_max = dc_fixpt_max(y_r, dc_fixpt_max(y_g, y_b));
551 arr_points[1].y = y3_max;
553 arr_points[1].slope = dc_fixpt_zero;
555 if (output_tf->tf == TRANSFER_FUNCTION_PQ) {
556 /* for PQ, we want to have a straight line from last HW X point,
557 * and the slope to be such that we hit 1.0 at 10000 nits.
559 const struct fixed31_32 end_value = dc_fixpt_from_int(125);
561 arr_points[1].slope = dc_fixpt_div(
562 dc_fixpt_sub(dc_fixpt_one, arr_points[1].y),
563 dc_fixpt_sub(end_value, arr_points[1].x));
566 regamma_params->hw_points_num = hw_points;
569 for (i = 1; i < 16; i++) {
570 if (seg_distr[k] != -1) {
571 regamma_params->arr_curve_points[k].segments_num = seg_distr[k];
572 regamma_params->arr_curve_points[i].offset =
573 regamma_params->arr_curve_points[k].offset + (1 << seg_distr[k]);
578 if (seg_distr[k] != -1)
579 regamma_params->arr_curve_points[k].segments_num = seg_distr[k];
582 rgb_plus_1 = rgb_resulted + 1;
586 while (i != hw_points + 1) {
587 if (dc_fixpt_lt(rgb_plus_1->red, rgb->red))
588 rgb_plus_1->red = rgb->red;
589 if (dc_fixpt_lt(rgb_plus_1->green, rgb->green))
590 rgb_plus_1->green = rgb->green;
591 if (dc_fixpt_lt(rgb_plus_1->blue, rgb->blue))
592 rgb_plus_1->blue = rgb->blue;
594 rgb->delta_red = dc_fixpt_sub(rgb_plus_1->red, rgb->red);
595 rgb->delta_green = dc_fixpt_sub(rgb_plus_1->green, rgb->green);
596 rgb->delta_blue = dc_fixpt_sub(rgb_plus_1->blue, rgb->blue);
603 convert_to_custom_float(rgb_resulted, arr_points, hw_points);
609 dce110_set_output_transfer_func(struct dc *dc, struct pipe_ctx *pipe_ctx,
610 const struct dc_stream_state *stream)
612 struct transform *xfm = pipe_ctx->plane_res.xfm;
614 xfm->funcs->opp_power_on_regamma_lut(xfm, true);
615 xfm->regamma_params.hw_points_num = GAMMA_HW_POINTS_NUM;
617 if (stream->out_transfer_func &&
618 stream->out_transfer_func->type == TF_TYPE_PREDEFINED &&
619 stream->out_transfer_func->tf == TRANSFER_FUNCTION_SRGB) {
620 xfm->funcs->opp_set_regamma_mode(xfm, OPP_REGAMMA_SRGB);
621 } else if (dce110_translate_regamma_to_hw_format(stream->out_transfer_func,
622 &xfm->regamma_params)) {
623 xfm->funcs->opp_program_regamma_pwl(xfm, &xfm->regamma_params);
624 xfm->funcs->opp_set_regamma_mode(xfm, OPP_REGAMMA_USER);
626 xfm->funcs->opp_set_regamma_mode(xfm, OPP_REGAMMA_BYPASS);
629 xfm->funcs->opp_power_on_regamma_lut(xfm, false);
634 void dce110_update_info_frame(struct pipe_ctx *pipe_ctx)
639 ASSERT(pipe_ctx->stream);
641 if (pipe_ctx->stream_res.stream_enc == NULL)
642 return; /* this is not root pipe */
644 is_hdmi_tmds = dc_is_hdmi_tmds_signal(pipe_ctx->stream->signal);
645 is_dp = dc_is_dp_signal(pipe_ctx->stream->signal);
647 if (!is_hdmi_tmds && !is_dp)
651 pipe_ctx->stream_res.stream_enc->funcs->update_hdmi_info_packets(
652 pipe_ctx->stream_res.stream_enc,
653 &pipe_ctx->stream_res.encoder_info_frame);
655 pipe_ctx->stream_res.stream_enc->funcs->update_dp_info_packets(
656 pipe_ctx->stream_res.stream_enc,
657 &pipe_ctx->stream_res.encoder_info_frame);
660 void dce110_enable_stream(struct pipe_ctx *pipe_ctx)
662 enum dc_lane_count lane_count =
663 pipe_ctx->stream->link->cur_link_settings.lane_count;
664 struct dc_crtc_timing *timing = &pipe_ctx->stream->timing;
665 struct dc_link *link = pipe_ctx->stream->link;
666 const struct dc *dc = link->dc;
668 uint32_t active_total_with_borders;
669 uint32_t early_control = 0;
670 struct timing_generator *tg = pipe_ctx->stream_res.tg;
672 /* For MST, there are multiply stream go to only one link.
673 * connect DIG back_end to front_end while enable_stream and
674 * disconnect them during disable_stream
675 * BY this, it is logic clean to separate stream and link */
676 link->link_enc->funcs->connect_dig_be_to_fe(link->link_enc,
677 pipe_ctx->stream_res.stream_enc->id, true);
679 dc->hwss.update_info_frame(pipe_ctx);
681 /* enable early control to avoid corruption on DP monitor*/
682 active_total_with_borders =
683 timing->h_addressable
684 + timing->h_border_left
685 + timing->h_border_right;
688 early_control = active_total_with_borders % lane_count;
690 if (early_control == 0)
691 early_control = lane_count;
693 tg->funcs->set_early_control(tg, early_control);
695 /* enable audio only within mode set */
696 if (pipe_ctx->stream_res.audio != NULL) {
697 if (dc_is_dp_signal(pipe_ctx->stream->signal))
698 pipe_ctx->stream_res.stream_enc->funcs->dp_audio_enable(pipe_ctx->stream_res.stream_enc);
706 static enum bp_result link_transmitter_control(
707 struct dc_bios *bios,
708 struct bp_transmitter_control *cntl)
710 enum bp_result result;
712 result = bios->funcs->transmitter_control(bios, cntl);
721 void dce110_edp_wait_for_hpd_ready(
722 struct dc_link *link,
725 struct dc_context *ctx = link->ctx;
726 struct graphics_object_id connector = link->link_enc->connector;
728 struct dc_sink *sink = link->local_sink;
729 bool edp_hpd_high = false;
730 uint32_t time_elapsed = 0;
731 uint32_t timeout = power_up ?
732 PANEL_POWER_UP_TIMEOUT : PANEL_POWER_DOWN_TIMEOUT;
734 if (dal_graphics_object_id_get_connector_id(connector)
735 != CONNECTOR_ID_EDP) {
742 * From KV, we will not HPD low after turning off VCC -
743 * instead, we will check the SW timer in power_up().
748 * When we power on/off the eDP panel,
749 * we need to wait until SENSE bit is high/low.
753 /* TODO what to do with this? */
754 hpd = get_hpd_gpio(ctx->dc_bios, connector, ctx->gpio_service);
762 if (sink->edid_caps.panel_patch.extra_t3_ms > 0) {
763 int extra_t3_in_ms = sink->edid_caps.panel_patch.extra_t3_ms;
765 msleep(extra_t3_in_ms);
769 dal_gpio_open(hpd, GPIO_MODE_INTERRUPT);
771 /* wait until timeout or panel detected */
774 uint32_t detected = 0;
776 dal_gpio_get_value(hpd, &detected);
778 if (!(detected ^ power_up)) {
783 msleep(HPD_CHECK_INTERVAL);
785 time_elapsed += HPD_CHECK_INTERVAL;
786 } while (time_elapsed < timeout);
790 dal_gpio_destroy_irq(&hpd);
792 if (false == edp_hpd_high) {
794 "%s: wait timed out!\n", __func__);
798 void dce110_edp_power_control(
799 struct dc_link *link,
802 struct dc_context *ctx = link->ctx;
803 struct bp_transmitter_control cntl = { 0 };
804 enum bp_result bp_result;
805 uint8_t panel_instance;
808 if (dal_graphics_object_id_get_connector_id(link->link_enc->connector)
809 != CONNECTOR_ID_EDP) {
814 if (!link->panel_cntl)
817 link->panel_cntl->funcs->is_panel_powered_on(link->panel_cntl)) {
819 unsigned long long current_ts = dm_get_timestamp(ctx);
820 unsigned long long time_since_edp_poweroff_ms =
821 div64_u64(dm_get_elapse_time_in_ns(
824 link->link_trace.time_stamp.edp_poweroff), 1000000);
825 unsigned long long time_since_edp_poweron_ms =
826 div64_u64(dm_get_elapse_time_in_ns(
829 link->link_trace.time_stamp.edp_poweron), 1000000);
831 "%s: transition: power_up=%d current_ts=%llu edp_poweroff=%llu edp_poweron=%llu time_since_edp_poweroff_ms=%llu time_since_edp_poweron_ms=%llu",
835 link->link_trace.time_stamp.edp_poweroff,
836 link->link_trace.time_stamp.edp_poweron,
837 time_since_edp_poweroff_ms,
838 time_since_edp_poweron_ms);
840 /* Send VBIOS command to prompt eDP panel power */
842 /* edp requires a min of 500ms from LCDVDD off to on */
843 unsigned long long remaining_min_edp_poweroff_time_ms = 500;
845 /* add time defined by a patch, if any (usually patch extra_t12_ms is 0) */
846 if (link->local_sink != NULL)
847 remaining_min_edp_poweroff_time_ms +=
848 link->local_sink->edid_caps.panel_patch.extra_t12_ms;
850 /* Adjust remaining_min_edp_poweroff_time_ms if this is not the first time. */
851 if (link->link_trace.time_stamp.edp_poweroff != 0) {
852 if (time_since_edp_poweroff_ms < remaining_min_edp_poweroff_time_ms)
853 remaining_min_edp_poweroff_time_ms =
854 remaining_min_edp_poweroff_time_ms - time_since_edp_poweroff_ms;
856 remaining_min_edp_poweroff_time_ms = 0;
859 if (remaining_min_edp_poweroff_time_ms) {
861 "%s: remaining_min_edp_poweroff_time_ms=%llu: begin wait.\n",
862 __func__, remaining_min_edp_poweroff_time_ms);
863 msleep(remaining_min_edp_poweroff_time_ms);
865 "%s: remaining_min_edp_poweroff_time_ms=%llu: end wait.\n",
866 __func__, remaining_min_edp_poweroff_time_ms);
867 dm_output_to_console("%s: wait %lld ms to power on eDP.\n",
868 __func__, remaining_min_edp_poweroff_time_ms);
871 "%s: remaining_min_edp_poweroff_time_ms=%llu: no wait required.\n",
872 __func__, remaining_min_edp_poweroff_time_ms);
877 "%s: BEGIN: Panel Power action: %s\n",
878 __func__, (power_up ? "On":"Off"));
880 cntl.action = power_up ?
881 TRANSMITTER_CONTROL_POWER_ON :
882 TRANSMITTER_CONTROL_POWER_OFF;
883 cntl.transmitter = link->link_enc->transmitter;
884 cntl.connector_obj_id = link->link_enc->connector;
885 cntl.coherent = false;
886 cntl.lanes_number = LANE_COUNT_FOUR;
887 cntl.hpd_sel = link->link_enc->hpd_source;
888 panel_instance = link->panel_cntl->inst;
890 if (ctx->dc->ctx->dmub_srv &&
891 ctx->dc->debug.dmub_command_table) {
892 if (cntl.action == TRANSMITTER_CONTROL_POWER_ON)
893 bp_result = ctx->dc_bios->funcs->enable_lvtma_control(ctx->dc_bios,
894 LVTMA_CONTROL_POWER_ON,
897 bp_result = ctx->dc_bios->funcs->enable_lvtma_control(ctx->dc_bios,
898 LVTMA_CONTROL_POWER_OFF,
902 bp_result = link_transmitter_control(ctx->dc_bios, &cntl);
905 "%s: END: Panel Power action: %s bp_result=%u\n",
906 __func__, (power_up ? "On":"Off"),
910 /*save driver power off time stamp*/
911 link->link_trace.time_stamp.edp_poweroff = dm_get_timestamp(ctx);
913 link->link_trace.time_stamp.edp_poweron = dm_get_timestamp(ctx);
916 "%s: updated values: edp_poweroff=%llu edp_poweron=%llu\n",
918 link->link_trace.time_stamp.edp_poweroff,
919 link->link_trace.time_stamp.edp_poweron);
921 if (bp_result != BP_RESULT_OK)
923 "%s: Panel Power bp_result: %d\n",
924 __func__, bp_result);
927 "%s: Skipping Panel Power action: %s\n",
928 __func__, (power_up ? "On":"Off"));
932 void dce110_edp_wait_for_T12(
933 struct dc_link *link)
935 struct dc_context *ctx = link->ctx;
937 if (dal_graphics_object_id_get_connector_id(link->link_enc->connector)
938 != CONNECTOR_ID_EDP) {
943 if (!link->panel_cntl)
946 if (!link->panel_cntl->funcs->is_panel_powered_on(link->panel_cntl) &&
947 link->link_trace.time_stamp.edp_poweroff != 0) {
948 unsigned int t12_duration = 500; // Default T12 as per spec
949 unsigned long long current_ts = dm_get_timestamp(ctx);
950 unsigned long long time_since_edp_poweroff_ms =
951 div64_u64(dm_get_elapse_time_in_ns(
954 link->link_trace.time_stamp.edp_poweroff), 1000000);
956 t12_duration += link->local_sink->edid_caps.panel_patch.extra_t12_ms; // Add extra T12
958 if (time_since_edp_poweroff_ms < t12_duration)
959 msleep(t12_duration - time_since_edp_poweroff_ms);
963 /*todo: cloned in stream enc, fix*/
966 * eDP only. Control the backlight of the eDP panel
968 void dce110_edp_backlight_control(
969 struct dc_link *link,
972 struct dc_context *ctx = link->ctx;
973 struct bp_transmitter_control cntl = { 0 };
974 uint8_t panel_instance;
976 if (dal_graphics_object_id_get_connector_id(link->link_enc->connector)
977 != CONNECTOR_ID_EDP) {
982 if (link->panel_cntl) {
983 bool is_backlight_on = link->panel_cntl->funcs->is_panel_backlight_on(link->panel_cntl);
985 if ((enable && is_backlight_on) || (!enable && !is_backlight_on)) {
987 "%s: panel already powered up/off. Do nothing.\n",
993 /* Send VBIOS command to control eDP panel backlight */
996 "%s: backlight action: %s\n",
997 __func__, (enable ? "On":"Off"));
999 cntl.action = enable ?
1000 TRANSMITTER_CONTROL_BACKLIGHT_ON :
1001 TRANSMITTER_CONTROL_BACKLIGHT_OFF;
1003 /*cntl.engine_id = ctx->engine;*/
1004 cntl.transmitter = link->link_enc->transmitter;
1005 cntl.connector_obj_id = link->link_enc->connector;
1006 /*todo: unhardcode*/
1007 cntl.lanes_number = LANE_COUNT_FOUR;
1008 cntl.hpd_sel = link->link_enc->hpd_source;
1009 cntl.signal = SIGNAL_TYPE_EDP;
1011 /* For eDP, the following delays might need to be considered
1012 * after link training completed:
1013 * idle period - min. accounts for required BS-Idle pattern,
1014 * max. allows for source frame synchronization);
1015 * 50 msec max. delay from valid video data from source
1016 * to video on dislpay or backlight enable.
1018 * Disable the delay for now.
1019 * Enable it in the future if necessary.
1021 /* dc_service_sleep_in_milliseconds(50); */
1023 panel_instance = link->panel_cntl->inst;
1024 if (cntl.action == TRANSMITTER_CONTROL_BACKLIGHT_ON)
1025 edp_receiver_ready_T7(link);
1027 if (ctx->dc->ctx->dmub_srv &&
1028 ctx->dc->debug.dmub_command_table) {
1029 if (cntl.action == TRANSMITTER_CONTROL_BACKLIGHT_ON)
1030 ctx->dc_bios->funcs->enable_lvtma_control(ctx->dc_bios,
1031 LVTMA_CONTROL_LCD_BLON,
1034 ctx->dc_bios->funcs->enable_lvtma_control(ctx->dc_bios,
1035 LVTMA_CONTROL_LCD_BLOFF,
1039 link_transmitter_control(ctx->dc_bios, &cntl);
1041 if (enable && link->dpcd_sink_ext_caps.bits.oled)
1042 msleep(OLED_POST_T7_DELAY);
1044 if (link->dpcd_sink_ext_caps.bits.oled ||
1045 link->dpcd_sink_ext_caps.bits.hdr_aux_backlight_control == 1 ||
1046 link->dpcd_sink_ext_caps.bits.sdr_aux_backlight_control == 1)
1047 dc_link_backlight_enable_aux(link, enable);
1050 if (cntl.action == TRANSMITTER_CONTROL_BACKLIGHT_OFF)
1051 edp_add_delay_for_T9(link);
1053 if (!enable && link->dpcd_sink_ext_caps.bits.oled)
1054 msleep(OLED_PRE_T11_DELAY);
1057 void dce110_enable_audio_stream(struct pipe_ctx *pipe_ctx)
1059 /* notify audio driver for audio modes of monitor */
1061 struct clk_mgr *clk_mgr;
1062 unsigned int i, num_audio = 1;
1064 if (!pipe_ctx->stream)
1067 dc = pipe_ctx->stream->ctx->dc;
1068 clk_mgr = dc->clk_mgr;
1070 if (pipe_ctx->stream_res.audio && pipe_ctx->stream_res.audio->enabled == true)
1073 if (pipe_ctx->stream_res.audio) {
1074 for (i = 0; i < MAX_PIPES; i++) {
1075 /*current_state not updated yet*/
1076 if (dc->current_state->res_ctx.pipe_ctx[i].stream_res.audio != NULL)
1080 pipe_ctx->stream_res.audio->funcs->az_enable(pipe_ctx->stream_res.audio);
1082 if (num_audio >= 1 && clk_mgr->funcs->enable_pme_wa)
1083 /*this is the first audio. apply the PME w/a in order to wake AZ from D3*/
1084 clk_mgr->funcs->enable_pme_wa(clk_mgr);
1086 /* TODO: audio should be per stream rather than per link */
1087 pipe_ctx->stream_res.stream_enc->funcs->audio_mute_control(
1088 pipe_ctx->stream_res.stream_enc, false);
1089 if (pipe_ctx->stream_res.audio)
1090 pipe_ctx->stream_res.audio->enabled = true;
1094 void dce110_disable_audio_stream(struct pipe_ctx *pipe_ctx)
1097 struct clk_mgr *clk_mgr;
1099 if (!pipe_ctx || !pipe_ctx->stream)
1102 dc = pipe_ctx->stream->ctx->dc;
1103 clk_mgr = dc->clk_mgr;
1105 if (pipe_ctx->stream_res.audio && pipe_ctx->stream_res.audio->enabled == false)
1108 pipe_ctx->stream_res.stream_enc->funcs->audio_mute_control(
1109 pipe_ctx->stream_res.stream_enc, true);
1110 if (pipe_ctx->stream_res.audio) {
1111 pipe_ctx->stream_res.audio->enabled = false;
1113 if (dc_is_dp_signal(pipe_ctx->stream->signal))
1114 pipe_ctx->stream_res.stream_enc->funcs->dp_audio_disable(
1115 pipe_ctx->stream_res.stream_enc);
1117 pipe_ctx->stream_res.stream_enc->funcs->hdmi_audio_disable(
1118 pipe_ctx->stream_res.stream_enc);
1120 if (clk_mgr->funcs->enable_pme_wa)
1121 /*this is the first audio. apply the PME w/a in order to wake AZ from D3*/
1122 clk_mgr->funcs->enable_pme_wa(clk_mgr);
1124 /* TODO: notify audio driver for if audio modes list changed
1125 * add audio mode list change flag */
1126 /* dal_audio_disable_azalia_audio_jack_presence(stream->audio,
1127 * stream->stream_engine_id);
1132 void dce110_disable_stream(struct pipe_ctx *pipe_ctx)
1134 struct dc_stream_state *stream = pipe_ctx->stream;
1135 struct dc_link *link = stream->link;
1136 struct dc *dc = pipe_ctx->stream->ctx->dc;
1138 if (dc_is_hdmi_tmds_signal(pipe_ctx->stream->signal)) {
1139 pipe_ctx->stream_res.stream_enc->funcs->stop_hdmi_info_packets(
1140 pipe_ctx->stream_res.stream_enc);
1141 pipe_ctx->stream_res.stream_enc->funcs->hdmi_reset_stream_attribute(
1142 pipe_ctx->stream_res.stream_enc);
1145 if (dc_is_dp_signal(pipe_ctx->stream->signal))
1146 pipe_ctx->stream_res.stream_enc->funcs->stop_dp_info_packets(
1147 pipe_ctx->stream_res.stream_enc);
1149 dc->hwss.disable_audio_stream(pipe_ctx);
1151 link->link_enc->funcs->connect_dig_be_to_fe(
1153 pipe_ctx->stream_res.stream_enc->id,
1158 void dce110_unblank_stream(struct pipe_ctx *pipe_ctx,
1159 struct dc_link_settings *link_settings)
1161 struct encoder_unblank_param params = { { 0 } };
1162 struct dc_stream_state *stream = pipe_ctx->stream;
1163 struct dc_link *link = stream->link;
1164 struct dce_hwseq *hws = link->dc->hwseq;
1166 /* only 3 items below are used by unblank */
1167 params.timing = pipe_ctx->stream->timing;
1168 params.link_settings.link_rate = link_settings->link_rate;
1170 if (dc_is_dp_signal(pipe_ctx->stream->signal))
1171 pipe_ctx->stream_res.stream_enc->funcs->dp_unblank(pipe_ctx->stream_res.stream_enc, ¶ms);
1173 if (link->local_sink && link->local_sink->sink_signal == SIGNAL_TYPE_EDP) {
1174 hws->funcs.edp_backlight_control(link, true);
1178 void dce110_blank_stream(struct pipe_ctx *pipe_ctx)
1180 struct dc_stream_state *stream = pipe_ctx->stream;
1181 struct dc_link *link = stream->link;
1182 struct dce_hwseq *hws = link->dc->hwseq;
1184 if (link->local_sink && link->local_sink->sink_signal == SIGNAL_TYPE_EDP) {
1185 hws->funcs.edp_backlight_control(link, false);
1186 link->dc->hwss.set_abm_immediate_disable(pipe_ctx);
1189 if (dc_is_dp_signal(pipe_ctx->stream->signal)) {
1190 pipe_ctx->stream_res.stream_enc->funcs->dp_blank(pipe_ctx->stream_res.stream_enc);
1192 if (!dc_is_embedded_signal(pipe_ctx->stream->signal)) {
1194 * After output is idle pattern some sinks need time to recognize the stream
1195 * has changed or they enter protection state and hang.
1198 } else if (pipe_ctx->stream->signal == SIGNAL_TYPE_EDP)
1199 edp_receiver_ready_T9(link);
1205 void dce110_set_avmute(struct pipe_ctx *pipe_ctx, bool enable)
1207 if (pipe_ctx != NULL && pipe_ctx->stream_res.stream_enc != NULL)
1208 pipe_ctx->stream_res.stream_enc->funcs->set_avmute(pipe_ctx->stream_res.stream_enc, enable);
1211 static enum audio_dto_source translate_to_dto_source(enum controller_id crtc_id)
1214 case CONTROLLER_ID_D0:
1215 return DTO_SOURCE_ID0;
1216 case CONTROLLER_ID_D1:
1217 return DTO_SOURCE_ID1;
1218 case CONTROLLER_ID_D2:
1219 return DTO_SOURCE_ID2;
1220 case CONTROLLER_ID_D3:
1221 return DTO_SOURCE_ID3;
1222 case CONTROLLER_ID_D4:
1223 return DTO_SOURCE_ID4;
1224 case CONTROLLER_ID_D5:
1225 return DTO_SOURCE_ID5;
1227 return DTO_SOURCE_UNKNOWN;
1231 static void build_audio_output(
1232 struct dc_state *state,
1233 const struct pipe_ctx *pipe_ctx,
1234 struct audio_output *audio_output)
1236 const struct dc_stream_state *stream = pipe_ctx->stream;
1237 audio_output->engine_id = pipe_ctx->stream_res.stream_enc->id;
1239 audio_output->signal = pipe_ctx->stream->signal;
1241 /* audio_crtc_info */
1243 audio_output->crtc_info.h_total =
1244 stream->timing.h_total;
1247 * Audio packets are sent during actual CRTC blank physical signal, we
1248 * need to specify actual active signal portion
1250 audio_output->crtc_info.h_active =
1251 stream->timing.h_addressable
1252 + stream->timing.h_border_left
1253 + stream->timing.h_border_right;
1255 audio_output->crtc_info.v_active =
1256 stream->timing.v_addressable
1257 + stream->timing.v_border_top
1258 + stream->timing.v_border_bottom;
1260 audio_output->crtc_info.pixel_repetition = 1;
1262 audio_output->crtc_info.interlaced =
1263 stream->timing.flags.INTERLACE;
1265 audio_output->crtc_info.refresh_rate =
1266 (stream->timing.pix_clk_100hz*100)/
1267 (stream->timing.h_total*stream->timing.v_total);
1269 audio_output->crtc_info.color_depth =
1270 stream->timing.display_color_depth;
1272 audio_output->crtc_info.requested_pixel_clock_100Hz =
1273 pipe_ctx->stream_res.pix_clk_params.requested_pix_clk_100hz;
1275 audio_output->crtc_info.calculated_pixel_clock_100Hz =
1276 pipe_ctx->stream_res.pix_clk_params.requested_pix_clk_100hz;
1278 /*for HDMI, audio ACR is with deep color ratio factor*/
1279 if (dc_is_hdmi_tmds_signal(pipe_ctx->stream->signal) &&
1280 audio_output->crtc_info.requested_pixel_clock_100Hz ==
1281 (stream->timing.pix_clk_100hz)) {
1282 if (pipe_ctx->stream_res.pix_clk_params.pixel_encoding == PIXEL_ENCODING_YCBCR420) {
1283 audio_output->crtc_info.requested_pixel_clock_100Hz =
1284 audio_output->crtc_info.requested_pixel_clock_100Hz/2;
1285 audio_output->crtc_info.calculated_pixel_clock_100Hz =
1286 pipe_ctx->stream_res.pix_clk_params.requested_pix_clk_100hz/2;
1291 if (state->clk_mgr &&
1292 (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT ||
1293 pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST)) {
1294 audio_output->pll_info.dp_dto_source_clock_in_khz =
1295 state->clk_mgr->funcs->get_dp_ref_clk_frequency(
1299 audio_output->pll_info.feed_back_divider =
1300 pipe_ctx->pll_settings.feedback_divider;
1302 audio_output->pll_info.dto_source =
1303 translate_to_dto_source(
1304 pipe_ctx->stream_res.tg->inst + 1);
1306 /* TODO hard code to enable for now. Need get from stream */
1307 audio_output->pll_info.ss_enabled = true;
1309 audio_output->pll_info.ss_percentage =
1310 pipe_ctx->pll_settings.ss_percentage;
1313 static void get_surface_visual_confirm_color(const struct pipe_ctx *pipe_ctx,
1314 struct tg_color *color)
1316 uint32_t color_value = MAX_TG_COLOR_VALUE * (4 - pipe_ctx->stream_res.tg->inst) / 4;
1318 switch (pipe_ctx->plane_res.scl_data.format) {
1319 case PIXEL_FORMAT_ARGB8888:
1320 /* set boarder color to red */
1321 color->color_r_cr = color_value;
1324 case PIXEL_FORMAT_ARGB2101010:
1325 /* set boarder color to blue */
1326 color->color_b_cb = color_value;
1328 case PIXEL_FORMAT_420BPP8:
1329 /* set boarder color to green */
1330 color->color_g_y = color_value;
1332 case PIXEL_FORMAT_420BPP10:
1333 /* set boarder color to yellow */
1334 color->color_g_y = color_value;
1335 color->color_r_cr = color_value;
1337 case PIXEL_FORMAT_FP16:
1338 /* set boarder color to white */
1339 color->color_r_cr = color_value;
1340 color->color_b_cb = color_value;
1341 color->color_g_y = color_value;
1348 static void program_scaler(const struct dc *dc,
1349 const struct pipe_ctx *pipe_ctx)
1351 struct tg_color color = {0};
1353 #if defined(CONFIG_DRM_AMD_DC_DCN)
1355 if (pipe_ctx->plane_res.xfm->funcs->transform_set_pixel_storage_depth == NULL)
1359 if (dc->debug.visual_confirm == VISUAL_CONFIRM_SURFACE)
1360 get_surface_visual_confirm_color(pipe_ctx, &color);
1362 color_space_to_black_color(dc,
1363 pipe_ctx->stream->output_color_space,
1366 pipe_ctx->plane_res.xfm->funcs->transform_set_pixel_storage_depth(
1367 pipe_ctx->plane_res.xfm,
1368 pipe_ctx->plane_res.scl_data.lb_params.depth,
1369 &pipe_ctx->stream->bit_depth_params);
1371 if (pipe_ctx->stream_res.tg->funcs->set_overscan_blank_color) {
1373 * The way 420 is packed, 2 channels carry Y component, 1 channel
1374 * alternate between Cb and Cr, so both channels need the pixel
1377 if (pipe_ctx->stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR420)
1378 color.color_r_cr = color.color_g_y;
1380 pipe_ctx->stream_res.tg->funcs->set_overscan_blank_color(
1381 pipe_ctx->stream_res.tg,
1385 pipe_ctx->plane_res.xfm->funcs->transform_set_scaler(pipe_ctx->plane_res.xfm,
1386 &pipe_ctx->plane_res.scl_data);
1389 static enum dc_status dce110_enable_stream_timing(
1390 struct pipe_ctx *pipe_ctx,
1391 struct dc_state *context,
1394 struct dc_stream_state *stream = pipe_ctx->stream;
1395 struct pipe_ctx *pipe_ctx_old = &dc->current_state->res_ctx.
1396 pipe_ctx[pipe_ctx->pipe_idx];
1397 struct tg_color black_color = {0};
1399 if (!pipe_ctx_old->stream) {
1401 /* program blank color */
1402 color_space_to_black_color(dc,
1403 stream->output_color_space, &black_color);
1404 pipe_ctx->stream_res.tg->funcs->set_blank_color(
1405 pipe_ctx->stream_res.tg,
1409 * Must blank CRTC after disabling power gating and before any
1410 * programming, otherwise CRTC will be hung in bad state
1412 pipe_ctx->stream_res.tg->funcs->set_blank(pipe_ctx->stream_res.tg, true);
1414 if (false == pipe_ctx->clock_source->funcs->program_pix_clk(
1415 pipe_ctx->clock_source,
1416 &pipe_ctx->stream_res.pix_clk_params,
1417 &pipe_ctx->pll_settings)) {
1418 BREAK_TO_DEBUGGER();
1419 return DC_ERROR_UNEXPECTED;
1422 pipe_ctx->stream_res.tg->funcs->program_timing(
1423 pipe_ctx->stream_res.tg,
1429 pipe_ctx->stream->signal,
1433 if (!pipe_ctx_old->stream) {
1434 if (false == pipe_ctx->stream_res.tg->funcs->enable_crtc(
1435 pipe_ctx->stream_res.tg)) {
1436 BREAK_TO_DEBUGGER();
1437 return DC_ERROR_UNEXPECTED;
1444 static enum dc_status apply_single_controller_ctx_to_hw(
1445 struct pipe_ctx *pipe_ctx,
1446 struct dc_state *context,
1449 struct dc_stream_state *stream = pipe_ctx->stream;
1450 struct drr_params params = {0};
1451 unsigned int event_triggers = 0;
1452 struct pipe_ctx *odm_pipe = pipe_ctx->next_odm_pipe;
1453 struct dce_hwseq *hws = dc->hwseq;
1455 if (hws->funcs.disable_stream_gating) {
1456 hws->funcs.disable_stream_gating(dc, pipe_ctx);
1459 if (pipe_ctx->stream_res.audio != NULL) {
1460 struct audio_output audio_output;
1462 build_audio_output(context, pipe_ctx, &audio_output);
1464 if (dc_is_dp_signal(pipe_ctx->stream->signal))
1465 pipe_ctx->stream_res.stream_enc->funcs->dp_audio_setup(
1466 pipe_ctx->stream_res.stream_enc,
1467 pipe_ctx->stream_res.audio->inst,
1468 &pipe_ctx->stream->audio_info);
1470 pipe_ctx->stream_res.stream_enc->funcs->hdmi_audio_setup(
1471 pipe_ctx->stream_res.stream_enc,
1472 pipe_ctx->stream_res.audio->inst,
1473 &pipe_ctx->stream->audio_info,
1474 &audio_output.crtc_info);
1476 pipe_ctx->stream_res.audio->funcs->az_configure(
1477 pipe_ctx->stream_res.audio,
1478 pipe_ctx->stream->signal,
1479 &audio_output.crtc_info,
1480 &pipe_ctx->stream->audio_info);
1484 /* Do not touch stream timing on seamless boot optimization. */
1485 if (!pipe_ctx->stream->apply_seamless_boot_optimization)
1486 hws->funcs.enable_stream_timing(pipe_ctx, context, dc);
1488 if (hws->funcs.setup_vupdate_interrupt)
1489 hws->funcs.setup_vupdate_interrupt(dc, pipe_ctx);
1491 params.vertical_total_min = stream->adjust.v_total_min;
1492 params.vertical_total_max = stream->adjust.v_total_max;
1493 if (pipe_ctx->stream_res.tg->funcs->set_drr)
1494 pipe_ctx->stream_res.tg->funcs->set_drr(
1495 pipe_ctx->stream_res.tg, ¶ms);
1497 // DRR should set trigger event to monitor surface update event
1498 if (stream->adjust.v_total_min != 0 && stream->adjust.v_total_max != 0)
1499 event_triggers = 0x80;
1500 /* Event triggers and num frames initialized for DRR, but can be
1501 * later updated for PSR use. Note DRR trigger events are generated
1502 * regardless of whether num frames met.
1504 if (pipe_ctx->stream_res.tg->funcs->set_static_screen_control)
1505 pipe_ctx->stream_res.tg->funcs->set_static_screen_control(
1506 pipe_ctx->stream_res.tg, event_triggers, 2);
1508 if (!dc_is_virtual_signal(pipe_ctx->stream->signal))
1509 pipe_ctx->stream_res.stream_enc->funcs->dig_connect_to_otg(
1510 pipe_ctx->stream_res.stream_enc,
1511 pipe_ctx->stream_res.tg->inst);
1513 pipe_ctx->stream_res.opp->funcs->opp_set_dyn_expansion(
1514 pipe_ctx->stream_res.opp,
1515 COLOR_SPACE_YCBCR601,
1516 stream->timing.display_color_depth,
1519 pipe_ctx->stream_res.opp->funcs->opp_program_fmt(
1520 pipe_ctx->stream_res.opp,
1521 &stream->bit_depth_params,
1524 odm_pipe->stream_res.opp->funcs->opp_set_dyn_expansion(
1525 odm_pipe->stream_res.opp,
1526 COLOR_SPACE_YCBCR601,
1527 stream->timing.display_color_depth,
1530 odm_pipe->stream_res.opp->funcs->opp_program_fmt(
1531 odm_pipe->stream_res.opp,
1532 &stream->bit_depth_params,
1534 odm_pipe = odm_pipe->next_odm_pipe;
1537 if (!stream->dpms_off)
1538 core_link_enable_stream(context, pipe_ctx);
1540 pipe_ctx->plane_res.scl_data.lb_params.alpha_en = pipe_ctx->bottom_pipe != 0;
1542 pipe_ctx->stream->link->psr_settings.psr_feature_enabled = false;
1547 /******************************************************************************/
1549 static void power_down_encoders(struct dc *dc)
1553 /* do not know BIOS back-front mapping, simply blank all. It will not
1556 for (i = 0; i < dc->res_pool->stream_enc_count; i++) {
1557 dc->res_pool->stream_enc[i]->funcs->dp_blank(
1558 dc->res_pool->stream_enc[i]);
1561 for (i = 0; i < dc->link_count; i++) {
1562 enum signal_type signal = dc->links[i]->connector_signal;
1564 if ((signal == SIGNAL_TYPE_EDP) ||
1565 (signal == SIGNAL_TYPE_DISPLAY_PORT))
1566 if (!dc->links[i]->wa_flags.dp_keep_receiver_powered)
1567 dp_receiver_power_ctrl(dc->links[i], false);
1569 if (signal != SIGNAL_TYPE_EDP)
1570 signal = SIGNAL_TYPE_NONE;
1572 dc->links[i]->link_enc->funcs->disable_output(
1573 dc->links[i]->link_enc, signal);
1575 dc->links[i]->link_status.link_active = false;
1576 memset(&dc->links[i]->cur_link_settings, 0,
1577 sizeof(dc->links[i]->cur_link_settings));
1581 static void power_down_controllers(struct dc *dc)
1585 for (i = 0; i < dc->res_pool->timing_generator_count; i++) {
1586 dc->res_pool->timing_generators[i]->funcs->disable_crtc(
1587 dc->res_pool->timing_generators[i]);
1591 static void power_down_clock_sources(struct dc *dc)
1595 if (dc->res_pool->dp_clock_source->funcs->cs_power_down(
1596 dc->res_pool->dp_clock_source) == false)
1597 dm_error("Failed to power down pll! (dp clk src)\n");
1599 for (i = 0; i < dc->res_pool->clk_src_count; i++) {
1600 if (dc->res_pool->clock_sources[i]->funcs->cs_power_down(
1601 dc->res_pool->clock_sources[i]) == false)
1602 dm_error("Failed to power down pll! (clk src index=%d)\n", i);
1606 static void power_down_all_hw_blocks(struct dc *dc)
1608 power_down_encoders(dc);
1610 power_down_controllers(dc);
1612 power_down_clock_sources(dc);
1614 if (dc->fbc_compressor)
1615 dc->fbc_compressor->funcs->disable_fbc(dc->fbc_compressor);
1618 static void disable_vga_and_power_gate_all_controllers(
1622 struct timing_generator *tg;
1623 struct dc_context *ctx = dc->ctx;
1625 for (i = 0; i < dc->res_pool->timing_generator_count; i++) {
1626 tg = dc->res_pool->timing_generators[i];
1628 if (tg->funcs->disable_vga)
1629 tg->funcs->disable_vga(tg);
1631 for (i = 0; i < dc->res_pool->pipe_count; i++) {
1632 /* Enable CLOCK gating for each pipe BEFORE controller
1634 enable_display_pipe_clock_gating(ctx,
1637 dc->current_state->res_ctx.pipe_ctx[i].pipe_idx = i;
1638 dc->hwss.disable_plane(dc,
1639 &dc->current_state->res_ctx.pipe_ctx[i]);
1644 static void get_edp_streams(struct dc_state *context,
1645 struct dc_stream_state **edp_streams,
1646 int *edp_stream_num)
1650 *edp_stream_num = 0;
1651 for (i = 0; i < context->stream_count; i++) {
1652 if (context->streams[i]->signal == SIGNAL_TYPE_EDP) {
1653 edp_streams[*edp_stream_num] = context->streams[i];
1654 if (++(*edp_stream_num) == MAX_NUM_EDP)
1660 static void get_edp_links_with_sink(
1662 struct dc_link **edp_links_with_sink,
1663 int *edp_with_sink_num)
1667 /* check if there is an eDP panel not in use */
1668 *edp_with_sink_num = 0;
1669 for (i = 0; i < dc->link_count; i++) {
1670 if (dc->links[i]->local_sink &&
1671 dc->links[i]->local_sink->sink_signal == SIGNAL_TYPE_EDP) {
1672 edp_links_with_sink[*edp_with_sink_num] = dc->links[i];
1673 if (++(*edp_with_sink_num) == MAX_NUM_EDP)
1680 * When ASIC goes from VBIOS/VGA mode to driver/accelerated mode we need:
1681 * 1. Power down all DC HW blocks
1682 * 2. Disable VGA engine on all controllers
1683 * 3. Enable power gating for controller
1684 * 4. Set acc_mode_change bit (VBIOS will clear this bit when going to FSDOS)
1686 void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context)
1688 struct dc_link *edp_links_with_sink[MAX_NUM_EDP];
1689 struct dc_link *edp_links[MAX_NUM_EDP];
1690 struct dc_stream_state *edp_streams[MAX_NUM_EDP];
1691 struct dc_link *edp_link_with_sink = NULL;
1692 struct dc_link *edp_link = NULL;
1693 struct dc_stream_state *edp_stream = NULL;
1694 struct dce_hwseq *hws = dc->hwseq;
1695 int edp_with_sink_num;
1699 bool can_apply_edp_fast_boot = false;
1700 bool can_apply_seamless_boot = false;
1701 bool keep_edp_vdd_on = false;
1705 get_edp_links_with_sink(dc, edp_links_with_sink, &edp_with_sink_num);
1706 get_edp_links(dc, edp_links, &edp_num);
1708 if (hws->funcs.init_pipes)
1709 hws->funcs.init_pipes(dc, context);
1711 get_edp_streams(context, edp_streams, &edp_stream_num);
1713 // Check fastboot support, disable on DCE8 because of blank screens
1714 if (edp_num && dc->ctx->dce_version != DCE_VERSION_8_0 &&
1715 dc->ctx->dce_version != DCE_VERSION_8_1 &&
1716 dc->ctx->dce_version != DCE_VERSION_8_3) {
1717 for (i = 0; i < edp_num; i++) {
1718 edp_link = edp_links[i];
1719 // enable fastboot if backend is enabled on eDP
1720 if (edp_link->link_enc->funcs->is_dig_enabled(edp_link->link_enc)) {
1721 /* Set optimization flag on eDP stream*/
1722 if (edp_stream_num && edp_link->link_status.link_active) {
1723 edp_stream = edp_streams[0];
1724 can_apply_edp_fast_boot = !is_edp_ilr_optimization_required(edp_stream->link, &edp_stream->timing);
1725 edp_stream->apply_edp_fast_boot_optimization = can_apply_edp_fast_boot;
1726 if (can_apply_edp_fast_boot)
1727 DC_LOG_EVENT_LINK_TRAINING("eDP fast boot disabled to optimize link rate\n");
1733 // We are trying to enable eDP, don't power down VDD
1735 keep_edp_vdd_on = true;
1738 // Check seamless boot support
1739 for (i = 0; i < context->stream_count; i++) {
1740 if (context->streams[i]->apply_seamless_boot_optimization) {
1741 can_apply_seamless_boot = true;
1746 /* eDP should not have stream in resume from S4 and so even with VBios post
1747 * it should get turned off
1749 if (edp_with_sink_num)
1750 edp_link_with_sink = edp_links_with_sink[0];
1752 if (!can_apply_edp_fast_boot && !can_apply_seamless_boot) {
1753 if (edp_link_with_sink && !keep_edp_vdd_on) {
1754 /*turn off backlight before DP_blank and encoder powered down*/
1755 hws->funcs.edp_backlight_control(edp_link_with_sink, false);
1757 /*resume from S3, no vbios posting, no need to power down again*/
1758 power_down_all_hw_blocks(dc);
1759 disable_vga_and_power_gate_all_controllers(dc);
1760 if (edp_link_with_sink && !keep_edp_vdd_on)
1761 dc->hwss.edp_power_control(edp_link_with_sink, false);
1763 bios_set_scratch_acc_mode_change(dc->ctx->dc_bios, 1);
1766 static uint32_t compute_pstate_blackout_duration(
1767 struct bw_fixed blackout_duration,
1768 const struct dc_stream_state *stream)
1770 uint32_t total_dest_line_time_ns;
1771 uint32_t pstate_blackout_duration_ns;
1773 pstate_blackout_duration_ns = 1000 * blackout_duration.value >> 24;
1775 total_dest_line_time_ns = 1000000UL *
1776 (stream->timing.h_total * 10) /
1777 stream->timing.pix_clk_100hz +
1778 pstate_blackout_duration_ns;
1780 return total_dest_line_time_ns;
1783 static void dce110_set_displaymarks(
1784 const struct dc *dc,
1785 struct dc_state *context)
1787 uint8_t i, num_pipes;
1788 unsigned int underlay_idx = dc->res_pool->underlay_pipe_index;
1790 for (i = 0, num_pipes = 0; i < MAX_PIPES; i++) {
1791 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
1792 uint32_t total_dest_line_time_ns;
1794 if (pipe_ctx->stream == NULL)
1797 total_dest_line_time_ns = compute_pstate_blackout_duration(
1798 dc->bw_vbios->blackout_duration, pipe_ctx->stream);
1799 pipe_ctx->plane_res.mi->funcs->mem_input_program_display_marks(
1800 pipe_ctx->plane_res.mi,
1801 context->bw_ctx.bw.dce.nbp_state_change_wm_ns[num_pipes],
1802 context->bw_ctx.bw.dce.stutter_exit_wm_ns[num_pipes],
1803 context->bw_ctx.bw.dce.stutter_entry_wm_ns[num_pipes],
1804 context->bw_ctx.bw.dce.urgent_wm_ns[num_pipes],
1805 total_dest_line_time_ns);
1806 if (i == underlay_idx) {
1808 pipe_ctx->plane_res.mi->funcs->mem_input_program_chroma_display_marks(
1809 pipe_ctx->plane_res.mi,
1810 context->bw_ctx.bw.dce.nbp_state_change_wm_ns[num_pipes],
1811 context->bw_ctx.bw.dce.stutter_exit_wm_ns[num_pipes],
1812 context->bw_ctx.bw.dce.urgent_wm_ns[num_pipes],
1813 total_dest_line_time_ns);
1819 void dce110_set_safe_displaymarks(
1820 struct resource_context *res_ctx,
1821 const struct resource_pool *pool)
1824 int underlay_idx = pool->underlay_pipe_index;
1825 struct dce_watermarks max_marks = {
1826 MAX_WATERMARK, MAX_WATERMARK, MAX_WATERMARK, MAX_WATERMARK };
1827 struct dce_watermarks nbp_marks = {
1828 SAFE_NBP_MARK, SAFE_NBP_MARK, SAFE_NBP_MARK, SAFE_NBP_MARK };
1829 struct dce_watermarks min_marks = { 0, 0, 0, 0};
1831 for (i = 0; i < MAX_PIPES; i++) {
1832 if (res_ctx->pipe_ctx[i].stream == NULL || res_ctx->pipe_ctx[i].plane_res.mi == NULL)
1835 res_ctx->pipe_ctx[i].plane_res.mi->funcs->mem_input_program_display_marks(
1836 res_ctx->pipe_ctx[i].plane_res.mi,
1843 if (i == underlay_idx)
1844 res_ctx->pipe_ctx[i].plane_res.mi->funcs->mem_input_program_chroma_display_marks(
1845 res_ctx->pipe_ctx[i].plane_res.mi,
1854 /*******************************************************************************
1856 ******************************************************************************/
1858 static void set_drr(struct pipe_ctx **pipe_ctx,
1859 int num_pipes, struct dc_crtc_timing_adjust adjust)
1862 struct drr_params params = {0};
1863 // DRR should set trigger event to monitor surface update event
1864 unsigned int event_triggers = 0x80;
1865 // Note DRR trigger events are generated regardless of whether num frames met.
1866 unsigned int num_frames = 2;
1868 params.vertical_total_max = adjust.v_total_max;
1869 params.vertical_total_min = adjust.v_total_min;
1871 /* TODO: If multiple pipes are to be supported, you need
1872 * some GSL stuff. Static screen triggers may be programmed differently
1875 for (i = 0; i < num_pipes; i++) {
1876 pipe_ctx[i]->stream_res.tg->funcs->set_drr(
1877 pipe_ctx[i]->stream_res.tg, ¶ms);
1879 if (adjust.v_total_max != 0 && adjust.v_total_min != 0)
1880 pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control(
1881 pipe_ctx[i]->stream_res.tg,
1882 event_triggers, num_frames);
1886 static void get_position(struct pipe_ctx **pipe_ctx,
1888 struct crtc_position *position)
1892 /* TODO: handle pipes > 1
1894 for (i = 0; i < num_pipes; i++)
1895 pipe_ctx[i]->stream_res.tg->funcs->get_position(pipe_ctx[i]->stream_res.tg, position);
1898 static void set_static_screen_control(struct pipe_ctx **pipe_ctx,
1899 int num_pipes, const struct dc_static_screen_params *params)
1902 unsigned int triggers = 0;
1904 if (params->triggers.overlay_update)
1906 if (params->triggers.surface_update)
1908 if (params->triggers.cursor_update)
1910 if (params->triggers.force_trigger)
1914 struct dc *dc = pipe_ctx[0]->stream->ctx->dc;
1916 if (dc->fbc_compressor)
1920 for (i = 0; i < num_pipes; i++)
1921 pipe_ctx[i]->stream_res.tg->funcs->
1922 set_static_screen_control(pipe_ctx[i]->stream_res.tg,
1923 triggers, params->num_frames);
1927 * Check if FBC can be enabled
1929 static bool should_enable_fbc(struct dc *dc,
1930 struct dc_state *context,
1934 struct pipe_ctx *pipe_ctx = NULL;
1935 struct resource_context *res_ctx = &context->res_ctx;
1936 unsigned int underlay_idx = dc->res_pool->underlay_pipe_index;
1939 ASSERT(dc->fbc_compressor);
1941 /* FBC memory should be allocated */
1942 if (!dc->ctx->fbc_gpu_addr)
1945 /* Only supports single display */
1946 if (context->stream_count != 1)
1949 for (i = 0; i < dc->res_pool->pipe_count; i++) {
1950 if (res_ctx->pipe_ctx[i].stream) {
1952 pipe_ctx = &res_ctx->pipe_ctx[i];
1957 /* fbc not applicable on underlay pipe */
1958 if (pipe_ctx->pipe_idx != underlay_idx) {
1965 if (i == dc->res_pool->pipe_count)
1968 if (!pipe_ctx->stream->link)
1971 /* Only supports eDP */
1972 if (pipe_ctx->stream->link->connector_signal != SIGNAL_TYPE_EDP)
1975 /* PSR should not be enabled */
1976 if (pipe_ctx->stream->link->psr_settings.psr_feature_enabled)
1979 /* Nothing to compress */
1980 if (!pipe_ctx->plane_state)
1983 /* Only for non-linear tiling */
1984 if (pipe_ctx->plane_state->tiling_info.gfx8.array_mode == DC_ARRAY_LINEAR_GENERAL)
1993 static void enable_fbc(
1995 struct dc_state *context)
1997 uint32_t pipe_idx = 0;
1999 if (should_enable_fbc(dc, context, &pipe_idx)) {
2000 /* Program GRPH COMPRESSED ADDRESS and PITCH */
2001 struct compr_addr_and_pitch_params params = {0, 0, 0};
2002 struct compressor *compr = dc->fbc_compressor;
2003 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[pipe_idx];
2005 params.source_view_width = pipe_ctx->stream->timing.h_addressable;
2006 params.source_view_height = pipe_ctx->stream->timing.v_addressable;
2007 params.inst = pipe_ctx->stream_res.tg->inst;
2008 compr->compr_surface_address.quad_part = dc->ctx->fbc_gpu_addr;
2010 compr->funcs->surface_address_and_pitch(compr, ¶ms);
2011 compr->funcs->set_fbc_invalidation_triggers(compr, 1);
2013 compr->funcs->enable_fbc(compr, ¶ms);
2017 static void dce110_reset_hw_ctx_wrap(
2019 struct dc_state *context)
2023 /* Reset old context */
2024 /* look up the targets that have been removed since last commit */
2025 for (i = 0; i < MAX_PIPES; i++) {
2026 struct pipe_ctx *pipe_ctx_old =
2027 &dc->current_state->res_ctx.pipe_ctx[i];
2028 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2030 /* Note: We need to disable output if clock sources change,
2031 * since bios does optimization and doesn't apply if changing
2032 * PHY when not already disabled.
2035 /* Skip underlay pipe since it will be handled in commit surface*/
2036 if (!pipe_ctx_old->stream || pipe_ctx_old->top_pipe)
2039 if (!pipe_ctx->stream ||
2040 pipe_need_reprogram(pipe_ctx_old, pipe_ctx)) {
2041 struct clock_source *old_clk = pipe_ctx_old->clock_source;
2043 /* Disable if new stream is null. O/w, if stream is
2044 * disabled already, no need to disable again.
2046 if (!pipe_ctx->stream || !pipe_ctx->stream->dpms_off) {
2047 core_link_disable_stream(pipe_ctx_old);
2049 /* free acquired resources*/
2050 if (pipe_ctx_old->stream_res.audio) {
2051 /*disable az_endpoint*/
2052 pipe_ctx_old->stream_res.audio->funcs->
2053 az_disable(pipe_ctx_old->stream_res.audio);
2056 if (dc->caps.dynamic_audio == true) {
2057 /*we have to dynamic arbitrate the audio endpoints*/
2058 /*we free the resource, need reset is_audio_acquired*/
2059 update_audio_usage(&dc->current_state->res_ctx, dc->res_pool,
2060 pipe_ctx_old->stream_res.audio, false);
2061 pipe_ctx_old->stream_res.audio = NULL;
2066 pipe_ctx_old->stream_res.tg->funcs->set_blank(pipe_ctx_old->stream_res.tg, true);
2067 if (!hwss_wait_for_blank_complete(pipe_ctx_old->stream_res.tg)) {
2068 dm_error("DC: failed to blank crtc!\n");
2069 BREAK_TO_DEBUGGER();
2071 pipe_ctx_old->stream_res.tg->funcs->disable_crtc(pipe_ctx_old->stream_res.tg);
2072 pipe_ctx_old->plane_res.mi->funcs->free_mem_input(
2073 pipe_ctx_old->plane_res.mi, dc->current_state->stream_count);
2075 if (old_clk && 0 == resource_get_clock_source_reference(&context->res_ctx,
2078 old_clk->funcs->cs_power_down(old_clk);
2080 dc->hwss.disable_plane(dc, pipe_ctx_old);
2082 pipe_ctx_old->stream = NULL;
2087 static void dce110_setup_audio_dto(
2089 struct dc_state *context)
2093 /* program audio wall clock. use HDMI as clock source if HDMI
2094 * audio active. Otherwise, use DP as clock source
2095 * first, loop to find any HDMI audio, if not, loop find DP audio
2097 /* Setup audio rate clock source */
2099 * Audio lag happened on DP monitor when unplug a HDMI monitor
2102 * In case of DP and HDMI connected or HDMI only, DCCG_AUDIO_DTO_SEL
2103 * is set to either dto0 or dto1, audio should work fine.
2104 * In case of DP connected only, DCCG_AUDIO_DTO_SEL should be dto1,
2105 * set to dto0 will cause audio lag.
2108 * Not optimized audio wall dto setup. When mode set, iterate pipe_ctx,
2109 * find first available pipe with audio, setup audio wall DTO per topology
2110 * instead of per pipe.
2112 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2113 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2115 if (pipe_ctx->stream == NULL)
2118 if (pipe_ctx->top_pipe)
2120 if (pipe_ctx->stream->signal != SIGNAL_TYPE_HDMI_TYPE_A)
2122 if (pipe_ctx->stream_res.audio != NULL) {
2123 struct audio_output audio_output;
2125 build_audio_output(context, pipe_ctx, &audio_output);
2127 pipe_ctx->stream_res.audio->funcs->wall_dto_setup(
2128 pipe_ctx->stream_res.audio,
2129 pipe_ctx->stream->signal,
2130 &audio_output.crtc_info,
2131 &audio_output.pll_info);
2136 /* no HDMI audio is found, try DP audio */
2137 if (i == dc->res_pool->pipe_count) {
2138 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2139 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2141 if (pipe_ctx->stream == NULL)
2144 if (pipe_ctx->top_pipe)
2147 if (!dc_is_dp_signal(pipe_ctx->stream->signal))
2150 if (pipe_ctx->stream_res.audio != NULL) {
2151 struct audio_output audio_output;
2153 build_audio_output(context, pipe_ctx, &audio_output);
2155 pipe_ctx->stream_res.audio->funcs->wall_dto_setup(
2156 pipe_ctx->stream_res.audio,
2157 pipe_ctx->stream->signal,
2158 &audio_output.crtc_info,
2159 &audio_output.pll_info);
2166 enum dc_status dce110_apply_ctx_to_hw(
2168 struct dc_state *context)
2170 struct dce_hwseq *hws = dc->hwseq;
2171 struct dc_bios *dcb = dc->ctx->dc_bios;
2172 enum dc_status status;
2175 /* Reset old context */
2176 /* look up the targets that have been removed since last commit */
2177 hws->funcs.reset_hw_ctx_wrap(dc, context);
2179 /* Skip applying if no targets */
2180 if (context->stream_count <= 0)
2183 /* Apply new context */
2184 dcb->funcs->set_scratch_critical_state(dcb, true);
2186 /* below is for real asic only */
2187 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2188 struct pipe_ctx *pipe_ctx_old =
2189 &dc->current_state->res_ctx.pipe_ctx[i];
2190 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2192 if (pipe_ctx->stream == NULL || pipe_ctx->top_pipe)
2195 if (pipe_ctx->stream == pipe_ctx_old->stream) {
2196 if (pipe_ctx_old->clock_source != pipe_ctx->clock_source)
2197 dce_crtc_switch_to_clk_src(dc->hwseq,
2198 pipe_ctx->clock_source, i);
2202 hws->funcs.enable_display_power_gating(
2203 dc, i, dc->ctx->dc_bios,
2204 PIPE_GATING_CONTROL_DISABLE);
2207 if (dc->fbc_compressor)
2208 dc->fbc_compressor->funcs->disable_fbc(dc->fbc_compressor);
2210 dce110_setup_audio_dto(dc, context);
2212 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2213 struct pipe_ctx *pipe_ctx_old =
2214 &dc->current_state->res_ctx.pipe_ctx[i];
2215 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2217 if (pipe_ctx->stream == NULL)
2220 if (pipe_ctx->stream == pipe_ctx_old->stream &&
2221 pipe_ctx->stream->link->link_state_valid) {
2225 if (pipe_ctx_old->stream && !pipe_need_reprogram(pipe_ctx_old, pipe_ctx))
2228 if (pipe_ctx->top_pipe || pipe_ctx->prev_odm_pipe)
2231 status = apply_single_controller_ctx_to_hw(
2236 if (DC_OK != status)
2240 if (dc->fbc_compressor)
2241 enable_fbc(dc, dc->current_state);
2243 dcb->funcs->set_scratch_critical_state(dcb, false);
2248 /*******************************************************************************
2249 * Front End programming
2250 ******************************************************************************/
2251 static void set_default_colors(struct pipe_ctx *pipe_ctx)
2253 struct default_adjustment default_adjust = { 0 };
2255 default_adjust.force_hw_default = false;
2256 default_adjust.in_color_space = pipe_ctx->plane_state->color_space;
2257 default_adjust.out_color_space = pipe_ctx->stream->output_color_space;
2258 default_adjust.csc_adjust_type = GRAPHICS_CSC_ADJUST_TYPE_SW;
2259 default_adjust.surface_pixel_format = pipe_ctx->plane_res.scl_data.format;
2261 /* display color depth */
2262 default_adjust.color_depth =
2263 pipe_ctx->stream->timing.display_color_depth;
2265 /* Lb color depth */
2266 default_adjust.lb_color_depth = pipe_ctx->plane_res.scl_data.lb_params.depth;
2268 pipe_ctx->plane_res.xfm->funcs->opp_set_csc_default(
2269 pipe_ctx->plane_res.xfm, &default_adjust);
2273 /*******************************************************************************
2274 * In order to turn on/off specific surface we will program
2277 * In case that we have two surfaces and they have a different visibility
2278 * we can't turn off the CRTC since it will turn off the entire display
2280 * |----------------------------------------------- |
2281 * |bottom pipe|curr pipe | | |
2282 * |Surface |Surface | Blender | CRCT |
2283 * |visibility |visibility | Configuration| |
2284 * |------------------------------------------------|
2285 * | off | off | CURRENT_PIPE | blank |
2286 * | off | on | CURRENT_PIPE | unblank |
2287 * | on | off | OTHER_PIPE | unblank |
2288 * | on | on | BLENDING | unblank |
2289 * -------------------------------------------------|
2291 ******************************************************************************/
2292 static void program_surface_visibility(const struct dc *dc,
2293 struct pipe_ctx *pipe_ctx)
2295 enum blnd_mode blender_mode = BLND_MODE_CURRENT_PIPE;
2296 bool blank_target = false;
2298 if (pipe_ctx->bottom_pipe) {
2300 /* For now we are supporting only two pipes */
2301 ASSERT(pipe_ctx->bottom_pipe->bottom_pipe == NULL);
2303 if (pipe_ctx->bottom_pipe->plane_state->visible) {
2304 if (pipe_ctx->plane_state->visible)
2305 blender_mode = BLND_MODE_BLENDING;
2307 blender_mode = BLND_MODE_OTHER_PIPE;
2309 } else if (!pipe_ctx->plane_state->visible)
2310 blank_target = true;
2312 } else if (!pipe_ctx->plane_state->visible)
2313 blank_target = true;
2315 dce_set_blender_mode(dc->hwseq, pipe_ctx->stream_res.tg->inst, blender_mode);
2316 pipe_ctx->stream_res.tg->funcs->set_blank(pipe_ctx->stream_res.tg, blank_target);
2320 static void program_gamut_remap(struct pipe_ctx *pipe_ctx)
2323 struct xfm_grph_csc_adjustment adjust;
2324 memset(&adjust, 0, sizeof(adjust));
2325 adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS;
2328 if (pipe_ctx->stream->gamut_remap_matrix.enable_remap == true) {
2329 adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_SW;
2331 for (i = 0; i < CSC_TEMPERATURE_MATRIX_SIZE; i++)
2332 adjust.temperature_matrix[i] =
2333 pipe_ctx->stream->gamut_remap_matrix.matrix[i];
2336 pipe_ctx->plane_res.xfm->funcs->transform_set_gamut_remap(pipe_ctx->plane_res.xfm, &adjust);
2338 static void update_plane_addr(const struct dc *dc,
2339 struct pipe_ctx *pipe_ctx)
2341 struct dc_plane_state *plane_state = pipe_ctx->plane_state;
2343 if (plane_state == NULL)
2346 pipe_ctx->plane_res.mi->funcs->mem_input_program_surface_flip_and_addr(
2347 pipe_ctx->plane_res.mi,
2348 &plane_state->address,
2349 plane_state->flip_immediate);
2351 plane_state->status.requested_address = plane_state->address;
2354 static void dce110_update_pending_status(struct pipe_ctx *pipe_ctx)
2356 struct dc_plane_state *plane_state = pipe_ctx->plane_state;
2358 if (plane_state == NULL)
2361 plane_state->status.is_flip_pending =
2362 pipe_ctx->plane_res.mi->funcs->mem_input_is_flip_pending(
2363 pipe_ctx->plane_res.mi);
2365 if (plane_state->status.is_flip_pending && !plane_state->visible)
2366 pipe_ctx->plane_res.mi->current_address = pipe_ctx->plane_res.mi->request_address;
2368 plane_state->status.current_address = pipe_ctx->plane_res.mi->current_address;
2369 if (pipe_ctx->plane_res.mi->current_address.type == PLN_ADDR_TYPE_GRPH_STEREO &&
2370 pipe_ctx->stream_res.tg->funcs->is_stereo_left_eye) {
2371 plane_state->status.is_right_eye =\
2372 !pipe_ctx->stream_res.tg->funcs->is_stereo_left_eye(pipe_ctx->stream_res.tg);
2376 void dce110_power_down(struct dc *dc)
2378 power_down_all_hw_blocks(dc);
2379 disable_vga_and_power_gate_all_controllers(dc);
2382 static bool wait_for_reset_trigger_to_occur(
2383 struct dc_context *dc_ctx,
2384 struct timing_generator *tg)
2388 /* To avoid endless loop we wait at most
2389 * frames_to_wait_on_triggered_reset frames for the reset to occur. */
2390 const uint32_t frames_to_wait_on_triggered_reset = 10;
2393 for (i = 0; i < frames_to_wait_on_triggered_reset; i++) {
2395 if (!tg->funcs->is_counter_moving(tg)) {
2396 DC_ERROR("TG counter is not moving!\n");
2400 if (tg->funcs->did_triggered_reset_occur(tg)) {
2402 /* usually occurs at i=1 */
2403 DC_SYNC_INFO("GSL: reset occurred at wait count: %d\n",
2408 /* Wait for one frame. */
2409 tg->funcs->wait_for_state(tg, CRTC_STATE_VACTIVE);
2410 tg->funcs->wait_for_state(tg, CRTC_STATE_VBLANK);
2414 DC_ERROR("GSL: Timeout on reset trigger!\n");
2419 /* Enable timing synchronization for a group of Timing Generators. */
2420 static void dce110_enable_timing_synchronization(
2424 struct pipe_ctx *grouped_pipes[])
2426 struct dc_context *dc_ctx = dc->ctx;
2427 struct dcp_gsl_params gsl_params = { 0 };
2430 DC_SYNC_INFO("GSL: Setting-up...\n");
2432 /* Designate a single TG in the group as a master.
2433 * Since HW doesn't care which one, we always assign
2434 * the 1st one in the group. */
2435 gsl_params.gsl_group = 0;
2436 gsl_params.gsl_master = grouped_pipes[0]->stream_res.tg->inst;
2438 for (i = 0; i < group_size; i++)
2439 grouped_pipes[i]->stream_res.tg->funcs->setup_global_swap_lock(
2440 grouped_pipes[i]->stream_res.tg, &gsl_params);
2442 /* Reset slave controllers on master VSync */
2443 DC_SYNC_INFO("GSL: enabling trigger-reset\n");
2445 for (i = 1 /* skip the master */; i < group_size; i++)
2446 grouped_pipes[i]->stream_res.tg->funcs->enable_reset_trigger(
2447 grouped_pipes[i]->stream_res.tg,
2448 gsl_params.gsl_group);
2450 for (i = 1 /* skip the master */; i < group_size; i++) {
2451 DC_SYNC_INFO("GSL: waiting for reset to occur.\n");
2452 wait_for_reset_trigger_to_occur(dc_ctx, grouped_pipes[i]->stream_res.tg);
2453 grouped_pipes[i]->stream_res.tg->funcs->disable_reset_trigger(
2454 grouped_pipes[i]->stream_res.tg);
2457 /* GSL Vblank synchronization is a one time sync mechanism, assumption
2458 * is that the sync'ed displays will not drift out of sync over time*/
2459 DC_SYNC_INFO("GSL: Restoring register states.\n");
2460 for (i = 0; i < group_size; i++)
2461 grouped_pipes[i]->stream_res.tg->funcs->tear_down_global_swap_lock(grouped_pipes[i]->stream_res.tg);
2463 DC_SYNC_INFO("GSL: Set-up complete.\n");
2466 static void dce110_enable_per_frame_crtc_position_reset(
2469 struct pipe_ctx *grouped_pipes[])
2471 struct dc_context *dc_ctx = dc->ctx;
2472 struct dcp_gsl_params gsl_params = { 0 };
2475 gsl_params.gsl_group = 0;
2476 gsl_params.gsl_master = 0;
2478 for (i = 0; i < group_size; i++)
2479 grouped_pipes[i]->stream_res.tg->funcs->setup_global_swap_lock(
2480 grouped_pipes[i]->stream_res.tg, &gsl_params);
2482 DC_SYNC_INFO("GSL: enabling trigger-reset\n");
2484 for (i = 1; i < group_size; i++)
2485 grouped_pipes[i]->stream_res.tg->funcs->enable_crtc_reset(
2486 grouped_pipes[i]->stream_res.tg,
2487 gsl_params.gsl_master,
2488 &grouped_pipes[i]->stream->triggered_crtc_reset);
2490 DC_SYNC_INFO("GSL: waiting for reset to occur.\n");
2491 for (i = 1; i < group_size; i++)
2492 wait_for_reset_trigger_to_occur(dc_ctx, grouped_pipes[i]->stream_res.tg);
2494 for (i = 0; i < group_size; i++)
2495 grouped_pipes[i]->stream_res.tg->funcs->tear_down_global_swap_lock(grouped_pipes[i]->stream_res.tg);
2499 static void init_pipes(struct dc *dc, struct dc_state *context)
2504 static void init_hw(struct dc *dc)
2508 struct transform *xfm;
2511 struct dce_hwseq *hws = dc->hwseq;
2512 uint32_t backlight = MAX_BACKLIGHT_LEVEL;
2514 bp = dc->ctx->dc_bios;
2515 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2516 xfm = dc->res_pool->transforms[i];
2517 xfm->funcs->transform_reset(xfm);
2519 hws->funcs.enable_display_power_gating(
2521 PIPE_GATING_CONTROL_INIT);
2522 hws->funcs.enable_display_power_gating(
2524 PIPE_GATING_CONTROL_DISABLE);
2525 hws->funcs.enable_display_pipe_clock_gating(
2530 dce_clock_gating_power_up(dc->hwseq, false);
2531 /***************************************/
2533 for (i = 0; i < dc->link_count; i++) {
2534 /****************************************/
2535 /* Power up AND update implementation according to the
2536 * required signal (which may be different from the
2537 * default signal on connector). */
2538 struct dc_link *link = dc->links[i];
2540 link->link_enc->funcs->hw_init(link->link_enc);
2543 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2544 struct timing_generator *tg = dc->res_pool->timing_generators[i];
2546 tg->funcs->disable_vga(tg);
2548 /* Blank controller using driver code instead of
2550 tg->funcs->set_blank(tg, true);
2551 hwss_wait_for_blank_complete(tg);
2554 for (i = 0; i < dc->res_pool->audio_count; i++) {
2555 struct audio *audio = dc->res_pool->audios[i];
2556 audio->funcs->hw_init(audio);
2559 for (i = 0; i < dc->link_count; i++) {
2560 struct dc_link *link = dc->links[i];
2562 if (link->panel_cntl)
2563 backlight = link->panel_cntl->funcs->hw_init(link->panel_cntl);
2566 abm = dc->res_pool->abm;
2568 abm->funcs->abm_init(abm, backlight);
2570 dmcu = dc->res_pool->dmcu;
2571 if (dmcu != NULL && abm != NULL)
2572 abm->dmcu_is_running = dmcu->funcs->is_dmcu_initialized(dmcu);
2574 if (dc->fbc_compressor)
2575 dc->fbc_compressor->funcs->power_up_fbc(dc->fbc_compressor);
2580 void dce110_prepare_bandwidth(
2582 struct dc_state *context)
2584 struct clk_mgr *dccg = dc->clk_mgr;
2586 dce110_set_safe_displaymarks(&context->res_ctx, dc->res_pool);
2588 dccg->funcs->update_clocks(
2594 void dce110_optimize_bandwidth(
2596 struct dc_state *context)
2598 struct clk_mgr *dccg = dc->clk_mgr;
2600 dce110_set_displaymarks(dc, context);
2602 dccg->funcs->update_clocks(
2608 static void dce110_program_front_end_for_pipe(
2609 struct dc *dc, struct pipe_ctx *pipe_ctx)
2611 struct mem_input *mi = pipe_ctx->plane_res.mi;
2612 struct dc_plane_state *plane_state = pipe_ctx->plane_state;
2613 struct xfm_grph_csc_adjustment adjust;
2614 struct out_csc_color_matrix tbl_entry;
2616 struct dce_hwseq *hws = dc->hwseq;
2619 memset(&tbl_entry, 0, sizeof(tbl_entry));
2621 memset(&adjust, 0, sizeof(adjust));
2622 adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS;
2624 dce_enable_fe_clock(dc->hwseq, mi->inst, true);
2626 set_default_colors(pipe_ctx);
2627 if (pipe_ctx->stream->csc_color_matrix.enable_adjustment
2629 tbl_entry.color_space =
2630 pipe_ctx->stream->output_color_space;
2632 for (i = 0; i < 12; i++)
2633 tbl_entry.regval[i] =
2634 pipe_ctx->stream->csc_color_matrix.matrix[i];
2636 pipe_ctx->plane_res.xfm->funcs->opp_set_csc_adjustment
2637 (pipe_ctx->plane_res.xfm, &tbl_entry);
2640 if (pipe_ctx->stream->gamut_remap_matrix.enable_remap == true) {
2641 adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_SW;
2643 for (i = 0; i < CSC_TEMPERATURE_MATRIX_SIZE; i++)
2644 adjust.temperature_matrix[i] =
2645 pipe_ctx->stream->gamut_remap_matrix.matrix[i];
2648 pipe_ctx->plane_res.xfm->funcs->transform_set_gamut_remap(pipe_ctx->plane_res.xfm, &adjust);
2650 pipe_ctx->plane_res.scl_data.lb_params.alpha_en = pipe_ctx->bottom_pipe != 0;
2652 program_scaler(dc, pipe_ctx);
2654 mi->funcs->mem_input_program_surface_config(
2656 plane_state->format,
2657 &plane_state->tiling_info,
2658 &plane_state->plane_size,
2659 plane_state->rotation,
2662 if (mi->funcs->set_blank)
2663 mi->funcs->set_blank(mi, pipe_ctx->plane_state->visible);
2665 if (dc->config.gpu_vm_support)
2666 mi->funcs->mem_input_program_pte_vm(
2667 pipe_ctx->plane_res.mi,
2668 plane_state->format,
2669 &plane_state->tiling_info,
2670 plane_state->rotation);
2672 /* Moved programming gamma from dc to hwss */
2673 if (pipe_ctx->plane_state->update_flags.bits.full_update ||
2674 pipe_ctx->plane_state->update_flags.bits.in_transfer_func_change ||
2675 pipe_ctx->plane_state->update_flags.bits.gamma_change)
2676 hws->funcs.set_input_transfer_func(dc, pipe_ctx, pipe_ctx->plane_state);
2678 if (pipe_ctx->plane_state->update_flags.bits.full_update)
2679 hws->funcs.set_output_transfer_func(dc, pipe_ctx, pipe_ctx->stream);
2682 "Pipe:%d %p: addr hi:0x%x, "
2685 " %d; dst: %d, %d, %d, %d;"
2686 "clip: %d, %d, %d, %d\n",
2688 (void *) pipe_ctx->plane_state,
2689 pipe_ctx->plane_state->address.grph.addr.high_part,
2690 pipe_ctx->plane_state->address.grph.addr.low_part,
2691 pipe_ctx->plane_state->src_rect.x,
2692 pipe_ctx->plane_state->src_rect.y,
2693 pipe_ctx->plane_state->src_rect.width,
2694 pipe_ctx->plane_state->src_rect.height,
2695 pipe_ctx->plane_state->dst_rect.x,
2696 pipe_ctx->plane_state->dst_rect.y,
2697 pipe_ctx->plane_state->dst_rect.width,
2698 pipe_ctx->plane_state->dst_rect.height,
2699 pipe_ctx->plane_state->clip_rect.x,
2700 pipe_ctx->plane_state->clip_rect.y,
2701 pipe_ctx->plane_state->clip_rect.width,
2702 pipe_ctx->plane_state->clip_rect.height);
2705 "Pipe %d: width, height, x, y\n"
2706 "viewport:%d, %d, %d, %d\n"
2707 "recout: %d, %d, %d, %d\n",
2709 pipe_ctx->plane_res.scl_data.viewport.width,
2710 pipe_ctx->plane_res.scl_data.viewport.height,
2711 pipe_ctx->plane_res.scl_data.viewport.x,
2712 pipe_ctx->plane_res.scl_data.viewport.y,
2713 pipe_ctx->plane_res.scl_data.recout.width,
2714 pipe_ctx->plane_res.scl_data.recout.height,
2715 pipe_ctx->plane_res.scl_data.recout.x,
2716 pipe_ctx->plane_res.scl_data.recout.y);
2719 static void dce110_apply_ctx_for_surface(
2721 const struct dc_stream_state *stream,
2723 struct dc_state *context)
2727 if (num_planes == 0)
2730 if (dc->fbc_compressor)
2731 dc->fbc_compressor->funcs->disable_fbc(dc->fbc_compressor);
2733 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2734 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2736 if (pipe_ctx->stream != stream)
2739 /* Need to allocate mem before program front end for Fiji */
2740 pipe_ctx->plane_res.mi->funcs->allocate_mem_input(
2741 pipe_ctx->plane_res.mi,
2742 pipe_ctx->stream->timing.h_total,
2743 pipe_ctx->stream->timing.v_total,
2744 pipe_ctx->stream->timing.pix_clk_100hz / 10,
2745 context->stream_count);
2747 dce110_program_front_end_for_pipe(dc, pipe_ctx);
2749 dc->hwss.update_plane_addr(dc, pipe_ctx);
2751 program_surface_visibility(dc, pipe_ctx);
2755 if (dc->fbc_compressor)
2756 enable_fbc(dc, context);
2759 static void dce110_post_unlock_program_front_end(
2761 struct dc_state *context)
2765 static void dce110_power_down_fe(struct dc *dc, struct pipe_ctx *pipe_ctx)
2767 struct dce_hwseq *hws = dc->hwseq;
2768 int fe_idx = pipe_ctx->plane_res.mi ?
2769 pipe_ctx->plane_res.mi->inst : pipe_ctx->pipe_idx;
2771 /* Do not power down fe when stream is active on dce*/
2772 if (dc->current_state->res_ctx.pipe_ctx[fe_idx].stream)
2775 hws->funcs.enable_display_power_gating(
2776 dc, fe_idx, dc->ctx->dc_bios, PIPE_GATING_CONTROL_ENABLE);
2778 dc->res_pool->transforms[fe_idx]->funcs->transform_reset(
2779 dc->res_pool->transforms[fe_idx]);
2782 static void dce110_wait_for_mpcc_disconnect(
2784 struct resource_pool *res_pool,
2785 struct pipe_ctx *pipe_ctx)
2790 static void program_output_csc(struct dc *dc,
2791 struct pipe_ctx *pipe_ctx,
2792 enum dc_color_space colorspace,
2797 struct out_csc_color_matrix tbl_entry;
2799 if (pipe_ctx->stream->csc_color_matrix.enable_adjustment == true) {
2800 enum dc_color_space color_space = pipe_ctx->stream->output_color_space;
2802 for (i = 0; i < 12; i++)
2803 tbl_entry.regval[i] = pipe_ctx->stream->csc_color_matrix.matrix[i];
2805 tbl_entry.color_space = color_space;
2807 pipe_ctx->plane_res.xfm->funcs->opp_set_csc_adjustment(
2808 pipe_ctx->plane_res.xfm, &tbl_entry);
2812 static void dce110_set_cursor_position(struct pipe_ctx *pipe_ctx)
2814 struct dc_cursor_position pos_cpy = pipe_ctx->stream->cursor_position;
2815 struct input_pixel_processor *ipp = pipe_ctx->plane_res.ipp;
2816 struct mem_input *mi = pipe_ctx->plane_res.mi;
2817 struct dc_cursor_mi_param param = {
2818 .pixel_clk_khz = pipe_ctx->stream->timing.pix_clk_100hz / 10,
2819 .ref_clk_khz = pipe_ctx->stream->ctx->dc->res_pool->ref_clocks.xtalin_clock_inKhz,
2820 .viewport = pipe_ctx->plane_res.scl_data.viewport,
2821 .h_scale_ratio = pipe_ctx->plane_res.scl_data.ratios.horz,
2822 .v_scale_ratio = pipe_ctx->plane_res.scl_data.ratios.vert,
2823 .rotation = pipe_ctx->plane_state->rotation,
2824 .mirror = pipe_ctx->plane_state->horizontal_mirror
2828 * If the cursor's source viewport is clipped then we need to
2829 * translate the cursor to appear in the correct position on
2832 * This translation isn't affected by scaling so it needs to be
2833 * done *after* we adjust the position for the scale factor.
2835 * This is only done by opt-in for now since there are still
2836 * some usecases like tiled display that might enable the
2837 * cursor on both streams while expecting dc to clip it.
2839 if (pos_cpy.translate_by_source) {
2840 pos_cpy.x += pipe_ctx->plane_state->src_rect.x;
2841 pos_cpy.y += pipe_ctx->plane_state->src_rect.y;
2844 if (pipe_ctx->plane_state->address.type
2845 == PLN_ADDR_TYPE_VIDEO_PROGRESSIVE)
2846 pos_cpy.enable = false;
2848 if (pipe_ctx->top_pipe && pipe_ctx->plane_state != pipe_ctx->top_pipe->plane_state)
2849 pos_cpy.enable = false;
2851 if (ipp->funcs->ipp_cursor_set_position)
2852 ipp->funcs->ipp_cursor_set_position(ipp, &pos_cpy, ¶m);
2853 if (mi->funcs->set_cursor_position)
2854 mi->funcs->set_cursor_position(mi, &pos_cpy, ¶m);
2857 static void dce110_set_cursor_attribute(struct pipe_ctx *pipe_ctx)
2859 struct dc_cursor_attributes *attributes = &pipe_ctx->stream->cursor_attributes;
2861 if (pipe_ctx->plane_res.ipp &&
2862 pipe_ctx->plane_res.ipp->funcs->ipp_cursor_set_attributes)
2863 pipe_ctx->plane_res.ipp->funcs->ipp_cursor_set_attributes(
2864 pipe_ctx->plane_res.ipp, attributes);
2866 if (pipe_ctx->plane_res.mi &&
2867 pipe_ctx->plane_res.mi->funcs->set_cursor_attributes)
2868 pipe_ctx->plane_res.mi->funcs->set_cursor_attributes(
2869 pipe_ctx->plane_res.mi, attributes);
2871 if (pipe_ctx->plane_res.xfm &&
2872 pipe_ctx->plane_res.xfm->funcs->set_cursor_attributes)
2873 pipe_ctx->plane_res.xfm->funcs->set_cursor_attributes(
2874 pipe_ctx->plane_res.xfm, attributes);
2877 bool dce110_set_backlight_level(struct pipe_ctx *pipe_ctx,
2878 uint32_t backlight_pwm_u16_16,
2879 uint32_t frame_ramp)
2881 struct dc_link *link = pipe_ctx->stream->link;
2882 struct dc *dc = link->ctx->dc;
2883 struct abm *abm = pipe_ctx->stream_res.abm;
2884 struct panel_cntl *panel_cntl = link->panel_cntl;
2885 struct dmcu *dmcu = dc->res_pool->dmcu;
2886 bool fw_set_brightness = true;
2887 /* DMCU -1 for all controller id values,
2890 uint32_t controller_id = pipe_ctx->stream_res.tg->inst + 1;
2892 if (abm == NULL || panel_cntl == NULL || (abm->funcs->set_backlight_level_pwm == NULL))
2896 fw_set_brightness = dmcu->funcs->is_dmcu_initialized(dmcu);
2898 if (!fw_set_brightness && panel_cntl->funcs->driver_set_backlight)
2899 panel_cntl->funcs->driver_set_backlight(panel_cntl, backlight_pwm_u16_16);
2901 abm->funcs->set_backlight_level_pwm(
2903 backlight_pwm_u16_16,
2906 link->panel_cntl->inst);
2911 void dce110_set_abm_immediate_disable(struct pipe_ctx *pipe_ctx)
2913 struct abm *abm = pipe_ctx->stream_res.abm;
2914 struct panel_cntl *panel_cntl = pipe_ctx->stream->link->panel_cntl;
2917 abm->funcs->set_abm_immediate_disable(abm,
2918 pipe_ctx->stream->link->panel_cntl->inst);
2921 panel_cntl->funcs->store_backlight_level(panel_cntl);
2924 void dce110_set_pipe(struct pipe_ctx *pipe_ctx)
2926 struct abm *abm = pipe_ctx->stream_res.abm;
2927 struct panel_cntl *panel_cntl = pipe_ctx->stream->link->panel_cntl;
2928 uint32_t otg_inst = pipe_ctx->stream_res.tg->inst + 1;
2930 if (abm && panel_cntl)
2931 abm->funcs->set_pipe(abm, otg_inst, panel_cntl->inst);
2934 static const struct hw_sequencer_funcs dce110_funcs = {
2935 .program_gamut_remap = program_gamut_remap,
2936 .program_output_csc = program_output_csc,
2938 .apply_ctx_to_hw = dce110_apply_ctx_to_hw,
2939 .apply_ctx_for_surface = dce110_apply_ctx_for_surface,
2940 .post_unlock_program_front_end = dce110_post_unlock_program_front_end,
2941 .update_plane_addr = update_plane_addr,
2942 .update_pending_status = dce110_update_pending_status,
2943 .enable_accelerated_mode = dce110_enable_accelerated_mode,
2944 .enable_timing_synchronization = dce110_enable_timing_synchronization,
2945 .enable_per_frame_crtc_position_reset = dce110_enable_per_frame_crtc_position_reset,
2946 .update_info_frame = dce110_update_info_frame,
2947 .enable_stream = dce110_enable_stream,
2948 .disable_stream = dce110_disable_stream,
2949 .unblank_stream = dce110_unblank_stream,
2950 .blank_stream = dce110_blank_stream,
2951 .enable_audio_stream = dce110_enable_audio_stream,
2952 .disable_audio_stream = dce110_disable_audio_stream,
2953 .disable_plane = dce110_power_down_fe,
2954 .pipe_control_lock = dce_pipe_control_lock,
2955 .interdependent_update_lock = NULL,
2956 .cursor_lock = dce_pipe_control_lock,
2957 .prepare_bandwidth = dce110_prepare_bandwidth,
2958 .optimize_bandwidth = dce110_optimize_bandwidth,
2960 .get_position = get_position,
2961 .set_static_screen_control = set_static_screen_control,
2962 .setup_stereo = NULL,
2963 .set_avmute = dce110_set_avmute,
2964 .wait_for_mpcc_disconnect = dce110_wait_for_mpcc_disconnect,
2965 .edp_backlight_control = dce110_edp_backlight_control,
2966 .edp_power_control = dce110_edp_power_control,
2967 .edp_wait_for_hpd_ready = dce110_edp_wait_for_hpd_ready,
2968 .set_cursor_position = dce110_set_cursor_position,
2969 .set_cursor_attribute = dce110_set_cursor_attribute,
2970 .set_backlight_level = dce110_set_backlight_level,
2971 .set_abm_immediate_disable = dce110_set_abm_immediate_disable,
2972 .set_pipe = dce110_set_pipe,
2975 static const struct hwseq_private_funcs dce110_private_funcs = {
2976 .init_pipes = init_pipes,
2977 .update_plane_addr = update_plane_addr,
2978 .set_input_transfer_func = dce110_set_input_transfer_func,
2979 .set_output_transfer_func = dce110_set_output_transfer_func,
2980 .power_down = dce110_power_down,
2981 .enable_display_pipe_clock_gating = enable_display_pipe_clock_gating,
2982 .enable_display_power_gating = dce110_enable_display_power_gating,
2983 .reset_hw_ctx_wrap = dce110_reset_hw_ctx_wrap,
2984 .enable_stream_timing = dce110_enable_stream_timing,
2985 .disable_stream_gating = NULL,
2986 .enable_stream_gating = NULL,
2987 .edp_backlight_control = dce110_edp_backlight_control,
2990 void dce110_hw_sequencer_construct(struct dc *dc)
2992 dc->hwss = dce110_funcs;
2993 dc->hwseq->funcs = dce110_private_funcs;