├── LICENSE ├── License.txt ├── README.md ├── SECURITY.md ├── Samples ├── 3D_Feature_Samples │ ├── 3D_Feature_Sample_App.cpp │ ├── CMakeLists.txt │ └── README.md ├── Color_Samples │ ├── CMakeLists.txt │ ├── ColorAlgorithms.cpp │ ├── ColorAlgorithms.h │ ├── ColorAlgorithms_App.cpp │ ├── ColorAlgorithms_App.h │ ├── Color_Sample_App.cpp │ └── README.md ├── CombinedDisplay │ ├── CMakeLists.txt │ ├── CombinedDisplay_Sample_App.cpp │ ├── Disable.cfg │ ├── Enable.cfg │ ├── Query.cfg │ └── README.md ├── Custom_Mode_Samples │ ├── CMakeLists.txt │ ├── CustomMode_Sample_App.cpp │ └── README.md ├── DisplayGenlock │ ├── CMakeLists.txt │ └── DisplayGenlock_Sample_App.cpp ├── DisplaySettings │ ├── CMakeLists.txt │ ├── DisplaySettings_Sample_App.cpp │ └── README.md ├── DynamicContrastEnhancement_Sample │ ├── CMakeLists.txt │ └── DynamicContrastEnhancement_Sample_App.cpp ├── Edid_Management_Sample │ ├── CMakeLists.txt │ ├── Edid_Mgmt_Sample_App.cpp │ └── README.md ├── FirmwareApi │ ├── CMakeLists.txt │ ├── FirmwareApiApp.cpp │ └── README.md ├── Generic_Sample │ ├── CMakeLists.txt │ └── Sample_ControlAPP.cpp ├── I2C_AUX_Samples │ ├── CMakeLists.txt │ ├── I2C_AUX_Sample_App.cpp │ └── README.md ├── IntelArcSync │ ├── CMakeLists.txt │ ├── IntelArcSync_App.cpp │ └── README.md ├── Media_Samples │ ├── CMakeLists.txt │ ├── Media_Sample_App.cpp │ └── README.md ├── Overclocking_Sample │ ├── CMakeLists.txt │ ├── README.md │ └── Sample_OverclockAPP.cpp ├── Panel_descriptor_Samples │ ├── CMakeLists.txt │ └── Panel_descriptor_Sample_App.cpp ├── Power_Feature_Samples │ ├── CMakeLists.txt │ ├── PowerFeature_Sample_App.cpp │ └── README.md ├── README.md ├── Scaling_Samples │ ├── CMakeLists.txt │ └── Scaling_App.cpp ├── ScdcRead │ ├── CMakeLists.txt │ ├── README.md │ └── ScdcReadApp.cpp ├── Telemetry_Samples │ ├── CMakeLists.txt │ ├── README.md │ └── Sample_TelemetryAPP.cpp ├── UBRR_Sample │ ├── CMakeLists.txt │ └── UBRR_Sample_App.cpp └── inc │ └── GenericIGCLApp.h ├── Source └── cApiWrapper.cpp ├── include └── igcl_api.h └── third-party-software.txt /LICENSE: -------------------------------------------------------------------------------- 1 | Intel Software License Agreement 2 | 10.07.21 3 | 4 | Use and Redistribution. You may use and redistribute Intel’s Control API software and the header files for the Intel® Graphics Control Library (collectively, the “Software”), solely for use on Intel platforms, provided the following conditions are met: 5 | * Redistributions must reproduce the above copyright notice and the following terms of use in the Software and in the documentation and/or other materials provided with the distribution. 6 | * Neither the name of Intel nor the names of its suppliers may be used to endorse or promote products derived from this Software without specific prior written permission. 7 | * No reverse engineering, decompilation, or disassembly of Software provided to you in binary form is permitted. 8 | 9 | Third Party Software. The Software may contain Third Party Software. “Third Party Software” is third party software, open source software or other Intel software listed in the “third-party-software.txt” or other similarly named text file that is included with the Software. Third Party Software, even if included with the distribution of the Software, may be governed by separate license terms, including without limitation, third party license terms, open source software notices and terms, and/or other Intel software license terms. These separate license terms solely govern your use of the Third Party Software. 10 | 11 | Ownership. Title to the Software and all copies remain with Intel or its suppliers. 12 | 13 | DISCLAIMER. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE DISCLAIMED. THIS SOFTWARE IS NOT INTENDED FOR USE IN SYSTEMS OR APPLICATIONS WHERE FAILURE OF THE SOFTWARE MAY CAUSE PERSONAL INJURY OR DEATH AND YOU AGREE THAT YOU ARE FULLY RESPONSIBLE FOR ANY CLAIMS, COSTS, DAMAGES, EXPENSES, AND ATTORNEYS’ FEES ARISING OUT OF ANY SUCH USE, EVEN IF ANY CLAIM ALLEGES THAT INTEL WAS NEGLIGENT REGARDING THE DESIGN OR MANUFACTURE OF THE SOFTWARE. 14 | 15 | LIMITATION OF LIABILITY; INDEMNITY. IN NO EVENT WILL INTEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. YOU AGREE TO INDEMNIFY, DEFEND, AND HOLD INTEL HARMLESS AGAINST ANY CLAIMS, DAMAGES, AND EXPENSES RESULTING FROM YOUR USE OR UNAUTHORIZED USE OF THE SOFTWARE. 16 | 17 | No support. Intel may make changes to the Software, at any time without notice, and is not obligated to support, update or provide training for the Software. 18 | 19 | Termination. Your right to use the Software is terminated immediately in the event of your breach of this agreement. 20 | 21 | Feedback. Should you provide Intel with comments, modifications, corrections, enhancements or other input (“Feedback”) related to the Software Intel will be free to use, disclose, reproduce, license or otherwise distribute or exploit the Feedback in its sole discretion without any obligations or restrictions of any kind, including without limitation, intellectual property rights or licensing obligations. 22 | 23 | Compliance with laws. You agree to comply with all applicable laws and regulations governing your use, transfer, import or export (or prohibition thereof) of the Software. 24 | 25 | Governing law. All disputes will be governed by the laws of the United States of America and the State of Delaware without reference to conflict of law principles and subject to the exclusive jurisdiction of the state or federal courts sitting in the State of Delaware, and each party agrees that it submits to the personal jurisdiction and venue of those courts and waives any objections. The United Nations Convention on Contracts for the International Sale of Goods (1980) is specifically excluded and will not apply to the Software. 26 | 27 | Severability. The parties intend that if a court holds that any provision of this agreement is invalid or unenforceable under applicable law, the court will modify the provision to the minimum extent necessary to make it valid and enforceable or sever and delete the provision from this agreement. Any change to or deletion of a provision of this agreement under this Section will not affect the validity or enforceability of the remainder of this agreement, which will continue in full force and effect. 28 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | Intel Software License Agreement 2 | 10.07.21 3 | 4 | Use and Redistribution. You may use and redistribute Intel’s Control API software and the header files for the Intel® Graphics Control Library (collectively, the “Software”), solely for use on Intel platforms, provided the following conditions are met: 5 | * Redistributions must reproduce the above copyright notice and the following terms of use in the Software and in the documentation and/or other materials provided with the distribution. 6 | * Neither the name of Intel nor the names of its suppliers may be used to endorse or promote products derived from this Software without specific prior written permission. 7 | * No reverse engineering, decompilation, or disassembly of Software provided to you in binary form is permitted. 8 | 9 | Third Party Software. The Software may contain Third Party Software. “Third Party Software” is third party software, open source software or other Intel software listed in the “third-party-software.txt” or other similarly named text file that is included with the Software. Third Party Software, even if included with the distribution of the Software, may be governed by separate license terms, including without limitation, third party license terms, open source software notices and terms, and/or other Intel software license terms. These separate license terms solely govern your use of the Third Party Software. 10 | 11 | Ownership. Title to the Software and all copies remain with Intel or its suppliers. 12 | 13 | DISCLAIMER. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE DISCLAIMED. THIS SOFTWARE IS NOT INTENDED FOR USE IN SYSTEMS OR APPLICATIONS WHERE FAILURE OF THE SOFTWARE MAY CAUSE PERSONAL INJURY OR DEATH AND YOU AGREE THAT YOU ARE FULLY RESPONSIBLE FOR ANY CLAIMS, COSTS, DAMAGES, EXPENSES, AND ATTORNEYS’ FEES ARISING OUT OF ANY SUCH USE, EVEN IF ANY CLAIM ALLEGES THAT INTEL WAS NEGLIGENT REGARDING THE DESIGN OR MANUFACTURE OF THE SOFTWARE. 14 | 15 | LIMITATION OF LIABILITY; INDEMNITY. IN NO EVENT WILL INTEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. YOU AGREE TO INDEMNIFY, DEFEND, AND HOLD INTEL HARMLESS AGAINST ANY CLAIMS, DAMAGES, AND EXPENSES RESULTING FROM YOUR USE OR UNAUTHORIZED USE OF THE SOFTWARE. 16 | 17 | No support. Intel may make changes to the Software, at any time without notice, and is not obligated to support, update or provide training for the Software. 18 | 19 | Termination. Your right to use the Software is terminated immediately in the event of your breach of this agreement. 20 | 21 | Feedback. Should you provide Intel with comments, modifications, corrections, enhancements or other input (“Feedback”) related to the Software Intel will be free to use, disclose, reproduce, license or otherwise distribute or exploit the Feedback in its sole discretion without any obligations or restrictions of any kind, including without limitation, intellectual property rights or licensing obligations. 22 | 23 | Compliance with laws. You agree to comply with all applicable laws and regulations governing your use, transfer, import or export (or prohibition thereof) of the Software. 24 | 25 | Governing law. All disputes will be governed by the laws of the United States of America and the State of Delaware without reference to conflict of law principles and subject to the exclusive jurisdiction of the state or federal courts sitting in the State of Delaware, and each party agrees that it submits to the personal jurisdiction and venue of those courts and waives any objections. The United Nations Convention on Contracts for the International Sale of Goods (1980) is specifically excluded and will not apply to the Software. 26 | 27 | Severability. The parties intend that if a court holds that any provision of this agreement is invalid or unenforceable under applicable law, the court will modify the provision to the minimum extent necessary to make it valid and enforceable or sever and delete the provision from this agreement. Any change to or deletion of a provision of this agreement under this Section will not affect the validity or enforceability of the remainder of this agreement, which will continue in full force and effect. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Intel Graphics Control Library (IGCL) 2 | Header, wrapper library and samples of IGCL version 1.0 3 | 4 | 5 | # Introduction 6 | IGCL is meant to be a collection of high level APIs for all control aspects of hardware, primarily graphics. This is replacement of legacy Intel CUISDK which used to be released only to OEM's and selected customers. IGCL allows global control and tweaking of display, media & 3D capabilities. 7 | 8 | # Notes 9 | * IGCL binaries are distributed as part of Intel Graphics driver package. 10 | * Header & library wrapper code are provided here to help developers with their application development. 11 | * For API/spec questions or issues, for now, use the "Issues" tab under Github. For issues related to an already shipped binary of this spec, contact standard Intel customer support for Graphics. 12 | * Performance & Telemetry API's, i.e., Engine/Fan/Telemetry/Frequency/Memory/Overclock/PCI/Power/Temperature are limited to 64-bit applications as of now. This is a Level0 limitation. 13 | 14 | # Usage 15 | cmake.exe -B -S -G "Visual Studio 17 2022" -A x64 16 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation. 3 | 4 | ## Reporting a Vulnerability 5 | Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). 6 | -------------------------------------------------------------------------------- /Samples/3D_Feature_Samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME 3D_Feature_Samples) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(3D_Feature_Samples VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/3D_Feature_Sample_App.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/3D_Feature_Samples/README.md: -------------------------------------------------------------------------------- 1 | Sample Application for 3D Feature interfaces -------------------------------------------------------------------------------- /Samples/Color_Samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME Color_Samples) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(Color_Samples VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/ColorAlgorithms_App.cpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/Color_Sample_App.cpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/ColorAlgorithms_App.h 9 | ${ROOT_DIR}/Source/cApiWrapper.cpp 10 | ) 11 | 12 | if(MSVC) 13 | set_target_properties(${TARGET_NAME} 14 | PROPERTIES 15 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 16 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 17 | ) 18 | 19 | ADD_DEFINITIONS(-DUNICODE) 20 | ADD_DEFINITIONS(-D_UNICODE) 21 | endif() 22 | 23 | include_directories(${ROOT_DIR}/include) 24 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/Color_Samples/ColorAlgorithms.cpp: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // 3 | // Copyright (c) Intel Corporation (2021-2022) 4 | // 5 | // INTEL MAKES NO WARRANTY OF ANY KIND REGARDING THE CODE. THIS CODE IS LICENSED 6 | // ON AN "AS IS" BASIS AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 7 | // INSTALLATION, TRAINING OR OTHER SERVICES. INTEL DOES NOT PROVIDE ANY UPDATES, 8 | // ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY WARRANTY OF 9 | // MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR ANY PARTICULAR PURPOSE, OR ANY 10 | // OTHER WARRANTY. Intel disclaims all liability, including liability for 11 | // infringement of any proprietary rights, relating to use of the code. No license, 12 | // express or implied, by estoppel or otherwise, to any intellectual property 13 | // rights is granted herein. 14 | // 15 | //-------------------------------------------------------------------------- 16 | 17 | /** 18 | * 19 | * @file ColorAlgorithms.cpp 20 | * @brief This file contains the algorithms for Color Sample APP. 21 | * 22 | */ 23 | 24 | #include "ColorAlgorithms.h" 25 | 26 | /*************************************************************** 27 | * @brief 28 | * MatrixMult3x3With3x1 29 | * @param Matrix1, Matrix2, Result 30 | * @return void 31 | ***************************************************************/ 32 | void MatrixMult3x3With3x1(const double Matrix1[3][3], const double Matrix2[3], double Result[3]) 33 | { 34 | double Tmp[3]; 35 | 36 | Tmp[0] = Matrix1[0][0] * Matrix2[0] + Matrix1[0][1] * Matrix2[1] + Matrix1[0][2] * Matrix2[2]; 37 | Tmp[1] = Matrix1[1][0] * Matrix2[0] + Matrix1[1][1] * Matrix2[1] + Matrix1[1][2] * Matrix2[2]; 38 | Tmp[2] = Matrix1[2][0] * Matrix2[0] + Matrix1[2][1] * Matrix2[1] + Matrix1[2][2] * Matrix2[2]; 39 | 40 | Result[0] = Tmp[0]; 41 | Result[1] = Tmp[1]; 42 | Result[2] = Tmp[2]; 43 | } 44 | 45 | /*************************************************************** 46 | * @brief 47 | * MatrixMult3x3 48 | * @param Matrix1[3][3], Matrix2[3][3], Result[3][3] 49 | * @return void 50 | ***************************************************************/ 51 | void MatrixMult3x3(const double Matrix1[3][3], const double Matrix2[3][3], double Result[3][3]) 52 | { 53 | double Tmp[3][3]; 54 | 55 | for (int y = 0; y < 3; y++) 56 | { 57 | for (int x = 0; x < 3; x++) 58 | { 59 | Tmp[y][x] = Matrix1[y][0] * Matrix2[0][x] + Matrix1[y][1] * Matrix2[1][x] + Matrix1[y][2] * Matrix2[2][x]; 60 | } 61 | } 62 | 63 | memcpy_s(Result, sizeof(Tmp), Tmp, sizeof(Tmp)); 64 | } 65 | 66 | /*************************************************************** 67 | * @brief 68 | * MatrixDeterminant3x3 69 | * @param Matrix[3][3] 70 | * @return void 71 | ***************************************************************/ 72 | double MatrixDeterminant3x3(const double Matrix[3][3]) 73 | { 74 | double Result; 75 | 76 | Result = Matrix[0][0] * (Matrix[1][1] * Matrix[2][2] - Matrix[1][2] * Matrix[2][1]); 77 | Result -= Matrix[0][1] * (Matrix[1][0] * Matrix[2][2] - Matrix[1][2] * Matrix[2][0]); 78 | Result += Matrix[0][2] * (Matrix[1][0] * Matrix[2][1] - Matrix[1][1] * Matrix[2][0]); 79 | 80 | return Result; 81 | } 82 | 83 | /*************************************************************** 84 | * @brief 85 | * MatrixInverse3x3 86 | * @param Matrix[3][3], Result[3][3] 87 | * @return void 88 | ***************************************************************/ 89 | void MatrixInverse3x3(const double Matrix[3][3], double Result[3][3]) 90 | { 91 | double Tmp[3][3]; 92 | double Determinant = MatrixDeterminant3x3(Matrix); 93 | 94 | if (0 != Determinant) 95 | { 96 | Tmp[0][0] = (Matrix[1][1] * Matrix[2][2] - Matrix[1][2] * Matrix[2][1]) / Determinant; 97 | Tmp[0][1] = (Matrix[0][2] * Matrix[2][1] - Matrix[2][2] * Matrix[0][1]) / Determinant; 98 | Tmp[0][2] = (Matrix[0][1] * Matrix[1][2] - Matrix[0][2] * Matrix[1][1]) / Determinant; 99 | Tmp[1][0] = (Matrix[1][2] * Matrix[2][0] - Matrix[1][0] * Matrix[2][2]) / Determinant; 100 | Tmp[1][1] = (Matrix[0][0] * Matrix[2][2] - Matrix[0][2] * Matrix[2][0]) / Determinant; 101 | Tmp[1][2] = (Matrix[0][2] * Matrix[1][0] - Matrix[0][0] * Matrix[1][2]) / Determinant; 102 | Tmp[2][0] = (Matrix[1][0] * Matrix[2][1] - Matrix[1][1] * Matrix[2][0]) / Determinant; 103 | Tmp[2][1] = (Matrix[0][1] * Matrix[2][0] - Matrix[0][0] * Matrix[2][1]) / Determinant; 104 | Tmp[2][2] = (Matrix[0][0] * Matrix[1][1] - Matrix[0][1] * Matrix[1][0]) / Determinant; 105 | 106 | Result[0][0] = Tmp[0][0]; 107 | Result[0][1] = Tmp[0][1]; 108 | Result[0][2] = Tmp[0][2]; 109 | Result[1][0] = Tmp[1][0]; 110 | Result[1][1] = Tmp[1][1]; 111 | Result[1][2] = Tmp[1][2]; 112 | Result[2][0] = Tmp[2][0]; 113 | Result[2][1] = Tmp[2][1]; 114 | Result[2][2] = Tmp[2][2]; 115 | } 116 | } 117 | 118 | /*************************************************************** 119 | * @brief 120 | * MatrixMultScalar3x3 121 | * @param Matrix[3][3], double 122 | * @return void 123 | ***************************************************************/ 124 | void MatrixMultScalar3x3(double Matrix[3][3], double Multiplier) 125 | { 126 | for (int y = 0; y < 3; y++) 127 | { 128 | for (int x = 0; x < 3; x++) 129 | { 130 | Matrix[y][x] *= Multiplier; 131 | } 132 | } 133 | } 134 | 135 | /*************************************************************** 136 | * @brief 137 | * MatrixMaxSumOfRow3x3 138 | * @param Matrix[3][3] 139 | * @return void 140 | ***************************************************************/ 141 | double MatrixMaxSumOfRow3x3(const double Matrix[3][3]) 142 | { 143 | double Val, MaxVal = -10.0; 144 | 145 | for (int y = 0; y < 3; y++) 146 | { 147 | Val = Matrix[y][0] + Matrix[y][1] + Matrix[y][2]; 148 | MaxVal = max(Val, MaxVal); 149 | } 150 | 151 | return MaxVal; 152 | } 153 | 154 | /*************************************************************** 155 | * @brief 156 | * MatrixNormalize3x3 157 | * @param Mat[3][3] 158 | * @return void 159 | ***************************************************************/ 160 | void MatrixNormalize3x3(double Mat[3][3]) 161 | { 162 | double Val = 0; 163 | double Maxrow = MatrixMaxSumOfRow3x3(Mat); 164 | 165 | if (Maxrow > 1) 166 | { 167 | MatrixMultScalar3x3(Mat, (1.0 / Maxrow)); 168 | } 169 | } 170 | 171 | /*************************************************************** 172 | * @brief 173 | * CreateRGB2XYZMatrix 174 | * @param ColorSpace, RGB2XYZ[3][3] 175 | * return void 176 | ***************************************************************/ 177 | void CreateRGB2XYZMatrix(ColorSpace Cspace, double RGB2XYZ[3][3]) 178 | { 179 | double XYZsum[3]; 180 | double Z[4]; 181 | double XYZw[3]; 182 | 183 | Z[0] = 1 - Cspace.White.CIEx - Cspace.White.CIEy; 184 | Z[1] = 1 - Cspace.Red.CIEx - Cspace.Red.CIEy; 185 | Z[2] = 1 - Cspace.Green.CIEx - Cspace.Green.CIEy; 186 | Z[3] = 1 - Cspace.Blue.CIEx - Cspace.Blue.CIEy; 187 | 188 | XYZw[0] = Cspace.White.CIEx / Cspace.White.CIEy; 189 | XYZw[1] = 1; 190 | XYZw[2] = Z[0] / Cspace.White.CIEy; 191 | 192 | double XYZRGB[3][3] = { { Cspace.Red.CIEx, Cspace.Green.CIEx, Cspace.Blue.CIEx }, { Cspace.Red.CIEy, Cspace.Green.CIEy, Cspace.Blue.CIEy }, { Z[1], Z[2], Z[3] } }; 193 | double Mat1[3][3]; 194 | 195 | MatrixInverse3x3(XYZRGB, Mat1); 196 | MatrixMult3x3With3x1(Mat1, XYZw, XYZsum); 197 | 198 | double Mat2[3][3] = { { XYZsum[0], 0, 0 }, { 0, XYZsum[1], 0 }, { 0, 0, XYZsum[2] } }; 199 | 200 | MatrixMult3x3(XYZRGB, Mat2, RGB2XYZ); 201 | } 202 | 203 | /*************************************************************** 204 | * @brief 205 | * CreateMatrixForMappingPanelToSRGBColorSpace 206 | * This funtion is called with PanelColorSpace which maps it with the SRGB color space 207 | * @param ColorSpace, GeneratedOutputMatrix[3][3] 208 | * @return void 209 | ***************************************************************/ 210 | void CreateMatrixForMappingPanelToSRGBColorSpace(ColorSpace PanelColorSpace, double GeneratedOutputMatrix[3][3]) 211 | { 212 | // standard SRGB color space harcoded https://en.wikipedia.org/wiki/SRGB 213 | static ColorSpace SRGBColorSpace = { 214 | { 0.3127, 0.3290, 1.0 }, // white x,y,Y 215 | { 0.64, 0.33, 0.2126 }, // red 216 | { 0.30, 0.60, 0.7152 }, // green 217 | { 0.15, 0.060, 0.0722 } // blue 218 | }; 219 | double RGB2XYZ_Target[3][3]; 220 | double RGB2XYZ_Panel[3][3]; 221 | double XYZ2RGB_Panel[3][3]; 222 | 223 | CreateRGB2XYZMatrix(SRGBColorSpace, RGB2XYZ_Target); // convert SRGB to XYZ 224 | 225 | CreateRGB2XYZMatrix(PanelColorSpace, RGB2XYZ_Panel); // convert Panel to XYZ 226 | MatrixInverse3x3(RGB2XYZ_Panel, XYZ2RGB_Panel); 227 | MatrixMult3x3(XYZ2RGB_Panel, RGB2XYZ_Target, GeneratedOutputMatrix); 228 | MatrixNormalize3x3(GeneratedOutputMatrix); 229 | } -------------------------------------------------------------------------------- /Samples/Color_Samples/ColorAlgorithms.h: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // 3 | // Copyright (c) Intel Corporation (2021-2022) 4 | // 5 | // INTEL MAKES NO WARRANTY OF ANY KIND REGARDING THE CODE. THIS CODE IS LICENSED 6 | // ON AN "AS IS" BASIS AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 7 | // INSTALLATION, TRAINING OR OTHER SERVICES. INTEL DOES NOT PROVIDE ANY UPDATES, 8 | // ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY WARRANTY OF 9 | // MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR ANY PARTICULAR PURPOSE, OR ANY 10 | // OTHER WARRANTY. Intel disclaims all liability, including liability for 11 | // infringement of any proprietary rights, relating to use of the code. No license, 12 | // express or implied, by estoppel or otherwise, to any intellectual property 13 | // rights is granted herein. 14 | // 15 | //-------------------------------------------------------------------------- 16 | 17 | /** 18 | * 19 | * @file ColorAlgorithms.h 20 | * @brief 21 | * 22 | */ 23 | 24 | #pragma once 25 | 26 | #include 27 | #include 28 | 29 | // https://en.wikipedia.org/wiki/CIE_1931_color_space#CIE_xy_chromaticity_diagram_and_the_CIE_xyY_color_space 30 | typedef struct 31 | { 32 | double CIEx; 33 | double CIEy; 34 | double CIELuminance; 35 | } IPIXEL_xyY; 36 | 37 | typedef struct ColorSpace 38 | { 39 | IPIXEL_xyY White; 40 | IPIXEL_xyY Red; 41 | IPIXEL_xyY Green; 42 | IPIXEL_xyY Blue; 43 | } ColorSpace; 44 | 45 | void MatrixMult3x3With3x1(const double Matrix1[3][3], const double Matrix2[3], double Result[3]); 46 | void MatrixMult3x3(const double Matrix1[3][3], const double Matrix2[3][3], double Result[3][3]); 47 | double MatrixDeterminant3x3(const double Matrix[3][3]); 48 | void MatrixInverse3x3(const double Matrix[3][3], double Result[3][3]); 49 | void MatrixMultScalar3x3(double Matrix[3][3], double Multiplier); 50 | double MatrixMaxSumOfRow3x3(const double Matrix[3][3]); 51 | void MatrixNormalize3x3(double Mat[3][3]); 52 | void CreateRGB2XYZMatrix(ColorSpace Cspace, double RGB2XYZ[3][3]); 53 | void CreateMatrixForMappingPanelToSRGBColorSpace(ColorSpace PanelColorSpace, double GeneratedOutputMatrix[3][3]); 54 | -------------------------------------------------------------------------------- /Samples/Color_Samples/ColorAlgorithms_App.cpp: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // Copyright (C) 2022 Intel Corporation 3 | // 4 | // 5 | // 6 | // SPDX-License-Identifier: MIT 7 | //-------------------------------------------------------------------------- 8 | 9 | /** 10 | * 11 | * @file ColorAlgorithms_App.cpp 12 | * @brief This file contains the algorithms for Color Sample APP. 13 | * 14 | */ 15 | 16 | #include "ColorAlgorithms_App.h" 17 | 18 | /*************************************************************** 19 | * @brief 20 | * MatrixMult3x3With3x1 21 | * @param Matrix1, Matrix2, Result 22 | * @return void 23 | ***************************************************************/ 24 | void MatrixMult3x3With3x1(const double Matrix1[3][3], const double Matrix2[3], double Result[3]) 25 | { 26 | double Tmp[3]; 27 | 28 | Tmp[0] = Matrix1[0][0] * Matrix2[0] + Matrix1[0][1] * Matrix2[1] + Matrix1[0][2] * Matrix2[2]; 29 | Tmp[1] = Matrix1[1][0] * Matrix2[0] + Matrix1[1][1] * Matrix2[1] + Matrix1[1][2] * Matrix2[2]; 30 | Tmp[2] = Matrix1[2][0] * Matrix2[0] + Matrix1[2][1] * Matrix2[1] + Matrix1[2][2] * Matrix2[2]; 31 | 32 | Result[0] = Tmp[0]; 33 | Result[1] = Tmp[1]; 34 | Result[2] = Tmp[2]; 35 | } 36 | 37 | /*************************************************************** 38 | * @brief 39 | * MatrixMult3x3 40 | * @param Matrix1[3][3], Matrix2[3][3], Result[3][3] 41 | * @return void 42 | ***************************************************************/ 43 | void MatrixMult3x3(const double Matrix1[3][3], const double Matrix2[3][3], double Result[3][3]) 44 | { 45 | double Tmp[3][3]; 46 | 47 | for (int y = 0; y < 3; y++) 48 | { 49 | for (int x = 0; x < 3; x++) 50 | { 51 | Tmp[y][x] = Matrix1[y][0] * Matrix2[0][x] + Matrix1[y][1] * Matrix2[1][x] + Matrix1[y][2] * Matrix2[2][x]; 52 | } 53 | } 54 | 55 | memcpy_s(Result, sizeof(Tmp), Tmp, sizeof(Tmp)); 56 | } 57 | 58 | /*************************************************************** 59 | * @brief 60 | * MatrixDeterminant3x3 61 | * @param Matrix[3][3] 62 | * @return void 63 | ***************************************************************/ 64 | double MatrixDeterminant3x3(const double Matrix[3][3]) 65 | { 66 | double Result; 67 | 68 | Result = Matrix[0][0] * (Matrix[1][1] * Matrix[2][2] - Matrix[1][2] * Matrix[2][1]); 69 | Result -= Matrix[0][1] * (Matrix[1][0] * Matrix[2][2] - Matrix[1][2] * Matrix[2][0]); 70 | Result += Matrix[0][2] * (Matrix[1][0] * Matrix[2][1] - Matrix[1][1] * Matrix[2][0]); 71 | 72 | return Result; 73 | } 74 | 75 | /*************************************************************** 76 | * @brief 77 | * MatrixInverse3x3 78 | * @param Matrix[3][3], Result[3][3] 79 | * @return void 80 | ***************************************************************/ 81 | void MatrixInverse3x3(const double Matrix[3][3], double Result[3][3]) 82 | { 83 | double Tmp[3][3]; 84 | double Determinant = MatrixDeterminant3x3(Matrix); 85 | 86 | if (0 != Determinant) 87 | { 88 | Tmp[0][0] = (Matrix[1][1] * Matrix[2][2] - Matrix[1][2] * Matrix[2][1]) / Determinant; 89 | Tmp[0][1] = (Matrix[0][2] * Matrix[2][1] - Matrix[2][2] * Matrix[0][1]) / Determinant; 90 | Tmp[0][2] = (Matrix[0][1] * Matrix[1][2] - Matrix[0][2] * Matrix[1][1]) / Determinant; 91 | Tmp[1][0] = (Matrix[1][2] * Matrix[2][0] - Matrix[1][0] * Matrix[2][2]) / Determinant; 92 | Tmp[1][1] = (Matrix[0][0] * Matrix[2][2] - Matrix[0][2] * Matrix[2][0]) / Determinant; 93 | Tmp[1][2] = (Matrix[0][2] * Matrix[1][0] - Matrix[0][0] * Matrix[1][2]) / Determinant; 94 | Tmp[2][0] = (Matrix[1][0] * Matrix[2][1] - Matrix[1][1] * Matrix[2][0]) / Determinant; 95 | Tmp[2][1] = (Matrix[0][1] * Matrix[2][0] - Matrix[0][0] * Matrix[2][1]) / Determinant; 96 | Tmp[2][2] = (Matrix[0][0] * Matrix[1][1] - Matrix[0][1] * Matrix[1][0]) / Determinant; 97 | 98 | Result[0][0] = Tmp[0][0]; 99 | Result[0][1] = Tmp[0][1]; 100 | Result[0][2] = Tmp[0][2]; 101 | Result[1][0] = Tmp[1][0]; 102 | Result[1][1] = Tmp[1][1]; 103 | Result[1][2] = Tmp[1][2]; 104 | Result[2][0] = Tmp[2][0]; 105 | Result[2][1] = Tmp[2][1]; 106 | Result[2][2] = Tmp[2][2]; 107 | } 108 | } 109 | 110 | /*************************************************************** 111 | * @brief 112 | * MatrixMultScalar3x3 113 | * @param Matrix[3][3], double 114 | * @return void 115 | ***************************************************************/ 116 | void MatrixMultScalar3x3(double Matrix[3][3], double Multiplier) 117 | { 118 | for (int y = 0; y < 3; y++) 119 | { 120 | for (int x = 0; x < 3; x++) 121 | { 122 | Matrix[y][x] *= Multiplier; 123 | } 124 | } 125 | } 126 | 127 | /*************************************************************** 128 | * @brief 129 | * MatrixMaxSumOfRow3x3 130 | * @param Matrix[3][3] 131 | * @return void 132 | ***************************************************************/ 133 | double MatrixMaxSumOfRow3x3(const double Matrix[3][3]) 134 | { 135 | double Val, MaxVal = -10.0; 136 | 137 | for (int y = 0; y < 3; y++) 138 | { 139 | Val = Matrix[y][0] + Matrix[y][1] + Matrix[y][2]; 140 | MaxVal = max(Val, MaxVal); 141 | } 142 | 143 | return MaxVal; 144 | } 145 | 146 | /*************************************************************** 147 | * @brief 148 | * MatrixNormalize3x3 149 | * @param Mat[3][3] 150 | * @return void 151 | ***************************************************************/ 152 | void MatrixNormalize3x3(double Mat[3][3]) 153 | { 154 | double Val = 0; 155 | double Maxrow = MatrixMaxSumOfRow3x3(Mat); 156 | 157 | if (Maxrow > 1) 158 | { 159 | MatrixMultScalar3x3(Mat, (1.0 / Maxrow)); 160 | } 161 | } 162 | 163 | /*************************************************************** 164 | * @brief 165 | * CreateRGB2XYZMatrix 166 | * @param ColorSpace, RGB2XYZ[3][3] 167 | * return void 168 | ***************************************************************/ 169 | void CreateRGB2XYZMatrix(ColorSpace Cspace, double RGB2XYZ[3][3]) 170 | { 171 | double XYZsum[3]; 172 | double Z[4]; 173 | double XYZw[3]; 174 | 175 | Z[0] = 1 - Cspace.White.CIEx - Cspace.White.CIEy; 176 | Z[1] = 1 - Cspace.Red.CIEx - Cspace.Red.CIEy; 177 | Z[2] = 1 - Cspace.Green.CIEx - Cspace.Green.CIEy; 178 | Z[3] = 1 - Cspace.Blue.CIEx - Cspace.Blue.CIEy; 179 | 180 | XYZw[0] = Cspace.White.CIEx / Cspace.White.CIEy; 181 | XYZw[1] = 1; 182 | XYZw[2] = Z[0] / Cspace.White.CIEy; 183 | 184 | double XYZRGB[3][3] = { { Cspace.Red.CIEx, Cspace.Green.CIEx, Cspace.Blue.CIEx }, { Cspace.Red.CIEy, Cspace.Green.CIEy, Cspace.Blue.CIEy }, { Z[1], Z[2], Z[3] } }; 185 | double Mat1[3][3]; 186 | 187 | MatrixInverse3x3(XYZRGB, Mat1); 188 | MatrixMult3x3With3x1(Mat1, XYZw, XYZsum); 189 | 190 | double Mat2[3][3] = { { XYZsum[0], 0, 0 }, { 0, XYZsum[1], 0 }, { 0, 0, XYZsum[2] } }; 191 | 192 | MatrixMult3x3(XYZRGB, Mat2, RGB2XYZ); 193 | } 194 | 195 | /*************************************************************** 196 | * @brief 197 | * CreateMatrixToScaleAndRotatePanelToContentColorSpace 198 | * This funtion is called with PanelColorSpace which maps it with the Content color space 199 | * @param ColorSpace,ContentColorSpace, GeneratedOutputMatrix[3][3] 200 | * @return void 201 | ***************************************************************/ 202 | void CreateMatrixToScaleAndRotatePanelToContentColorSpace(ColorSpace PanelColorSpace, ColorSpace ContentColorSpace, double GeneratedOutputMatrix[3][3]) 203 | { 204 | double RGB2XYZ_Content[3][3]; 205 | double RGB2XYZ_Panel[3][3]; 206 | double XYZ2RGB_Panel[3][3]; 207 | 208 | CreateRGB2XYZMatrix(ContentColorSpace, RGB2XYZ_Content); // convert ContentColorSpace to XYZ 209 | CreateRGB2XYZMatrix(PanelColorSpace, RGB2XYZ_Panel); // convert Panel to XYZ 210 | MatrixInverse3x3(RGB2XYZ_Panel, XYZ2RGB_Panel); 211 | MatrixMult3x3(XYZ2RGB_Panel, RGB2XYZ_Content, GeneratedOutputMatrix); 212 | MatrixNormalize3x3(GeneratedOutputMatrix); 213 | } -------------------------------------------------------------------------------- /Samples/Color_Samples/ColorAlgorithms_App.h: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // Copyright (C) 2022 Intel Corporation 3 | // 4 | // 5 | // 6 | // SPDX-License-Identifier: MIT 7 | //-------------------------------------------------------------------------- 8 | 9 | /** 10 | * 11 | * @file ColorAlgorithms_App.h 12 | * @brief 13 | * 14 | */ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | // https://en.wikipedia.org/wiki/CIE_1931_color_space#CIE_xy_chromaticity_diagram_and_the_CIE_xyY_color_space 22 | typedef struct 23 | { 24 | double CIEx; 25 | double CIEy; 26 | double CIELuminance; 27 | } IPIXEL_xyY; 28 | 29 | typedef struct ColorSpace 30 | { 31 | IPIXEL_xyY White; 32 | IPIXEL_xyY Red; 33 | IPIXEL_xyY Green; 34 | IPIXEL_xyY Blue; 35 | } ColorSpace; 36 | 37 | void MatrixMult3x3With3x1(const double Matrix1[3][3], const double Matrix2[3], double Result[3]); 38 | void MatrixMult3x3(const double Matrix1[3][3], const double Matrix2[3][3], double Result[3][3]); 39 | double MatrixDeterminant3x3(const double Matrix[3][3]); 40 | void MatrixInverse3x3(const double Matrix[3][3], double Result[3][3]); 41 | void MatrixMultScalar3x3(double Matrix[3][3], double Multiplier); 42 | double MatrixMaxSumOfRow3x3(const double Matrix[3][3]); 43 | void MatrixNormalize3x3(double Mat[3][3]); 44 | void CreateRGB2XYZMatrix(ColorSpace Cspace, double RGB2XYZ[3][3]); 45 | void CreateMatrixToScaleAndRotatePanelToContentColorSpace(ColorSpace PanelColorSpace, ColorSpace ContentColorSpace, double GeneratedOutputMatrix[3][3]); 46 | -------------------------------------------------------------------------------- /Samples/Color_Samples/README.md: -------------------------------------------------------------------------------- 1 | Sample Application for Color interfaces -------------------------------------------------------------------------------- /Samples/CombinedDisplay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME CombinedDisplay) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(CombinedDisplay VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/CombinedDisplay_Sample_App.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/CombinedDisplay/Disable.cfg: -------------------------------------------------------------------------------- 1 | ## syntax - OpType and NumOutputs must be placed at first. Configuration item label is case sensitive. 2 | 3 | OpType = 3 # Operation type: 1 -- Is_Supported_Config, 2 -- Enable, 3 -- Disable, 4 -- Query_Config 4 | NumOutputs = 4 # Number of (display) outputs: has to be 2 or greater, maximum is 4. 5 | DisplayOrder = 0,1,2,3 # which displays are involved: 0 indicates the first, 1 indicates the 2nd, and so on. order matters, "1 0" means display 1 will be viewed as first elected and display 0 is will be viewed as 2nd selected. 6 | CombinedDesktopWidth = 3840 # combined display width 7 | CombinedDesktopHeight = 2160 # combined display height 8 | 9 | # ChildInfo = Display Number,{FbSrc},{FbPos},Orientation,{Target Mode} where 10 | # FbSrc = {left,top,right,bottom} 11 | # FbPos = {left,top,right,bottom} 12 | # Display Orientation = 0 (0 rotation), 2 (180 rotation) 13 | # Target Mode = {width, height, refresh} : If 0, this means using native target mode instead of custom mode 14 | ChildInfo = 0,{0,0,1920,1080},{0,0,1920,1080}, 0, {0,0,0} 15 | ChildInfo = 1,{1920,0,3840,1080},{0,0,1920,1080}, 0, {0,0,0} 16 | ChildInfo = 2,{0,1080,1920,2160},{0,0,1920,1080}, 0, {0,0,0} 17 | ChildInfo = 3,{1920,1080,3840,2160},{0,0,1920,1080}, 0, {0,0,0} -------------------------------------------------------------------------------- /Samples/CombinedDisplay/Enable.cfg: -------------------------------------------------------------------------------- 1 | ## syntax - OpType and NumOutputs must be placed at first. Configuration item label is case sensitive. 2 | 3 | OpType = 2 # Operation type: 1 -- Is_Supported_Config, 2 -- Enable, 3 -- Disable, 4 -- Query_Config 4 | NumOutputs = 2 # Number of (display) outputs: has to be 2 or greater, maximum is 4. 5 | DisplayOrder = 0,1,2,3 # which displays are involved: 0 indicates the first, 1 indicates the 2nd, and so on. order matters, "1 0" means display 1 will be viewed as first elected and display 0 is will be viewed as 2nd selected. 6 | CombinedDesktopWidth = 3840 # combined display width 7 | CombinedDesktopHeight = 1080 # combined display height 8 | 9 | # ChildInfo = Display Number,{FbSrc},{FbPos},Orientation,{Target Mode} where 10 | # FbSrc = {left,top,right,bottom} 11 | # FbPos = {left,top,right,bottom} 12 | # Display Orientation = 0 (0 rotation), 2 (180 rotation) 13 | # Target Mode = {width, height, refresh} : If 0, this means using native target mode instead of custom mode 14 | ChildInfo = 0,{0,0,1920,1080},{0,0,1920,1080}, 0, {0,0,0} 15 | ChildInfo = 1,{1920,0,3840,1080},{0,0,1920,1080}, 0, {0,0,0} 16 | ChildInfo = 2,{0,1080,1920,2160},{0,0,1920,1080}, 0, {0,0,0} 17 | ChildInfo = 3,{1920,1080,3840,2160},{0,0,1920,1080}, 0, {0,0,0} -------------------------------------------------------------------------------- /Samples/CombinedDisplay/Query.cfg: -------------------------------------------------------------------------------- 1 | ## syntax - OpType and NumOutputs must be placed at first. Configuration item label is case sensitive. 2 | 3 | OpType = 4 # Operation type: 1 -- Is_Supported_Config, 2 -- Enable, 3 -- Disable, 4 -- Query_Config 4 | NumOutputs = 4 # Number of (display) outputs: has to be 2 or greater, maximum is 4. 5 | DisplayOrder = 0,1,2,3 # which displays are involved: 0 indicates the first, 1 indicates the 2nd, and so on. order matters, "1 0" means display 1 will be viewed as first elected and display 0 is will be viewed as 2nd selected. 6 | CombinedDesktopWidth = 3840 # combined display width 7 | CombinedDesktopHeight = 2160 # combined display height 8 | 9 | # ChildInfo = Display Number,{FbSrc},{FbPos},Orientation,{Target Mode} where 10 | # FbSrc = {left,top,right,bottom} 11 | # FbPos = {left,top,right,bottom} 12 | # Display Orientation = 0 (0 rotation), 2 (180 rotation) 13 | # Target Mode = {width, height, refresh} : If 0, this means using native target mode instead of custom mode 14 | ChildInfo = 0,{0,0,1920,1080},{0,0,1920,1080}, 0, {0,0,0} 15 | ChildInfo = 1,{1920,0,3840,1080},{0,0,1920,1080}, 0, {0,0,0} 16 | ChildInfo = 2,{0,1080,1920,2160},{0,0,1920,1080}, 0, {0,0,0} 17 | ChildInfo = 3,{1920,1080,3840,2160},{0,0,1920,1080}, 0, {0,0,0} -------------------------------------------------------------------------------- /Samples/CombinedDisplay/README.md: -------------------------------------------------------------------------------- 1 | # Sample Application for Combined Display 2 | 3 | ### Usage: `CombinedDisplay_Sample_App.exe` [Combined Display Port] 4 | ### Combined Display Port - 0 | 1 5 | - Combined Display port number you want to disable or query. Default is 0. 6 | ### Config File - sample config file 7 | - Enable.cfg - Enabling 1x2 mode of Combined Display with 1080p displays 8 | - Disable.cfg - Disabling Combined Display 9 | - Query.cfg - Querying current Combined Display topology 10 | -------------------------------------------------------------------------------- /Samples/Custom_Mode_Samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME Custom_Mode_Samples) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(Custom_Mode_Samples VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/CustomMode_Sample_App.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/Custom_Mode_Samples/CustomMode_Sample_App.cpp: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // Copyright (C) 2022 Intel Corporation 3 | // 4 | // 5 | // 6 | // SPDX-License-Identifier: MIT 7 | //-------------------------------------------------------------------------- 8 | 9 | /** 10 | * 11 | * @file CustomMode_Sample_APP.cpp 12 | * @brief : This file contains the 'main' function and the Custom Mode Sample APP. Program execution begins and ends there. 13 | * 14 | */ 15 | 16 | #define _CRTDBG_MAP_ALLOC 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #define CTL_APIEXPORT // caller of control API DLL shall define this before 25 | // including igcl_api.h 26 | #include "igcl_api.h" 27 | #include "GenericIGCLApp.h" 28 | 29 | #define VOID_POINTER_INCREMENT(p, n) ((void *)((char *)(p) + (n))) 30 | 31 | ctl_result_t GResult = CTL_RESULT_SUCCESS; 32 | 33 | typedef struct _mode 34 | { 35 | uint32_t X; 36 | uint32_t Y; 37 | } mode; 38 | 39 | /*************************************************************** 40 | * @brief 41 | * Get Custom Modes 42 | * @param hDisplayOutput 43 | * @return ctl_result_t 44 | ***************************************************************/ 45 | ctl_result_t GetCustomModes(ctl_display_output_handle_t hDisplayOutput) 46 | { 47 | ctl_result_t Result = CTL_RESULT_SUCCESS; 48 | ctl_get_set_custom_mode_args_t GetNumofCustomModes = { 0 }; 49 | ctl_get_set_custom_mode_args_t GetCustomModes = { 0 }; 50 | ctl_custom_src_mode_t *pCustomSourceModes = NULL; 51 | ctl_custom_src_mode_t *pCustomSourceModesList = NULL; 52 | uint8_t NumOfCustomModes = 0; 53 | size_t pCustomModeSourceSize = 0; 54 | 55 | GetNumofCustomModes.NumOfModes = 0; 56 | GetNumofCustomModes.CustomModeOpType = CTL_CUSTOM_MODE_OPERATION_TYPES_GET_CUSTOM_SOURCE_MODES; 57 | GetNumofCustomModes.pCustomSrcModeList = NULL; 58 | GetNumofCustomModes.Size = sizeof(ctl_get_set_custom_mode_args_t); 59 | GetNumofCustomModes.Version = 0; 60 | 61 | // Get number of custom modes already added. 62 | Result = ctlGetSetCustomMode(hDisplayOutput, &GetNumofCustomModes); 63 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetCustomMode"); 64 | 65 | NumOfCustomModes = GetNumofCustomModes.NumOfModes; 66 | 67 | if (0 == NumOfCustomModes) 68 | { 69 | APP_LOG_WARN("No Custom modes added."); 70 | goto Exit; 71 | } 72 | else 73 | { 74 | APP_LOG_INFO("Number of custom modes:%d", NumOfCustomModes); 75 | } 76 | 77 | pCustomModeSourceSize = NumOfCustomModes * sizeof(ctl_custom_src_mode_t); 78 | 79 | pCustomSourceModes = (ctl_custom_src_mode_t *)malloc(pCustomModeSourceSize); 80 | 81 | EXIT_ON_MEM_ALLOC_FAILURE(pCustomSourceModes, "pCustomSourceModes"); 82 | 83 | memset(pCustomSourceModes, 0, pCustomModeSourceSize); 84 | 85 | GetCustomModes.NumOfModes = NumOfCustomModes; 86 | GetCustomModes.CustomModeOpType = CTL_CUSTOM_MODE_OPERATION_TYPES_GET_CUSTOM_SOURCE_MODES; 87 | GetCustomModes.pCustomSrcModeList = pCustomSourceModes; 88 | GetCustomModes.Size = sizeof(ctl_get_set_custom_mode_args_t); 89 | GetCustomModes.Version = 0; 90 | 91 | // Get custom modes already added. 92 | Result = ctlGetSetCustomMode(hDisplayOutput, &GetCustomModes); 93 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetCustomMode"); 94 | 95 | pCustomSourceModesList = pCustomSourceModes; 96 | 97 | APP_LOG_INFO("No.\tSourceX\tSourceY"); 98 | for (uint8_t i = 0; i < NumOfCustomModes; i++) 99 | { 100 | APP_LOG_INFO(" %d\t%d\t%d", i, pCustomSourceModesList->SourceX, pCustomSourceModesList->SourceY); 101 | pCustomSourceModesList++; 102 | } 103 | 104 | Exit: 105 | CTL_FREE_MEM(pCustomSourceModes); 106 | return Result; 107 | } 108 | 109 | /*************************************************************** 110 | * @brief 111 | * Add Custom Mode(At a time only one custom mode add operation is supported) 112 | * @param hDisplayOutput 113 | * @return ctl_result_t 114 | ***************************************************************/ 115 | ctl_result_t AddCustomModes(ctl_display_output_handle_t hDisplayOutput, uint32_t SourceX, uint32_t SourceY) 116 | { 117 | ctl_result_t Result = CTL_RESULT_SUCCESS; 118 | ctl_get_set_custom_mode_args_t AddCustomMode = { 0 }; 119 | ctl_custom_src_mode_t *pCustomSourceMode = NULL; 120 | 121 | pCustomSourceMode = (ctl_custom_src_mode_t *)malloc(sizeof(ctl_custom_src_mode_t)); 122 | 123 | EXIT_ON_MEM_ALLOC_FAILURE(pCustomSourceMode, "pCustomSourceMode"); 124 | 125 | memset(pCustomSourceMode, 0, sizeof(ctl_custom_src_mode_t)); 126 | 127 | AddCustomMode.NumOfModes = 1; 128 | AddCustomMode.CustomModeOpType = CTL_CUSTOM_MODE_OPERATION_TYPES_ADD_CUSTOM_SOURCE_MODE; 129 | AddCustomMode.pCustomSrcModeList = pCustomSourceMode; 130 | AddCustomMode.Size = sizeof(ctl_get_set_custom_mode_args_t); 131 | AddCustomMode.Version = 0; 132 | 133 | pCustomSourceMode->SourceX = SourceX; 134 | pCustomSourceMode->SourceY = SourceY; 135 | 136 | APP_LOG_INFO("Adding Custom mode X:%d Y:%d", SourceX, SourceY); 137 | 138 | // Add Custom mode. 139 | Result = ctlGetSetCustomMode(hDisplayOutput, &AddCustomMode); 140 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetCustomMode"); 141 | 142 | Exit: 143 | CTL_FREE_MEM(pCustomSourceMode); 144 | return Result; 145 | } 146 | 147 | /*************************************************************** 148 | * @brief 149 | * Add Custom Mode(At a time only one custom mode add operation is supported) 150 | * @param hDisplayOutput 151 | * @return ctl_result_t 152 | ***************************************************************/ 153 | ctl_result_t RemoveCustomModes(ctl_display_output_handle_t hDisplayOutput) 154 | { 155 | // This is a referance example to remove custom modes. 156 | // Here we are removing 2 modes at a time. 157 | // Single or multiple mode removal at a single call is possible. 158 | 159 | ctl_result_t Result = CTL_RESULT_SUCCESS; 160 | ctl_get_set_custom_mode_args_t RemoveCustomModes = { 0 }; 161 | ctl_custom_src_mode_t *pCustomSourceModes = NULL; 162 | ctl_custom_src_mode_t *pCustomSourceModesList = NULL; 163 | uint8_t NumOfModesToRemove = 2; 164 | mode Modes[2] = { { 822, 522 }, { 824, 524 } }; 165 | size_t pCustomModeSourceSize = 0; 166 | 167 | pCustomModeSourceSize = NumOfModesToRemove * sizeof(ctl_custom_src_mode_t); 168 | 169 | pCustomSourceModes = (ctl_custom_src_mode_t *)malloc(pCustomModeSourceSize); 170 | 171 | EXIT_ON_MEM_ALLOC_FAILURE(pCustomSourceModes, "pCustomSourceModes"); 172 | 173 | memset(pCustomSourceModes, 0, pCustomModeSourceSize); 174 | 175 | RemoveCustomModes.NumOfModes = NumOfModesToRemove; 176 | RemoveCustomModes.CustomModeOpType = CTL_CUSTOM_MODE_OPERATION_TYPES_REMOVE_CUSTOM_SOURCE_MODES; 177 | RemoveCustomModes.pCustomSrcModeList = pCustomSourceModes; 178 | RemoveCustomModes.Size = sizeof(ctl_get_set_custom_mode_args_t); 179 | RemoveCustomModes.Version = 0; 180 | 181 | pCustomSourceModesList = pCustomSourceModes; 182 | 183 | for (uint8_t i = 0; i < NumOfModesToRemove; i++) 184 | { 185 | pCustomSourceModesList->SourceX = Modes[i].X; 186 | pCustomSourceModesList->SourceY = Modes[i].Y; 187 | pCustomSourceModesList++; 188 | APP_LOG_INFO("Removing Custom mode X:%d Y:%d", Modes[i].X, Modes[i].Y); 189 | } 190 | 191 | // Add Custom mode. 192 | Result = ctlGetSetCustomMode(hDisplayOutput, &RemoveCustomModes); 193 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetCustomMode"); 194 | 195 | Exit: 196 | CTL_FREE_MEM(pCustomSourceModes); 197 | return Result; 198 | } 199 | 200 | /*************************************************************** 201 | * @brief EnumerateDisplayHandles 202 | * Only for demonstration purpose, API is called for each of the display output handle in below snippet. 203 | * User has to filter through the available display output handle and has to call the API with particular display output handle. 204 | * @param hDisplayOutput, DisplayCount 205 | * @return ctl_result_t 206 | ***************************************************************/ 207 | ctl_result_t EnumerateDisplayHandles(ctl_display_output_handle_t *hDisplayOutput, uint32_t DisplayCount) 208 | { 209 | ctl_result_t Result = CTL_RESULT_SUCCESS; 210 | 211 | for (uint32_t DisplayIndex = 0; DisplayIndex < DisplayCount; DisplayIndex++) 212 | { 213 | ctl_display_properties_t DisplayProperties = {}; 214 | DisplayProperties.Size = sizeof(ctl_display_properties_t); 215 | 216 | EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput[DisplayIndex], "hDisplayOutput"); 217 | 218 | Result = ctlGetDisplayProperties(hDisplayOutput[DisplayIndex], &DisplayProperties); 219 | 220 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetDisplayProperties"); 221 | 222 | bool IsDisplayAttached = DisplayProperties.DisplayConfigFlags & CTL_DISPLAY_CONFIG_FLAG_DISPLAY_ATTACHED; 223 | 224 | if (FALSE == IsDisplayAttached) 225 | { 226 | APP_LOG_WARN("Display %d is not attached, skipping the call for this display", DisplayIndex); 227 | continue; 228 | } 229 | else 230 | { 231 | APP_LOG_INFO("Attached Display Count: %d", DisplayIndex); 232 | } 233 | 234 | // At a time only one custom mode add operation is supported 235 | 236 | Result = AddCustomModes(hDisplayOutput[DisplayIndex], 822, 522); 237 | 238 | STORE_AND_RESET_ERROR(Result); 239 | 240 | Result = AddCustomModes(hDisplayOutput[DisplayIndex], 1248, 702); 241 | 242 | STORE_AND_RESET_ERROR(Result); 243 | 244 | Result = AddCustomModes(hDisplayOutput[DisplayIndex], 824, 524); 245 | 246 | STORE_AND_RESET_ERROR(Result); 247 | 248 | Result = GetCustomModes(hDisplayOutput[DisplayIndex]); 249 | 250 | STORE_AND_RESET_ERROR(Result); 251 | 252 | // Remove custom mode supports one or multiple custom mode removel at a time. 253 | 254 | Result = RemoveCustomModes(hDisplayOutput[DisplayIndex]); 255 | 256 | STORE_AND_RESET_ERROR(Result); 257 | 258 | Result = GetCustomModes(hDisplayOutput[DisplayIndex]); 259 | 260 | STORE_AND_RESET_ERROR(Result); 261 | } 262 | 263 | Exit: 264 | return Result; 265 | } 266 | 267 | /*************************************************************** 268 | * @brief EnumerateTargetDisplays 269 | * Enumerates all the possible target display's for the adapters 270 | * @param hDisplayOutput, AdapterCount, hDevices 271 | * @return ctl_result_t 272 | ***************************************************************/ 273 | ctl_result_t EnumerateTargetDisplays(ctl_display_output_handle_t *hDisplayOutput, uint32_t AdapterCount, ctl_device_adapter_handle_t *hDevices) 274 | { 275 | ctl_result_t Result = CTL_RESULT_SUCCESS; 276 | uint32_t DisplayCount = 0; 277 | 278 | for (uint32_t AdapterIndex = 0; AdapterIndex < AdapterCount; AdapterIndex++) 279 | { 280 | // enumerate all the possible target display's for the adapters 281 | // first step is to get the count 282 | DisplayCount = 0; 283 | 284 | Result = ctlEnumerateDisplayOutputs(hDevices[AdapterIndex], &DisplayCount, hDisplayOutput); 285 | 286 | if (CTL_RESULT_SUCCESS != Result) 287 | { 288 | APP_LOG_WARN("ctlEnumerateDisplayOutputs returned failure code: 0x%X", Result); 289 | STORE_AND_RESET_ERROR(Result); 290 | continue; 291 | } 292 | else if (DisplayCount <= 0) 293 | { 294 | APP_LOG_WARN("Invalid Display Count. skipping display enumration for adapter:%d", AdapterIndex); 295 | continue; 296 | } 297 | 298 | hDisplayOutput = (ctl_display_output_handle_t *)malloc(sizeof(ctl_display_output_handle_t) * DisplayCount); 299 | 300 | EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput, "hDisplayOutput"); 301 | 302 | Result = ctlEnumerateDisplayOutputs(hDevices[AdapterIndex], &DisplayCount, hDisplayOutput); 303 | 304 | if (CTL_RESULT_SUCCESS != Result) 305 | { 306 | APP_LOG_WARN("ctlEnumerateDisplayOutputs returned failure code: 0x%X", Result); 307 | STORE_AND_RESET_ERROR(Result); 308 | } 309 | 310 | // Only for demonstration purpose, API is called for each of the display output handle in below snippet. 311 | // User has to filter through the available display output handle and has to call the API with particular display output handle. 312 | Result = EnumerateDisplayHandles(hDisplayOutput, DisplayCount); 313 | 314 | if (CTL_RESULT_SUCCESS != Result) 315 | { 316 | APP_LOG_WARN("EnumerateDisplayHandles returned failure code: 0x%X", Result); 317 | } 318 | 319 | CTL_FREE_MEM(hDisplayOutput); 320 | } 321 | 322 | Exit: 323 | 324 | CTL_FREE_MEM(hDisplayOutput); 325 | return Result; 326 | } 327 | 328 | /*************************************************************** 329 | * @brief Main Function which calls the Sample Power feature API 330 | * @param 331 | * @return int 332 | ***************************************************************/ 333 | int main() 334 | { 335 | ctl_result_t Result = CTL_RESULT_SUCCESS; 336 | ctl_device_adapter_handle_t *hDevices = NULL; 337 | ctl_display_output_handle_t *hDisplayOutput = NULL; 338 | ctl_device_adapter_properties_t DeviceAdapterProperties = { 0 }; 339 | // Get a handle to the DLL module. 340 | uint32_t AdapterCount = 0; 341 | uint32_t DisplayCount = 0; 342 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 343 | 344 | ctl_init_args_t CtlInitArgs; 345 | ctl_api_handle_t hAPIHandle; 346 | CtlInitArgs.AppVersion = CTL_MAKE_VERSION(CTL_IMPL_MAJOR_VERSION, CTL_IMPL_MINOR_VERSION); 347 | CtlInitArgs.flags = 0; 348 | CtlInitArgs.Size = sizeof(CtlInitArgs); 349 | CtlInitArgs.Version = 0; 350 | ZeroMemory(&CtlInitArgs.ApplicationUID, sizeof(ctl_application_id_t)); 351 | 352 | try 353 | { 354 | Result = ctlInit(&CtlInitArgs, &hAPIHandle); 355 | LOG_AND_EXIT_ON_ERROR(Result, "ctlInit"); 356 | } 357 | catch (const std::bad_array_new_length &e) 358 | { 359 | APP_LOG_ERROR("%s ", e.what()); 360 | } 361 | 362 | // Initialization successful 363 | // Get the list of Intel Adapters 364 | try 365 | { 366 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 367 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 368 | } 369 | catch (const std::bad_array_new_length &e) 370 | { 371 | APP_LOG_ERROR("%s ", e.what()); 372 | } 373 | 374 | hDevices = (ctl_device_adapter_handle_t *)malloc(sizeof(ctl_device_adapter_handle_t) * AdapterCount); 375 | EXIT_ON_MEM_ALLOC_FAILURE(hDevices, "hDevices"); 376 | 377 | try 378 | { 379 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 380 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 381 | } 382 | catch (const std::bad_array_new_length &e) 383 | { 384 | APP_LOG_ERROR("%s ", e.what()); 385 | } 386 | 387 | Result = EnumerateTargetDisplays(hDisplayOutput, AdapterCount, hDevices); 388 | 389 | if (CTL_RESULT_SUCCESS != Result) 390 | { 391 | APP_LOG_ERROR("EnumerateTargetDisplays returned failure code: 0x%X", Result); 392 | STORE_AND_RESET_ERROR(Result); 393 | } 394 | 395 | Exit: 396 | 397 | ctlClose(hAPIHandle); 398 | CTL_FREE_MEM(hDisplayOutput); 399 | CTL_FREE_MEM(hDevices); 400 | APP_LOG_INFO("Overrall test result is 0x%X", GResult); 401 | return GResult; 402 | } 403 | -------------------------------------------------------------------------------- /Samples/Custom_Mode_Samples/README.md: -------------------------------------------------------------------------------- 1 | Sample Application for Custom modes -------------------------------------------------------------------------------- /Samples/DisplayGenlock/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME DisplayGenlock) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(DisplayGenlock VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/DisplayGenlock_Sample_App.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/DisplaySettings/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME DisplaySettings) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(DisplaySettings VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/DisplaySettings_Sample_App.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/DisplaySettings/DisplaySettings_Sample_App.cpp: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // Copyright (C) 2022 Intel Corporation 3 | // 4 | // 5 | // 6 | // SPDX-License-Identifier: MIT 7 | //-------------------------------------------------------------------------- 8 | 9 | /** 10 | * 11 | * @file DisplaySettings_Sample_App.cpp 12 | * @brief : This file contains the 'main' function and the DisplaySettings Sample APP. Program execution begins and ends there. 13 | * 14 | */ 15 | 16 | #define _CRTDBG_MAP_ALLOC 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #define CTL_APIEXPORT // caller of control API DLL shall define this before 25 | // including igcl_api.h 26 | #include "igcl_api.h" 27 | #include "GenericIGCLApp.h" 28 | 29 | #define API_VERSION 0; 30 | 31 | ctl_result_t GResult = CTL_RESULT_SUCCESS; 32 | 33 | /*************************************************************** 34 | * @brief 35 | * Sample test for Get/Set Quantization Range 36 | * @param hDisplayOutput 37 | * @return ctl_result_t 38 | ***************************************************************/ 39 | ctl_result_t TestToGetSetQuantizationRange(ctl_display_output_handle_t hDisplayOutput) 40 | { 41 | ctl_result_t Result = CTL_RESULT_SUCCESS; 42 | ctl_display_settings_t AppliedDisplaySettings = { 0 }; 43 | ctl_display_settings_t NewDisplaySettings = { 0 }; 44 | bool IsControllable, IsSupported = FALSE; 45 | 46 | // GET CALL 47 | AppliedDisplaySettings.Version = API_VERSION; 48 | AppliedDisplaySettings.Size = sizeof(ctl_display_settings_t); 49 | AppliedDisplaySettings.Set = FALSE; 50 | 51 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &AppliedDisplaySettings); 52 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (Quantization Range GET CALL)"); 53 | 54 | IsControllable = (CTL_DISPLAY_SETTING_FLAG_QUANTIZATION_RANGE & AppliedDisplaySettings.ControllableFlags) ? TRUE : FALSE; 55 | IsSupported = (CTL_DISPLAY_SETTING_FLAG_QUANTIZATION_RANGE & AppliedDisplaySettings.SupportedFlags) ? TRUE : FALSE; 56 | 57 | if ((FALSE == IsControllable) || (FALSE == IsSupported)) 58 | { 59 | APP_LOG_WARN("Get/Set Quantization Range is not supported"); 60 | Result = CTL_RESULT_ERROR_UNSUPPORTED_FEATURE; 61 | goto Exit; 62 | } 63 | 64 | APP_LOG_INFO(" Current Applied Quantization Range is %d ", AppliedDisplaySettings.QuantizationRange); 65 | 66 | // SET CALL 67 | NewDisplaySettings.Version = API_VERSION; 68 | NewDisplaySettings.Size = sizeof(ctl_display_settings_t); 69 | NewDisplaySettings.Set = TRUE; 70 | 71 | NewDisplaySettings.ValidFlags = CTL_DISPLAY_SETTING_FLAG_QUANTIZATION_RANGE; 72 | NewDisplaySettings.QuantizationRange = CTL_DISPLAY_SETTING_QUANTIZATION_RANGE_FULL_RANGE; 73 | 74 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &NewDisplaySettings); 75 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (Quantization Range SET CALL)"); 76 | 77 | // GET CALL 78 | AppliedDisplaySettings = { 0 }; 79 | AppliedDisplaySettings.Version = API_VERSION; 80 | AppliedDisplaySettings.Size = sizeof(ctl_display_settings_t); 81 | AppliedDisplaySettings.Set = FALSE; 82 | 83 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &AppliedDisplaySettings); 84 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (Quantization Range GET CALL)"); 85 | APP_LOG_INFO(" Current Quantization Range is %d ", AppliedDisplaySettings.QuantizationRange); 86 | 87 | Exit: 88 | return Result; 89 | } 90 | 91 | /*************************************************************** 92 | * @brief 93 | * Sample test for Get/Set PictureAspectRatio 94 | * @param hDisplayOutput 95 | * @return ctl_result_t 96 | ***************************************************************/ 97 | ctl_result_t TestToGetSetPictureAspectRatio(ctl_display_output_handle_t hDisplayOutput) 98 | { 99 | ctl_result_t Result = CTL_RESULT_SUCCESS; 100 | ctl_display_settings_t AppliedDisplaySettings = { 0 }; 101 | ctl_display_settings_t NewDisplaySettings = { 0 }; 102 | bool IsControllable, IsSupported = FALSE; 103 | 104 | // GET CALL 105 | AppliedDisplaySettings.Version = API_VERSION; 106 | AppliedDisplaySettings.Size = sizeof(ctl_display_settings_t); 107 | AppliedDisplaySettings.Set = FALSE; 108 | 109 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &AppliedDisplaySettings); 110 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (Picture Aspect Ratio GET CALL)"); 111 | 112 | IsControllable = (CTL_DISPLAY_SETTING_FLAG_PICTURE_AR & AppliedDisplaySettings.ControllableFlags) ? TRUE : FALSE; 113 | IsSupported = (CTL_DISPLAY_SETTING_FLAG_PICTURE_AR & AppliedDisplaySettings.SupportedFlags) ? TRUE : FALSE; 114 | 115 | if ((FALSE == IsControllable) || (FALSE == IsSupported)) 116 | { 117 | APP_LOG_WARN("Get/Set PictureAspectRatio is not supported"); 118 | Result = CTL_RESULT_ERROR_UNSUPPORTED_FEATURE; 119 | goto Exit; 120 | } 121 | 122 | APP_LOG_INFO(" Supported Picture Aspect Ratio is %d ", AppliedDisplaySettings.SupportedPictureAR); 123 | APP_LOG_INFO(" Current Applied Picture Aspect Ratio is %d ", AppliedDisplaySettings.PictureAR); 124 | 125 | // CALL TO SET 16_9 126 | if (CTL_DISPLAY_SETTING_PICTURE_AR_FLAG_AR_16_9 & AppliedDisplaySettings.SupportedPictureAR) 127 | { 128 | 129 | NewDisplaySettings.Version = API_VERSION; 130 | NewDisplaySettings.Size = sizeof(ctl_display_settings_t); 131 | NewDisplaySettings.Set = TRUE; 132 | 133 | NewDisplaySettings.ValidFlags = CTL_DISPLAY_SETTING_FLAG_PICTURE_AR; 134 | NewDisplaySettings.PictureAR = CTL_DISPLAY_SETTING_PICTURE_AR_FLAG_AR_16_9; 135 | 136 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &NewDisplaySettings); 137 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (Picture Aspect Ratio SET CALL)"); 138 | } 139 | 140 | // GET CALL 141 | AppliedDisplaySettings = { 0 }; 142 | AppliedDisplaySettings.Version = API_VERSION; 143 | AppliedDisplaySettings.Size = sizeof(ctl_display_settings_t); 144 | AppliedDisplaySettings.Set = FALSE; 145 | 146 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &AppliedDisplaySettings); 147 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (Picture Aspect Ratio GET CALL)"); 148 | APP_LOG_INFO(" Current Picture Aspect Ratio is %d ", AppliedDisplaySettings.PictureAR); 149 | 150 | Exit: 151 | return Result; 152 | } 153 | 154 | /*************************************************************** 155 | * @brief 156 | * Sample test for Get/Set ContentType 157 | * @param hDisplayOutput 158 | * @return ctl_result_t 159 | ***************************************************************/ 160 | ctl_result_t TestToGetSetContentType(ctl_display_output_handle_t hDisplayOutput) 161 | { 162 | ctl_result_t Result = CTL_RESULT_SUCCESS; 163 | ctl_display_settings_t AppliedDisplaySettings = { 0 }; 164 | ctl_display_settings_t NewDisplaySettings = { 0 }; 165 | bool IsControllable, IsSupported = FALSE; 166 | 167 | // GET CALL 168 | AppliedDisplaySettings.Version = API_VERSION; 169 | AppliedDisplaySettings.Size = sizeof(ctl_display_settings_t); 170 | AppliedDisplaySettings.Set = FALSE; 171 | 172 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &AppliedDisplaySettings); 173 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (ContentType GET CALL)"); 174 | 175 | IsControllable = (CTL_DISPLAY_SETTING_FLAG_CONTENT_TYPE & AppliedDisplaySettings.ControllableFlags) ? TRUE : FALSE; 176 | IsSupported = (CTL_DISPLAY_SETTING_FLAG_CONTENT_TYPE & AppliedDisplaySettings.SupportedFlags) ? TRUE : FALSE; 177 | 178 | if ((FALSE == IsControllable) || (FALSE == IsSupported)) 179 | { 180 | APP_LOG_WARN("Get/Set ContentType is not supported"); 181 | Result = CTL_RESULT_ERROR_UNSUPPORTED_FEATURE; 182 | goto Exit; 183 | } 184 | 185 | APP_LOG_INFO(" Current Applied ContentType is %d ", AppliedDisplaySettings.ContentType); 186 | 187 | // CALL TO SET GAMING CONTENT TYPE 188 | NewDisplaySettings.Version = API_VERSION; 189 | NewDisplaySettings.Size = sizeof(ctl_display_settings_t); 190 | NewDisplaySettings.Set = TRUE; 191 | 192 | NewDisplaySettings.ValidFlags = CTL_DISPLAY_SETTING_FLAG_CONTENT_TYPE; 193 | NewDisplaySettings.ContentType = CTL_DISPLAY_SETTING_CONTENT_TYPE_GAMING; 194 | 195 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &NewDisplaySettings); 196 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (ContentType SET CALL)"); 197 | 198 | // GET CALL 199 | AppliedDisplaySettings = { 0 }; 200 | AppliedDisplaySettings.Version = API_VERSION; 201 | AppliedDisplaySettings.Size = sizeof(ctl_display_settings_t); 202 | AppliedDisplaySettings.Set = FALSE; 203 | 204 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &AppliedDisplaySettings); 205 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (ContentType GET CALL)"); 206 | APP_LOG_INFO(" Current ContentType is %d ", AppliedDisplaySettings.ContentType); 207 | 208 | Exit: 209 | return Result; 210 | } 211 | 212 | /*************************************************************** 213 | * @brief 214 | * Sample test for Get/Set LowLatency 215 | * @param hDisplayOutput 216 | * @return ctl_result_t 217 | ***************************************************************/ 218 | ctl_result_t TestToGetSetLowLatency(ctl_display_output_handle_t hDisplayOutput) 219 | { 220 | ctl_result_t Result = CTL_RESULT_SUCCESS; 221 | ctl_display_settings_t AppliedDisplaySettings = { 0 }; 222 | ctl_display_settings_t NewDisplaySettings = { 0 }; 223 | bool IsControllable, IsSupported = FALSE; 224 | 225 | // GET CALL 226 | AppliedDisplaySettings.Version = API_VERSION; 227 | AppliedDisplaySettings.Size = sizeof(ctl_display_settings_t); 228 | AppliedDisplaySettings.Set = FALSE; 229 | 230 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &AppliedDisplaySettings); 231 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (LowLatency GET CALL)"); 232 | 233 | IsControllable = (CTL_DISPLAY_SETTING_FLAG_LOW_LATENCY & AppliedDisplaySettings.ControllableFlags) ? TRUE : FALSE; 234 | IsSupported = (CTL_DISPLAY_SETTING_FLAG_LOW_LATENCY & AppliedDisplaySettings.SupportedFlags) ? TRUE : FALSE; 235 | 236 | if ((FALSE == IsControllable) || (FALSE == IsSupported)) 237 | { 238 | APP_LOG_WARN("Get/Set LowLatency is not supported"); 239 | Result = CTL_RESULT_ERROR_UNSUPPORTED_FEATURE; 240 | goto Exit; 241 | } 242 | 243 | APP_LOG_INFO(" Current Applied LowLatency is %d ", AppliedDisplaySettings.LowLatency); 244 | 245 | // CALL TO ENABLE HDR10+ LOW_LATENCY 246 | NewDisplaySettings.Version = API_VERSION; 247 | NewDisplaySettings.Size = sizeof(ctl_display_settings_t); 248 | NewDisplaySettings.Set = TRUE; 249 | 250 | NewDisplaySettings.ValidFlags = CTL_DISPLAY_SETTING_FLAG_LOW_LATENCY; 251 | NewDisplaySettings.LowLatency = CTL_DISPLAY_SETTING_LOW_LATENCY_ENABLED; 252 | 253 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &NewDisplaySettings); 254 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (LowLatency SET CALL)"); 255 | 256 | // GET CALL 257 | AppliedDisplaySettings = { 0 }; 258 | AppliedDisplaySettings.Version = API_VERSION; 259 | AppliedDisplaySettings.Size = sizeof(ctl_display_settings_t); 260 | AppliedDisplaySettings.Set = FALSE; 261 | 262 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &AppliedDisplaySettings); 263 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (LowLatency GET CALL)"); 264 | APP_LOG_INFO(" Current LowLatency is %d ", AppliedDisplaySettings.LowLatency); 265 | 266 | Exit: 267 | return Result; 268 | } 269 | 270 | /*************************************************************** 271 | * @brief 272 | * Sample test for Get/Set SourceTonemapping 273 | * @param hDisplayOutput 274 | * @return ctl_result_t 275 | ***************************************************************/ 276 | ctl_result_t TestToGetSetSourceTonemapping(ctl_display_output_handle_t hDisplayOutput) 277 | { 278 | ctl_result_t Result = CTL_RESULT_SUCCESS; 279 | ctl_display_settings_t AppliedDisplaySettings = { 0 }; 280 | ctl_display_settings_t NewDisplaySettings = { 0 }; 281 | bool IsControllable, IsSupported = FALSE; 282 | 283 | // GET CALL 284 | AppliedDisplaySettings.Version = API_VERSION; 285 | AppliedDisplaySettings.Size = sizeof(ctl_display_settings_t); 286 | AppliedDisplaySettings.Set = FALSE; 287 | 288 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &AppliedDisplaySettings); 289 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (SourceTM GET CALL)"); 290 | 291 | IsControllable = (CTL_DISPLAY_SETTING_FLAG_SOURCE_TM & AppliedDisplaySettings.ControllableFlags) ? TRUE : FALSE; 292 | IsSupported = (CTL_DISPLAY_SETTING_FLAG_SOURCE_TM & AppliedDisplaySettings.SupportedFlags) ? TRUE : FALSE; 293 | 294 | if ((FALSE == IsControllable) || (FALSE == IsSupported)) 295 | { 296 | APP_LOG_WARN("Get/Set SourceTM is not supported"); 297 | Result = CTL_RESULT_ERROR_UNSUPPORTED_FEATURE; 298 | goto Exit; 299 | } 300 | 301 | APP_LOG_INFO(" Current Applied SourceTM is %d ", AppliedDisplaySettings.SourceTM); 302 | 303 | // CALL TO ENABLE HDR10+ SOURCETM 304 | NewDisplaySettings.Version = API_VERSION; 305 | NewDisplaySettings.Size = sizeof(ctl_display_settings_t); 306 | NewDisplaySettings.Set = TRUE; 307 | 308 | NewDisplaySettings.ValidFlags = CTL_DISPLAY_SETTING_FLAG_SOURCE_TM; 309 | NewDisplaySettings.SourceTM = CTL_DISPLAY_SETTING_SOURCETM_ENABLED; 310 | 311 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &NewDisplaySettings); 312 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (SourceTM SET CALL)"); 313 | 314 | // GET CALL 315 | AppliedDisplaySettings = { 0 }; 316 | AppliedDisplaySettings.Version = API_VERSION; 317 | AppliedDisplaySettings.Size = sizeof(ctl_display_settings_t); 318 | AppliedDisplaySettings.Set = FALSE; 319 | 320 | Result = ctlGetSetDisplaySettings(hDisplayOutput, &AppliedDisplaySettings); 321 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (SourceTM GET CALL)"); 322 | APP_LOG_INFO(" Current SourceTM is %d ", AppliedDisplaySettings.SourceTM); 323 | 324 | Exit: 325 | return Result; 326 | } 327 | 328 | /*************************************************************** 329 | * @brief EnumerateDisplayHandles 330 | * Only for demonstration purpose, API is called for each of the display output handle in below snippet. 331 | * User has to filter through the available display output handle and has to call the API with particular display output handle. 332 | * @param hDisplayOutput, DisplayCount 333 | * @return ctl_result_t 334 | ***************************************************************/ 335 | ctl_result_t EnumerateDisplayHandles(ctl_display_output_handle_t *hDisplayOutput, uint32_t DisplayCount) 336 | { 337 | ctl_result_t Result = CTL_RESULT_SUCCESS; 338 | 339 | for (uint32_t DisplayIndex = 0; DisplayIndex < DisplayCount; DisplayIndex++) 340 | { 341 | ctl_display_properties_t DisplayProperties = {}; 342 | DisplayProperties.Size = sizeof(ctl_display_properties_t); 343 | 344 | EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput[DisplayIndex], "hDisplayOutput"); 345 | 346 | Result = ctlGetDisplayProperties(hDisplayOutput[DisplayIndex], &DisplayProperties); 347 | 348 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetDisplayProperties"); 349 | 350 | bool IsDisplayAttached = DisplayProperties.DisplayConfigFlags & CTL_DISPLAY_CONFIG_FLAG_DISPLAY_ATTACHED; 351 | 352 | if (FALSE == IsDisplayAttached) 353 | { 354 | continue; 355 | } 356 | 357 | APP_LOG_INFO("Attached Display Count: %d", DisplayIndex); 358 | 359 | // Get/Set Quantization Range 360 | Result = TestToGetSetQuantizationRange(hDisplayOutput[DisplayIndex]); 361 | STORE_AND_RESET_ERROR(Result); 362 | 363 | // Get/Set Picture Aspect Ratio 364 | Result = TestToGetSetPictureAspectRatio(hDisplayOutput[DisplayIndex]); 365 | STORE_AND_RESET_ERROR(Result); 366 | 367 | // Get/Set Content type 368 | Result = TestToGetSetContentType(hDisplayOutput[DisplayIndex]); 369 | STORE_AND_RESET_ERROR(Result); 370 | 371 | // Get/Set HDR10+ Low Latency Flag 372 | Result = TestToGetSetLowLatency(hDisplayOutput[DisplayIndex]); 373 | STORE_AND_RESET_ERROR(Result); 374 | 375 | // Get/Set HDR10+ Source Tonemapping Flag 376 | Result = TestToGetSetSourceTonemapping(hDisplayOutput[DisplayIndex]); 377 | STORE_AND_RESET_ERROR(Result); 378 | } 379 | 380 | Exit: 381 | return Result; 382 | } 383 | 384 | /*************************************************************** 385 | * @brief EnumerateTargetDisplays 386 | * Enumerates all the possible target display's for the adapters 387 | * @param hDisplayOutput, AdapterCount, hDevices 388 | * @return ctl_result_t 389 | ***************************************************************/ 390 | ctl_result_t EnumerateTargetDisplays(ctl_display_output_handle_t *hDisplayOutput, uint32_t AdapterCount, ctl_device_adapter_handle_t *hDevices) 391 | { 392 | ctl_result_t Result = CTL_RESULT_SUCCESS; 393 | uint32_t DisplayCount = 0; 394 | 395 | for (uint32_t AdapterIndex = 0; AdapterIndex < AdapterCount; AdapterIndex++) 396 | { 397 | // enumerate all the possible target display's for the adapters 398 | // first step is to get the count 399 | DisplayCount = 0; 400 | 401 | Result = ctlEnumerateDisplayOutputs(hDevices[AdapterIndex], &DisplayCount, hDisplayOutput); 402 | 403 | if (CTL_RESULT_SUCCESS != Result) 404 | { 405 | APP_LOG_WARN("ctlEnumerateDisplayOutputs returned failure code: 0x%X", Result); 406 | STORE_AND_RESET_ERROR(Result); 407 | continue; 408 | } 409 | else if (DisplayCount <= 0) 410 | { 411 | APP_LOG_WARN("Invalid Display Count. skipping display enumration for adapter:%d", AdapterIndex); 412 | continue; 413 | } 414 | 415 | hDisplayOutput = (ctl_display_output_handle_t *)malloc(sizeof(ctl_display_output_handle_t) * DisplayCount); 416 | 417 | EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput, "hDisplayOutput"); 418 | 419 | Result = ctlEnumerateDisplayOutputs(hDevices[AdapterIndex], &DisplayCount, hDisplayOutput); 420 | 421 | if (CTL_RESULT_SUCCESS != Result) 422 | { 423 | APP_LOG_WARN("ctlEnumerateDisplayOutputs returned failure code: 0x%X", Result); 424 | STORE_AND_RESET_ERROR(Result); 425 | } 426 | 427 | // Only for demonstration purpose, API is called for each of the display output handle in below snippet. 428 | // User has to filter through the available display output handle and has to call the API with particular display output handle. 429 | Result = EnumerateDisplayHandles(hDisplayOutput, DisplayCount); 430 | 431 | if (CTL_RESULT_SUCCESS != Result) 432 | { 433 | APP_LOG_WARN("EnumerateDisplayHandles returned failure code: 0x%X", Result); 434 | } 435 | 436 | CTL_FREE_MEM(hDisplayOutput); 437 | } 438 | 439 | Exit: 440 | 441 | CTL_FREE_MEM(hDisplayOutput); 442 | return Result; 443 | } 444 | 445 | /*************************************************************** 446 | * @brief Main Function which calls the Sample Display Settings API 447 | * @param 448 | * @return int 449 | ***************************************************************/ 450 | int main() 451 | { 452 | ctl_result_t Result = CTL_RESULT_SUCCESS; 453 | ctl_device_adapter_handle_t *hDevices = NULL; 454 | ctl_display_output_handle_t *hDisplayOutput = NULL; 455 | ctl_device_adapter_properties_t DeviceAdapterProperties = { 0 }; 456 | // Get a handle to the DLL module. 457 | uint32_t AdapterCount = 0; 458 | uint32_t DisplayCount = 0; 459 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 460 | 461 | ctl_init_args_t CtlInitArgs; 462 | ctl_api_handle_t hAPIHandle; 463 | CtlInitArgs.AppVersion = CTL_MAKE_VERSION(CTL_IMPL_MAJOR_VERSION, CTL_IMPL_MINOR_VERSION); 464 | CtlInitArgs.flags = 0; 465 | CtlInitArgs.Size = sizeof(CtlInitArgs); 466 | CtlInitArgs.Version = 0; 467 | ZeroMemory(&CtlInitArgs.ApplicationUID, sizeof(ctl_application_id_t)); 468 | 469 | try 470 | { 471 | Result = ctlInit(&CtlInitArgs, &hAPIHandle); 472 | LOG_AND_EXIT_ON_ERROR(Result, "ctlInit"); 473 | } 474 | catch (const std::bad_array_new_length &e) 475 | { 476 | APP_LOG_ERROR("%s ", e.what()); 477 | } 478 | 479 | // Initialization successful 480 | // Get the list of Intel Adapters 481 | try 482 | { 483 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 484 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 485 | } 486 | catch (const std::bad_array_new_length &e) 487 | { 488 | APP_LOG_ERROR("%s ", e.what()); 489 | } 490 | 491 | hDevices = (ctl_device_adapter_handle_t *)malloc(sizeof(ctl_device_adapter_handle_t) * AdapterCount); 492 | EXIT_ON_MEM_ALLOC_FAILURE(hDevices, "hDevices"); 493 | 494 | try 495 | { 496 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 497 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 498 | } 499 | catch (const std::bad_array_new_length &e) 500 | { 501 | APP_LOG_ERROR("%s ", e.what()); 502 | } 503 | 504 | Result = EnumerateTargetDisplays(hDisplayOutput, AdapterCount, hDevices); 505 | 506 | if (CTL_RESULT_SUCCESS != Result) 507 | { 508 | APP_LOG_ERROR("EnumerateTargetDisplays returned failure code: 0x%X", Result); 509 | STORE_AND_RESET_ERROR(Result); 510 | } 511 | 512 | Exit: 513 | 514 | ctlClose(hAPIHandle); 515 | CTL_FREE_MEM(hDisplayOutput); 516 | CTL_FREE_MEM(hDevices); 517 | APP_LOG_INFO("Overrall test result is 0x%X", GResult); 518 | return GResult; 519 | } 520 | -------------------------------------------------------------------------------- /Samples/DisplaySettings/README.md: -------------------------------------------------------------------------------- 1 | Sample Application for Display Settings interfaces -------------------------------------------------------------------------------- /Samples/DynamicContrastEnhancement_Sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME DynamicContrastEnhancement_Sample) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(DynamicContrastEnhancement_Sample VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/DynamicContrastEnhancement_Sample_App.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/DynamicContrastEnhancement_Sample/DynamicContrastEnhancement_Sample_App.cpp: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // Copyright (C) 2022 Intel Corporation 3 | // 4 | // 5 | // 6 | // SPDX-License-Identifier: MIT 7 | //-------------------------------------------------------------------------- 8 | 9 | /** 10 | * 11 | * @file DynamicContrastEnhancement_Sample_App.cpp 12 | * This sample app performs the following operations for each adapter: 13 | * (1) Gets the feature status, and if feature is enabled, returns the histogram, and calculates the average luminance 14 | * (2) Sets the target brightness according to the user-provided brightness percent value and brightness phase-in speed multiplier 15 | */ 16 | 17 | #define _CRTDBG_MAP_ALLOC 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | using namespace std; 24 | 25 | #define CTL_APIEXPORT // caller of control API DLL shall define this before 26 | // including control_api.h 27 | #include "igcl_api.h" 28 | #include "GenericIGCLApp.h" 29 | 30 | ctl_result_t GResult = CTL_RESULT_SUCCESS; 31 | static bool IsSetOp = FALSE; 32 | static bool Enable = FALSE; 33 | static uint32_t TargetBrightnessPercent = 0; 34 | static double PhaseinSpeedMultiplier = 0.0; 35 | 36 | #define BLC_PWM_LOW_PRECISION_FACTOR 100 37 | 38 | /*************************************************************** 39 | * @brief PrintUsage 40 | * Print usage of Dynamic Contrast Enhancement sample app 41 | * @param pAppName 42 | * @return void 43 | ***************************************************************/ 44 | void PrintUsage(char *pAppName) 45 | { 46 | printf("Dynamic Contrast Enhancement Sample Application\n"); 47 | printf("\nUsage: %s \n", pAppName); 48 | printf("\n\n"); 49 | printf("\tget : get the feature status and, if feature is enabled, returns the average luminance and current histogram\n"); 50 | printf("\tset : to enable/disable feature, and to set the brightness with the phase-in speed multiplier when feature is enabled\n"); 51 | printf(" :\n"); 52 | printf("\tenable : to enable the feature\n"); 53 | printf("\tdisable : to disable the feature\n"); 54 | printf("\tenable : to set brightness with phase-in speed multiplier\n"); 55 | printf("\t\t : 10 to 100 (applicable if feature is enabled)\n"); 56 | printf("\t\t : 0 (no phase-in) or 1.0 to 2.0 (applicable if feature is enabled)\n"); 57 | printf("Examples:\n"); 58 | printf("\t%s get\n", pAppName); 59 | printf("\t%s set enable\n", pAppName); 60 | printf("\t%s set enable 50 0\n", pAppName); 61 | printf("\t%s set enable 75 1.2\n", pAppName); 62 | printf("\t%s set disable\n", pAppName); 63 | } 64 | 65 | /*************************************************************** 66 | * @brief ParseTargetBrightnessPercent 67 | * Parse target brightness percent value 68 | * @param pArg 69 | * @return ctl_result_t 70 | ***************************************************************/ 71 | ctl_result_t ParseTargetBrightnessPercent(char *pArg) 72 | { 73 | ctl_result_t Result = CTL_RESULT_SUCCESS; 74 | 75 | for (uint8_t i = 0; i < strlen(pArg); i++) 76 | { 77 | if (0 == isdigit(pArg[i])) 78 | { 79 | Result = CTL_RESULT_ERROR_INVALID_ARGUMENT; 80 | break; 81 | } 82 | } 83 | 84 | if (CTL_RESULT_SUCCESS == Result) 85 | { 86 | TargetBrightnessPercent = atoi(pArg); 87 | if (TargetBrightnessPercent < 10 || TargetBrightnessPercent > 100) 88 | { 89 | Result = CTL_RESULT_ERROR_INVALID_ARGUMENT; 90 | } 91 | } 92 | 93 | return Result; 94 | } 95 | 96 | /*************************************************************** 97 | * @brief ParsePhaseinSpeedMultiplier 98 | * Parse phase-in speed multiplier value 99 | * @param pArg 100 | * @return ctl_result_t 101 | ***************************************************************/ 102 | ctl_result_t ParsePhaseinSpeedMultiplier(char *pArg) 103 | { 104 | ctl_result_t Result = CTL_RESULT_SUCCESS; 105 | 106 | PhaseinSpeedMultiplier = atof(pArg); 107 | 108 | if (PhaseinSpeedMultiplier == 0.0) 109 | { 110 | if (0 != strcmp(pArg, "0") && 0 != strcmp(pArg, "0.0")) 111 | { 112 | Result = CTL_RESULT_ERROR_INVALID_ARGUMENT; 113 | } 114 | } 115 | else 116 | { 117 | if (pArg[0] == '0') // invalid input that begins with 0 (e.g., 01) 118 | { 119 | Result = CTL_RESULT_ERROR_INVALID_ARGUMENT; 120 | } 121 | else if (PhaseinSpeedMultiplier < 1.0 || PhaseinSpeedMultiplier > 2.0) 122 | { 123 | Result = CTL_RESULT_ERROR_INVALID_ARGUMENT; 124 | } 125 | } 126 | 127 | return Result; 128 | } 129 | 130 | /*************************************************************** 131 | * @brief ParseSetOperationArgs 132 | * Parse the set operation command line arguments 133 | * @param argc, pArgv[] 134 | * @return ctl_result_t 135 | ***************************************************************/ 136 | ctl_result_t ParseSetOperationArgs(int argc, char *pArgv[]) 137 | { 138 | ctl_result_t Result = CTL_RESULT_SUCCESS; 139 | 140 | if (0 != strcmp(pArgv[1], "set")) 141 | { 142 | Result = CTL_RESULT_ERROR_INVALID_OPERATION_TYPE; 143 | EXIT_ON_ERROR(Result); 144 | } 145 | 146 | if (0 == strcmp(pArgv[2], "enable")) 147 | { 148 | Enable = TRUE; 149 | } 150 | else if (0 == strcmp(pArgv[2], "disable") && argc == 3) 151 | { 152 | Enable = FALSE; 153 | } 154 | else 155 | { 156 | Result = CTL_RESULT_ERROR_INVALID_ARGUMENT; 157 | EXIT_ON_ERROR(Result); 158 | } 159 | 160 | if (argc == 5) 161 | { 162 | Result = ParseTargetBrightnessPercent(pArgv[3]); 163 | if (CTL_RESULT_SUCCESS != Result) 164 | { 165 | EXIT_ON_ERROR(Result); 166 | } 167 | Result = ParsePhaseinSpeedMultiplier(pArgv[4]); 168 | if (CTL_RESULT_SUCCESS != Result) 169 | { 170 | EXIT_ON_ERROR(Result); 171 | } 172 | } 173 | 174 | Exit: 175 | if (CTL_RESULT_SUCCESS == Result) 176 | { 177 | IsSetOp = TRUE; 178 | } 179 | else 180 | { 181 | PrintUsage(pArgv[0]); 182 | } 183 | 184 | return Result; 185 | } 186 | 187 | /*************************************************************** 188 | * @brief GetCmdlineArgs 189 | * Get command line arguments 190 | * @param argc, pArgv[] 191 | * @return ctl_result_t 192 | ***************************************************************/ 193 | ctl_result_t GetCmdlineArgs(int argc, char *pArgv[]) 194 | { 195 | ctl_result_t Result = CTL_RESULT_SUCCESS; 196 | 197 | if ((argc < 2 || argc > 5) || argc == 4) 198 | { 199 | PrintUsage(pArgv[0]); 200 | Result = CTL_RESULT_ERROR_INVALID_ARGUMENT; 201 | } 202 | else if (argc == 2) 203 | { 204 | if (0 == strcmp(pArgv[1], "get")) 205 | { 206 | IsSetOp = FALSE; 207 | } 208 | else 209 | { 210 | PrintUsage(pArgv[0]); 211 | Result = CTL_RESULT_ERROR_INVALID_OPERATION_TYPE; 212 | } 213 | } 214 | else 215 | { 216 | Result = ParseSetOperationArgs(argc, pArgv); 217 | } 218 | 219 | return Result; 220 | } 221 | 222 | /*************************************************************** 223 | * @brief GetSRGBDecodingValue 224 | * Calculate the normalized SRGB transformed value 225 | * @param Input 226 | * @return double 227 | ***************************************************************/ 228 | double GetSRGBDecodingValue(double Input) 229 | { 230 | 231 | // https://en.wikipedia.org/wiki/SRGB#Transfer_function_(%22gamma%22) 232 | 233 | double Output; 234 | 235 | if (Input <= 0.04045) 236 | { 237 | Output = Input / 12.92; 238 | } 239 | else 240 | { 241 | Output = pow(((Input + 0.055) / 1.055), 2.4); 242 | } 243 | 244 | return Output; 245 | } 246 | 247 | /*************************************************************** 248 | * @brief CalculateAverageLuminance 249 | * Calculate the average luminance 250 | * @param DceArgs 251 | * @return double 252 | ***************************************************************/ 253 | double CalculateAverageLuminance(const ctl_dce_args_t DceArgs) 254 | { 255 | uint32_t TotalNumPixels = 0; 256 | double DeGammaLUT = 0.0; 257 | double TotalLuminance = 0.0; 258 | double AverageLuminance = 0.0; 259 | double BinIndexNormalizingFactor = 0.0; 260 | 261 | BinIndexNormalizingFactor = 1.0 / (double)(DceArgs.NumBins - 1); 262 | for (uint32_t Index = 0; Index < DceArgs.NumBins; Index++) 263 | { 264 | TotalNumPixels += DceArgs.pHistogram[Index]; 265 | DeGammaLUT = GetSRGBDecodingValue((double)Index * BinIndexNormalizingFactor); 266 | TotalLuminance += (double)DceArgs.pHistogram[Index] * DeGammaLUT; 267 | } 268 | 269 | if (0 != TotalNumPixels) 270 | { 271 | AverageLuminance = (TotalLuminance / TotalNumPixels) * BLC_PWM_LOW_PRECISION_FACTOR; 272 | } 273 | 274 | return AverageLuminance; 275 | } 276 | 277 | /*************************************************************** 278 | * @brief PrintGetOperationOutputs 279 | * Print feature status, calculated avg luminance and histogram 280 | * @param DceArgs 281 | * @return void 282 | ***************************************************************/ 283 | void PrintGetOperationOutputs(const ctl_dce_args_t DceArgs) 284 | { 285 | printf("IsSupported = %d\n", DceArgs.IsSupported); 286 | printf("Enable = %d\n", DceArgs.Enable); 287 | 288 | if (TRUE == DceArgs.IsSupported && TRUE == DceArgs.Enable && DceArgs.NumBins > 0) 289 | { 290 | double AverageLuminance = CalculateAverageLuminance(DceArgs); 291 | printf("Average Luminance: %f\n", AverageLuminance); 292 | 293 | for (uint32_t Index = 0; Index < DceArgs.NumBins; Index++) 294 | { 295 | printf("Histogram Bin[%d] = %d\n", Index, DceArgs.pHistogram[Index]); 296 | } 297 | } 298 | } 299 | 300 | /*************************************************************** 301 | * @brief TestDynamicContrastEnhancement 302 | * Sample test for Dynamic Contrast Enhancement feature 303 | * @param hDevices, AdapterCount 304 | * @return ctl_result_t 305 | ***************************************************************/ 306 | ctl_result_t TestDynamicContrastEnhancement(ctl_device_adapter_handle_t *hDevices, uint32_t AdapterCount) 307 | { 308 | ctl_result_t Result = CTL_RESULT_SUCCESS; 309 | ctl_dce_args_t DceArgs = { 0 }; 310 | ctl_display_output_handle_t *pDisplayOutputs = NULL; 311 | uint32_t DisplayCount = 0; 312 | bool IsDisplayActive = false; 313 | bool IsDisplayAttached = false; 314 | bool IsInternalDisplay = false; 315 | 316 | DceArgs.Set = IsSetOp; 317 | if (TRUE == DceArgs.Set) 318 | { 319 | DceArgs.Enable = Enable; 320 | DceArgs.TargetBrightnessPercent = TargetBrightnessPercent; 321 | DceArgs.PhaseinSpeedMultiplier = PhaseinSpeedMultiplier; 322 | } 323 | 324 | for (uint32_t Index = 0; Index < AdapterCount; Index++) 325 | { 326 | DisplayCount = 0; 327 | 328 | // Enumerate all the possible target displays for the adapters 329 | // First step is to get the count 330 | Result = ctlEnumerateDisplayOutputs(hDevices[Index], &DisplayCount, NULL); 331 | 332 | if (CTL_RESULT_SUCCESS != Result) 333 | { 334 | LOG_AND_STORE_RESET_RESULT_ON_ERROR(Result, "ctlEnumerateDisplayOutputs"); 335 | continue; 336 | } 337 | else if (DisplayCount <= 0) 338 | { 339 | printf("Invalid Display Count. Skipping display enumeration for adapter: %d\n", Index); 340 | continue; 341 | } 342 | 343 | pDisplayOutputs = (ctl_display_output_handle_t *)malloc(sizeof(ctl_display_output_handle_t) * DisplayCount); 344 | EXIT_ON_MEM_ALLOC_FAILURE(pDisplayOutputs, "pDisplayOutputs"); 345 | 346 | Result = ctlEnumerateDisplayOutputs(hDevices[Index], &DisplayCount, pDisplayOutputs); 347 | LOG_AND_STORE_RESET_RESULT_ON_ERROR(Result, "ctlEnumerateDisplayOutputs"); 348 | 349 | for (uint32_t i = 0; i < DisplayCount; i++) 350 | { 351 | ctl_display_properties_t stDisplayProperties = {}; 352 | stDisplayProperties.Size = sizeof(ctl_display_properties_t); 353 | 354 | if (NULL == pDisplayOutputs[i]) 355 | { 356 | printf("pDisplayOutputs[%d] is NULL.\n", i); 357 | Result = CTL_RESULT_ERROR_INVALID_NULL_HANDLE; 358 | EXIT_ON_ERROR(Result); 359 | } 360 | 361 | Result = ctlGetDisplayProperties(pDisplayOutputs[i], &stDisplayProperties); 362 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetDisplayProperties"); 363 | 364 | ctl_adapter_display_encoder_properties_t stDisplayEncoderProperties = {}; 365 | stDisplayEncoderProperties.Size = sizeof(ctl_adapter_display_encoder_properties_t); 366 | 367 | Result = ctlGetAdaperDisplayEncoderProperties(pDisplayOutputs[i], &stDisplayEncoderProperties); 368 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetAdaperDisplayEncoderProperties"); 369 | 370 | IsDisplayActive = stDisplayProperties.DisplayConfigFlags & CTL_DISPLAY_CONFIG_FLAG_DISPLAY_ACTIVE; 371 | IsDisplayAttached = stDisplayProperties.DisplayConfigFlags & CTL_DISPLAY_CONFIG_FLAG_DISPLAY_ATTACHED; 372 | 373 | if (TRUE == IsDisplayActive && TRUE == IsDisplayAttached) 374 | { 375 | IsInternalDisplay = stDisplayEncoderProperties.EncoderConfigFlags & CTL_ENCODER_CONFIG_FLAG_INTERNAL_DISPLAY; 376 | if (FALSE == IsInternalDisplay) 377 | { 378 | printf("Display %d is not an internal display\n", i); 379 | continue; 380 | } 381 | 382 | // For the Get operation, call first time to get the NumBins 383 | Result = ctlGetSetDynamicContrastEnhancement(pDisplayOutputs[i], &DceArgs); 384 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDynamicContrastEnhancement"); 385 | 386 | // For the Get operation, call second time to fill histogram of NumBins * uint32_t size 387 | if (FALSE == DceArgs.Set) 388 | { 389 | if (TRUE == DceArgs.IsSupported && TRUE == DceArgs.Enable && DceArgs.NumBins > 0) 390 | { 391 | DceArgs.pHistogram = (uint32_t *)malloc(sizeof(uint32_t) * DceArgs.NumBins); 392 | EXIT_ON_MEM_ALLOC_FAILURE(DceArgs.pHistogram, "DceArgs.pHistogram"); 393 | 394 | Result = ctlGetSetDynamicContrastEnhancement(pDisplayOutputs[i], &DceArgs); 395 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDynamicContrastEnhancement"); 396 | } 397 | 398 | PrintGetOperationOutputs(DceArgs); 399 | } 400 | } 401 | } 402 | 403 | // Free handle display output pointers 404 | CTL_FREE_MEM(pDisplayOutputs); 405 | } 406 | 407 | Exit: 408 | CTL_FREE_MEM(pDisplayOutputs); 409 | CTL_FREE_MEM(DceArgs.pHistogram) 410 | return Result; 411 | } 412 | 413 | /*************************************************************** 414 | * @brief Main Function that calls the Dynamic Contrast Enhancement API 415 | * @param Argc 416 | * @param pArgv[] 417 | * @return int 418 | ***************************************************************/ 419 | int main(int argc, char *pArgv[]) 420 | { 421 | ctl_result_t Result = CTL_RESULT_SUCCESS; 422 | ctl_device_adapter_handle_t *hDevices = nullptr; 423 | uint32_t AdapterCount = 0; 424 | ctl_init_args_t CtlInitArgs; 425 | ctl_api_handle_t hAPIHandle = nullptr; 426 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 427 | 428 | // Get cmdline arguments 429 | Result = GetCmdlineArgs(argc, pArgv); 430 | LOG_AND_EXIT_ON_ERROR(Result, "GetCmdlineArgs"); 431 | 432 | ZeroMemory(&CtlInitArgs, sizeof(ctl_init_args_t)); 433 | CtlInitArgs.AppVersion = CTL_MAKE_VERSION(CTL_IMPL_MAJOR_VERSION, CTL_IMPL_MINOR_VERSION); 434 | CtlInitArgs.flags = 0; 435 | CtlInitArgs.Size = sizeof(CtlInitArgs); 436 | CtlInitArgs.Version = 0; 437 | 438 | try 439 | { 440 | Result = ctlInit(&CtlInitArgs, &hAPIHandle); 441 | LOG_AND_EXIT_ON_ERROR(Result, "ctlInit"); 442 | } 443 | catch (const std::bad_array_new_length &e) 444 | { 445 | printf("%s \n", e.what()); 446 | } 447 | 448 | // Initialization successful 449 | // Get the list of Intel Adapters 450 | try 451 | { 452 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, NULL); 453 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 454 | } 455 | catch (const std::bad_array_new_length &e) 456 | { 457 | printf("%s \n", e.what()); 458 | } 459 | 460 | hDevices = (ctl_device_adapter_handle_t *)malloc(sizeof(ctl_device_adapter_handle_t) * AdapterCount); 461 | EXIT_ON_MEM_ALLOC_FAILURE(hDevices, "hDevices"); 462 | 463 | try 464 | { 465 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 466 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 467 | } 468 | catch (const std::bad_array_new_length &e) 469 | { 470 | printf("%s \n", e.what()); 471 | } 472 | 473 | Result = TestDynamicContrastEnhancement(hDevices, AdapterCount); 474 | LOG_AND_STORE_RESET_RESULT_ON_ERROR(Result, "TestDynamicContrastEnhancement"); 475 | 476 | Exit: 477 | 478 | ctlClose(hAPIHandle); 479 | CTL_FREE_MEM(hDevices); 480 | 481 | printf("Overall test result is 0x%X\n", GResult); 482 | 483 | return GResult; 484 | } -------------------------------------------------------------------------------- /Samples/Edid_Management_Sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME Edid_Management_Sample) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(Edid_Management_Sample VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Edid_Mgmt_Sample_App.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/Edid_Management_Sample/README.md: -------------------------------------------------------------------------------- 1 | # Sample Application for EDID management APIs. 2 | 3 | ## EDID Management API 4 | - App calls EDID management operations on all connected displays based on input args from commandline. 5 | ### Below Operations are added as Sample 6 | - EDID Lock : Monitor or User Supplied EDID (hard coded in Sample app) 7 | - EDID Unlock 8 | - EDID Override with User Supplied EDID (hard coded in Sample app) 9 | - EDID Remove 10 | - EDID Read (Currently Active) 11 | ### Commandline Args 12 | - If no args passed all EDID management operations mentioned above will be performed on all connected displays. 13 | - '[Operation Type]' 14 | - If passed only specified operation performed on all connected displays. 15 | - Options: 16 | - '-lock' : locks Monitor EDID, if called with Target ID as 2nd param, locks Supplied EDID (App hardcoded). 17 | - '-unlock' : unlock previous operation 18 | - '-over' : Overrides EDID 19 | - '-rem' : Removed EDID 20 | - '-read' : Reads Current Active EDID 21 | - '-help' : Display usage 22 | - '<-a Adapter#>' 23 | - Specify adapter number [min:0, max:4]. 0 (default) - apply operation to all adapters 24 | - '<-t Target ID?' 25 | - Specify Target ID in hex. e.g. '1040' 26 | - '<-e Path\To\EDID binary>' 27 | - Specify EDID binary 28 | 29 | ### Usage 30 | Edid\_Mgmt\_Sample\_app.exe [Operation] <-a Adapter#> <-t Target_ID> <-e Bbin_Filename> 31 | 32 | ### Example 33 | Edid\_Mgmt\_Sample\_app.exe -read -a 0 -t 1040 -e IGCL_DELU2410.bin 34 | 35 | -------------------------------------------------------------------------------- /Samples/FirmwareApi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME FirmwareApi) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(FirmwareApi VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/FirmwareApiApp.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/FirmwareApi/FirmwareApiApp.cpp: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // Copyright (C) 2022 Intel Corporation 3 | // 4 | // 5 | // 6 | // SPDX-License-Identifier: MIT 7 | //-------------------------------------------------------------------------- 8 | 9 | /** 10 | * 11 | * @file FirmwareApiApp.cpp 12 | * @brief This file contains the I2C AUX Sample App & the 'main' function. Program execution begins and ends there. 13 | * 14 | */ 15 | 16 | #define _CRTDBG_MAP_ALLOC 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #define CTL_APIEXPORT // caller of control API DLL shall define this before 25 | // including igcl_api.h 26 | #include "igcl_api.h" 27 | #include "GenericIGCLApp.h" 28 | 29 | ctl_result_t IsDiscreteGfxAdapter(ctl_device_adapter_properties_t *pDeviceAdapterProperties) 30 | { 31 | if (CTL_DEVICE_TYPE_GRAPHICS != pDeviceAdapterProperties->device_type) 32 | { 33 | printf("This is not a Graphics device \n"); 34 | return CTL_RESULT_ERROR_NOT_INITIALIZED; 35 | } 36 | if (0 != pDeviceAdapterProperties->graphics_adapter_properties) 37 | { 38 | printf("This is not a Discrete Graphics adapter, its either integrated/LDA adapter \n"); 39 | return CTL_RESULT_ERROR_INVALID_NULL_HANDLE; 40 | } 41 | 42 | return CTL_RESULT_SUCCESS; 43 | } 44 | 45 | int main() 46 | { 47 | ctl_result_t Result = CTL_RESULT_SUCCESS; 48 | uint32_t AdapterCount = 0; 49 | ctl_device_adapter_handle_t *hDevices = nullptr; 50 | ctl_device_adapter_properties_t DeviceAdapterProperties[4] = { 0 }; 51 | LUID DeviceID[4] = { 0 }; 52 | 53 | // Get a handle to the DLL module. 54 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 55 | 56 | ctl_init_args_t CtlInitArgs; 57 | ctl_api_handle_t hAPIHandle; 58 | CtlInitArgs.AppVersion = CTL_MAKE_VERSION(CTL_IMPL_MAJOR_VERSION, CTL_IMPL_MINOR_VERSION); 59 | CtlInitArgs.flags = CTL_INIT_FLAG_USE_LEVEL_ZERO; 60 | CtlInitArgs.Size = sizeof(CtlInitArgs); 61 | CtlInitArgs.Version = 0; 62 | 63 | ZeroMemory(&CtlInitArgs.ApplicationUID, sizeof(ctl_application_id_t)); 64 | 65 | try 66 | { 67 | Result = ctlInit(&CtlInitArgs, &hAPIHandle); 68 | LOG_AND_EXIT_ON_ERROR(Result, "ctlInit"); 69 | } 70 | catch (const std::bad_array_new_length &e) 71 | { 72 | printf("%s \n", e.what()); 73 | } 74 | 75 | if (CTL_RESULT_SUCCESS != Result) 76 | { 77 | goto Exit; 78 | } 79 | 80 | AdapterCount = 0; 81 | 82 | // Initialization successful 83 | // Get the list of Intel Adapters 84 | try 85 | { 86 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, NULL); 87 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 88 | } 89 | catch (const std::bad_array_new_length &e) 90 | { 91 | printf("%s \n", e.what()); 92 | } 93 | 94 | if (CTL_RESULT_SUCCESS == Result) 95 | { 96 | hDevices = (ctl_device_adapter_handle_t *)malloc(sizeof(ctl_device_adapter_handle_t) * AdapterCount); 97 | if (nullptr == hDevices) 98 | { 99 | Result = CTL_RESULT_ERROR_INVALID_NULL_POINTER; 100 | goto Exit; 101 | } 102 | 103 | try 104 | { 105 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 106 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 107 | } 108 | catch (const std::bad_array_new_length &e) 109 | { 110 | printf("%s \n", e.what()); 111 | } 112 | } 113 | if (CTL_RESULT_SUCCESS != Result) 114 | { 115 | printf("ctlEnumerateDevices returned failure code: 0x%X\n", Result); 116 | goto Exit; 117 | } 118 | 119 | try 120 | { 121 | for (uint32_t i = 0; i < AdapterCount; i++) 122 | { 123 | DeviceAdapterProperties[i].Size = sizeof(ctl_device_adapter_properties_t); 124 | DeviceAdapterProperties[i].pDeviceID = &(DeviceID[i]); 125 | DeviceAdapterProperties[i].device_id_size = sizeof(LUID); 126 | if (NULL == DeviceAdapterProperties[i].pDeviceID) 127 | { 128 | Result = CTL_RESULT_ERROR_INVALID_NULL_POINTER; 129 | goto Exit; 130 | } 131 | 132 | Result = ctlGetDeviceProperties(hDevices[i], &DeviceAdapterProperties[i]); 133 | if (Result != CTL_RESULT_SUCCESS) 134 | { 135 | printf("ctlGetDeviceProperties returned failure code: 0x%X\n", Result); 136 | continue; 137 | } 138 | 139 | Result = IsDiscreteGfxAdapter(&DeviceAdapterProperties[i]); 140 | if (Result != CTL_RESULT_SUCCESS) 141 | { 142 | continue; 143 | } 144 | 145 | // Get PCI paramters to check link speed 146 | ctl_pci_properties_t PciProperties = { 0 }; 147 | PciProperties.Size = sizeof(PciProperties); 148 | ctl_result_t res = ctlPciGetProperties(hDevices[i], &PciProperties); 149 | if (res != CTL_RESULT_SUCCESS) 150 | { 151 | printf("Error: %d from PCI get properties.", res); 152 | continue; 153 | } 154 | 155 | // Get PCI paramters to check current link speed 156 | ctl_pci_state_t PciState = { 0 }; 157 | PciState.Size = sizeof(PciState); 158 | 159 | res = ctlPciGetState(hDevices[i], &PciState); 160 | if (res != CTL_RESULT_SUCCESS) 161 | { 162 | printf("Error: %d from PCI get properties.", res); 163 | continue; 164 | } 165 | 166 | printf("PCI Max link speed: %d :: PCI Current link speed: %d \n", PciProperties.maxSpeed.gen, PciState.speed.gen); 167 | 168 | if (PciState.speed.gen == 5) 169 | { 170 | printf("Current PCI link speed is already Gen5, so nothing to do\n"); 171 | continue; 172 | } 173 | 174 | // Check if current FW supports Gen5 to Gen4 downgrade capability 175 | ctl_firmware_properties_t BaseFwProperties = { 0 }; 176 | BaseFwProperties.Size = sizeof(BaseFwProperties); 177 | 178 | res = ctlGetFirmwareProperties(hDevices[i], &BaseFwProperties); 179 | if (res == CTL_RESULT_SUCCESS) 180 | { 181 | if (BaseFwProperties.FirmwareConfig & CTL_FIRMWARE_CONFIG_FLAG_IS_DEVICE_LINK_SPEED_DOWNGRADE_CAPABLE) 182 | { 183 | printf("FW supports Gen5 to Gen4 downgrade capability\n"); 184 | } 185 | else 186 | { 187 | printf("FW does not support Gen5 to Gen4 downgrade capability\n"); 188 | continue; 189 | } 190 | 191 | if (BaseFwProperties.FirmwareConfig & CTL_FIRMWARE_CONFIG_FLAG_IS_DEVICE_LINK_SPEED_DOWNGRADE_ACTIVE) 192 | { 193 | printf("We already attempted to go to Gen5 and it probably failed, nothing else to do now"); 194 | continue; 195 | } 196 | } 197 | else 198 | { 199 | printf("Error: %d from getfirmwareproperties.", res); 200 | } 201 | 202 | // Enumerate firmware components 203 | uint32_t Count = 0; 204 | ctl_firmware_component_handle_t *phFirmwareComponents = nullptr; 205 | 206 | res = ctlEnumerateFirmwareComponents(hDevices[i], &Count, nullptr); 207 | if (res != CTL_RESULT_SUCCESS) 208 | { 209 | printf("Error: %d from enumeratefirmwarecomponents.", res); 210 | continue; 211 | } 212 | 213 | phFirmwareComponents = (ctl_firmware_component_handle_t *)malloc(sizeof(ctl_firmware_component_handle_t) * Count); 214 | if (phFirmwareComponents == nullptr) 215 | { 216 | printf("Error: %d from malloc.", res); 217 | continue; 218 | } 219 | res = ctlEnumerateFirmwareComponents(hDevices[i], &Count, phFirmwareComponents); 220 | if (res != CTL_RESULT_SUCCESS) 221 | { 222 | if (phFirmwareComponents != nullptr) 223 | free(phFirmwareComponents); 224 | 225 | printf("Error: %d from enumeratefirmwarecomponents.", res); 226 | continue; 227 | } 228 | 229 | for (uint32_t j = 0; j < Count; j++) 230 | { 231 | ctl_firmware_component_properties_t FwComponentProperties = { 0 }; 232 | FwComponentProperties.Size = sizeof(FwComponentProperties); 233 | 234 | res = ctlGetFirmwareComponentProperties(phFirmwareComponents[j], &FwComponentProperties); 235 | if (res != CTL_RESULT_SUCCESS) 236 | { 237 | printf("Error: %d from getfirmwarecomponentproperties.", res); 238 | continue; 239 | } 240 | 241 | printf("Fw componenent (%d) : Name: %s and Version : %s \n", j, FwComponentProperties.name, FwComponentProperties.version); 242 | } 243 | 244 | if (phFirmwareComponents != nullptr) 245 | free(phFirmwareComponents); 246 | } 247 | } 248 | catch (const std::bad_array_new_length &e) 249 | { 250 | printf("%s \n", e.what()); 251 | } 252 | Exit: 253 | 254 | if (hDevices != nullptr) 255 | free(hDevices); 256 | 257 | ctlClose(hAPIHandle); 258 | 259 | printf("Overrall test result is 0x%X\n", CTL_RESULT_SUCCESS); 260 | 261 | return CTL_RESULT_SUCCESS; 262 | } 263 | -------------------------------------------------------------------------------- /Samples/FirmwareApi/README.md: -------------------------------------------------------------------------------- 1 | Sample Application for Firmware API interfaces 2 | -------------------------------------------------------------------------------- /Samples/Generic_Sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME Generic_Sample) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(Generic_Sample VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Sample_ControlAPP.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/I2C_AUX_Samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME I2C_AUX_Samples) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(I2C_AUX_Samples VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/I2C_AUX_Sample_App.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/I2C_AUX_Samples/I2C_AUX_Sample_App.cpp: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // Copyright (C) 2022 Intel Corporation 3 | // 4 | // 5 | // 6 | // SPDX-License-Identifier: MIT 7 | //-------------------------------------------------------------------------- 8 | 9 | /** 10 | * 11 | * @file I2C_AUX_Sample_App.cpp 12 | * @brief This file contains the I2C AUX Sample App & the 'main' function. Program execution begins and ends there. 13 | * 14 | */ 15 | 16 | #define _CRTDBG_MAP_ALLOC 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #define CTL_APIEXPORT // caller of control API DLL shall define this before 24 | // including igcl_api.h 25 | #include "igcl_api.h" 26 | #include "GenericIGCLApp.h" 27 | 28 | ctl_result_t GResult = CTL_RESULT_SUCCESS; 29 | 30 | /*************************************************************** 31 | * @brief TestI2CAUXAccess 32 | * Reference code to use I2CAuxAccess API 33 | * @param hDisplayOutput 34 | * @return ctl_result_t 35 | ***************************************************************/ 36 | ctl_result_t TestI2CAUXAccess(ctl_display_output_handle_t hDisplayOutput) 37 | { 38 | ctl_result_t Result = CTL_RESULT_SUCCESS; 39 | ctl_aux_access_args_t AUXArgs = { 0 }; // AUX Access WRITE 40 | ctl_i2c_access_args_t I2CArgs = { 0 }; // I2C Access 41 | 42 | APP_LOG_INFO("Aux Read Test."); 43 | 44 | AUXArgs.Size = sizeof(ctl_aux_access_args_t); 45 | AUXArgs.OpType = CTL_OPERATION_TYPE_WRITE; 46 | AUXArgs.Address = 0x103; // DPCD offset for TRAINING_LANE0_SET 47 | AUXArgs.DataSize = 1; 48 | AUXArgs.Flags = CTL_AUX_FLAG_NATIVE_AUX; // CTL_AUX_FLAG_NATIVE_AUX for DPCD Access & CTL_AUX_FLAG_I2C_AUX for EDID access for DP/eDP displays. 49 | AUXArgs.Data[0] = 0x01; 50 | 51 | Result = ctlAUXAccess(hDisplayOutput, &AUXArgs); 52 | 53 | if (CTL_RESULT_SUCCESS != Result) 54 | { 55 | APP_LOG_ERROR("ctlAUXAccess for Native Aux DPCD WRITE returned failure code: 0x%X", Result); 56 | STORE_AND_RESET_ERROR(Result); 57 | } 58 | 59 | // AUX Access READ 60 | AUXArgs.Size = sizeof(ctl_aux_access_args_t); 61 | AUXArgs.OpType = CTL_OPERATION_TYPE_READ; 62 | AUXArgs.Address = 0x103; // Address used for demonstration purpose 63 | AUXArgs.DataSize = 1; 64 | AUXArgs.Flags = CTL_AUX_FLAG_NATIVE_AUX; 65 | 66 | EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput, "hDisplayOutput"); 67 | 68 | Result = ctlAUXAccess(hDisplayOutput, &AUXArgs); 69 | 70 | if (CTL_RESULT_SUCCESS != Result) 71 | { 72 | APP_LOG_ERROR("ctlAUXAccess for Native Aux DPCD Read returned failure code: 0x%X", Result); 73 | STORE_AND_RESET_ERROR(Result); 74 | } 75 | else 76 | { 77 | // Print the data 78 | for (uint32_t j = 0; j < AUXArgs.DataSize; j++) 79 | { 80 | APP_LOG_INFO("Read data[%d] = : 0x%X", j, AUXArgs.Data[j]); 81 | } 82 | } 83 | 84 | APP_LOG_INFO("I2C Write Test."); 85 | 86 | // I2C WRITE : 82 01 10 AC at adddress 6E and subaddress 51 87 | // If we write these BYTEs ( 82 01 10 AC) to adddress 6E and 88 | // subaddress 51, it should update the current brightness to the 10th 89 | // byte at adddress 6E and subaddress 51. One can verify by changing 90 | // panel brightness from panel buttons and the writing to adddress 6E 91 | // and subaddress 51 ( 82 01 10 AC), and then reading 10th byte at 92 | // adddress 6E and subaddress 51. For Example : The following 11 byte 93 | // values should be shown by the I2C Read post I2C write. Values are 94 | // 6E 88 02 00 10 00 00 64 00 19 D9. (If HDMI panel brightness is set 95 | // to 25%) 10th byte value is current brightness value of the 96 | // panel.To confirm that value is correct or not, convert the Hex 97 | // value to Decimal. 98 | 99 | I2CArgs.Size = sizeof(ctl_i2c_access_args_t); 100 | I2CArgs.OpType = CTL_OPERATION_TYPE_WRITE; 101 | I2CArgs.Address = 0x6E; // Address used for demonstration purpose 102 | I2CArgs.Offset = 0x51; // Offset used for demonstration purpose 103 | I2CArgs.DataSize = 4; 104 | I2CArgs.Data[0] = 0x82; 105 | I2CArgs.Data[1] = 0x01; 106 | I2CArgs.Data[2] = 0x10; 107 | I2CArgs.Data[3] = 0xAC; 108 | 109 | EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput, "hDisplayOutput"); 110 | 111 | Result = ctlI2CAccess(hDisplayOutput, &I2CArgs); 112 | 113 | if (CTL_RESULT_SUCCESS != Result) 114 | { 115 | APP_LOG_ERROR("ctlI2CAccess for I2C write returned failure code: 0x%X", Result); 116 | STORE_AND_RESET_ERROR(Result); 117 | } 118 | APP_LOG_INFO("I2C Read Test."); 119 | // I2C READ : 82 01 10 AC at adddress 6E and subaddress 51 120 | I2CArgs.Size = sizeof(ctl_i2c_access_args_t); 121 | I2CArgs.OpType = CTL_OPERATION_TYPE_READ; 122 | I2CArgs.Address = 0x6E; // Address used for demonstration purpose 123 | I2CArgs.Offset = 0x51; // Offset used for demonstration purpose 124 | I2CArgs.DataSize = 11; 125 | // I2CArgs.Flags = CTL_I2C_FLAG_ATOMICI2C; // Need to set this to do Atomic I2C call 126 | 127 | Result = ctlI2CAccess(hDisplayOutput, &I2CArgs); 128 | LOG_AND_EXIT_ON_ERROR(Result, "ctlI2CAccess for I2C read"); 129 | 130 | // Print the data 131 | for (uint32_t j = 0; j < I2CArgs.DataSize; j++) 132 | { 133 | APP_LOG_INFO("Read data[%d] = : 0x%X", j, I2CArgs.Data[j]); 134 | } 135 | 136 | Exit: 137 | 138 | return Result; 139 | } 140 | 141 | /*************************************************************** 142 | * @brief Tests I2C Access on enumerated Pin Pairs. 143 | * Reference code to use ctlI2CAccessOnPinPair API 144 | * @param hI2cPinPair 145 | * @return ctl_result_t 146 | ***************************************************************/ 147 | ctl_result_t TestI2CAUXAccessOnPinPair(ctl_i2c_pin_pair_handle_t hI2cPinPair) 148 | { 149 | ctl_result_t Result = CTL_RESULT_SUCCESS; 150 | ctl_i2c_access_pinpair_args_t I2CArgs = { 0 }; // I2C Access 151 | 152 | // I2C WRITE : 82 01 10 AC at adddress 6E and subaddress 51 153 | // If we write these BYTEs ( 82 01 10 AC) to adddress 6E and 154 | // subaddress 51, it should update the current brightness to the 10th 155 | // byte at adddress 6E and subaddress 51. One can verify by changing 156 | // panel brightness from panel buttons and the writing to adddress 6E 157 | // and subaddress 51 ( 82 01 10 AC), and then reading 10th byte at 158 | // adddress 6E and subaddress 51. For Example : The following 11 byte 159 | // values should be shown by the I2C Read post I2C write. Values are 160 | // 6E 88 02 00 10 00 00 64 00 19 D9. (If HDMI panel brightness is set 161 | // to 25%) 10th byte value is current brightness value of the 162 | // panel.To confirm that value is correct or not, convert the Hex 163 | // value to Decimal. 164 | 165 | I2CArgs.Size = sizeof(I2CArgs); 166 | I2CArgs.OpType = CTL_OPERATION_TYPE_WRITE; 167 | I2CArgs.Address = 0x6E; // Address used for demonstration purpose 168 | I2CArgs.Offset = 0x51; // Offset used for demonstration purpose 169 | I2CArgs.DataSize = 4; 170 | I2CArgs.Data[0] = 0x82; 171 | I2CArgs.Data[1] = 0x01; 172 | I2CArgs.Data[2] = 0x10; 173 | I2CArgs.Data[3] = 0xAC; 174 | 175 | APP_LOG_INFO("I2C Write Test: Address %#x, Offset %#x, size %d.", I2CArgs.Address, I2CArgs.Offset, I2CArgs.DataSize); 176 | Result = ctlI2CAccessOnPinPair(hI2cPinPair, &I2CArgs); 177 | if (CTL_RESULT_SUCCESS != Result) 178 | { 179 | APP_LOG_ERROR("I2C write returned failure code: 0x%X", Result); 180 | STORE_AND_RESET_ERROR(Result); 181 | } 182 | else 183 | { 184 | APP_LOG_INFO("I2C Write Test Success."); 185 | } 186 | 187 | ZeroMemory(&I2CArgs, sizeof(I2CArgs)); 188 | // I2C READ : 82 01 10 AC at adddress 6E and subaddress 51 189 | I2CArgs.Size = sizeof(I2CArgs); 190 | I2CArgs.OpType = CTL_OPERATION_TYPE_READ; 191 | I2CArgs.Address = 0x6E; // Address used for demonstration purpose 192 | I2CArgs.Offset = 0x51; // Offset used for demonstration purpose 193 | I2CArgs.DataSize = 11; 194 | // Optional Flag examples: 195 | // I2CArgs.Flags = CTL_I2C_FLAG_2BYTE_INDEX; 196 | // I2CArgs.Flags |= CTL_I2C_FLAG_SPEED_BIT_BASH; 197 | // I2CArgs.Flags = CTL_I2C_FLAG_ATOMICI2C; // Need to set this to do Atomic I2C call 198 | 199 | APP_LOG_INFO("I2C Read Test: Address %#X, Offset %#X, size %d, Flags %#X.", I2CArgs.Address, I2CArgs.Offset, I2CArgs.DataSize, I2CArgs.Flags); 200 | Result = ctlI2CAccessOnPinPair(hI2cPinPair, &I2CArgs); 201 | LOG_AND_EXIT_ON_ERROR(Result, "ctlI2CAccessOnPinPair for I2C read"); 202 | 203 | // Print the data 204 | for (uint32_t j = 0; j < I2CArgs.DataSize; j++) 205 | { 206 | APP_LOG_INFO("Read data[%d] = : 0x%X", j, I2CArgs.Data[j]); 207 | } 208 | 209 | Exit: 210 | PRINT_LOGS("-------------------------"); 211 | return Result; 212 | } 213 | 214 | /*************************************************************** 215 | * @brief EnumerateDisplayHandles 216 | * Only for demonstration purpose, API is called for each of the display output handle in below snippet. 217 | * User has to filter through the available display output handle and has to call the API with particular display output handle. 218 | * @param hDisplayOutput, DisplayCount 219 | * @return ctl_result_t 220 | ***************************************************************/ 221 | ctl_result_t EnumerateDisplayHandles(ctl_display_output_handle_t *hDisplayOutput, uint32_t DisplayCount) 222 | { 223 | ctl_result_t Result = CTL_RESULT_SUCCESS; 224 | 225 | for (uint32_t DisplayIndex = 0; DisplayIndex < DisplayCount; DisplayIndex++) 226 | { 227 | ctl_display_properties_t DisplayProperties = { 0 }; 228 | DisplayProperties.Size = sizeof(ctl_display_properties_t); 229 | APP_LOG_INFO("Display Handle: %p", hDisplayOutput[DisplayIndex]); 230 | PRINT_LOGS("-------------------------"); 231 | Result = ctlGetDisplayProperties(hDisplayOutput[DisplayIndex], &DisplayProperties); 232 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetDisplayProperties"); 233 | 234 | bool IsDisplayAttached = (0 != (DisplayProperties.DisplayConfigFlags & CTL_DISPLAY_CONFIG_FLAG_DISPLAY_ATTACHED)); 235 | 236 | if (FALSE == IsDisplayAttached) 237 | { 238 | APP_LOG_WARN("Display %d is not attached, skipping the call for this display", DisplayIndex); 239 | continue; 240 | } 241 | 242 | Result = TestI2CAUXAccess(hDisplayOutput[DisplayIndex]); 243 | STORE_AND_RESET_ERROR(Result); 244 | } 245 | 246 | Exit: 247 | return Result; 248 | } 249 | 250 | /*************************************************************** 251 | * @brief For demonstration purpose, API is called for each of the I2c Pin Pair handle in below snippet. 252 | * 253 | * @param hI2cPinPair, PinPairCount 254 | * @return ctl_result_t 255 | ***************************************************************/ 256 | ctl_result_t TestI2cAccessOnEmumeratedPinPairs(ctl_i2c_pin_pair_handle_t *hI2cPinPair, uint32_t PinPairCount) 257 | { 258 | ctl_result_t Result = CTL_RESULT_SUCCESS; 259 | for (uint32_t Index = 0; Index < PinPairCount; Index++) 260 | { 261 | APP_LOG_INFO("I2CAccessOnPinPair Test for Pin Pair[%d] handle: %p", Index, hI2cPinPair[Index]); 262 | PRINT_LOGS("-------------------------"); 263 | Result = TestI2CAUXAccessOnPinPair(hI2cPinPair[Index]); 264 | STORE_AND_RESET_ERROR(Result); 265 | } 266 | 267 | return Result; 268 | } 269 | 270 | /*************************************************************** 271 | * @brief EnumerateTargetDisplays 272 | * Enumerates all the possible target display's for the adapters 273 | * @param hDisplayOutput, AdapterCount, hDevices 274 | * @return ctl_result_t 275 | ***************************************************************/ 276 | ctl_result_t EnumerateTargetDisplays(uint32_t AdapterCount, ctl_device_adapter_handle_t *hDevices) 277 | { 278 | ctl_display_output_handle_t *hDisplayOutput = NULL; 279 | ctl_result_t Result = CTL_RESULT_SUCCESS; 280 | uint32_t DisplayCount = 0; 281 | 282 | for (uint32_t AdapterIndex = 0; AdapterIndex < AdapterCount; AdapterIndex++) 283 | { 284 | APP_LOG_INFO("Adapter Handle: %p", hDevices[AdapterIndex]); 285 | PRINT_LOGS("==============================="); 286 | 287 | // enumerate all the possible target display's for the adapters 288 | // first step is to get the count 289 | DisplayCount = 0; 290 | 291 | Result = ctlEnumerateDisplayOutputs(hDevices[AdapterIndex], &DisplayCount, hDisplayOutput); 292 | 293 | if (CTL_RESULT_SUCCESS != Result) 294 | { 295 | APP_LOG_ERROR("ctlEnumerateDisplayOutputs returned failure code: 0x%X", Result); 296 | STORE_AND_RESET_ERROR(Result); 297 | continue; 298 | } 299 | else if (DisplayCount <= 0) 300 | { 301 | APP_LOG_WARN("Invalid Display Count. skipping display enumration for adapter:%d", AdapterIndex); 302 | continue; 303 | } 304 | 305 | hDisplayOutput = (ctl_display_output_handle_t *)malloc(sizeof(ctl_display_output_handle_t) * DisplayCount); 306 | EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput, "hDisplayOutput"); 307 | 308 | Result = ctlEnumerateDisplayOutputs(hDevices[AdapterIndex], &DisplayCount, hDisplayOutput); 309 | 310 | if (CTL_RESULT_SUCCESS != Result) 311 | { 312 | APP_LOG_ERROR("ctlEnumerateDisplayOutputs returned failure code: 0x%X", Result); 313 | STORE_AND_RESET_ERROR(Result); 314 | } 315 | 316 | // Only for demonstration purpose, API is called for each of the display output handle in below snippet. 317 | // User has to filter through the available display output handle and has to call the API with particular display output handle. 318 | Result = EnumerateDisplayHandles(hDisplayOutput, DisplayCount); 319 | 320 | if (CTL_RESULT_SUCCESS != Result) 321 | { 322 | APP_LOG_ERROR("EnumerateDisplayHandles returned failure code: 0x%X", Result); 323 | } 324 | 325 | CTL_FREE_MEM(hDisplayOutput); 326 | } 327 | 328 | Exit: 329 | 330 | CTL_FREE_MEM(hDisplayOutput); 331 | return Result; 332 | } 333 | 334 | /*************************************************************** 335 | * @brief EnumerateI2CDevices 336 | * Enumerates all the possible I2C PinPairs for the adapters 337 | * @param AdapterCount, hDevices 338 | * @return ctl_result_t 339 | ***************************************************************/ 340 | ctl_result_t EnumerateI2CDevices(uint32_t AdapterCount, ctl_device_adapter_handle_t *hDevices) 341 | { 342 | ctl_i2c_pin_pair_handle_t *hI2cPinPair = NULL; 343 | ctl_result_t Result = CTL_RESULT_SUCCESS; 344 | uint32_t PinCount = 0; 345 | 346 | for (uint32_t AdapterIndex = 0; AdapterIndex < AdapterCount; AdapterIndex++) 347 | { 348 | APP_LOG_INFO("I2C Access Test For Adapter[%d] handle: %p", AdapterIndex, hDevices[AdapterIndex]); 349 | PRINT_LOGS("==========================="); 350 | // enumerate all the possible target display's for the adapters 351 | // first step is to get the count 352 | PinCount = 0; 353 | 354 | Result = ctlEnumerateI2CPinPairs(hDevices[AdapterIndex], &PinCount, hI2cPinPair); 355 | 356 | if (CTL_RESULT_SUCCESS != Result) 357 | { 358 | APP_LOG_ERROR("ctlEnumerateI2CPinPairs returned failure code: 0x%X", Result); 359 | STORE_AND_RESET_ERROR(Result); 360 | continue; 361 | } 362 | else if (PinCount <= 0) 363 | { 364 | APP_LOG_ERROR("Invalid Display Count. skipping pin pair enumration for adapter:%d", AdapterIndex); 365 | continue; 366 | } 367 | 368 | hI2cPinPair = (ctl_i2c_pin_pair_handle_t *)malloc(sizeof(ctl_i2c_pin_pair_handle_t) * PinCount); 369 | EXIT_ON_MEM_ALLOC_FAILURE(hI2cPinPair, "hI2cPinPair"); 370 | 371 | Result = ctlEnumerateI2CPinPairs(hDevices[AdapterIndex], &PinCount, hI2cPinPair); 372 | 373 | if (CTL_RESULT_SUCCESS != Result) 374 | { 375 | APP_LOG_ERROR("ctlEnumerateI2CPinPairs returned failure code: 0x%X", Result); 376 | STORE_AND_RESET_ERROR(Result); 377 | } 378 | 379 | // Only for demonstration purpose, API is called for each of the display output handle in below snippet. 380 | // User has to filter through the available display output handle and has to call the API with particular display output handle. 381 | Result = TestI2cAccessOnEmumeratedPinPairs(hI2cPinPair, PinCount); 382 | 383 | if (CTL_RESULT_SUCCESS != Result) 384 | { 385 | APP_LOG_ERROR("TestI2cAccessOnEmumeratedPinPairs returned failure code: 0x%X", Result); 386 | } 387 | 388 | CTL_FREE_MEM(hI2cPinPair); 389 | } 390 | 391 | Exit: 392 | 393 | CTL_FREE_MEM(hI2cPinPair); 394 | return Result; 395 | } 396 | 397 | /*************************************************************** 398 | * @brief Main Function which calls the Sample I2CAuxAccess API 399 | * @param 400 | * @return int 401 | ***************************************************************/ 402 | int main() 403 | { 404 | ctl_result_t Result = CTL_RESULT_SUCCESS; 405 | ctl_device_adapter_handle_t *hDevices = NULL; 406 | // Get a handle to the DLL module. 407 | uint32_t AdapterCount = 0; 408 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 409 | 410 | ctl_init_args_t CtlInitArgs; 411 | ctl_api_handle_t hAPIHandle; 412 | 413 | ZeroMemory(&CtlInitArgs, sizeof(ctl_init_args_t)); 414 | 415 | CtlInitArgs.AppVersion = CTL_MAKE_VERSION(CTL_IMPL_MAJOR_VERSION, CTL_IMPL_MINOR_VERSION); 416 | CtlInitArgs.flags = 0; 417 | CtlInitArgs.Size = sizeof(CtlInitArgs); 418 | CtlInitArgs.Version = 0; 419 | 420 | try 421 | { 422 | Result = ctlInit(&CtlInitArgs, &hAPIHandle); 423 | LOG_AND_EXIT_ON_ERROR(Result, "ctlInit"); 424 | } 425 | catch (const std::bad_array_new_length &e) 426 | { 427 | APP_LOG_ERROR("%s ", e.what()); 428 | } 429 | 430 | // Initialization successful 431 | // Get the list of Intel Adapters 432 | try 433 | { 434 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 435 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 436 | } 437 | catch (const std::bad_array_new_length &e) 438 | { 439 | APP_LOG_ERROR("%s ", e.what()); 440 | } 441 | 442 | hDevices = (ctl_device_adapter_handle_t *)malloc(sizeof(ctl_device_adapter_handle_t) * AdapterCount); 443 | EXIT_ON_MEM_ALLOC_FAILURE(hDevices, "hDevices"); 444 | 445 | try 446 | { 447 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 448 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 449 | } 450 | catch (const std::bad_array_new_length &e) 451 | { 452 | APP_LOG_ERROR("%s ", e.what()); 453 | } 454 | 455 | Result = EnumerateTargetDisplays(AdapterCount, hDevices); 456 | 457 | if (CTL_RESULT_SUCCESS != Result) 458 | { 459 | APP_LOG_ERROR("EnumerateTargetDisplays returned failure code: 0x%X", Result); 460 | STORE_AND_RESET_ERROR(Result); 461 | } 462 | #if 0 // Keeping the call disabled as not needed for regular Display use cases. Mainly intended for non-display devices. 463 | Result = EnumerateI2CDevices(AdapterCount, hDevices); 464 | if (CTL_RESULT_SUCCESS != Result) 465 | { 466 | APP_LOG_ERROR("EnumerateI2CDevices returned failure code: 0x%X", Result); 467 | STORE_AND_RESET_ERROR(Result); 468 | } 469 | #endif 470 | Exit: 471 | 472 | ctlClose(hAPIHandle); 473 | CTL_FREE_MEM(hDevices); 474 | APP_LOG_INFO("Overrall test result is 0x%X", GResult); 475 | return GResult; 476 | } 477 | 478 | // Run program: Ctrl + F5 or Debug > Start Without Debugging menu 479 | // Debug program: F5 or Debug > Start Debugging menu 480 | 481 | // Tips for Getting Started: 482 | // 1. Use the Solution Explorer window to add/manage files 483 | // 2. Use the Team Explorer window to connect to source control 484 | // 3. Use the Output window to see build output and other messages 485 | // 4. Use the Error List window to view errors 486 | // 5. Go to Project > Add New Item to create new code files, or Project > Add 487 | // Existing Item to add existing code files to the project 488 | // 6. In the future, to open this project again, go to File > Open > Project 489 | // and select the .sln file 490 | -------------------------------------------------------------------------------- /Samples/I2C_AUX_Samples/README.md: -------------------------------------------------------------------------------- 1 | Sample Application for I2C aux -------------------------------------------------------------------------------- /Samples/IntelArcSync/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME IntelArcSync) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(IntelArcSync VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/IntelArcSync_App.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/IntelArcSync/README.md: -------------------------------------------------------------------------------- 1 | **Usage**: `IntelArcSync_App.exe [option] [sub-option]` 2 | 3 | A sample app to control Intel Arc Sync profile options. 4 | 5 | **Options** 6 |
 7 | get
 8 |         caps                    Print Intel Arc Sync caps
 9 |         profile                 Print active Intel Arc Sync profile details
