1 2 /*++ 3 4 Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved 5 6 7 This program and the accompanying materials are licensed and made available under 8 9 the terms and conditions of the BSD License that accompanies this distribution. 10 11 The full text of the license may be found at 12 13 http://opensource.org/licenses/bsd-license.php. 14 15 16 17 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 18 19 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 20 21 22 23 24 25 Module Name: 26 27 IgdOpRegion.h 28 29 Abstract: 30 31 This is part of the implementation of an Intel Graphics drivers OpRegion / 32 Software SCI interface between system BIOS, ASL code, and Graphics drivers. 33 34 Supporting Specifiction: OpRegion / Software SCI SPEC 0.70 35 36 Acronyms: 37 IGD: Internal Graphics Device 38 NVS: ACPI Non Volatile Storage 39 OpRegion: ACPI Operational Region 40 VBT: Video BIOS Table (OEM customizable data) 41 42 --*/ 43 44 #ifndef _IGD_OPREGION_H_ 45 #define _IGD_OPREGION_H_ 46 47 // 48 // Statements that include other header files. 49 // 50 #include "VlvPlatformInit.h" 51 #include "VlvCommonDefinitions.h" 52 #include <Uefi/UefiInternalFormRepresentation.h> 53 #include <FrameworkDxe.h> 54 55 // 56 // 57 // OpRegion (Miscellaneous) #defines. 58 // 59 // OpRegion Header #defines. 60 // 61 62 #define HEADER_SIGNATURE "IntelGraphicsMem" 63 #define HEADER_SIZE 0x2000 64 #define HEADER_OPREGION_VER 0x0200 65 #define HEADER_OPREGION_REV 0x00 66 67 // 68 //For VLV Tablet, MailBOX2(SCI)is not supported. 69 // 70 #define HEADER_MBOX_SUPPORT (HD_MBOX4 + HD_MBOX3 + HD_MBOX1) 71 #define HD_MBOX1 BIT0 72 #define HD_MBOX2 BIT1 73 #define HD_MBOX3 BIT2 74 #define HD_MBOX4 BIT3 75 #define HD_MBOX5 BIT4 76 #define SVER_SIZE 32 77 78 // 79 //Audio Type support for VLV2 A0 80 // 81 #define AUDIO_TYPE_SUPPORT_MASK 0xFFFFFFF3 82 #define NO_AUDIO_SUPPORT (0<<2) 83 #define HD_AUDIO_SUPPORT (1<<2) 84 #define LPE_AUDIO_SUPPORT (2<<2) 85 #define AUDIO_TYPE_FIELD_MASK 0xFFFFFFEF 86 #define AUDIO_TYPE_FIELD_VALID (1<<4) 87 #define AUDIO_TYPE_FIELD_INVALID (0<<4) 88 89 // 90 // OpRegion Mailbox 1 EQUates. 91 // 92 // OpRegion Mailbox 3 EQUates. 93 // 94 #define ALS_ENABLE BIT0 95 #define BLC_ENABLE BIT1 96 #define BACKLIGHT_BRIGHTNESS 0xFF 97 #define FIELD_VALID_BIT BIT31 98 #define WORD_FIELD_VALID_BIT BIT15 99 #define PFIT_ENABLE BIT2 100 #define PFIT_OPRN_AUTO 0x00000000 101 #define PFIT_OPRN_SCALING 0x00000007 102 #define PFIT_OPRN_OFF 0x00000000 103 #define PFIT_SETUP_AUTO 0 104 #define PFIT_SETUP_SCALING 1 105 #define PFIT_SETUP_OFF 2 106 #define INIT_BRIGHT_LEVEL 0x64 107 #define PFIT_STRETCH 6 108 #define PFIT_CENTER 1 109 110 // 111 // GMCH PCI register access #defines. 112 // 113 114 #define IgdMmPci32(Register) MmPci32 (0, IGD_BUS, IGD_DEV, IGD_FUN_0, Register) 115 #define IgdMmPci16Or(Register, OrData) MmPci16Or (0, IGD_BUS, IGD_DEV, IGD_FUN_0, Register, OrData) 116 #define IgdMmPci16AndThenOr(Register,AndData,OrData) MmPci16AndThenOr (0, IGD_BUS, IGD_DEV, IGD_FUN_0, Register, AndData, OrData) 117 118 // 119 // Video BIOS / VBT #defines 120 // 121 #define IGD_DID_VLV 0x0F31 122 #define OPTION_ROM_SIGNATURE 0xAA55 123 #define VBIOS_LOCATION_PRIMARY 0xC0000 124 125 #define VBT_SIGNATURE SIGNATURE_32 ('$', 'V', 'B', 'T') 126 127 // 128 // Typedef stuctures 129 // 130 #pragma pack (1) 131 typedef struct { 132 UINT16 Signature; // 0xAA55 133 UINT8 Size512; 134 UINT8 Reserved[21]; 135 UINT16 PcirOffset; 136 UINT16 VbtOffset; 137 } INTEL_VBIOS_OPTION_ROM_HEADER; 138 #pragma pack () 139 140 #pragma pack (1) 141 typedef struct { 142 UINT32 Signature; // "PCIR" 143 UINT16 VendorId; // 0x8086 144 UINT16 DeviceId; 145 UINT16 Reserved0; 146 UINT16 Length; 147 UINT8 Revision; 148 UINT8 ClassCode[3]; 149 UINT16 ImageLength; 150 UINT16 CodeRevision; 151 UINT8 CodeType; 152 UINT8 Indicator; 153 UINT16 Reserved1; 154 } INTEL_VBIOS_PCIR_STRUCTURE; 155 #pragma pack () 156 157 #pragma pack (1) 158 typedef struct { 159 UINT8 HeaderSignature[20]; 160 UINT16 HeaderVersion; 161 UINT16 HeaderSize; 162 UINT16 HeaderVbtSize; 163 UINT8 HeaderVbtCheckSum; 164 UINT8 HeaderReserved; 165 UINT32 HeaderOffsetVbtDataBlock; 166 UINT32 HeaderOffsetAim1; 167 UINT32 HeaderOffsetAim2; 168 UINT32 HeaderOffsetAim3; 169 UINT32 HeaderOffsetAim4; 170 UINT8 DataHeaderSignature[16]; 171 UINT16 DataHeaderVersion; 172 UINT16 DataHeaderSize; 173 UINT16 DataHeaderDataBlockSize; 174 UINT8 CoreBlockId; 175 UINT16 CoreBlockSize; 176 UINT16 CoreBlockBiosSize; 177 UINT8 CoreBlockBiosType; 178 UINT8 CoreBlockReleaseStatus; 179 UINT8 CoreBlockHWSupported; 180 UINT8 CoreBlockIntegratedHW; 181 UINT8 CoreBlockBiosBuild[4]; 182 UINT8 CoreBlockBiosSignOn[155]; 183 } VBIOS_VBT_STRUCTURE; 184 #pragma pack () 185 186 // 187 // Driver Private Function definitions 188 // 189 EFI_STATUS 190 GetSVER ( 191 OUT UINT8 *SVER 192 ); 193 194 /** 195 Acquire the string associated with the ProducerGuid and return it. 196 197 @param ProducerGuid The Guid to search the HII database for 198 @param Token The token value of the string to extract 199 @param String The string that is extracted 200 201 @retval EFI_SUCCESS The function completed successfully 202 @retval EFI_NOT_FOUND The requested string was not found 203 204 **/ 205 EFI_STATUS 206 GetStringFromToken ( 207 IN EFI_GUID *ProducerGuid, 208 IN STRING_REF Token, 209 OUT CHAR16 **String 210 ); 211 212 /** 213 214 Graphics OpRegion / Software SCI driver installation function. 215 216 @param Void 217 218 @retval EFI_SUCCESS The driver installed without error. 219 @retval EFI_ABORTED The driver encountered an error and could not complete 220 installation of the ACPI tables. 221 **/ 222 EFI_STATUS 223 IgdOpRegionInit ( 224 void 225 ); 226 227 /** 228 Extract information pertaining to the HiiHandle 229 230 @param HiiHandle Hii handle 231 @param ImageLength For input, length of DefaultImage; 232 For output, length of actually required 233 234 @param DefaultImage Image buffer prepared by caller 235 @param Guid Guid information about the form 236 237 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate 238 @retval EFI_BUFFER_TOO_SMALL DefualtImage has no enough ImageLength 239 @retval EFI_SUCCESS Successfully extract data from Hii database. 240 241 **/ 242 EFI_STATUS 243 ExtractDataFromHiiHandle ( 244 IN EFI_HII_HANDLE HiiHandle, 245 IN OUT UINT16 *ImageLength, 246 OUT UINT8 *DefaultImage, 247 OUT EFI_GUID *Guid 248 ); 249 #endif 250