diff options
Diffstat (limited to 'drivers/gpu/drm/msm/dp/dp_link.c')
-rw-r--r-- | drivers/gpu/drm/msm/dp/dp_link.c | 103 |
1 files changed, 61 insertions, 42 deletions
diff --git a/drivers/gpu/drm/msm/dp/dp_link.c b/drivers/gpu/drm/msm/dp/dp_link.c index d4d31e5bda07..36f0af02749f 100644 --- a/drivers/gpu/drm/msm/dp/dp_link.c +++ b/drivers/gpu/drm/msm/dp/dp_link.c @@ -36,6 +36,7 @@ struct dp_link_request { struct dp_link_private { u32 prev_sink_count; struct device *dev; + struct drm_device *drm_dev; struct drm_dp_aux *aux; struct dp_link dp_link; @@ -128,14 +129,14 @@ static int dp_link_parse_audio_channel_period(struct dp_link_private *link) goto exit; req->test_audio_period_ch_1 = ret; - DRM_DEBUG_DP("test_audio_period_ch_1 = 0x%x\n", ret); + drm_dbg_dp(link->drm_dev, "test_audio_period_ch_1 = 0x%x\n", ret); ret = dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH2); if (ret == -EINVAL) goto exit; req->test_audio_period_ch_2 = ret; - DRM_DEBUG_DP("test_audio_period_ch_2 = 0x%x\n", ret); + drm_dbg_dp(link->drm_dev, "test_audio_period_ch_2 = 0x%x\n", ret); /* TEST_AUDIO_PERIOD_CH_3 (Byte 0x275) */ ret = dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH3); @@ -143,42 +144,42 @@ static int dp_link_parse_audio_channel_period(struct dp_link_private *link) goto exit; req->test_audio_period_ch_3 = ret; - DRM_DEBUG_DP("test_audio_period_ch_3 = 0x%x\n", ret); + drm_dbg_dp(link->drm_dev, "test_audio_period_ch_3 = 0x%x\n", ret); ret = dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH4); if (ret == -EINVAL) goto exit; req->test_audio_period_ch_4 = ret; - DRM_DEBUG_DP("test_audio_period_ch_4 = 0x%x\n", ret); + drm_dbg_dp(link->drm_dev, "test_audio_period_ch_4 = 0x%x\n", ret); ret = dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH5); if (ret == -EINVAL) goto exit; req->test_audio_period_ch_5 = ret; - DRM_DEBUG_DP("test_audio_period_ch_5 = 0x%x\n", ret); + drm_dbg_dp(link->drm_dev, "test_audio_period_ch_5 = 0x%x\n", ret); ret = dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH6); if (ret == -EINVAL) goto exit; req->test_audio_period_ch_6 = ret; - DRM_DEBUG_DP("test_audio_period_ch_6 = 0x%x\n", ret); + drm_dbg_dp(link->drm_dev, "test_audio_period_ch_6 = 0x%x\n", ret); ret = dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH7); if (ret == -EINVAL) goto exit; req->test_audio_period_ch_7 = ret; - DRM_DEBUG_DP("test_audio_period_ch_7 = 0x%x\n", ret); + drm_dbg_dp(link->drm_dev, "test_audio_period_ch_7 = 0x%x\n", ret); ret = dp_link_get_period(link, DP_TEST_AUDIO_PERIOD_CH8); if (ret == -EINVAL) goto exit; req->test_audio_period_ch_8 = ret; - DRM_DEBUG_DP("test_audio_period_ch_8 = 0x%x\n", ret); + drm_dbg_dp(link->drm_dev, "test_audio_period_ch_8 = 0x%x\n", ret); exit: return ret; } @@ -205,7 +206,7 @@ static int dp_link_parse_audio_pattern_type(struct dp_link_private *link) } link->dp_link.test_audio.test_audio_pattern_type = data; - DRM_DEBUG_DP("audio pattern type = 0x%x\n", data); + drm_dbg_dp(link->drm_dev, "audio pattern type = 0x%x\n", data); exit: return ret; } @@ -246,8 +247,9 @@ static int dp_link_parse_audio_mode(struct dp_link_private *link) link->dp_link.test_audio.test_audio_sampling_rate = sampling_rate; link->dp_link.test_audio.test_audio_channel_count = channel_count; - DRM_DEBUG_DP("sampling_rate = 0x%x, channel_count = 0x%x\n", - sampling_rate, channel_count); + drm_dbg_dp(link->drm_dev, + "sampling_rate = 0x%x, channel_count = 0x%x\n", + sampling_rate, channel_count); exit: return ret; } @@ -486,7 +488,8 @@ static int dp_link_parse_video_pattern_params(struct dp_link_private *link) return ret; } - DRM_DEBUG_DP("link video pattern = 0x%x\n" + drm_dbg_dp(link->drm_dev, + "link video pattern = 0x%x\n" "link dynamic range = 0x%x\n" "link bit depth = 0x%x\n" "TEST_H_TOTAL = %d, TEST_V_TOTAL = %d\n" @@ -543,7 +546,8 @@ static int dp_link_parse_link_training_params(struct dp_link_private *link) } link->request.test_link_rate = bp; - DRM_DEBUG_DP("link rate = 0x%x\n", link->request.test_link_rate); + drm_dbg_dp(link->drm_dev, "link rate = 0x%x\n", + link->request.test_link_rate); rlen = drm_dp_dpcd_readb(link->aux, DP_TEST_LANE_COUNT, &bp); if (rlen < 0) { @@ -558,7 +562,8 @@ static int dp_link_parse_link_training_params(struct dp_link_private *link) } link->request.test_lane_count = bp; - DRM_DEBUG_DP("lane count = 0x%x\n", link->request.test_lane_count); + drm_dbg_dp(link->drm_dev, "lane count = 0x%x\n", + link->request.test_lane_count); return 0; } @@ -583,7 +588,7 @@ static int dp_link_parse_phy_test_params(struct dp_link_private *link) link->dp_link.phy_params.phy_test_pattern_sel = data & 0x07; - DRM_DEBUG_DP("phy_test_pattern_sel = 0x%x\n", data); + drm_dbg_dp(link->drm_dev, "phy_test_pattern_sel = 0x%x\n", data); switch (data) { case DP_PHY_TEST_PATTERN_SEL_MASK: @@ -639,10 +644,10 @@ static int dp_link_parse_request(struct dp_link_private *link) return rlen; } - DRM_DEBUG_DP("device service irq vector = 0x%x\n", data); + drm_dbg_dp(link->drm_dev, "device service irq vector = 0x%x\n", data); if (!(data & DP_AUTOMATED_TEST_REQUEST)) { - DRM_DEBUG_DP("no test requested\n"); + drm_dbg_dp(link->drm_dev, "no test requested\n"); return 0; } @@ -657,11 +662,11 @@ static int dp_link_parse_request(struct dp_link_private *link) } if (!data || (data == DP_TEST_LINK_FAUX_PATTERN)) { - DRM_DEBUG_DP("link 0x%x not supported\n", data); + drm_dbg_dp(link->drm_dev, "link 0x%x not supported\n", data); goto end; } - DRM_DEBUG_DP("Test:(0x%x) requested\n", data); + drm_dbg_dp(link->drm_dev, "Test:(0x%x) requested\n", data); link->request.test_requested = data; if (link->request.test_requested == DP_TEST_LINK_PHY_TEST_PATTERN) { ret = dp_link_parse_phy_test_params(link); @@ -732,8 +737,8 @@ static int dp_link_parse_sink_count(struct dp_link *dp_link) link->dp_link.sink_count = DP_GET_SINK_COUNT(link->dp_link.sink_count); - DRM_DEBUG_DP("sink_count = 0x%x, cp_ready = 0x%x\n", - link->dp_link.sink_count, cp_ready); + drm_dbg_dp(link->drm_dev, "sink_count = 0x%x, cp_ready = 0x%x\n", + link->dp_link.sink_count, cp_ready); return 0; } @@ -774,7 +779,8 @@ static int dp_link_process_link_training_request(struct dp_link_private *link) if (link->request.test_requested != DP_TEST_LINK_TRAINING) return -EINVAL; - DRM_DEBUG_DP("Test:0x%x link rate = 0x%x, lane count = 0x%x\n", + drm_dbg_dp(link->drm_dev, + "Test:0x%x link rate = 0x%x, lane count = 0x%x\n", DP_TEST_LINK_TRAINING, link->request.test_link_rate, link->request.test_lane_count); @@ -852,13 +858,13 @@ bool dp_link_send_edid_checksum(struct dp_link *dp_link, u8 checksum) static void dp_link_parse_vx_px(struct dp_link_private *link) { - DRM_DEBUG_DP("vx: 0=%d, 1=%d, 2=%d, 3=%d\n", + drm_dbg_dp(link->drm_dev, "vx: 0=%d, 1=%d, 2=%d, 3=%d\n", drm_dp_get_adjust_request_voltage(link->link_status, 0), drm_dp_get_adjust_request_voltage(link->link_status, 1), drm_dp_get_adjust_request_voltage(link->link_status, 2), drm_dp_get_adjust_request_voltage(link->link_status, 3)); - DRM_DEBUG_DP("px: 0=%d, 1=%d, 2=%d, 3=%d\n", + drm_dbg_dp(link->drm_dev, "px: 0=%d, 1=%d, 2=%d, 3=%d\n", drm_dp_get_adjust_request_pre_emphasis(link->link_status, 0), drm_dp_get_adjust_request_pre_emphasis(link->link_status, 1), drm_dp_get_adjust_request_pre_emphasis(link->link_status, 2), @@ -868,7 +874,8 @@ static void dp_link_parse_vx_px(struct dp_link_private *link) * Update the voltage and pre-emphasis levels as per DPCD request * vector. */ - DRM_DEBUG_DP("Current: v_level = 0x%x, p_level = 0x%x\n", + drm_dbg_dp(link->drm_dev, + "Current: v_level = 0x%x, p_level = 0x%x\n", link->dp_link.phy_params.v_level, link->dp_link.phy_params.p_level); link->dp_link.phy_params.v_level = @@ -878,7 +885,8 @@ static void dp_link_parse_vx_px(struct dp_link_private *link) link->dp_link.phy_params.p_level >>= DP_TRAIN_PRE_EMPHASIS_SHIFT; - DRM_DEBUG_DP("Requested: v_level = 0x%x, p_level = 0x%x\n", + drm_dbg_dp(link->drm_dev, + "Requested: v_level = 0x%x, p_level = 0x%x\n", link->dp_link.phy_params.v_level, link->dp_link.phy_params.p_level); } @@ -895,7 +903,7 @@ static int dp_link_process_phy_test_pattern_request( struct dp_link_private *link) { if (!(link->request.test_requested & DP_TEST_LINK_PHY_TEST_PATTERN)) { - DRM_DEBUG_DP("no phy test\n"); + drm_dbg_dp(link->drm_dev, "no phy test\n"); return -EINVAL; } @@ -907,11 +915,13 @@ static int dp_link_process_phy_test_pattern_request( return -EINVAL; } - DRM_DEBUG_DP("Current: rate = 0x%x, lane count = 0x%x\n", + drm_dbg_dp(link->drm_dev, + "Current: rate = 0x%x, lane count = 0x%x\n", link->dp_link.link_params.rate, link->dp_link.link_params.num_lanes); - DRM_DEBUG_DP("Requested: rate = 0x%x, lane count = 0x%x\n", + drm_dbg_dp(link->drm_dev, + "Requested: rate = 0x%x, lane count = 0x%x\n", link->request.test_link_rate, link->request.test_lane_count); @@ -942,17 +952,18 @@ static u8 get_link_status(const u8 link_status[DP_LINK_STATUS_SIZE], int r) */ static int dp_link_process_link_status_update(struct dp_link_private *link) { - bool channel_eq_done = drm_dp_channel_eq_ok(link->link_status, - link->dp_link.link_params.num_lanes); + bool channel_eq_done = drm_dp_channel_eq_ok(link->link_status, + link->dp_link.link_params.num_lanes); - bool clock_recovery_done = drm_dp_clock_recovery_ok(link->link_status, - link->dp_link.link_params.num_lanes); + bool clock_recovery_done = drm_dp_clock_recovery_ok(link->link_status, + link->dp_link.link_params.num_lanes); - DRM_DEBUG_DP("channel_eq_done = %d, clock_recovery_done = %d\n", + drm_dbg_dp(link->drm_dev, + "channel_eq_done = %d, clock_recovery_done = %d\n", channel_eq_done, clock_recovery_done); - if (channel_eq_done && clock_recovery_done) - return -EINVAL; + if (channel_eq_done && clock_recovery_done) + return -EINVAL; return 0; @@ -1058,7 +1069,8 @@ int dp_link_process_request(struct dp_link *dp_link) } } - DRM_DEBUG_DP("sink request=%#x", dp_link->sink_request); + drm_dbg_dp(link->drm_dev, "sink request=%#x", + dp_link->sink_request); return ret; } @@ -1090,18 +1102,22 @@ int dp_link_adjust_levels(struct dp_link *dp_link, u8 *link_status) { int i; int v_max = 0, p_max = 0; + struct dp_link_private *link; if (!dp_link) { DRM_ERROR("invalid input\n"); return -EINVAL; } + link = container_of(dp_link, struct dp_link_private, dp_link); + /* use the max level across lanes */ for (i = 0; i < dp_link->link_params.num_lanes; i++) { u8 data_v = drm_dp_get_adjust_request_voltage(link_status, i); u8 data_p = drm_dp_get_adjust_request_pre_emphasis(link_status, i); - DRM_DEBUG_DP("lane=%d req_vol_swing=%d req_pre_emphasis=%d\n", + drm_dbg_dp(link->drm_dev, + "lane=%d req_vol_swing=%d req_pre_emphasis=%d\n", i, data_v, data_p); if (v_max < data_v) v_max = data_v; @@ -1117,14 +1133,16 @@ int dp_link_adjust_levels(struct dp_link *dp_link, u8 *link_status) * the allowable range. */ if (dp_link->phy_params.v_level > DP_TRAIN_VOLTAGE_SWING_MAX) { - DRM_DEBUG_DP("Requested vSwingLevel=%d, change to %d\n", + drm_dbg_dp(link->drm_dev, + "Requested vSwingLevel=%d, change to %d\n", dp_link->phy_params.v_level, DP_TRAIN_VOLTAGE_SWING_MAX); dp_link->phy_params.v_level = DP_TRAIN_VOLTAGE_SWING_MAX; } if (dp_link->phy_params.p_level > DP_TRAIN_PRE_EMPHASIS_MAX) { - DRM_DEBUG_DP("Requested preEmphasisLevel=%d, change to %d\n", + drm_dbg_dp(link->drm_dev, + "Requested preEmphasisLevel=%d, change to %d\n", dp_link->phy_params.p_level, DP_TRAIN_PRE_EMPHASIS_MAX); dp_link->phy_params.p_level = DP_TRAIN_PRE_EMPHASIS_MAX; @@ -1133,13 +1151,14 @@ int dp_link_adjust_levels(struct dp_link *dp_link, u8 *link_status) if ((dp_link->phy_params.p_level > DP_TRAIN_PRE_EMPHASIS_LVL_1) && (dp_link->phy_params.v_level == DP_TRAIN_VOLTAGE_SWING_LVL_2)) { - DRM_DEBUG_DP("Requested preEmphasisLevel=%d, change to %d\n", + drm_dbg_dp(link->drm_dev, + "Requested preEmphasisLevel=%d, change to %d\n", dp_link->phy_params.p_level, DP_TRAIN_PRE_EMPHASIS_LVL_1); dp_link->phy_params.p_level = DP_TRAIN_PRE_EMPHASIS_LVL_1; } - DRM_DEBUG_DP("adjusted: v_level=%d, p_level=%d\n", + drm_dbg_dp(link->drm_dev, "adjusted: v_level=%d, p_level=%d\n", dp_link->phy_params.v_level, dp_link->phy_params.p_level); return 0; |