10 |         profile-names           Print the list of profile names available
11 | 
12 | set
13 |         profile                 Set the Intel Arc Sync profile
14 |                 < profile-name >          Name of Intel Arc Sync profile to apply
15 |                 [< min-rr >]              Used only in CUSTOM profile. Min RR value in Hz.
16 |                 [< max-rr >]              Used only in CUSTOM profile. Max RR value in Hz.
17 |                 [< sfdit-value >]         Used only in CUSTOM profile. SFDIT value in micro seconds.
18 |                 [< sfddt-value >]         Used only in CUSTOM profile. SFDDT value in micro seconds.
19 | 
20 | 21 | **Examples**: 22 | 23 | IntelArcSync_App.exe get caps 24 | 25 | IntelArcSync_App.exe get profile 26 | 27 | IntelArcSync_App.exe get profile-names 28 | 29 | IntelArcSync_App.exe set profile RECOMMENDED 30 | 31 | IntelArcSync_App.exe set profile OFF 32 | 33 | IntelArcSync_App.exe set profile EXCELLENT 34 | 35 | IntelArcSync_App.exe set profile CUSTOM 60 90 5000 5000 36 | -------------------------------------------------------------------------------- /Samples/Media_Samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME Media_Samples) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(Media_Samples VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Media_Sample_App.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/Media_Samples/README.md: -------------------------------------------------------------------------------- 1 | Sample Application for Media interfaces -------------------------------------------------------------------------------- /Samples/Overclocking_Sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME Overclocking_Sample) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(Overclocking_Sample VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Sample_OverclockAPP.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/Overclocking_Sample/README.md: -------------------------------------------------------------------------------- 1 | Sample Application for the Overclocking interface with Overclocking V2 APIs -------------------------------------------------------------------------------- /Samples/Panel_descriptor_Samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME Panel_descriptor_Samples) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(Panel_descriptor_Samples VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Panel_descriptor_Sample_App.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/Panel_descriptor_Samples/Panel_descriptor_Sample_App.cpp: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // Copyright (C) 2022 Intel Corporation 3 | // 4 | // 5 | // 6 | // SPDX-License-Identifier: MIT 7 | //-------------------------------------------------------------------------- 8 | 9 | /** 10 | * 11 | * @file Panel_descriptor_Sample_APP.cpp 12 | * @brief This file contains the Panel_descriptor_Sample_APP & the 'main' function. Program execution begins and ends there. 13 | * 14 | */ 15 | 16 | #define _CRTDBG_MAP_ALLOC 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #define CTL_APIEXPORT // caller of control API DLL shall define this before 24 | // including igcl_api.h 25 | #include "igcl_api.h" 26 | #include "GenericIGCLApp.h" 27 | 28 | ctl_result_t GResult = CTL_RESULT_SUCCESS; 29 | 30 | /*************************************************************** 31 | * @brief 32 | * GetPanelDescriptor: Sample app to use PanelDescriptor API 33 | * @param ctl_display_output_handle_t, ctl_panel_descriptor_access_args_t 34 | * @return ctl_result_t 35 | ***************************************************************/ 36 | ctl_result_t GetPanelDescriptor(ctl_display_output_handle_t hDisplayOutput, ctl_panel_descriptor_access_args_t *pPanelDescArgs) 37 | { 38 | ctl_result_t Result = CTL_RESULT_SUCCESS; 39 | uint32_t DescriptorDataSize = 0; 40 | 41 | Result = ctlPanelDescriptorAccess(hDisplayOutput, pPanelDescArgs); 42 | LOG_AND_EXIT_ON_ERROR(Result, "ctlPanelDescriptorAccess"); 43 | 44 | // Print the descriptor data size 45 | DescriptorDataSize = pPanelDescArgs->DescriptorDataSize; 46 | APP_LOG_INFO("DescriptorDataSize = : %d", DescriptorDataSize); 47 | 48 | // Once we have the size of the descriptor data, do another call to ctlPanelDescriptorAccess with DescriptorDataSize as the value derived from 1st ctlPanelDescriptorAccess 49 | // call. 50 | pPanelDescArgs->Size = sizeof(ctl_panel_descriptor_access_args_t); 51 | pPanelDescArgs->OpType = CTL_OPERATION_TYPE_READ; // Currently only Read operation is supported. Write operationnot supported. 52 | pPanelDescArgs->BlockNumber = 0; // Block number 53 | pPanelDescArgs->DescriptorDataSize = DescriptorDataSize; 54 | pPanelDescArgs->pDescriptorData = (uint8_t *)malloc(DescriptorDataSize * sizeof(uint8_t)); // Allocate memory for the descriptor data 55 | 56 | EXIT_ON_MEM_ALLOC_FAILURE(pPanelDescArgs->pDescriptorData, "PanelDescArgs.pDescriptorData"); 57 | 58 | Result = ctlPanelDescriptorAccess(hDisplayOutput, pPanelDescArgs); 59 | LOG_AND_EXIT_ON_ERROR(Result, "ctlPanelDescriptorAccess"); 60 | 61 | APP_LOG_INFO("Panel Descriptor Data on block %d: ", pPanelDescArgs->BlockNumber); 62 | for (uint32_t i = 0; i < pPanelDescArgs->DescriptorDataSize; i += 16) 63 | { 64 | for (uint32_t j = i; j < (i + 16); j++) 65 | { 66 | APP_LOG_INFO("0x%02X ", pPanelDescArgs->pDescriptorData[j]); 67 | } 68 | } 69 | 70 | // EXTENSION BLOCKS READ : For EDID, Need to get the number of extensions blocks from 127th byte of base block 71 | uint32_t NumberOfExtnBlocks = pPanelDescArgs->pDescriptorData[126]; // 127th byte specifies the number of extension blocks 72 | 73 | if (0 == NumberOfExtnBlocks) 74 | { 75 | APP_LOG_ERROR("No Extn Block found "); 76 | goto Exit; 77 | } 78 | 79 | for (uint32_t BlockIndex = 0; BlockIndex < NumberOfExtnBlocks; BlockIndex++) 80 | { 81 | ctl_panel_descriptor_access_args_t ExtBlockPanelDescArgs = { 0 }; 82 | uint32_t ExtBlockDescriptorDataSize = 0; 83 | 84 | // Need to query the size of the descriptor first and then need to query for the descriptor data 85 | // For size query, make ctlPanelDescriptorAccess call with DescriptorDataSize equals 0, It returns the size of the descriptor data. 86 | ExtBlockPanelDescArgs.Size = sizeof(ctl_panel_descriptor_access_args_t); 87 | ExtBlockPanelDescArgs.OpType = CTL_OPERATION_TYPE_READ; // Currently only Read operation is supported. Write operation is not supported. 88 | ExtBlockPanelDescArgs.BlockNumber = BlockIndex + 1; // Blocks numbered 1, 2, 3 ... 89 | ExtBlockPanelDescArgs.DescriptorDataSize = ExtBlockDescriptorDataSize; 90 | 91 | Result = ctlPanelDescriptorAccess(hDisplayOutput, &ExtBlockPanelDescArgs); 92 | LOG_AND_EXIT_ON_ERROR(Result, "ctlPanelDescriptorAccess for querying DescriptorDataSize for extension block"); 93 | 94 | // Print the descriptor data size 95 | ExtBlockDescriptorDataSize = ExtBlockPanelDescArgs.DescriptorDataSize; 96 | APP_LOG_INFO("DescriptorDataSize for extension block = : %d", ExtBlockDescriptorDataSize); 97 | 98 | // Once we have the size of the descriptor data, do another call to ctlPanelDescriptorAccess with DescriptorDataSize as the value derived from 1st 99 | // ctlPanelDescriptorAcces call. 100 | ExtBlockPanelDescArgs = { 0 }; 101 | ExtBlockPanelDescArgs.Size = sizeof(ctl_panel_descriptor_access_args_t); 102 | ExtBlockPanelDescArgs.OpType = CTL_OPERATION_TYPE_READ; // Currently only Read operation is supported. Write operationnot supported. 103 | ExtBlockPanelDescArgs.BlockNumber = BlockIndex + 1; // Block number 104 | ExtBlockPanelDescArgs.DescriptorDataSize = ExtBlockDescriptorDataSize; 105 | ExtBlockPanelDescArgs.pDescriptorData = (uint8_t *)malloc(ExtBlockDescriptorDataSize * sizeof(uint8_t)); // Allocate memory for the descriptor data 106 | 107 | EXIT_ON_MEM_ALLOC_FAILURE(ExtBlockPanelDescArgs.pDescriptorData, "ExtBlockPanelDescArgs.pDescriptorData"); 108 | 109 | Result = ctlPanelDescriptorAccess(hDisplayOutput, &ExtBlockPanelDescArgs); 110 | 111 | if (CTL_RESULT_SUCCESS != Result) 112 | { 113 | APP_LOG_ERROR("ctlPanelDescriptorAccess for extension block %d returned failure code: 0x%X", BlockIndex, Result); 114 | CTL_FREE_MEM(ExtBlockPanelDescArgs.pDescriptorData); 115 | goto Exit; 116 | } 117 | 118 | APP_LOG_INFO("Panel Descriptor Data on block %d: ", ExtBlockPanelDescArgs.BlockNumber); 119 | for (uint32_t i = 0; i < pPanelDescArgs->DescriptorDataSize; i += 16) 120 | { 121 | for (uint32_t j = i; j < (i + 16); j++) 122 | { 123 | APP_LOG_INFO("0x%02X ", ExtBlockPanelDescArgs.pDescriptorData[j]); 124 | } 125 | } 126 | 127 | CTL_FREE_MEM(ExtBlockPanelDescArgs.pDescriptorData); 128 | } 129 | 130 | Exit: 131 | CTL_FREE_MEM(pPanelDescArgs->pDescriptorData); 132 | return Result; 133 | } 134 | 135 | /*************************************************************** 136 | * @brief EnumerateDisplayHandles 137 | * Only for demonstration purpose, API is called for each of the display output handle in below snippet. 138 | * User has to filter through the available display output handle and has to call the API with particular display output handle. 139 | * @param hDisplayOutput, DisplayCount 140 | * @return ctl_result_t 141 | ***************************************************************/ 142 | ctl_result_t EnumerateDisplayHandles(ctl_display_output_handle_t *hDisplayOutput, uint32_t DisplayCount) 143 | { 144 | ctl_result_t Result = CTL_RESULT_SUCCESS; 145 | 146 | if (0 == DisplayCount) 147 | { 148 | APP_LOG_ERROR("Invalid Display Count "); 149 | goto Exit; 150 | } 151 | 152 | for (uint32_t DisplayIndex = 0; DisplayIndex < DisplayCount; DisplayIndex++) 153 | { 154 | ctl_display_properties_t DisplayProperties = { 0 }; 155 | DisplayProperties.Size = sizeof(ctl_display_properties_t); 156 | 157 | Result = ctlGetDisplayProperties(hDisplayOutput[DisplayIndex], &DisplayProperties); 158 | 159 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetDisplayProperties"); 160 | 161 | bool IsDisplayAttached = DisplayProperties.DisplayConfigFlags & CTL_DISPLAY_CONFIG_FLAG_DISPLAY_ATTACHED; 162 | 163 | if (FALSE == IsDisplayAttached) 164 | { 165 | APP_LOG_WARN("Display %d is not attached, skipping the call for this display", DisplayIndex); 166 | continue; 167 | } 168 | 169 | // Panel descriptor access 170 | // Need to query the size of the descriptor first and then need to query for the descriptor data 171 | // For size query, make ctlPanelDescriptorAccess call with DescriptorDataSize equals 0, It returns the size of the descriptor data. 172 | ctl_panel_descriptor_access_args_t PanelDescArgs; 173 | PanelDescArgs = { 0 }; 174 | uint32_t DescriptorDataSize = 0; 175 | 176 | PanelDescArgs.Size = sizeof(ctl_panel_descriptor_access_args_t); 177 | PanelDescArgs.OpType = CTL_OPERATION_TYPE_READ; // Currently only Read operation is supported. Write operation is not supported. 178 | PanelDescArgs.BlockNumber = 0; // Block number 179 | PanelDescArgs.DescriptorDataSize = DescriptorDataSize; 180 | 181 | Result = GetPanelDescriptor(hDisplayOutput[DisplayIndex], &PanelDescArgs); 182 | 183 | STORE_AND_RESET_ERROR(Result); 184 | } 185 | 186 | Exit: 187 | return Result; 188 | } 189 | 190 | /*************************************************************** 191 | * @brief EnumerateTargetDisplays 192 | * Enumerates all the possible target display's for the adapters 193 | * @param hDisplayOutput, AdapterCount, hDevices 194 | * @return ctl_result_t 195 | ***************************************************************/ 196 | ctl_result_t EnumerateTargetDisplays(uint32_t AdapterCount, ctl_device_adapter_handle_t *hDevices) 197 | { 198 | ctl_display_output_handle_t *hDisplayOutput = NULL; 199 | ctl_result_t Result = CTL_RESULT_SUCCESS; 200 | uint32_t DisplayCount = 0; 201 | 202 | for (uint32_t AdapterIndex = 0; AdapterIndex < AdapterCount; AdapterIndex++) 203 | { 204 | // enumerate all the possible target display's for the adapters 205 | // first step is to get the count 206 | DisplayCount = 0; 207 | 208 | Result = ctlEnumerateDisplayOutputs(hDevices[AdapterIndex], &DisplayCount, hDisplayOutput); 209 | 210 | if (CTL_RESULT_SUCCESS != Result) 211 | { 212 | APP_LOG_ERROR("ctlEnumerateDisplayOutputs returned failure code: 0x%X", Result); 213 | STORE_AND_RESET_ERROR(Result); 214 | continue; 215 | } 216 | else if (DisplayCount <= 0) 217 | { 218 | APP_LOG_WARN("Invalid Display Count. skipping display enumration for adapter:%d", AdapterIndex); 219 | continue; 220 | } 221 | 222 | hDisplayOutput = (ctl_display_output_handle_t *)malloc(sizeof(ctl_display_output_handle_t) * DisplayCount); 223 | EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput, "hDisplayOutput"); 224 | 225 | Result = ctlEnumerateDisplayOutputs(hDevices[AdapterIndex], &DisplayCount, hDisplayOutput); 226 | 227 | if (CTL_RESULT_SUCCESS != Result) 228 | { 229 | APP_LOG_ERROR("ctlEnumerateDisplayOutputs returned failure code: 0x%X", Result); 230 | STORE_AND_RESET_ERROR(Result); 231 | } 232 | 233 | // Only for demonstration purpose, API is called for each of the display output handle in below snippet. 234 | // User has to filter through the available display output handle and has to call the API with particular display output handle. 235 | Result = EnumerateDisplayHandles(hDisplayOutput, DisplayCount); 236 | 237 | if (CTL_RESULT_SUCCESS != Result) 238 | { 239 | APP_LOG_ERROR("EnumerateDisplayHandles returned failure code: 0x%X", Result); 240 | } 241 | 242 | CTL_FREE_MEM(hDisplayOutput); 243 | } 244 | 245 | Exit: 246 | 247 | CTL_FREE_MEM(hDisplayOutput); 248 | return Result; 249 | } 250 | 251 | /*************************************************************** 252 | * @brief Main Function which calls the Sample Panel Descriptor API 253 | * @param 254 | * @return int 255 | ***************************************************************/ 256 | int main() 257 | { 258 | ctl_result_t Result = CTL_RESULT_SUCCESS; 259 | ctl_device_adapter_handle_t *hDevices = NULL; 260 | // Get a handle to the DLL module. 261 | uint32_t AdapterCount = 0; 262 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 263 | 264 | ctl_init_args_t CtlInitArgs; 265 | ctl_api_handle_t hAPIHandle; 266 | 267 | ZeroMemory(&CtlInitArgs, sizeof(ctl_init_args_t)); 268 | 269 | CtlInitArgs.AppVersion = CTL_MAKE_VERSION(CTL_IMPL_MAJOR_VERSION, CTL_IMPL_MINOR_VERSION); 270 | CtlInitArgs.flags = 0; 271 | CtlInitArgs.Size = sizeof(CtlInitArgs); 272 | CtlInitArgs.Version = 0; 273 | 274 | try 275 | { 276 | Result = ctlInit(&CtlInitArgs, &hAPIHandle); 277 | LOG_AND_EXIT_ON_ERROR(Result, "ctlInit"); 278 | } 279 | catch (const std::bad_array_new_length &e) 280 | { 281 | APP_LOG_ERROR("%s ", e.what()); 282 | } 283 | 284 | // Initialization successful 285 | // Get the list of Intel Adapters 286 | try 287 | { 288 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 289 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 290 | } 291 | catch (const std::bad_array_new_length &e) 292 | { 293 | APP_LOG_ERROR("%s ", e.what()); 294 | } 295 | 296 | hDevices = (ctl_device_adapter_handle_t *)malloc(sizeof(ctl_device_adapter_handle_t) * AdapterCount); 297 | EXIT_ON_MEM_ALLOC_FAILURE(hDevices, "hDevices"); 298 | 299 | try 300 | { 301 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 302 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 303 | } 304 | catch (const std::bad_array_new_length &e) 305 | { 306 | APP_LOG_ERROR("%s ", e.what()); 307 | } 308 | 309 | Result = EnumerateTargetDisplays(AdapterCount, hDevices); 310 | 311 | if (CTL_RESULT_SUCCESS != Result) 312 | { 313 | APP_LOG_ERROR("EnumerateTargetDisplays returned failure code: 0x%X", Result); 314 | STORE_AND_RESET_ERROR(Result); 315 | } 316 | 317 | Exit: 318 | ctlClose(hAPIHandle); 319 | CTL_FREE_MEM(hDevices); 320 | APP_LOG_INFO("Overrall test result is 0x%X", GResult); 321 | return GResult; 322 | } -------------------------------------------------------------------------------- /Samples/Power_Feature_Samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME Power_Feature_Samples) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(Power_Feature_Samples VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/PowerFeature_Sample_App.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/Power_Feature_Samples/README.md: -------------------------------------------------------------------------------- 1 | Sample Application for Power Feature interfaces -------------------------------------------------------------------------------- /Samples/README.md: -------------------------------------------------------------------------------- 1 | # Sample Applications 2 | -------------------------------------------------------------------------------- /Samples/Scaling_Samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME Scaling_Samples) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(Scaling_Samples VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Scaling_App.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/Scaling_Samples/Scaling_App.cpp: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // Copyright (C) 2022 Intel Corporation 3 | // 4 | // 5 | // 6 | // SPDX-License-Identifier: MIT 7 | //-------------------------------------------------------------------------- 8 | 9 | /** 10 | * 11 | * @file Scaling_APP.cpp 12 | * @brief This file contains the 'main' function. Program execution begins and ends there. 13 | * 14 | */ 15 | 16 | #define _CRTDBG_MAP_ALLOC 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #define CTL_APIEXPORT // caller of control API DLL shall define this before 24 | // including igcl_api.h 25 | #include "igcl_api.h" 26 | #include "GenericIGCLApp.h" 27 | 28 | ctl_result_t GResult = CTL_RESULT_SUCCESS; 29 | 30 | /*************************************************************** 31 | * @brief 32 | * Scaling Test 33 | * @param hDevices 34 | * @return ctl_result_t 35 | ***************************************************************/ 36 | ctl_result_t ScalingTest(ctl_device_adapter_handle_t hDevices, uint8_t ScaleType, uint32_t PerX = 0, uint32_t PerY = 0) 37 | { 38 | ctl_display_output_handle_t *hDisplayOutput = NULL; 39 | uint32_t DisplayCount = 0; 40 | ctl_result_t Result = CTL_RESULT_SUCCESS; 41 | ctl_retro_scaling_caps_t RetroScalingCaps = { 0 }; 42 | ctl_retro_scaling_settings_t RetroScalingSettings = { 0 }; 43 | ctl_scaling_caps_t ScalingCaps = { 0 }; 44 | ctl_scaling_settings_t ScalingSetting = { 0 }; 45 | bool ModeSet; 46 | 47 | // Test Retro scaling 48 | // Retro scaling is adapter capability 49 | RetroScalingSettings = { 0 }; 50 | RetroScalingCaps = { 0 }; 51 | RetroScalingCaps.Size = sizeof(ctl_retro_scaling_caps_t); 52 | 53 | Result = ctlGetSupportedRetroScalingCapability(hDevices, &RetroScalingCaps); 54 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSupportedRetroScalingCapability"); 55 | 56 | APP_LOG_INFO("ctlGetSupportedRetroScalingCapability returned Caps: 0x%X", RetroScalingCaps.SupportedRetroScaling); 57 | 58 | // Test Integer Scaling 59 | RetroScalingSettings.Enable = true; 60 | RetroScalingSettings.RetroScalingType = RetroScalingSettings.RetroScalingType | CTL_RETRO_SCALING_TYPE_FLAG_INTEGER; 61 | RetroScalingSettings.Size = sizeof(ctl_retro_scaling_settings_t); 62 | 63 | Result = ctlGetSetRetroScaling(hDevices, &RetroScalingSettings); 64 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetRetroScaling"); 65 | 66 | // Check if applied correctly 67 | RetroScalingSettings = { 0 }; 68 | RetroScalingSettings.Get = true; 69 | RetroScalingSettings.RetroScalingType = RetroScalingSettings.RetroScalingType | CTL_RETRO_SCALING_TYPE_FLAG_INTEGER; 70 | RetroScalingSettings.Size = sizeof(ctl_retro_scaling_settings_t); 71 | 72 | Result = ctlGetSetRetroScaling(hDevices, &RetroScalingSettings); 73 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetRetroScaling"); 74 | 75 | APP_LOG_INFO("ctlGetSetRetroScaling returned Enable: 0x%X type:0x%x", RetroScalingSettings.Enable, RetroScalingSettings.RetroScalingType); 76 | 77 | // Enumerate all the possible target display's for the adapters 78 | Result = ctlEnumerateDisplayOutputs(hDevices, &DisplayCount, hDisplayOutput); 79 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDisplayOutputs"); 80 | 81 | if (DisplayCount <= 0) 82 | { 83 | APP_LOG_ERROR("Invalid Display Count"); 84 | goto Exit; 85 | } 86 | 87 | hDisplayOutput = (ctl_display_output_handle_t *)malloc(sizeof(ctl_display_output_handle_t) * DisplayCount); 88 | EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput, "hDisplayOutput"); 89 | 90 | Result = ctlEnumerateDisplayOutputs(hDevices, &DisplayCount, hDisplayOutput); 91 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDisplayOutputs"); 92 | 93 | // Only for demonstration purpose, API is called for each of the display output handle in below snippet. 94 | // User has to filter through the available display output handle and has to call the API with particular display output handle. 95 | for (uint32_t i = 0; i < DisplayCount; i++) 96 | { 97 | ScalingCaps = { 0 }; 98 | ScalingSetting = { 0 }; 99 | ScalingCaps.Size = sizeof(ctl_scaling_caps_t); 100 | 101 | EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput[i], "hDisplayOutput"); 102 | 103 | Result = ctlGetSupportedScalingCapability(hDisplayOutput[i], &ScalingCaps); 104 | 105 | if (CTL_RESULT_SUCCESS != Result) 106 | { 107 | APP_LOG_WARN("ctlGetSupportedScalingCapability returned failure code: 0x%X", Result); 108 | STORE_AND_RESET_ERROR(Result); 109 | continue; 110 | } 111 | 112 | APP_LOG_INFO("ctlGetSupportedScalingCapability returned caps: 0x%X", ScalingCaps.SupportedScaling); 113 | 114 | PRINT_LOGS("******* Supported Scaling types ********"); 115 | 116 | if (CTL_SCALING_TYPE_FLAG_IDENTITY & ScalingCaps.SupportedScaling) 117 | { 118 | APP_LOG_INFO("CTL_SCALING_TYPE_FLAG_IDENTITY(1) is supported"); 119 | } 120 | if (CTL_SCALING_TYPE_FLAG_CENTERED & ScalingCaps.SupportedScaling) 121 | { 122 | APP_LOG_INFO("CTL_SCALING_TYPE_FLAG_CENTERED(2) is supported"); 123 | } 124 | if (CTL_SCALING_TYPE_FLAG_STRETCHED & ScalingCaps.SupportedScaling) 125 | { 126 | APP_LOG_INFO("CTL_SCALING_TYPE_FLAG_STRETCHED(4) is supported"); 127 | } 128 | if (CTL_SCALING_TYPE_FLAG_ASPECT_RATIO_CENTERED_MAX & ScalingCaps.SupportedScaling) 129 | { 130 | APP_LOG_INFO("CTL_SCALING_TYPE_FLAG_ASPECT_RATIO_CENTERED_MAX(8) is supported"); 131 | } 132 | if (CTL_SCALING_TYPE_FLAG_CUSTOM & ScalingCaps.SupportedScaling) 133 | { 134 | APP_LOG_INFO("CTL_SCALING_TYPE_FLAG_CUSTOM(16) is supported"); 135 | } 136 | 137 | if (0 != ScalingCaps.SupportedScaling) 138 | { 139 | ScalingSetting.Size = sizeof(ctl_scaling_settings_t); 140 | ScalingSetting.Version = 1; 141 | Result = ctlGetCurrentScaling(hDisplayOutput[i], &ScalingSetting); 142 | 143 | if (CTL_RESULT_SUCCESS != Result) 144 | { 145 | APP_LOG_WARN("ctlGetCurrentScaling returned failure code: 0x%X", Result); 146 | STORE_AND_RESET_ERROR(Result); 147 | continue; 148 | } 149 | APP_LOG_INFO("ctlGetCurrentScaling returned Enable: 0x%X ScalingType:0x%x PreferredScalingType:0x%x", ScalingSetting.Enable, ScalingSetting.ScalingType, 150 | ScalingSetting.PreferredScalingType); 151 | } 152 | 153 | // fill custom scaling details only if it is supported 154 | if ((CTL_SCALING_TYPE_FLAG_CUSTOM & ScalingCaps.SupportedScaling) && (CTL_SCALING_TYPE_FLAG_CUSTOM == ScaleType)) 155 | { 156 | // check if hardware modeset required to apply custom scaling 157 | ModeSet = ((TRUE == ScalingSetting.Enable) && (CTL_SCALING_TYPE_FLAG_CUSTOM == ScalingSetting.ScalingType)) ? FALSE : TRUE; 158 | // filling custom scaling details 159 | ScalingSetting = { 0 }; 160 | ScalingSetting.Enable = true; 161 | ScalingSetting.ScalingType = CTL_SCALING_TYPE_FLAG_CUSTOM; 162 | ScalingSetting.Size = sizeof(ctl_scaling_settings_t); 163 | ScalingSetting.HardwareModeSet = (TRUE == ModeSet) ? TRUE : FALSE; 164 | ScalingSetting.Version = 1; 165 | 166 | APP_LOG_INFO("*** PerX:%d PerY:%d ***", PerX, PerY); 167 | 168 | ScalingSetting.CustomScalingX = PerX; 169 | ScalingSetting.CustomScalingY = PerY; 170 | } 171 | else 172 | { 173 | // filling custom scaling details 174 | ScalingSetting = { 0 }; 175 | ScalingSetting.Enable = true; 176 | ScalingSetting.ScalingType = ScaleType; 177 | ScalingSetting.Size = sizeof(ctl_scaling_settings_t); 178 | ScalingSetting.Version = 1; 179 | } 180 | 181 | APP_LOG_INFO("ScalingSetting.ScalingType:%d", ScalingSetting.ScalingType); 182 | 183 | Result = ctlSetCurrentScaling(hDisplayOutput[i], &ScalingSetting); 184 | 185 | if (CTL_RESULT_SUCCESS != Result) 186 | { 187 | APP_LOG_WARN("ctlSetCurrentScaling returned failure code: 0x%X", Result); 188 | STORE_AND_RESET_ERROR(Result); 189 | continue; 190 | } 191 | // check if the applied scaling was successful 192 | ScalingSetting = { 0 }; 193 | ScalingSetting.Size = sizeof(ctl_scaling_settings_t); 194 | ScalingSetting.Version = 1; 195 | Result = ctlGetCurrentScaling(hDisplayOutput[i], &ScalingSetting); 196 | if (CTL_RESULT_SUCCESS != Result) 197 | { 198 | APP_LOG_WARN("ctlGetCurrentScaling returned failure code: 0x%X", Result); 199 | STORE_AND_RESET_ERROR(Result); 200 | continue; 201 | } 202 | 203 | APP_LOG_INFO("ctlGetCurrentScaling returned Enable: 0x%X ScalingType:0x%x PreferredScalingType:0x%x", ScalingSetting.Enable, ScalingSetting.ScalingType, ScalingSetting.PreferredScalingType); 204 | 205 | if (CTL_SCALING_TYPE_FLAG_CUSTOM == ScalingSetting.ScalingType) 206 | { 207 | APP_LOG_INFO("ScalingSetting.CustomScalingX:%d", ScalingSetting.CustomScalingX); 208 | APP_LOG_INFO("ScalingSetting.CustomScalingY:%d", ScalingSetting.CustomScalingY); 209 | } 210 | } 211 | 212 | Exit: 213 | CTL_FREE_MEM(hDisplayOutput); 214 | return Result; 215 | } 216 | 217 | /*************************************************************** 218 | * @brief Main Function which calls the Scaling API 219 | * main 220 | * @param 221 | * @return 222 | ***************************************************************/ 223 | int main(int argc, char *pArgv[]) 224 | { 225 | uint8_t ScaleType = 0; 226 | uint32_t X = 0, Y = 0; 227 | 228 | if (argc < 2) 229 | { 230 | APP_LOG_ERROR("Enter Scale type!\""); 231 | return 0; 232 | } 233 | 234 | // Converting string type to integer type 235 | // using function "atoi( argument)" 236 | 237 | if (2 == argc) 238 | { 239 | ScaleType = atoi(pArgv[1]); 240 | } 241 | else if (4 == argc) 242 | { 243 | ScaleType = atoi(pArgv[1]); 244 | X = atoi(pArgv[2]); 245 | Y = atoi(pArgv[3]); 246 | } 247 | 248 | ctl_result_t Result = CTL_RESULT_SUCCESS; 249 | ctl_device_adapter_handle_t *hDevices = NULL; 250 | // Get a handle to the DLL module. 251 | uint32_t AdapterCount = 0; 252 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 253 | 254 | ctl_init_args_t CtlInitArgs; 255 | ctl_api_handle_t hAPIHandle; 256 | 257 | ZeroMemory(&CtlInitArgs, sizeof(ctl_init_args_t)); 258 | 259 | ctl_retro_scaling_caps_t RetroScalingCaps = { 0 }; 260 | ctl_retro_scaling_settings_t RetroScalingSettings = { 0 }; 261 | ctl_scaling_caps_t ScalingCaps = { 0 }; 262 | ctl_scaling_settings_t ScalingSetting = { 0 }; 263 | 264 | CtlInitArgs.AppVersion = CTL_MAKE_VERSION(CTL_IMPL_MAJOR_VERSION, CTL_IMPL_MINOR_VERSION); 265 | CtlInitArgs.flags = 0; 266 | CtlInitArgs.Size = sizeof(CtlInitArgs); 267 | CtlInitArgs.Version = 0; 268 | 269 | try 270 | { 271 | Result = ctlInit(&CtlInitArgs, &hAPIHandle); 272 | LOG_AND_EXIT_ON_ERROR(Result, "ctlInit"); 273 | } 274 | catch (const std::bad_array_new_length &e) 275 | { 276 | APP_LOG_ERROR("%s ", e.what()); 277 | } 278 | 279 | // Initialization successful 280 | // Get the list of Intel Adapters 281 | try 282 | { 283 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 284 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 285 | } 286 | catch (const std::bad_array_new_length &e) 287 | { 288 | APP_LOG_ERROR("%s ", e.what()); 289 | } 290 | 291 | hDevices = (ctl_device_adapter_handle_t *)malloc(sizeof(ctl_device_adapter_handle_t) * AdapterCount); 292 | EXIT_ON_MEM_ALLOC_FAILURE(hDevices, "hDevices"); 293 | 294 | try 295 | { 296 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 297 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 298 | } 299 | catch (const std::bad_array_new_length &e) 300 | { 301 | APP_LOG_ERROR("%s ", e.what()); 302 | } 303 | 304 | for (uint32_t i = 0; i < AdapterCount; i++) 305 | { 306 | Result = ScalingTest(hDevices[i], ScaleType, X, Y); 307 | 308 | if (CTL_RESULT_SUCCESS != Result) 309 | { 310 | APP_LOG_WARN("ctlGetCurrentScaling returned failure code: 0x%X", Result); 311 | STORE_AND_RESET_ERROR(Result); 312 | continue; 313 | } 314 | } 315 | 316 | Exit: 317 | 318 | ctlClose(hAPIHandle); 319 | CTL_FREE_MEM(hDevices); 320 | APP_LOG_INFO("Overrall test result is 0x%X", GResult); 321 | return GResult; 322 | } -------------------------------------------------------------------------------- /Samples/ScdcRead/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME ScdcRead) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(ScdcRead VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/ScdcReadApp.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/ScdcRead/README.md: -------------------------------------------------------------------------------- 1 | Sample Application for SCDC reads -------------------------------------------------------------------------------- /Samples/ScdcRead/ScdcReadApp.cpp: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // Copyright (C) 2022 Intel Corporation 3 | // 4 | // 5 | // 6 | // SPDX-License-Identifier: MIT 7 | //-------------------------------------------------------------------------- 8 | 9 | /** 10 | * 11 | * @file ScdcReadApp.cpp 12 | * @brief This file contains the SCDC Read & the 'main' function. Program execution begins and ends there. 13 | * 14 | */ 15 | 16 | #define _CRTDBG_MAP_ALLOC 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #define CTL_APIEXPORT // caller of control API DLL shall define this before 24 | // including igcl_api.h 25 | #include "igcl_api.h" 26 | #include "GenericIGCLApp.h" 27 | 28 | ctl_result_t GResult = CTL_RESULT_SUCCESS; 29 | 30 | /*************************************************************** 31 | * @brief ScdcReadFromPanel 32 | * Reference code to read SCDC data from panel 33 | * @param hDisplayOutput 34 | * @return ctl_result_t 35 | ***************************************************************/ 36 | ctl_result_t ScdcReadFromPanel(ctl_display_output_handle_t hDisplayOutput) 37 | { 38 | ctl_result_t Result = CTL_RESULT_SUCCESS; 39 | ctl_i2c_access_args_t I2CArgs = { 0 }; // I2C Access 40 | uint32_t Count = 0; 41 | 42 | I2CArgs.Size = sizeof(ctl_i2c_access_args_t); 43 | I2CArgs.OpType = CTL_OPERATION_TYPE_READ; 44 | 45 | EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput, "hDisplayOutput"); 46 | 47 | I2CArgs.Address = 0xA8; 48 | printf("\nReading SCDC...\n"); 49 | 50 | I2CArgs.Offset = 0x00; 51 | I2CArgs.DataSize = 0x80; 52 | 53 | Result = ctlI2CAccess(hDisplayOutput, &I2CArgs); 54 | LOG_AND_EXIT_ON_ERROR(Result, "ctlI2CAccess for I2C read"); 55 | 56 | // Print the data 57 | for (uint32_t i = 0; i < I2CArgs.DataSize / 16; i++) 58 | { 59 | for (uint32_t j = 0; j < 16; j++) 60 | printf("0x%02X ", I2CArgs.Data[j + (i * 16)]); 61 | printf("\n\n"); 62 | } 63 | 64 | Exit: 65 | 66 | return Result; 67 | } 68 | 69 | /*************************************************************** 70 | * @brief ReadScdcData 71 | * 72 | * @param hDisplayOutput, DisplayCount 73 | * @return ctl_result_t 74 | ***************************************************************/ 75 | ctl_result_t ReadScdcData(ctl_display_output_handle_t *hDisplayOutput, uint32_t DisplayCount) 76 | { 77 | ctl_result_t Result = CTL_RESULT_SUCCESS; 78 | 79 | for (uint32_t DisplayIndex = 0; DisplayIndex < DisplayCount; DisplayIndex++) 80 | { 81 | ctl_display_properties_t DisplayProperties = { 0 }; 82 | DisplayProperties.Size = sizeof(ctl_display_properties_t); 83 | 84 | Result = ctlGetDisplayProperties(hDisplayOutput[DisplayIndex], &DisplayProperties); 85 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetDisplayProperties"); 86 | 87 | bool IsDisplayAttached = (0 != (DisplayProperties.DisplayConfigFlags & CTL_DISPLAY_CONFIG_FLAG_DISPLAY_ATTACHED)); 88 | 89 | if (FALSE == IsDisplayAttached) 90 | { 91 | printf("Display %d is not attached, skipping the call for this display\n", DisplayIndex); 92 | continue; 93 | } 94 | 95 | if ((DisplayProperties.Type != CTL_DISPLAY_OUTPUT_TYPES_HDMI) && 96 | ((DisplayProperties.ProtocolConverterType == 0) || (DisplayProperties.ProtocolConverterOutput != CTL_DISPLAY_OUTPUT_TYPES_HDMI))) 97 | { 98 | printf("Display %d is not HDMI, skipping the call for this display\n", DisplayIndex); 99 | continue; 100 | } 101 | 102 | Result = ScdcReadFromPanel(hDisplayOutput[DisplayIndex]); 103 | STORE_AND_RESET_ERROR(Result); 104 | } 105 | 106 | Exit: 107 | return Result; 108 | } 109 | 110 | /*************************************************************** 111 | * @brief EnumerateTargetDisplays 112 | * Enumerates all the possible target display's for the adapters 113 | * @param hDisplayOutput, AdapterCount, hDevices, **hDisplayOutput, *pDisplayCount 114 | * @return ctl_result_t 115 | ***************************************************************/ 116 | ctl_result_t EnumerateTargetDisplays(uint32_t AdapterCount, ctl_device_adapter_handle_t *hDevices, ctl_display_output_handle_t **hDisplayOutput, uint32_t *pDisplayCount) 117 | { 118 | ctl_result_t Result = CTL_RESULT_SUCCESS; 119 | 120 | for (uint32_t AdapterIndex = 0; AdapterIndex < AdapterCount; AdapterIndex++) 121 | { 122 | // enumerate all the possible target display's for the adapters 123 | // first step is to get the count 124 | *pDisplayCount = 0; 125 | 126 | Result = ctlEnumerateDisplayOutputs(hDevices[AdapterIndex], pDisplayCount, *hDisplayOutput); 127 | 128 | if (CTL_RESULT_SUCCESS != Result) 129 | { 130 | printf("ctlEnumerateDisplayOutputs returned failure to get # of displays code: 0x%X\n", Result); 131 | STORE_AND_RESET_ERROR(Result); 132 | continue; 133 | } 134 | else if (*pDisplayCount <= 0) 135 | { 136 | printf("Invalid Display Count. skipping display enumration for adapter:%d\n", AdapterIndex); 137 | continue; 138 | } 139 | 140 | *hDisplayOutput = (ctl_display_output_handle_t *)malloc(sizeof(ctl_display_output_handle_t) * (*pDisplayCount)); 141 | EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput, "hDisplayOutput"); 142 | 143 | Result = ctlEnumerateDisplayOutputs(hDevices[AdapterIndex], pDisplayCount, *hDisplayOutput); 144 | 145 | if (CTL_RESULT_SUCCESS != Result) 146 | { 147 | printf("ctlEnumerateDisplayOutputs returned failure to get handles code: 0x%X\n", Result); 148 | STORE_AND_RESET_ERROR(Result); 149 | } 150 | } 151 | 152 | Exit: 153 | 154 | return Result; 155 | } 156 | 157 | /*************************************************************** 158 | * @brief Main Function which calls the Sample I2CAuxAccess API for SCDC reads 159 | * @param 160 | * @return int 161 | ***************************************************************/ 162 | int main() 163 | { 164 | ctl_result_t Result = CTL_RESULT_SUCCESS; 165 | ctl_device_adapter_handle_t *hDevices = NULL; 166 | ctl_display_output_handle_t *hDisplayOutput = NULL; 167 | uint32_t DisplayCount; 168 | 169 | // Get a handle to the DLL module. 170 | uint32_t AdapterCount = 0; 171 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 172 | 173 | ctl_init_args_t CtlInitArgs; 174 | ctl_api_handle_t hAPIHandle; 175 | 176 | ZeroMemory(&CtlInitArgs, sizeof(ctl_init_args_t)); 177 | 178 | CtlInitArgs.AppVersion = CTL_MAKE_VERSION(CTL_IMPL_MAJOR_VERSION, CTL_IMPL_MINOR_VERSION); 179 | CtlInitArgs.flags = 0; 180 | CtlInitArgs.Size = sizeof(CtlInitArgs); 181 | CtlInitArgs.Version = 0; 182 | 183 | try 184 | { 185 | Result = ctlInit(&CtlInitArgs, &hAPIHandle); 186 | LOG_AND_EXIT_ON_ERROR(Result, "ctlInit"); 187 | } 188 | catch (const std::bad_array_new_length &e) 189 | { 190 | printf("%s \n", e.what()); 191 | } 192 | 193 | // Initialization successful 194 | // Get the list of Intel Adapters 195 | try 196 | { 197 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 198 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 199 | } 200 | catch (const std::bad_array_new_length &e) 201 | { 202 | printf("%s \n", e.what()); 203 | } 204 | 205 | hDevices = (ctl_device_adapter_handle_t *)malloc(sizeof(ctl_device_adapter_handle_t) * AdapterCount); 206 | EXIT_ON_MEM_ALLOC_FAILURE(hDevices, "hDevices"); 207 | 208 | try 209 | { 210 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 211 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 212 | } 213 | catch (const std::bad_array_new_length &e) 214 | { 215 | printf("%s \n", e.what()); 216 | } 217 | 218 | Result = EnumerateTargetDisplays(AdapterCount, hDevices, &hDisplayOutput, &DisplayCount); 219 | 220 | if (CTL_RESULT_SUCCESS != Result) 221 | { 222 | printf("EnumerateTargetDisplays returned failure code: 0x%X\n", Result); 223 | STORE_AND_RESET_ERROR(Result); 224 | } 225 | 226 | // Only for demonstration purpose, API is called for each of the display output handle in below snippet. 227 | // User has to filter through the available display output handle and has to call the API with particular display output handle. 228 | Result = ReadScdcData(hDisplayOutput, DisplayCount); 229 | 230 | if (CTL_RESULT_SUCCESS != Result) 231 | { 232 | printf("EnumerateDisplayHandles returned failure code: 0x%X\n", Result); 233 | } 234 | 235 | Exit: 236 | 237 | CTL_FREE_MEM(hDisplayOutput); 238 | 239 | ctlClose(hAPIHandle); 240 | CTL_FREE_MEM(hDevices); 241 | printf("Overrall test result is 0x%X\n", GResult); 242 | return GResult; 243 | } 244 | 245 | // Run program: Ctrl + F5 or Debug > Start Without Debugging menu 246 | // Debug program: F5 or Debug > Start Debugging menu 247 | 248 | // Tips for Getting Started: 249 | // 1. Use the Solution Explorer window to add/manage files 250 | // 2. Use the Team Explorer window to connect to source control 251 | // 3. Use the Output window to see build output and other messages 252 | // 4. Use the Error List window to view errors 253 | // 5. Go to Project > Add New Item to create new code files, or Project > Add 254 | // Existing Item to add existing code files to the project 255 | // 6. In the future, to open this project again, go to File > Open > Project 256 | // and select the .sln file 257 | -------------------------------------------------------------------------------- /Samples/Telemetry_Samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME Telemetry_Samples) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(Telemetry_Samples VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Sample_TelemetryAPP.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/Telemetry_Samples/README.md: -------------------------------------------------------------------------------- 1 | Sample Application for the Telemetry interface -------------------------------------------------------------------------------- /Samples/UBRR_Sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR) 2 | set(TARGET_NAME UBRR_Sample) 3 | get_filename_component(ROOT_DIR ../../ ABSOLUTE) 4 | project(UBRR_Sample VERSION 1.0) 5 | add_executable(${TARGET_NAME} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/UBRR_Sample_App.cpp 7 | ${ROOT_DIR}/Source/cApiWrapper.cpp 8 | ) 9 | 10 | if(MSVC) 11 | set_target_properties(${TARGET_NAME} 12 | PROPERTIES 13 | VS_DEBUGGER_COMMAND_ARGUMENTS "" 14 | VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)" 15 | ) 16 | 17 | ADD_DEFINITIONS(-DUNICODE) 18 | ADD_DEFINITIONS(-D_UNICODE) 19 | endif() 20 | 21 | include_directories(${ROOT_DIR}/include) 22 | include_directories(${ROOT_DIR}/Samples/inc) -------------------------------------------------------------------------------- /Samples/UBRR_Sample/UBRR_Sample_App.cpp: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // Copyright (C) 2022 Intel Corporation 3 | // 4 | // 5 | // 6 | // SPDX-License-Identifier: MIT 7 | //-------------------------------------------------------------------------- 8 | 9 | /** 10 | * 11 | * @file UBRR_Sample_APP.cpp 12 | * @brief This file contains the 'main' function & the UBRR Sample APP. Program execution begins and ends there. 13 | * 14 | */ 15 | 16 | #define _CRTDBG_MAP_ALLOC 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #define CTL_APIEXPORT // caller of control API DLL shall define this before 24 | // including igcl_api.h 25 | #include "igcl_api.h" 26 | #include "GenericIGCLApp.h" 27 | 28 | ctl_result_t GResult = CTL_RESULT_SUCCESS; 29 | 30 | /*************************************************************** 31 | * @brief EnumerateDisplayHandles 32 | * Only for demonstration purpose, API is called for each of the display output handle in below snippet. 33 | * User has to filter through the available display output handle and has to call the API with particular display output handle. 34 | * @param hDisplayOutput, DisplayCount 35 | * @return ctl_result_t 36 | ***************************************************************/ 37 | ctl_result_t EnumerateDisplayHandles(ctl_display_output_handle_t *hDisplayOutput, uint32_t DisplayCount) 38 | { 39 | ctl_result_t Result = CTL_RESULT_SUCCESS; 40 | 41 | if (0 == DisplayCount) 42 | { 43 | APP_LOG_ERROR("Invalid Display Count "); 44 | goto Exit; 45 | } 46 | 47 | // Only for demonstration purpose, API is called for each of the display output handle in below snippet. 48 | // User has to filter through the available display output handle and has to call the API with particular display output handle. 49 | for (uint32_t DisplayIndex = 0; DisplayIndex < DisplayCount; DisplayIndex++) 50 | { 51 | ctl_power_optimization_caps_t PowerOptimizationCaps = { 0 }; 52 | ctl_power_optimization_settings_t PowerOptimizationSetting = { 0 }; 53 | 54 | if (NULL == hDisplayOutput[DisplayIndex]) 55 | { 56 | continue; 57 | } 58 | 59 | PowerOptimizationCaps.Size = sizeof(ctl_pfnGetPowerOptimizationCaps_t); 60 | Result = ctlGetPowerOptimizationCaps(hDisplayOutput[DisplayIndex], &PowerOptimizationCaps); 61 | 62 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetPowerOptimizationCaps"); 63 | 64 | if (PowerOptimizationCaps.SupportedFeatures & CTL_POWER_OPTIMIZATION_FLAG_LRR) 65 | { 66 | PowerOptimizationSetting.PowerOptimizationFeature = CTL_POWER_OPTIMIZATION_FLAG_LRR; 67 | PowerOptimizationSetting.Size = sizeof(ctl_power_optimization_settings_t); 68 | Result = ctlGetPowerOptimizationSetting(hDisplayOutput[DisplayIndex], &PowerOptimizationSetting); 69 | 70 | LOG_AND_EXIT_ON_ERROR(Result, "ctlGetPowerOptimizationSetting"); 71 | } 72 | 73 | if (PowerOptimizationSetting.FeatureSpecificData.LRRInfo.SupportedLRRTypes & CTL_POWER_OPTIMIZATION_LRR_FLAG_UBLRR) 74 | { 75 | if (PowerOptimizationSetting.FeatureSpecificData.LRRInfo.bRequirePSRDisable) 76 | { 77 | // Disable PSR. 78 | } 79 | 80 | PowerOptimizationSetting = { 0 }; 81 | PowerOptimizationSetting.PowerOptimizationFeature = CTL_POWER_OPTIMIZATION_FLAG_LRR; 82 | 83 | PowerOptimizationSetting.FeatureSpecificData.LRRInfo.CurrentLRRTypes = CTL_POWER_OPTIMIZATION_LRR_FLAG_UBLRR; 84 | PowerOptimizationSetting.Enable = TRUE; 85 | PowerOptimizationSetting.Size = sizeof(ctl_power_optimization_settings_t); 86 | Result = ctlSetPowerOptimizationSetting(hDisplayOutput[DisplayIndex], &PowerOptimizationSetting); 87 | 88 | LOG_AND_EXIT_ON_ERROR(Result, "ctlSetPowerOptimizationSetting"); 89 | } 90 | } 91 | 92 | Exit: 93 | return Result; 94 | } 95 | 96 | /*************************************************************** 97 | * @brief EnumerateTargetDisplays 98 | * Enumerates all the possible target display's for the adapters 99 | * @param hDisplayOutput, AdapterCount, hDevices 100 | * @return ctl_result_t 101 | ***************************************************************/ 102 | ctl_result_t EnumerateTargetDisplays(uint32_t AdapterCount, ctl_device_adapter_handle_t *hDevices) 103 | { 104 | ctl_display_output_handle_t *hDisplayOutput = NULL; 105 | ctl_result_t Result = CTL_RESULT_SUCCESS; 106 | uint32_t DisplayCount = 0; 107 | 108 | for (uint32_t AdapterIndex = 0; AdapterIndex < AdapterCount; AdapterIndex++) 109 | { 110 | // enumerate all the possible target display's for the adapters 111 | // first step is to get the count 112 | DisplayCount = 0; 113 | 114 | Result = ctlEnumerateDisplayOutputs(hDevices[AdapterIndex], &DisplayCount, hDisplayOutput); 115 | 116 | if (CTL_RESULT_SUCCESS != Result) 117 | { 118 | APP_LOG_WARN("ctlEnumerateDisplayOutputs returned failure code: 0x%X", Result); 119 | STORE_AND_RESET_ERROR(Result); 120 | continue; 121 | } 122 | else if (DisplayCount <= 0) 123 | { 124 | APP_LOG_WARN("Invalid Display Count. skipping display enumeration for adapter:%d", AdapterIndex); 125 | continue; 126 | } 127 | 128 | hDisplayOutput = (ctl_display_output_handle_t *)malloc(sizeof(ctl_display_output_handle_t) * DisplayCount); 129 | 130 | EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput, "hDisplayOutput"); 131 | 132 | Result = ctlEnumerateDisplayOutputs(hDevices[AdapterIndex], &DisplayCount, hDisplayOutput); 133 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDisplayOutputs"); 134 | 135 | // Only for demonstration purpose, API is called for each of the display output handle in below snippet. 136 | // User has to filter through the available display output handle and has to call the API with particular display output handle. 137 | Result = EnumerateDisplayHandles(hDisplayOutput, DisplayCount); 138 | STORE_AND_RESET_ERROR(Result); 139 | 140 | CTL_FREE_MEM(hDisplayOutput); 141 | } 142 | 143 | Exit: 144 | 145 | CTL_FREE_MEM(hDisplayOutput); 146 | return Result; 147 | } 148 | 149 | /*************************************************************** 150 | * @brief 151 | * Main Function which calls the Sample UBBR API 152 | * @param 153 | * @return int 154 | ***************************************************************/ 155 | int main() 156 | { 157 | ctl_result_t Result = CTL_RESULT_SUCCESS; 158 | ctl_device_adapter_handle_t *hDevices = NULL; 159 | // Get a handle to the DLL module. 160 | uint32_t AdapterCount = 0; 161 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 162 | 163 | ctl_init_args_t CtlInitArgs; 164 | ctl_api_handle_t hAPIHandle; 165 | 166 | ZeroMemory(&CtlInitArgs, sizeof(ctl_init_args_t)); 167 | 168 | CtlInitArgs.AppVersion = CTL_MAKE_VERSION(CTL_IMPL_MAJOR_VERSION, CTL_IMPL_MINOR_VERSION); 169 | CtlInitArgs.flags = 0; 170 | CtlInitArgs.Size = sizeof(CtlInitArgs); 171 | CtlInitArgs.Version = 0; 172 | 173 | try 174 | { 175 | Result = ctlInit(&CtlInitArgs, &hAPIHandle); 176 | LOG_AND_EXIT_ON_ERROR(Result, "ctlInit"); 177 | } 178 | catch (const std::bad_array_new_length &e) 179 | { 180 | APP_LOG_ERROR("%s ", e.what()); 181 | } 182 | 183 | // Initialization successful 184 | // Get the list of Intel Adapters 185 | try 186 | { 187 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 188 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 189 | } 190 | catch (const std::bad_array_new_length &e) 191 | { 192 | APP_LOG_ERROR("%s ", e.what()); 193 | } 194 | 195 | hDevices = (ctl_device_adapter_handle_t *)malloc(sizeof(ctl_device_adapter_handle_t) * AdapterCount); 196 | EXIT_ON_MEM_ALLOC_FAILURE(hDevices, "hDevices"); 197 | 198 | try 199 | { 200 | Result = ctlEnumerateDevices(hAPIHandle, &AdapterCount, hDevices); 201 | LOG_AND_EXIT_ON_ERROR(Result, "ctlEnumerateDevices"); 202 | } 203 | catch (const std::bad_array_new_length &e) 204 | { 205 | APP_LOG_ERROR("%s ", e.what()); 206 | } 207 | 208 | Result = EnumerateTargetDisplays(AdapterCount, hDevices); 209 | 210 | if (CTL_RESULT_SUCCESS != Result) 211 | { 212 | APP_LOG_ERROR("EnumerateTargetDisplays returned failure code: 0x%X", Result); 213 | STORE_AND_RESET_ERROR(Result); 214 | } 215 | 216 | Exit: 217 | 218 | ctlClose(hAPIHandle); 219 | CTL_FREE_MEM(hDevices); 220 | APP_LOG_INFO("Overrall test result is 0x%X", GResult); 221 | return GResult; 222 | } -------------------------------------------------------------------------------- /Samples/inc/GenericIGCLApp.h: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // Copyright (C) 2022 Intel Corporation 3 | // 4 | // 5 | // 6 | // SPDX-License-Identifier: MIT 7 | //-------------------------------------------------------------------------- 8 | 9 | /** 10 | * 11 | * @file GenericIGCLApp.h 12 | * @brief 13 | * 14 | */ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "igcl_api.h" 24 | 25 | #define STORE_AND_RESET_ERROR(Result) \ 26 | if (CTL_RESULT_SUCCESS != Result) \ 27 | GResult = Result; \ 28 | Result = CTL_RESULT_SUCCESS; 29 | 30 | #define CTL_FREE_MEM(Ptr) \ 31 | if (NULL != Ptr) \ 32 | { \ 33 | free(Ptr); \ 34 | Ptr = NULL; \ 35 | } 36 | 37 | #define EXIT_ON_ERROR(Result) \ 38 | if (CTL_RESULT_SUCCESS != Result) \ 39 | goto Exit; 40 | 41 | #define LOG_AND_EXIT_ON_ERROR(Result, ErrRtrndByFunc) \ 42 | if (CTL_RESULT_SUCCESS != Result) \ 43 | { \ 44 | printf("[ERROR] %s returned failure code: 0x%X\n", ErrRtrndByFunc, Result); \ 45 | goto Exit; \ 46 | } 47 | 48 | #define EXIT_ON_MEM_ALLOC_FAILURE(Ptr, AllocatedVarName) \ 49 | if (NULL == Ptr) \ 50 | { \ 51 | Result = CTL_RESULT_ERROR_INVALID_NULL_POINTER; \ 52 | printf("[ERROR] Memory Allocation Failed: %s \n", AllocatedVarName); \ 53 | goto Exit; \ 54 | } 55 | 56 | #define LOG_AND_STORE_RESET_RESULT_ON_ERROR(Result, ErrRtrndByFunc) \ 57 | if (CTL_RESULT_SUCCESS != Result) \ 58 | { \ 59 | printf("[ERROR] %s returned failure code: 0x%X\n", ErrRtrndByFunc, Result); \ 60 | STORE_AND_RESET_ERROR(Result); \ 61 | } 62 | 63 | // Application logging macro 64 | #define APP_LOG_INFO(fmt, ...) printf("[INFO] " fmt "\n", ##__VA_ARGS__) 65 | #define APP_LOG_WARN(fmt, ...) printf("[WARN] " fmt "\n", ##__VA_ARGS__) 66 | #define APP_LOG_ERROR(fmt, ...) printf("[ERROR] " fmt "\n", ##__VA_ARGS__) 67 | 68 | #define PRINT_LOGS(...) \ 69 | printf(__VA_ARGS__); \ 70 | printf("\n") 71 | 72 | #define CONTROL_BIT(_i) (1 << _i) 73 | 74 | typedef enum _feature_control_type 75 | { 76 | ENDURANCE_GAMING_CONTROLS = 0, ///< Endurance gaming controls 77 | ENDURANCE_GAMING_MODES = 1, ///< Endurance gaming modes 78 | } feature_control_type; 79 | 80 | /*************************************************************** 81 | * @brief Method to get 3D feature name 82 | ***************************************************************/ 83 | inline char *Get3DFeatureName(ctl_3d_feature_t FeatureType) 84 | { 85 | switch (FeatureType) 86 | { 87 | case CTL_3D_FEATURE_FRAME_PACING: 88 | return "Frame pacing"; 89 | case CTL_3D_FEATURE_ENDURANCE_GAMING: 90 | return "Endurance gaming"; 91 | case CTL_3D_FEATURE_FRAME_LIMIT: 92 | return "Frame limit"; 93 | case CTL_3D_FEATURE_ANISOTROPIC: 94 | return "Anisotropic"; 95 | case CTL_3D_FEATURE_CMAA: 96 | return "CMAA"; 97 | case CTL_3D_FEATURE_TEXTURE_FILTERING_QUALITY: 98 | return "TEXTURE_FILTERING_QUALITY"; 99 | case CTL_3D_FEATURE_ADAPTIVE_TESSELLATION: 100 | return "Adaptive tessellation"; 101 | case CTL_3D_FEATURE_SHARPENING_FILTER: 102 | return "Sharpening filter"; 103 | case CTL_3D_FEATURE_MSAA: 104 | return "MSAA"; 105 | case CTL_3D_FEATURE_GAMING_FLIP_MODES: 106 | return "Gaming flip modes"; 107 | case CTL_3D_FEATURE_ADAPTIVE_SYNC_PLUS: 108 | return "Adaptive sync plus"; 109 | case CTL_3D_FEATURE_APP_PROFILES: 110 | return "Application profile"; 111 | case CTL_3D_FEATURE_APP_PROFILE_DETAILS: 112 | return "Application profile custom details"; 113 | case CTL_3D_FEATURE_EMULATED_TYPED_64BIT_ATOMICS: 114 | return "Emulated typed 64 bit atomics"; 115 | case CTL_3D_FEATURE_VRR_WINDOWED_BLT: 116 | return "VRR windowed blt"; 117 | case CTL_3D_FEATURE_GLOBAL_OR_PER_APP: 118 | return "global or per app settings"; 119 | case CTL_3D_FEATURE_LOW_LATENCY: 120 | return "Low Latency"; 121 | default: 122 | return "No Name"; 123 | } 124 | } 125 | 126 | /*************************************************************** 127 | * @brief 128 | * Helper function/macros 129 | * @param 130 | * @return char* 131 | ***************************************************************/ 132 | inline char *GetProfileTypeName(ctl_3d_tier_type_flags_t Flag) 133 | { 134 | if ((CTL_3D_TIER_TYPE_FLAG_COMPATIBILITY & Flag) && (CTL_3D_TIER_TYPE_FLAG_PERFORMANCE & Flag)) 135 | return "Compatibility and Performance"; 136 | else if (CTL_3D_TIER_TYPE_FLAG_COMPATIBILITY & Flag) 137 | return "Compatibility"; 138 | else if (CTL_3D_TIER_TYPE_FLAG_PERFORMANCE & Flag) 139 | return "Performance"; 140 | 141 | return "Unknown tier type"; 142 | } 143 | 144 | /*************************************************************** 145 | * @brief 146 | * Helper function/macros 147 | * @param 148 | * @return char* 149 | ***************************************************************/ 150 | inline char *GetProfileTierName(ctl_3d_tier_profile_flags_t Flags, char *pTierName, rsize_t NameLength) 151 | { 152 | strcpy_s(pTierName, NameLength, ""); 153 | 154 | if (0 == Flags) 155 | { 156 | strcat_s(pTierName, NameLength, "None"); 157 | } 158 | else 159 | { 160 | if (Flags & CTL_3D_TIER_PROFILE_FLAG_TIER_1) 161 | strcat_s(pTierName, NameLength, "Tier1, "); 162 | if (Flags & CTL_3D_TIER_PROFILE_FLAG_TIER_2) 163 | strcat_s(pTierName, NameLength, "Tier2, "); 164 | if (Flags & CTL_3D_TIER_PROFILE_FLAG_TIER_RECOMMENDED) 165 | strcat_s(pTierName, NameLength, "Recommended Tier"); 166 | } 167 | 168 | return pTierName; 169 | } 170 | 171 | /*************************************************************** 172 | * @brief Method to print 3d feature support across UMD in a generic way 173 | * 174 | * place_holder_for_Detailed_desc 175 | * @param 176 | * @return 177 | ***************************************************************/ 178 | inline void Print3DFeatureSupport(ctl_3d_feature_details_t *pFeatureDetails) 179 | { 180 | ctl_3d_feature_misc_flags_t FeatureSupport; 181 | FeatureSupport = pFeatureDetails->FeatureMiscSupport; 182 | if (CTL_3D_FEATURE_MISC_FLAG_DX11 & FeatureSupport) 183 | { 184 | printf("[INFO] pFeatureDetails->FeatureMiscSupport = CTL_3D_FEATURE_MISC_FLAG_DX11\n"); 185 | } 186 | if (CTL_3D_FEATURE_MISC_FLAG_DX12 & FeatureSupport) 187 | { 188 | printf("[INFO] pFeatureDetails->FeatureMiscSupport = CTL_3D_FEATURE_MISC_FLAG_DX12\n"); 189 | } 190 | if (CTL_3D_FEATURE_MISC_FLAG_VULKAN & FeatureSupport) 191 | { 192 | printf("[INFO] pFeatureDetails->FeatureMiscSupport = CTL_3D_FEATURE_MISC_FLAG_VULKAN\n"); 193 | } 194 | if (CTL_3D_FEATURE_MISC_FLAG_LIVE_CHANGE & FeatureSupport) 195 | { 196 | printf("[INFO] pFeatureDetails->FeatureMiscSupport = CTL_3D_FEATURE_MISC_FLAG_LIVE_CHANGE\n"); 197 | } 198 | return; 199 | } 200 | 201 | /*************************************************************** 202 | * @brief Method to Print Endurance Gaming Control 203 | * 204 | * @param Control 205 | * @return 206 | ***************************************************************/ 207 | inline void PrintEnduranceGamingControl(uint32_t Control) 208 | { 209 | switch (Control) 210 | { 211 | case CTL_3D_ENDURANCE_GAMING_CONTROL_TURN_OFF: 212 | printf("[INFO] pEGCaps->EGControlCaps.SupportedTypes = CTL_3D_ENDURANCE_GAMING_CONTROL_TURN_OFF\n"); 213 | 214 | break; 215 | 216 | case CTL_3D_ENDURANCE_GAMING_CONTROL_TURN_ON: 217 | printf("[INFO] pEGCaps->EGControlCaps.SupportedTypes = CTL_3D_ENDURANCE_GAMING_CONTROL_TURN_ON\n"); 218 | 219 | break; 220 | 221 | case CTL_3D_ENDURANCE_GAMING_CONTROL_AUTO: 222 | printf("[INFO] pEGCaps->EGControlCaps.SupportedTypes = CTL_3D_ENDURANCE_GAMING_CONTROL_AUTO\n"); 223 | 224 | break; 225 | 226 | default: 227 | return; 228 | } 229 | } 230 | 231 | /*************************************************************** 232 | * @brief Method to Print Endurance Gaming Mode 233 | * 234 | * @param Control 235 | * @return 236 | ***************************************************************/ 237 | inline void PrintEnduranceGamingMode(uint32_t Mode) 238 | { 239 | switch (Mode) 240 | { 241 | case CTL_3D_ENDURANCE_GAMING_MODE_BETTER_PERFORMANCE: 242 | printf("[INFO] pEGCaps->EGModeCaps.SupportedTypes = CTL_3D_ENDURANCE_GAMING_MODE_BETTER_PERFORMANCE\n"); 243 | 244 | break; 245 | 246 | case CTL_3D_ENDURANCE_GAMING_MODE_BALANCED: 247 | printf("[INFO] pEGCaps->EGModeCaps.SupportedTypes = CTL_3D_ENDURANCE_GAMING_MODE_BALANCED\n"); 248 | 249 | break; 250 | 251 | case CTL_3D_ENDURANCE_GAMING_MODE_MAXIMUM_BATTERY: 252 | printf("[INFO] pEGCaps->EGModeCaps.SupportedTypes = CTL_3D_ENDURANCE_GAMING_MODE_MAXIMUM_BATTERY\n"); 253 | 254 | break; 255 | 256 | default: 257 | return; 258 | } 259 | } 260 | 261 | /*************************************************************** 262 | * @brief Method to print 3d feature setting type 263 | * 264 | * @param Setting 265 | * @param SettingType 266 | * @return 267 | ***************************************************************/ 268 | inline void Print3DFeatureSupportedSettingType(uint32_t Setting, feature_control_type ControlType) 269 | { 270 | switch (ControlType) 271 | { 272 | case ENDURANCE_GAMING_CONTROLS: 273 | 274 | PrintEnduranceGamingControl(Setting); 275 | 276 | break; 277 | 278 | case ENDURANCE_GAMING_MODES: 279 | 280 | PrintEnduranceGamingMode(Setting); 281 | 282 | break; 283 | 284 | default: 285 | return; 286 | } 287 | } 288 | 289 | /*************************************************************** 290 | * @brief Method to print 3d feature supported settings in a generic way 291 | * 292 | * @param SupportMask 293 | * @param Settings 294 | * @param SettingType 295 | * @return 296 | ***************************************************************/ 297 | inline void Print3DFeatureSupportedSettings(uint64_t SupportMask, std::vector Settings, feature_control_type ControlType) 298 | { 299 | for (uint8_t i = 0; i < Settings.size(); i++) 300 | { 301 | uint32_t Setting = CONTROL_BIT(Settings[i]); 302 | 303 | if (Setting & SupportMask) 304 | { 305 | Print3DFeatureSupportedSettingType(Settings[i], ControlType); 306 | } 307 | } 308 | } 309 | 310 | /*************************************************************** 311 | * @brief Method to print 3d feature details struct in a generic way 312 | * 313 | * place_holder_for_Detailed_desc 314 | * @param 315 | * @return 316 | ***************************************************************/ 317 | inline void Print3DFeatureDetail(ctl_3d_feature_details_t *pFeatureDetails) 318 | { 319 | if (pFeatureDetails) 320 | { 321 | printf("[INFO] 3D Feature supported: %s (%d)\n", Get3DFeatureName(pFeatureDetails->FeatureType), pFeatureDetails->FeatureType); 322 | printf("[INFO] Feature conflict mask flag: 0x%llX\n", pFeatureDetails->ConflictingFeatures); 323 | printf("[INFO] Supported per application: %d\n", pFeatureDetails->PerAppSupport); 324 | printf("[INFO] Supports live change: %s\n", (pFeatureDetails->FeatureMiscSupport & CTL_3D_FEATURE_MISC_FLAG_LIVE_CHANGE) ? "Yes" : "No"); 325 | Print3DFeatureSupport(pFeatureDetails); 326 | 327 | switch (pFeatureDetails->ValueType) 328 | { 329 | case CTL_PROPERTY_VALUE_TYPE_ENUM: 330 | { 331 | printf("[INFO] Default value: %d\n", pFeatureDetails->Value.EnumType.DefaultType); 332 | if (CTL_3D_FEATURE_GAMING_FLIP_MODES == pFeatureDetails->FeatureType) 333 | { 334 | ctl_gaming_flip_mode_flags_t GamingflipCaps = (ctl_gaming_flip_mode_flags_t)pFeatureDetails->Value.EnumType.SupportedTypes; 335 | 336 | if (CTL_GAMING_FLIP_MODE_FLAG_APPLICATION_DEFAULT & GamingflipCaps) 337 | { 338 | printf("[INFO] pFeatureDetails->Value.EnumType.SupportedTypes = CTL_GAMING_FLIP_MODE_FLAG_APPLICATION_DEFAULT\n"); 339 | } 340 | if (CTL_GAMING_FLIP_MODE_FLAG_VSYNC_OFF & GamingflipCaps) 341 | { 342 | printf("[INFO] pFeatureDetails->Value.EnumType.SupportedTypes = CTL_GAMING_FLIP_MODE_FLAG_VSYNC_OFF\n"); 343 | } 344 | if (CTL_GAMING_FLIP_MODE_FLAG_VSYNC_ON & GamingflipCaps) 345 | { 346 | printf("[INFO] pFeatureDetails->Value.EnumType.SupportedTypes = CTL_GAMING_FLIP_MODE_FLAG_VSYNC_ON\n"); 347 | } 348 | if (CTL_GAMING_FLIP_MODE_FLAG_SMOOTH_SYNC & GamingflipCaps) 349 | { 350 | printf("[INFO] pFeatureDetails->Value.EnumType.SupportedTypes = CTL_GAMING_FLIP_MODE_FLAG_SMOOTH_SYNC\n"); 351 | } 352 | if (CTL_GAMING_FLIP_MODE_FLAG_SPEED_FRAME & GamingflipCaps) 353 | { 354 | printf("[INFO] pFeatureDetails->Value.EnumType.SupportedTypes = CTL_GAMING_FLIP_MODE_FLAG_SPEED_FRAME\n"); 355 | } 356 | if (CTL_GAMING_FLIP_MODE_FLAG_CAPPED_FPS & GamingflipCaps) 357 | { 358 | printf("[INFO] pFeatureDetails->Value.EnumType.SupportedTypes = CTL_GAMING_FLIP_MODE_FLAG_CAPPED_FPS\n"); 359 | } 360 | } 361 | // printf(" Enabled value: %d\n", pFeatureDetails->Value.EnumType.EnableType); 362 | } 363 | break; 364 | case CTL_PROPERTY_VALUE_TYPE_BOOL: 365 | { 366 | printf("[INFO] Default value: %d\n", pFeatureDetails->Value.BoolType.DefaultState); 367 | // printf(" Enabled value: %d\n", pFeatureDetails->Value.BoolType.Enable); 368 | } 369 | break; 370 | case CTL_PROPERTY_VALUE_TYPE_FLOAT: 371 | { 372 | printf("[INFO] Min possible value: %f\n", pFeatureDetails->Value.FloatType.RangeInfo.min_possible_value); 373 | printf("[INFO] Max possible value: %f\n", pFeatureDetails->Value.FloatType.RangeInfo.max_possible_value); 374 | printf("[INFO] Step size: %f\n", pFeatureDetails->Value.FloatType.RangeInfo.step_size); 375 | printf("[INFO] Default value: %f\n", pFeatureDetails->Value.FloatType.RangeInfo.default_value); 376 | // printf(" Current value: %f\n", pFeatureDetails->Value.FloatType.Value); 377 | } 378 | break; 379 | case CTL_PROPERTY_VALUE_TYPE_INT32: 380 | { 381 | printf("[INFO] Min possible value: %d\n", pFeatureDetails->Value.IntType.RangeInfo.min_possible_value); 382 | printf("[INFO] Max possible value: %d\n", pFeatureDetails->Value.IntType.RangeInfo.max_possible_value); 383 | printf("[INFO] Step size: %d\n", pFeatureDetails->Value.IntType.RangeInfo.step_size); 384 | printf("[INFO] Default value: %d\n", pFeatureDetails->Value.IntType.RangeInfo.default_value); 385 | // printf(" Current value: %d\n", pFeatureDetails->Value.IntType.Value); 386 | } 387 | break; 388 | case CTL_PROPERTY_VALUE_TYPE_CUSTOM: 389 | { 390 | if (pFeatureDetails->pCustomValue == NULL) 391 | { 392 | printf("[WARN] Empty custom data\n"); 393 | break; 394 | } 395 | 396 | switch (pFeatureDetails->FeatureType) 397 | { 398 | case CTL_3D_FEATURE_ADAPTIVE_SYNC_PLUS: 399 | { 400 | ctl_adaptivesync_caps_t *pASCaps = (ctl_adaptivesync_caps_t *)pFeatureDetails->pCustomValue; 401 | printf("[INFO] AdaptiveBalanceSupported = %d\n", pASCaps->AdaptiveBalanceSupported); 402 | printf("[INFO] AdaptiveBalanceStrengthCaps.DefaultEnable = %d\n", pASCaps->AdaptiveBalanceStrengthCaps.DefaultEnable); 403 | printf("[INFO] AdaptiveBalanceStrengthCaps.RangeInfo.default_value = %f\n", pASCaps->AdaptiveBalanceStrengthCaps.RangeInfo.default_value); 404 | printf("[INFO] AdaptiveBalanceStrengthCaps.RangeInfo.min_possible_value = %f\n", pASCaps->AdaptiveBalanceStrengthCaps.RangeInfo.min_possible_value); 405 | printf("[INFO] AdaptiveBalanceStrengthCaps.RangeInfo.max_possible_value = %f\n", pASCaps->AdaptiveBalanceStrengthCaps.RangeInfo.max_possible_value); 406 | printf("[INFO] AdaptiveBalanceStrengthCaps.RangeInfo.step_size = %f\n", pASCaps->AdaptiveBalanceStrengthCaps.RangeInfo.step_size); 407 | } 408 | break; 409 | 410 | case CTL_3D_FEATURE_ENDURANCE_GAMING: 411 | { 412 | ctl_endurance_gaming_caps_t *pEGCaps = (ctl_endurance_gaming_caps_t *)pFeatureDetails->pCustomValue; 413 | std::vector EGControls = { CTL_3D_ENDURANCE_GAMING_CONTROL_TURN_OFF, CTL_3D_ENDURANCE_GAMING_CONTROL_TURN_ON, CTL_3D_ENDURANCE_GAMING_CONTROL_AUTO }; 414 | std::vector EGModes = { CTL_3D_ENDURANCE_GAMING_MODE_BETTER_PERFORMANCE, CTL_3D_ENDURANCE_GAMING_MODE_BALANCED, CTL_3D_ENDURANCE_GAMING_MODE_MAXIMUM_BATTERY }; 415 | printf("[INFO] pEGCaps->EGControlCaps.DefaultType = %d\n", pEGCaps->EGControlCaps.DefaultType); 416 | printf("[INFO] pEGCaps->EGModeCaps.DefaultType = %d\n", pEGCaps->EGModeCaps.DefaultType); 417 | 418 | Print3DFeatureSupportedSettings(pEGCaps->EGControlCaps.SupportedTypes, move(EGControls), ENDURANCE_GAMING_CONTROLS); 419 | Print3DFeatureSupportedSettings(pEGCaps->EGModeCaps.SupportedTypes, move(EGModes), ENDURANCE_GAMING_MODES); 420 | } 421 | break; 422 | 423 | case CTL_3D_FEATURE_APP_PROFILES: 424 | { 425 | ctl_3d_app_profiles_caps_t *pCaps = (ctl_3d_app_profiles_caps_t *)pFeatureDetails->pCustomValue; 426 | printf("[INFO] pCaps->SupportedTierTypes = %s\n", GetProfileTypeName(pCaps->SupportedTierTypes)); 427 | } 428 | break; 429 | 430 | default: 431 | { 432 | printf("[ERROR] Unknown feature type with custom capabilities! ERROR!!\n"); 433 | } 434 | break; 435 | } 436 | } 437 | break; 438 | 439 | default: 440 | return; 441 | } 442 | } 443 | } 444 | -------------------------------------------------------------------------------- /third-party-software.txt: -------------------------------------------------------------------------------- 1 | None 2 | --------------------------------------------------------------------------------