[haiku-commits] haiku: hrev44470 - src/add-ons/accelerants/radeon_hd headers/private/graphics/common

  • From: kallisti5@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 5 Aug 2012 07:02:15 +0200 (CEST)

hrev44470 adds 1 changeset to branch 'master'
old head: 9b008d31ffa35bb2c98bb2accf83e16fb7f2f9ad
new head: 694eca3bb6f6e24fd64db71bb06d95d545e1d009

----------------------------------------------------------------------------

694eca3: radeon_hd: Add DP link_train_ce
  
  * First attempts at DisplayPort link training
    clock equalization.
  * Add DP define to detect equalization state
  * Working towards resolving #8626

                          [ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev44470
Commit:      694eca3bb6f6e24fd64db71bb06d95d545e1d009
URL:         http://cgit.haiku-os.org/haiku/commit/?id=694eca3
Author:      Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date:        Sun Aug  5 05:01:43 2012 UTC

Ticket:      https://dev.haiku-os.org/ticket/8626

----------------------------------------------------------------------------

3 files changed, 81 insertions(+), 1 deletion(-)
headers/private/graphics/common/dp_raw.h          |    6 ++
src/add-ons/accelerants/radeon_hd/displayport.cpp |   75 ++++++++++++++++-
src/add-ons/accelerants/radeon_hd/displayport.h   |    1 +

----------------------------------------------------------------------------

diff --git a/headers/private/graphics/common/dp_raw.h 
b/headers/private/graphics/common/dp_raw.h
index 556c1b1..6673ef5 100644
--- a/headers/private/graphics/common/dp_raw.h
+++ b/headers/private/graphics/common/dp_raw.h
@@ -168,6 +168,12 @@
 #define DP_LANE_STATUS_CR_DONE_B                       (1 << 4)        // Bool
 #define DP_LANE_STATUS_CHEQ_DONE_B                     (1 << 5)        // Bool
 #define DP_LANE_STATUS_SYMB_LOCK_B                     (1 << 6)        // Bool
+#define DP_LANE_STATUS_EQUALIZED_A                     
DP_LANE_STATUS_CR_DONE_A \
+                                                                               
        || DP_LANE_STATUS_CHEQ_DONE_A \
+                                                                               
        || DP_LANE_STATUS_SYMB_LOCK_A
+#define DP_LANE_STATUS_EQUALIZED_B                     
DP_LANE_STATUS_CR_DONE_B \
+                                                                               
        || DP_LANE_STATUS_CHEQ_DONE_B \
+                                                                               
        || DP_LANE_STATUS_SYMB_LOCK_B
 // DP Lane Align Status (0x0204)
 #define DP_LANE_ALIGN                                          0x0204          
// Reg
 #define DP_LANE_ALIGN_DONE                                     (1 << 0)        
// Bool
diff --git a/src/add-ons/accelerants/radeon_hd/displayport.cpp 
b/src/add-ons/accelerants/radeon_hd/displayport.cpp
index ec3bb93..0efa525 100644
--- a/src/add-ons/accelerants/radeon_hd/displayport.cpp
+++ b/src/add-ons/accelerants/radeon_hd/displayport.cpp
@@ -410,6 +410,27 @@ dp_clock_recovery_ok(dp_info* dp)
 }
 
 
+static bool
+dp_clock_equalization_ok(dp_info* dp)
+{
+       uint8 laneAlignment
+               = dp->linkStatus[DP_LANE_ALIGN - DP_LANE_STATUS_0_1];
+
+       if ((laneAlignment & DP_LANE_ALIGN_DONE) == 0)
+               return false;
+
+       int lane;
+       for (lane = 0; lane < dp->laneCount; lane++) {
+               uint8 laneStatus = dp_get_lane_status(dp, lane);
+               if ((laneStatus & DP_LANE_STATUS_EQUALIZED_A)
+                       != DP_LANE_STATUS_EQUALIZED_A) {
+                       return false;
+               }
+       }
+       return true;
+}
+
+
 static void
 dp_update_vs_emph(uint32 connectorIndex)
 {
@@ -613,6 +634,58 @@ dp_link_train_cr(uint32 connectorIndex)
 
 
 status_t
+dp_link_train_ce(uint32 connectorIndex)
+{
+       TRACE("%s\n", __func__);
+
+       dp_info* dp = &gConnector[connectorIndex]->dpInfo;
+
+       // TODO: DisplayPort: Supports TP3?
+       dp_set_tp(connectorIndex, DP_TRAIN_PATTERN_2);
+
+       dp->trainingAttempts = 0;
+       bool channelEqual = false;
+
+       while (1) {
+               if (dp->trainingReadInterval == 0)
+                       snooze(100);
+               else
+                       snooze(1000 * 4 * dp->trainingReadInterval);
+
+               if (!dp_get_link_status(dp))
+                       break;
+
+               if (dp_clock_equalization_ok(dp)) {
+                       channelEqual = true;
+                       break;
+               }
+
+               if (dp->trainingAttempts > 5) {
+                       ERROR("%s: ERROR: failed > 5 times!\n", __func__);
+                       break;
+               }
+
+               dp_get_adjust_train(dp);
+
+               dp_update_vs_emph(connectorIndex);
+               dp->trainingAttempts++;
+       }
+
+       if (!channelEqual) {
+               ERROR("%s: ERROR: failed\n", __func__);
+               return B_ERROR;
+       }
+
+       TRACE("%s: channels equalized at voltage %d pre-emphasis %d\n",
+               __func__, dp->trainingSet[0] & DP_ADJ_VCC_SWING_LANEA_MASK,
+               (dp->trainingSet[0] & DP_TRAIN_PRE_EMPHASIS_MASK)
+               >> DP_TRAIN_PRE_EMPHASIS_SHIFT);
+
+       return B_OK;
+}
+
+
+status_t
 dp_link_train(uint8 crtcID, display_mode* mode)
 {
        TRACE("%s\n", __func__);
@@ -702,7 +775,7 @@ dp_link_train(uint8 crtcID, display_mode* mode)
        dpcd_reg_write(hwPin, DP_TRAIN, DP_TRAIN_PATTERN_DISABLED);
 
        dp_link_train_cr(connectorIndex);
-       // TODO: dp_link_train_ce
+       dp_link_train_ce(connectorIndex);
 
 
        // *** DisplayPort link training finish
diff --git a/src/add-ons/accelerants/radeon_hd/displayport.h 
b/src/add-ons/accelerants/radeon_hd/displayport.h
index ebf06fb..570934a 100644
--- a/src/add-ons/accelerants/radeon_hd/displayport.h
+++ b/src/add-ons/accelerants/radeon_hd/displayport.h
@@ -37,6 +37,7 @@ void dp_setup_connectors();
 
 status_t dp_link_train(uint8 crtcID, display_mode* mode);
 status_t dp_link_train_cr(uint32 connectorIndex);
+status_t dp_link_train_ce(uint32 connectorIndex);
 
 
 #endif /* RADEON_HD_DISPLAYPORT_H */


Other related posts:

  • » [haiku-commits] haiku: hrev44470 - src/add-ons/accelerants/radeon_hd headers/private/graphics/common - kallisti5