summaryrefslogtreecommitdiff
path: root/src/mainboard/system76/bonw14/acpi/dgpu.asl
blob: d7349ef7f8ec674526c72fbaa9844f1335a7d664 (plain)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* SPDX-License-Identifier: GPL-2.0-only */

Device (\_SB.PCI0.PEG0)
{
	Name (_ADR, 0x00010000)

	Device (PEGP)
	{
		Name (_ADR, 0)

		// Convert a byte to a hex string, trimming extra parts
		Method (BHEX, 1)
		{
			Local0 = ToHexString(Arg0)
			Return (Mid(Local0, SizeOf(Local0) - 2, 2))
		}

		// UUID to string
		Method (IDST, 1)
		{
			Local0 = ""
			Fprintf(
				Local0,
				"%o%o%o%o-%o%o-%o%o-%o%o-%o%o%o%o%o%o",
				BHEX(DerefOf(Arg0[3])),
				BHEX(DerefOf(Arg0[2])),
				BHEX(DerefOf(Arg0[1])),
				BHEX(DerefOf(Arg0[0])),
				BHEX(DerefOf(Arg0[5])),
				BHEX(DerefOf(Arg0[4])),
				BHEX(DerefOf(Arg0[7])),
				BHEX(DerefOf(Arg0[6])),
				BHEX(DerefOf(Arg0[8])),
				BHEX(DerefOf(Arg0[9])),
				BHEX(DerefOf(Arg0[10])),
				BHEX(DerefOf(Arg0[11])),
				BHEX(DerefOf(Arg0[12])),
				BHEX(DerefOf(Arg0[13])),
				BHEX(DerefOf(Arg0[14])),
				BHEX(DerefOf(Arg0[15]))
			)
			Return (Local0)
		}

		// Safe hex conversion, checks type first
		Method (SFST, 1)
		{
			Local0 = ObjectType(Arg0)
			If (Local0 == 1 || Local0 == 2 || Local0 == 3) {
				Return (ToHexString(Arg0))
			} Else {
				Return (Concatenate("Type: ", Arg0))
			}
		}

		Method (_DSM, 4, Serialized)
		{
			Printf("NVIDIA _DSM")
			Printf("  Arg0: %o", IDST(Arg0))
			Printf("  Arg1: %o", SFST(Arg1))
			Printf("  Arg2: %o", SFST(Arg2))
			Printf("  Arg3: %o", SFST(Arg3))

			If (Arg0 == ToUUID ("d4a50b75-65c7-46f7-bfb7-41514cea0244")) {
				If (Arg1 != 0x0102) {
					Printf("  Invalid Arg1, return 0x80000002")
					Return (0x80000002)
				}

				If (Arg2 == 0) {
					Printf("  Arg2 == 0x00, return supported functions")
					Return (Buffer (4) { 0x01, 0x00, 0x10, 0x00 })
				}

				If (Arg2 == 0x14) {
					Printf("  Arg2 == 0x14, return backlight package")
					Return (Package (9) {
						0x8000A450,
						0x0200,
						0,
						0,
						1,
						1,
						200,
						32,
						1000
					})
				}

				Printf("  Unknown Arg2, return 0x80000002")
				Return (0x80000002)
			}

			Printf("  Unknown Arg0, return 0x80000001")
			Return (0x80000001)
		}

		// _DOD: Display Output Devices
		Method (_DOD, 0, NotSerialized)
		{
			Return (Package (3) {
				0x80008320,
				0x80006330,
				0x8000A450
			})
		}

		Device (HDM0)
		{
			Name (_ADR, 0x80008320)
		}

		Device (DSP0)
		{
			Name (_ADR, 0x80006330)
		}

		Device (DSP1)
		{
			Name (_ADR, 0x8000A450)
		}
	}
}