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 bool dc_link_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 (!dm_helpers_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 dm_helpers_dp_update_branch_info(
536 if (!dm_helpers_dp_mst_start_top_mgr(
539 /* MST not supported */
540 link->type = dc_connection_single;
541 sink_caps->signal = SIGNAL_TYPE_DISPLAY_PORT;
545 if (link->type != dc_connection_mst_branch &&
546 is_dp_active_dongle(link)) {
547 /* DP active dongles */
548 link->type = dc_connection_active_dongle;
549 if (!link->dpcd_caps.sink_count.bits.SINK_COUNT) {
551 * active dongle unplug processing for short irq
553 link_disconnect_sink(link);
557 if (link->dpcd_caps.dongle_type != DISPLAY_DONGLE_DP_HDMI_CONVERTER)
558 *converter_disable_audio = true;
561 /* DP passive dongles */
562 sink_caps->signal = dp_passive_dongle_detection(link->ddc,
570 static bool is_same_edid(struct dc_edid *old_edid, struct dc_edid *new_edid)
572 if (old_edid->length != new_edid->length)
575 if (new_edid->length == 0)
578 return (memcmp(old_edid->raw_edid, new_edid->raw_edid, new_edid->length) == 0);
581 bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason)
583 struct dc_sink_init_data sink_init_data = { 0 };
584 struct display_sink_capability sink_caps = { 0 };
586 bool converter_disable_audio = false;
587 struct audio_support *aud_support = &link->dc->res_pool->audio_support;
588 bool same_edid = false;
589 enum dc_edid_status edid_status;
590 struct dc_context *dc_ctx = link->ctx;
591 struct dc_sink *sink = NULL;
592 struct dc_sink *prev_sink = NULL;
593 struct dpcd_caps prev_dpcd_caps;
594 bool same_dpcd = true;
595 enum dc_connection_type new_connection_type = dc_connection_none;
596 DC_LOGGER_INIT(link->ctx->logger);
597 if (link->connector_signal == SIGNAL_TYPE_VIRTUAL)
600 if (false == detect_sink(link, &new_connection_type)) {
605 if (link->connector_signal == SIGNAL_TYPE_EDP &&
609 prev_sink = link->local_sink;
610 if (prev_sink != NULL) {
611 dc_sink_retain(prev_sink);
612 memcpy(&prev_dpcd_caps, &link->dpcd_caps, sizeof(struct dpcd_caps));
614 link_disconnect_sink(link);
616 if (new_connection_type != dc_connection_none) {
617 link->type = new_connection_type;
619 /* From Disconnected-to-Connected. */
620 switch (link->connector_signal) {
621 case SIGNAL_TYPE_HDMI_TYPE_A: {
622 sink_caps.transaction_type = DDC_TRANSACTION_TYPE_I2C;
623 if (aud_support->hdmi_audio_native)
624 sink_caps.signal = SIGNAL_TYPE_HDMI_TYPE_A;
626 sink_caps.signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
630 case SIGNAL_TYPE_DVI_SINGLE_LINK: {
631 sink_caps.transaction_type = DDC_TRANSACTION_TYPE_I2C;
632 sink_caps.signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
636 case SIGNAL_TYPE_DVI_DUAL_LINK: {
637 sink_caps.transaction_type = DDC_TRANSACTION_TYPE_I2C;
638 sink_caps.signal = SIGNAL_TYPE_DVI_DUAL_LINK;
642 case SIGNAL_TYPE_EDP: {
643 detect_edp_sink_caps(link);
644 sink_caps.transaction_type =
645 DDC_TRANSACTION_TYPE_I2C_OVER_AUX;
646 sink_caps.signal = SIGNAL_TYPE_EDP;
650 case SIGNAL_TYPE_DISPLAY_PORT: {
654 &converter_disable_audio,
655 aud_support, reason)) {
656 if (prev_sink != NULL)
657 dc_sink_release(prev_sink);
661 // Check if dpcp block is the same
662 if (prev_sink != NULL) {
663 if (memcmp(&link->dpcd_caps, &prev_dpcd_caps, sizeof(struct dpcd_caps)))
666 /* Active dongle downstream unplug */
667 if (link->type == dc_connection_active_dongle
668 && link->dpcd_caps.sink_count.
669 bits.SINK_COUNT == 0) {
670 if (prev_sink != NULL)
671 dc_sink_release(prev_sink);
675 if (link->type == dc_connection_mst_branch) {
676 LINK_INFO("link=%d, mst branch is now Connected\n",
678 /* Need to setup mst link_cap struct here
679 * otherwise dc_link_detect() will leave mst link_cap
680 * empty which leads to allocate_mst_payload() has "0"
681 * pbn_per_slot value leading to exception on dc_fixpt_div()
683 link->verified_link_cap = link->reported_link_cap;
684 if (prev_sink != NULL)
685 dc_sink_release(prev_sink);
693 DC_ERROR("Invalid connector type! signal:%d\n",
694 link->connector_signal);
695 if (prev_sink != NULL)
696 dc_sink_release(prev_sink);
700 if (link->dpcd_caps.sink_count.bits.SINK_COUNT)
701 link->dpcd_sink_count = link->dpcd_caps.sink_count.
704 link->dpcd_sink_count = 1;
706 dal_ddc_service_set_transaction_type(
708 sink_caps.transaction_type);
710 link->aux_mode = dal_ddc_service_is_in_aux_transaction_mode(
713 sink_init_data.link = link;
714 sink_init_data.sink_signal = sink_caps.signal;
716 sink = dc_sink_create(&sink_init_data);
718 DC_ERROR("Failed to create sink!\n");
719 if (prev_sink != NULL)
720 dc_sink_release(prev_sink);
724 sink->dongle_max_pix_clk = sink_caps.max_hdmi_pixel_clock;
725 sink->converter_disable_audio = converter_disable_audio;
727 link->local_sink = sink;
729 edid_status = dm_helpers_read_local_edid(
734 switch (edid_status) {
735 case EDID_BAD_CHECKSUM:
736 DC_LOG_ERROR("EDID checksum invalid.\n");
738 case EDID_NO_RESPONSE:
739 DC_LOG_ERROR("No EDID read.\n");
744 // Check if edid is the same
745 if ((prev_sink != NULL) && ((edid_status == EDID_THE_SAME) || (edid_status == EDID_OK)))
746 same_edid = is_same_edid(&prev_sink->dc_edid, &sink->dc_edid);
748 // If both edid and dpcd are the same, then discard new sink and revert back to original sink
749 if ((same_edid) && (same_dpcd)) {
750 link_disconnect_remap(prev_sink, link);
754 if (link->connector_signal == SIGNAL_TYPE_DISPLAY_PORT &&
755 sink_caps.transaction_type ==
756 DDC_TRANSACTION_TYPE_I2C_OVER_AUX) {
758 * TODO debug why Dell 2413 doesn't like
762 /* deal with non-mst cases */
763 dp_hbr_verify_link_cap(link, &link->reported_link_cap);
766 /* HDMI-DVI Dongle */
767 if (sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A &&
768 !sink->edid_caps.edid_hdmi)
769 sink->sink_signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
772 /* Connectivity log: detection */
773 for (i = 0; i < sink->dc_edid.length / EDID_BLOCK_SIZE; i++) {
774 CONN_DATA_DETECT(link,
775 &sink->dc_edid.raw_edid[i * EDID_BLOCK_SIZE],
777 "%s: [Block %d] ", sink->edid_caps.display_name, i);
780 DC_LOG_DETECTION_EDID_PARSER("%s: "
781 "manufacturer_id = %X, "
783 "serial_number = %X, "
784 "manufacture_week = %d, "
785 "manufacture_year = %d, "
786 "display_name = %s, "
787 "speaker_flag = %d, "
788 "audio_mode_count = %d\n",
790 sink->edid_caps.manufacturer_id,
791 sink->edid_caps.product_id,
792 sink->edid_caps.serial_number,
793 sink->edid_caps.manufacture_week,
794 sink->edid_caps.manufacture_year,
795 sink->edid_caps.display_name,
796 sink->edid_caps.speaker_flags,
797 sink->edid_caps.audio_mode_count);
799 for (i = 0; i < sink->edid_caps.audio_mode_count; i++) {
800 DC_LOG_DETECTION_EDID_PARSER("%s: mode number = %d, "
802 "channel_count = %d, "
804 "sample_size = %d\n",
807 sink->edid_caps.audio_modes[i].format_code,
808 sink->edid_caps.audio_modes[i].channel_count,
809 sink->edid_caps.audio_modes[i].sample_rate,
810 sink->edid_caps.audio_modes[i].sample_size);
814 /* From Connected-to-Disconnected. */
815 if (link->type == dc_connection_mst_branch) {
816 LINK_INFO("link=%d, mst branch is now Disconnected\n",
819 dm_helpers_dp_mst_stop_top_mgr(link->ctx, link);
821 link->mst_stream_alloc_table.stream_count = 0;
822 memset(link->mst_stream_alloc_table.stream_allocations, 0, sizeof(link->mst_stream_alloc_table.stream_allocations));
825 link->type = dc_connection_none;
826 sink_caps.signal = SIGNAL_TYPE_NONE;
829 LINK_INFO("link=%d, dc_sink_in=%p is now %s prev_sink=%p dpcd same=%d edid same=%d\n",
830 link->link_index, sink,
831 (sink_caps.signal == SIGNAL_TYPE_NONE ?
832 "Disconnected":"Connected"), prev_sink,
833 same_dpcd, same_edid);
835 if (prev_sink != NULL)
836 dc_sink_release(prev_sink);
841 static enum hpd_source_id get_hpd_line(
842 struct dc_link *link)
845 enum hpd_source_id hpd_id = HPD_SOURCEID_UNKNOWN;
847 hpd = get_hpd_gpio(link->ctx->dc_bios, link->link_id, link->ctx->gpio_service);
850 switch (dal_irq_get_source(hpd)) {
851 case DC_IRQ_SOURCE_HPD1:
852 hpd_id = HPD_SOURCEID1;
854 case DC_IRQ_SOURCE_HPD2:
855 hpd_id = HPD_SOURCEID2;
857 case DC_IRQ_SOURCE_HPD3:
858 hpd_id = HPD_SOURCEID3;
860 case DC_IRQ_SOURCE_HPD4:
861 hpd_id = HPD_SOURCEID4;
863 case DC_IRQ_SOURCE_HPD5:
864 hpd_id = HPD_SOURCEID5;
866 case DC_IRQ_SOURCE_HPD6:
867 hpd_id = HPD_SOURCEID6;
874 dal_gpio_destroy_irq(&hpd);
880 static enum channel_id get_ddc_line(struct dc_link *link)
883 enum channel_id channel = CHANNEL_ID_UNKNOWN;
885 ddc = dal_ddc_service_get_ddc_pin(link->ddc);
888 switch (dal_ddc_get_line(ddc)) {
889 case GPIO_DDC_LINE_DDC1:
890 channel = CHANNEL_ID_DDC1;
892 case GPIO_DDC_LINE_DDC2:
893 channel = CHANNEL_ID_DDC2;
895 case GPIO_DDC_LINE_DDC3:
896 channel = CHANNEL_ID_DDC3;
898 case GPIO_DDC_LINE_DDC4:
899 channel = CHANNEL_ID_DDC4;
901 case GPIO_DDC_LINE_DDC5:
902 channel = CHANNEL_ID_DDC5;
904 case GPIO_DDC_LINE_DDC6:
905 channel = CHANNEL_ID_DDC6;
907 case GPIO_DDC_LINE_DDC_VGA:
908 channel = CHANNEL_ID_DDC_VGA;
910 case GPIO_DDC_LINE_I2C_PAD:
911 channel = CHANNEL_ID_I2C_PAD;
922 static enum transmitter translate_encoder_to_transmitter(
923 struct graphics_object_id encoder)
925 switch (encoder.id) {
926 case ENCODER_ID_INTERNAL_UNIPHY:
927 switch (encoder.enum_id) {
929 return TRANSMITTER_UNIPHY_A;
931 return TRANSMITTER_UNIPHY_B;
933 return TRANSMITTER_UNKNOWN;
936 case ENCODER_ID_INTERNAL_UNIPHY1:
937 switch (encoder.enum_id) {
939 return TRANSMITTER_UNIPHY_C;
941 return TRANSMITTER_UNIPHY_D;
943 return TRANSMITTER_UNKNOWN;
946 case ENCODER_ID_INTERNAL_UNIPHY2:
947 switch (encoder.enum_id) {
949 return TRANSMITTER_UNIPHY_E;
951 return TRANSMITTER_UNIPHY_F;
953 return TRANSMITTER_UNKNOWN;
956 case ENCODER_ID_INTERNAL_UNIPHY3:
957 switch (encoder.enum_id) {
959 return TRANSMITTER_UNIPHY_G;
961 return TRANSMITTER_UNKNOWN;
964 case ENCODER_ID_EXTERNAL_NUTMEG:
965 switch (encoder.enum_id) {
967 return TRANSMITTER_NUTMEG_CRT;
969 return TRANSMITTER_UNKNOWN;
972 case ENCODER_ID_EXTERNAL_TRAVIS:
973 switch (encoder.enum_id) {
975 return TRANSMITTER_TRAVIS_CRT;
977 return TRANSMITTER_TRAVIS_LCD;
979 return TRANSMITTER_UNKNOWN;
983 return TRANSMITTER_UNKNOWN;
987 static bool construct(
988 struct dc_link *link,
989 const struct link_init_data *init_params)
992 struct gpio *hpd_gpio = NULL;
993 struct ddc_service_init_data ddc_service_init_data = { { 0 } };
994 struct dc_context *dc_ctx = init_params->ctx;
995 struct encoder_init_data enc_init_data = { 0 };
996 struct integrated_info info = {{{ 0 }}};
997 struct dc_bios *bios = init_params->dc->ctx->dc_bios;
998 const struct dc_vbios_funcs *bp_funcs = bios->funcs;
999 DC_LOGGER_INIT(dc_ctx->logger);
1001 link->irq_source_hpd = DC_IRQ_SOURCE_INVALID;
1002 link->irq_source_hpd_rx = DC_IRQ_SOURCE_INVALID;
1004 link->link_status.dpcd_caps = &link->dpcd_caps;
1006 link->dc = init_params->dc;
1008 link->link_index = init_params->link_index;
1010 link->link_id = bios->funcs->get_connector_id(bios, init_params->connector_index);
1012 if (link->link_id.type != OBJECT_TYPE_CONNECTOR) {
1013 dm_error("%s: Invalid Connector ObjectID from Adapter Service for connector index:%d! type %d expected %d\n",
1014 __func__, init_params->connector_index,
1015 link->link_id.type, OBJECT_TYPE_CONNECTOR);
1019 hpd_gpio = get_hpd_gpio(link->ctx->dc_bios, link->link_id, link->ctx->gpio_service);
1021 if (hpd_gpio != NULL)
1022 link->irq_source_hpd = dal_irq_get_source(hpd_gpio);
1024 switch (link->link_id.id) {
1025 case CONNECTOR_ID_HDMI_TYPE_A:
1026 link->connector_signal = SIGNAL_TYPE_HDMI_TYPE_A;
1029 case CONNECTOR_ID_SINGLE_LINK_DVID:
1030 case CONNECTOR_ID_SINGLE_LINK_DVII:
1031 link->connector_signal = SIGNAL_TYPE_DVI_SINGLE_LINK;
1033 case CONNECTOR_ID_DUAL_LINK_DVID:
1034 case CONNECTOR_ID_DUAL_LINK_DVII:
1035 link->connector_signal = SIGNAL_TYPE_DVI_DUAL_LINK;
1037 case CONNECTOR_ID_DISPLAY_PORT:
1038 link->connector_signal = SIGNAL_TYPE_DISPLAY_PORT;
1040 if (hpd_gpio != NULL)
1041 link->irq_source_hpd_rx =
1042 dal_irq_get_rx_source(hpd_gpio);
1045 case CONNECTOR_ID_EDP:
1046 link->connector_signal = SIGNAL_TYPE_EDP;
1048 if (hpd_gpio != NULL) {
1049 link->irq_source_hpd = DC_IRQ_SOURCE_INVALID;
1050 link->irq_source_hpd_rx =
1051 dal_irq_get_rx_source(hpd_gpio);
1055 DC_LOG_WARNING("Unsupported Connector type:%d!\n", link->link_id.id);
1059 if (hpd_gpio != NULL) {
1060 dal_gpio_destroy_irq(&hpd_gpio);
1064 /* TODO: #DAL3 Implement id to str function.*/
1065 LINK_INFO("Connector[%d] description:"
1067 init_params->connector_index,
1068 link->connector_signal);
1070 ddc_service_init_data.ctx = link->ctx;
1071 ddc_service_init_data.id = link->link_id;
1072 ddc_service_init_data.link = link;
1073 link->ddc = dal_ddc_service_create(&ddc_service_init_data);
1075 if (link->ddc == NULL) {
1076 DC_ERROR("Failed to create ddc_service!\n");
1077 goto ddc_create_fail;
1082 dal_ddc_service_get_ddc_pin(link->ddc));
1084 enc_init_data.ctx = dc_ctx;
1085 bp_funcs->get_src_obj(dc_ctx->dc_bios, link->link_id, 0, &enc_init_data.encoder);
1086 enc_init_data.connector = link->link_id;
1087 enc_init_data.channel = get_ddc_line(link);
1088 enc_init_data.hpd_source = get_hpd_line(link);
1090 link->hpd_src = enc_init_data.hpd_source;
1092 enc_init_data.transmitter =
1093 translate_encoder_to_transmitter(enc_init_data.encoder);
1094 link->link_enc = link->dc->res_pool->funcs->link_enc_create(
1097 if( link->link_enc == NULL) {
1098 DC_ERROR("Failed to create link encoder!\n");
1099 goto link_enc_create_fail;
1102 link->link_enc_hw_inst = link->link_enc->transmitter;
1104 for (i = 0; i < 4; i++) {
1106 bp_funcs->get_device_tag(dc_ctx->dc_bios, link->link_id, i, &link->device_tag)) {
1107 DC_ERROR("Failed to find device tag!\n");
1108 goto device_tag_fail;
1111 /* Look for device tag that matches connector signal,
1112 * CRT for rgb, LCD for other supported signal tyes
1114 if (!bp_funcs->is_device_id_supported(dc_ctx->dc_bios, link->device_tag.dev_id))
1116 if (link->device_tag.dev_id.device_type == DEVICE_TYPE_CRT
1117 && link->connector_signal != SIGNAL_TYPE_RGB)
1119 if (link->device_tag.dev_id.device_type == DEVICE_TYPE_LCD
1120 && link->connector_signal == SIGNAL_TYPE_RGB)
1125 if (bios->integrated_info)
1126 info = *bios->integrated_info;
1128 /* Look for channel mapping corresponding to connector and device tag */
1129 for (i = 0; i < MAX_NUMBER_OF_EXT_DISPLAY_PATH; i++) {
1130 struct external_display_path *path =
1131 &info.ext_disp_conn_info.path[i];
1132 if (path->device_connector_id.enum_id == link->link_id.enum_id
1133 && path->device_connector_id.id == link->link_id.id
1134 && path->device_connector_id.type == link->link_id.type) {
1136 if (link->device_tag.acpi_device != 0
1137 && path->device_acpi_enum == link->device_tag.acpi_device) {
1138 link->ddi_channel_mapping = path->channel_mapping;
1139 link->chip_caps = path->caps;
1140 } else if (path->device_tag ==
1141 link->device_tag.dev_id.raw_device_tag) {
1142 link->ddi_channel_mapping = path->channel_mapping;
1143 link->chip_caps = path->caps;
1150 * TODO check if GPIO programmed correctly
1152 * If GPIO isn't programmed correctly HPD might not rise or drain
1153 * fast enough, leading to bounces.
1155 program_hpd_filter(link);
1159 link->link_enc->funcs->destroy(&link->link_enc);
1160 link_enc_create_fail:
1161 dal_ddc_service_destroy(&link->ddc);
1165 if (hpd_gpio != NULL) {
1166 dal_gpio_destroy_irq(&hpd_gpio);
1172 /*******************************************************************************
1174 ******************************************************************************/
1175 struct dc_link *link_create(const struct link_init_data *init_params)
1177 struct dc_link *link =
1178 kzalloc(sizeof(*link), GFP_KERNEL);
1183 if (false == construct(link, init_params))
1184 goto construct_fail;
1195 void link_destroy(struct dc_link **link)
1202 static void dpcd_configure_panel_mode(
1203 struct dc_link *link,
1204 enum dp_panel_mode panel_mode)
1206 union dpcd_edp_config edp_config_set;
1207 bool panel_mode_edp = false;
1208 DC_LOGGER_INIT(link->ctx->logger);
1210 memset(&edp_config_set, '\0', sizeof(union dpcd_edp_config));
1212 if (DP_PANEL_MODE_DEFAULT != panel_mode) {
1214 switch (panel_mode) {
1215 case DP_PANEL_MODE_EDP:
1216 case DP_PANEL_MODE_SPECIAL:
1217 panel_mode_edp = true;
1224 /*set edp panel mode in receiver*/
1225 core_link_read_dpcd(
1227 DP_EDP_CONFIGURATION_SET,
1228 &edp_config_set.raw,
1229 sizeof(edp_config_set.raw));
1231 if (edp_config_set.bits.PANEL_MODE_EDP
1232 != panel_mode_edp) {
1233 enum ddc_result result = DDC_RESULT_UNKNOWN;
1235 edp_config_set.bits.PANEL_MODE_EDP =
1237 result = core_link_write_dpcd(
1239 DP_EDP_CONFIGURATION_SET,
1240 &edp_config_set.raw,
1241 sizeof(edp_config_set.raw));
1243 ASSERT(result == DDC_RESULT_SUCESSFULL);
1246 DC_LOG_DETECTION_DP_CAPS("Link: %d eDP panel mode supported: %d "
1247 "eDP panel mode enabled: %d \n",
1249 link->dpcd_caps.panel_mode_edp,
1253 static void enable_stream_features(struct pipe_ctx *pipe_ctx)
1255 struct dc_stream_state *stream = pipe_ctx->stream;
1256 struct dc_link *link = stream->sink->link;
1257 union down_spread_ctrl old_downspread;
1258 union down_spread_ctrl new_downspread;
1260 core_link_read_dpcd(link, DP_DOWNSPREAD_CTRL,
1261 &old_downspread.raw, sizeof(old_downspread));
1263 new_downspread.raw = old_downspread.raw;
1265 new_downspread.bits.IGNORE_MSA_TIMING_PARAM =
1266 (stream->ignore_msa_timing_param) ? 1 : 0;
1268 if (new_downspread.raw != old_downspread.raw) {
1269 core_link_write_dpcd(link, DP_DOWNSPREAD_CTRL,
1270 &new_downspread.raw, sizeof(new_downspread));
1274 static enum dc_status enable_link_dp(
1275 struct dc_state *state,
1276 struct pipe_ctx *pipe_ctx)
1278 struct dc_stream_state *stream = pipe_ctx->stream;
1279 enum dc_status status;
1280 bool skip_video_pattern;
1281 struct dc_link *link = stream->sink->link;
1282 struct dc_link_settings link_settings = {0};
1283 enum dp_panel_mode panel_mode;
1284 enum dc_link_rate max_link_rate = LINK_RATE_HIGH2;
1286 /* get link settings for video mode timing */
1287 decide_link_settings(stream, &link_settings);
1289 /* raise clock state for HBR3 if required. Confirmed with HW DCE/DPCS
1290 * logic for HBR3 still needs Nominal (0.8V) on VDDC rail
1292 if (link->link_enc->features.flags.bits.IS_HBR3_CAPABLE)
1293 max_link_rate = LINK_RATE_HIGH3;
1295 if (link_settings.link_rate == max_link_rate) {
1296 struct dc_clocks clocks = state->bw.dcn.clk;
1298 /* dce/dcn compat, do not update dispclk */
1299 clocks.dispclk_khz = 0;
1300 /* 27mhz = 27000000hz= 27000khz */
1301 clocks.phyclk_khz = link_settings.link_rate * 27000;
1303 state->dis_clk->funcs->update_clocks(
1304 state->dis_clk, &clocks, false);
1309 pipe_ctx->stream->signal,
1310 pipe_ctx->clock_source->id,
1313 if (stream->sink->edid_caps.panel_patch.dppowerup_delay > 0) {
1314 int delay_dp_power_up_in_ms = stream->sink->edid_caps.panel_patch.dppowerup_delay;
1316 msleep(delay_dp_power_up_in_ms);
1319 panel_mode = dp_get_panel_mode(link);
1320 dpcd_configure_panel_mode(link, panel_mode);
1322 skip_video_pattern = true;
1324 if (link_settings.link_rate == LINK_RATE_LOW)
1325 skip_video_pattern = false;
1327 if (perform_link_training_with_retries(
1331 LINK_TRAINING_ATTEMPTS)) {
1332 link->cur_link_settings = link_settings;
1336 status = DC_FAIL_DP_LINK_TRAINING;
1338 enable_stream_features(pipe_ctx);
1343 static enum dc_status enable_link_edp(
1344 struct dc_state *state,
1345 struct pipe_ctx *pipe_ctx)
1347 enum dc_status status;
1348 struct dc_stream_state *stream = pipe_ctx->stream;
1349 struct dc_link *link = stream->sink->link;
1350 /*in case it is not on*/
1351 link->dc->hwss.edp_power_control(link, true);
1352 link->dc->hwss.edp_wait_for_hpd_ready(link, true);
1354 status = enable_link_dp(state, pipe_ctx);
1360 static enum dc_status enable_link_dp_mst(
1361 struct dc_state *state,
1362 struct pipe_ctx *pipe_ctx)
1364 struct dc_link *link = pipe_ctx->stream->sink->link;
1366 /* sink signal type after MST branch is MST. Multiple MST sinks
1367 * share one link. Link DP PHY is enable or training only once.
1369 if (link->cur_link_settings.lane_count != LANE_COUNT_UNKNOWN)
1372 /* clear payload table */
1373 dm_helpers_dp_mst_clear_payload_allocation_table(link->ctx, link);
1375 /* set the sink to MST mode before enabling the link */
1376 dp_enable_mst_on_sink(link, true);
1378 return enable_link_dp(state, pipe_ctx);
1381 static bool get_ext_hdmi_settings(struct pipe_ctx *pipe_ctx,
1382 enum engine_id eng_id,
1383 struct ext_hdmi_settings *settings)
1385 bool result = false;
1387 struct integrated_info *integrated_info =
1388 pipe_ctx->stream->ctx->dc_bios->integrated_info;
1390 if (integrated_info == NULL)
1394 * Get retimer settings from sbios for passing SI eye test for DCE11
1395 * The setting values are varied based on board revision and port id
1396 * Therefore the setting values of each ports is passed by sbios.
1399 // Check if current bios contains ext Hdmi settings
1400 if (integrated_info->gpu_cap_info & 0x20) {
1402 case ENGINE_ID_DIGA:
1403 settings->slv_addr = integrated_info->dp0_ext_hdmi_slv_addr;
1404 settings->reg_num = integrated_info->dp0_ext_hdmi_6g_reg_num;
1405 settings->reg_num_6g = integrated_info->dp0_ext_hdmi_6g_reg_num;
1406 memmove(settings->reg_settings,
1407 integrated_info->dp0_ext_hdmi_reg_settings,
1408 sizeof(integrated_info->dp0_ext_hdmi_reg_settings));
1409 memmove(settings->reg_settings_6g,
1410 integrated_info->dp0_ext_hdmi_6g_reg_settings,
1411 sizeof(integrated_info->dp0_ext_hdmi_6g_reg_settings));
1414 case ENGINE_ID_DIGB:
1415 settings->slv_addr = integrated_info->dp1_ext_hdmi_slv_addr;
1416 settings->reg_num = integrated_info->dp1_ext_hdmi_6g_reg_num;
1417 settings->reg_num_6g = integrated_info->dp1_ext_hdmi_6g_reg_num;
1418 memmove(settings->reg_settings,
1419 integrated_info->dp1_ext_hdmi_reg_settings,
1420 sizeof(integrated_info->dp1_ext_hdmi_reg_settings));
1421 memmove(settings->reg_settings_6g,
1422 integrated_info->dp1_ext_hdmi_6g_reg_settings,
1423 sizeof(integrated_info->dp1_ext_hdmi_6g_reg_settings));
1426 case ENGINE_ID_DIGC:
1427 settings->slv_addr = integrated_info->dp2_ext_hdmi_slv_addr;
1428 settings->reg_num = integrated_info->dp2_ext_hdmi_6g_reg_num;
1429 settings->reg_num_6g = integrated_info->dp2_ext_hdmi_6g_reg_num;
1430 memmove(settings->reg_settings,
1431 integrated_info->dp2_ext_hdmi_reg_settings,
1432 sizeof(integrated_info->dp2_ext_hdmi_reg_settings));
1433 memmove(settings->reg_settings_6g,
1434 integrated_info->dp2_ext_hdmi_6g_reg_settings,
1435 sizeof(integrated_info->dp2_ext_hdmi_6g_reg_settings));
1438 case ENGINE_ID_DIGD:
1439 settings->slv_addr = integrated_info->dp3_ext_hdmi_slv_addr;
1440 settings->reg_num = integrated_info->dp3_ext_hdmi_6g_reg_num;
1441 settings->reg_num_6g = integrated_info->dp3_ext_hdmi_6g_reg_num;
1442 memmove(settings->reg_settings,
1443 integrated_info->dp3_ext_hdmi_reg_settings,
1444 sizeof(integrated_info->dp3_ext_hdmi_reg_settings));
1445 memmove(settings->reg_settings_6g,
1446 integrated_info->dp3_ext_hdmi_6g_reg_settings,
1447 sizeof(integrated_info->dp3_ext_hdmi_6g_reg_settings));
1454 if (result == true) {
1455 // Validate settings from bios integrated info table
1456 if (settings->slv_addr == 0)
1458 if (settings->reg_num > 9)
1460 if (settings->reg_num_6g > 3)
1463 for (i = 0; i < settings->reg_num; i++) {
1464 if (settings->reg_settings[i].i2c_reg_index > 0x20)
1468 for (i = 0; i < settings->reg_num_6g; i++) {
1469 if (settings->reg_settings_6g[i].i2c_reg_index > 0x20)
1478 static bool i2c_write(struct pipe_ctx *pipe_ctx,
1479 uint8_t address, uint8_t *buffer, uint32_t length)
1481 struct i2c_command cmd = {0};
1482 struct i2c_payload payload = {0};
1484 memset(&payload, 0, sizeof(payload));
1485 memset(&cmd, 0, sizeof(cmd));
1487 cmd.number_of_payloads = 1;
1488 cmd.engine = I2C_COMMAND_ENGINE_DEFAULT;
1489 cmd.speed = pipe_ctx->stream->ctx->dc->caps.i2c_speed_in_khz;
1491 payload.address = address;
1492 payload.data = buffer;
1493 payload.length = length;
1494 payload.write = true;
1495 cmd.payloads = &payload;
1497 if (dc_submit_i2c(pipe_ctx->stream->ctx->dc,
1498 pipe_ctx->stream->sink->link->link_index, &cmd))
1504 static void write_i2c_retimer_setting(
1505 struct pipe_ctx *pipe_ctx,
1507 bool is_over_340mhz,
1508 struct ext_hdmi_settings *settings)
1510 uint8_t slave_address = (settings->slv_addr >> 1);
1512 const uint8_t apply_rx_tx_change = 0x4;
1513 uint8_t offset = 0xA;
1516 bool i2c_success = false;
1518 memset(&buffer, 0, sizeof(buffer));
1520 /* Start Ext-Hdmi programming*/
1522 for (i = 0; i < settings->reg_num; i++) {
1523 /* Apply 3G settings */
1524 if (settings->reg_settings[i].i2c_reg_index <= 0x20) {
1526 buffer[0] = settings->reg_settings[i].i2c_reg_index;
1527 buffer[1] = settings->reg_settings[i].i2c_reg_val;
1528 i2c_success = i2c_write(pipe_ctx, slave_address,
1529 buffer, sizeof(buffer));
1533 ASSERT(i2c_success);
1535 /* Based on DP159 specs, APPLY_RX_TX_CHANGE bit in 0x0A
1536 * needs to be set to 1 on every 0xA-0xC write.
1538 if (settings->reg_settings[i].i2c_reg_index == 0xA ||
1539 settings->reg_settings[i].i2c_reg_index == 0xB ||
1540 settings->reg_settings[i].i2c_reg_index == 0xC) {
1542 /* Query current value from offset 0xA */
1543 if (settings->reg_settings[i].i2c_reg_index == 0xA)
1544 value = settings->reg_settings[i].i2c_reg_val;
1547 dal_ddc_service_query_ddc_data(
1548 pipe_ctx->stream->sink->link->ddc,
1549 slave_address, &offset, 1, &value, 1);
1552 ASSERT(i2c_success);
1556 /* Set APPLY_RX_TX_CHANGE bit to 1 */
1557 buffer[1] = value | apply_rx_tx_change;
1558 i2c_success = i2c_write(pipe_ctx, slave_address,
1559 buffer, sizeof(buffer));
1562 ASSERT(i2c_success);
1567 /* Apply 3G settings */
1568 if (is_over_340mhz) {
1569 for (i = 0; i < settings->reg_num_6g; i++) {
1570 /* Apply 3G settings */
1571 if (settings->reg_settings[i].i2c_reg_index <= 0x20) {
1573 buffer[0] = settings->reg_settings_6g[i].i2c_reg_index;
1574 buffer[1] = settings->reg_settings_6g[i].i2c_reg_val;
1575 i2c_success = i2c_write(pipe_ctx, slave_address,
1576 buffer, sizeof(buffer));
1580 ASSERT(i2c_success);
1582 /* Based on DP159 specs, APPLY_RX_TX_CHANGE bit in 0x0A
1583 * needs to be set to 1 on every 0xA-0xC write.
1585 if (settings->reg_settings_6g[i].i2c_reg_index == 0xA ||
1586 settings->reg_settings_6g[i].i2c_reg_index == 0xB ||
1587 settings->reg_settings_6g[i].i2c_reg_index == 0xC) {
1589 /* Query current value from offset 0xA */
1590 if (settings->reg_settings_6g[i].i2c_reg_index == 0xA)
1591 value = settings->reg_settings_6g[i].i2c_reg_val;
1594 dal_ddc_service_query_ddc_data(
1595 pipe_ctx->stream->sink->link->ddc,
1596 slave_address, &offset, 1, &value, 1);
1599 ASSERT(i2c_success);
1603 /* Set APPLY_RX_TX_CHANGE bit to 1 */
1604 buffer[1] = value | apply_rx_tx_change;
1605 i2c_success = i2c_write(pipe_ctx, slave_address,
1606 buffer, sizeof(buffer));
1609 ASSERT(i2c_success);
1616 /* Program additional settings if using 640x480 resolution */
1618 /* Write offset 0xFF to 0x01 */
1621 i2c_success = i2c_write(pipe_ctx, slave_address,
1622 buffer, sizeof(buffer));
1625 ASSERT(i2c_success);
1627 /* Write offset 0x00 to 0x23 */
1630 i2c_success = i2c_write(pipe_ctx, slave_address,
1631 buffer, sizeof(buffer));
1634 ASSERT(i2c_success);
1636 /* Write offset 0xff to 0x00 */
1639 i2c_success = i2c_write(pipe_ctx, slave_address,
1640 buffer, sizeof(buffer));
1643 ASSERT(i2c_success);
1648 static void write_i2c_default_retimer_setting(
1649 struct pipe_ctx *pipe_ctx,
1651 bool is_over_340mhz)
1653 uint8_t slave_address = (0xBA >> 1);
1655 bool i2c_success = false;
1657 memset(&buffer, 0, sizeof(buffer));
1659 /* Program Slave Address for tuning single integrity */
1660 /* Write offset 0x0A to 0x13 */
1663 i2c_success = i2c_write(pipe_ctx, slave_address,
1664 buffer, sizeof(buffer));
1667 ASSERT(i2c_success);
1669 /* Write offset 0x0A to 0x17 */
1672 i2c_success = i2c_write(pipe_ctx, slave_address,
1673 buffer, sizeof(buffer));
1676 ASSERT(i2c_success);
1678 /* Write offset 0x0B to 0xDA or 0xD8 */
1680 buffer[1] = is_over_340mhz ? 0xDA : 0xD8;
1681 i2c_success = i2c_write(pipe_ctx, slave_address,
1682 buffer, sizeof(buffer));
1685 ASSERT(i2c_success);
1687 /* Write offset 0x0A to 0x17 */
1690 i2c_success = i2c_write(pipe_ctx, slave_address,
1691 buffer, sizeof(buffer));
1694 ASSERT(i2c_success);
1696 /* Write offset 0x0C to 0x1D or 0x91 */
1698 buffer[1] = is_over_340mhz ? 0x1D : 0x91;
1699 i2c_success = i2c_write(pipe_ctx, slave_address,
1700 buffer, sizeof(buffer));
1703 ASSERT(i2c_success);
1705 /* Write offset 0x0A to 0x17 */
1708 i2c_success = i2c_write(pipe_ctx, slave_address,
1709 buffer, sizeof(buffer));
1712 ASSERT(i2c_success);
1716 /* Program additional settings if using 640x480 resolution */
1718 /* Write offset 0xFF to 0x01 */
1721 i2c_success = i2c_write(pipe_ctx, slave_address,
1722 buffer, sizeof(buffer));
1725 ASSERT(i2c_success);
1727 /* Write offset 0x00 to 0x23 */
1730 i2c_success = i2c_write(pipe_ctx, slave_address,
1731 buffer, sizeof(buffer));
1734 ASSERT(i2c_success);
1736 /* Write offset 0xff to 0x00 */
1739 i2c_success = i2c_write(pipe_ctx, slave_address,
1740 buffer, sizeof(buffer));
1743 ASSERT(i2c_success);
1747 static void write_i2c_redriver_setting(
1748 struct pipe_ctx *pipe_ctx,
1749 bool is_over_340mhz)
1751 uint8_t slave_address = (0xF0 >> 1);
1753 bool i2c_success = false;
1755 memset(&buffer, 0, sizeof(buffer));
1757 // Program Slave Address for tuning single integrity
1761 buffer[6] = is_over_340mhz ? 0x4E : 0x4A;
1763 i2c_success = i2c_write(pipe_ctx, slave_address,
1764 buffer, sizeof(buffer));
1768 ASSERT(i2c_success);
1771 static void enable_link_hdmi(struct pipe_ctx *pipe_ctx)
1773 struct dc_stream_state *stream = pipe_ctx->stream;
1774 struct dc_link *link = stream->sink->link;
1775 enum dc_color_depth display_color_depth;
1776 enum engine_id eng_id;
1777 struct ext_hdmi_settings settings = {0};
1778 bool is_over_340mhz = false;
1779 bool is_vga_mode = (stream->timing.h_addressable == 640)
1780 && (stream->timing.v_addressable == 480);
1782 if (stream->phy_pix_clk > 340000)
1783 is_over_340mhz = true;
1785 if (dc_is_hdmi_signal(pipe_ctx->stream->signal)) {
1786 unsigned short masked_chip_caps = pipe_ctx->stream->sink->link->chip_caps &
1787 EXT_DISPLAY_PATH_CAPS__EXT_CHIP_MASK;
1788 if (masked_chip_caps == EXT_DISPLAY_PATH_CAPS__HDMI20_TISN65DP159RSBT) {
1789 /* DP159, Retimer settings */
1790 eng_id = pipe_ctx->stream_res.stream_enc->id;
1792 if (get_ext_hdmi_settings(pipe_ctx, eng_id, &settings)) {
1793 write_i2c_retimer_setting(pipe_ctx,
1794 is_vga_mode, is_over_340mhz, &settings);
1796 write_i2c_default_retimer_setting(pipe_ctx,
1797 is_vga_mode, is_over_340mhz);
1799 } else if (masked_chip_caps == EXT_DISPLAY_PATH_CAPS__HDMI20_PI3EQX1204) {
1800 /* PI3EQX1204, Redriver settings */
1801 write_i2c_redriver_setting(pipe_ctx, is_over_340mhz);
1805 if (dc_is_hdmi_signal(pipe_ctx->stream->signal))
1806 dal_ddc_service_write_scdc_data(
1807 stream->sink->link->ddc,
1808 stream->phy_pix_clk,
1809 stream->timing.flags.LTE_340MCSC_SCRAMBLE);
1811 memset(&stream->sink->link->cur_link_settings, 0,
1812 sizeof(struct dc_link_settings));
1814 display_color_depth = stream->timing.display_color_depth;
1815 if (stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR422)
1816 display_color_depth = COLOR_DEPTH_888;
1818 link->link_enc->funcs->enable_tmds_output(
1820 pipe_ctx->clock_source->id,
1821 display_color_depth,
1822 pipe_ctx->stream->signal,
1823 stream->phy_pix_clk);
1825 if (pipe_ctx->stream->signal == SIGNAL_TYPE_HDMI_TYPE_A)
1826 dal_ddc_service_read_scdc_data(link->ddc);
1829 /****************************enable_link***********************************/
1830 static enum dc_status enable_link(
1831 struct dc_state *state,
1832 struct pipe_ctx *pipe_ctx)
1834 enum dc_status status = DC_ERROR_UNEXPECTED;
1835 switch (pipe_ctx->stream->signal) {
1836 case SIGNAL_TYPE_DISPLAY_PORT:
1837 status = enable_link_dp(state, pipe_ctx);
1839 case SIGNAL_TYPE_EDP:
1840 status = enable_link_edp(state, pipe_ctx);
1842 case SIGNAL_TYPE_DISPLAY_PORT_MST:
1843 status = enable_link_dp_mst(state, pipe_ctx);
1846 case SIGNAL_TYPE_DVI_SINGLE_LINK:
1847 case SIGNAL_TYPE_DVI_DUAL_LINK:
1848 case SIGNAL_TYPE_HDMI_TYPE_A:
1849 enable_link_hdmi(pipe_ctx);
1852 case SIGNAL_TYPE_VIRTUAL:
1862 static void disable_link(struct dc_link *link, enum signal_type signal)
1865 * TODO: implement call for dp_set_hw_test_pattern
1866 * it is needed for compliance testing
1869 /* here we need to specify that encoder output settings
1870 * need to be calculated as for the set mode,
1871 * it will lead to querying dynamic link capabilities
1872 * which should be done before enable output */
1874 if (dc_is_dp_signal(signal)) {
1876 if (dc_is_dp_sst_signal(signal))
1877 dp_disable_link_phy(link, signal);
1879 dp_disable_link_phy_mst(link, signal);
1881 link->link_enc->funcs->disable_output(link->link_enc, signal);
1884 static bool dp_active_dongle_validate_timing(
1885 const struct dc_crtc_timing *timing,
1886 const struct dpcd_caps *dpcd_caps)
1888 unsigned int required_pix_clk = timing->pix_clk_khz;
1889 const struct dc_dongle_caps *dongle_caps = &dpcd_caps->dongle_caps;
1891 switch (dpcd_caps->dongle_type) {
1892 case DISPLAY_DONGLE_DP_VGA_CONVERTER:
1893 case DISPLAY_DONGLE_DP_DVI_CONVERTER:
1894 case DISPLAY_DONGLE_DP_DVI_DONGLE:
1895 if (timing->pixel_encoding == PIXEL_ENCODING_RGB)
1903 if (dongle_caps->dongle_type != DISPLAY_DONGLE_DP_HDMI_CONVERTER ||
1904 dongle_caps->extendedCapValid == false)
1907 /* Check Pixel Encoding */
1908 switch (timing->pixel_encoding) {
1909 case PIXEL_ENCODING_RGB:
1910 case PIXEL_ENCODING_YCBCR444:
1912 case PIXEL_ENCODING_YCBCR422:
1913 if (!dongle_caps->is_dp_hdmi_ycbcr422_pass_through)
1916 case PIXEL_ENCODING_YCBCR420:
1917 if (!dongle_caps->is_dp_hdmi_ycbcr420_pass_through)
1921 /* Invalid Pixel Encoding*/
1926 /* Check Color Depth and Pixel Clock */
1927 if (timing->pixel_encoding == PIXEL_ENCODING_YCBCR420)
1928 required_pix_clk /= 2;
1929 else if (timing->pixel_encoding == PIXEL_ENCODING_YCBCR422)
1930 required_pix_clk = required_pix_clk * 2 / 3;
1932 switch (timing->display_color_depth) {
1933 case COLOR_DEPTH_666:
1934 case COLOR_DEPTH_888:
1935 /*888 and 666 should always be supported*/
1937 case COLOR_DEPTH_101010:
1938 if (dongle_caps->dp_hdmi_max_bpc < 10)
1940 required_pix_clk = required_pix_clk * 10 / 8;
1942 case COLOR_DEPTH_121212:
1943 if (dongle_caps->dp_hdmi_max_bpc < 12)
1945 required_pix_clk = required_pix_clk * 12 / 8;
1948 case COLOR_DEPTH_141414:
1949 case COLOR_DEPTH_161616:
1951 /* These color depths are currently not supported */
1955 if (required_pix_clk > dongle_caps->dp_hdmi_max_pixel_clk)
1961 enum dc_status dc_link_validate_mode_timing(
1962 const struct dc_stream_state *stream,
1963 struct dc_link *link,
1964 const struct dc_crtc_timing *timing)
1966 uint32_t max_pix_clk = stream->sink->dongle_max_pix_clk;
1967 struct dpcd_caps *dpcd_caps = &link->dpcd_caps;
1969 /* A hack to avoid failing any modes for EDID override feature on
1970 * topology change such as lower quality cable for DP or different dongle
1972 if (link->remote_sinks[0])
1975 /* Passive Dongle */
1976 if (0 != max_pix_clk && timing->pix_clk_khz > max_pix_clk)
1977 return DC_EXCEED_DONGLE_CAP;
1980 if (!dp_active_dongle_validate_timing(timing, dpcd_caps))
1981 return DC_EXCEED_DONGLE_CAP;
1983 switch (stream->signal) {
1984 case SIGNAL_TYPE_EDP:
1985 case SIGNAL_TYPE_DISPLAY_PORT:
1986 if (!dp_validate_mode_timing(
1989 return DC_NO_DP_LINK_BANDWIDTH;
2000 bool dc_link_set_backlight_level(const struct dc_link *link, uint32_t level,
2001 uint32_t frame_ramp, const struct dc_stream_state *stream)
2003 struct dc *core_dc = link->ctx->dc;
2004 struct abm *abm = core_dc->res_pool->abm;
2005 struct dmcu *dmcu = core_dc->res_pool->dmcu;
2006 unsigned int controller_id = 0;
2007 bool use_smooth_brightness = true;
2009 DC_LOGGER_INIT(link->ctx->logger);
2011 if ((dmcu == NULL) ||
2013 (abm->funcs->set_backlight_level == NULL))
2017 if (stream->bl_pwm_level == EDP_BACKLIGHT_RAMP_DISABLE_LEVEL)
2020 ((struct dc_stream_state *)stream)->bl_pwm_level = level;
2023 use_smooth_brightness = dmcu->funcs->is_dmcu_initialized(dmcu);
2025 DC_LOG_BACKLIGHT("New Backlight level: %d (0x%X)\n", level, level);
2027 if (dc_is_embedded_signal(link->connector_signal)) {
2028 if (stream != NULL) {
2029 for (i = 0; i < MAX_PIPES; i++) {
2030 if (core_dc->current_state->res_ctx.
2033 /* DMCU -1 for all controller id values,
2037 core_dc->current_state->
2038 res_ctx.pipe_ctx[i].stream_res.tg->inst +
2042 abm->funcs->set_backlight_level(
2047 use_smooth_brightness);
2053 bool dc_link_set_abm_disable(const struct dc_link *link)
2055 struct dc *core_dc = link->ctx->dc;
2056 struct abm *abm = core_dc->res_pool->abm;
2058 if ((abm == NULL) || (abm->funcs->set_backlight_level == NULL))
2061 abm->funcs->set_abm_immediate_disable(abm);
2066 bool dc_link_set_psr_enable(const struct dc_link *link, bool enable, bool wait)
2068 struct dc *core_dc = link->ctx->dc;
2069 struct dmcu *dmcu = core_dc->res_pool->dmcu;
2071 if (dmcu != NULL && link->psr_enabled)
2072 dmcu->funcs->set_psr_enable(dmcu, enable, wait);
2077 const struct dc_link_status *dc_link_get_status(const struct dc_link *link)
2079 return &link->link_status;
2082 void core_link_resume(struct dc_link *link)
2084 if (link->connector_signal != SIGNAL_TYPE_VIRTUAL)
2085 program_hpd_filter(link);
2088 static struct fixed31_32 get_pbn_per_slot(struct dc_stream_state *stream)
2090 struct dc_link_settings *link_settings =
2091 &stream->sink->link->cur_link_settings;
2092 uint32_t link_rate_in_mbps =
2093 link_settings->link_rate * LINK_RATE_REF_FREQ_IN_MHZ;
2094 struct fixed31_32 mbps = dc_fixpt_from_int(
2095 link_rate_in_mbps * link_settings->lane_count);
2097 return dc_fixpt_div_int(mbps, 54);
2100 static int get_color_depth(enum dc_color_depth color_depth)
2102 switch (color_depth) {
2103 case COLOR_DEPTH_666: return 6;
2104 case COLOR_DEPTH_888: return 8;
2105 case COLOR_DEPTH_101010: return 10;
2106 case COLOR_DEPTH_121212: return 12;
2107 case COLOR_DEPTH_141414: return 14;
2108 case COLOR_DEPTH_161616: return 16;
2113 static struct fixed31_32 get_pbn_from_timing(struct pipe_ctx *pipe_ctx)
2117 struct fixed31_32 peak_kbps;
2119 uint32_t denominator;
2121 bpc = get_color_depth(pipe_ctx->stream_res.pix_clk_params.color_depth);
2122 kbps = pipe_ctx->stream_res.pix_clk_params.requested_pix_clk * bpc * 3;
2125 * margin 5300ppm + 300ppm ~ 0.6% as per spec, factor is 1.006
2126 * The unit of 54/64Mbytes/sec is an arbitrary unit chosen based on
2127 * common multiplier to render an integer PBN for all link rate/lane
2128 * counts combinations
2130 * peak_kbps *= (1006/1000)
2131 * peak_kbps *= (64/54)
2132 * peak_kbps *= 8 convert to bytes
2135 numerator = 64 * PEAK_FACTOR_X1000;
2136 denominator = 54 * 8 * 1000 * 1000;
2138 peak_kbps = dc_fixpt_from_fraction(kbps, denominator);
2143 static void update_mst_stream_alloc_table(
2144 struct dc_link *link,
2145 struct stream_encoder *stream_enc,
2146 const struct dp_mst_stream_allocation_table *proposed_table)
2148 struct link_mst_stream_allocation work_table[MAX_CONTROLLER_NUM] = {
2150 struct link_mst_stream_allocation *dc_alloc;
2155 /* if DRM proposed_table has more than one new payload */
2156 ASSERT(proposed_table->stream_count -
2157 link->mst_stream_alloc_table.stream_count < 2);
2159 /* copy proposed_table to link, add stream encoder */
2160 for (i = 0; i < proposed_table->stream_count; i++) {
2162 for (j = 0; j < link->mst_stream_alloc_table.stream_count; j++) {
2164 &link->mst_stream_alloc_table.stream_allocations[j];
2166 if (dc_alloc->vcp_id ==
2167 proposed_table->stream_allocations[i].vcp_id) {
2169 work_table[i] = *dc_alloc;
2170 break; /* exit j loop */
2175 if (j == link->mst_stream_alloc_table.stream_count) {
2176 work_table[i].vcp_id =
2177 proposed_table->stream_allocations[i].vcp_id;
2178 work_table[i].slot_count =
2179 proposed_table->stream_allocations[i].slot_count;
2180 work_table[i].stream_enc = stream_enc;
2184 /* update link->mst_stream_alloc_table with work_table */
2185 link->mst_stream_alloc_table.stream_count =
2186 proposed_table->stream_count;
2187 for (i = 0; i < MAX_CONTROLLER_NUM; i++)
2188 link->mst_stream_alloc_table.stream_allocations[i] =
2192 /* convert link_mst_stream_alloc_table to dm dp_mst_stream_alloc_table
2193 * because stream_encoder is not exposed to dm
2195 static enum dc_status allocate_mst_payload(struct pipe_ctx *pipe_ctx)
2197 struct dc_stream_state *stream = pipe_ctx->stream;
2198 struct dc_link *link = stream->sink->link;
2199 struct link_encoder *link_encoder = link->link_enc;
2200 struct stream_encoder *stream_encoder = pipe_ctx->stream_res.stream_enc;
2201 struct dp_mst_stream_allocation_table proposed_table = {0};
2202 struct fixed31_32 avg_time_slots_per_mtp;
2203 struct fixed31_32 pbn;
2204 struct fixed31_32 pbn_per_slot;
2206 DC_LOGGER_INIT(link->ctx->logger);
2208 /* enable_link_dp_mst already check link->enabled_stream_count
2209 * and stream is in link->stream[]. This is called during set mode,
2210 * stream_enc is available.
2213 /* get calculate VC payload for stream: stream_alloc */
2214 if (dm_helpers_dp_mst_write_payload_allocation_table(
2219 update_mst_stream_alloc_table(
2220 link, pipe_ctx->stream_res.stream_enc, &proposed_table);
2223 DC_LOG_WARNING("Failed to update"
2224 "MST allocation table for"
2226 pipe_ctx->pipe_idx);
2229 "stream_count: %d: \n ",
2231 link->mst_stream_alloc_table.stream_count);
2233 for (i = 0; i < MAX_CONTROLLER_NUM; i++) {
2234 DC_LOG_MST("stream_enc[%d]: %p "
2235 "stream[%d].vcp_id: %d "
2236 "stream[%d].slot_count: %d\n",
2238 (void *) link->mst_stream_alloc_table.stream_allocations[i].stream_enc,
2240 link->mst_stream_alloc_table.stream_allocations[i].vcp_id,
2242 link->mst_stream_alloc_table.stream_allocations[i].slot_count);
2245 ASSERT(proposed_table.stream_count > 0);
2247 /* program DP source TX for payload */
2248 link_encoder->funcs->update_mst_stream_allocation_table(
2250 &link->mst_stream_alloc_table);
2252 /* send down message */
2253 dm_helpers_dp_mst_poll_for_allocation_change_trigger(
2257 dm_helpers_dp_mst_send_payload_allocation(
2262 /* slot X.Y for only current stream */
2263 pbn_per_slot = get_pbn_per_slot(stream);
2264 pbn = get_pbn_from_timing(pipe_ctx);
2265 avg_time_slots_per_mtp = dc_fixpt_div(pbn, pbn_per_slot);
2267 stream_encoder->funcs->set_mst_bandwidth(
2269 avg_time_slots_per_mtp);
2275 static enum dc_status deallocate_mst_payload(struct pipe_ctx *pipe_ctx)
2277 struct dc_stream_state *stream = pipe_ctx->stream;
2278 struct dc_link *link = stream->sink->link;
2279 struct link_encoder *link_encoder = link->link_enc;
2280 struct stream_encoder *stream_encoder = pipe_ctx->stream_res.stream_enc;
2281 struct dp_mst_stream_allocation_table proposed_table = {0};
2282 struct fixed31_32 avg_time_slots_per_mtp = dc_fixpt_from_int(0);
2284 bool mst_mode = (link->type == dc_connection_mst_branch);
2285 DC_LOGGER_INIT(link->ctx->logger);
2287 /* deallocate_mst_payload is called before disable link. When mode or
2288 * disable/enable monitor, new stream is created which is not in link
2289 * stream[] yet. For this, payload is not allocated yet, so de-alloc
2290 * should not done. For new mode set, map_resources will get engine
2291 * for new stream, so stream_enc->id should be validated until here.
2295 stream_encoder->funcs->set_mst_bandwidth(
2297 avg_time_slots_per_mtp);
2299 /* TODO: which component is responsible for remove payload table? */
2301 if (dm_helpers_dp_mst_write_payload_allocation_table(
2307 update_mst_stream_alloc_table(
2308 link, pipe_ctx->stream_res.stream_enc, &proposed_table);
2311 DC_LOG_WARNING("Failed to update"
2312 "MST allocation table for"
2314 pipe_ctx->pipe_idx);
2319 "stream_count: %d: ",
2321 link->mst_stream_alloc_table.stream_count);
2323 for (i = 0; i < MAX_CONTROLLER_NUM; i++) {
2324 DC_LOG_MST("stream_enc[%d]: %p "
2325 "stream[%d].vcp_id: %d "
2326 "stream[%d].slot_count: %d\n",
2328 (void *) link->mst_stream_alloc_table.stream_allocations[i].stream_enc,
2330 link->mst_stream_alloc_table.stream_allocations[i].vcp_id,
2332 link->mst_stream_alloc_table.stream_allocations[i].slot_count);
2335 link_encoder->funcs->update_mst_stream_allocation_table(
2337 &link->mst_stream_alloc_table);
2340 dm_helpers_dp_mst_poll_for_allocation_change_trigger(
2344 dm_helpers_dp_mst_send_payload_allocation(
2353 void core_link_enable_stream(
2354 struct dc_state *state,
2355 struct pipe_ctx *pipe_ctx)
2357 struct dc *core_dc = pipe_ctx->stream->ctx->dc;
2358 enum dc_status status;
2359 DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger);
2361 /* eDP lit up by bios already, no need to enable again. */
2362 if (pipe_ctx->stream->signal == SIGNAL_TYPE_EDP &&
2363 core_dc->apply_edp_fast_boot_optimization) {
2364 core_dc->apply_edp_fast_boot_optimization = false;
2365 pipe_ctx->stream->dpms_off = false;
2369 if (pipe_ctx->stream->dpms_off)
2372 status = enable_link(state, pipe_ctx);
2374 if (status != DC_OK) {
2375 DC_LOG_WARNING("enabling link %u failed: %d\n",
2376 pipe_ctx->stream->sink->link->link_index,
2379 /* Abort stream enable *unless* the failure was due to
2380 * DP link training - some DP monitors will recover and
2381 * show the stream anyway. But MST displays can't proceed
2382 * without link training.
2384 if (status != DC_FAIL_DP_LINK_TRAINING ||
2385 pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
2386 BREAK_TO_DEBUGGER();
2391 core_dc->hwss.enable_audio_stream(pipe_ctx);
2393 /* turn off otg test pattern if enable */
2394 if (pipe_ctx->stream_res.tg->funcs->set_test_pattern)
2395 pipe_ctx->stream_res.tg->funcs->set_test_pattern(pipe_ctx->stream_res.tg,
2396 CONTROLLER_DP_TEST_PATTERN_VIDEOMODE,
2397 COLOR_DEPTH_UNDEFINED);
2399 core_dc->hwss.enable_stream(pipe_ctx);
2401 if (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
2402 allocate_mst_payload(pipe_ctx);
2404 core_dc->hwss.unblank_stream(pipe_ctx,
2405 &pipe_ctx->stream->sink->link->cur_link_settings);
2408 void core_link_disable_stream(struct pipe_ctx *pipe_ctx, int option)
2410 struct dc *core_dc = pipe_ctx->stream->ctx->dc;
2412 if (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
2413 deallocate_mst_payload(pipe_ctx);
2415 core_dc->hwss.blank_stream(pipe_ctx);
2417 core_dc->hwss.disable_stream(pipe_ctx, option);
2419 disable_link(pipe_ctx->stream->sink->link, pipe_ctx->stream->signal);
2422 void core_link_set_avmute(struct pipe_ctx *pipe_ctx, bool enable)
2424 struct dc *core_dc = pipe_ctx->stream->ctx->dc;
2426 if (pipe_ctx->stream->signal != SIGNAL_TYPE_HDMI_TYPE_A)
2429 core_dc->hwss.set_avmute(pipe_ctx, enable);
2433 *****************************************************************************
2434 * Function: dc_link_enable_hpd_filter
2437 * If enable is true, programs HPD filter on associated HPD line using
2438 * delay_on_disconnect/delay_on_connect values dependent on
2439 * link->connector_signal
2441 * If enable is false, programs HPD filter on associated HPD line with no
2442 * delays on connect or disconnect
2444 * @param [in] link: pointer to the dc link
2445 * @param [in] enable: boolean specifying whether to enable hbd
2446 *****************************************************************************
2448 void dc_link_enable_hpd_filter(struct dc_link *link, bool enable)
2453 link->is_hpd_filter_disabled = false;
2454 program_hpd_filter(link);
2456 link->is_hpd_filter_disabled = true;
2457 /* Obtain HPD handle */
2458 hpd = get_hpd_gpio(link->ctx->dc_bios, link->link_id, link->ctx->gpio_service);
2463 /* Setup HPD filtering */
2464 if (dal_gpio_open(hpd, GPIO_MODE_INTERRUPT) == GPIO_RESULT_OK) {
2465 struct gpio_hpd_config config;
2467 config.delay_on_connect = 0;
2468 config.delay_on_disconnect = 0;
2470 dal_irq_setup_hpd_filter(hpd, &config);
2472 dal_gpio_close(hpd);
2474 ASSERT_CRITICAL(false);
2476 /* Release HPD handle */
2477 dal_gpio_destroy_irq(&hpd);