1 /* 2 * Copyright 2012-2016, 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("dp_common: " x) 17 #else 18 # define TRACE(x...) ; 19 #endif 20 21 #define ERROR(x...) _sPrintf("dp_common: " 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! (0x%" B_PRIX32 ")\n", 40 __func__, linkRate); 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! (0x%" B_PRIX32 ")\n", 57 __func__, rawLinkRate); 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