Lines Matching refs:link

50 					struct msm_dp_link_info *link)
56 if (link->revision < 0x11)
78 struct msm_dp_link_info *link)
83 if (link->revision < 0x11)
100 static int msm_dp_link_get_period(struct msm_dp_link_private *link, int const addr)
107 if (drm_dp_dpcd_readb(link->aux, addr, &data) < 0) {
126 static int msm_dp_link_parse_audio_channel_period(struct msm_dp_link_private *link)
129 struct msm_dp_link_test_audio *req = &link->msm_dp_link.test_audio;
131 ret = msm_dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH1);
136 drm_dbg_dp(link->drm_dev, "test_audio_period_ch_1 = 0x%x\n", ret);
138 ret = msm_dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH2);
143 drm_dbg_dp(link->drm_dev, "test_audio_period_ch_2 = 0x%x\n", ret);
146 ret = msm_dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH3);
151 drm_dbg_dp(link->drm_dev, "test_audio_period_ch_3 = 0x%x\n", ret);
153 ret = msm_dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH4);
158 drm_dbg_dp(link->drm_dev, "test_audio_period_ch_4 = 0x%x\n", ret);
160 ret = msm_dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH5);
165 drm_dbg_dp(link->drm_dev, "test_audio_period_ch_5 = 0x%x\n", ret);
167 ret = msm_dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH6);
172 drm_dbg_dp(link->drm_dev, "test_audio_period_ch_6 = 0x%x\n", ret);
174 ret = msm_dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH7);
179 drm_dbg_dp(link->drm_dev, "test_audio_period_ch_7 = 0x%x\n", ret);
181 ret = msm_dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH8);
186 drm_dbg_dp(link->drm_dev, "test_audio_period_ch_8 = 0x%x\n", ret);
191 static int msm_dp_link_parse_audio_pattern_type(struct msm_dp_link_private *link)
198 rlen = drm_dp_dpcd_readb(link->aux,
201 DRM_ERROR("failed to read link audio mode. rlen=%zd\n", rlen);
212 link->msm_dp_link.test_audio.test_audio_pattern_type = data;
213 drm_dbg_dp(link->drm_dev, "audio pattern type = 0x%x\n", data);
218 static int msm_dp_link_parse_audio_mode(struct msm_dp_link_private *link)
228 rlen = drm_dp_dpcd_readb(link->aux, DP_TEST_AUDIO_MODE, &data);
230 DRM_ERROR("failed to read link audio mode. rlen=%zd\n", rlen);
252 link->msm_dp_link.test_audio.test_audio_sampling_rate = sampling_rate;
253 link->msm_dp_link.test_audio.test_audio_channel_count = channel_count;
254 drm_dbg_dp(link->drm_dev,
261 static int msm_dp_link_parse_audio_pattern_params(struct msm_dp_link_private *link)
265 ret = msm_dp_link_parse_audio_mode(link);
269 ret = msm_dp_link_parse_audio_pattern_type(link);
273 ret = msm_dp_link_parse_audio_channel_period(link);
311 static int msm_dp_link_parse_timing_params1(struct msm_dp_link_private *link,
320 /* Read the requested video link pattern (Byte 0x221). */
321 rlen = drm_dp_dpcd_read(link->aux, addr, bp, len);
332 static int msm_dp_link_parse_timing_params2(struct msm_dp_link_private *link,
342 /* Read the requested video link pattern (Byte 0x221). */
343 rlen = drm_dp_dpcd_read(link->aux, addr, bp, len);
355 static int msm_dp_link_parse_timing_params3(struct msm_dp_link_private *link,
362 rlen = drm_dp_dpcd_read(link->aux, addr, &bp, len);
374 * @link: Display Port Driver data
376 * Returns 0 if it successfully parses the video link pattern and the link
379 static int msm_dp_link_parse_video_pattern_params(struct msm_dp_link_private *link)
385 rlen = drm_dp_dpcd_readb(link->aux, DP_TEST_PATTERN, &bp);
387 DRM_ERROR("failed to read link video pattern. rlen=%zd\n",
393 DRM_ERROR("invalid link video pattern = 0x%x\n", bp);
398 link->msm_dp_link.test_video.test_video_pattern = bp;
401 rlen = drm_dp_dpcd_readb(link->aux, DP_TEST_MISC0, &bp);
403 DRM_ERROR("failed to read link bit depth. rlen=%zd\n", rlen);
408 link->msm_dp_link.test_video.test_dyn_range =
414 DRM_ERROR("invalid link bit depth = 0x%x\n", bp);
419 link->msm_dp_link.test_video.test_bit_depth = bp;
422 ret = msm_dp_link_parse_timing_params1(link, DP_TEST_H_TOTAL_HI, 2,
423 &link->msm_dp_link.test_video.test_h_total);
429 ret = msm_dp_link_parse_timing_params1(link, DP_TEST_V_TOTAL_HI, 2,
430 &link->msm_dp_link.test_video.test_v_total);
436 ret = msm_dp_link_parse_timing_params1(link, DP_TEST_H_START_HI, 2,
437 &link->msm_dp_link.test_video.test_h_start);
443 ret = msm_dp_link_parse_timing_params1(link, DP_TEST_V_START_HI, 2,
444 &link->msm_dp_link.test_video.test_v_start);
450 ret = msm_dp_link_parse_timing_params2(link, DP_TEST_HSYNC_HI, 2,
451 &link->msm_dp_link.test_video.test_hsync_pol,
452 &link->msm_dp_link.test_video.test_hsync_width);
458 ret = msm_dp_link_parse_timing_params2(link, DP_TEST_VSYNC_HI, 2,
459 &link->msm_dp_link.test_video.test_vsync_pol,
460 &link->msm_dp_link.test_video.test_vsync_width);
466 ret = msm_dp_link_parse_timing_params1(link, DP_TEST_H_WIDTH_HI, 2,
467 &link->msm_dp_link.test_video.test_h_width);
473 ret = msm_dp_link_parse_timing_params1(link, DP_TEST_V_HEIGHT_HI, 2,
474 &link->msm_dp_link.test_video.test_v_height);
480 ret = msm_dp_link_parse_timing_params3(link, DP_TEST_MISC1,
481 &link->msm_dp_link.test_video.test_rr_d);
482 link->msm_dp_link.test_video.test_rr_d &= DP_TEST_REFRESH_DENOMINATOR;
488 ret = msm_dp_link_parse_timing_params3(link, DP_TEST_REFRESH_RATE_NUMERATOR,
489 &link->msm_dp_link.test_video.test_rr_n);
495 drm_dbg_dp(link->drm_dev,
496 "link video pattern = 0x%x\n"
497 "link dynamic range = 0x%x\n"
498 "link bit depth = 0x%x\n"
509 link->msm_dp_link.test_video.test_video_pattern,
510 link->msm_dp_link.test_video.test_dyn_range,
511 link->msm_dp_link.test_video.test_bit_depth,
512 link->msm_dp_link.test_video.test_h_total,
513 link->msm_dp_link.test_video.test_v_total,
514 link->msm_dp_link.test_video.test_h_start,
515 link->msm_dp_link.test_video.test_v_start,
516 link->msm_dp_link.test_video.test_hsync_pol,
517 link->msm_dp_link.test_video.test_hsync_width,
518 link->msm_dp_link.test_video.test_vsync_pol,
519 link->msm_dp_link.test_video.test_vsync_width,
520 link->msm_dp_link.test_video.test_h_width,
521 link->msm_dp_link.test_video.test_v_height,
522 link->msm_dp_link.test_video.test_rr_d,
523 link->msm_dp_link.test_video.test_rr_n);
529 * msm_dp_link_parse_link_training_params() - parses link training parameters from
531 * @link: Display Port Driver data
533 * Returns 0 if it successfully parses the link rate (Byte 0x219) and lane
536 static int msm_dp_link_parse_link_training_params(struct msm_dp_link_private *link)
541 rlen = drm_dp_dpcd_readb(link->aux, DP_TEST_LINK_RATE, &bp);
543 DRM_ERROR("failed to read link rate. rlen=%zd\n", rlen);
548 DRM_ERROR("invalid link rate = 0x%x\n", bp);
552 link->request.test_link_rate = bp;
553 drm_dbg_dp(link->drm_dev, "link rate = 0x%x\n",
554 link->request.test_link_rate);
556 rlen = drm_dp_dpcd_readb(link->aux, DP_TEST_LANE_COUNT, &bp);
568 link->request.test_lane_count = bp;
569 drm_dbg_dp(link->drm_dev, "lane count = 0x%x\n",
570 link->request.test_lane_count);
575 * msm_dp_link_parse_phy_test_params() - parses the phy link parameters
576 * @link: Display Port Driver data
578 * Parses the DPCD (Byte 0x248) for the DP PHY link pattern that is being
581 static int msm_dp_link_parse_phy_test_params(struct msm_dp_link_private *link)
586 rlen = drm_dp_dpcd_readb(link->aux, DP_PHY_TEST_PATTERN,
589 DRM_ERROR("failed to read phy link pattern. rlen=%zd\n", rlen);
593 link->msm_dp_link.phy_params.phy_test_pattern_sel = data & 0x07;
595 drm_dbg_dp(link->drm_dev, "phy_test_pattern_sel = 0x%x\n", data);
612 * msm_dp_link_is_video_audio_test_requested() - checks for audio/video link request
613 * @link: link requested by the sink
615 * Returns true if the requested link is a permitted audio/video link.
617 static bool msm_dp_link_is_video_audio_test_requested(u32 link)
623 return ((link & video_audio_test) &&
624 !(link & ~video_audio_test));
628 * msm_dp_link_parse_request() - parses link request parameters from sink
629 * @link: Display Port Driver data
631 * Parses the DPCD to check if an automated link is requested (Byte 0x201),
632 * and what type of link automation is being requested (Byte 0x218).
634 static int msm_dp_link_parse_request(struct msm_dp_link_private *link)
642 * whether an automated link has been requested by the sink.
644 rlen = drm_dp_dpcd_readb(link->aux,
651 drm_dbg_dp(link->drm_dev, "device service irq vector = 0x%x\n", data);
654 drm_dbg_dp(link->drm_dev, "no test requested\n");
659 * Read the link request byte (Byte 0x218) to determine what type
660 * of automated link has been requested by the sink.
662 rlen = drm_dp_dpcd_readb(link->aux, DP_TEST_REQUEST, &data);
669 drm_dbg_dp(link->drm_dev, "link 0x%x not supported\n", data);
673 drm_dbg_dp(link->drm_dev, "Test:(0x%x) requested\n", data);
674 link->request.test_requested = data;
675 if (link->request.test_requested == DP_TEST_LINK_PHY_TEST_PATTERN) {
676 ret = msm_dp_link_parse_phy_test_params(link);
679 ret = msm_dp_link_parse_link_training_params(link);
684 if (link->request.test_requested == DP_TEST_LINK_TRAINING) {
685 ret = msm_dp_link_parse_link_training_params(link);
691 link->request.test_requested)) {
692 ret = msm_dp_link_parse_video_pattern_params(link);
696 ret = msm_dp_link_parse_audio_pattern_params(link);
700 * Send a DP_TEST_ACK if all link parameters are valid, otherwise send
704 link->msm_dp_link.test_response = DP_TEST_NAK;
706 if (link->request.test_requested != DP_TEST_LINK_EDID_READ)
707 link->msm_dp_link.test_response = DP_TEST_ACK;
709 link->msm_dp_link.test_response =
716 static int msm_dp_link_parse_sink_status_field(struct msm_dp_link_private *link)
720 link->prev_sink_count = link->msm_dp_link.sink_count;
721 ret = drm_dp_read_sink_count(link->aux);
726 link->msm_dp_link.sink_count = ret;
728 ret = drm_dp_dpcd_read_link_status(link->aux,
729 link->link_status);
731 DRM_ERROR("DP link status read failed\n");
735 return msm_dp_link_parse_request(link);
740 * @link: Display Port link data
742 * This function will handle new link training requests that are initiated by
743 * the sink. In particular, it will update the requested lane count and link
744 * rate, and then trigger the link retraining procedure.
746 * The function will return 0 if a link training request has been processed,
749 static int msm_dp_link_process_link_training_request(struct msm_dp_link_private *link)
751 if (link->request.test_requested != DP_TEST_LINK_TRAINING)
754 drm_dbg_dp(link->drm_dev,
755 "Test:0x%x link rate = 0x%x, lane count = 0x%x\n",
757 link->request.test_link_rate,
758 link->request.test_lane_count);
760 link->msm_dp_link.link_params.num_lanes = link->request.test_lane_count;
761 link->msm_dp_link.link_params.rate =
762 drm_dp_bw_code_to_link_rate(link->request.test_link_rate);
769 struct msm_dp_link_private *link = NULL;
777 link = container_of(msm_dp_link, struct msm_dp_link_private, msm_dp_link);
779 ret = drm_dp_dpcd_writeb(link->aux, DP_TEST_RESPONSE,
788 struct msm_dp_link_private *link = NULL;
796 link = container_of(msm_dp_link, struct msm_dp_link_private, msm_dp_link);
798 mutex_lock(&link->psm_mutex);
800 ret = msm_dp_aux_link_power_down(link->aux, link_info);
802 ret = msm_dp_aux_link_power_up(link->aux, link_info);
808 mutex_unlock(&link->psm_mutex);
814 struct msm_dp_link_private *link = NULL;
822 link = container_of(msm_dp_link, struct msm_dp_link_private, msm_dp_link);
824 ret = drm_dp_dpcd_writeb(link->aux, DP_TEST_EDID_CHECKSUM,
829 static void msm_dp_link_parse_vx_px(struct msm_dp_link_private *link)
831 drm_dbg_dp(link->drm_dev, "vx: 0=%d, 1=%d, 2=%d, 3=%d\n",
832 drm_dp_get_adjust_request_voltage(link->link_status, 0),
833 drm_dp_get_adjust_request_voltage(link->link_status, 1),
834 drm_dp_get_adjust_request_voltage(link->link_status, 2),
835 drm_dp_get_adjust_request_voltage(link->link_status, 3));
837 drm_dbg_dp(link->drm_dev, "px: 0=%d, 1=%d, 2=%d, 3=%d\n",
838 drm_dp_get_adjust_request_pre_emphasis(link->link_status, 0),
839 drm_dp_get_adjust_request_pre_emphasis(link->link_status, 1),
840 drm_dp_get_adjust_request_pre_emphasis(link->link_status, 2),
841 drm_dp_get_adjust_request_pre_emphasis(link->link_status, 3));
847 drm_dbg_dp(link->drm_dev,
849 link->msm_dp_link.phy_params.v_level,
850 link->msm_dp_link.phy_params.p_level);
851 link->msm_dp_link.phy_params.v_level =
852 drm_dp_get_adjust_request_voltage(link->link_status, 0);
853 link->msm_dp_link.phy_params.p_level =
854 drm_dp_get_adjust_request_pre_emphasis(link->link_status, 0);
856 link->msm_dp_link.phy_params.p_level >>= DP_TRAIN_PRE_EMPHASIS_SHIFT;
858 drm_dbg_dp(link->drm_dev,
860 link->msm_dp_link.phy_params.v_level,
861 link->msm_dp_link.phy_params.p_level);
865 * msm_dp_link_process_phy_test_pattern_request() - process new phy link requests
866 * @link: Display Port Driver data
868 * This function will handle new phy link pattern requests that are initiated
869 * by the sink. The function will return 0 if a phy link pattern has been
873 struct msm_dp_link_private *link)
875 if (!(link->request.test_requested & DP_TEST_LINK_PHY_TEST_PATTERN)) {
876 drm_dbg_dp(link->drm_dev, "no phy test\n");
880 if (!is_link_rate_valid(link->request.test_link_rate) ||
881 !is_lane_count_valid(link->request.test_lane_count)) {
882 DRM_ERROR("Invalid: link rate = 0x%x,lane count = 0x%x\n",
883 link->request.test_link_rate,
884 link->request.test_lane_count);
888 drm_dbg_dp(link->drm_dev,
890 link->msm_dp_link.link_params.rate,
891 link->msm_dp_link.link_params.num_lanes);
893 drm_dbg_dp(link->drm_dev,
895 link->request.test_link_rate,
896 link->request.test_lane_count);
898 link->msm_dp_link.link_params.num_lanes = link->request.test_lane_count;
899 link->msm_dp_link.link_params.rate =
900 drm_dp_bw_code_to_link_rate(link->request.test_link_rate);
902 msm_dp_link_parse_vx_px(link);
907 static bool msm_dp_link_read_psr_error_status(struct msm_dp_link_private *link)
911 drm_dp_dpcd_read(link->aux, DP_PSR_ERROR_STATUS, &status, 1);
925 static bool msm_dp_link_psr_capability_changed(struct msm_dp_link_private *link)
929 drm_dp_dpcd_read(link->aux, DP_PSR_ESI, &status, 1);
932 drm_dbg_dp(link->drm_dev, "PSR Capability Change\n");
945 * msm_dp_link_process_link_status_update() - processes link status updates
946 * @link: Display Port link module data
948 * This function will check for changes in the link status, e.g. clock
949 * recovery done on all lanes, and trigger link training if there is a
950 * failure/error on the link.
952 * The function will return 0 if the a link status update has been processed,
955 static int msm_dp_link_process_link_status_update(struct msm_dp_link_private *link)
957 bool channel_eq_done = drm_dp_channel_eq_ok(link->link_status,
958 link->msm_dp_link.link_params.num_lanes);
960 bool clock_recovery_done = drm_dp_clock_recovery_ok(link->link_status,
961 link->msm_dp_link.link_params.num_lanes);
963 drm_dbg_dp(link->drm_dev,
975 * @link: Display Port Driver data
984 static int msm_dp_link_process_ds_port_status_change(struct msm_dp_link_private *link)
986 if (get_link_status(link->link_status, DP_LANE_ALIGN_STATUS_UPDATED) &
990 if (link->prev_sink_count == link->msm_dp_link.sink_count)
995 link->prev_sink_count = link->msm_dp_link.sink_count;
1000 static bool msm_dp_link_is_video_pattern_requested(struct msm_dp_link_private *link)
1002 return (link->request.test_requested & DP_TEST_LINK_VIDEO_PATTERN)
1003 && !(link->request.test_requested &
1007 static bool msm_dp_link_is_audio_pattern_requested(struct msm_dp_link_private *link)
1009 return (link->request.test_requested & DP_TEST_LINK_AUDIO_PATTERN);
1012 static void msm_dp_link_reset_data(struct msm_dp_link_private *link)
1014 link->request = (const struct msm_dp_link_request){ 0 };
1015 link->msm_dp_link.test_video = (const struct msm_dp_link_test_video){ 0 };
1016 link->msm_dp_link.test_video.test_bit_depth = DP_TEST_BIT_DEPTH_UNKNOWN;
1017 link->msm_dp_link.test_audio = (const struct msm_dp_link_test_audio){ 0 };
1018 link->msm_dp_link.phy_params.phy_test_pattern_sel = 0;
1019 link->msm_dp_link.sink_request = 0;
1020 link->msm_dp_link.test_response = 0;
1025 * @msm_dp_link: pointer to link module data
1029 * the start of a new link training request or sink status update.
1034 struct msm_dp_link_private *link;
1041 link = container_of(msm_dp_link, struct msm_dp_link_private, msm_dp_link);
1043 msm_dp_link_reset_data(link);
1045 ret = msm_dp_link_parse_sink_status_field(link);
1049 if (link->request.test_requested == DP_TEST_LINK_EDID_READ) {
1051 } else if (!msm_dp_link_process_ds_port_status_change(link)) {
1053 } else if (!msm_dp_link_process_link_training_request(link)) {
1055 } else if (!msm_dp_link_process_phy_test_pattern_request(link)) {
1057 } else if (msm_dp_link_read_psr_error_status(link)) {
1059 } else if (msm_dp_link_psr_capability_changed(link)) {
1060 drm_dbg_dp(link->drm_dev, "PSR Capability changed\n");
1062 ret = msm_dp_link_process_link_status_update(link);
1066 if (msm_dp_link_is_video_pattern_requested(link)) {
1070 if (msm_dp_link_is_audio_pattern_requested(link)) {
1077 drm_dbg_dp(link->drm_dev, "sink request=%#x\n",
1085 struct msm_dp_link_private *link;
1092 link = container_of(msm_dp_link, struct msm_dp_link_private, msm_dp_link);
1098 if (msm_dp_link_is_video_pattern_requested(link)) {
1099 if (link->msm_dp_link.test_video.test_dyn_range &
1112 struct msm_dp_link_private *link;
1119 link = container_of(msm_dp_link, struct msm_dp_link_private, msm_dp_link);
1126 drm_dbg_dp(link->drm_dev,
1143 drm_dbg_dp(link->drm_dev,
1151 drm_dbg_dp(link->drm_dev,
1160 drm_dbg_dp(link->drm_dev,
1167 drm_dbg_dp(link->drm_dev, "adjusted: v_level=%d, p_level=%d\n",
1182 struct msm_dp_link_private *link;
1184 link = container_of(msm_dp_link, struct msm_dp_link_private, msm_dp_link);
1202 drm_dbg_dp(link->drm_dev, "bpp=%d not supported, use bpc=8\n",
1215 struct msm_dp_link_private *link;
1223 link = devm_kzalloc(dev, sizeof(*link), GFP_KERNEL);
1224 if (!link)
1227 link->aux = aux;
1229 mutex_init(&link->psm_mutex);
1230 msm_dp_link = &link->msm_dp_link;