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