Debian Codegraph @

src/include/acpi/acpi_pld.h

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #ifndef __ACPI_ACPI_PLD_H__
4 #define __ACPI_ACPI_PLD_H__
5
6 #include <acpi/acpi.h>
7 #include <stdint.h>
8
9 enum acpi_pld_panel {
10 PLD_PANEL_TOP,
11 PLD_PANEL_BOTTOM,
12 PLD_PANEL_LEFT,
13 PLD_PANEL_RIGHT,
14 PLD_PANEL_FRONT,
15 PLD_PANEL_BACK,
16 PLD_PANEL_UNKNOWN
17 };
18
19 enum acpi_pld_vertical_position {
20 PLD_VERTICAL_POSITION_UPPER,
21 PLD_VERTICAL_POSITION_CENTER,
22 PLD_VERTICAL_POSITION_LOWER
23 };
24
25 enum acpi_pld_horizontal_position {
26 PLD_HORIZONTAL_POSITION_LEFT,
27 PLD_HORIZONTAL_POSITION_CENTER,
28 PLD_HORIZONTAL_POSITION_RIGHT
29 };
30
31 enum acpi_pld_shape {
32 PLD_SHAPE_ROUND,
33 PLD_SHAPE_OVAL,
34 PLD_SHAPE_SQUARE,
35 PLD_SHAPE_VERTICAL_RECTANGLE,
36 PLD_SHAPE_HORIZONTAL_RECTANGLE,
37 PLD_SHAPE_VERTICAL_TRAPEZOID,
38 PLD_SHAPE_HORIZONTAL_TRAPEZOID,
39 PLD_SHAPE_UNKNOWN,
40 PLD_SHAPE_CHAMFERED
41 };
42
43 enum acpi_pld_orientation {
44 PLD_ORIENTATION_HORIZONTAL,
45 PLD_ORIENTATION_VERTICAL,
46 };
47
48 enum acpi_pld_rotate {
49 PLD_ROTATE_0,
50 PLD_ROTATE_45,
51 PLD_ROTATE_90,
52 PLD_ROTATE_135,
53 PLD_ROTATE_180,
54 PLD_ROTATE_225,
55 PLD_ROTATE_270,
56 PLD_ROTATE_315
57 };
58
59 #define ACPI_PLD_GROUP(__token, __position) \
60 { \
61 .token = __token, \
62 .position = __position, \
63 }
64
65 /*
66 * ACPI specification 6.3 third paragraph of section 6.1.8:
67 * All Panel references (Top, Bottom, Right, Left, etc.) are interpreted
68 * as though the user is facing the front of the system.
69 *
70 * A `_PLD` describes the offset and rotation of a single device connection point
71 * from an `origin` that resides in the lower left hand corner of its Panel.
72 */
73
74 #define ACPI_PLD_TYPE_A(__panel, __horiz, __grp) \
75 { \
76 .visible = true, \
77 .panel = PLD_PANEL_##__panel, \
78 .shape = PLD_SHAPE_HORIZONTAL_RECTANGLE, \
79 .horizontal_position = PLD_HORIZONTAL_POSITION_##__horiz, \
80 .group = __grp, \
81 }
82
83 #define ACPI_PLD_TYPE_C(__panel, __horiz, __grp) \
84 { \
85 .visible = true, \
86 .panel = PLD_PANEL_##__panel, \
87 .shape = PLD_SHAPE_OVAL, \
88 .horizontal_position = PLD_HORIZONTAL_POSITION_##__horiz, \
89 .group = __grp, \
90 }
91
92 struct acpi_pld_group {
93 uint8_t token;
94 uint8_t position;
95 };
96
97 struct acpi_pld {
98 /* Color field can be explicitly ignored */
99 bool ignore_color;
100 uint8_t color_red;
101 uint8_t color_blue;
102 uint8_t color_green;
103
104 /* Port characteristics */
105 bool visible; /* Can be seen by the user */
106 bool lid; /* Port is on lid of device */
107 bool dock; /* Port is in a docking station */
108 bool bay; /* Port is in a bay */
109 bool ejectable; /* Device is ejectable, has _EJx objects */
110 bool ejectable_ospm; /* Device needs OSPM to eject */
111 uint16_t width; /* Width in mm */
112 uint16_t height; /* Height in mm */
113 uint16_t vertical_offset;
114 uint16_t horizontal_offset;
115 enum acpi_pld_panel panel;
116 enum acpi_pld_horizontal_position horizontal_position;
117 enum acpi_pld_vertical_position vertical_position;
118 enum acpi_pld_shape shape;
119 enum acpi_pld_rotate rotation;
120
121 /* Port grouping */
122 enum acpi_pld_orientation orientation;
123 struct acpi_pld_group group;
124 uint8_t draw_order;
125 uint8_t cabinet_number;
126 uint8_t card_cage_number;
127
128 /* Set if this PLD defines a reference shape */
129 bool reference_shape;
130 };
131
132 /* Fill out PLD structure with defaults based on USB port type */
133 int acpi_pld_fill_usb(struct acpi_pld *pld, enum acpi_upc_type type,
134 struct acpi_pld_group *group);
135
136 /* Turn PLD structure into a 20 byte ACPI buffer */
137 int acpi_pld_to_buffer(const struct acpi_pld *pld, uint8_t *buf, int buf_len);
138
139 #endif /* __ACPI_ACPI_PLD_H__ */