Repository navigation
Expand file tree
/
Copy pathsmc.c
More file actions
85 lines (69 loc) · 1.72 KB
/
Copy pathsmc.c
File metadata and controls
85 lines (69 loc) · 1.72 KB
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
81
82
83
84
85
/* SPDX-License-Identifier: MIT */
#include <boot2target.h>
EFI_GUID gAppleSmcIoProtocolGuid = APPLE_SMC_IO_PROTOCOL_GUID;
#define SMC_KEY_MVHR SMC_MAKE_KEY('M', 'V', 'H', 'R') /* SMC enable key */
#define SMC_KEY_MVMR SMC_MAKE_KEY('M', 'V', 'M', 'R') /* Display reset key */
#define SMC_KEY_MVMS SMC_MAKE_KEY('M', 'V', 'M', 'S') /* Cable connect toggle: 3 = disconnected, 6 or 8 = connected */
EFI_STATUS TdmIsCableConnected(
APPLE_SMC_IO_PROTOCOL *SmcIo,
BOOLEAN *IsConnected
)
{
EFI_STATUS Status;
SMC_DATA Value;
Status = SmcIo->SmcReadValue(
SmcIo,
SMC_KEY_MVMS,
sizeof(Value),
&Value
);
if (EFI_ERROR(Status))
{
printf("Cannot read cable connection value!\n");
*IsConnected = FALSE;
return Status;
}
*IsConnected = (Value != 3) ? TRUE : FALSE;
return EFI_SUCCESS;
}
EFI_STATUS TdmToggle(
APPLE_SMC_IO_PROTOCOL *SmcIo,
BOOLEAN Enable
)
{
EFI_STATUS Status;
SMC_DATA Value;
Value = (SMC_DATA) Enable;
Status = SmcIo->SmcWriteValue(
SmcIo,
SMC_KEY_MVHR,
sizeof(Value),
&Value
);
if (EFI_ERROR(Status))
{
printf("Cannot send enable/disable to MVHR!\n");
return Status;
}
return EFI_SUCCESS;
}
EFI_STATUS TdmResetLcd(
APPLE_SMC_IO_PROTOCOL *SmcIo
)
{
EFI_STATUS Status;
SMC_DATA Value;
Value = 2;
Status = SmcIo->SmcWriteValue(
SmcIo,
SMC_KEY_MVMR,
sizeof(Value),
&Value
);
if (EFI_ERROR(Status))
{
printf("Cannot send reset command to MVMR!\n");
return Status;
}
return EFI_SUCCESS;
}