AMD ADL Windows
This commit is contained in:
parent
687424e732
commit
479d51df87
8 changed files with 6048 additions and 1 deletions
34
OpenRGB.cpp
34
OpenRGB.cpp
|
|
@ -18,6 +18,7 @@
|
|||
#include "i2c_smbus_i801.h"
|
||||
#include "i2c_smbus_nct6775.h"
|
||||
#include "i2c_smbus_nvapi.h"
|
||||
#include "i2c_smbus_amdadl.h"
|
||||
#include "super_io.h"
|
||||
#include "wmi.h"
|
||||
#else /* WIN32 */
|
||||
|
|
@ -120,6 +121,36 @@ void DetectNvAPII2CBusses()
|
|||
}
|
||||
} /* DetectNvAPII2CBusses() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAMDADLI2CBusses (Windows) *
|
||||
* *
|
||||
* Detects available AMD ADL I2C adapters and enumerates *
|
||||
* i2c_smbus_interface objects for them. Only enumerates Bus Nr 1 *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectADLI2C()
|
||||
{
|
||||
int adl_status;
|
||||
int gpu_count = 0;
|
||||
ADL_CONTEXT_HANDLE gpu_handle;
|
||||
|
||||
i2c_smbus_amdadl * adl_bus = new i2c_smbus_amdadl(gpu_handle);
|
||||
|
||||
adl_status = adl_bus->ADL_Initialize();
|
||||
|
||||
if(0 != adl_status)
|
||||
{
|
||||
printf_s("ADL Status %d \n", adl_status);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(adl_bus->device_name, "AMD ADL I2C on GPU %d", gpu_count);
|
||||
busses.push_back(adl_bus);
|
||||
}
|
||||
} /* DetectAMDADLI2CBusses() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectI2CBusses (Windows) *
|
||||
|
|
@ -205,6 +236,9 @@ void DetectI2CBusses()
|
|||
// Detect NVidia NvAPI I2C adapters
|
||||
DetectNvAPII2CBusses();
|
||||
|
||||
// Detect AMD ADL I2C adadpters
|
||||
DetectADLI2C();
|
||||
|
||||
} /* DetectI2CBusses() */
|
||||
|
||||
#else /* WIN32 */
|
||||
|
|
|
|||
|
|
@ -326,6 +326,7 @@ FORMS += \
|
|||
# Windows-specific Configuration #
|
||||
#-----------------------------------------------------------------------#
|
||||
win32:INCLUDEPATH += \
|
||||
dependencies/display-library/include \
|
||||
dependencies/hidapi \
|
||||
dependencies/inpout32_1501/Win32/ \
|
||||
dependencies/libusb-1.0.22/include \
|
||||
|
|
@ -336,6 +337,7 @@ win32:INCLUDEPATH += \
|
|||
win32:SOURCES += \
|
||||
dependencies/hidapi/hidapi.c \
|
||||
dependencies/NVFC/nvapi.cpp \
|
||||
i2c_smbus/i2c_smbus_amdadl.cpp \
|
||||
i2c_smbus/i2c_smbus_i801.cpp \
|
||||
i2c_smbus/i2c_smbus_nct6775.cpp \
|
||||
i2c_smbus/i2c_smbus_nvapi.cpp \
|
||||
|
|
@ -346,6 +348,9 @@ win32:SOURCES += \
|
|||
RGBController/RGBController_OpenRazerWindows.cpp \
|
||||
|
||||
win32:HEADERS += \
|
||||
dependencies/display-library/include/adl_defines.h \
|
||||
dependencies/display-library/include/adl_sdk.h \
|
||||
dependencies/display-library/include/adl_structures.h \
|
||||
dependencies/inpout32_1501/Win32/inpout32.h \
|
||||
dependencies/NVFC/nvapi.h \
|
||||
i2c_smbus/i2c_smbus_i801.h \
|
||||
|
|
|
|||
|
|
@ -109,7 +109,9 @@ As of now, only Gigabyte RGB Fusion 2.0 boards have been reported to have issues
|
|||
* OpenRazer-Win32: https://github.com/CalcProgrammer1/openrazer-win32
|
||||
|
||||
* Qt-Plus (ColorWheel): https://github.com/liuyanghejerry/Qt-Plus
|
||||
|
||||
|
||||
* AMD ADL Libraries: https://github.com/GPUOpen-LibrariesAndSDKs/display-library
|
||||
|
||||
## Projects Researched
|
||||
|
||||
While no code from these projects directly made its way into OpenRGB, these projects have been invaluable resources for protocol information.
|
||||
|
|
@ -137,3 +139,5 @@ While no code from these projects directly made its way into OpenRGB, these proj
|
|||
* msi-keyboard: https://github.com/bparker06/msi-keyboard
|
||||
|
||||
* rivalcfg: https://github.com/flozz/rivalcfg
|
||||
|
||||
* VRMTool: https://github.com/rbrune/VRMtool
|
||||
|
|
|
|||
2342
dependencies/display-library/include/adl_defines.h
vendored
Normal file
2342
dependencies/display-library/include/adl_defines.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
44
dependencies/display-library/include/adl_sdk.h
vendored
Normal file
44
dependencies/display-library/include/adl_sdk.h
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// MIT LICENSE:
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
/// \file adl_sdk.h
|
||||
/// \brief Contains the definition of the Memory Allocation Callback.\n <b>Included in ADL SDK</b>
|
||||
///
|
||||
/// \n\n
|
||||
/// This file contains the definition of the Memory Allocation Callback.\n
|
||||
/// It also includes definitions of the respective structures and constants.\n
|
||||
/// <b> This is the only header file to be included in a C/C++ project using ADL </b>
|
||||
|
||||
#ifndef ADL_SDK_H_
|
||||
#define ADL_SDK_H_
|
||||
|
||||
#include "adl_structures.h"
|
||||
|
||||
#if defined (LINUX)
|
||||
#define __stdcall
|
||||
#endif /* (LINUX) */
|
||||
|
||||
/// Memory Allocation Call back
|
||||
typedef void* ( __stdcall *ADL_MAIN_MALLOC_CALLBACK )( int );
|
||||
|
||||
|
||||
#endif /* ADL_SDK_H_ */
|
||||
3440
dependencies/display-library/include/adl_structures.h
vendored
Normal file
3440
dependencies/display-library/include/adl_structures.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
144
i2c_smbus/i2c_smbus_amdadl.cpp
Normal file
144
i2c_smbus/i2c_smbus_amdadl.cpp
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
/*-----------------------------------------*\
|
||||
| i2c_smbus_amdadl.cpp |
|
||||
| |
|
||||
| Definitions and types for AMD ADL I2C |
|
||||
| functions |
|
||||
| |
|
||||
| Niels Westphal (crashniels) 05/30/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "i2c_smbus_amdadl.h"
|
||||
|
||||
typedef int ( *ADL2_MAIN_CONTROL_CREATE )(ADL_MAIN_MALLOC_CALLBACK, int, ADL_CONTEXT_HANDLE*);
|
||||
typedef int ( *ADL2_MAIN_CONTROL_DESTROY )(ADL_CONTEXT_HANDLE);
|
||||
typedef int ( *ADL2_ADAPTER_NUMBEROFADAPTERS_GET ) ( ADL_CONTEXT_HANDLE , int* );
|
||||
typedef int ( *ADL2_ADAPTER_PRIMARY_GET) (ADL_CONTEXT_HANDLE, int* lpPrimaryAdapterIndex);
|
||||
typedef int ( *ADL2_DISPLAY_WRITEANDREADI2C) (ADL_CONTEXT_HANDLE, int iAdapterIndex, ADLI2C* plI2C);
|
||||
|
||||
ADL2_MAIN_CONTROL_CREATE ADL2_Main_Control_Create;
|
||||
ADL2_MAIN_CONTROL_DESTROY ADL2_Main_Control_Destroy;
|
||||
ADL2_ADAPTER_NUMBEROFADAPTERS_GET ADL2_Adapter_NumberOfAdapters_Get;
|
||||
ADL2_ADAPTER_PRIMARY_GET ADL2_Adapter_Primary_Get;
|
||||
ADL2_DISPLAY_WRITEANDREADI2C ADL2_Display_WriteAndReadI2C;
|
||||
|
||||
int i2c_smbus_amdadl::LoadLibraries()
|
||||
{
|
||||
HINSTANCE hDLL;
|
||||
hDLL = LoadLibrary("atiadlxx.dll");
|
||||
if (hDLL == NULL)
|
||||
{
|
||||
// A 32 bit calling application on 64 bit OS will fail to LoadLIbrary.
|
||||
// Try to load the 32 bit library (atiadlxy.dll) instead
|
||||
hDLL = LoadLibrary("atiadlxy.dll");
|
||||
return ADL_ERR;
|
||||
}
|
||||
else
|
||||
{
|
||||
ADL2_Main_Control_Create = (ADL2_MAIN_CONTROL_CREATE)GetProcAddress(hDLL, "ADL2_Main_Control_Create");
|
||||
ADL2_Main_Control_Destroy = (ADL2_MAIN_CONTROL_DESTROY)GetProcAddress(hDLL, "ADL2_Main_Control_Destroy");
|
||||
ADL2_Adapter_NumberOfAdapters_Get = (ADL2_ADAPTER_NUMBEROFADAPTERS_GET)GetProcAddress(hDLL, "ADL2_Adapter_NumberOfAdapters_Get");
|
||||
ADL2_Adapter_Primary_Get = (ADL2_ADAPTER_PRIMARY_GET)GetProcAddress(hDLL, "ADL2_Adapter_Primary_Get");
|
||||
ADL2_Display_WriteAndReadI2C = (ADL2_DISPLAY_WRITEANDREADI2C)GetProcAddress(hDLL, "ADL2_Display_WriteAndReadI2C");
|
||||
return ADL_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Memory allocation function
|
||||
void* __stdcall ADL_Main_Memory_Alloc ( int iSize )
|
||||
{
|
||||
void* lpBuffer = malloc ( iSize );
|
||||
return lpBuffer;
|
||||
}
|
||||
|
||||
// Optional Memory de-allocation function
|
||||
void __stdcall ADL_Main_Memory_Free ( void* lpBuffer )
|
||||
{
|
||||
if ( NULL != lpBuffer )
|
||||
{
|
||||
free ( lpBuffer );
|
||||
lpBuffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
i2c_smbus_amdadl::i2c_smbus_amdadl(ADL_CONTEXT_HANDLE context)
|
||||
{
|
||||
this->context = context;
|
||||
};
|
||||
|
||||
int i2c_smbus_amdadl::ADL_Initialize()
|
||||
{
|
||||
return LoadLibraries();
|
||||
//ADL2_Main_Control_Create(::ADL_Main_Memory_Alloc, 1, &_context);
|
||||
};
|
||||
|
||||
s32 i2c_smbus_amdadl::i2c_smbus_xfer(u8 addr, char read_write, u8 command, int size, i2c_smbus_data* data)
|
||||
{
|
||||
int PrimaryDisplay;
|
||||
int ret;
|
||||
|
||||
ADLI2C* pI2C;
|
||||
ADLI2C I2Cstore;
|
||||
pI2C = &I2Cstore;
|
||||
|
||||
pI2C->iSize = sizeof(ADLI2C);
|
||||
pI2C->iSpeed = 100;
|
||||
pI2C->iLine = 1; //location of the Aura chip
|
||||
pI2C->iAddress = addr << 1;
|
||||
pI2C->iOffset = command;
|
||||
pI2C->pcData = (char*)data;
|
||||
|
||||
|
||||
if (ADL_OK != ADL2_Main_Control_Create(::ADL_Main_Memory_Alloc, 1, &context))
|
||||
{
|
||||
printf("Cannot get handle!\n");
|
||||
return ADL_ERR;
|
||||
}
|
||||
|
||||
if (ADL_OK != ADL2_Adapter_Primary_Get(context, &PrimaryDisplay))
|
||||
{
|
||||
printf("Cannot get Display!\n");
|
||||
return ADL_ERR;
|
||||
}
|
||||
|
||||
switch (size)
|
||||
{
|
||||
case I2C_SMBUS_QUICK:
|
||||
//garbo data
|
||||
//pI2C->iDataSize = 0;
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case I2C_SMBUS_BYTE:
|
||||
//pI2C->iDataSize = 1;
|
||||
//break;
|
||||
|
||||
case I2C_SMBUS_BYTE_DATA:
|
||||
pI2C->iDataSize = 1;
|
||||
break;
|
||||
|
||||
case I2C_SMBUS_WORD_DATA:
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case I2C_SMBUS_BLOCK_DATA:
|
||||
return -1;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (read_write == I2C_SMBUS_READ)
|
||||
{
|
||||
pI2C->iAction = ADL_DL_I2C_ACTIONREAD;
|
||||
ret = ADL2_Display_WriteAndReadI2C(context, PrimaryDisplay, pI2C);
|
||||
}
|
||||
else if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
pI2C->iAction = ADL_DL_I2C_ACTIONWRITE;
|
||||
ret = ADL2_Display_WriteAndReadI2C(context, PrimaryDisplay, pI2C);
|
||||
}
|
||||
|
||||
return (ret);
|
||||
};
|
||||
|
||||
34
i2c_smbus/i2c_smbus_amdadl.h
Normal file
34
i2c_smbus/i2c_smbus_amdadl.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*-----------------------------------------*\
|
||||
| i2c_smbus_amdadl.h |
|
||||
| |
|
||||
| Definitions and types for AMD ADL I2C |
|
||||
| functions |
|
||||
| |
|
||||
| Niels Westphal (crashniels) 05/30/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "i2c_smbus.h"
|
||||
#include "adl_sdk.h"
|
||||
#include "adl_defines.h"
|
||||
#include "adl_structures.h"
|
||||
#include "windows.h"
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
|
||||
#pragma once
|
||||
|
||||
class i2c_smbus_amdadl : public i2c_smbus_interface
|
||||
{
|
||||
public:
|
||||
i2c_smbus_amdadl(ADL_CONTEXT_HANDLE context);
|
||||
|
||||
int LoadLibraries();
|
||||
//void* __stdcall ADL_Main_Memory_Alloc ( int iSize );
|
||||
//void __stdcall ADL_Main_Memory_Free ( void* lpBuffer );
|
||||
int ADL_Initialize();
|
||||
|
||||
private:
|
||||
s32 i2c_smbus_xfer(u8 addr, char read_write, u8 command, int size, i2c_smbus_data* data);
|
||||
ADL_CONTEXT_HANDLE context = NULL;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue