summaryrefslogtreecommitdiff
path: root/src/mainboard/purism/librem_jsl/acpi/vbtn.asl
blob: 3cca8a350249dfe8fef444c78de19b579779ae5e (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
/* SPDX-License-Identifier: GPL-2.0-only */
Name (FLAP, 0x40) /* Flag indicating device is in laptop mode */

/* Virtual events */
Name (VTBL, 0xcc) /* Tablet Mode */
Name (VLAP, 0xcd) /* Laptop Mode */

Device (VBTN)
{
	Name (_HID, "INT33D6")
	Name (_UID, 1)
	Name (_DDN, "Intel Virtual Button Driver")

	/*
	 * This method is called at driver probe time and must exist or
	 * the driver will not load.
	 */
	Method (VBDL)
	{
	}

	/*
	 * This method returns flags indicating tablet and dock modes.
	 * It is called at driver probe time so the OS knows what the
	 * state of the device is at boot.
	 */
	Method (VGBS)
	{
		Local0 = 0
		If (CKLP ()) {
			Local0 |= ^^FLAP
		}
		Return (Local0)
	}

	Method (_STA, 0)
	{
		Return (0xF)
	}

	Method (CKLP, 0)
	{
		/* 120 = GPP_D4 */
		If (\_SB.PCI0.GRXS (120)) {
			Printf ("VBTN: tablet mode")
			Return (0)	/* Tablet mode */
		} Else {
			Printf ("VBTN: laptop mode")
			Return (1)	/* Laptop mode */
		}
	}

	Method (NTFY, 0)
	{
		/* Notify the new state */
		If (CKLP ()) {
			Notify (^^VBTN, ^^VLAP)
		} Else {
			Notify (^^VBTN, ^^VTBL)
		}
	}
}