2 * Copyright 2012-15 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 "dm_services.h"
28 #include "dm_helpers.h"
30 #include "grph_object_id.h"
31 #include "gpio_service_interface.h"
32 #include "core_status.h"
33 #include "dc_link_dp.h"
34 #include "dc_link_ddc.h"
35 #include "link_hwss.h"
38 #include "link_encoder.h"
39 #include "hw_sequencer.h"
42 #include "fixed31_32.h"
43 #include "dpcd_defs.h"
46 #include "dce/dce_11_0_d.h"
47 #include "dce/dce_11_0_enum.h"
48 #include "dce/dce_11_0_sh_mask.h"
50 #define DC_LOGGER_INIT(logger)
53 #define LINK_INFO(...) \
57 /*******************************************************************************
59 ******************************************************************************/
62 LINK_RATE_REF_FREQ_IN_MHZ = 27,
63 PEAK_FACTOR_X1000 = 1006
66 /*******************************************************************************
68 ******************************************************************************/
69 static void destruct(struct dc_link *link)
74 dal_ddc_service_destroy(&link->ddc);
77 link->link_enc->funcs->destroy(&link->link_enc);
80 dc_sink_release(link->local_sink);
82 for (i = 0; i < link->sink_count; ++i)
83 dc_sink_release(link->remote_sinks[i]);
86 struct gpio *get_hpd_gpio(struct dc_bios *dcb,
87 struct graphics_object_id link_id,
88 struct gpio_service *gpio_service)
90 enum bp_result bp_result;
91 struct graphics_object_hpd_info hpd_info;
92 struct gpio_pin_info pin_info;
94 if (dcb->funcs->get_hpd_info(dcb, link_id, &hpd_info) != BP_RESULT_OK)
97 bp_result = dcb->funcs->get_gpio_pin_info(dcb,
98 hpd_info.hpd_int_gpio_uid, &pin_info);
100 if (bp_result != BP_RESULT_OK) {
101 ASSERT(bp_result == BP_RESULT_NORECORD);
105 return dal_gpio_service_create_irq(
112 * Function: program_hpd_filter
115 * Programs HPD filter on associated HPD line
117 * @param [in] delay_on_connect_in_ms: Connect filter timeout
118 * @param [in] delay_on_disconnect_in_ms: Disconnect filter timeout
121 * true on success, false otherwise
123 static bool program_hpd_filter(
124 const struct dc_link *link)
130 int delay_on_connect_in_ms = 0;
131 int delay_on_disconnect_in_ms = 0;
133 if (link->is_hpd_filter_disabled)
135 /* Verify feature is supported */
136 switch (link->connector_signal) {
137 case SIGNAL_TYPE_DVI_SINGLE_LINK:
138 case SIGNAL_TYPE_DVI_DUAL_LINK:
139 case SIGNAL_TYPE_HDMI_TYPE_A:
140 /* Program hpd filter */
141 delay_on_connect_in_ms = 500;
142 delay_on_disconnect_in_ms = 100;
144 case SIGNAL_TYPE_DISPLAY_PORT:
145 case SIGNAL_TYPE_DISPLAY_PORT_MST:
146 /* Program hpd filter to allow DP signal to settle */
147 /* 500: not able to detect MST <-> SST switch as HPD is low for
148 * only 100ms on DELL U2413
149 * 0: some passive dongle still show aux mode instead of i2c
150 * 20-50:not enough to hide bouncing HPD with passive dongle.
151 * also see intermittent i2c read issues.
153 delay_on_connect_in_ms = 80;
154 delay_on_disconnect_in_ms = 0;
156 case SIGNAL_TYPE_LVDS:
157 case SIGNAL_TYPE_EDP:
159 /* Don't program hpd filter */
163 /* Obtain HPD handle */
164 hpd = get_hpd_gpio(link->ctx->dc_bios, link->link_id, link->ctx->gpio_service);
169 /* Setup HPD filtering */
170 if (dal_gpio_open(hpd, GPIO_MODE_INTERRUPT) == GPIO_RESULT_OK) {
171 struct gpio_hpd_config config;
173 config.delay_on_connect = delay_on_connect_in_ms;
174 config.delay_on_disconnect = delay_on_disconnect_in_ms;
176 dal_irq_setup_hpd_filter(hpd, &config);
182 ASSERT_CRITICAL(false);
185 /* Release HPD handle */
186 dal_gpio_destroy_irq(&hpd);
191 static bool detect_sink(struct dc_link *link, enum dc_connection_type *type)
193 uint32_t is_hpd_high = 0;
194 struct gpio *hpd_pin;
196 /* todo: may need to lock gpio access */
197 hpd_pin = get_hpd_gpio(link->ctx->dc_bios, link->link_id, link->ctx->gpio_service);
199 goto hpd_gpio_failure;
201 dal_gpio_open(hpd_pin, GPIO_MODE_INTERRUPT);
202 dal_gpio_get_value(hpd_pin, &is_hpd_high);
203 dal_gpio_close(hpd_pin);
204 dal_gpio_destroy_irq(&hpd_pin);
207 *type = dc_connection_single;
208 /* TODO: need to do the actual detection */
210 *type = dc_connection_none;
219 static enum ddc_transaction_type get_ddc_transaction_type(
220 enum signal_type sink_signal)
222 enum ddc_transaction_type transaction_type = DDC_TRANSACTION_TYPE_NONE;
224 switch (sink_signal) {
225 case SIGNAL_TYPE_DVI_SINGLE_LINK:
226 case SIGNAL_TYPE_DVI_DUAL_LINK:
227 case SIGNAL_TYPE_HDMI_TYPE_A:
228 case SIGNAL_TYPE_LVDS:
229 case SIGNAL_TYPE_RGB:
230 transaction_type = DDC_TRANSACTION_TYPE_I2C;
233 case SIGNAL_TYPE_DISPLAY_PORT:
234 case SIGNAL_TYPE_EDP:
235 transaction_type = DDC_TRANSACTION_TYPE_I2C_OVER_AUX;
238 case SIGNAL_TYPE_DISPLAY_PORT_MST:
239 /* MST does not use I2COverAux, but there is the
240 * SPECIAL use case for "immediate dwnstrm device
241 * access" (EPR#370830). */
242 transaction_type = DDC_TRANSACTION_TYPE_I2C_OVER_AUX;
249 return transaction_type;
252 static enum signal_type get_basic_signal_type(
253 struct graphics_object_id encoder,
254 struct graphics_object_id downstream)
256 if (downstream.type == OBJECT_TYPE_CONNECTOR) {
257 switch (downstream.id) {
258 case CONNECTOR_ID_SINGLE_LINK_DVII:
259 switch (encoder.id) {
260 case ENCODER_ID_INTERNAL_DAC1:
261 case ENCODER_ID_INTERNAL_KLDSCP_DAC1:
262 case ENCODER_ID_INTERNAL_DAC2:
263 case ENCODER_ID_INTERNAL_KLDSCP_DAC2:
264 return SIGNAL_TYPE_RGB;
266 return SIGNAL_TYPE_DVI_SINGLE_LINK;
269 case CONNECTOR_ID_DUAL_LINK_DVII:
271 switch (encoder.id) {
272 case ENCODER_ID_INTERNAL_DAC1:
273 case ENCODER_ID_INTERNAL_KLDSCP_DAC1:
274 case ENCODER_ID_INTERNAL_DAC2:
275 case ENCODER_ID_INTERNAL_KLDSCP_DAC2:
276 return SIGNAL_TYPE_RGB;
278 return SIGNAL_TYPE_DVI_DUAL_LINK;
282 case CONNECTOR_ID_SINGLE_LINK_DVID:
283 return SIGNAL_TYPE_DVI_SINGLE_LINK;
284 case CONNECTOR_ID_DUAL_LINK_DVID:
285 return SIGNAL_TYPE_DVI_DUAL_LINK;
286 case CONNECTOR_ID_VGA:
287 return SIGNAL_TYPE_RGB;
288 case CONNECTOR_ID_HDMI_TYPE_A:
289 return SIGNAL_TYPE_HDMI_TYPE_A;
290 case CONNECTOR_ID_LVDS:
291 return SIGNAL_TYPE_LVDS;
292 case CONNECTOR_ID_DISPLAY_PORT:
293 return SIGNAL_TYPE_DISPLAY_PORT;
294 case CONNECTOR_ID_EDP:
295 return SIGNAL_TYPE_EDP;
297 return SIGNAL_TYPE_NONE;
299 } else if (downstream.type == OBJECT_TYPE_ENCODER) {
300 switch (downstream.id) {
301 case ENCODER_ID_EXTERNAL_NUTMEG:
302 case ENCODER_ID_EXTERNAL_TRAVIS:
303 return SIGNAL_TYPE_DISPLAY_PORT;
305 return SIGNAL_TYPE_NONE;
309 return SIGNAL_TYPE_NONE;
314 * Check whether there is a dongle on DP connector
316 static bool is_dp_sink_present(struct dc_link *link)
318 enum gpio_result gpio_result;
319 uint32_t clock_pin = 0;
323 enum connector_id connector_id =
324 dal_graphics_object_id_get_connector_id(link->link_id);
327 ((connector_id == CONNECTOR_ID_DISPLAY_PORT) ||
328 (connector_id == CONNECTOR_ID_EDP));
330 ddc = dal_ddc_service_get_ddc_pin(link->ddc);
337 /* Open GPIO and set it to I2C mode */
338 /* Note: this GpioMode_Input will be converted
339 * to GpioConfigType_I2cAuxDualMode in GPIO component,
340 * which indicates we need additional delay */
342 if (GPIO_RESULT_OK != dal_ddc_open(
343 ddc, GPIO_MODE_INPUT, GPIO_DDC_CONFIG_TYPE_MODE_I2C)) {
344 dal_gpio_destroy_ddc(&ddc);
349 /* Read GPIO: DP sink is present if both clock and data pins are zero */
350 /* [anaumov] in DAL2, there was no check for GPIO failure */
352 gpio_result = dal_gpio_get_value(ddc->pin_clock, &clock_pin);
353 ASSERT(gpio_result == GPIO_RESULT_OK);
355 present = (gpio_result == GPIO_RESULT_OK) && !clock_pin;
364 * Detect output sink type
366 static enum signal_type link_detect_sink(
367 struct dc_link *link,
368 enum dc_detect_reason reason)
370 enum signal_type result = get_basic_signal_type(
371 link->link_enc->id, link->link_id);
373 /* Internal digital encoder will detect only dongles
374 * that require digital signal */
376 /* Detection mechanism is different
377 * for different native connectors.
378 * LVDS connector supports only LVDS signal;
379 * PCIE is a bus slot, the actual connector needs to be detected first;
380 * eDP connector supports only eDP signal;
381 * HDMI should check straps for audio */
383 /* PCIE detects the actual connector on add-on board */
385 if (link->link_id.id == CONNECTOR_ID_PCIE) {
386 /* ZAZTODO implement PCIE add-on card detection */
389 switch (link->link_id.id) {
390 case CONNECTOR_ID_HDMI_TYPE_A: {
391 /* check audio support:
392 * if native HDMI is not supported, switch to DVI */
393 struct audio_support *aud_support = &link->dc->res_pool->audio_support;
395 if (!aud_support->hdmi_audio_native)
396 if (link->link_id.id == CONNECTOR_ID_HDMI_TYPE_A)
397 result = SIGNAL_TYPE_DVI_SINGLE_LINK;
400 case CONNECTOR_ID_DISPLAY_PORT: {
401 /* DP HPD short pulse. Passive DP dongle will not
404 if (reason != DETECT_REASON_HPDRX) {
405 /* Check whether DP signal detected: if not -
406 * we assume signal is DVI; it could be corrected
407 * to HDMI after dongle detection
409 if (!is_dp_sink_present(link))
410 result = SIGNAL_TYPE_DVI_SINGLE_LINK;
421 static enum signal_type decide_signal_from_strap_and_dongle_type(
422 enum display_dongle_type dongle_type,
423 struct audio_support *audio_support)
425 enum signal_type signal = SIGNAL_TYPE_NONE;
427 switch (dongle_type) {
428 case DISPLAY_DONGLE_DP_HDMI_DONGLE:
429 if (audio_support->hdmi_audio_on_dongle)
430 signal = SIGNAL_TYPE_HDMI_TYPE_A;
432 signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
434 case DISPLAY_DONGLE_DP_DVI_DONGLE:
435 signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
437 case DISPLAY_DONGLE_DP_HDMI_MISMATCHED_DONGLE:
438 if (audio_support->hdmi_audio_native)
439 signal = SIGNAL_TYPE_HDMI_TYPE_A;
441 signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
444 signal = SIGNAL_TYPE_NONE;
451 static enum signal_type dp_passive_dongle_detection(
452 struct ddc_service *ddc,
453 struct display_sink_capability *sink_cap,
454 struct audio_support *audio_support)
456 dal_ddc_service_i2c_query_dp_dual_mode_adaptor(
458 return decide_signal_from_strap_and_dongle_type(
459 sink_cap->dongle_type,
463 static void link_disconnect_sink(struct dc_link *link)
465 if (link->local_sink) {
466 dc_sink_release(link->local_sink);
467 link->local_sink = NULL;
470 link->dpcd_sink_count = 0;
473 static void link_disconnect_remap(struct dc_sink *prev_sink, struct dc_link *link)
475 dc_sink_release(link->local_sink);
476 link->local_sink = prev_sink;
480 static bool detect_dp(
481 struct dc_link *link,
482 struct display_sink_capability *sink_caps,
483 bool *converter_disable_audio,
484 struct audio_support *audio_support,
485 enum dc_detect_reason reason)
488 sink_caps->signal = link_detect_sink(link, reason);
489 sink_caps->transaction_type =
490 get_ddc_transaction_type(sink_caps->signal);
492 if (sink_caps->transaction_type == DDC_TRANSACTION_TYPE_I2C_OVER_AUX) {
493 sink_caps->signal = SIGNAL_TYPE_DISPLAY_PORT;
494 if (!detect_dp_sink_caps(link))
497 if (is_mst_supported(link)) {
498 sink_caps->signal = SIGNAL_TYPE_DISPLAY_PORT_MST;
499 link->type = dc_connection_mst_branch;
501 dal_ddc_service_set_transaction_type(
503 sink_caps->transaction_type);
506 * This call will initiate MST topology discovery. Which
507 * will detect MST ports and add new DRM connector DRM
508 * framework. Then read EDID via remote i2c over aux. In
509 * the end, will notify DRM detect result and save EDID
510 * into DRM framework.
512 * .detect is called by .fill_modes.
513 * .fill_modes is called by user mode ioctl
514 * DRM_IOCTL_MODE_GETCONNECTOR.
516 * .get_modes is called by .fill_modes.
518 * call .get_modes, AMDGPU DM implementation will create
519 * new dc_sink and add to dc_link. For long HPD plug
520 * in/out, MST has its own handle.
522 * Therefore, just after dc_create, link->sink is not
523 * created for MST until user mode app calls
524 * DRM_IOCTL_MODE_GETCONNECTOR.
526 * Need check ->sink usages in case ->sink = NULL
527 * TODO: s3 resume check
529 if (reason == DETECT_REASON_BOOT)
532 if (!dm_helpers_dp_mst_start_top_mgr(
535 /* MST not supported */
536 link->type = dc_connection_single;
537 sink_caps->signal = SIGNAL_TYPE_DISPLAY_PORT;
541 if (link->type != dc_connection_mst_branch &&
542 is_dp_active_dongle(link)) {
543 /* DP active dongles */
544 link->type = dc_connection_active_dongle;
545 if (!link->dpcd_caps.sink_count.bits.SINK_COUNT) {
547 * active dongle unplug processing for short irq
549 link_disconnect_sink(link);
553 if (link->dpcd_caps.dongle_type != DISPLAY_DONGLE_DP_HDMI_CONVERTER)
554 *converter_disable_audio = true;
557 /* DP passive dongles */
558 sink_caps->signal = dp_passive_dongle_detection(link->ddc,
566 static bool is_same_edid(struct dc_edid *old_edid, struct dc_edid *new_edid)
568 if (old_edid->length != new_edid->length)
571 if (new_edid->length == 0)
574 return (memcmp(old_edid->raw_edid, new_edid->raw_edid, new_edid->length) == 0);
577 bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason)
579 struct dc_sink_init_data sink_init_data = { 0 };
580 struct display_sink_capability sink_caps = { 0 };
582 bool converter_disable_audio = false;
583 struct audio_support *aud_support = &link->dc->res_pool->audio_support;
584 bool same_edid = false;
585 enum dc_edid_status edid_status;
586 struct dc_context *dc_ctx = link->ctx;
587 struct dc_sink *sink = NULL;
588 struct dc_sink *prev_sink = NULL;
589 struct dpcd_caps prev_dpcd_caps;
590 bool same_dpcd = true;
591 enum dc_connection_type new_connection_type = dc_connection_none;
592 DC_LOGGER_INIT(link->ctx->logger);
593 if (link->connector_signal == SIGNAL_TYPE_VIRTUAL)
596 if (false == detect_sink(link, &new_connection_type)) {
601 if (link->connector_signal == SIGNAL_TYPE_EDP &&
605 prev_sink = link->local_sink;
606 if (prev_sink != NULL) {
607 dc_sink_retain(prev_sink);
608 memcpy(&prev_dpcd_caps, &link->dpcd_caps, sizeof(struct dpcd_caps));
610 link_disconnect_sink(link);
612 if (new_connection_type != dc_connection_none) {
613 link->type = new_connection_type;
615 /* From Disconnected-to-Connected. */
616 switch (link->connector_signal) {
617 case SIGNAL_TYPE_HDMI_TYPE_A: {
618 sink_caps.transaction_type = DDC_TRANSACTION_TYPE_I2C;
619 if (aud_support->hdmi_audio_native)
620 sink_caps.signal = SIGNAL_TYPE_HDMI_TYPE_A;
622 sink_caps.signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
626 case SIGNAL_TYPE_DVI_SINGLE_LINK: {
627 sink_caps.transaction_type = DDC_TRANSACTION_TYPE_I2C;
628 sink_caps.signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
632 case SIGNAL_TYPE_DVI_DUAL_LINK: {
633 sink_caps.transaction_type = DDC_TRANSACTION_TYPE_I2C;
634 sink_caps.signal = SIGNAL_TYPE_DVI_DUAL_LINK;
638 case SIGNAL_TYPE_EDP: {
639 detect_edp_sink_caps(link);
640 sink_caps.transaction_type =
641 DDC_TRANSACTION_TYPE_I2C_OVER_AUX;
642 sink_caps.signal = SIGNAL_TYPE_EDP;
646 case SIGNAL_TYPE_DISPLAY_PORT: {
650 &converter_disable_audio,
651 aud_support, reason)) {
652 if (prev_sink != NULL)
653 dc_sink_release(prev_sink);
657 // Check if dpcp block is the same
658 if (prev_sink != NULL) {
659 if (memcmp(&link->dpcd_caps, &prev_dpcd_caps, sizeof(struct dpcd_caps)))
662 /* Active dongle downstream unplug */
663 if (link->type == dc_connection_active_dongle
664 && link->dpcd_caps.sink_count.
665 bits.SINK_COUNT == 0) {
666 if (prev_sink != NULL)
667 dc_sink_release(prev_sink);
671 if (link->type == dc_connection_mst_branch) {
672 LINK_INFO("link=%d, mst branch is now Connected\n",
674 /* Need to setup mst link_cap struct here
675 * otherwise dc_link_detect() will leave mst link_cap
676 * empty which leads to allocate_mst_payload() has "0"
677 * pbn_per_slot value leading to exception on dc_fixpt_div()
679 link->verified_link_cap = link->reported_link_cap;
680 if (prev_sink != NULL)
681 dc_sink_release(prev_sink);
689 DC_ERROR("Invalid connector type! signal:%d\n",
690 link->connector_signal);
691 if (prev_sink != NULL)
692 dc_sink_release(prev_sink);
696 if (link->dpcd_caps.sink_count.bits.SINK_COUNT)
697 link->dpcd_sink_count = link->dpcd_caps.sink_count.
700 link->dpcd_sink_count = 1;
702 dal_ddc_service_set_transaction_type(
704 sink_caps.transaction_type);
706 link->aux_mode = dal_ddc_service_is_in_aux_transaction_mode(
709 sink_init_data.link = link;
710 sink_init_data.sink_signal = sink_caps.signal;
712 sink = dc_sink_create(&sink_init_data);
714 DC_ERROR("Failed to create sink!\n");
715 if (prev_sink != NULL)
716 dc_sink_release(prev_sink);
720 sink->dongle_max_pix_clk = sink_caps.max_hdmi_pixel_clock;
721 sink->converter_disable_audio = converter_disable_audio;
723 link->local_sink = sink;
725 edid_status = dm_helpers_read_local_edid(
730 switch (edid_status) {
731 case EDID_BAD_CHECKSUM:
732 DC_LOG_ERROR("EDID checksum invalid.\n");
734 case EDID_NO_RESPONSE:
735 DC_LOG_ERROR("No EDID read.\n");
740 // Check if edid is the same
741 if ((prev_sink != NULL) && ((edid_status == EDID_THE_SAME) || (edid_status == EDID_OK)))
742 same_edid = is_same_edid(&prev_sink->dc_edid, &sink->dc_edid);
744 // If both edid and dpcd are the same, then discard new sink and revert back to original sink
745 if ((same_edid) && (same_dpcd)) {
746 link_disconnect_remap(prev_sink, link);
750 if (link->connector_signal == SIGNAL_TYPE_DISPLAY_PORT &&
751 sink_caps.transaction_type ==
752 DDC_TRANSACTION_TYPE_I2C_OVER_AUX) {
754 * TODO debug why Dell 2413 doesn't like
758 /* deal with non-mst cases */
759 dp_hbr_verify_link_cap(link, &link->reported_link_cap);
762 /* HDMI-DVI Dongle */
763 if (sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A &&
764 !sink->edid_caps.edid_hdmi)
765 sink->sink_signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
768 /* Connectivity log: detection */
769 for (i = 0; i < sink->dc_edid.length / EDID_BLOCK_SIZE; i++) {
770 CONN_DATA_DETECT(link,
771 &sink->dc_edid.raw_edid[i * EDID_BLOCK_SIZE],
773 "%s: [Block %d] ", sink->edid_caps.display_name, i);
776 DC_LOG_DETECTION_EDID_PARSER("%s: "
777 "manufacturer_id = %X, "
779 "serial_number = %X, "
780 "manufacture_week = %d, "
781 "manufacture_year = %d, "
782 "display_name = %s, "
783 "speaker_flag = %d, "
784 "audio_mode_count = %d\n",
786 sink->edid_caps.manufacturer_id,
787 sink->edid_caps.product_id,
788 sink->edid_caps.serial_number,
789 sink->edid_caps.manufacture_week,
790 sink->edid_caps.manufacture_year,
791 sink->edid_caps.display_name,
792 sink->edid_caps.speaker_flags,
793 sink->edid_caps.audio_mode_count);
795 for (i = 0; i < sink->edid_caps.audio_mode_count; i++) {
796 DC_LOG_DETECTION_EDID_PARSER("%s: mode number = %d, "
798 "channel_count = %d, "
800 "sample_size = %d\n",
803 sink->edid_caps.audio_modes[i].format_code,
804 sink->edid_caps.audio_modes[i].channel_count,
805 sink->edid_caps.audio_modes[i].sample_rate,
806 sink->edid_caps.audio_modes[i].sample_size);
810 /* From Connected-to-Disconnected. */
811 if (link->type == dc_connection_mst_branch) {
812 LINK_INFO("link=%d, mst branch is now Disconnected\n",
815 dm_helpers_dp_mst_stop_top_mgr(link->ctx, link);
817 link->mst_stream_alloc_table.stream_count = 0;
818 memset(link->mst_stream_alloc_table.stream_allocations, 0, sizeof(link->mst_stream_alloc_table.stream_allocations));
821 link->type = dc_connection_none;
822 sink_caps.signal = SIGNAL_TYPE_NONE;
825 LINK_INFO("link=%d, dc_sink_in=%p is now %s prev_sink=%p dpcd same=%d edid same=%d\n",
826 link->link_index, sink,
827 (sink_caps.signal == SIGNAL_TYPE_NONE ?
828 "Disconnected":"Connected"), prev_sink,
829 same_dpcd, same_edid);
831 if (prev_sink != NULL)
832 dc_sink_release(prev_sink);
837 static enum hpd_source_id get_hpd_line(
838 struct dc_link *link)
841 enum hpd_source_id hpd_id = HPD_SOURCEID_UNKNOWN;
843 hpd = get_hpd_gpio(link->ctx->dc_bios, link->link_id, link->ctx->gpio_service);
846 switch (dal_irq_get_source(hpd)) {
847 case DC_IRQ_SOURCE_HPD1:
848 hpd_id = HPD_SOURCEID1;
850 case DC_IRQ_SOURCE_HPD2:
851 hpd_id = HPD_SOURCEID2;
853 case DC_IRQ_SOURCE_HPD3:
854 hpd_id = HPD_SOURCEID3;
856 case DC_IRQ_SOURCE_HPD4:
857 hpd_id = HPD_SOURCEID4;
859 case DC_IRQ_SOURCE_HPD5:
860 hpd_id = HPD_SOURCEID5;
862 case DC_IRQ_SOURCE_HPD6:
863 hpd_id = HPD_SOURCEID6;
870 dal_gpio_destroy_irq(&hpd);
876 static enum channel_id get_ddc_line(struct dc_link *link)
879 enum channel_id channel = CHANNEL_ID_UNKNOWN;
881 ddc = dal_ddc_service_get_ddc_pin(link->ddc);
884 switch (dal_ddc_get_line(ddc)) {
885 case GPIO_DDC_LINE_DDC1:
886 channel = CHANNEL_ID_DDC1;
888 case GPIO_DDC_LINE_DDC2:
889 channel = CHANNEL_ID_DDC2;
891 case GPIO_DDC_LINE_DDC3:
892 channel = CHANNEL_ID_DDC3;
894 case GPIO_DDC_LINE_DDC4:
895 channel = CHANNEL_ID_DDC4;
897 case GPIO_DDC_LINE_DDC5:
898 channel = CHANNEL_ID_DDC5;
900 case GPIO_DDC_LINE_DDC6:
901 channel = CHANNEL_ID_DDC6;
903 case GPIO_DDC_LINE_DDC_VGA:
904 channel = CHANNEL_ID_DDC_VGA;
906 case GPIO_DDC_LINE_I2C_PAD:
907 channel = CHANNEL_ID_I2C_PAD;
918 static enum transmitter translate_encoder_to_transmitter(
919 struct graphics_object_id encoder)
921 switch (encoder.id) {
922 case ENCODER_ID_INTERNAL_UNIPHY:
923 switch (encoder.enum_id) {
925 return TRANSMITTER_UNIPHY_A;
927 return TRANSMITTER_UNIPHY_B;
929 return TRANSMITTER_UNKNOWN;
932 case ENCODER_ID_INTERNAL_UNIPHY1:
933 switch (encoder.enum_id) {
935 return TRANSMITTER_UNIPHY_C;
937 return TRANSMITTER_UNIPHY_D;
939 return TRANSMITTER_UNKNOWN;
942 case ENCODER_ID_INTERNAL_UNIPHY2:
943 switch (encoder.enum_id) {
945 return TRANSMITTER_UNIPHY_E;
947 return TRANSMITTER_UNIPHY_F;
949 return TRANSMITTER_UNKNOWN;
952 case ENCODER_ID_INTERNAL_UNIPHY3:
953 switch (encoder.enum_id) {
955 return TRANSMITTER_UNIPHY_G;
957 return TRANSMITTER_UNKNOWN;
960 case ENCODER_ID_EXTERNAL_NUTMEG:
961 switch (encoder.enum_id) {
963 return TRANSMITTER_NUTMEG_CRT;
965 return TRANSMITTER_UNKNOWN;
968 case ENCODER_ID_EXTERNAL_TRAVIS:
969 switch (encoder.enum_id) {
971 return TRANSMITTER_TRAVIS_CRT;
973 return TRANSMITTER_TRAVIS_LCD;
975 return TRANSMITTER_UNKNOWN;
979 return TRANSMITTER_UNKNOWN;
983 static bool construct(
984 struct dc_link *link,
985 const struct link_init_data *init_params)
988 struct gpio *hpd_gpio = NULL;
989 struct ddc_service_init_data ddc_service_init_data = { { 0 } };
990 struct dc_context *dc_ctx = init_params->ctx;
991 struct encoder_init_data enc_init_data = { 0 };
992 struct integrated_info info = {{{ 0 }}};
993 struct dc_bios *bios = init_params->dc->ctx->dc_bios;
994 const struct dc_vbios_funcs *bp_funcs = bios->funcs;
995 DC_LOGGER_INIT(dc_ctx->logger);
997 link->irq_source_hpd = DC_IRQ_SOURCE_INVALID;
998 link->irq_source_hpd_rx = DC_IRQ_SOURCE_INVALID;
1000 link->link_status.dpcd_caps = &link->dpcd_caps;
1002 link->dc = init_params->dc;
1004 link->link_index = init_params->link_index;
1006 link->link_id = bios->funcs->get_connector_id(bios, init_params->connector_index);
1008 if (link->link_id.type != OBJECT_TYPE_CONNECTOR) {
1009 dm_error("%s: Invalid Connector ObjectID from Adapter Service for connector index:%d! type %d expected %d\n",
1010 __func__, init_params->connector_index,
1011 link->link_id.type, OBJECT_TYPE_CONNECTOR);
1015 hpd_gpio = get_hpd_gpio(link->ctx->dc_bios, link->link_id, link->ctx->gpio_service);
1017 if (hpd_gpio != NULL)
1018 link->irq_source_hpd = dal_irq_get_source(hpd_gpio);
1020 switch (link->link_id.id) {
1021 case CONNECTOR_ID_HDMI_TYPE_A:
1022 link->connector_signal = SIGNAL_TYPE_HDMI_TYPE_A;
1025 case CONNECTOR_ID_SINGLE_LINK_DVID:
1026 case CONNECTOR_ID_SINGLE_LINK_DVII:
1027 link->connector_signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
1029 case CONNECTOR_ID_DUAL_LINK_DVID:
1030 case CONNECTOR_ID_DUAL_LINK_DVII:
1031 link->connector_signal = SIGNAL_TYPE_DVI_DUAL_LINK;
1033 case CONNECTOR_ID_DISPLAY_PORT:
1034 link->connector_signal = SIGNAL_TYPE_DISPLAY_PORT;
1036 if (hpd_gpio != NULL)
1037 link->irq_source_hpd_rx =
1038 dal_irq_get_rx_source(hpd_gpio);
1041 case CONNECTOR_ID_EDP:
1042 link->connector_signal = SIGNAL_TYPE_EDP;
1044 if (hpd_gpio != NULL) {
1045 link->irq_source_hpd = DC_IRQ_SOURCE_INVALID;
1046 link->irq_source_hpd_rx =
1047 dal_irq_get_rx_source(hpd_gpio);
1051 DC_LOG_WARNING("Unsupported Connector type:%d!\n", link->link_id.id);
1055 if (hpd_gpio != NULL) {
1056 dal_gpio_destroy_irq(&hpd_gpio);
1060 /* TODO: #DAL3 Implement id to str function.*/
1061 LINK_INFO("Connector[%d] description:"
1063 init_params->connector_index,
1064 link->connector_signal);
1066 ddc_service_init_data.ctx = link->ctx;
1067 ddc_service_init_data.id = link->link_id;
1068 ddc_service_init_data.link = link;
1069 link->ddc = dal_ddc_service_create(&ddc_service_init_data);
1071 if (link->ddc == NULL) {
1072 DC_ERROR("Failed to create ddc_service!\n");
1073 goto ddc_create_fail;
1078 dal_ddc_service_get_ddc_pin(link->ddc));
1080 enc_init_data.ctx = dc_ctx;
1081 bp_funcs->get_src_obj(dc_ctx->dc_bios, link->link_id, 0, &enc_init_data.encoder);
1082 enc_init_data.connector = link->link_id;
1083 enc_init_data.channel = get_ddc_line(link);
1084 enc_init_data.hpd_source = get_hpd_line(link);
1086 link->hpd_src = enc_init_data.hpd_source;
1088 enc_init_data.transmitter =
1089 translate_encoder_to_transmitter(enc_init_data.encoder);
1090 link->link_enc = link->dc->res_pool->funcs->link_enc_create(
1093 if( link->link_enc == NULL) {
1094 DC_ERROR("Failed to create link encoder!\n");
1095 goto link_enc_create_fail;
1098 link->link_enc_hw_inst = link->link_enc->transmitter;
1100 for (i = 0; i < 4; i++) {
1102 bp_funcs->get_device_tag(dc_ctx->dc_bios, link->link_id, i, &link->device_tag)) {
1103 DC_ERROR("Failed to find device tag!\n");
1104 goto device_tag_fail;
1107 /* Look for device tag that matches connector signal,
1108 * CRT for rgb, LCD for other supported signal tyes
1110 if (!bp_funcs->is_device_id_supported(dc_ctx->dc_bios, link->device_tag.dev_id))
1112 if (link->device_tag.dev_id.device_type == DEVICE_TYPE_CRT
1113 && link->connector_signal != SIGNAL_TYPE_RGB)
1115 if (link->device_tag.dev_id.device_type == DEVICE_TYPE_LCD
1116 && link->connector_signal == SIGNAL_TYPE_RGB)
1121 if (bios->integrated_info)
1122 info = *bios->integrated_info;
1124 /* Look for channel mapping corresponding to connector and device tag */
1125 for (i = 0; i < MAX_NUMBER_OF_EXT_DISPLAY_PATH; i++) {
1126 struct external_display_path *path =
1127 &info.ext_disp_conn_info.path[i];
1128 if (path->device_connector_id.enum_id == link->link_id.enum_id
1129 && path->device_connector_id.id == link->link_id.id
1130 && path->device_connector_id.type == link->link_id.type) {
1132 if (link->device_tag.acpi_device != 0
1133 && path->device_acpi_enum == link->device_tag.acpi_device) {
1134 link->ddi_channel_mapping = path->channel_mapping;
1135 link->chip_caps = path->caps;
1136 } else if (path->device_tag ==
1137 link->device_tag.dev_id.raw_device_tag) {
1138 link->ddi_channel_mapping = path->channel_mapping;
1139 link->chip_caps = path->caps;
1146 * TODO check if GPIO programmed correctly
1148 * If GPIO isn't programmed correctly HPD might not rise or drain
1149 * fast enough, leading to bounces.
1151 program_hpd_filter(link);
1155 link->link_enc->funcs->destroy(&link->link_enc);
1156 link_enc_create_fail:
1157 dal_ddc_service_destroy(&link->ddc);
1161 if (hpd_gpio != NULL) {
1162 dal_gpio_destroy_irq(&hpd_gpio);
1168 /*******************************************************************************
1170 ******************************************************************************/
1171 struct dc_link *link_create(const struct link_init_data *init_params)
1173 struct dc_link *link =
1174 kzalloc(sizeof(*link), GFP_KERNEL);
1179 if (false == construct(link, init_params))
1180 goto construct_fail;
1191 void link_destroy(struct dc_link **link)
1198 static void dpcd_configure_panel_mode(
1199 struct dc_link *link,
1200 enum dp_panel_mode panel_mode)
1202 union dpcd_edp_config edp_config_set;
1203 bool panel_mode_edp = false;
1204 DC_LOGGER_INIT(link->ctx->logger);
1206 memset(&edp_config_set, '\0', sizeof(union dpcd_edp_config));
1208 if (DP_PANEL_MODE_DEFAULT != panel_mode) {
1210 switch (panel_mode) {
1211 case DP_PANEL_MODE_EDP:
1212 case DP_PANEL_MODE_SPECIAL:
1213 panel_mode_edp = true;
1220 /*set edp panel mode in receiver*/
1221 core_link_read_dpcd(
1223 DP_EDP_CONFIGURATION_SET,
1224 &edp_config_set.raw,
1225 sizeof(edp_config_set.raw));
1227 if (edp_config_set.bits.PANEL_MODE_EDP
1228 != panel_mode_edp) {
1229 enum ddc_result result = DDC_RESULT_UNKNOWN;
1231 edp_config_set.bits.PANEL_MODE_EDP =
1233 result = core_link_write_dpcd(
1235 DP_EDP_CONFIGURATION_SET,
1236 &edp_config_set.raw,
1237 sizeof(edp_config_set.raw));
1239 ASSERT(result == DDC_RESULT_SUCESSFULL);
1242 DC_LOG_DETECTION_DP_CAPS("Link: %d eDP panel mode supported: %d "
1243 "eDP panel mode enabled: %d \n",
1245 link->dpcd_caps.panel_mode_edp,
1249 static void enable_stream_features(struct pipe_ctx *pipe_ctx)
1251 struct dc_stream_state *stream = pipe_ctx->stream;
1252 struct dc_link *link = stream->sink->link;
1253 union down_spread_ctrl old_downspread;
1254 union down_spread_ctrl new_downspread;
1256 core_link_read_dpcd(link, DP_DOWNSPREAD_CTRL,
1257 &old_downspread.raw, sizeof(old_downspread));
1259 new_downspread.raw = old_downspread.raw;
1261 new_downspread.bits.IGNORE_MSA_TIMING_PARAM =
1262 (stream->ignore_msa_timing_param) ? 1 : 0;
1264 if (new_downspread.raw != old_downspread.raw) {
1265 core_link_write_dpcd(link, DP_DOWNSPREAD_CTRL,
1266 &new_downspread.raw, sizeof(new_downspread));
1270 static enum dc_status enable_link_dp(
1271 struct dc_state *state,
1272 struct pipe_ctx *pipe_ctx)
1274 struct dc_stream_state *stream = pipe_ctx->stream;
1275 enum dc_status status;
1276 bool skip_video_pattern;
1277 struct dc_link *link = stream->sink->link;
1278 struct dc_link_settings link_settings = {0};
1279 enum dp_panel_mode panel_mode;
1280 enum dc_link_rate max_link_rate = LINK_RATE_HIGH2;
1282 /* get link settings for video mode timing */
1283 decide_link_settings(stream, &link_settings);
1285 /* raise clock state for HBR3 if required. Confirmed with HW DCE/DPCS
1286 * logic for HBR3 still needs Nominal (0.8V) on VDDC rail
1288 if (link->link_enc->features.flags.bits.IS_HBR3_CAPABLE)
1289 max_link_rate = LINK_RATE_HIGH3;
1291 if (link_settings.link_rate == max_link_rate) {
1292 struct dc_clocks clocks = state->bw.dcn.clk;
1294 /* dce/dcn compat, do not update dispclk */
1295 clocks.dispclk_khz = 0;
1296 /* 27mhz = 27000000hz= 27000khz */
1297 clocks.phyclk_khz = link_settings.link_rate * 27000;
1299 state->dis_clk->funcs->update_clocks(
1300 state->dis_clk, &clocks, false);
1305 pipe_ctx->stream->signal,
1306 pipe_ctx->clock_source->id,
1309 if (stream->sink->edid_caps.panel_patch.dppowerup_delay > 0) {
1310 int delay_dp_power_up_in_ms = stream->sink->edid_caps.panel_patch.dppowerup_delay;
1312 msleep(delay_dp_power_up_in_ms);
1315 panel_mode = dp_get_panel_mode(link);
1316 dpcd_configure_panel_mode(link, panel_mode);
1318 skip_video_pattern = true;
1320 if (link_settings.link_rate == LINK_RATE_LOW)
1321 skip_video_pattern = false;
1323 if (perform_link_training_with_retries(
1327 LINK_TRAINING_ATTEMPTS)) {
1328 link->cur_link_settings = link_settings;
1332 status = DC_FAIL_DP_LINK_TRAINING;
1334 enable_stream_features(pipe_ctx);
1339 static enum dc_status enable_link_edp(
1340 struct dc_state *state,
1341 struct pipe_ctx *pipe_ctx)
1343 enum dc_status status;
1344 struct dc_stream_state *stream = pipe_ctx->stream;
1345 struct dc_link *link = stream->sink->link;
1346 /*in case it is not on*/
1347 link->dc->hwss.edp_power_control(link, true);
1348 link->dc->hwss.edp_wait_for_hpd_ready(link, true);
1350 status = enable_link_dp(state, pipe_ctx);
1356 static enum dc_status enable_link_dp_mst(
1357 struct dc_state *state,
1358 struct pipe_ctx *pipe_ctx)
1360 struct dc_link *link = pipe_ctx->stream->sink->link;
1362 /* sink signal type after MST branch is MST. Multiple MST sinks
1363 * share one link. Link DP PHY is enable or training only once.
1365 if (link->cur_link_settings.lane_count != LANE_COUNT_UNKNOWN)
1368 /* clear payload table */
1369 dm_helpers_dp_mst_clear_payload_allocation_table(link->ctx, link);
1371 /* set the sink to MST mode before enabling the link */
1372 dp_enable_mst_on_sink(link, true);
1374 return enable_link_dp(state, pipe_ctx);
1377 static bool get_ext_hdmi_settings(struct pipe_ctx *pipe_ctx,
1378 enum engine_id eng_id,
1379 struct ext_hdmi_settings *settings)
1381 bool result = false;
1383 struct integrated_info *integrated_info =
1384 pipe_ctx->stream->ctx->dc_bios->integrated_info;
1386 if (integrated_info == NULL)
1390 * Get retimer settings from sbios for passing SI eye test for DCE11
1391 * The setting values are varied based on board revision and port id
1392 * Therefore the setting values of each ports is passed by sbios.
1395 // Check if current bios contains ext Hdmi settings
1396 if (integrated_info->gpu_cap_info & 0x20) {
1398 case ENGINE_ID_DIGA:
1399 settings->slv_addr = integrated_info->dp0_ext_hdmi_slv_addr;
1400 settings->reg_num = integrated_info->dp0_ext_hdmi_6g_reg_num;
1401 settings->reg_num_6g = integrated_info->dp0_ext_hdmi_6g_reg_num;
1402 memmove(settings->reg_settings,
1403 integrated_info->dp0_ext_hdmi_reg_settings,
1404 sizeof(integrated_info->dp0_ext_hdmi_reg_settings));
1405 memmove(settings->reg_settings_6g,
1406 integrated_info->dp0_ext_hdmi_6g_reg_settings,
1407 sizeof(integrated_info->dp0_ext_hdmi_6g_reg_settings));
1410 case ENGINE_ID_DIGB:
1411 settings->slv_addr = integrated_info->dp1_ext_hdmi_slv_addr;
1412 settings->reg_num = integrated_info->dp1_ext_hdmi_6g_reg_num;
1413 settings->reg_num_6g = integrated_info->dp1_ext_hdmi_6g_reg_num;
1414 memmove(settings->reg_settings,
1415 integrated_info->dp1_ext_hdmi_reg_settings,
1416 sizeof(integrated_info->dp1_ext_hdmi_reg_settings));
1417 memmove(settings->reg_settings_6g,
1418 integrated_info->dp1_ext_hdmi_6g_reg_settings,
1419 sizeof(integrated_info->dp1_ext_hdmi_6g_reg_settings));
1422 case ENGINE_ID_DIGC:
1423 settings->slv_addr = integrated_info->dp2_ext_hdmi_slv_addr;
1424 settings->reg_num = integrated_info->dp2_ext_hdmi_6g_reg_num;
1425 settings->reg_num_6g = integrated_info->dp2_ext_hdmi_6g_reg_num;
1426 memmove(settings->reg_settings,
1427 integrated_info->dp2_ext_hdmi_reg_settings,
1428 sizeof(integrated_info->dp2_ext_hdmi_reg_settings));
1429 memmove(settings->reg_settings_6g,
1430 integrated_info->dp2_ext_hdmi_6g_reg_settings,
1431 sizeof(integrated_info->dp2_ext_hdmi_6g_reg_settings));
1434 case ENGINE_ID_DIGD:
1435 settings->slv_addr = integrated_info->dp3_ext_hdmi_slv_addr;
1436 settings->reg_num = integrated_info->dp3_ext_hdmi_6g_reg_num;
1437 settings->reg_num_6g = integrated_info->dp3_ext_hdmi_6g_reg_num;
1438 memmove(settings->reg_settings,
1439 integrated_info->dp3_ext_hdmi_reg_settings,
1440 sizeof(integrated_info->dp3_ext_hdmi_reg_settings));
1441 memmove(settings->reg_settings_6g,
1442 integrated_info->dp3_ext_hdmi_6g_reg_settings,
1443 sizeof(integrated_info->dp3_ext_hdmi_6g_reg_settings));
1450 if (result == true) {
1451 // Validate settings from bios integrated info table
1452 if (settings->slv_addr == 0)
1454 if (settings->reg_num > 9)
1456 if (settings->reg_num_6g > 3)
1459 for (i = 0; i < settings->reg_num; i++) {
1460 if (settings->reg_settings[i].i2c_reg_index > 0x20)
1464 for (i = 0; i < settings->reg_num_6g; i++) {
1465 if (settings->reg_settings_6g[i].i2c_reg_index > 0x20)
1474 static bool i2c_write(struct pipe_ctx *pipe_ctx,
1475 uint8_t address, uint8_t *buffer, uint32_t length)
1477 struct i2c_command cmd = {0};
1478 struct i2c_payload payload = {0};
1480 memset(&payload, 0, sizeof(payload));
1481 memset(&cmd, 0, sizeof(cmd));
1483 cmd.number_of_payloads = 1;
1484 cmd.engine = I2C_COMMAND_ENGINE_DEFAULT;
1485 cmd.speed = pipe_ctx->stream->ctx->dc->caps.i2c_speed_in_khz;
1487 payload.address = address;
1488 payload.data = buffer;
1489 payload.length = length;
1490 payload.write = true;
1491 cmd.payloads = &payload;
1493 if (dc_submit_i2c(pipe_ctx->stream->ctx->dc,
1494 pipe_ctx->stream->sink->link->link_index, &cmd))
1500 static void write_i2c_retimer_setting(
1501 struct pipe_ctx *pipe_ctx,
1503 bool is_over_340mhz,
1504 struct ext_hdmi_settings *settings)
1506 uint8_t slave_address = (settings->slv_addr >> 1);
1508 const uint8_t apply_rx_tx_change = 0x4;
1509 uint8_t offset = 0xA;
1512 bool i2c_success = false;
1514 memset(&buffer, 0, sizeof(buffer));
1516 /* Start Ext-Hdmi programming*/
1518 for (i = 0; i < settings->reg_num; i++) {
1519 /* Apply 3G settings */
1520 if (settings->reg_settings[i].i2c_reg_index <= 0x20) {
1522 buffer[0] = settings->reg_settings[i].i2c_reg_index;
1523 buffer[1] = settings->reg_settings[i].i2c_reg_val;
1524 i2c_success = i2c_write(pipe_ctx, slave_address,
1525 buffer, sizeof(buffer));
1529 ASSERT(i2c_success);
1531 /* Based on DP159 specs, APPLY_RX_TX_CHANGE bit in 0x0A
1532 * needs to be set to 1 on every 0xA-0xC write.
1534 if (settings->reg_settings[i].i2c_reg_index == 0xA ||
1535 settings->reg_settings[i].i2c_reg_index == 0xB ||
1536 settings->reg_settings[i].i2c_reg_index == 0xC) {
1538 /* Query current value from offset 0xA */
1539 if (settings->reg_settings[i].i2c_reg_index == 0xA)
1540 value = settings->reg_settings[i].i2c_reg_val;
1543 dal_ddc_service_query_ddc_data(
1544 pipe_ctx->stream->sink->link->ddc,
1545 slave_address, &offset, 1, &value, 1);
1548 ASSERT(i2c_success);
1552 /* Set APPLY_RX_TX_CHANGE bit to 1 */
1553 buffer[1] = value | apply_rx_tx_change;
1554 i2c_success = i2c_write(pipe_ctx, slave_address,
1555 buffer, sizeof(buffer));
1558 ASSERT(i2c_success);
1563 /* Apply 3G settings */
1564 if (is_over_340mhz) {
1565 for (i = 0; i < settings->reg_num_6g; i++) {
1566 /* Apply 3G settings */
1567 if (settings->reg_settings[i].i2c_reg_index <= 0x20) {
1569 buffer[0] = settings->reg_settings_6g[i].i2c_reg_index;
1570 buffer[1] = settings->reg_settings_6g[i].i2c_reg_val;
1571 i2c_success = i2c_write(pipe_ctx, slave_address,
1572 buffer, sizeof(buffer));
1576 ASSERT(i2c_success);
1578 /* Based on DP159 specs, APPLY_RX_TX_CHANGE bit in 0x0A
1579 * needs to be set to 1 on every 0xA-0xC write.
1581 if (settings->reg_settings_6g[i].i2c_reg_index == 0xA ||
1582 settings->reg_settings_6g[i].i2c_reg_index == 0xB ||
1583 settings->reg_settings_6g[i].i2c_reg_index == 0xC) {
1585 /* Query current value from offset 0xA */
1586 if (settings->reg_settings_6g[i].i2c_reg_index == 0xA)
1587 value = settings->reg_settings_6g[i].i2c_reg_val;
1590 dal_ddc_service_query_ddc_data(
1591 pipe_ctx->stream->sink->link->ddc,
1592 slave_address, &offset, 1, &value, 1);
1595 ASSERT(i2c_success);
1599 /* Set APPLY_RX_TX_CHANGE bit to 1 */
1600 buffer[1] = value | apply_rx_tx_change;
1601 i2c_success = i2c_write(pipe_ctx, slave_address,
1602 buffer, sizeof(buffer));
1605 ASSERT(i2c_success);
1612 /* Program additional settings if using 640x480 resolution */
1614 /* Write offset 0xFF to 0x01 */
1617 i2c_success = i2c_write(pipe_ctx, slave_address,
1618 buffer, sizeof(buffer));
1621 ASSERT(i2c_success);
1623 /* Write offset 0x00 to 0x23 */
1626 i2c_success = i2c_write(pipe_ctx, slave_address,
1627 buffer, sizeof(buffer));
1630 ASSERT(i2c_success);
1632 /* Write offset 0xff to 0x00 */
1635 i2c_success = i2c_write(pipe_ctx, slave_address,
1636 buffer, sizeof(buffer));
1639 ASSERT(i2c_success);
1644 static void write_i2c_default_retimer_setting(
1645 struct pipe_ctx *pipe_ctx,
1647 bool is_over_340mhz)
1649 uint8_t slave_address = (0xBA >> 1);
1651 bool i2c_success = false;
1653 memset(&buffer, 0, sizeof(buffer));
1655 /* Program Slave Address for tuning single integrity */
1656 /* Write offset 0x0A to 0x13 */
1659 i2c_success = i2c_write(pipe_ctx, slave_address,
1660 buffer, sizeof(buffer));
1663 ASSERT(i2c_success);
1665 /* Write offset 0x0A to 0x17 */
1668 i2c_success = i2c_write(pipe_ctx, slave_address,
1669 buffer, sizeof(buffer));
1672 ASSERT(i2c_success);
1674 /* Write offset 0x0B to 0xDA or 0xD8 */
1676 buffer[1] = is_over_340mhz ? 0xDA : 0xD8;
1677 i2c_success = i2c_write(pipe_ctx, slave_address,
1678 buffer, sizeof(buffer));
1681 ASSERT(i2c_success);
1683 /* Write offset 0x0A to 0x17 */
1686 i2c_success = i2c_write(pipe_ctx, slave_address,
1687 buffer, sizeof(buffer));
1690 ASSERT(i2c_success);
1692 /* Write offset 0x0C to 0x1D or 0x91 */
1694 buffer[1] = is_over_340mhz ? 0x1D : 0x91;
1695 i2c_success = i2c_write(pipe_ctx, slave_address,
1696 buffer, sizeof(buffer));
1699 ASSERT(i2c_success);
1701 /* Write offset 0x0A to 0x17 */
1704 i2c_success = i2c_write(pipe_ctx, slave_address,
1705 buffer, sizeof(buffer));
1708 ASSERT(i2c_success);
1712 /* Program additional settings if using 640x480 resolution */
1714 /* Write offset 0xFF to 0x01 */
1717 i2c_success = i2c_write(pipe_ctx, slave_address,
1718 buffer, sizeof(buffer));
1721 ASSERT(i2c_success);
1723 /* Write offset 0x00 to 0x23 */
1726 i2c_success = i2c_write(pipe_ctx, slave_address,
1727 buffer, sizeof(buffer));
1730 ASSERT(i2c_success);
1732 /* Write offset 0xff to 0x00 */
1735 i2c_success = i2c_write(pipe_ctx, slave_address,
1736 buffer, sizeof(buffer));
1739 ASSERT(i2c_success);
1743 static void write_i2c_redriver_setting(
1744 struct pipe_ctx *pipe_ctx,
1745 bool is_over_340mhz)
1747 uint8_t slave_address = (0xF0 >> 1);
1749 bool i2c_success = false;
1751 memset(&buffer, 0, sizeof(buffer));
1753 // Program Slave Address for tuning single integrity
1757 buffer[6] = is_over_340mhz ? 0x4E : 0x4A;
1759 i2c_success = i2c_write(pipe_ctx, slave_address,
1760 buffer, sizeof(buffer));
1764 ASSERT(i2c_success);
1767 static void enable_link_hdmi(struct pipe_ctx *pipe_ctx)
1769 struct dc_stream_state *stream = pipe_ctx->stream;
1770 struct dc_link *link = stream->sink->link;
1771 enum dc_color_depth display_color_depth;
1772 enum engine_id eng_id;
1773 struct ext_hdmi_settings settings = {0};
1774 bool is_over_340mhz = false;
1775 bool is_vga_mode = (stream->timing.h_addressable == 640)
1776 && (stream->timing.v_addressable == 480);
1778 if (stream->phy_pix_clk > 340000)
1779 is_over_340mhz = true;
1781 if (dc_is_hdmi_signal(pipe_ctx->stream->signal)) {
1782 unsigned short masked_chip_caps = pipe_ctx->stream->sink->link->chip_caps &
1783 EXT_DISPLAY_PATH_CAPS__EXT_CHIP_MASK;
1784 if (masked_chip_caps == EXT_DISPLAY_PATH_CAPS__HDMI20_TISN65DP159RSBT) {
1785 /* DP159, Retimer settings */
1786 eng_id = pipe_ctx->stream_res.stream_enc->id;
1788 if (get_ext_hdmi_settings(pipe_ctx, eng_id, &settings)) {
1789 write_i2c_retimer_setting(pipe_ctx,
1790 is_vga_mode, is_over_340mhz, &settings);
1792 write_i2c_default_retimer_setting(pipe_ctx,
1793 is_vga_mode, is_over_340mhz);
1795 } else if (masked_chip_caps == EXT_DISPLAY_PATH_CAPS__HDMI20_PI3EQX1204) {
1796 /* PI3EQX1204, Redriver settings */
1797 write_i2c_redriver_setting(pipe_ctx, is_over_340mhz);
1801 if (dc_is_hdmi_signal(pipe_ctx->stream->signal))
1802 dal_ddc_service_write_scdc_data(
1803 stream->sink->link->ddc,
1804 stream->phy_pix_clk,
1805 stream->timing.flags.LTE_340MCSC_SCRAMBLE);
1807 memset(&stream->sink->link->cur_link_settings, 0,
1808 sizeof(struct dc_link_settings));
1810 display_color_depth = stream->timing.display_color_depth;
1811 if (stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR422)
1812 display_color_depth = COLOR_DEPTH_888;
1814 link->link_enc->funcs->enable_tmds_output(
1816 pipe_ctx->clock_source->id,
1817 display_color_depth,
1818 pipe_ctx->stream->signal,
1819 stream->phy_pix_clk);
1821 if (pipe_ctx->stream->signal == SIGNAL_TYPE_HDMI_TYPE_A)
1822 dal_ddc_service_read_scdc_data(link->ddc);
1825 /****************************enable_link***********************************/
1826 static enum dc_status enable_link(
1827 struct dc_state *state,
1828 struct pipe_ctx *pipe_ctx)
1830 enum dc_status status = DC_ERROR_UNEXPECTED;
1831 switch (pipe_ctx->stream->signal) {
1832 case SIGNAL_TYPE_DISPLAY_PORT:
1833 status = enable_link_dp(state, pipe_ctx);
1835 case SIGNAL_TYPE_EDP:
1836 status = enable_link_edp(state, pipe_ctx);
1838 case SIGNAL_TYPE_DISPLAY_PORT_MST:
1839 status = enable_link_dp_mst(state, pipe_ctx);
1842 case SIGNAL_TYPE_DVI_SINGLE_LINK:
1843 case SIGNAL_TYPE_DVI_DUAL_LINK:
1844 case SIGNAL_TYPE_HDMI_TYPE_A:
1845 enable_link_hdmi(pipe_ctx);
1848 case SIGNAL_TYPE_VIRTUAL:
1858 static void disable_link(struct dc_link *link, enum signal_type signal)
1861 * TODO: implement call for dp_set_hw_test_pattern
1862 * it is needed for compliance testing
1865 /* here we need to specify that encoder output settings
1866 * need to be calculated as for the set mode,
1867 * it will lead to querying dynamic link capabilities
1868 * which should be done before enable output */
1870 if (dc_is_dp_signal(signal)) {
1872 if (dc_is_dp_sst_signal(signal))
1873 dp_disable_link_phy(link, signal);
1875 dp_disable_link_phy_mst(link, signal);
1877 link->link_enc->funcs->disable_output(link->link_enc, signal);
1880 static bool dp_active_dongle_validate_timing(
1881 const struct dc_crtc_timing *timing,
1882 const struct dpcd_caps *dpcd_caps)
1884 unsigned int required_pix_clk = timing->pix_clk_khz;
1885 const struct dc_dongle_caps *dongle_caps = &dpcd_caps->dongle_caps;
1887 switch (dpcd_caps->dongle_type) {
1888 case DISPLAY_DONGLE_DP_VGA_CONVERTER:
1889 case DISPLAY_DONGLE_DP_DVI_CONVERTER:
1890 case DISPLAY_DONGLE_DP_DVI_DONGLE:
1891 if (timing->pixel_encoding == PIXEL_ENCODING_RGB)
1899 if (dongle_caps->dongle_type != DISPLAY_DONGLE_DP_HDMI_CONVERTER ||
1900 dongle_caps->extendedCapValid == false)
1903 /* Check Pixel Encoding */
1904 switch (timing->pixel_encoding) {
1905 case PIXEL_ENCODING_RGB:
1906 case PIXEL_ENCODING_YCBCR444:
1908 case PIXEL_ENCODING_YCBCR422:
1909 if (!dongle_caps->is_dp_hdmi_ycbcr422_pass_through)
1912 case PIXEL_ENCODING_YCBCR420:
1913 if (!dongle_caps->is_dp_hdmi_ycbcr420_pass_through)
1917 /* Invalid Pixel Encoding*/
1922 /* Check Color Depth and Pixel Clock */
1923 if (timing->pixel_encoding == PIXEL_ENCODING_YCBCR420)
1924 required_pix_clk /= 2;
1925 else if (timing->pixel_encoding == PIXEL_ENCODING_YCBCR422)
1926 required_pix_clk = required_pix_clk * 2 / 3;
1928 switch (timing->display_color_depth) {
1929 case COLOR_DEPTH_666:
1930 case COLOR_DEPTH_888:
1931 /*888 and 666 should always be supported*/
1933 case COLOR_DEPTH_101010:
1934 if (dongle_caps->dp_hdmi_max_bpc < 10)
1936 required_pix_clk = required_pix_clk * 10 / 8;
1938 case COLOR_DEPTH_121212:
1939 if (dongle_caps->dp_hdmi_max_bpc < 12)
1941 required_pix_clk = required_pix_clk * 12 / 8;
1944 case COLOR_DEPTH_141414:
1945 case COLOR_DEPTH_161616:
1947 /* These color depths are currently not supported */
1951 if (required_pix_clk > dongle_caps->dp_hdmi_max_pixel_clk)
1957 enum dc_status dc_link_validate_mode_timing(
1958 const struct dc_stream_state *stream,
1959 struct dc_link *link,
1960 const struct dc_crtc_timing *timing)
1962 uint32_t max_pix_clk = stream->sink->dongle_max_pix_clk;
1963 struct dpcd_caps *dpcd_caps = &link->dpcd_caps;
1965 /* A hack to avoid failing any modes for EDID override feature on
1966 * topology change such as lower quality cable for DP or different dongle
1968 if (link->remote_sinks[0])
1971 /* Passive Dongle */
1972 if (0 != max_pix_clk && timing->pix_clk_khz > max_pix_clk)
1973 return DC_EXCEED_DONGLE_CAP;
1976 if (!dp_active_dongle_validate_timing(timing, dpcd_caps))
1977 return DC_EXCEED_DONGLE_CAP;
1979 switch (stream->signal) {
1980 case SIGNAL_TYPE_EDP:
1981 case SIGNAL_TYPE_DISPLAY_PORT:
1982 if (!dp_validate_mode_timing(
1985 return DC_NO_DP_LINK_BANDWIDTH;
1996 bool dc_link_set_backlight_level(const struct dc_link *link, uint32_t level,
1997 uint32_t frame_ramp, const struct dc_stream_state *stream)
1999 struct dc *core_dc = link->ctx->dc;
2000 struct abm *abm = core_dc->res_pool->abm;
2001 struct dmcu *dmcu = core_dc->res_pool->dmcu;
2002 unsigned int controller_id = 0;
2003 bool use_smooth_brightness = true;
2005 DC_LOGGER_INIT(link->ctx->logger);
2007 if ((dmcu == NULL) ||
2009 (abm->funcs->set_backlight_level == NULL))
2013 if (stream->bl_pwm_level == EDP_BACKLIGHT_RAMP_DISABLE_LEVEL)
2016 ((struct dc_stream_state *)stream)->bl_pwm_level = level;
2019 use_smooth_brightness = dmcu->funcs->is_dmcu_initialized(dmcu);
2021 DC_LOG_BACKLIGHT("New Backlight level: %d (0x%X)\n", level, level);
2023 if (dc_is_embedded_signal(link->connector_signal)) {
2024 if (stream != NULL) {
2025 for (i = 0; i < MAX_PIPES; i++) {
2026 if (core_dc->current_state->res_ctx.
2029 /* DMCU -1 for all controller id values,
2033 core_dc->current_state->
2034 res_ctx.pipe_ctx[i].stream_res.tg->inst +
2038 abm->funcs->set_backlight_level(
2043 use_smooth_brightness);
2049 bool dc_link_set_abm_disable(const struct dc_link *link)
2051 struct dc *core_dc = link->ctx->dc;
2052 struct abm *abm = core_dc->res_pool->abm;
2054 if ((abm == NULL) || (abm->funcs->set_backlight_level == NULL))
2057 abm->funcs->set_abm_immediate_disable(abm);
2062 bool dc_link_set_psr_enable(const struct dc_link *link, bool enable, bool wait)
2064 struct dc *core_dc = link->ctx->dc;
2065 struct dmcu *dmcu = core_dc->res_pool->dmcu;
2067 if (dmcu != NULL && link->psr_enabled)
2068 dmcu->funcs->set_psr_enable(dmcu, enable, wait);
2073 const struct dc_link_status *dc_link_get_status(const struct dc_link *link)
2075 return &link->link_status;
2078 void core_link_resume(struct dc_link *link)
2080 if (link->connector_signal != SIGNAL_TYPE_VIRTUAL)
2081 program_hpd_filter(link);
2084 static struct fixed31_32 get_pbn_per_slot(struct dc_stream_state *stream)
2086 struct dc_link_settings *link_settings =
2087 &stream->sink->link->cur_link_settings;
2088 uint32_t link_rate_in_mbps =
2089 link_settings->link_rate * LINK_RATE_REF_FREQ_IN_MHZ;
2090 struct fixed31_32 mbps = dc_fixpt_from_int(
2091 link_rate_in_mbps * link_settings->lane_count);
2093 return dc_fixpt_div_int(mbps, 54);
2096 static int get_color_depth(enum dc_color_depth color_depth)
2098 switch (color_depth) {
2099 case COLOR_DEPTH_666: return 6;
2100 case COLOR_DEPTH_888: return 8;
2101 case COLOR_DEPTH_101010: return 10;
2102 case COLOR_DEPTH_121212: return 12;
2103 case COLOR_DEPTH_141414: return 14;
2104 case COLOR_DEPTH_161616: return 16;
2109 static struct fixed31_32 get_pbn_from_timing(struct pipe_ctx *pipe_ctx)
2113 struct fixed31_32 peak_kbps;
2115 uint32_t denominator;
2117 bpc = get_color_depth(pipe_ctx->stream_res.pix_clk_params.color_depth);
2118 kbps = pipe_ctx->stream_res.pix_clk_params.requested_pix_clk * bpc * 3;
2121 * margin 5300ppm + 300ppm ~ 0.6% as per spec, factor is 1.006
2122 * The unit of 54/64Mbytes/sec is an arbitrary unit chosen based on
2123 * common multiplier to render an integer PBN for all link rate/lane
2124 * counts combinations
2126 * peak_kbps *= (1006/1000)
2127 * peak_kbps *= (64/54)
2128 * peak_kbps *= 8 convert to bytes
2131 numerator = 64 * PEAK_FACTOR_X1000;
2132 denominator = 54 * 8 * 1000 * 1000;
2134 peak_kbps = dc_fixpt_from_fraction(kbps, denominator);
2139 static void update_mst_stream_alloc_table(
2140 struct dc_link *link,
2141 struct stream_encoder *stream_enc,
2142 const struct dp_mst_stream_allocation_table *proposed_table)
2144 struct link_mst_stream_allocation work_table[MAX_CONTROLLER_NUM] = {
2146 struct link_mst_stream_allocation *dc_alloc;
2151 /* if DRM proposed_table has more than one new payload */
2152 ASSERT(proposed_table->stream_count -
2153 link->mst_stream_alloc_table.stream_count < 2);
2155 /* copy proposed_table to link, add stream encoder */
2156 for (i = 0; i < proposed_table->stream_count; i++) {
2158 for (j = 0; j < link->mst_stream_alloc_table.stream_count; j++) {
2160 &link->mst_stream_alloc_table.stream_allocations[j];
2162 if (dc_alloc->vcp_id ==
2163 proposed_table->stream_allocations[i].vcp_id) {
2165 work_table[i] = *dc_alloc;
2166 break; /* exit j loop */
2171 if (j == link->mst_stream_alloc_table.stream_count) {
2172 work_table[i].vcp_id =
2173 proposed_table->stream_allocations[i].vcp_id;
2174 work_table[i].slot_count =
2175 proposed_table->stream_allocations[i].slot_count;
2176 work_table[i].stream_enc = stream_enc;
2180 /* update link->mst_stream_alloc_table with work_table */
2181 link->mst_stream_alloc_table.stream_count =
2182 proposed_table->stream_count;
2183 for (i = 0; i < MAX_CONTROLLER_NUM; i++)
2184 link->mst_stream_alloc_table.stream_allocations[i] =
2188 /* convert link_mst_stream_alloc_table to dm dp_mst_stream_alloc_table
2189 * because stream_encoder is not exposed to dm
2191 static enum dc_status allocate_mst_payload(struct pipe_ctx *pipe_ctx)
2193 struct dc_stream_state *stream = pipe_ctx->stream;
2194 struct dc_link *link = stream->sink->link;
2195 struct link_encoder *link_encoder = link->link_enc;
2196 struct stream_encoder *stream_encoder = pipe_ctx->stream_res.stream_enc;
2197 struct dp_mst_stream_allocation_table proposed_table = {0};
2198 struct fixed31_32 avg_time_slots_per_mtp;
2199 struct fixed31_32 pbn;
2200 struct fixed31_32 pbn_per_slot;
2202 DC_LOGGER_INIT(link->ctx->logger);
2204 /* enable_link_dp_mst already check link->enabled_stream_count
2205 * and stream is in link->stream[]. This is called during set mode,
2206 * stream_enc is available.
2209 /* get calculate VC payload for stream: stream_alloc */
2210 if (dm_helpers_dp_mst_write_payload_allocation_table(
2215 update_mst_stream_alloc_table(
2216 link, pipe_ctx->stream_res.stream_enc, &proposed_table);
2219 DC_LOG_WARNING("Failed to update"
2220 "MST allocation table for"
2222 pipe_ctx->pipe_idx);
2225 "stream_count: %d: \n ",
2227 link->mst_stream_alloc_table.stream_count);
2229 for (i = 0; i < MAX_CONTROLLER_NUM; i++) {
2230 DC_LOG_MST("stream_enc[%d]: %p "
2231 "stream[%d].vcp_id: %d "
2232 "stream[%d].slot_count: %d\n",
2234 (void *) link->mst_stream_alloc_table.stream_allocations[i].stream_enc,
2236 link->mst_stream_alloc_table.stream_allocations[i].vcp_id,
2238 link->mst_stream_alloc_table.stream_allocations[i].slot_count);
2241 ASSERT(proposed_table.stream_count > 0);
2243 /* program DP source TX for payload */
2244 link_encoder->funcs->update_mst_stream_allocation_table(
2246 &link->mst_stream_alloc_table);
2248 /* send down message */
2249 dm_helpers_dp_mst_poll_for_allocation_change_trigger(
2253 dm_helpers_dp_mst_send_payload_allocation(
2258 /* slot X.Y for only current stream */
2259 pbn_per_slot = get_pbn_per_slot(stream);
2260 pbn = get_pbn_from_timing(pipe_ctx);
2261 avg_time_slots_per_mtp = dc_fixpt_div(pbn, pbn_per_slot);
2263 stream_encoder->funcs->set_mst_bandwidth(
2265 avg_time_slots_per_mtp);
2271 static enum dc_status deallocate_mst_payload(struct pipe_ctx *pipe_ctx)
2273 struct dc_stream_state *stream = pipe_ctx->stream;
2274 struct dc_link *link = stream->sink->link;
2275 struct link_encoder *link_encoder = link->link_enc;
2276 struct stream_encoder *stream_encoder = pipe_ctx->stream_res.stream_enc;
2277 struct dp_mst_stream_allocation_table proposed_table = {0};
2278 struct fixed31_32 avg_time_slots_per_mtp = dc_fixpt_from_int(0);
2280 bool mst_mode = (link->type == dc_connection_mst_branch);
2281 DC_LOGGER_INIT(link->ctx->logger);
2283 /* deallocate_mst_payload is called before disable link. When mode or
2284 * disable/enable monitor, new stream is created which is not in link
2285 * stream[] yet. For this, payload is not allocated yet, so de-alloc
2286 * should not done. For new mode set, map_resources will get engine
2287 * for new stream, so stream_enc->id should be validated until here.
2291 stream_encoder->funcs->set_mst_bandwidth(
2293 avg_time_slots_per_mtp);
2295 /* TODO: which component is responsible for remove payload table? */
2297 if (dm_helpers_dp_mst_write_payload_allocation_table(
2303 update_mst_stream_alloc_table(
2304 link, pipe_ctx->stream_res.stream_enc, &proposed_table);
2307 DC_LOG_WARNING("Failed to update"
2308 "MST allocation table for"
2310 pipe_ctx->pipe_idx);
2315 "stream_count: %d: ",
2317 link->mst_stream_alloc_table.stream_count);
2319 for (i = 0; i < MAX_CONTROLLER_NUM; i++) {
2320 DC_LOG_MST("stream_enc[%d]: %p "
2321 "stream[%d].vcp_id: %d "
2322 "stream[%d].slot_count: %d\n",
2324 (void *) link->mst_stream_alloc_table.stream_allocations[i].stream_enc,
2326 link->mst_stream_alloc_table.stream_allocations[i].vcp_id,
2328 link->mst_stream_alloc_table.stream_allocations[i].slot_count);
2331 link_encoder->funcs->update_mst_stream_allocation_table(
2333 &link->mst_stream_alloc_table);
2336 dm_helpers_dp_mst_poll_for_allocation_change_trigger(
2340 dm_helpers_dp_mst_send_payload_allocation(
2349 void core_link_enable_stream(
2350 struct dc_state *state,
2351 struct pipe_ctx *pipe_ctx)
2353 struct dc *core_dc = pipe_ctx->stream->ctx->dc;
2354 enum dc_status status;
2355 DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger);
2357 /* eDP lit up by bios already, no need to enable again. */
2358 if (pipe_ctx->stream->signal == SIGNAL_TYPE_EDP &&
2359 core_dc->apply_edp_fast_boot_optimization) {
2360 core_dc->apply_edp_fast_boot_optimization = false;
2361 pipe_ctx->stream->dpms_off = false;
2365 if (pipe_ctx->stream->dpms_off)
2368 status = enable_link(state, pipe_ctx);
2370 if (status != DC_OK) {
2371 DC_LOG_WARNING("enabling link %u failed: %d\n",
2372 pipe_ctx->stream->sink->link->link_index,
2375 /* Abort stream enable *unless* the failure was due to
2376 * DP link training - some DP monitors will recover and
2377 * show the stream anyway. But MST displays can't proceed
2378 * without link training.
2380 if (status != DC_FAIL_DP_LINK_TRAINING ||
2381 pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
2382 BREAK_TO_DEBUGGER();
2387 core_dc->hwss.enable_audio_stream(pipe_ctx);
2389 /* turn off otg test pattern if enable */
2390 if (pipe_ctx->stream_res.tg->funcs->set_test_pattern)
2391 pipe_ctx->stream_res.tg->funcs->set_test_pattern(pipe_ctx->stream_res.tg,
2392 CONTROLLER_DP_TEST_PATTERN_VIDEOMODE,
2393 COLOR_DEPTH_UNDEFINED);
2395 core_dc->hwss.enable_stream(pipe_ctx);
2397 if (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
2398 allocate_mst_payload(pipe_ctx);
2400 core_dc->hwss.unblank_stream(pipe_ctx,
2401 &pipe_ctx->stream->sink->link->cur_link_settings);
2404 void core_link_disable_stream(struct pipe_ctx *pipe_ctx, int option)
2406 struct dc *core_dc = pipe_ctx->stream->ctx->dc;
2408 if (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
2409 deallocate_mst_payload(pipe_ctx);
2411 core_dc->hwss.blank_stream(pipe_ctx);
2413 core_dc->hwss.disable_stream(pipe_ctx, option);
2415 disable_link(pipe_ctx->stream->sink->link, pipe_ctx->stream->signal);
2418 void core_link_set_avmute(struct pipe_ctx *pipe_ctx, bool enable)
2420 struct dc *core_dc = pipe_ctx->stream->ctx->dc;
2422 if (pipe_ctx->stream->signal != SIGNAL_TYPE_HDMI_TYPE_A)
2425 core_dc->hwss.set_avmute(pipe_ctx, enable);
2429 *****************************************************************************
2430 * Function: dc_link_enable_hpd_filter
2433 * If enable is true, programs HPD filter on associated HPD line using
2434 * delay_on_disconnect/delay_on_connect values dependent on
2435 * link->connector_signal
2437 * If enable is false, programs HPD filter on associated HPD line with no
2438 * delays on connect or disconnect
2440 * @param [in] link: pointer to the dc link
2441 * @param [in] enable: boolean specifying whether to enable hbd
2442 *****************************************************************************
2444 void dc_link_enable_hpd_filter(struct dc_link *link, bool enable)
2449 link->is_hpd_filter_disabled = false;
2450 program_hpd_filter(link);
2452 link->is_hpd_filter_disabled = true;
2453 /* Obtain HPD handle */
2454 hpd = get_hpd_gpio(link->ctx->dc_bios, link->link_id, link->ctx->gpio_service);
2459 /* Setup HPD filtering */
2460 if (dal_gpio_open(hpd, GPIO_MODE_INTERRUPT) == GPIO_RESULT_OK) {
2461 struct gpio_hpd_config config;
2463 config.delay_on_connect = 0;
2464 config.delay_on_disconnect = 0;
2466 dal_irq_setup_hpd_filter(hpd, &config);
2468 dal_gpio_close(hpd);
2470 ASSERT_CRITICAL(false);
2472 /* Release HPD handle */
2473 dal_gpio_destroy_irq(&hpd);