Hi Ben, These are the nouveau patches from my small dp helper refactoring that just landed in drm-next. Simply reduces the amount of magic numbers a bit, otherwise no functional changes. Due to lack of hw not really tested beyond checking that the compiler is still happy. Cheers, Daniel Daniel Vetter (3): drm/nouveau: use the cr_ok/chanel_eq_ok helpers drm/nouveau: use dp link train request helper drm/nouveau: use the new drm_dp_max_lane_count helper drivers/gpu/drm/nouveau/nouveau_dp.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) -- 1.7.11.4
Daniel Vetter
2012-Nov-21 16:03 UTC
[Nouveau] [PATCH 1/3] drm/nouveau: use the cr_ok/chanel_eq_ok helpers
Only compile-tested, due to a lack of nouveau dp hw. Should be equivalent code though. Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch> --- drivers/gpu/drm/nouveau/nouveau_dp.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c b/drivers/gpu/drm/nouveau/nouveau_dp.c index 978a108..3045a00 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dp.c +++ b/drivers/gpu/drm/nouveau/nouveau_dp.c @@ -175,7 +175,7 @@ dp_link_train_cr(struct drm_device *dev, struct dp_state *dp) { bool cr_done = false, abort = false; int voltage = dp->conf[0] & DP_TRAIN_VOLTAGE_SWING_MASK; - int tries = 0, i; + int tries = 0; dp_set_training_pattern(dev, dp, DP_TRAINING_PATTERN_1); @@ -184,16 +184,7 @@ dp_link_train_cr(struct drm_device *dev, struct dp_state *dp) dp_link_train_update(dev, dp, 100)) break; - cr_done = true; - for (i = 0; i < dp->link_nr; i++) { - u8 lane = (dp->stat[i >> 1] >> ((i & 1) * 4)) & 0xf; - if (!(lane & DP_LANE_CR_DONE)) { - cr_done = false; - if (dp->conf[i] & DP_TRAIN_MAX_SWING_REACHED) - abort = true; - break; - } - } + cr_done = drm_dp_clock_recovery_ok(dp->stat, dp->link_nr); if ((dp->conf[0] & DP_TRAIN_VOLTAGE_SWING_MASK) != voltage) { voltage = dp->conf[0] & DP_TRAIN_VOLTAGE_SWING_MASK; @@ -208,7 +199,7 @@ static int dp_link_train_eq(struct drm_device *dev, struct dp_state *dp) { bool eq_done, cr_done = true; - int tries = 0, i; + int tries = 0; dp_set_training_pattern(dev, dp, DP_TRAINING_PATTERN_2); @@ -216,15 +207,8 @@ dp_link_train_eq(struct drm_device *dev, struct dp_state *dp) if (dp_link_train_update(dev, dp, 400)) break; - eq_done = !!(dp->stat[2] & DP_INTERLANE_ALIGN_DONE); - for (i = 0; i < dp->link_nr && eq_done; i++) { - u8 lane = (dp->stat[i >> 1] >> ((i & 1) * 4)) & 0xf; - if (!(lane & DP_LANE_CR_DONE)) - cr_done = false; - if (!(lane & DP_LANE_CHANNEL_EQ_DONE) || - !(lane & DP_LANE_SYMBOL_LOCKED)) - eq_done = false; - } + eq_done = drm_dp_channel_eq_ok(dp->stat, dp->link_nr); + cr_done = drm_dp_clock_recovery_ok(dp->stat, dp->link_nr); if (dp_link_train_commit(dev, dp)) break; -- 1.7.11.4
Daniel Vetter
2012-Nov-21 16:03 UTC
[Nouveau] [PATCH 2/3] drm/nouveau: use dp link train request helper
nouveau again score with an impressive density of magic numbers. Again only compile-tested due to lack of hw, but should be equivalent code. Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch> --- drivers/gpu/drm/nouveau/nouveau_dp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c b/drivers/gpu/drm/nouveau/nouveau_dp.c index 3045a00..ed10c1d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dp.c +++ b/drivers/gpu/drm/nouveau/nouveau_dp.c @@ -137,11 +137,10 @@ dp_link_train_commit(struct drm_device *dev, struct dp_state *dp) int i; for (i = 0; i < dp->link_nr; i++) { - u8 lane = (dp->stat[4 + (i >> 1)] >> ((i & 1) * 4)) & 0xf; - u8 lpre = (lane & 0x0c) >> 2; - u8 lvsw = (lane & 0x03) >> 0; + u8 lpre = drm_dp_get_adjust_request_pre_emphasis(dp->stat, i); + u8 lvsw = drm_dp_get_adjust_request_voltage(dp->stat, i); - dp->conf[i] = (lpre << 3) | lvsw; + dp->conf[i] = lpre | lvsw; if (lvsw == DP_TRAIN_VOLTAGE_SWING_1200) dp->conf[i] |= DP_TRAIN_MAX_SWING_REACHED; if ((lpre << 3) == DP_TRAIN_PRE_EMPHASIS_9_5) -- 1.7.11.4
Daniel Vetter
2012-Nov-21 16:04 UTC
[Nouveau] [PATCH 3/3] drm/nouveau: use the new drm_dp_max_lane_count helper
Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch> --- drivers/gpu/drm/nouveau/nouveau_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c b/drivers/gpu/drm/nouveau/nouveau_dp.c index ed10c1d..437e26b 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dp.c +++ b/drivers/gpu/drm/nouveau/nouveau_dp.c @@ -411,7 +411,7 @@ nouveau_dp_detect(struct drm_encoder *encoder) return false; nv_encoder->dp.link_bw = 27000 * dpcd[1]; - nv_encoder->dp.link_nr = dpcd[2] & DP_MAX_LANE_COUNT_MASK; + nv_encoder->dp.link_nr = drm_dp_max_lane_count(dpcd); NV_DEBUG(drm, "display: %dx%d dpcd 0x%02x\n", nv_encoder->dp.link_nr, nv_encoder->dp.link_bw, dpcd[0]); -- 1.7.11.4