summaryrefslogtreecommitdiff
path: root/Silicon/BroxtonSoC/BroxtonSiPkg/NorthCluster/AcpiTables/IgfxDsm.asl
blob: ce950a51e844113221f255451967d911965dc770 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
/** @file
  IGD OpRegion/_DSM Reference Code.
  This file contains Get BIOS Data and Callback functions for
  the Integrated Graphics Device (IGD) OpRegion/DSM mechanism.

  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>

  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php.

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

External(IPAT)
External(IPSC)
External(IBTT)
External(IBIA)
External(LIDS)
External(IDMS)
External(HVCO)
External(\DHPD)

//
// _DSM Device Specific Method
//
// Arg0: UUID Unique function identifier
// Arg1: Integer Revision Level
// Arg2: Integer Function Index (1 = Return Supported Functions)
// Arg3: Additional Inputs/Package Parameters Bits [31:0] input as {Byte0, Byte1, Byte2, Byte3} to BIOS which is passed as 32 bit DWORD by Driver
//
Method (_DSM, 4, Serialized, 0, UnknownObj, {BuffObj, IntObj, IntObj, PkgObj}) {

  If (LEqual(Arg0, ToUUID ("3E5B41C6-EB1D-4260-9D15-C71FBADAE414"))) {
    //
    // _DSM Definition for Igd functions
    // Arguments:
    // Arg0: UUID: 3E5B41C6-EB1D-4260-9D15-C71FBADAE414
    // Arg1: Revision ID: 1
    // Arg2: Function Index: 16
    // Arg3: Additional Inputs Bits[31:0] Arg3 {Byte0, Byte1, Byte2, Byte3}
    //
    // Return:
    // Success for simple notification, Opregion update for some routines and a Package for AKSV
    //
    //
    // Switch by function index
    //
    Switch(ToInteger(Arg2)) {
      //
      // Function Index: 0
      // Standard query - A bitmask of functions supported
      //
      // Return: A bitmask of functions supported
      //
      Case (0)
      {
        If (LEqual(Arg1, 1)) { // test Arg1 for Revision ID: 1
          Store("iGfx Supported Functions Bitmap ", Debug)
          Return (0x3E7FF)
        }
      }

      //
      // Function Index: 1
      // Adapter Power State Notification
      // Arg3 Bits [7:0]: Adapter Power State bits [7:0] from Driver 00h = D0; 01h = D1; 02h = D2; 04h = D3 (Cold/Hot); 08h = D4 (Hibernate Notification)
      // Return: Success
      //
      Case(1) {
        If (LEqual(Arg1, 1)) { // test Arg1 for Revision ID: 1
          Store(" Adapter Power State Notification ", Debug)

#if (ENBDT_PF_ENABLE == 1)
          //
          // Handle Low Power S0 Idle Capability if enabled
          //
          If(LAnd(LEqual(S0ID, 1),LLess(OSYS, 2015))) {
            //
            // Call GUAM to trigger CS Entry
            //   If Adapter Power State Notification = D1 (Arg3[0]=0x01)
            //
            If (LEqual (And(DerefOf (Index (Arg3,0)), 0xFF), 0x01)) {
              // GUAM - Global User Absent Mode Notification Method
              \GUAM(One) // 0x01 - Power State Standby (CS Entry)
            }
          }
#endif

          // Upon notification from driver that the Adapter Power State = D0,
          // check if previous lid event failed.  If it did, retry the lid
          // event here.
          If(LEqual(DerefOf (Index (Arg3,0)), 0)) {
            Store(CLID, Local0)
            If(And(0x80000000,Local0)) {
              And(CLID, 0x0000000F, CLID)
              GLID(CLID)
            }
          }
          Return(0x01)
        }
      }

      //
      // Function Index: 2
      // Display Power State Notification
      // Arg3: Display Power State Bits [15:8]
      // 00h = On
      // 01h = Standby
      // 02h = Suspend
      // 04h = Off
      // 08h = Reduced On
      // Return: Success
      //
     Case(2) {
        if (LEqual(Arg1, 1)) { // test Arg1 for Revision ID: 1
          Store("Display Power State Notification ", Debug)
#if (ENBDT_PF_ENABLE == 1)
          //
          // Handle Low Power S0 Idle Capability if enabled
          //
          If(LAnd(LEqual(S0ID, 1),LLess(OSYS, 2015))) {
            Store(And(DerefOf (Index (Arg3,1)), 0xFF), Local0)
            //
            // Call GUAM
            // If Display Turn ON Notification (Arg3 [1] == 0) for CS Exit
            //
            If (LEqual (Local0, 0)) {
              // GUAM - Global User Absent Mode Notification Method
              \GUAM(Zero) // 0x00 - Power State On (CS Exit)
            }
          }
#endif
          Return(0x01)
        }
      }

      //
      // Function Index: 3
      // BIOS POST Completion Notification
      // Return: Success
      //
      Case(3) {
        if (LEqual(Arg1, 1)) { // test Arg1 for Revision ID: 1
          Store("BIOS POST Completion Notification ", Debug)
          Return(0x01)      // Not supported, but no failure
        }
      }

      //
      // Function Index: 4
      // Pre-Hires Set Mode
      // Return: Success
      //
      Case(4) {
        if (LEqual(Arg1, 1)){ // test Arg1 for Revision ID: 1
          Store("Pre-Hires Set Mode ", Debug)
          Return(0x01)      // Not supported, but no failure
        }
      }

      //
      // Function Index: 5
      // Post-Hires Set Mode
      // Return: Success
      //
      Case(5) {
        if (LEqual(Arg1, 1)){ // test Arg1 for Revision ID: 1
          Store("Post-Hires Set Mode ", Debug)
          Return(0x01)      // Not supported, but no failure
        }
      }

      //
      // Function Index: 6
      // SetDisplayDeviceNotification (Display Switch)
      // Return: Success
      //
      Case(6) {
        if (LEqual(Arg1, 1)){ // test Arg1 for Revision ID: 1
          Store("SetDisplayDeviceNotification", Debug)
          Return(0x01)      // Not supported, but no failure
        }
      }

      //
      // Function Index: 7
      // SetBootDevicePreference
      // Return: Success
      //
      Case(7) {
        if (LEqual(Arg1, 1)){ // test Arg1 for Revision ID: 1
          //<TODO> An OEM may elect to implement this method.  In that case,
          // the input values must be saved into non-volatile storage for
          // parsing during the next boot.  The following Sample code is Intel
          // validated implementation.

          Store("SetBootDevicePreference ", Debug)
          And(DerefOf (Index (Arg3,0)), 0xFF, IBTT) // Save the boot display to NVS
          Return(0x01)
        }
      }

      //
      // Function Index: 8
      // SetPanelPreference
      // Return: Success
      //
      Case(8) {
        if (LEqual(Arg1, 1)){ // test Arg1 for Revision ID: 1
          // An OEM may elect to implement this method.  In that case,
          // the input values must be saved into non-volatile storage for
          // parsing during the next boot.  The following Sample code is Intel
          // validated implementation.

          Store("SetPanelPreference ", Debug)
          //
          // Set the panel-related NVRAM variables based the input from the driver.
          //
          And(DerefOf (Index (Arg3,0)), 0xFF, IPSC)

          //
          // Change panel type if a change is requested by the driver (Change if
          // panel type input is non-zero).  Zero=No change requested.
          //
          If(And(DerefOf (Index (Arg3,1)), 0xFF)) {
            And(DerefOf (Index (Arg3,1)), 0xFF, IPAT)
            Decrement(IPAT)    // 0 = no change, so fit to CMOS map
          }
          And(ShiftRight(DerefOf (Index (Arg3,2)), 4), 0x7, IBIA)
          Return(0x01)         // Success
        }
      }

      //
      // Function Index: 9
      // FullScreenDOS
      // Return: Success
      //
      Case(9) {
        if (LEqual(Arg1, 1)){ // test Arg1 for Revision ID: 1
          Store("FullScreenDOS ", Debug)
          Return(0x01)      // Not supported, but no failure
        }
      }

      //
      // Function Index: 10
      // APM Complete
      // Return: Adjusted Lid State
      //
     Case(10) {
        if (LEqual(Arg1, 1)) { // test Arg1 for Revision ID: 1

          Store("APM Complete ", Debug)
          Store(ShiftLeft(LIDS, 8), Local0) // Report the lid state
          Add(Local0, 0x100, Local0)        // Adjust the lid state, 0 = Unknown
          Return(Local0)
        }
      }

      //
      //
      // Function Index: 13
      // GetBootDisplayPreference
      // Arg3 Bits [30:16] : Boot Device Ports
      // Arg3 Bits [7:0] : Boot Device Type
      // Return: Boot device port and Boot device type from saved configuration
      //
     Case(13) {
        if (LEqual(Arg1, 1)){ // test Arg1 for Revision ID: 1

          Store("GetBootDisplayPreference ", Debug)
          Or(ShiftLeft(DerefOf (Index (Arg3,3)), 24), ShiftLeft(DerefOf (Index (Arg3,2)), 16), Local0) // Combine Arg3 Bits [31:16]
          And(Local0, 0xEFFF0000, Local0)
          And(Local0, ShiftLeft(DeRefOf(Index(DBTB, IBTT)), 16), Local0)
          Or(IBTT, Local0, Local0) // Arg3 Bits [7:0] = Boot device type
          Return(Local0)
        }
      }

      //
      // Function Index: 14
      // GetPanelDetails
      // Return: Different Panel Settings
      //
      Case(14) {
        if (LEqual(Arg1, 1)){ // test Arg1 for Revision ID: 1
          Store("GetPanelDetails ", Debug)

          //
          // Report the scaling setting
          // Bits [7:0] - Panel Scaling
          // Bits contain the panel scaling user setting from CMOS
          // 00h = On: Auto
          // 01h = On: Force Scaling
          // 02h = Off
          // 03h = Maintain Aspect Ratio
          //
          Store(IPSC, Local0)
          Or(Local0, ShiftLeft(IPAT, 8), Local0)

          //
          // Adjust panel type, 0 = VBT default
          // Bits [15:8] - Panel Type
          // Bits contain the panel type user setting from CMOS
          // 00h = Not Valid, use default Panel Type & Timings from VBT
          // 01h - 0Fh = Panel Number
          //
          Add(Local0, 0x100, Local0)

          //
          // Report the lid state and Adjust it
          // Bits [16] - Lid State
          // Bits contain the current panel lid state
          // 0 = Lid Open
          // 1 = Lid Closed
          //
          Or(Local0, ShiftLeft(LIDS, 16), Local0)
          Add(Local0, 0x10000, Local0)

          //
          // Report the BIA setting
          // Bits [22:20] - Backlight Image Adaptation (BIA) Control
          // Bits contain the backlight image adaptation control user setting from CMOS
          // 000 = VBT Default
          // 001 = BIA Disabled (BLC may still be enabled)
          // 010 - 110 = BIA Enabled at Aggressiveness Level [1 - 5]
          //
          Or(Local0, ShiftLeft(IBIA, 20), Local0)
          Return(Local0)
        }
      }

      //
      // Function Index: 15
      // GetInternalGraphics
      // Return: Different Internal Grahics Settings
      //

      Case(15) {
        if (LEqual(Arg1, 1)){ // test Arg1 for Revision ID: 1
          Store("GetInternalGraphics ", Debug)

          Store(GIVD, Local0)                    // Local0[0]      - VGA mode(1=VGA)
          Xor(Local0, 1, Local0)                 // Invert the VGA mode polarity

          Or(Local0, ShiftLeft(GMFN, 1), Local0) // Local0[1]      - # IGD PCI functions-1
                                                 // Local0[3:2]    - Reserved
                                                 // Local0[4]      - IGD D3 support(0=cold)
                                                 // Local0[10:5]   - Reserved
          Or(Local0, ShiftLeft(3, 11), Local0)   // Local0[12:11]  - DVMT version (11b = 5.0)

          //
          // Report DVMT 5.0 Total Graphics memory size.
          //
          Or(Local0, ShiftLeft(IDMS, 17), Local0) // Bits 20:17 are for Gfx total memory size

          //
          // If the "Set Internal Graphics" call is supported, the modified
          // settings flag must be programmed per the specification.  This means
          // that the flag must be set to indicate that system BIOS requests
          // these settings.  Once "Set Internal Graphics" is called, the
          //  modified settings flag must be cleared on all subsequent calls to
          // this function.
          //
          // Report the graphics frequency based on B0:D2:F0:RF0h[12].  Must
          // take into account the current VCO.
          //
#if (ENBDT_PF_ENABLE == 1)
          Or(ShiftLeft(DeRefOf(Index(DeRefOf(Index(CDCT, HVCO)), CDVL)), 21),Local0, Local0)
          Return(Local0)
#endif
        }
      }

      //
      // Function Index: 16
      // GetAKSV
      // Retrun: 5 bytes of AKSV
      //

      Case(16) {
        if (LEqual(Arg1, 1)){ // test Arg1 for Revision ID: 1
          Store("GetAKSV", Debug)
          Return(0x01)      // Not supported, but no failure
        }
      }
      //
      // Function Index: 17 Set DISPLAY_HPD_CTL
      //
      // Arg2: function = PMC_HPD_CTL (define as next function # available)
      // Arg3: value to be programmed
      // Function PMC_HPD_CTL:
      // Feature Overview:
      // During DC9, Display Engine HPD logic is powered off. This requires special handling from PMC, Punit/PCU and DE.
      // Based on BIOS configuration, PMC will detect Hotplug events and wakes system while display engine is powered off.
      // ->Detects rising edge, falling edge or any edge
      // PMC communicates Hotplug event to Punit/PCU to DE. DE generates new "PCU Interrupt for DDI" to IA.
      // IA calls driver ISR to handle the interrupt
      //

      Case(17) {
        if (LEqual(Arg1, 1)){ // test Arg1 for Revision ID: 1
            Store("SetDHPD", Debug)
            Store(arg3, \DHPD)
        }
      }

    } // End of switch(Arg2)

  } // End of if (ToUUID("3E5B41C6-EB1D-4260-9D15-C71FBADAE414D"))
  Return (Buffer () {0x00})
} // End of _DSM