diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-10-18 04:15:24 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-10-22 16:23:36 -0400 |
commit | 1ffdff134eb2d943bde3e4901ac48a9656a7e7a5 (patch) | |
tree | a173f28a4d7f9b961645ed16f64857cf734b8113 /drivers/gpu/drm/drm_dp_helper.c | |
parent | 00ae9a456dd9a3e26db2265c0d25dec0d1e74b07 (diff) |
drm: dp helper: extract drm_dp_channel_eq_ok
radeon and intel use the exact same definition.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Dave Airlie <airlied@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/drm_dp_helper.c')
-rw-r--r-- | drivers/gpu/drm/drm_dp_helper.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index bb4eaf60117f..1378b789bd10 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c | |||
@@ -205,3 +205,53 @@ i2c_dp_aux_add_bus(struct i2c_adapter *adapter) | |||
205 | return error; | 205 | return error; |
206 | } | 206 | } |
207 | EXPORT_SYMBOL(i2c_dp_aux_add_bus); | 207 | EXPORT_SYMBOL(i2c_dp_aux_add_bus); |
208 | |||
209 | /* Helpers for DP link training */ | ||
210 | static u8 dp_link_status(u8 link_status[DP_LINK_STATUS_SIZE], int r) | ||
211 | { | ||
212 | return link_status[r - DP_LANE0_1_STATUS]; | ||
213 | } | ||
214 | |||
215 | static u8 dp_get_lane_status(u8 link_status[DP_LINK_STATUS_SIZE], | ||
216 | int lane) | ||
217 | { | ||
218 | int i = DP_LANE0_1_STATUS + (lane >> 1); | ||
219 | int s = (lane & 1) * 4; | ||
220 | u8 l = dp_link_status(link_status, i); | ||
221 | return (l >> s) & 0xf; | ||
222 | } | ||
223 | |||
224 | bool drm_dp_channel_eq_ok(u8 link_status[DP_LINK_STATUS_SIZE], | ||
225 | int lane_count) | ||
226 | { | ||
227 | u8 lane_align; | ||
228 | u8 lane_status; | ||
229 | int lane; | ||
230 | |||
231 | lane_align = dp_link_status(link_status, | ||
232 | DP_LANE_ALIGN_STATUS_UPDATED); | ||
233 | if ((lane_align & DP_INTERLANE_ALIGN_DONE) == 0) | ||
234 | return false; | ||
235 | for (lane = 0; lane < lane_count; lane++) { | ||
236 | lane_status = dp_get_lane_status(link_status, lane); | ||
237 | if ((lane_status & DP_CHANNEL_EQ_BITS) != DP_CHANNEL_EQ_BITS) | ||
238 | return false; | ||
239 | } | ||
240 | return true; | ||
241 | } | ||
242 | EXPORT_SYMBOL(drm_dp_channel_eq_ok); | ||
243 | |||
244 | bool drm_dp_clock_recovery_ok(u8 link_status[DP_LINK_STATUS_SIZE], | ||
245 | int lane_count) | ||
246 | { | ||
247 | int lane; | ||
248 | u8 lane_status; | ||
249 | |||
250 | for (lane = 0; lane < lane_count; lane++) { | ||
251 | lane_status = dp_get_lane_status(link_status, lane); | ||
252 | if ((lane_status & DP_LANE_CR_DONE) == 0) | ||
253 | return false; | ||
254 | } | ||
255 | return true; | ||
256 | } | ||
257 | EXPORT_SYMBOL(drm_dp_clock_recovery_ok); | ||