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 "clock_source.h"
55 #include "reg_helper.h"
57 /* include DCE11 register header files */
58 #include "dce/dce_11_0_d.h"
59 #include "dce/dce_11_0_sh_mask.h"
60 #include "custom_float.h"
62 #include "atomfirmware.h"
65 * All values are in milliseconds;
66 * For eDP, after power-up/power/down,
67 * 300/500 msec max. delay from LCDVCC to black video generation
69 #define PANEL_POWER_UP_TIMEOUT 300
70 #define PANEL_POWER_DOWN_TIMEOUT 500
71 #define HPD_CHECK_INTERVAL 10
76 #define DC_LOGGER_INIT()
82 #define FN(reg_name, field_name) \
83 hws->shifts->field_name, hws->masks->field_name
85 struct dce110_hw_seq_reg_offsets
{
89 static const struct dce110_hw_seq_reg_offsets reg_offsets
[] = {
91 .crtc
= (mmCRTC0_CRTC_GSL_CONTROL
- mmCRTC_GSL_CONTROL
),
94 .crtc
= (mmCRTC1_CRTC_GSL_CONTROL
- mmCRTC_GSL_CONTROL
),
97 .crtc
= (mmCRTC2_CRTC_GSL_CONTROL
- mmCRTC_GSL_CONTROL
),
100 .crtc
= (mmCRTCV_GSL_CONTROL
- mmCRTC_GSL_CONTROL
),
104 #define HW_REG_BLND(reg, id)\
105 (reg + reg_offsets[id].blnd)
107 #define HW_REG_CRTC(reg, id)\
108 (reg + reg_offsets[id].crtc)
110 #define MAX_WATERMARK 0xFFFF
111 #define SAFE_NBP_MARK 0x7FFF
113 /*******************************************************************************
114 * Private definitions
115 ******************************************************************************/
116 /***************************PIPE_CONTROL***********************************/
117 static void dce110_init_pte(struct dc_context
*ctx
)
121 uint32_t chunk_int
= 0;
122 uint32_t chunk_mul
= 0;
124 addr
= mmUNP_DVMM_PTE_CONTROL
;
125 value
= dm_read_reg(ctx
, addr
);
131 DVMM_USE_SINGLE_PTE
);
137 DVMM_PTE_BUFFER_MODE0
);
143 DVMM_PTE_BUFFER_MODE1
);
145 dm_write_reg(ctx
, addr
, value
);
147 addr
= mmDVMM_PTE_REQ
;
148 value
= dm_read_reg(ctx
, addr
);
150 chunk_int
= get_reg_field_value(
153 HFLIP_PTEREQ_PER_CHUNK_INT
);
155 chunk_mul
= get_reg_field_value(
158 HFLIP_PTEREQ_PER_CHUNK_MULTIPLIER
);
160 if (chunk_int
!= 0x4 || chunk_mul
!= 0x4) {
166 MAX_PTEREQ_TO_ISSUE
);
172 HFLIP_PTEREQ_PER_CHUNK_INT
);
178 HFLIP_PTEREQ_PER_CHUNK_MULTIPLIER
);
180 dm_write_reg(ctx
, addr
, value
);
183 /**************************************************************************/
185 static void enable_display_pipe_clock_gating(
186 struct dc_context
*ctx
,
192 static bool dce110_enable_display_power_gating(
194 uint8_t controller_id
,
196 enum pipe_gating_control power_gating
)
198 enum bp_result bp_result
= BP_RESULT_OK
;
199 enum bp_pipe_control_action cntl
;
200 struct dc_context
*ctx
= dc
->ctx
;
201 unsigned int underlay_idx
= dc
->res_pool
->underlay_pipe_index
;
203 if (IS_FPGA_MAXIMUS_DC(ctx
->dce_environment
))
206 if (power_gating
== PIPE_GATING_CONTROL_INIT
)
207 cntl
= ASIC_PIPE_INIT
;
208 else if (power_gating
== PIPE_GATING_CONTROL_ENABLE
)
209 cntl
= ASIC_PIPE_ENABLE
;
211 cntl
= ASIC_PIPE_DISABLE
;
213 if (controller_id
== underlay_idx
)
214 controller_id
= CONTROLLER_ID_UNDERLAY0
- 1;
216 if (power_gating
!= PIPE_GATING_CONTROL_INIT
|| controller_id
== 0){
218 bp_result
= dcb
->funcs
->enable_disp_power_gating(
219 dcb
, controller_id
+ 1, cntl
);
221 /* Revert MASTER_UPDATE_MODE to 0 because bios sets it 2
222 * by default when command table is called
224 * Bios parser accepts controller_id = 6 as indicative of
225 * underlay pipe in dce110. But we do not support more
228 if (controller_id
< CONTROLLER_ID_MAX
- 1)
230 HW_REG_CRTC(mmCRTC_MASTER_UPDATE_MODE
, controller_id
),
234 if (power_gating
!= PIPE_GATING_CONTROL_ENABLE
)
235 dce110_init_pte(ctx
);
237 if (bp_result
== BP_RESULT_OK
)
243 static void build_prescale_params(struct ipp_prescale_params
*prescale_params
,
244 const struct dc_plane_state
*plane_state
)
246 prescale_params
->mode
= IPP_PRESCALE_MODE_FIXED_UNSIGNED
;
248 switch (plane_state
->format
) {
249 case SURFACE_PIXEL_FORMAT_GRPH_RGB565
:
250 prescale_params
->scale
= 0x2082;
252 case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888
:
253 case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888
:
254 prescale_params
->scale
= 0x2020;
256 case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010
:
257 case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010
:
258 prescale_params
->scale
= 0x2008;
260 case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616
:
261 case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F
:
262 prescale_params
->scale
= 0x2000;
271 dce110_set_input_transfer_func(struct pipe_ctx
*pipe_ctx
,
272 const struct dc_plane_state
*plane_state
)
274 struct input_pixel_processor
*ipp
= pipe_ctx
->plane_res
.ipp
;
275 const struct dc_transfer_func
*tf
= NULL
;
276 struct ipp_prescale_params prescale_params
= { 0 };
282 if (plane_state
->in_transfer_func
)
283 tf
= plane_state
->in_transfer_func
;
285 build_prescale_params(&prescale_params
, plane_state
);
286 ipp
->funcs
->ipp_program_prescale(ipp
, &prescale_params
);
288 if (plane_state
->gamma_correction
&&
289 !plane_state
->gamma_correction
->is_identity
&&
290 dce_use_lut(plane_state
->format
))
291 ipp
->funcs
->ipp_program_input_lut(ipp
, plane_state
->gamma_correction
);
294 /* Default case if no input transfer function specified */
295 ipp
->funcs
->ipp_set_degamma(ipp
, IPP_DEGAMMA_MODE_HW_sRGB
);
296 } else if (tf
->type
== TF_TYPE_PREDEFINED
) {
298 case TRANSFER_FUNCTION_SRGB
:
299 ipp
->funcs
->ipp_set_degamma(ipp
, IPP_DEGAMMA_MODE_HW_sRGB
);
301 case TRANSFER_FUNCTION_BT709
:
302 ipp
->funcs
->ipp_set_degamma(ipp
, IPP_DEGAMMA_MODE_HW_xvYCC
);
304 case TRANSFER_FUNCTION_LINEAR
:
305 ipp
->funcs
->ipp_set_degamma(ipp
, IPP_DEGAMMA_MODE_BYPASS
);
307 case TRANSFER_FUNCTION_PQ
:
312 } else if (tf
->type
== TF_TYPE_BYPASS
) {
313 ipp
->funcs
->ipp_set_degamma(ipp
, IPP_DEGAMMA_MODE_BYPASS
);
315 /*TF_TYPE_DISTRIBUTED_POINTS - Not supported in DCE 11*/
322 static bool convert_to_custom_float(struct pwl_result_data
*rgb_resulted
,
323 struct curve_points
*arr_points
,
324 uint32_t hw_points_num
)
326 struct custom_float_format fmt
;
328 struct pwl_result_data
*rgb
= rgb_resulted
;
332 fmt
.exponenta_bits
= 6;
333 fmt
.mantissa_bits
= 12;
336 if (!convert_to_custom_float_format(arr_points
[0].x
, &fmt
,
337 &arr_points
[0].custom_float_x
)) {
342 if (!convert_to_custom_float_format(arr_points
[0].offset
, &fmt
,
343 &arr_points
[0].custom_float_offset
)) {
348 if (!convert_to_custom_float_format(arr_points
[0].slope
, &fmt
,
349 &arr_points
[0].custom_float_slope
)) {
354 fmt
.mantissa_bits
= 10;
357 if (!convert_to_custom_float_format(arr_points
[1].x
, &fmt
,
358 &arr_points
[1].custom_float_x
)) {
363 if (!convert_to_custom_float_format(arr_points
[1].y
, &fmt
,
364 &arr_points
[1].custom_float_y
)) {
369 if (!convert_to_custom_float_format(arr_points
[1].slope
, &fmt
,
370 &arr_points
[1].custom_float_slope
)) {
375 fmt
.mantissa_bits
= 12;
378 while (i
!= hw_points_num
) {
379 if (!convert_to_custom_float_format(rgb
->red
, &fmt
,
385 if (!convert_to_custom_float_format(rgb
->green
, &fmt
,
391 if (!convert_to_custom_float_format(rgb
->blue
, &fmt
,
397 if (!convert_to_custom_float_format(rgb
->delta_red
, &fmt
,
398 &rgb
->delta_red_reg
)) {
403 if (!convert_to_custom_float_format(rgb
->delta_green
, &fmt
,
404 &rgb
->delta_green_reg
)) {
409 if (!convert_to_custom_float_format(rgb
->delta_blue
, &fmt
,
410 &rgb
->delta_blue_reg
)) {
422 #define MAX_LOW_POINT 25
423 #define NUMBER_REGIONS 16
424 #define NUMBER_SW_SEGMENTS 16
427 dce110_translate_regamma_to_hw_format(const struct dc_transfer_func
*output_tf
,
428 struct pwl_params
*regamma_params
)
430 struct curve_points
*arr_points
;
431 struct pwl_result_data
*rgb_resulted
;
432 struct pwl_result_data
*rgb
;
433 struct pwl_result_data
*rgb_plus_1
;
434 struct fixed31_32 y_r
;
435 struct fixed31_32 y_g
;
436 struct fixed31_32 y_b
;
437 struct fixed31_32 y1_min
;
438 struct fixed31_32 y3_max
;
440 int32_t region_start
, region_end
;
441 uint32_t i
, j
, k
, seg_distr
[NUMBER_REGIONS
], increment
, start_index
, hw_points
;
443 if (output_tf
== NULL
|| regamma_params
== NULL
|| output_tf
->type
== TF_TYPE_BYPASS
)
446 arr_points
= regamma_params
->arr_points
;
447 rgb_resulted
= regamma_params
->rgb_resulted
;
450 memset(regamma_params
, 0, sizeof(struct pwl_params
));
452 if (output_tf
->tf
== TRANSFER_FUNCTION_PQ
) {
454 * segments are from 2^-11 to 2^5
457 region_end
= region_start
+ NUMBER_REGIONS
;
459 for (i
= 0; i
< NUMBER_REGIONS
; i
++)
464 * segment is from 2^-10 to 2^1
465 * We include an extra segment for range [2^0, 2^1). This is to
466 * ensure that colors with normalized values of 1 don't miss the
490 for (k
= 0; k
< 16; k
++) {
491 if (seg_distr
[k
] != -1)
492 hw_points
+= (1 << seg_distr
[k
]);
496 for (k
= 0; k
< (region_end
- region_start
); k
++) {
497 increment
= NUMBER_SW_SEGMENTS
/ (1 << seg_distr
[k
]);
498 start_index
= (region_start
+ k
+ MAX_LOW_POINT
) *
500 for (i
= start_index
; i
< start_index
+ NUMBER_SW_SEGMENTS
;
502 if (j
== hw_points
- 1)
504 rgb_resulted
[j
].red
= output_tf
->tf_pts
.red
[i
];
505 rgb_resulted
[j
].green
= output_tf
->tf_pts
.green
[i
];
506 rgb_resulted
[j
].blue
= output_tf
->tf_pts
.blue
[i
];
512 start_index
= (region_end
+ MAX_LOW_POINT
) * NUMBER_SW_SEGMENTS
;
513 rgb_resulted
[hw_points
- 1].red
= output_tf
->tf_pts
.red
[start_index
];
514 rgb_resulted
[hw_points
- 1].green
= output_tf
->tf_pts
.green
[start_index
];
515 rgb_resulted
[hw_points
- 1].blue
= output_tf
->tf_pts
.blue
[start_index
];
517 arr_points
[0].x
= dc_fixpt_pow(dc_fixpt_from_int(2),
518 dc_fixpt_from_int(region_start
));
519 arr_points
[1].x
= dc_fixpt_pow(dc_fixpt_from_int(2),
520 dc_fixpt_from_int(region_end
));
522 y_r
= rgb_resulted
[0].red
;
523 y_g
= rgb_resulted
[0].green
;
524 y_b
= rgb_resulted
[0].blue
;
526 y1_min
= dc_fixpt_min(y_r
, dc_fixpt_min(y_g
, y_b
));
528 arr_points
[0].y
= y1_min
;
529 arr_points
[0].slope
= dc_fixpt_div(arr_points
[0].y
,
532 y_r
= rgb_resulted
[hw_points
- 1].red
;
533 y_g
= rgb_resulted
[hw_points
- 1].green
;
534 y_b
= rgb_resulted
[hw_points
- 1].blue
;
536 /* see comment above, m_arrPoints[1].y should be the Y value for the
537 * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1)
539 y3_max
= dc_fixpt_max(y_r
, dc_fixpt_max(y_g
, y_b
));
541 arr_points
[1].y
= y3_max
;
543 arr_points
[1].slope
= dc_fixpt_zero
;
545 if (output_tf
->tf
== TRANSFER_FUNCTION_PQ
) {
546 /* for PQ, we want to have a straight line from last HW X point,
547 * and the slope to be such that we hit 1.0 at 10000 nits.
549 const struct fixed31_32 end_value
= dc_fixpt_from_int(125);
551 arr_points
[1].slope
= dc_fixpt_div(
552 dc_fixpt_sub(dc_fixpt_one
, arr_points
[1].y
),
553 dc_fixpt_sub(end_value
, arr_points
[1].x
));
556 regamma_params
->hw_points_num
= hw_points
;
559 for (i
= 1; i
< 16; i
++) {
560 if (seg_distr
[k
] != -1) {
561 regamma_params
->arr_curve_points
[k
].segments_num
= seg_distr
[k
];
562 regamma_params
->arr_curve_points
[i
].offset
=
563 regamma_params
->arr_curve_points
[k
].offset
+ (1 << seg_distr
[k
]);
568 if (seg_distr
[k
] != -1)
569 regamma_params
->arr_curve_points
[k
].segments_num
= seg_distr
[k
];
572 rgb_plus_1
= rgb_resulted
+ 1;
576 while (i
!= hw_points
+ 1) {
577 if (dc_fixpt_lt(rgb_plus_1
->red
, rgb
->red
))
578 rgb_plus_1
->red
= rgb
->red
;
579 if (dc_fixpt_lt(rgb_plus_1
->green
, rgb
->green
))
580 rgb_plus_1
->green
= rgb
->green
;
581 if (dc_fixpt_lt(rgb_plus_1
->blue
, rgb
->blue
))
582 rgb_plus_1
->blue
= rgb
->blue
;
584 rgb
->delta_red
= dc_fixpt_sub(rgb_plus_1
->red
, rgb
->red
);
585 rgb
->delta_green
= dc_fixpt_sub(rgb_plus_1
->green
, rgb
->green
);
586 rgb
->delta_blue
= dc_fixpt_sub(rgb_plus_1
->blue
, rgb
->blue
);
593 convert_to_custom_float(rgb_resulted
, arr_points
, hw_points
);
599 dce110_set_output_transfer_func(struct pipe_ctx
*pipe_ctx
,
600 const struct dc_stream_state
*stream
)
602 struct transform
*xfm
= pipe_ctx
->plane_res
.xfm
;
604 xfm
->funcs
->opp_power_on_regamma_lut(xfm
, true);
605 xfm
->regamma_params
.hw_points_num
= GAMMA_HW_POINTS_NUM
;
607 if (stream
->out_transfer_func
&&
608 stream
->out_transfer_func
->type
== TF_TYPE_PREDEFINED
&&
609 stream
->out_transfer_func
->tf
== TRANSFER_FUNCTION_SRGB
) {
610 xfm
->funcs
->opp_set_regamma_mode(xfm
, OPP_REGAMMA_SRGB
);
611 } else if (dce110_translate_regamma_to_hw_format(stream
->out_transfer_func
,
612 &xfm
->regamma_params
)) {
613 xfm
->funcs
->opp_program_regamma_pwl(xfm
, &xfm
->regamma_params
);
614 xfm
->funcs
->opp_set_regamma_mode(xfm
, OPP_REGAMMA_USER
);
616 xfm
->funcs
->opp_set_regamma_mode(xfm
, OPP_REGAMMA_BYPASS
);
619 xfm
->funcs
->opp_power_on_regamma_lut(xfm
, false);
624 void dce110_update_info_frame(struct pipe_ctx
*pipe_ctx
)
629 ASSERT(pipe_ctx
->stream
);
631 if (pipe_ctx
->stream_res
.stream_enc
== NULL
)
632 return; /* this is not root pipe */
634 is_hdmi_tmds
= dc_is_hdmi_tmds_signal(pipe_ctx
->stream
->signal
);
635 is_dp
= dc_is_dp_signal(pipe_ctx
->stream
->signal
);
637 if (!is_hdmi_tmds
&& !is_dp
)
641 pipe_ctx
->stream_res
.stream_enc
->funcs
->update_hdmi_info_packets(
642 pipe_ctx
->stream_res
.stream_enc
,
643 &pipe_ctx
->stream_res
.encoder_info_frame
);
645 pipe_ctx
->stream_res
.stream_enc
->funcs
->update_dp_info_packets(
646 pipe_ctx
->stream_res
.stream_enc
,
647 &pipe_ctx
->stream_res
.encoder_info_frame
);
650 void dce110_enable_stream(struct pipe_ctx
*pipe_ctx
)
652 enum dc_lane_count lane_count
=
653 pipe_ctx
->stream
->link
->cur_link_settings
.lane_count
;
655 struct dc_crtc_timing
*timing
= &pipe_ctx
->stream
->timing
;
656 struct dc_link
*link
= pipe_ctx
->stream
->link
;
659 uint32_t active_total_with_borders
;
660 uint32_t early_control
= 0;
661 struct timing_generator
*tg
= pipe_ctx
->stream_res
.tg
;
663 /* For MST, there are multiply stream go to only one link.
664 * connect DIG back_end to front_end while enable_stream and
665 * disconnect them during disable_stream
666 * BY this, it is logic clean to separate stream and link */
667 link
->link_enc
->funcs
->connect_dig_be_to_fe(link
->link_enc
,
668 pipe_ctx
->stream_res
.stream_enc
->id
, true);
670 /* update AVI info frame (HDMI, DP)*/
671 /* TODO: FPGA may change to hwss.update_info_frame */
673 #if defined(CONFIG_DRM_AMD_DC_DCN2_0)
674 if (pipe_ctx
->stream_res
.stream_enc
->funcs
->set_dynamic_metadata
!= NULL
&&
675 pipe_ctx
->plane_res
.hubp
!= NULL
) {
676 if (pipe_ctx
->stream
->dmdata_address
.quad_part
!= 0) {
677 /* if using dynamic meta, don't set up generic infopackets */
678 pipe_ctx
->stream_res
.encoder_info_frame
.hdrsmd
.valid
= false;
679 pipe_ctx
->stream_res
.stream_enc
->funcs
->set_dynamic_metadata(
680 pipe_ctx
->stream_res
.stream_enc
,
681 true, pipe_ctx
->plane_res
.hubp
->inst
,
682 dc_is_dp_signal(pipe_ctx
->stream
->signal
) ?
683 dmdata_dp
: dmdata_hdmi
);
685 pipe_ctx
->stream_res
.stream_enc
->funcs
->set_dynamic_metadata(
686 pipe_ctx
->stream_res
.stream_enc
,
687 false, pipe_ctx
->plane_res
.hubp
->inst
,
688 dc_is_dp_signal(pipe_ctx
->stream
->signal
) ?
689 dmdata_dp
: dmdata_hdmi
);
692 dce110_update_info_frame(pipe_ctx
);
694 /* enable early control to avoid corruption on DP monitor*/
695 active_total_with_borders
=
696 timing
->h_addressable
697 + timing
->h_border_left
698 + timing
->h_border_right
;
701 early_control
= active_total_with_borders
% lane_count
;
703 if (early_control
== 0)
704 early_control
= lane_count
;
706 tg
->funcs
->set_early_control(tg
, early_control
);
708 /* enable audio only within mode set */
709 if (pipe_ctx
->stream_res
.audio
!= NULL
) {
710 if (dc_is_dp_signal(pipe_ctx
->stream
->signal
))
711 pipe_ctx
->stream_res
.stream_enc
->funcs
->dp_audio_enable(pipe_ctx
->stream_res
.stream_enc
);
719 /*todo: cloned in stream enc, fix*/
720 static bool is_panel_backlight_on(struct dce_hwseq
*hws
)
724 REG_GET(LVTMA_PWRSEQ_CNTL
, LVTMA_BLON
, &value
);
729 static bool is_panel_powered_on(struct dce_hwseq
*hws
)
731 uint32_t pwr_seq_state
, dig_on
, dig_on_ovrd
;
734 REG_GET(LVTMA_PWRSEQ_STATE
, LVTMA_PWRSEQ_TARGET_STATE_R
, &pwr_seq_state
);
736 REG_GET_2(LVTMA_PWRSEQ_CNTL
, LVTMA_DIGON
, &dig_on
, LVTMA_DIGON_OVRD
, &dig_on_ovrd
);
738 return (pwr_seq_state
== 1) || (dig_on
== 1 && dig_on_ovrd
== 1);
741 static enum bp_result
link_transmitter_control(
742 struct dc_bios
*bios
,
743 struct bp_transmitter_control
*cntl
)
745 enum bp_result result
;
747 result
= bios
->funcs
->transmitter_control(bios
, cntl
);
756 void hwss_edp_wait_for_hpd_ready(
757 struct dc_link
*link
,
760 struct dc_context
*ctx
= link
->ctx
;
761 struct graphics_object_id connector
= link
->link_enc
->connector
;
763 bool edp_hpd_high
= false;
764 uint32_t time_elapsed
= 0;
765 uint32_t timeout
= power_up
?
766 PANEL_POWER_UP_TIMEOUT
: PANEL_POWER_DOWN_TIMEOUT
;
768 if (dal_graphics_object_id_get_connector_id(connector
)
769 != CONNECTOR_ID_EDP
) {
776 * From KV, we will not HPD low after turning off VCC -
777 * instead, we will check the SW timer in power_up().
782 * When we power on/off the eDP panel,
783 * we need to wait until SENSE bit is high/low.
787 /* TODO what to do with this? */
788 hpd
= get_hpd_gpio(ctx
->dc_bios
, connector
, ctx
->gpio_service
);
795 dal_gpio_open(hpd
, GPIO_MODE_INTERRUPT
);
797 /* wait until timeout or panel detected */
800 uint32_t detected
= 0;
802 dal_gpio_get_value(hpd
, &detected
);
804 if (!(detected
^ power_up
)) {
809 msleep(HPD_CHECK_INTERVAL
);
811 time_elapsed
+= HPD_CHECK_INTERVAL
;
812 } while (time_elapsed
< timeout
);
816 dal_gpio_destroy_irq(&hpd
);
818 if (false == edp_hpd_high
) {
820 "%s: wait timed out!\n", __func__
);
824 void hwss_edp_power_control(
825 struct dc_link
*link
,
828 struct dc_context
*ctx
= link
->ctx
;
829 struct dce_hwseq
*hwseq
= ctx
->dc
->hwseq
;
830 struct bp_transmitter_control cntl
= { 0 };
831 enum bp_result bp_result
;
834 if (dal_graphics_object_id_get_connector_id(link
->link_enc
->connector
)
835 != CONNECTOR_ID_EDP
) {
840 if (power_up
!= is_panel_powered_on(hwseq
)) {
841 /* Send VBIOS command to prompt eDP panel power */
843 unsigned long long current_ts
= dm_get_timestamp(ctx
);
844 unsigned long long duration_in_ms
=
845 div64_u64(dm_get_elapse_time_in_ns(
848 link
->link_trace
.time_stamp
.edp_poweroff
), 1000000);
849 unsigned long long wait_time_ms
= 0;
851 /* max 500ms from LCDVDD off to on */
852 unsigned long long edp_poweroff_time_ms
= 500;
854 if (link
->local_sink
!= NULL
)
855 edp_poweroff_time_ms
=
856 500 + link
->local_sink
->edid_caps
.panel_patch
.extra_t12_ms
;
857 if (link
->link_trace
.time_stamp
.edp_poweroff
== 0)
858 wait_time_ms
= edp_poweroff_time_ms
;
859 else if (duration_in_ms
< edp_poweroff_time_ms
)
860 wait_time_ms
= edp_poweroff_time_ms
- duration_in_ms
;
863 msleep(wait_time_ms
);
864 dm_output_to_console("%s: wait %lld ms to power on eDP.\n",
865 __func__
, wait_time_ms
);
871 "%s: Panel Power action: %s\n",
872 __func__
, (power_up
? "On":"Off"));
874 cntl
.action
= power_up
?
875 TRANSMITTER_CONTROL_POWER_ON
:
876 TRANSMITTER_CONTROL_POWER_OFF
;
877 cntl
.transmitter
= link
->link_enc
->transmitter
;
878 cntl
.connector_obj_id
= link
->link_enc
->connector
;
879 cntl
.coherent
= false;
880 cntl
.lanes_number
= LANE_COUNT_FOUR
;
881 cntl
.hpd_sel
= link
->link_enc
->hpd_source
;
882 bp_result
= link_transmitter_control(ctx
->dc_bios
, &cntl
);
885 /*save driver power off time stamp*/
886 link
->link_trace
.time_stamp
.edp_poweroff
= dm_get_timestamp(ctx
);
888 link
->link_trace
.time_stamp
.edp_poweron
= dm_get_timestamp(ctx
);
890 if (bp_result
!= BP_RESULT_OK
)
892 "%s: Panel Power bp_result: %d\n",
893 __func__
, bp_result
);
896 "%s: Skipping Panel Power action: %s\n",
897 __func__
, (power_up
? "On":"Off"));
901 /*todo: cloned in stream enc, fix*/
904 * eDP only. Control the backlight of the eDP panel
906 void hwss_edp_backlight_control(
907 struct dc_link
*link
,
910 struct dc_context
*ctx
= link
->ctx
;
911 struct dce_hwseq
*hws
= ctx
->dc
->hwseq
;
912 struct bp_transmitter_control cntl
= { 0 };
914 if (dal_graphics_object_id_get_connector_id(link
->link_enc
->connector
)
915 != CONNECTOR_ID_EDP
) {
920 if (enable
&& is_panel_backlight_on(hws
)) {
922 "%s: panel already powered up. Do nothing.\n",
927 /* Send VBIOS command to control eDP panel backlight */
930 "%s: backlight action: %s\n",
931 __func__
, (enable
? "On":"Off"));
933 cntl
.action
= enable
?
934 TRANSMITTER_CONTROL_BACKLIGHT_ON
:
935 TRANSMITTER_CONTROL_BACKLIGHT_OFF
;
937 /*cntl.engine_id = ctx->engine;*/
938 cntl
.transmitter
= link
->link_enc
->transmitter
;
939 cntl
.connector_obj_id
= link
->link_enc
->connector
;
941 cntl
.lanes_number
= LANE_COUNT_FOUR
;
942 cntl
.hpd_sel
= link
->link_enc
->hpd_source
;
943 cntl
.signal
= SIGNAL_TYPE_EDP
;
945 /* For eDP, the following delays might need to be considered
946 * after link training completed:
947 * idle period - min. accounts for required BS-Idle pattern,
948 * max. allows for source frame synchronization);
949 * 50 msec max. delay from valid video data from source
950 * to video on dislpay or backlight enable.
952 * Disable the delay for now.
953 * Enable it in the future if necessary.
955 /* dc_service_sleep_in_milliseconds(50); */
957 if (cntl
.action
== TRANSMITTER_CONTROL_BACKLIGHT_ON
)
958 edp_receiver_ready_T7(link
);
959 link_transmitter_control(ctx
->dc_bios
, &cntl
);
961 if (cntl
.action
== TRANSMITTER_CONTROL_BACKLIGHT_OFF
)
962 edp_receiver_ready_T9(link
);
965 void dce110_enable_audio_stream(struct pipe_ctx
*pipe_ctx
)
967 /* notify audio driver for audio modes of monitor */
969 struct pp_smu_funcs
*pp_smu
= NULL
;
970 struct clk_mgr
*clk_mgr
;
971 unsigned int i
, num_audio
= 1;
973 if (!pipe_ctx
->stream
)
976 core_dc
= pipe_ctx
->stream
->ctx
->dc
;
977 clk_mgr
= core_dc
->clk_mgr
;
979 if (pipe_ctx
->stream_res
.audio
&& pipe_ctx
->stream_res
.audio
->enabled
== true)
982 if (core_dc
->res_pool
->pp_smu
)
983 pp_smu
= core_dc
->res_pool
->pp_smu
;
985 if (pipe_ctx
->stream_res
.audio
) {
986 for (i
= 0; i
< MAX_PIPES
; i
++) {
987 /*current_state not updated yet*/
988 if (core_dc
->current_state
->res_ctx
.pipe_ctx
[i
].stream_res
.audio
!= NULL
)
992 pipe_ctx
->stream_res
.audio
->funcs
->az_enable(pipe_ctx
->stream_res
.audio
);
994 if (num_audio
>= 1 && clk_mgr
->funcs
->enable_pme_wa
)
995 /*this is the first audio. apply the PME w/a in order to wake AZ from D3*/
996 clk_mgr
->funcs
->enable_pme_wa(clk_mgr
);
998 /* TODO: audio should be per stream rather than per link */
999 pipe_ctx
->stream_res
.stream_enc
->funcs
->audio_mute_control(
1000 pipe_ctx
->stream_res
.stream_enc
, false);
1001 if (pipe_ctx
->stream_res
.audio
)
1002 pipe_ctx
->stream_res
.audio
->enabled
= true;
1006 void dce110_disable_audio_stream(struct pipe_ctx
*pipe_ctx
, int option
)
1009 struct pp_smu_funcs
*pp_smu
= NULL
;
1010 struct clk_mgr
*clk_mgr
;
1012 if (!pipe_ctx
|| !pipe_ctx
->stream
)
1015 dc
= pipe_ctx
->stream
->ctx
->dc
;
1016 clk_mgr
= dc
->clk_mgr
;
1018 if (pipe_ctx
->stream_res
.audio
&& pipe_ctx
->stream_res
.audio
->enabled
== false)
1021 pipe_ctx
->stream_res
.stream_enc
->funcs
->audio_mute_control(
1022 pipe_ctx
->stream_res
.stream_enc
, true);
1023 if (pipe_ctx
->stream_res
.audio
) {
1024 pipe_ctx
->stream_res
.audio
->enabled
= false;
1026 if (dc
->res_pool
->pp_smu
)
1027 pp_smu
= dc
->res_pool
->pp_smu
;
1029 if (option
!= KEEP_ACQUIRED_RESOURCE
||
1030 !dc
->debug
.az_endpoint_mute_only
)
1031 /*only disalbe az_endpoint if power down or free*/
1032 pipe_ctx
->stream_res
.audio
->funcs
->az_disable(pipe_ctx
->stream_res
.audio
);
1034 if (dc_is_dp_signal(pipe_ctx
->stream
->signal
))
1035 pipe_ctx
->stream_res
.stream_enc
->funcs
->dp_audio_disable(
1036 pipe_ctx
->stream_res
.stream_enc
);
1038 pipe_ctx
->stream_res
.stream_enc
->funcs
->hdmi_audio_disable(
1039 pipe_ctx
->stream_res
.stream_enc
);
1040 /*don't free audio if it is from retrain or internal disable stream*/
1041 if (option
== FREE_ACQUIRED_RESOURCE
&& dc
->caps
.dynamic_audio
== true) {
1042 /*we have to dynamic arbitrate the audio endpoints*/
1043 /*we free the resource, need reset is_audio_acquired*/
1044 update_audio_usage(&dc
->current_state
->res_ctx
, dc
->res_pool
, pipe_ctx
->stream_res
.audio
, false);
1045 pipe_ctx
->stream_res
.audio
= NULL
;
1047 if (clk_mgr
->funcs
->enable_pme_wa
)
1048 /*this is the first audio. apply the PME w/a in order to wake AZ from D3*/
1049 clk_mgr
->funcs
->enable_pme_wa(clk_mgr
);
1051 /* TODO: notify audio driver for if audio modes list changed
1052 * add audio mode list change flag */
1053 /* dal_audio_disable_azalia_audio_jack_presence(stream->audio,
1054 * stream->stream_engine_id);
1059 void dce110_disable_stream(struct pipe_ctx
*pipe_ctx
, int option
)
1061 struct dc_stream_state
*stream
= pipe_ctx
->stream
;
1062 struct dc_link
*link
= stream
->link
;
1063 struct dc
*dc
= pipe_ctx
->stream
->ctx
->dc
;
1065 if (dc_is_hdmi_tmds_signal(pipe_ctx
->stream
->signal
))
1066 pipe_ctx
->stream_res
.stream_enc
->funcs
->stop_hdmi_info_packets(
1067 pipe_ctx
->stream_res
.stream_enc
);
1069 if (dc_is_dp_signal(pipe_ctx
->stream
->signal
))
1070 pipe_ctx
->stream_res
.stream_enc
->funcs
->stop_dp_info_packets(
1071 pipe_ctx
->stream_res
.stream_enc
);
1073 dc
->hwss
.disable_audio_stream(pipe_ctx
, option
);
1075 link
->link_enc
->funcs
->connect_dig_be_to_fe(
1077 pipe_ctx
->stream_res
.stream_enc
->id
,
1082 void dce110_unblank_stream(struct pipe_ctx
*pipe_ctx
,
1083 struct dc_link_settings
*link_settings
)
1085 struct encoder_unblank_param params
= { { 0 } };
1086 struct dc_stream_state
*stream
= pipe_ctx
->stream
;
1087 struct dc_link
*link
= stream
->link
;
1089 /* only 3 items below are used by unblank */
1090 params
.timing
= pipe_ctx
->stream
->timing
;
1091 params
.link_settings
.link_rate
= link_settings
->link_rate
;
1093 if (dc_is_dp_signal(pipe_ctx
->stream
->signal
))
1094 pipe_ctx
->stream_res
.stream_enc
->funcs
->dp_unblank(pipe_ctx
->stream_res
.stream_enc
, ¶ms
);
1096 if (link
->local_sink
&& link
->local_sink
->sink_signal
== SIGNAL_TYPE_EDP
) {
1097 link
->dc
->hwss
.edp_backlight_control(link
, true);
1101 void dce110_blank_stream(struct pipe_ctx
*pipe_ctx
)
1103 struct dc_stream_state
*stream
= pipe_ctx
->stream
;
1104 struct dc_link
*link
= stream
->link
;
1106 if (link
->local_sink
&& link
->local_sink
->sink_signal
== SIGNAL_TYPE_EDP
) {
1107 link
->dc
->hwss
.edp_backlight_control(link
, false);
1108 dc_link_set_abm_disable(link
);
1111 if (dc_is_dp_signal(pipe_ctx
->stream
->signal
))
1112 pipe_ctx
->stream_res
.stream_enc
->funcs
->dp_blank(pipe_ctx
->stream_res
.stream_enc
);
1116 void dce110_set_avmute(struct pipe_ctx
*pipe_ctx
, bool enable
)
1118 if (pipe_ctx
!= NULL
&& pipe_ctx
->stream_res
.stream_enc
!= NULL
)
1119 pipe_ctx
->stream_res
.stream_enc
->funcs
->set_avmute(pipe_ctx
->stream_res
.stream_enc
, enable
);
1122 static enum audio_dto_source
translate_to_dto_source(enum controller_id crtc_id
)
1125 case CONTROLLER_ID_D0
:
1126 return DTO_SOURCE_ID0
;
1127 case CONTROLLER_ID_D1
:
1128 return DTO_SOURCE_ID1
;
1129 case CONTROLLER_ID_D2
:
1130 return DTO_SOURCE_ID2
;
1131 case CONTROLLER_ID_D3
:
1132 return DTO_SOURCE_ID3
;
1133 case CONTROLLER_ID_D4
:
1134 return DTO_SOURCE_ID4
;
1135 case CONTROLLER_ID_D5
:
1136 return DTO_SOURCE_ID5
;
1138 return DTO_SOURCE_UNKNOWN
;
1142 static void build_audio_output(
1143 struct dc_state
*state
,
1144 const struct pipe_ctx
*pipe_ctx
,
1145 struct audio_output
*audio_output
)
1147 const struct dc_stream_state
*stream
= pipe_ctx
->stream
;
1148 audio_output
->engine_id
= pipe_ctx
->stream_res
.stream_enc
->id
;
1150 audio_output
->signal
= pipe_ctx
->stream
->signal
;
1152 /* audio_crtc_info */
1154 audio_output
->crtc_info
.h_total
=
1155 stream
->timing
.h_total
;
1158 * Audio packets are sent during actual CRTC blank physical signal, we
1159 * need to specify actual active signal portion
1161 audio_output
->crtc_info
.h_active
=
1162 stream
->timing
.h_addressable
1163 + stream
->timing
.h_border_left
1164 + stream
->timing
.h_border_right
;
1166 audio_output
->crtc_info
.v_active
=
1167 stream
->timing
.v_addressable
1168 + stream
->timing
.v_border_top
1169 + stream
->timing
.v_border_bottom
;
1171 audio_output
->crtc_info
.pixel_repetition
= 1;
1173 audio_output
->crtc_info
.interlaced
=
1174 stream
->timing
.flags
.INTERLACE
;
1176 audio_output
->crtc_info
.refresh_rate
=
1177 (stream
->timing
.pix_clk_100hz
*10000)/
1178 (stream
->timing
.h_total
*stream
->timing
.v_total
);
1180 audio_output
->crtc_info
.color_depth
=
1181 stream
->timing
.display_color_depth
;
1183 audio_output
->crtc_info
.requested_pixel_clock
=
1184 pipe_ctx
->stream_res
.pix_clk_params
.requested_pix_clk_100hz
/ 10;
1186 audio_output
->crtc_info
.calculated_pixel_clock
=
1187 pipe_ctx
->stream_res
.pix_clk_params
.requested_pix_clk_100hz
/ 10;
1189 /*for HDMI, audio ACR is with deep color ratio factor*/
1190 if (dc_is_hdmi_signal(pipe_ctx
->stream
->signal
) &&
1191 audio_output
->crtc_info
.requested_pixel_clock
==
1192 (stream
->timing
.pix_clk_100hz
/ 10)) {
1193 if (pipe_ctx
->stream_res
.pix_clk_params
.pixel_encoding
== PIXEL_ENCODING_YCBCR420
) {
1194 audio_output
->crtc_info
.requested_pixel_clock
=
1195 audio_output
->crtc_info
.requested_pixel_clock
/2;
1196 audio_output
->crtc_info
.calculated_pixel_clock
=
1197 pipe_ctx
->stream_res
.pix_clk_params
.requested_pix_clk_100hz
/20;
1202 if (pipe_ctx
->stream
->signal
== SIGNAL_TYPE_DISPLAY_PORT
||
1203 pipe_ctx
->stream
->signal
== SIGNAL_TYPE_DISPLAY_PORT_MST
) {
1204 audio_output
->pll_info
.dp_dto_source_clock_in_khz
=
1205 state
->clk_mgr
->funcs
->get_dp_ref_clk_frequency(
1209 audio_output
->pll_info
.feed_back_divider
=
1210 pipe_ctx
->pll_settings
.feedback_divider
;
1212 audio_output
->pll_info
.dto_source
=
1213 translate_to_dto_source(
1214 pipe_ctx
->stream_res
.tg
->inst
+ 1);
1216 /* TODO hard code to enable for now. Need get from stream */
1217 audio_output
->pll_info
.ss_enabled
= true;
1219 audio_output
->pll_info
.ss_percentage
=
1220 pipe_ctx
->pll_settings
.ss_percentage
;
1223 static void get_surface_visual_confirm_color(const struct pipe_ctx
*pipe_ctx
,
1224 struct tg_color
*color
)
1226 uint32_t color_value
= MAX_TG_COLOR_VALUE
* (4 - pipe_ctx
->stream_res
.tg
->inst
) / 4;
1228 switch (pipe_ctx
->plane_res
.scl_data
.format
) {
1229 case PIXEL_FORMAT_ARGB8888
:
1230 /* set boarder color to red */
1231 color
->color_r_cr
= color_value
;
1234 case PIXEL_FORMAT_ARGB2101010
:
1235 /* set boarder color to blue */
1236 color
->color_b_cb
= color_value
;
1238 case PIXEL_FORMAT_420BPP8
:
1239 /* set boarder color to green */
1240 color
->color_g_y
= color_value
;
1242 case PIXEL_FORMAT_420BPP10
:
1243 /* set boarder color to yellow */
1244 color
->color_g_y
= color_value
;
1245 color
->color_r_cr
= color_value
;
1247 case PIXEL_FORMAT_FP16
:
1248 /* set boarder color to white */
1249 color
->color_r_cr
= color_value
;
1250 color
->color_b_cb
= color_value
;
1251 color
->color_g_y
= color_value
;
1258 static void program_scaler(const struct dc
*dc
,
1259 const struct pipe_ctx
*pipe_ctx
)
1261 struct tg_color color
= {0};
1263 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
1265 if (pipe_ctx
->plane_res
.xfm
->funcs
->transform_set_pixel_storage_depth
== NULL
)
1269 if (dc
->debug
.visual_confirm
== VISUAL_CONFIRM_SURFACE
)
1270 get_surface_visual_confirm_color(pipe_ctx
, &color
);
1272 color_space_to_black_color(dc
,
1273 pipe_ctx
->stream
->output_color_space
,
1276 pipe_ctx
->plane_res
.xfm
->funcs
->transform_set_pixel_storage_depth(
1277 pipe_ctx
->plane_res
.xfm
,
1278 pipe_ctx
->plane_res
.scl_data
.lb_params
.depth
,
1279 &pipe_ctx
->stream
->bit_depth_params
);
1281 if (pipe_ctx
->stream_res
.tg
->funcs
->set_overscan_blank_color
) {
1283 * The way 420 is packed, 2 channels carry Y component, 1 channel
1284 * alternate between Cb and Cr, so both channels need the pixel
1287 if (pipe_ctx
->stream
->timing
.pixel_encoding
== PIXEL_ENCODING_YCBCR420
)
1288 color
.color_r_cr
= color
.color_g_y
;
1290 pipe_ctx
->stream_res
.tg
->funcs
->set_overscan_blank_color(
1291 pipe_ctx
->stream_res
.tg
,
1295 pipe_ctx
->plane_res
.xfm
->funcs
->transform_set_scaler(pipe_ctx
->plane_res
.xfm
,
1296 &pipe_ctx
->plane_res
.scl_data
);
1299 static enum dc_status
dce110_enable_stream_timing(
1300 struct pipe_ctx
*pipe_ctx
,
1301 struct dc_state
*context
,
1304 struct dc_stream_state
*stream
= pipe_ctx
->stream
;
1305 struct pipe_ctx
*pipe_ctx_old
= &dc
->current_state
->res_ctx
.
1306 pipe_ctx
[pipe_ctx
->pipe_idx
];
1307 struct tg_color black_color
= {0};
1309 if (!pipe_ctx_old
->stream
) {
1311 /* program blank color */
1312 color_space_to_black_color(dc
,
1313 stream
->output_color_space
, &black_color
);
1314 pipe_ctx
->stream_res
.tg
->funcs
->set_blank_color(
1315 pipe_ctx
->stream_res
.tg
,
1319 * Must blank CRTC after disabling power gating and before any
1320 * programming, otherwise CRTC will be hung in bad state
1322 pipe_ctx
->stream_res
.tg
->funcs
->set_blank(pipe_ctx
->stream_res
.tg
, true);
1324 if (false == pipe_ctx
->clock_source
->funcs
->program_pix_clk(
1325 pipe_ctx
->clock_source
,
1326 &pipe_ctx
->stream_res
.pix_clk_params
,
1327 &pipe_ctx
->pll_settings
)) {
1328 BREAK_TO_DEBUGGER();
1329 return DC_ERROR_UNEXPECTED
;
1332 pipe_ctx
->stream_res
.tg
->funcs
->program_timing(
1333 pipe_ctx
->stream_res
.tg
,
1339 pipe_ctx
->stream
->signal
,
1343 if (!pipe_ctx_old
->stream
) {
1344 if (false == pipe_ctx
->stream_res
.tg
->funcs
->enable_crtc(
1345 pipe_ctx
->stream_res
.tg
)) {
1346 BREAK_TO_DEBUGGER();
1347 return DC_ERROR_UNEXPECTED
;
1354 static enum dc_status
apply_single_controller_ctx_to_hw(
1355 struct pipe_ctx
*pipe_ctx
,
1356 struct dc_state
*context
,
1359 struct dc_stream_state
*stream
= pipe_ctx
->stream
;
1360 struct drr_params params
= {0};
1361 unsigned int event_triggers
= 0;
1362 #if defined(CONFIG_DRM_AMD_DC_DCN2_0)
1363 struct pipe_ctx
*odm_pipe
= dc_res_get_odm_bottom_pipe(pipe_ctx
);
1366 if (dc
->hwss
.disable_stream_gating
) {
1367 dc
->hwss
.disable_stream_gating(dc
, pipe_ctx
);
1370 if (pipe_ctx
->stream_res
.audio
!= NULL
) {
1371 struct audio_output audio_output
;
1373 build_audio_output(context
, pipe_ctx
, &audio_output
);
1375 if (dc_is_dp_signal(pipe_ctx
->stream
->signal
))
1376 pipe_ctx
->stream_res
.stream_enc
->funcs
->dp_audio_setup(
1377 pipe_ctx
->stream_res
.stream_enc
,
1378 pipe_ctx
->stream_res
.audio
->inst
,
1379 &pipe_ctx
->stream
->audio_info
);
1381 pipe_ctx
->stream_res
.stream_enc
->funcs
->hdmi_audio_setup(
1382 pipe_ctx
->stream_res
.stream_enc
,
1383 pipe_ctx
->stream_res
.audio
->inst
,
1384 &pipe_ctx
->stream
->audio_info
,
1385 &audio_output
.crtc_info
);
1387 pipe_ctx
->stream_res
.audio
->funcs
->az_configure(
1388 pipe_ctx
->stream_res
.audio
,
1389 pipe_ctx
->stream
->signal
,
1390 &audio_output
.crtc_info
,
1391 &pipe_ctx
->stream
->audio_info
);
1395 /* Do not touch stream timing on seamless boot optimization. */
1396 if (!pipe_ctx
->stream
->apply_seamless_boot_optimization
)
1397 dc
->hwss
.enable_stream_timing(pipe_ctx
, context
, dc
);
1399 if (dc
->hwss
.setup_vupdate_interrupt
)
1400 dc
->hwss
.setup_vupdate_interrupt(pipe_ctx
);
1402 params
.vertical_total_min
= stream
->adjust
.v_total_min
;
1403 params
.vertical_total_max
= stream
->adjust
.v_total_max
;
1404 if (pipe_ctx
->stream_res
.tg
->funcs
->set_drr
)
1405 pipe_ctx
->stream_res
.tg
->funcs
->set_drr(
1406 pipe_ctx
->stream_res
.tg
, ¶ms
);
1408 // DRR should set trigger event to monitor surface update event
1409 if (stream
->adjust
.v_total_min
!= 0 && stream
->adjust
.v_total_max
!= 0)
1410 event_triggers
= 0x80;
1411 if (pipe_ctx
->stream_res
.tg
->funcs
->set_static_screen_control
)
1412 pipe_ctx
->stream_res
.tg
->funcs
->set_static_screen_control(
1413 pipe_ctx
->stream_res
.tg
, event_triggers
);
1415 if (!dc_is_virtual_signal(pipe_ctx
->stream
->signal
))
1416 pipe_ctx
->stream_res
.stream_enc
->funcs
->dig_connect_to_otg(
1417 pipe_ctx
->stream_res
.stream_enc
,
1418 pipe_ctx
->stream_res
.tg
->inst
);
1420 pipe_ctx
->stream_res
.opp
->funcs
->opp_set_dyn_expansion(
1421 pipe_ctx
->stream_res
.opp
,
1422 COLOR_SPACE_YCBCR601
,
1423 stream
->timing
.display_color_depth
,
1426 pipe_ctx
->stream_res
.opp
->funcs
->opp_program_fmt(
1427 pipe_ctx
->stream_res
.opp
,
1428 &stream
->bit_depth_params
,
1430 #if defined(CONFIG_DRM_AMD_DC_DCN2_0)
1432 odm_pipe
->stream_res
.opp
->funcs
->opp_set_dyn_expansion(
1433 odm_pipe
->stream_res
.opp
,
1434 COLOR_SPACE_YCBCR601
,
1435 stream
->timing
.display_color_depth
,
1438 odm_pipe
->stream_res
.opp
->funcs
->opp_program_fmt(
1439 odm_pipe
->stream_res
.opp
,
1440 &stream
->bit_depth_params
,
1445 if (!stream
->dpms_off
)
1446 core_link_enable_stream(context
, pipe_ctx
);
1448 pipe_ctx
->plane_res
.scl_data
.lb_params
.alpha_en
= pipe_ctx
->bottom_pipe
!= 0;
1450 pipe_ctx
->stream
->link
->psr_enabled
= false;
1455 /******************************************************************************/
1457 static void power_down_encoders(struct dc
*dc
)
1460 enum connector_id connector_id
;
1461 enum signal_type signal
= SIGNAL_TYPE_NONE
;
1463 /* do not know BIOS back-front mapping, simply blank all. It will not
1466 for (i
= 0; i
< dc
->res_pool
->stream_enc_count
; i
++) {
1467 dc
->res_pool
->stream_enc
[i
]->funcs
->dp_blank(
1468 dc
->res_pool
->stream_enc
[i
]);
1471 for (i
= 0; i
< dc
->link_count
; i
++) {
1472 connector_id
= dal_graphics_object_id_get_connector_id(dc
->links
[i
]->link_id
);
1473 if ((connector_id
== CONNECTOR_ID_DISPLAY_PORT
) ||
1474 (connector_id
== CONNECTOR_ID_EDP
)) {
1476 if (!dc
->links
[i
]->wa_flags
.dp_keep_receiver_powered
)
1477 dp_receiver_power_ctrl(dc
->links
[i
], false);
1478 if (connector_id
== CONNECTOR_ID_EDP
)
1479 signal
= SIGNAL_TYPE_EDP
;
1482 dc
->links
[i
]->link_enc
->funcs
->disable_output(
1483 dc
->links
[i
]->link_enc
, signal
);
1487 static void power_down_controllers(struct dc
*dc
)
1491 for (i
= 0; i
< dc
->res_pool
->timing_generator_count
; i
++) {
1492 dc
->res_pool
->timing_generators
[i
]->funcs
->disable_crtc(
1493 dc
->res_pool
->timing_generators
[i
]);
1497 static void power_down_clock_sources(struct dc
*dc
)
1501 if (dc
->res_pool
->dp_clock_source
->funcs
->cs_power_down(
1502 dc
->res_pool
->dp_clock_source
) == false)
1503 dm_error("Failed to power down pll! (dp clk src)\n");
1505 for (i
= 0; i
< dc
->res_pool
->clk_src_count
; i
++) {
1506 if (dc
->res_pool
->clock_sources
[i
]->funcs
->cs_power_down(
1507 dc
->res_pool
->clock_sources
[i
]) == false)
1508 dm_error("Failed to power down pll! (clk src index=%d)\n", i
);
1512 static void power_down_all_hw_blocks(struct dc
*dc
)
1514 power_down_encoders(dc
);
1516 power_down_controllers(dc
);
1518 power_down_clock_sources(dc
);
1520 if (dc
->fbc_compressor
)
1521 dc
->fbc_compressor
->funcs
->disable_fbc(dc
->fbc_compressor
);
1524 static void disable_vga_and_power_gate_all_controllers(
1528 struct timing_generator
*tg
;
1529 struct dc_context
*ctx
= dc
->ctx
;
1531 for (i
= 0; i
< dc
->res_pool
->timing_generator_count
; i
++) {
1532 tg
= dc
->res_pool
->timing_generators
[i
];
1534 if (tg
->funcs
->disable_vga
)
1535 tg
->funcs
->disable_vga(tg
);
1537 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
1538 /* Enable CLOCK gating for each pipe BEFORE controller
1540 enable_display_pipe_clock_gating(ctx
,
1543 dc
->current_state
->res_ctx
.pipe_ctx
[i
].pipe_idx
= i
;
1544 dc
->hwss
.disable_plane(dc
,
1545 &dc
->current_state
->res_ctx
.pipe_ctx
[i
]);
1550 static struct dc_stream_state
*get_edp_stream(struct dc_state
*context
)
1554 for (i
= 0; i
< context
->stream_count
; i
++) {
1555 if (context
->streams
[i
]->signal
== SIGNAL_TYPE_EDP
)
1556 return context
->streams
[i
];
1561 static struct dc_link
*get_edp_link(struct dc
*dc
)
1565 // report any eDP links, even unconnected DDI's
1566 for (i
= 0; i
< dc
->link_count
; i
++) {
1567 if (dc
->links
[i
]->connector_signal
== SIGNAL_TYPE_EDP
)
1568 return dc
->links
[i
];
1573 static struct dc_link
*get_edp_link_with_sink(
1575 struct dc_state
*context
)
1578 struct dc_link
*link
= NULL
;
1580 /* check if there is an eDP panel not in use */
1581 for (i
= 0; i
< dc
->link_count
; i
++) {
1582 if (dc
->links
[i
]->local_sink
&&
1583 dc
->links
[i
]->local_sink
->sink_signal
== SIGNAL_TYPE_EDP
) {
1584 link
= dc
->links
[i
];
1593 * When ASIC goes from VBIOS/VGA mode to driver/accelerated mode we need:
1594 * 1. Power down all DC HW blocks
1595 * 2. Disable VGA engine on all controllers
1596 * 3. Enable power gating for controller
1597 * 4. Set acc_mode_change bit (VBIOS will clear this bit when going to FSDOS)
1599 void dce110_enable_accelerated_mode(struct dc
*dc
, struct dc_state
*context
)
1602 struct dc_link
*edp_link_with_sink
= get_edp_link_with_sink(dc
, context
);
1603 struct dc_link
*edp_link
= get_edp_link(dc
);
1604 struct dc_stream_state
*edp_stream
= NULL
;
1605 bool can_apply_edp_fast_boot
= false;
1606 bool can_apply_seamless_boot
= false;
1607 bool keep_edp_vdd_on
= false;
1609 if (dc
->hwss
.init_pipes
)
1610 dc
->hwss
.init_pipes(dc
, context
);
1612 edp_stream
= get_edp_stream(context
);
1614 // Check fastboot support, disable on DCE8 because of blank screens
1615 if (edp_link
&& dc
->ctx
->dce_version
!= DCE_VERSION_8_0
&&
1616 dc
->ctx
->dce_version
!= DCE_VERSION_8_1
&&
1617 dc
->ctx
->dce_version
!= DCE_VERSION_8_3
) {
1619 // enable fastboot if backend is enabled on eDP
1620 if (edp_link
->link_enc
->funcs
->is_dig_enabled(edp_link
->link_enc
)) {
1621 /* Set optimization flag on eDP stream*/
1623 edp_stream
->apply_edp_fast_boot_optimization
= true;
1624 can_apply_edp_fast_boot
= true;
1628 // We are trying to enable eDP, don't power down VDD
1630 keep_edp_vdd_on
= true;
1633 // Check seamless boot support
1634 for (i
= 0; i
< context
->stream_count
; i
++) {
1635 if (context
->streams
[i
]->apply_seamless_boot_optimization
) {
1636 can_apply_seamless_boot
= true;
1641 /* eDP should not have stream in resume from S4 and so even with VBios post
1642 * it should get turned off
1644 if (!can_apply_edp_fast_boot
&& !can_apply_seamless_boot
) {
1645 if (edp_link_with_sink
&& !keep_edp_vdd_on
) {
1646 /*turn off backlight before DP_blank and encoder powered down*/
1647 dc
->hwss
.edp_backlight_control(edp_link_with_sink
, false);
1649 /*resume from S3, no vbios posting, no need to power down again*/
1650 power_down_all_hw_blocks(dc
);
1651 disable_vga_and_power_gate_all_controllers(dc
);
1652 if (edp_link_with_sink
&& !keep_edp_vdd_on
)
1653 dc
->hwss
.edp_power_control(edp_link_with_sink
, false);
1655 bios_set_scratch_acc_mode_change(dc
->ctx
->dc_bios
);
1658 static uint32_t compute_pstate_blackout_duration(
1659 struct bw_fixed blackout_duration
,
1660 const struct dc_stream_state
*stream
)
1662 uint32_t total_dest_line_time_ns
;
1663 uint32_t pstate_blackout_duration_ns
;
1665 pstate_blackout_duration_ns
= 1000 * blackout_duration
.value
>> 24;
1667 total_dest_line_time_ns
= 1000000UL *
1668 (stream
->timing
.h_total
* 10) /
1669 stream
->timing
.pix_clk_100hz
+
1670 pstate_blackout_duration_ns
;
1672 return total_dest_line_time_ns
;
1675 static void dce110_set_displaymarks(
1676 const struct dc
*dc
,
1677 struct dc_state
*context
)
1679 uint8_t i
, num_pipes
;
1680 unsigned int underlay_idx
= dc
->res_pool
->underlay_pipe_index
;
1682 for (i
= 0, num_pipes
= 0; i
< MAX_PIPES
; i
++) {
1683 struct pipe_ctx
*pipe_ctx
= &context
->res_ctx
.pipe_ctx
[i
];
1684 uint32_t total_dest_line_time_ns
;
1686 if (pipe_ctx
->stream
== NULL
)
1689 total_dest_line_time_ns
= compute_pstate_blackout_duration(
1690 dc
->bw_vbios
->blackout_duration
, pipe_ctx
->stream
);
1691 pipe_ctx
->plane_res
.mi
->funcs
->mem_input_program_display_marks(
1692 pipe_ctx
->plane_res
.mi
,
1693 context
->bw_ctx
.bw
.dce
.nbp_state_change_wm_ns
[num_pipes
],
1694 context
->bw_ctx
.bw
.dce
.stutter_exit_wm_ns
[num_pipes
],
1695 context
->bw_ctx
.bw
.dce
.stutter_entry_wm_ns
[num_pipes
],
1696 context
->bw_ctx
.bw
.dce
.urgent_wm_ns
[num_pipes
],
1697 total_dest_line_time_ns
);
1698 if (i
== underlay_idx
) {
1700 pipe_ctx
->plane_res
.mi
->funcs
->mem_input_program_chroma_display_marks(
1701 pipe_ctx
->plane_res
.mi
,
1702 context
->bw_ctx
.bw
.dce
.nbp_state_change_wm_ns
[num_pipes
],
1703 context
->bw_ctx
.bw
.dce
.stutter_exit_wm_ns
[num_pipes
],
1704 context
->bw_ctx
.bw
.dce
.urgent_wm_ns
[num_pipes
],
1705 total_dest_line_time_ns
);
1711 void dce110_set_safe_displaymarks(
1712 struct resource_context
*res_ctx
,
1713 const struct resource_pool
*pool
)
1716 int underlay_idx
= pool
->underlay_pipe_index
;
1717 struct dce_watermarks max_marks
= {
1718 MAX_WATERMARK
, MAX_WATERMARK
, MAX_WATERMARK
, MAX_WATERMARK
};
1719 struct dce_watermarks nbp_marks
= {
1720 SAFE_NBP_MARK
, SAFE_NBP_MARK
, SAFE_NBP_MARK
, SAFE_NBP_MARK
};
1721 struct dce_watermarks min_marks
= { 0, 0, 0, 0};
1723 for (i
= 0; i
< MAX_PIPES
; i
++) {
1724 if (res_ctx
->pipe_ctx
[i
].stream
== NULL
|| res_ctx
->pipe_ctx
[i
].plane_res
.mi
== NULL
)
1727 res_ctx
->pipe_ctx
[i
].plane_res
.mi
->funcs
->mem_input_program_display_marks(
1728 res_ctx
->pipe_ctx
[i
].plane_res
.mi
,
1735 if (i
== underlay_idx
)
1736 res_ctx
->pipe_ctx
[i
].plane_res
.mi
->funcs
->mem_input_program_chroma_display_marks(
1737 res_ctx
->pipe_ctx
[i
].plane_res
.mi
,
1746 /*******************************************************************************
1748 ******************************************************************************/
1750 static void set_drr(struct pipe_ctx
**pipe_ctx
,
1751 int num_pipes
, int vmin
, int vmax
)
1754 struct drr_params params
= {0};
1755 // DRR should set trigger event to monitor surface update event
1756 unsigned int event_triggers
= 0x80;
1758 params
.vertical_total_max
= vmax
;
1759 params
.vertical_total_min
= vmin
;
1761 /* TODO: If multiple pipes are to be supported, you need
1762 * some GSL stuff. Static screen triggers may be programmed differently
1765 for (i
= 0; i
< num_pipes
; i
++) {
1766 pipe_ctx
[i
]->stream_res
.tg
->funcs
->set_drr(
1767 pipe_ctx
[i
]->stream_res
.tg
, ¶ms
);
1769 if (vmax
!= 0 && vmin
!= 0)
1770 pipe_ctx
[i
]->stream_res
.tg
->funcs
->set_static_screen_control(
1771 pipe_ctx
[i
]->stream_res
.tg
,
1776 static void get_position(struct pipe_ctx
**pipe_ctx
,
1778 struct crtc_position
*position
)
1782 /* TODO: handle pipes > 1
1784 for (i
= 0; i
< num_pipes
; i
++)
1785 pipe_ctx
[i
]->stream_res
.tg
->funcs
->get_position(pipe_ctx
[i
]->stream_res
.tg
, position
);
1788 static void set_static_screen_control(struct pipe_ctx
**pipe_ctx
,
1789 int num_pipes
, const struct dc_static_screen_events
*events
)
1792 unsigned int value
= 0;
1794 if (events
->overlay_update
)
1796 if (events
->surface_update
)
1798 if (events
->cursor_update
)
1800 if (events
->force_trigger
)
1804 struct dc
*dc
= pipe_ctx
[0]->stream
->ctx
->dc
;
1806 if (dc
->fbc_compressor
)
1810 for (i
= 0; i
< num_pipes
; i
++)
1811 pipe_ctx
[i
]->stream_res
.tg
->funcs
->
1812 set_static_screen_control(pipe_ctx
[i
]->stream_res
.tg
, value
);
1816 * Check if FBC can be enabled
1818 static bool should_enable_fbc(struct dc
*dc
,
1819 struct dc_state
*context
,
1823 struct pipe_ctx
*pipe_ctx
= NULL
;
1824 struct resource_context
*res_ctx
= &context
->res_ctx
;
1825 unsigned int underlay_idx
= dc
->res_pool
->underlay_pipe_index
;
1828 ASSERT(dc
->fbc_compressor
);
1830 /* FBC memory should be allocated */
1831 if (!dc
->ctx
->fbc_gpu_addr
)
1834 /* Only supports single display */
1835 if (context
->stream_count
!= 1)
1838 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
1839 if (res_ctx
->pipe_ctx
[i
].stream
) {
1841 pipe_ctx
= &res_ctx
->pipe_ctx
[i
];
1846 /* fbc not applicable on underlay pipe */
1847 if (pipe_ctx
->pipe_idx
!= underlay_idx
) {
1854 if (i
== dc
->res_pool
->pipe_count
)
1857 if (!pipe_ctx
->stream
->link
)
1860 /* Only supports eDP */
1861 if (pipe_ctx
->stream
->link
->connector_signal
!= SIGNAL_TYPE_EDP
)
1864 /* PSR should not be enabled */
1865 if (pipe_ctx
->stream
->link
->psr_enabled
)
1868 /* Nothing to compress */
1869 if (!pipe_ctx
->plane_state
)
1872 /* Only for non-linear tiling */
1873 if (pipe_ctx
->plane_state
->tiling_info
.gfx8
.array_mode
== DC_ARRAY_LINEAR_GENERAL
)
1882 static void enable_fbc(
1884 struct dc_state
*context
)
1886 uint32_t pipe_idx
= 0;
1888 if (should_enable_fbc(dc
, context
, &pipe_idx
)) {
1889 /* Program GRPH COMPRESSED ADDRESS and PITCH */
1890 struct compr_addr_and_pitch_params params
= {0, 0, 0};
1891 struct compressor
*compr
= dc
->fbc_compressor
;
1892 struct pipe_ctx
*pipe_ctx
= &context
->res_ctx
.pipe_ctx
[pipe_idx
];
1894 params
.source_view_width
= pipe_ctx
->stream
->timing
.h_addressable
;
1895 params
.source_view_height
= pipe_ctx
->stream
->timing
.v_addressable
;
1896 params
.inst
= pipe_ctx
->stream_res
.tg
->inst
;
1897 compr
->compr_surface_address
.quad_part
= dc
->ctx
->fbc_gpu_addr
;
1899 compr
->funcs
->surface_address_and_pitch(compr
, ¶ms
);
1900 compr
->funcs
->set_fbc_invalidation_triggers(compr
, 1);
1902 compr
->funcs
->enable_fbc(compr
, ¶ms
);
1906 static void dce110_reset_hw_ctx_wrap(
1908 struct dc_state
*context
)
1912 /* Reset old context */
1913 /* look up the targets that have been removed since last commit */
1914 for (i
= 0; i
< MAX_PIPES
; i
++) {
1915 struct pipe_ctx
*pipe_ctx_old
=
1916 &dc
->current_state
->res_ctx
.pipe_ctx
[i
];
1917 struct pipe_ctx
*pipe_ctx
= &context
->res_ctx
.pipe_ctx
[i
];
1919 /* Note: We need to disable output if clock sources change,
1920 * since bios does optimization and doesn't apply if changing
1921 * PHY when not already disabled.
1924 /* Skip underlay pipe since it will be handled in commit surface*/
1925 if (!pipe_ctx_old
->stream
|| pipe_ctx_old
->top_pipe
)
1928 if (!pipe_ctx
->stream
||
1929 pipe_need_reprogram(pipe_ctx_old
, pipe_ctx
)) {
1930 struct clock_source
*old_clk
= pipe_ctx_old
->clock_source
;
1932 /* Disable if new stream is null. O/w, if stream is
1933 * disabled already, no need to disable again.
1935 if (!pipe_ctx
->stream
|| !pipe_ctx
->stream
->dpms_off
)
1936 core_link_disable_stream(pipe_ctx_old
, FREE_ACQUIRED_RESOURCE
);
1938 pipe_ctx_old
->stream_res
.tg
->funcs
->set_blank(pipe_ctx_old
->stream_res
.tg
, true);
1939 if (!hwss_wait_for_blank_complete(pipe_ctx_old
->stream_res
.tg
)) {
1940 dm_error("DC: failed to blank crtc!\n");
1941 BREAK_TO_DEBUGGER();
1943 pipe_ctx_old
->stream_res
.tg
->funcs
->disable_crtc(pipe_ctx_old
->stream_res
.tg
);
1944 pipe_ctx_old
->plane_res
.mi
->funcs
->free_mem_input(
1945 pipe_ctx_old
->plane_res
.mi
, dc
->current_state
->stream_count
);
1947 if (old_clk
&& 0 == resource_get_clock_source_reference(&context
->res_ctx
,
1950 old_clk
->funcs
->cs_power_down(old_clk
);
1952 dc
->hwss
.disable_plane(dc
, pipe_ctx_old
);
1954 pipe_ctx_old
->stream
= NULL
;
1959 static void dce110_setup_audio_dto(
1961 struct dc_state
*context
)
1965 /* program audio wall clock. use HDMI as clock source if HDMI
1966 * audio active. Otherwise, use DP as clock source
1967 * first, loop to find any HDMI audio, if not, loop find DP audio
1969 /* Setup audio rate clock source */
1971 * Audio lag happened on DP monitor when unplug a HDMI monitor
1974 * In case of DP and HDMI connected or HDMI only, DCCG_AUDIO_DTO_SEL
1975 * is set to either dto0 or dto1, audio should work fine.
1976 * In case of DP connected only, DCCG_AUDIO_DTO_SEL should be dto1,
1977 * set to dto0 will cause audio lag.
1980 * Not optimized audio wall dto setup. When mode set, iterate pipe_ctx,
1981 * find first available pipe with audio, setup audio wall DTO per topology
1982 * instead of per pipe.
1984 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
1985 struct pipe_ctx
*pipe_ctx
= &context
->res_ctx
.pipe_ctx
[i
];
1987 if (pipe_ctx
->stream
== NULL
)
1990 if (pipe_ctx
->top_pipe
)
1993 if (pipe_ctx
->stream
->signal
!= SIGNAL_TYPE_HDMI_TYPE_A
)
1996 if (pipe_ctx
->stream_res
.audio
!= NULL
) {
1997 struct audio_output audio_output
;
1999 build_audio_output(context
, pipe_ctx
, &audio_output
);
2001 pipe_ctx
->stream_res
.audio
->funcs
->wall_dto_setup(
2002 pipe_ctx
->stream_res
.audio
,
2003 pipe_ctx
->stream
->signal
,
2004 &audio_output
.crtc_info
,
2005 &audio_output
.pll_info
);
2010 /* no HDMI audio is found, try DP audio */
2011 if (i
== dc
->res_pool
->pipe_count
) {
2012 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
2013 struct pipe_ctx
*pipe_ctx
= &context
->res_ctx
.pipe_ctx
[i
];
2015 if (pipe_ctx
->stream
== NULL
)
2018 if (pipe_ctx
->top_pipe
)
2021 if (!dc_is_dp_signal(pipe_ctx
->stream
->signal
))
2024 if (pipe_ctx
->stream_res
.audio
!= NULL
) {
2025 struct audio_output audio_output
;
2027 build_audio_output(context
, pipe_ctx
, &audio_output
);
2029 pipe_ctx
->stream_res
.audio
->funcs
->wall_dto_setup(
2030 pipe_ctx
->stream_res
.audio
,
2031 pipe_ctx
->stream
->signal
,
2032 &audio_output
.crtc_info
,
2033 &audio_output
.pll_info
);
2040 enum dc_status
dce110_apply_ctx_to_hw(
2042 struct dc_state
*context
)
2044 struct dc_bios
*dcb
= dc
->ctx
->dc_bios
;
2045 enum dc_status status
;
2048 /* Reset old context */
2049 /* look up the targets that have been removed since last commit */
2050 dc
->hwss
.reset_hw_ctx_wrap(dc
, context
);
2052 /* Skip applying if no targets */
2053 if (context
->stream_count
<= 0)
2056 /* Apply new context */
2057 dcb
->funcs
->set_scratch_critical_state(dcb
, true);
2059 /* below is for real asic only */
2060 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
2061 struct pipe_ctx
*pipe_ctx_old
=
2062 &dc
->current_state
->res_ctx
.pipe_ctx
[i
];
2063 struct pipe_ctx
*pipe_ctx
= &context
->res_ctx
.pipe_ctx
[i
];
2065 if (pipe_ctx
->stream
== NULL
|| pipe_ctx
->top_pipe
)
2068 if (pipe_ctx
->stream
== pipe_ctx_old
->stream
) {
2069 if (pipe_ctx_old
->clock_source
!= pipe_ctx
->clock_source
)
2070 dce_crtc_switch_to_clk_src(dc
->hwseq
,
2071 pipe_ctx
->clock_source
, i
);
2075 dc
->hwss
.enable_display_power_gating(
2076 dc
, i
, dc
->ctx
->dc_bios
,
2077 PIPE_GATING_CONTROL_DISABLE
);
2080 if (dc
->fbc_compressor
)
2081 dc
->fbc_compressor
->funcs
->disable_fbc(dc
->fbc_compressor
);
2083 dce110_setup_audio_dto(dc
, context
);
2085 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
2086 struct pipe_ctx
*pipe_ctx_old
=
2087 &dc
->current_state
->res_ctx
.pipe_ctx
[i
];
2088 struct pipe_ctx
*pipe_ctx
= &context
->res_ctx
.pipe_ctx
[i
];
2090 if (pipe_ctx
->stream
== NULL
)
2093 if (pipe_ctx
->stream
== pipe_ctx_old
->stream
&&
2094 pipe_ctx
->stream
->link
->link_state_valid
) {
2098 if (pipe_ctx_old
->stream
&& !pipe_need_reprogram(pipe_ctx_old
, pipe_ctx
))
2101 if (pipe_ctx
->top_pipe
)
2104 status
= apply_single_controller_ctx_to_hw(
2109 if (DC_OK
!= status
)
2113 if (dc
->fbc_compressor
)
2114 enable_fbc(dc
, dc
->current_state
);
2116 dcb
->funcs
->set_scratch_critical_state(dcb
, false);
2121 /*******************************************************************************
2122 * Front End programming
2123 ******************************************************************************/
2124 static void set_default_colors(struct pipe_ctx
*pipe_ctx
)
2126 struct default_adjustment default_adjust
= { 0 };
2128 default_adjust
.force_hw_default
= false;
2129 default_adjust
.in_color_space
= pipe_ctx
->plane_state
->color_space
;
2130 default_adjust
.out_color_space
= pipe_ctx
->stream
->output_color_space
;
2131 default_adjust
.csc_adjust_type
= GRAPHICS_CSC_ADJUST_TYPE_SW
;
2132 default_adjust
.surface_pixel_format
= pipe_ctx
->plane_res
.scl_data
.format
;
2134 /* display color depth */
2135 default_adjust
.color_depth
=
2136 pipe_ctx
->stream
->timing
.display_color_depth
;
2138 /* Lb color depth */
2139 default_adjust
.lb_color_depth
= pipe_ctx
->plane_res
.scl_data
.lb_params
.depth
;
2141 pipe_ctx
->plane_res
.xfm
->funcs
->opp_set_csc_default(
2142 pipe_ctx
->plane_res
.xfm
, &default_adjust
);
2146 /*******************************************************************************
2147 * In order to turn on/off specific surface we will program
2150 * In case that we have two surfaces and they have a different visibility
2151 * we can't turn off the CRTC since it will turn off the entire display
2153 * |----------------------------------------------- |
2154 * |bottom pipe|curr pipe | | |
2155 * |Surface |Surface | Blender | CRCT |
2156 * |visibility |visibility | Configuration| |
2157 * |------------------------------------------------|
2158 * | off | off | CURRENT_PIPE | blank |
2159 * | off | on | CURRENT_PIPE | unblank |
2160 * | on | off | OTHER_PIPE | unblank |
2161 * | on | on | BLENDING | unblank |
2162 * -------------------------------------------------|
2164 ******************************************************************************/
2165 static void program_surface_visibility(const struct dc
*dc
,
2166 struct pipe_ctx
*pipe_ctx
)
2168 enum blnd_mode blender_mode
= BLND_MODE_CURRENT_PIPE
;
2169 bool blank_target
= false;
2171 if (pipe_ctx
->bottom_pipe
) {
2173 /* For now we are supporting only two pipes */
2174 ASSERT(pipe_ctx
->bottom_pipe
->bottom_pipe
== NULL
);
2176 if (pipe_ctx
->bottom_pipe
->plane_state
->visible
) {
2177 if (pipe_ctx
->plane_state
->visible
)
2178 blender_mode
= BLND_MODE_BLENDING
;
2180 blender_mode
= BLND_MODE_OTHER_PIPE
;
2182 } else if (!pipe_ctx
->plane_state
->visible
)
2183 blank_target
= true;
2185 } else if (!pipe_ctx
->plane_state
->visible
)
2186 blank_target
= true;
2188 dce_set_blender_mode(dc
->hwseq
, pipe_ctx
->stream_res
.tg
->inst
, blender_mode
);
2189 pipe_ctx
->stream_res
.tg
->funcs
->set_blank(pipe_ctx
->stream_res
.tg
, blank_target
);
2193 static void program_gamut_remap(struct pipe_ctx
*pipe_ctx
)
2196 struct xfm_grph_csc_adjustment adjust
;
2197 memset(&adjust
, 0, sizeof(adjust
));
2198 adjust
.gamut_adjust_type
= GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS
;
2201 if (pipe_ctx
->stream
->gamut_remap_matrix
.enable_remap
== true) {
2202 adjust
.gamut_adjust_type
= GRAPHICS_GAMUT_ADJUST_TYPE_SW
;
2204 for (i
= 0; i
< CSC_TEMPERATURE_MATRIX_SIZE
; i
++)
2205 adjust
.temperature_matrix
[i
] =
2206 pipe_ctx
->stream
->gamut_remap_matrix
.matrix
[i
];
2209 pipe_ctx
->plane_res
.xfm
->funcs
->transform_set_gamut_remap(pipe_ctx
->plane_res
.xfm
, &adjust
);
2211 static void update_plane_addr(const struct dc
*dc
,
2212 struct pipe_ctx
*pipe_ctx
)
2214 struct dc_plane_state
*plane_state
= pipe_ctx
->plane_state
;
2216 if (plane_state
== NULL
)
2219 pipe_ctx
->plane_res
.mi
->funcs
->mem_input_program_surface_flip_and_addr(
2220 pipe_ctx
->plane_res
.mi
,
2221 &plane_state
->address
,
2222 plane_state
->flip_immediate
);
2224 plane_state
->status
.requested_address
= plane_state
->address
;
2227 static void dce110_update_pending_status(struct pipe_ctx
*pipe_ctx
)
2229 struct dc_plane_state
*plane_state
= pipe_ctx
->plane_state
;
2231 if (plane_state
== NULL
)
2234 plane_state
->status
.is_flip_pending
=
2235 pipe_ctx
->plane_res
.mi
->funcs
->mem_input_is_flip_pending(
2236 pipe_ctx
->plane_res
.mi
);
2238 if (plane_state
->status
.is_flip_pending
&& !plane_state
->visible
)
2239 pipe_ctx
->plane_res
.mi
->current_address
= pipe_ctx
->plane_res
.mi
->request_address
;
2241 plane_state
->status
.current_address
= pipe_ctx
->plane_res
.mi
->current_address
;
2242 if (pipe_ctx
->plane_res
.mi
->current_address
.type
== PLN_ADDR_TYPE_GRPH_STEREO
&&
2243 pipe_ctx
->stream_res
.tg
->funcs
->is_stereo_left_eye
) {
2244 plane_state
->status
.is_right_eye
=\
2245 !pipe_ctx
->stream_res
.tg
->funcs
->is_stereo_left_eye(pipe_ctx
->stream_res
.tg
);
2249 void dce110_power_down(struct dc
*dc
)
2251 power_down_all_hw_blocks(dc
);
2252 disable_vga_and_power_gate_all_controllers(dc
);
2255 static bool wait_for_reset_trigger_to_occur(
2256 struct dc_context
*dc_ctx
,
2257 struct timing_generator
*tg
)
2261 /* To avoid endless loop we wait at most
2262 * frames_to_wait_on_triggered_reset frames for the reset to occur. */
2263 const uint32_t frames_to_wait_on_triggered_reset
= 10;
2266 for (i
= 0; i
< frames_to_wait_on_triggered_reset
; i
++) {
2268 if (!tg
->funcs
->is_counter_moving(tg
)) {
2269 DC_ERROR("TG counter is not moving!\n");
2273 if (tg
->funcs
->did_triggered_reset_occur(tg
)) {
2275 /* usually occurs at i=1 */
2276 DC_SYNC_INFO("GSL: reset occurred at wait count: %d\n",
2281 /* Wait for one frame. */
2282 tg
->funcs
->wait_for_state(tg
, CRTC_STATE_VACTIVE
);
2283 tg
->funcs
->wait_for_state(tg
, CRTC_STATE_VBLANK
);
2287 DC_ERROR("GSL: Timeout on reset trigger!\n");
2292 /* Enable timing synchronization for a group of Timing Generators. */
2293 static void dce110_enable_timing_synchronization(
2297 struct pipe_ctx
*grouped_pipes
[])
2299 struct dc_context
*dc_ctx
= dc
->ctx
;
2300 struct dcp_gsl_params gsl_params
= { 0 };
2303 DC_SYNC_INFO("GSL: Setting-up...\n");
2305 /* Designate a single TG in the group as a master.
2306 * Since HW doesn't care which one, we always assign
2307 * the 1st one in the group. */
2308 gsl_params
.gsl_group
= 0;
2309 gsl_params
.gsl_master
= grouped_pipes
[0]->stream_res
.tg
->inst
;
2311 for (i
= 0; i
< group_size
; i
++)
2312 grouped_pipes
[i
]->stream_res
.tg
->funcs
->setup_global_swap_lock(
2313 grouped_pipes
[i
]->stream_res
.tg
, &gsl_params
);
2315 /* Reset slave controllers on master VSync */
2316 DC_SYNC_INFO("GSL: enabling trigger-reset\n");
2318 for (i
= 1 /* skip the master */; i
< group_size
; i
++)
2319 grouped_pipes
[i
]->stream_res
.tg
->funcs
->enable_reset_trigger(
2320 grouped_pipes
[i
]->stream_res
.tg
,
2321 gsl_params
.gsl_group
);
2323 for (i
= 1 /* skip the master */; i
< group_size
; i
++) {
2324 DC_SYNC_INFO("GSL: waiting for reset to occur.\n");
2325 wait_for_reset_trigger_to_occur(dc_ctx
, grouped_pipes
[i
]->stream_res
.tg
);
2326 grouped_pipes
[i
]->stream_res
.tg
->funcs
->disable_reset_trigger(
2327 grouped_pipes
[i
]->stream_res
.tg
);
2330 /* GSL Vblank synchronization is a one time sync mechanism, assumption
2331 * is that the sync'ed displays will not drift out of sync over time*/
2332 DC_SYNC_INFO("GSL: Restoring register states.\n");
2333 for (i
= 0; i
< group_size
; i
++)
2334 grouped_pipes
[i
]->stream_res
.tg
->funcs
->tear_down_global_swap_lock(grouped_pipes
[i
]->stream_res
.tg
);
2336 DC_SYNC_INFO("GSL: Set-up complete.\n");
2339 static void dce110_enable_per_frame_crtc_position_reset(
2342 struct pipe_ctx
*grouped_pipes
[])
2344 struct dc_context
*dc_ctx
= dc
->ctx
;
2345 struct dcp_gsl_params gsl_params
= { 0 };
2348 gsl_params
.gsl_group
= 0;
2349 gsl_params
.gsl_master
= 0;
2351 for (i
= 0; i
< group_size
; i
++)
2352 grouped_pipes
[i
]->stream_res
.tg
->funcs
->setup_global_swap_lock(
2353 grouped_pipes
[i
]->stream_res
.tg
, &gsl_params
);
2355 DC_SYNC_INFO("GSL: enabling trigger-reset\n");
2357 for (i
= 1; i
< group_size
; i
++)
2358 grouped_pipes
[i
]->stream_res
.tg
->funcs
->enable_crtc_reset(
2359 grouped_pipes
[i
]->stream_res
.tg
,
2360 gsl_params
.gsl_master
,
2361 &grouped_pipes
[i
]->stream
->triggered_crtc_reset
);
2363 DC_SYNC_INFO("GSL: waiting for reset to occur.\n");
2364 for (i
= 1; i
< group_size
; i
++)
2365 wait_for_reset_trigger_to_occur(dc_ctx
, grouped_pipes
[i
]->stream_res
.tg
);
2367 for (i
= 0; i
< group_size
; i
++)
2368 grouped_pipes
[i
]->stream_res
.tg
->funcs
->tear_down_global_swap_lock(grouped_pipes
[i
]->stream_res
.tg
);
2372 static void init_pipes(struct dc
*dc
, struct dc_state
*context
)
2377 static void init_hw(struct dc
*dc
)
2381 struct transform
*xfm
;
2385 bp
= dc
->ctx
->dc_bios
;
2386 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
2387 xfm
= dc
->res_pool
->transforms
[i
];
2388 xfm
->funcs
->transform_reset(xfm
);
2390 dc
->hwss
.enable_display_power_gating(
2392 PIPE_GATING_CONTROL_INIT
);
2393 dc
->hwss
.enable_display_power_gating(
2395 PIPE_GATING_CONTROL_DISABLE
);
2396 dc
->hwss
.enable_display_pipe_clock_gating(
2401 dce_clock_gating_power_up(dc
->hwseq
, false);
2402 /***************************************/
2404 for (i
= 0; i
< dc
->link_count
; i
++) {
2405 /****************************************/
2406 /* Power up AND update implementation according to the
2407 * required signal (which may be different from the
2408 * default signal on connector). */
2409 struct dc_link
*link
= dc
->links
[i
];
2411 link
->link_enc
->funcs
->hw_init(link
->link_enc
);
2414 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
2415 struct timing_generator
*tg
= dc
->res_pool
->timing_generators
[i
];
2417 tg
->funcs
->disable_vga(tg
);
2419 /* Blank controller using driver code instead of
2421 tg
->funcs
->set_blank(tg
, true);
2422 hwss_wait_for_blank_complete(tg
);
2425 for (i
= 0; i
< dc
->res_pool
->audio_count
; i
++) {
2426 struct audio
*audio
= dc
->res_pool
->audios
[i
];
2427 audio
->funcs
->hw_init(audio
);
2430 abm
= dc
->res_pool
->abm
;
2432 abm
->funcs
->init_backlight(abm
);
2433 abm
->funcs
->abm_init(abm
);
2436 dmcu
= dc
->res_pool
->dmcu
;
2437 if (dmcu
!= NULL
&& abm
!= NULL
)
2438 abm
->dmcu_is_running
= dmcu
->funcs
->is_dmcu_initialized(dmcu
);
2440 if (dc
->fbc_compressor
)
2441 dc
->fbc_compressor
->funcs
->power_up_fbc(dc
->fbc_compressor
);
2446 void dce110_prepare_bandwidth(
2448 struct dc_state
*context
)
2450 struct clk_mgr
*dccg
= dc
->clk_mgr
;
2452 dce110_set_safe_displaymarks(&context
->res_ctx
, dc
->res_pool
);
2454 dccg
->funcs
->update_clocks(
2460 void dce110_optimize_bandwidth(
2462 struct dc_state
*context
)
2464 struct clk_mgr
*dccg
= dc
->clk_mgr
;
2466 dce110_set_displaymarks(dc
, context
);
2468 dccg
->funcs
->update_clocks(
2474 static void dce110_program_front_end_for_pipe(
2475 struct dc
*dc
, struct pipe_ctx
*pipe_ctx
)
2477 struct mem_input
*mi
= pipe_ctx
->plane_res
.mi
;
2478 struct pipe_ctx
*old_pipe
= NULL
;
2479 struct dc_plane_state
*plane_state
= pipe_ctx
->plane_state
;
2480 struct xfm_grph_csc_adjustment adjust
;
2481 struct out_csc_color_matrix tbl_entry
;
2484 memset(&tbl_entry
, 0, sizeof(tbl_entry
));
2486 if (dc
->current_state
)
2487 old_pipe
= &dc
->current_state
->res_ctx
.pipe_ctx
[pipe_ctx
->pipe_idx
];
2489 memset(&adjust
, 0, sizeof(adjust
));
2490 adjust
.gamut_adjust_type
= GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS
;
2492 dce_enable_fe_clock(dc
->hwseq
, mi
->inst
, true);
2494 set_default_colors(pipe_ctx
);
2495 if (pipe_ctx
->stream
->csc_color_matrix
.enable_adjustment
2497 tbl_entry
.color_space
=
2498 pipe_ctx
->stream
->output_color_space
;
2500 for (i
= 0; i
< 12; i
++)
2501 tbl_entry
.regval
[i
] =
2502 pipe_ctx
->stream
->csc_color_matrix
.matrix
[i
];
2504 pipe_ctx
->plane_res
.xfm
->funcs
->opp_set_csc_adjustment
2505 (pipe_ctx
->plane_res
.xfm
, &tbl_entry
);
2508 if (pipe_ctx
->stream
->gamut_remap_matrix
.enable_remap
== true) {
2509 adjust
.gamut_adjust_type
= GRAPHICS_GAMUT_ADJUST_TYPE_SW
;
2511 for (i
= 0; i
< CSC_TEMPERATURE_MATRIX_SIZE
; i
++)
2512 adjust
.temperature_matrix
[i
] =
2513 pipe_ctx
->stream
->gamut_remap_matrix
.matrix
[i
];
2516 pipe_ctx
->plane_res
.xfm
->funcs
->transform_set_gamut_remap(pipe_ctx
->plane_res
.xfm
, &adjust
);
2518 pipe_ctx
->plane_res
.scl_data
.lb_params
.alpha_en
= pipe_ctx
->bottom_pipe
!= 0;
2520 program_scaler(dc
, pipe_ctx
);
2522 mi
->funcs
->mem_input_program_surface_config(
2524 plane_state
->format
,
2525 &plane_state
->tiling_info
,
2526 &plane_state
->plane_size
,
2527 plane_state
->rotation
,
2530 if (mi
->funcs
->set_blank
)
2531 mi
->funcs
->set_blank(mi
, pipe_ctx
->plane_state
->visible
);
2533 if (dc
->config
.gpu_vm_support
)
2534 mi
->funcs
->mem_input_program_pte_vm(
2535 pipe_ctx
->plane_res
.mi
,
2536 plane_state
->format
,
2537 &plane_state
->tiling_info
,
2538 plane_state
->rotation
);
2540 /* Moved programming gamma from dc to hwss */
2541 if (pipe_ctx
->plane_state
->update_flags
.bits
.full_update
||
2542 pipe_ctx
->plane_state
->update_flags
.bits
.in_transfer_func_change
||
2543 pipe_ctx
->plane_state
->update_flags
.bits
.gamma_change
)
2544 dc
->hwss
.set_input_transfer_func(pipe_ctx
, pipe_ctx
->plane_state
);
2546 if (pipe_ctx
->plane_state
->update_flags
.bits
.full_update
)
2547 dc
->hwss
.set_output_transfer_func(pipe_ctx
, pipe_ctx
->stream
);
2550 "Pipe:%d %p: addr hi:0x%x, "
2553 " %d; dst: %d, %d, %d, %d;"
2554 "clip: %d, %d, %d, %d\n",
2556 (void *) pipe_ctx
->plane_state
,
2557 pipe_ctx
->plane_state
->address
.grph
.addr
.high_part
,
2558 pipe_ctx
->plane_state
->address
.grph
.addr
.low_part
,
2559 pipe_ctx
->plane_state
->src_rect
.x
,
2560 pipe_ctx
->plane_state
->src_rect
.y
,
2561 pipe_ctx
->plane_state
->src_rect
.width
,
2562 pipe_ctx
->plane_state
->src_rect
.height
,
2563 pipe_ctx
->plane_state
->dst_rect
.x
,
2564 pipe_ctx
->plane_state
->dst_rect
.y
,
2565 pipe_ctx
->plane_state
->dst_rect
.width
,
2566 pipe_ctx
->plane_state
->dst_rect
.height
,
2567 pipe_ctx
->plane_state
->clip_rect
.x
,
2568 pipe_ctx
->plane_state
->clip_rect
.y
,
2569 pipe_ctx
->plane_state
->clip_rect
.width
,
2570 pipe_ctx
->plane_state
->clip_rect
.height
);
2573 "Pipe %d: width, height, x, y\n"
2574 "viewport:%d, %d, %d, %d\n"
2575 "recout: %d, %d, %d, %d\n",
2577 pipe_ctx
->plane_res
.scl_data
.viewport
.width
,
2578 pipe_ctx
->plane_res
.scl_data
.viewport
.height
,
2579 pipe_ctx
->plane_res
.scl_data
.viewport
.x
,
2580 pipe_ctx
->plane_res
.scl_data
.viewport
.y
,
2581 pipe_ctx
->plane_res
.scl_data
.recout
.width
,
2582 pipe_ctx
->plane_res
.scl_data
.recout
.height
,
2583 pipe_ctx
->plane_res
.scl_data
.recout
.x
,
2584 pipe_ctx
->plane_res
.scl_data
.recout
.y
);
2587 static void dce110_apply_ctx_for_surface(
2589 const struct dc_stream_state
*stream
,
2591 struct dc_state
*context
)
2595 if (num_planes
== 0)
2598 if (dc
->fbc_compressor
)
2599 dc
->fbc_compressor
->funcs
->disable_fbc(dc
->fbc_compressor
);
2601 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
2602 struct pipe_ctx
*pipe_ctx
= &context
->res_ctx
.pipe_ctx
[i
];
2603 struct pipe_ctx
*old_pipe_ctx
= &dc
->current_state
->res_ctx
.pipe_ctx
[i
];
2605 if (stream
== pipe_ctx
->stream
) {
2606 if (!pipe_ctx
->top_pipe
&&
2607 (pipe_ctx
->plane_state
|| old_pipe_ctx
->plane_state
))
2608 dc
->hwss
.pipe_control_lock(dc
, pipe_ctx
, true);
2612 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
2613 struct pipe_ctx
*pipe_ctx
= &context
->res_ctx
.pipe_ctx
[i
];
2615 if (pipe_ctx
->stream
!= stream
)
2618 /* Need to allocate mem before program front end for Fiji */
2619 pipe_ctx
->plane_res
.mi
->funcs
->allocate_mem_input(
2620 pipe_ctx
->plane_res
.mi
,
2621 pipe_ctx
->stream
->timing
.h_total
,
2622 pipe_ctx
->stream
->timing
.v_total
,
2623 pipe_ctx
->stream
->timing
.pix_clk_100hz
/ 10,
2624 context
->stream_count
);
2626 dce110_program_front_end_for_pipe(dc
, pipe_ctx
);
2628 dc
->hwss
.update_plane_addr(dc
, pipe_ctx
);
2630 program_surface_visibility(dc
, pipe_ctx
);
2634 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
2635 struct pipe_ctx
*pipe_ctx
= &context
->res_ctx
.pipe_ctx
[i
];
2636 struct pipe_ctx
*old_pipe_ctx
= &dc
->current_state
->res_ctx
.pipe_ctx
[i
];
2638 if ((stream
== pipe_ctx
->stream
) &&
2639 (!pipe_ctx
->top_pipe
) &&
2640 (pipe_ctx
->plane_state
|| old_pipe_ctx
->plane_state
))
2641 dc
->hwss
.pipe_control_lock(dc
, pipe_ctx
, false);
2644 if (dc
->fbc_compressor
)
2645 enable_fbc(dc
, context
);
2648 static void dce110_power_down_fe(struct dc
*dc
, struct pipe_ctx
*pipe_ctx
)
2650 int fe_idx
= pipe_ctx
->plane_res
.mi
?
2651 pipe_ctx
->plane_res
.mi
->inst
: pipe_ctx
->pipe_idx
;
2653 /* Do not power down fe when stream is active on dce*/
2654 if (dc
->current_state
->res_ctx
.pipe_ctx
[fe_idx
].stream
)
2657 dc
->hwss
.enable_display_power_gating(
2658 dc
, fe_idx
, dc
->ctx
->dc_bios
, PIPE_GATING_CONTROL_ENABLE
);
2660 dc
->res_pool
->transforms
[fe_idx
]->funcs
->transform_reset(
2661 dc
->res_pool
->transforms
[fe_idx
]);
2664 static void dce110_wait_for_mpcc_disconnect(
2666 struct resource_pool
*res_pool
,
2667 struct pipe_ctx
*pipe_ctx
)
2672 static void program_output_csc(struct dc
*dc
,
2673 struct pipe_ctx
*pipe_ctx
,
2674 enum dc_color_space colorspace
,
2679 struct out_csc_color_matrix tbl_entry
;
2681 if (pipe_ctx
->stream
->csc_color_matrix
.enable_adjustment
== true) {
2682 enum dc_color_space color_space
= pipe_ctx
->stream
->output_color_space
;
2684 for (i
= 0; i
< 12; i
++)
2685 tbl_entry
.regval
[i
] = pipe_ctx
->stream
->csc_color_matrix
.matrix
[i
];
2687 tbl_entry
.color_space
= color_space
;
2689 pipe_ctx
->plane_res
.xfm
->funcs
->opp_set_csc_adjustment(
2690 pipe_ctx
->plane_res
.xfm
, &tbl_entry
);
2694 void dce110_set_cursor_position(struct pipe_ctx
*pipe_ctx
)
2696 struct dc_cursor_position pos_cpy
= pipe_ctx
->stream
->cursor_position
;
2697 struct input_pixel_processor
*ipp
= pipe_ctx
->plane_res
.ipp
;
2698 struct mem_input
*mi
= pipe_ctx
->plane_res
.mi
;
2699 struct dc_cursor_mi_param param
= {
2700 .pixel_clk_khz
= pipe_ctx
->stream
->timing
.pix_clk_100hz
/ 10,
2701 .ref_clk_khz
= pipe_ctx
->stream
->ctx
->dc
->res_pool
->ref_clocks
.xtalin_clock_inKhz
,
2702 .viewport
= pipe_ctx
->plane_res
.scl_data
.viewport
,
2703 .h_scale_ratio
= pipe_ctx
->plane_res
.scl_data
.ratios
.horz
,
2704 .v_scale_ratio
= pipe_ctx
->plane_res
.scl_data
.ratios
.vert
,
2705 .rotation
= pipe_ctx
->plane_state
->rotation
,
2706 .mirror
= pipe_ctx
->plane_state
->horizontal_mirror
2709 if (pipe_ctx
->plane_state
->address
.type
2710 == PLN_ADDR_TYPE_VIDEO_PROGRESSIVE
)
2711 pos_cpy
.enable
= false;
2713 if (pipe_ctx
->top_pipe
&& pipe_ctx
->plane_state
!= pipe_ctx
->top_pipe
->plane_state
)
2714 pos_cpy
.enable
= false;
2716 if (ipp
->funcs
->ipp_cursor_set_position
)
2717 ipp
->funcs
->ipp_cursor_set_position(ipp
, &pos_cpy
, ¶m
);
2718 if (mi
->funcs
->set_cursor_position
)
2719 mi
->funcs
->set_cursor_position(mi
, &pos_cpy
, ¶m
);
2722 void dce110_set_cursor_attribute(struct pipe_ctx
*pipe_ctx
)
2724 struct dc_cursor_attributes
*attributes
= &pipe_ctx
->stream
->cursor_attributes
;
2726 if (pipe_ctx
->plane_res
.ipp
&&
2727 pipe_ctx
->plane_res
.ipp
->funcs
->ipp_cursor_set_attributes
)
2728 pipe_ctx
->plane_res
.ipp
->funcs
->ipp_cursor_set_attributes(
2729 pipe_ctx
->plane_res
.ipp
, attributes
);
2731 if (pipe_ctx
->plane_res
.mi
&&
2732 pipe_ctx
->plane_res
.mi
->funcs
->set_cursor_attributes
)
2733 pipe_ctx
->plane_res
.mi
->funcs
->set_cursor_attributes(
2734 pipe_ctx
->plane_res
.mi
, attributes
);
2736 if (pipe_ctx
->plane_res
.xfm
&&
2737 pipe_ctx
->plane_res
.xfm
->funcs
->set_cursor_attributes
)
2738 pipe_ctx
->plane_res
.xfm
->funcs
->set_cursor_attributes(
2739 pipe_ctx
->plane_res
.xfm
, attributes
);
2742 static const struct hw_sequencer_funcs dce110_funcs
= {
2743 .program_gamut_remap
= program_gamut_remap
,
2744 .program_output_csc
= program_output_csc
,
2746 .init_pipes
= init_pipes
,
2747 .apply_ctx_to_hw
= dce110_apply_ctx_to_hw
,
2748 .apply_ctx_for_surface
= dce110_apply_ctx_for_surface
,
2749 .update_plane_addr
= update_plane_addr
,
2750 .update_pending_status
= dce110_update_pending_status
,
2751 .set_input_transfer_func
= dce110_set_input_transfer_func
,
2752 .set_output_transfer_func
= dce110_set_output_transfer_func
,
2753 .power_down
= dce110_power_down
,
2754 .enable_accelerated_mode
= dce110_enable_accelerated_mode
,
2755 .enable_timing_synchronization
= dce110_enable_timing_synchronization
,
2756 .enable_per_frame_crtc_position_reset
= dce110_enable_per_frame_crtc_position_reset
,
2757 .update_info_frame
= dce110_update_info_frame
,
2758 .enable_stream
= dce110_enable_stream
,
2759 .disable_stream
= dce110_disable_stream
,
2760 .unblank_stream
= dce110_unblank_stream
,
2761 .blank_stream
= dce110_blank_stream
,
2762 .enable_audio_stream
= dce110_enable_audio_stream
,
2763 .disable_audio_stream
= dce110_disable_audio_stream
,
2764 .enable_display_pipe_clock_gating
= enable_display_pipe_clock_gating
,
2765 .enable_display_power_gating
= dce110_enable_display_power_gating
,
2766 .disable_plane
= dce110_power_down_fe
,
2767 .pipe_control_lock
= dce_pipe_control_lock
,
2768 .prepare_bandwidth
= dce110_prepare_bandwidth
,
2769 .optimize_bandwidth
= dce110_optimize_bandwidth
,
2771 .get_position
= get_position
,
2772 .set_static_screen_control
= set_static_screen_control
,
2773 .reset_hw_ctx_wrap
= dce110_reset_hw_ctx_wrap
,
2774 .enable_stream_timing
= dce110_enable_stream_timing
,
2775 .disable_stream_gating
= NULL
,
2776 .enable_stream_gating
= NULL
,
2777 .setup_stereo
= NULL
,
2778 .set_avmute
= dce110_set_avmute
,
2779 .wait_for_mpcc_disconnect
= dce110_wait_for_mpcc_disconnect
,
2780 .edp_backlight_control
= hwss_edp_backlight_control
,
2781 .edp_power_control
= hwss_edp_power_control
,
2782 .edp_wait_for_hpd_ready
= hwss_edp_wait_for_hpd_ready
,
2783 .set_cursor_position
= dce110_set_cursor_position
,
2784 .set_cursor_attribute
= dce110_set_cursor_attribute
2787 void dce110_hw_sequencer_construct(struct dc
*dc
)
2789 dc
->hwss
= dce110_funcs
;