summaryrefslogtreecommitdiff
path: root/ReferenceCode/Chipset/SystemAgent/AcpiTables/SaSsdt/IgdOMOBF.ASL
blob: 07a716bf2024d9c9c06ea4c3a38e82c7fb6619df (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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
/*++
  This file contains an 'Intel Peripheral Driver' and uniquely
  identified as "Intel Reference Module" and is
  licensed for Intel CPUs and chipsets under the terms of your
  license agreement with Intel or your vendor.  This file may
  be modified by the user, subject to additional terms of the
  license agreement
--*/

/*++

Copyright (c)  1999 - 2013 Intel Corporation. All rights reserved
This software and associated documentation (if any) is furnished
under a license and may only be used or copied in accordance
with the terms of the license. Except as permitted by such
license, no part of this software or documentation may be
reproduced, stored in a retrieval system, or transmitted in any
form or by any means without the express written consent of
Intel Corporation.


Module Name:

  IgdOMOBF.ASL

Abstract:

  IGD OpRegion/Software SCI Reference Code.
  This file contains ASL code with the purpose of handling events
  i.e. hotkeys and other system interrupts.

--*/


// Notes:
// 1. The following routines are to be called from the appropriate event
//    handlers.
// 2. This code cannot comprehend the exact implementation in the OEM's BIOS.
//    Therefore, an OEM must call these methods from the existing event
//    handler infrastructure.  Details on when/why to call each method is
//    included in the method header under the "usage" section.


/************************************************************************;
;* ACPI Notification Methods
;************************************************************************/


/************************************************************************;
;*
;* Name:	PDRD
;*
;* Description:	Check if the graphics driver is ready to process
;*		notifications and video extensions.
;*
;* Usage:	This method is to be called prior to performing any
;*		notifications or handling video extensions.
;*		Ex: If (PDRD()) {Return (FAIL)}
;*
;* Input:	None
;*
;* Output:	None
;*
;* References:	DRDY (Driver ready status), ASLP (Driver recommended
;*		sleep timeout value).
;*
;************************************************************************/

External(HNOT, MethodObj)

Method(PDRD)
{

		// Sleep for ASLP milliseconds if the driver is not ready.


	// If DRDY is clear, the driver is not ready.  If the return value is
	// !=0, do not perform any notifications or video extension handling.

	Return(LNot(DRDY))
}


/************************************************************************;
;*
;* Name:	PSTS
;*
;* Description:	Check if the graphics driver has completed the previous
;*		"notify" command.
;*
;* Usage:	This method is called before every "notify" command.  A
;*		"notify" should only be set if the driver has completed the
;*		previous command.  Else, ignore the event and exit the parent
;*		method.
;*		Ex: If (PSTS()) {Return (FAIL)}
;*
;* Input:	None
;*
;* Output:	None
;*
;* References:	CSTS (Notification status), ASLP (Driver recommended sleep
;*		timeout value).
;*
;************************************************************************/

Method(PSTS)
{
	If(LGreater(CSTS, 2))
	{
		// Sleep for ASLP milliseconds if the status is not "success,
		// failure, or pending"
		//
		Sleep(ASLP)
	}

	Return(LEqual(CSTS, 3))		// Return True if still Dispatched
}


/************************************************************************;
;*
;* Name:	GNOT
;*
;* Description:	Call the appropriate methods to query the graphics driver
;*		status.  If all methods return success, do a notification of
;*		the graphics device.
;*
;* Usage:	This method is to be called when a graphics device
;*		notification is required (display switch hotkey, etc).
;*
;* Input:	Arg0 = Current event type:
;*			1 = display switch
;*			2 = lid
;*			3 = dock
;*		Arg1 = Notification type:
;*			0 = Re-enumeration
;*			0x80 = Display switch
;*
;* Output:	Returns 0 = success, 1 = failure
;*
;* References:	PDRD and PSTS methods.  OSYS (OS version)
;*
;************************************************************************/

Method(GNOT, 2)
{
	// Check for 1. Driver loaded, 2. Driver ready.
	// If any of these cases is not met, skip this event and return failure.
	//
	If(PDRD())
	{
		Return(0x1)		// Return failure if driver not loaded.
	}

	Store(Arg0, CEVT)		// Set up the current event value
	Store(3, CSTS)			// CSTS=BIOS dispatched an event

	If(LAnd(LEqual(CHPD, 0), LEqual(Arg1, 0)))	// Do not re-enum if driver supports hotplug
	{
		If(LOr(LGreater(OSYS, 2000), LLess(OSYS, 2006)))
		{
			//
			// WINXP requires that the entire PCI Bridge be re-enumerated.
			//
			Notify(\_SB.PCI0, Arg1)
		}
		Else
		{
			//
			// Re-enumerate the Graphics Device for non-XP operating systems.
			//
			Notify(\_SB.PCI0.GFX0, Arg1)
		}
	}

	If(CondRefOf(HNOT))
	{
		HNOT(Arg0)  //Notification handler for Switchable graphics
	}
	Else
	{
		Notify(\_SB.PCI0.GFX0,0x80)
	}

	Return(0x0)			// Return success
}


/************************************************************************;
;*
;* Name:	GHDS
;*
;* Description:	Handle a hotkey display switching event (performs a
;*		Notify(GFX0, 0).
;*
;* Usage:	This method must be called when a hotkey event occurs and the
;*		purpose of that hotkey is to do a display switch.
;*
;* Input:	Arg0 = Toggle table number.
;*
;* Output:	Returns 0 = success, 1 = failure.
;*		CEVT and TIDX are indirect outputs.
;*
;* References:	TIDX, GNOT
;*
;************************************************************************/

Method(GHDS, 1)
{
	Store(Arg0, TIDX)		// Store the table number

	// Call GNOT for CEVT = 1 = hotkey, notify value = 0

	Return(GNOT(1, 0))		// Return stats from GNOT
}


/************************************************************************;
;*
;* Name:	GLID
;*
;* Description:	Handle a lid event (performs the Notify(GFX0, 0), but not the
;*		lid notify).
;*
;* Usage:	This method must be called when a lid event occurs.  A
;*		Notify(LID0, 0x80) must follow the call to this method.
;*
;* Input:	Arg0 = Lid state:
;*			0 = All closed
;*			1 = internal LFP lid open
;*			2 = external lid open
;*			3 = both external and internal open
;*
;* Output:	Returns 0=success, 1=failure.
;*		CLID and CEVT are indirect outputs.
;*
;* References:	CLID, GNOT
;*
;************************************************************************/

Method(GLID, 1)
{

        If (LEqual(Arg0,1))
	{
           Store(3,CLID)
        }
	Else
	{
           Store(Arg0, CLID)
        }

        //Store(Arg0, CLID)		// Store the current lid state

	// Call GNOT for CEVT=2=Lid, notify value = 0

	if (GNOT(2, 0)) {
	  Or (CLID, 0x80000000, CLID)
	  Return (1)		// Return Fail
	}

	Return (0)		// Return Pass
}


/************************************************************************;
;*
;* Name:	GDCK
;*
;* Description:	Handle a docking event by updating the current docking status
;*		and doing a notification.
;*
;* Usage:	This method must be called when a docking event occurs.
;*
;* Input:	Arg0 = Docking state:
;*			0 = Undocked
;*			1 = Docked
;*
;* Output:	Returns 0=success, 1=failure.
;*		CDCK and CEVT are indirect outputs.
;*
;* References:	CDCK, GNOT
;*
;************************************************************************/

Method(GDCK, 1)
{
	Store(Arg0, CDCK)		// Store the current dock state

	// Call GNOT for CEVT=4=Dock, notify value = 0

	Return(GNOT(4, 0))		// Return stats from GNOT
}


/************************************************************************;
;* ASLE Interrupt Methods
;************************************************************************/


/************************************************************************;
;*
;* Name:	PARD
;*
;* Description:	Check if the driver is ready to handle ASLE interrupts
;*		generate by the system BIOS.
;*
;* Usage:	This method must be called before generating each ASLE
;*		interrupt.
;*
;* Input:	None
;*
;* Output:	Returns 0 = success, 1 = failure.
;*
;* References:	ARDY (Driver readiness), ASLP (Driver recommended sleep
;*		timeout value)
;*
;************************************************************************/

Method(PARD)
{
	If(LNot(ARDY))
	{

		// Sleep for ASLP milliseconds if the driver is not ready.

		Sleep(ASLP)
	}

	// If ARDY is clear, the driver is not ready.  If the return value is
	// !=0, do not generate the ASLE interrupt.

	Return(LNot(ARDY))
}

//
// Intel Ultrabook Event Handler.  Arg0 represents the Ultrabook Event Bit # to pass
// to the Intel Graphics Driver.  Note that this is a serialized method, meaning
// sumultaneous events are not allowed.
//

Method(IUEH,1,Serialized)
{
  And(IUER,0xC0,IUER)   			// Clear all button events on entry.
  XOr(IUER,Shiftleft(1,Arg0),IUER)	        // Toggle status.

  If(LLessEqual(Arg0,4))			// Button Event?
  {
   	Return(AINT(5,0))			// Generate event and return status.

  }
  Else						// Indicator Event.
  {
        Return(AINT(Arg0,0))			// Generate event and return status.
  }
}

/************************************************************************;
;*
;* Name:	AINT
;*
;* Description:	Call the appropriate methods to generate an ASLE interrupt.
;*		This process includes ensuring the graphics driver is ready
;*		to process the interrupt, ensuring the driver supports the
;*		interrupt of interest, and passing information about the event
;*		to the graphics driver.
;*
;* Usage:	This method must called to generate an ASLE interrupt.
;*
;* Input:	Arg0 = ASLE command function code:
;*			0 = Set ALS illuminance
;*			1 = Set backlight brightness
;*			2 = Do Panel Fitting
;*			4 = Reserved
;*			5 = Button Indicator Event
;*			6 = Convertible Indicator Event
;*			7 = Docking Indicator Event
;*		Arg1 = If Arg0 = 0, current ALS reading:
;*			0 = Reading below sensor range
;*			1-0xFFFE = Current sensor reading
;*			0xFFFF = Reading above sensor range
;*		Arg1 = If Arg0 = 1, requested backlight percentage
;*
;* Output:	Returns 0 = success, 1 = failure
;*
;* References:	PARD method.
;*
;************************************************************************/

Method(AINT, 2)
{

	// Return failure if the requested feature is not supported by the
	// driver.

	If(LNot(And(TCHE, ShiftLeft(1, Arg0))))
	{
		Return(0x1)
	}

	// Return failure if the driver is not ready to handle an ASLE
	// interrupt.

	If(PARD())
	{
  		Return(0x1)
	}

	// Handle Intel Ultrabook Events.

	If(LAnd(LGreaterEqual(Arg0,5),LLessEqual(Arg0,7)))
	{
		Store(ShiftLeft(1,Arg0), ASLC)				// Set Ultrbook Event [6:4].
		Store(0x01, ASLE)               			// Generate ASLE interrupt

		Store(0,Local2)						// Use Local2 as a timeout counter.  Intialize to zero.

    		While(LAnd(LLess(Local2,250),LNotEqual(ASLC,0)))	// Wait 1 second or until Driver ACKs a success.
    		{
			Sleep(4)					// Delay 4 ms.
			Increment(Local2)				// Increment Timeout.
		}

		Return(0)					// Return success
	}

	// Evaluate the first argument (Panel fitting, backlight brightness, or ALS).

	If(LEqual(Arg0, 2))		// Arg0 = 2, so request a panel fitting mode change.
	{
		If(CPFM)					// If current mode field is non-zero use it.
		{
			And(CPFM, 0x0F, Local0)			// Create variables without reserved
			And(EPFM, 0x0F, Local1)			// or valid bits.

			If(LEqual(Local0, 1))			// If current mode is centered,
			{
				If(And(Local1, 6))		// and if stretched is enabled,
				{
					Store(6, PFIT)		// request stretched.
				}
				Else				// Otherwise,
				{
					If(And(Local1, 8))	// if aspect ratio is enabled,
					{
						Store(8, PFIT)	// request aspect ratio.
					}
					Else			// Only centered mode is enabled
					{
						Store(1, PFIT)	// so request centered. (No change.)
					}
				}
			}
			If(LEqual(Local0, 6))			// If current mode is stretched,
			{
				If(And(Local1, 8))		// and if aspect ratio is enabled,
				{
					Store(8, PFIT)		// request aspect ratio.
				}
				Else				// Otherwise,
				{
					If(And(Local1, 1))	// if centered is enabled,
					{
						Store(1, PFIT)	// request centered.
					}
					Else			// Only stretched mode is enabled
					{
						Store(6, PFIT)	// so request stretched. (No change.)
					}
				}
			}
			If(LEqual(Local0, 8))			// If current mode is aspect ratio,
			{
				If(And(Local1, 1))		// and if centered is enabled,
				{
					Store(1, PFIT)		// request centered.
				}
				Else				// Otherwise,
				{
					If(And(Local1, 6))	// if stretched is enabled,
					{
						Store(6, PFIT)	// request stretched.
					}
					Else			// Only aspect ratio mode is enabled
					{
						Store(8, PFIT)	// so request aspect ratio. (No change.)
					}
				}
			}
		}

		// The following code for panel fitting (within the Else condition) is retained for backward compatiblity.

		Else				// If CFPM field is zero use PFIT and toggle the
		{
			Xor(PFIT,7,PFIT)	// mode setting between stretched and centered only.
		}

		Or(PFIT,0x80000000,PFIT) 	// Set the valid bit for all cases.

		Store(4, ASLC)			// Store "Panel fitting event" to ASLC[31:1]
	}
	Else
	{
		If(LEqual(Arg0, 1))		// Arg0=1, so set the backlight brightness.
		{
			Store(Divide(Multiply(Arg1, 255), 100), BCLP) // Convert from percent to 0-255.

			Or(BCLP, 0x80000000, BCLP)	// Set the valid bit.

			Store(2, ASLC)			// Store "Backlight control event" to ASLC[31:1]
		}
		Else
		{
			If(LEqual(Arg0, 0))		// Arg0=0, so set the ALS illuminace
			{
				Store(Arg1, ALSI)

			  	Store(1, ASLC)		// Store "ALS event" to ASLC[31:1]
			}
			Else
			{
				Return(0x1) // Unsupported function
			}
		}
	}

	Store(0x01, ASLE)               // Generate ASLE interrupt
	Return(0x0)			// Return success
}


/************************************************************************;
;*
;* Name:	SCIP
;*
;* Description:	Checks the presence of the OpRegion and SCI
;*
;* Usage:	This method is called before other OpRegion methods. The
;*		former "GSMI True/False is not always valid.  This method
;*		checks if the OpRegion Version is non-zero and if non-zero,
;*		(present and readable) then checks the GSMI flag.
;*
;* Input:	None
;*
;* Output:	Boolean True = SCI present.
;*
;* References:	None
;*
;************************************************************************/

Method(SCIP)
{
	If(LNotEqual(OVER,0))		// If OpRegion Version not 0.
	{
		Return(LNot(GSMI))	// Return True if SCI.
	}

	Return(0)			// Else Return False.
}