Nico Huber | 53ec8c5 | 2020-03-21 19:50:26 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpigen.h> |
Elyes Haouas | bdd03c2 | 2024-05-27 11:20:07 +0200 | [diff] [blame^] | 4 | #include <stdio.h> |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 5 | #include <string.h> |
| 6 | #include "i915.h" |
| 7 | |
| 8 | void |
| 9 | drivers_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 Huber | bed7ad9 | 2020-03-21 19:09:45 +0100 | [diff] [blame] | 13 | int counters[ARRAY_SIZE(names)] = { 0 }; |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 14 | |
Nico Huber | 38641aa | 2020-03-31 17:51:18 +0200 | [diff] [blame] | 15 | if (!conf->ndid) |
| 16 | return; |
| 17 | |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 18 | acpigen_write_scope("\\_SB.PCI0.GFX0"); |
| 19 | |
| 20 | /* |
Nico Huber | 53c1717 | 2020-03-21 18:47:24 +0100 | [diff] [blame] | 21 | Method (_DOD, 0) |
| 22 | { |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 23 | Return (Package() { |
| 24 | 0x5a5a5a5a, |
| 25 | 0x5a5a5a5a, |
| 26 | 0x5a5a5a5a |
| 27 | }) |
Nico Huber | 53c1717 | 2020-03-21 18:47:24 +0100 | [diff] [blame] | 28 | } |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 29 | */ |
| 30 | acpigen_write_method("_DOD", 0); |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 31 | |
Nico Huber | 53c1717 | 2020-03-21 18:47:24 +0100 | [diff] [blame] | 32 | acpigen_emit_byte(RETURN_OP); |
| 33 | acpigen_write_package(conf->ndid); |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 34 | for (i = 0; i < conf->ndid; i++) { |
Elyes Haouas | 3467704 | 2023-08-26 16:42:11 +0200 | [diff] [blame] | 35 | acpigen_write_dword(conf->did[i] | 0x80010000); |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 36 | } |
| 37 | acpigen_pop_len(); /* End Package. */ |
Nico Huber | 53c1717 | 2020-03-21 18:47:24 +0100 | [diff] [blame] | 38 | |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 39 | acpigen_pop_len(); /* End Method. */ |
| 40 | |
| 41 | for (i = 0; i < conf->ndid; i++) { |
Nico Huber | c0be410 | 2020-03-21 18:52:14 +0100 | [diff] [blame] | 42 | char name[5]; |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 43 | int kind; |
Nico Huber | 53c1717 | 2020-03-21 18:47:24 +0100 | [diff] [blame] | 44 | |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 45 | kind = (conf->did[i] >> 8) & 0xf; |
| 46 | if (kind >= ARRAY_SIZE(names)) { |
| 47 | kind = 0; |
| 48 | } |
Nico Huber | 53c1717 | 2020-03-21 18:47:24 +0100 | [diff] [blame] | 49 | |
Nico Huber | c0be410 | 2020-03-21 18:52:14 +0100 | [diff] [blame] | 50 | snprintf(name, sizeof(name), "%s%d", names[kind], counters[kind]); |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 51 | counters[kind]++; |
Nico Huber | 53c1717 | 2020-03-21 18:47:24 +0100 | [diff] [blame] | 52 | |
| 53 | /* Device (LCD0) */ |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 54 | acpigen_write_device(name); |
Nico Huber | 53c1717 | 2020-03-21 18:47:24 +0100 | [diff] [blame] | 55 | |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 56 | /* 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 HAOUAS | 0d8f1da | 2018-05-28 15:48:04 +0200 | [diff] [blame] | 64 | Return (^^XBCL()) |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 65 | } |
| 66 | */ |
| 67 | acpigen_write_method("_BCL", 0); |
Nico Huber | 53c1717 | 2020-03-21 18:47:24 +0100 | [diff] [blame] | 68 | acpigen_emit_byte(RETURN_OP); |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 69 | acpigen_emit_namestring("^^XBCL"); |
| 70 | acpigen_pop_len(); |
| 71 | |
| 72 | /* |
| 73 | Method (_BCM, 1, NotSerialized) |
| 74 | { |
Elyes HAOUAS | 0d8f1da | 2018-05-28 15:48:04 +0200 | [diff] [blame] | 75 | ^^XBCM(Arg0) |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 76 | } |
| 77 | */ |
| 78 | acpigen_write_method("_BCM", 1); |
| 79 | acpigen_emit_namestring("^^XBCM"); |
Nico Huber | 53c1717 | 2020-03-21 18:47:24 +0100 | [diff] [blame] | 80 | acpigen_emit_byte(ARG0_OP); |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 81 | acpigen_pop_len(); |
| 82 | |
| 83 | /* |
| 84 | Method (_BQC, 0, NotSerialized) |
| 85 | { |
Elyes HAOUAS | 0d8f1da | 2018-05-28 15:48:04 +0200 | [diff] [blame] | 86 | Return (^^XBQC()) |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 87 | } |
| 88 | */ |
| 89 | acpigen_write_method("_BQC", 0); |
Nico Huber | 53c1717 | 2020-03-21 18:47:24 +0100 | [diff] [blame] | 90 | acpigen_emit_byte(RETURN_OP); |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 91 | acpigen_emit_namestring("^^XBQC"); |
| 92 | acpigen_pop_len(); |
| 93 | } |
| 94 | |
| 95 | /* |
Nico Huber | e98f6af | 2020-03-21 18:40:03 +0100 | [diff] [blame] | 96 | * _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 Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 107 | */ |
| 108 | acpigen_write_method("_DCS", 0); |
Nico Huber | e98f6af | 2020-03-21 18:40:03 +0100 | [diff] [blame] | 109 | acpigen_write_return_integer(0x1d); |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 110 | acpigen_pop_len(); |
| 111 | |
| 112 | /* |
Nico Huber | e98f6af | 2020-03-21 18:40:03 +0100 | [diff] [blame] | 113 | Method(_DGS, 0) |
| 114 | { |
| 115 | Return (0) |
| 116 | } |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 117 | */ |
| 118 | acpigen_write_method("_DGS", 0); |
Nico Huber | e98f6af | 2020-03-21 18:40:03 +0100 | [diff] [blame] | 119 | acpigen_write_return_integer(0); |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 120 | acpigen_pop_len(); |
| 121 | |
| 122 | /* |
Nico Huber | e98f6af | 2020-03-21 18:40:03 +0100 | [diff] [blame] | 123 | Method(_DSS, 1) |
| 124 | { |
| 125 | } |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 126 | */ |
Matt DeVillier | 17b1a69 | 2017-05-27 17:49:21 -0500 | [diff] [blame] | 127 | acpigen_write_method("_DSS", 1); |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 128 | acpigen_pop_len(); |
| 129 | |
Nico Huber | 53c1717 | 2020-03-21 18:47:24 +0100 | [diff] [blame] | 130 | acpigen_pop_len(); /* End Device. */ |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 131 | } |
| 132 | |
Nico Huber | 53c1717 | 2020-03-21 18:47:24 +0100 | [diff] [blame] | 133 | acpigen_pop_len(); /* End Scope. */ |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 134 | } |