blob: 534c0d8e108bfeac02538630a4bd92184c0a06b9 [file] [log] [blame]
Nico Huber53ec8c52020-03-21 19:50:26 +01001/* SPDX-License-Identifier: GPL-2.0-or-later */
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +01002
Furquan Shaikh76cedd22020-05-02 10:24:23 -07003#include <acpi/acpigen.h>
Elyes Haouasbdd03c22024-05-27 11:20:07 +02004#include <stdio.h>
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +01005#include <string.h>
6#include "i915.h"
7
8void
9drivers_intel_gma_displays_ssdt_generate(const struct i915_gpu_controller_info *conf)
10{
11 size_t i;
12 const char *names[] = { "UNK", "VGA", "TV", "DVI", "LCD" };
Nico Huberbed7ad92020-03-21 19:09:45 +010013 int counters[ARRAY_SIZE(names)] = { 0 };
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010014
Nico Huber38641aa2020-03-31 17:51:18 +020015 if (!conf->ndid)
16 return;
17
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010018 acpigen_write_scope("\\_SB.PCI0.GFX0");
19
20 /*
Nico Huber53c17172020-03-21 18:47:24 +010021 Method (_DOD, 0)
22 {
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010023 Return (Package() {
24 0x5a5a5a5a,
25 0x5a5a5a5a,
26 0x5a5a5a5a
27 })
Nico Huber53c17172020-03-21 18:47:24 +010028 }
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010029 */
30 acpigen_write_method("_DOD", 0);
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010031
Nico Huber53c17172020-03-21 18:47:24 +010032 acpigen_emit_byte(RETURN_OP);
33 acpigen_write_package(conf->ndid);
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010034 for (i = 0; i < conf->ndid; i++) {
Elyes Haouas34677042023-08-26 16:42:11 +020035 acpigen_write_dword(conf->did[i] | 0x80010000);
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010036 }
37 acpigen_pop_len(); /* End Package. */
Nico Huber53c17172020-03-21 18:47:24 +010038
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010039 acpigen_pop_len(); /* End Method. */
40
41 for (i = 0; i < conf->ndid; i++) {
Nico Huberc0be4102020-03-21 18:52:14 +010042 char name[5];
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010043 int kind;
Nico Huber53c17172020-03-21 18:47:24 +010044
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010045 kind = (conf->did[i] >> 8) & 0xf;
46 if (kind >= ARRAY_SIZE(names)) {
47 kind = 0;
48 }
Nico Huber53c17172020-03-21 18:47:24 +010049
Nico Huberc0be4102020-03-21 18:52:14 +010050 snprintf(name, sizeof(name), "%s%d", names[kind], counters[kind]);
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010051 counters[kind]++;
Nico Huber53c17172020-03-21 18:47:24 +010052
53 /* Device (LCD0) */
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010054 acpigen_write_device(name);
Nico Huber53c17172020-03-21 18:47:24 +010055
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010056 /* Name (_ADR, 0x0410) */
57 acpigen_write_name_dword("_ADR", conf->did[i] & 0xffff);
58
59 /* ACPI brightness for LCD. */
60 if (kind == 4) {
61 /*
62 Method (_BCL, 0, NotSerialized)
63 {
Elyes HAOUAS0d8f1da2018-05-28 15:48:04 +020064 Return (^^XBCL())
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010065 }
66 */
67 acpigen_write_method("_BCL", 0);
Nico Huber53c17172020-03-21 18:47:24 +010068 acpigen_emit_byte(RETURN_OP);
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010069 acpigen_emit_namestring("^^XBCL");
70 acpigen_pop_len();
71
72 /*
73 Method (_BCM, 1, NotSerialized)
74 {
Elyes HAOUAS0d8f1da2018-05-28 15:48:04 +020075 ^^XBCM(Arg0)
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010076 }
77 */
78 acpigen_write_method("_BCM", 1);
79 acpigen_emit_namestring("^^XBCM");
Nico Huber53c17172020-03-21 18:47:24 +010080 acpigen_emit_byte(ARG0_OP);
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010081 acpigen_pop_len();
82
83 /*
84 Method (_BQC, 0, NotSerialized)
85 {
Elyes HAOUAS0d8f1da2018-05-28 15:48:04 +020086 Return (^^XBQC())
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010087 }
88 */
89 acpigen_write_method("_BQC", 0);
Nico Huber53c17172020-03-21 18:47:24 +010090 acpigen_emit_byte(RETURN_OP);
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010091 acpigen_emit_namestring("^^XBQC");
92 acpigen_pop_len();
93 }
94
95 /*
Nico Hubere98f6af2020-03-21 18:40:03 +010096 * _DCS, _DGS and _DSS are required by specification. However,
97 * we never implemented them properly, and no OS driver com-
98 * plained yet. So we stub them out and keep the traditional
99 * behavior in case an OS driver checks for their existence.
100 */
101
102 /*
103 Method(_DCS, 0)
104 {
105 Return (0x1d)
106 }
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +0100107 */
108 acpigen_write_method("_DCS", 0);
Nico Hubere98f6af2020-03-21 18:40:03 +0100109 acpigen_write_return_integer(0x1d);
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +0100110 acpigen_pop_len();
111
112 /*
Nico Hubere98f6af2020-03-21 18:40:03 +0100113 Method(_DGS, 0)
114 {
115 Return (0)
116 }
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +0100117 */
118 acpigen_write_method("_DGS", 0);
Nico Hubere98f6af2020-03-21 18:40:03 +0100119 acpigen_write_return_integer(0);
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +0100120 acpigen_pop_len();
121
122 /*
Nico Hubere98f6af2020-03-21 18:40:03 +0100123 Method(_DSS, 1)
124 {
125 }
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +0100126 */
Matt DeVillier17b1a692017-05-27 17:49:21 -0500127 acpigen_write_method("_DSS", 1);
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +0100128 acpigen_pop_len();
129
Nico Huber53c17172020-03-21 18:47:24 +0100130 acpigen_pop_len(); /* End Device. */
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +0100131 }
132
Nico Huber53c17172020-03-21 18:47:24 +0100133 acpigen_pop_len(); /* End Scope. */
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +0100134}