IgdOpRegion.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*++
  2. Copyright (c) 1999 - 2019, Intel Corporation. All rights reserved
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. Module Name:
  5. IgdOpRegion.h
  6. Abstract:
  7. This is part of the implementation of an Intel Graphics drivers OpRegion /
  8. Software SCI interface between system BIOS, ASL code, and Graphics drivers.
  9. Supporting Specifiction: OpRegion / Software SCI SPEC 0.70
  10. Acronyms:
  11. IGD: Internal Graphics Device
  12. NVS: ACPI Non Volatile Storage
  13. OpRegion: ACPI Operational Region
  14. VBT: Video BIOS Table (OEM customizable data)
  15. --*/
  16. #ifndef _IGD_OPREGION_H_
  17. #define _IGD_OPREGION_H_
  18. //
  19. // Statements that include other header files.
  20. //
  21. #include "VlvPlatformInit.h"
  22. #include "VlvCommonDefinitions.h"
  23. #include <Uefi/UefiInternalFormRepresentation.h>
  24. #include <PiDxe.h>
  25. //
  26. //
  27. // OpRegion (Miscellaneous) #defines.
  28. //
  29. // OpRegion Header #defines.
  30. //
  31. #define HEADER_SIGNATURE "IntelGraphicsMem"
  32. #define HEADER_SIZE 0x2000
  33. #define HEADER_OPREGION_VER 0x0200
  34. #define HEADER_OPREGION_REV 0x00
  35. //
  36. //For VLV Tablet, MailBOX2(SCI)is not supported.
  37. //
  38. #define HEADER_MBOX_SUPPORT (HD_MBOX4 + HD_MBOX3 + HD_MBOX1)
  39. #define HD_MBOX1 BIT0
  40. #define HD_MBOX2 BIT1
  41. #define HD_MBOX3 BIT2
  42. #define HD_MBOX4 BIT3
  43. #define HD_MBOX5 BIT4
  44. #define SVER_SIZE 32
  45. //
  46. //Audio Type support for VLV2 A0
  47. //
  48. #define AUDIO_TYPE_SUPPORT_MASK 0xFFFFFFF3
  49. #define NO_AUDIO_SUPPORT (0<<2)
  50. #define HD_AUDIO_SUPPORT (1<<2)
  51. #define LPE_AUDIO_SUPPORT (2<<2)
  52. #define AUDIO_TYPE_FIELD_MASK 0xFFFFFFEF
  53. #define AUDIO_TYPE_FIELD_VALID (1<<4)
  54. #define AUDIO_TYPE_FIELD_INVALID (0<<4)
  55. //
  56. // OpRegion Mailbox 1 EQUates.
  57. //
  58. // OpRegion Mailbox 3 EQUates.
  59. //
  60. #define ALS_ENABLE BIT0
  61. #define BLC_ENABLE BIT1
  62. #define BACKLIGHT_BRIGHTNESS 0xFF
  63. #define FIELD_VALID_BIT BIT31
  64. #define WORD_FIELD_VALID_BIT BIT15
  65. #define PFIT_ENABLE BIT2
  66. #define PFIT_OPRN_AUTO 0x00000000
  67. #define PFIT_OPRN_SCALING 0x00000007
  68. #define PFIT_OPRN_OFF 0x00000000
  69. #define PFIT_SETUP_AUTO 0
  70. #define PFIT_SETUP_SCALING 1
  71. #define PFIT_SETUP_OFF 2
  72. #define INIT_BRIGHT_LEVEL 0x64
  73. #define PFIT_STRETCH 6
  74. #define PFIT_CENTER 1
  75. //
  76. // GMCH PCI register access #defines.
  77. //
  78. #define IgdMmPci32(Register) MmPci32 (0, IGD_BUS, IGD_DEV, IGD_FUN_0, Register)
  79. #define IgdMmPci16Or(Register, OrData) MmPci16Or (0, IGD_BUS, IGD_DEV, IGD_FUN_0, Register, OrData)
  80. #define IgdMmPci16AndThenOr(Register,AndData,OrData) MmPci16AndThenOr (0, IGD_BUS, IGD_DEV, IGD_FUN_0, Register, AndData, OrData)
  81. //
  82. // Video BIOS / VBT #defines
  83. //
  84. #define IGD_DID_VLV 0x0F31
  85. #define OPTION_ROM_SIGNATURE 0xAA55
  86. #define VBIOS_LOCATION_PRIMARY 0xC0000
  87. #define VBT_SIGNATURE SIGNATURE_32 ('$', 'V', 'B', 'T')
  88. //
  89. // Typedef stuctures
  90. //
  91. #pragma pack (1)
  92. typedef struct {
  93. UINT16 Signature; // 0xAA55
  94. UINT8 Size512;
  95. UINT8 Reserved[21];
  96. UINT16 PcirOffset;
  97. UINT16 VbtOffset;
  98. } INTEL_VBIOS_OPTION_ROM_HEADER;
  99. #pragma pack ()
  100. #pragma pack (1)
  101. typedef struct {
  102. UINT32 Signature; // "PCIR"
  103. UINT16 VendorId; // 0x8086
  104. UINT16 DeviceId;
  105. UINT16 Reserved0;
  106. UINT16 Length;
  107. UINT8 Revision;
  108. UINT8 ClassCode[3];
  109. UINT16 ImageLength;
  110. UINT16 CodeRevision;
  111. UINT8 CodeType;
  112. UINT8 Indicator;
  113. UINT16 Reserved1;
  114. } INTEL_VBIOS_PCIR_STRUCTURE;
  115. #pragma pack ()
  116. #pragma pack (1)
  117. typedef struct {
  118. UINT8 HeaderSignature[20];
  119. UINT16 HeaderVersion;
  120. UINT16 HeaderSize;
  121. UINT16 HeaderVbtSize;
  122. UINT8 HeaderVbtCheckSum;
  123. UINT8 HeaderReserved;
  124. UINT32 HeaderOffsetVbtDataBlock;
  125. UINT32 HeaderOffsetAim1;
  126. UINT32 HeaderOffsetAim2;
  127. UINT32 HeaderOffsetAim3;
  128. UINT32 HeaderOffsetAim4;
  129. UINT8 DataHeaderSignature[16];
  130. UINT16 DataHeaderVersion;
  131. UINT16 DataHeaderSize;
  132. UINT16 DataHeaderDataBlockSize;
  133. UINT8 CoreBlockId;
  134. UINT16 CoreBlockSize;
  135. UINT16 CoreBlockBiosSize;
  136. UINT8 CoreBlockBiosType;
  137. UINT8 CoreBlockReleaseStatus;
  138. UINT8 CoreBlockHWSupported;
  139. UINT8 CoreBlockIntegratedHW;
  140. UINT8 CoreBlockBiosBuild[4];
  141. UINT8 CoreBlockBiosSignOn[155];
  142. } VBIOS_VBT_STRUCTURE;
  143. #pragma pack ()
  144. //
  145. // Driver Private Function definitions
  146. //
  147. EFI_STATUS
  148. GetSVER (
  149. OUT UINT8 *SVER
  150. );
  151. /**
  152. Graphics OpRegion / Software SCI driver installation function.
  153. @param Void
  154. @retval EFI_SUCCESS The driver installed without error.
  155. @retval EFI_ABORTED The driver encountered an error and could not complete
  156. installation of the ACPI tables.
  157. **/
  158. EFI_STATUS
  159. IgdOpRegionInit (
  160. void
  161. );
  162. /**
  163. Extract information pertaining to the HiiHandle
  164. @param HiiHandle Hii handle
  165. @param ImageLength For input, length of DefaultImage;
  166. For output, length of actually required
  167. @param DefaultImage Image buffer prepared by caller
  168. @param Guid Guid information about the form
  169. @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
  170. @retval EFI_BUFFER_TOO_SMALL DefualtImage has no enough ImageLength
  171. @retval EFI_SUCCESS Successfully extract data from Hii database.
  172. **/
  173. EFI_STATUS
  174. ExtractDataFromHiiHandle (
  175. IN EFI_HII_HANDLE HiiHandle,
  176. IN OUT UINT16 *ImageLength,
  177. OUT UINT8 *DefaultImage,
  178. OUT EFI_GUID *Guid
  179. );
  180. #endif