coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
acpi.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <acpi/acpigen.h>
4 #include <string.h>
5 #include "i915.h"
6 
7 void
9 {
10  size_t i;
11  const char *names[] = { "UNK", "VGA", "TV", "DVI", "LCD" };
12  int counters[ARRAY_SIZE(names)] = { 0 };
13 
14  if (!conf->ndid)
15  return;
16 
17  acpigen_write_scope("\\_SB.PCI0.GFX0");
18 
19  /*
20  Method (_DOD, 0)
21  {
22  Return (Package() {
23  0x5a5a5a5a,
24  0x5a5a5a5a,
25  0x5a5a5a5a
26  })
27  }
28  */
29  acpigen_write_method("_DOD", 0);
30 
33  for (i = 0; i < conf->ndid; i++) {
34  acpigen_write_dword (conf->did[i] | 0x80010000);
35  }
36  acpigen_pop_len(); /* End Package. */
37 
38  acpigen_pop_len(); /* End Method. */
39 
40  for (i = 0; i < conf->ndid; i++) {
41  char name[5];
42  int kind;
43 
44  kind = (conf->did[i] >> 8) & 0xf;
45  if (kind >= ARRAY_SIZE(names)) {
46  kind = 0;
47  }
48 
49  snprintf(name, sizeof(name), "%s%d", names[kind], counters[kind]);
50  counters[kind]++;
51 
52  /* Device (LCD0) */
54 
55  /* Name (_ADR, 0x0410) */
56  acpigen_write_name_dword("_ADR", conf->did[i] & 0xffff);
57 
58  /* ACPI brightness for LCD. */
59  if (kind == 4) {
60  /*
61  Method (_BCL, 0, NotSerialized)
62  {
63  Return (^^XBCL())
64  }
65  */
66  acpigen_write_method("_BCL", 0);
68  acpigen_emit_namestring("^^XBCL");
70 
71  /*
72  Method (_BCM, 1, NotSerialized)
73  {
74  ^^XBCM(Arg0)
75  }
76  */
77  acpigen_write_method("_BCM", 1);
78  acpigen_emit_namestring("^^XBCM");
81 
82  /*
83  Method (_BQC, 0, NotSerialized)
84  {
85  Return (^^XBQC())
86  }
87  */
88  acpigen_write_method("_BQC", 0);
90  acpigen_emit_namestring("^^XBQC");
92  }
93 
94  /*
95  * _DCS, _DGS and _DSS are required by specification. However,
96  * we never implemented them properly, and no OS driver com-
97  * plained yet. So we stub them out and keep the traditional
98  * behavior in case an OS driver checks for their existence.
99  */
100 
101  /*
102  Method(_DCS, 0)
103  {
104  Return (0x1d)
105  }
106  */
107  acpigen_write_method("_DCS", 0);
109  acpigen_pop_len();
110 
111  /*
112  Method(_DGS, 0)
113  {
114  Return (0)
115  }
116  */
117  acpigen_write_method("_DGS", 0);
119  acpigen_pop_len();
120 
121  /*
122  Method(_DSS, 1)
123  {
124  }
125  */
126  acpigen_write_method("_DSS", 1);
127  acpigen_pop_len();
128 
129  acpigen_pop_len(); /* End Device. */
130  }
131 
132  acpigen_pop_len(); /* End Scope. */
133 }
void acpigen_write_dword(unsigned int data)
Definition: acpigen.c:108
void acpigen_emit_namestring(const char *namepath)
Definition: acpigen.c:275
void acpigen_write_return_integer(uint64_t arg)
Definition: acpigen.c:1583
void acpigen_pop_len(void)
Definition: acpigen.c:37
void acpigen_write_scope(const char *name)
Definition: acpigen.c:326
char * acpigen_write_package(int nr_el)
Definition: acpigen.c:86
void acpigen_emit_byte(unsigned char b)
Definition: acpigen.c:61
void acpigen_write_name_dword(const char *name, uint32_t val)
Definition: acpigen.c:158
void acpigen_write_device(const char *name)
Definition: acpigen.c:769
void acpigen_write_method(const char *name, int nargs)
Definition: acpigen.c:758
const char * name
Definition: mmu.c:92
#define ARRAY_SIZE(a)
Definition: helpers.h:12
void drivers_intel_gma_displays_ssdt_generate(const struct i915_gpu_controller_info *conf)
Definition: acpi.c:8
@ ARG0_OP
Definition: acpigen.h:89
@ RETURN_OP
Definition: acpigen.h:146
int snprintf(char *buf, size_t size, const char *fmt,...)
Note: This file is only for POSIX compatibility, and is meant to be chain-included via string....
Definition: vsprintf.c:35