1 /* 2 * Copyright 2012, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Alexander von Gluck, kallisti5@unixzen.com 7 */ 8 9 10 #include "dp.h" 11 12 13 #define TRACE_DISPLAY 14 #ifdef TRACE_DISPLAY 15 extern "C" void _sPrintf(const char* format, ...); 16 # define TRACE(x...) _sPrintf("radeon_hd: " x) 17 #else 18 # define TRACE(x...) ; 19 #endif 20 21 #define ERROR(x...) _sPrintf("radeon_hd: " x) 22 23 24 uint32 25 dp_encode_link_rate(uint32 linkRate) 26 { 27 switch (linkRate) { 28 case 162000: 29 // 1.62 Ghz 30 return DP_LINK_RATE_162; 31 case 270000: 32 // 2.7 Ghz 33 return DP_LINK_RATE_270; 34 case 540000: 35 // 5.4 Ghz 36 return DP_LINK_RATE_540; 37 } 38 39 ERROR("%s: Unknown DisplayPort Link Rate!\n", 40 __func__); 41 return DP_LINK_RATE_162; 42 } 43 44 45 uint32 46 dp_decode_link_rate(uint32 rawLinkRate) 47 { 48 switch (rawLinkRate) { 49 case DP_LINK_RATE_162: 50 return 162000; 51 case DP_LINK_RATE_270: 52 return 270000; 53 case DP_LINK_RATE_540: 54 return 540000; 55 } 56 ERROR("%s: Unknown DisplayPort Link Rate!\n", 57 __func__); 58 return 162000; 59 } 60 61 62 uint32 63 dp_get_pixel_clock_max(int linkRate, int laneCount, int bpp) 64 { 65 return (linkRate * laneCount * 8) / bpp; 66 } 67 68 69 uint32 70 dp_get_link_rate_max(dp_info* dpInfo) 71 { 72 return dp_decode_link_rate(dpInfo->config[DP_MAX_LINK_RATE]); 73 } 74 75 76 uint32 77 dp_get_lane_count_max(dp_info* dpInfo) 78 { 79 return dpInfo->config[DP_MAX_LANE_COUNT] & DP_MAX_LANE_COUNT_MASK; 80 } 81