Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 92 additions & 6 deletions Samples/DisplaySettings/DisplaySettings_Sample_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,79 @@ ctl_result_t TestToGetSetSourceTonemapping(ctl_display_output_handle_t hDisplayO
return Result;
}

/***************************************************************
* @brief
* Sample test for HDR10+
* @param hDisplayOutput
* @return ctl_result_t
***************************************************************/
ctl_result_t TestHDR10Plus(ctl_display_output_handle_t hDisplayOutput)
{
ctl_result_t Result = CTL_RESULT_SUCCESS;
ctl_display_settings_t AppliedDisplaySettings = { 0 };
ctl_display_settings_t NewDisplaySettings = { 0 };
bool IsControllable, IsSupported = FALSE;

// GET CALL
AppliedDisplaySettings.Version = API_VERSION;
AppliedDisplaySettings.Size = sizeof(ctl_display_settings_t);
AppliedDisplaySettings.Set = FALSE;
AppliedDisplaySettings.ValidFlags = CTL_DISPLAY_SETTING_FLAG_LOW_LATENCY | CTL_DISPLAY_SETTING_FLAG_SOURCE_TM;

Result = ctlGetSetDisplaySettings(hDisplayOutput, &AppliedDisplaySettings);
LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (LowLatency GET CALL)");

// LowLatency
IsControllable = (CTL_DISPLAY_SETTING_FLAG_LOW_LATENCY & AppliedDisplaySettings.ControllableFlags) ? TRUE : FALSE;
IsSupported = (CTL_DISPLAY_SETTING_FLAG_LOW_LATENCY & AppliedDisplaySettings.SupportedFlags) ? TRUE : FALSE;

if ((FALSE == IsControllable) || (FALSE == IsSupported))
{
APP_LOG_WARN("Get/Set LowLatency is not supported/controllable = %d/%d", IsSupported, IsControllable);
Result = CTL_RESULT_ERROR_UNSUPPORTED_FEATURE;
goto Exit;
}
APP_LOG_INFO(" Current Applied LowLatency is %d ", AppliedDisplaySettings.LowLatency);

// SourceTM
IsControllable = (CTL_DISPLAY_SETTING_FLAG_SOURCE_TM & AppliedDisplaySettings.ControllableFlags) ? TRUE : FALSE;
IsSupported = (CTL_DISPLAY_SETTING_FLAG_SOURCE_TM & AppliedDisplaySettings.SupportedFlags) ? TRUE : FALSE;

if ((FALSE == IsControllable) || (FALSE == IsSupported))
{
APP_LOG_WARN("Get/Set SourceTM is not supported/controllable = %d/%d. Ensure HDR mode is enabled in OS settings.", IsSupported, IsControllable);
Result = CTL_RESULT_ERROR_UNSUPPORTED_FEATURE;
goto Exit;
}
APP_LOG_INFO(" Current Applied SourceTM is %d ", AppliedDisplaySettings.SourceTM);

// CALL TO ENABLE HDR10+ LOW_LATENCY
NewDisplaySettings.Version = API_VERSION;
NewDisplaySettings.Size = sizeof(ctl_display_settings_t);
NewDisplaySettings.Set = TRUE;
NewDisplaySettings.ValidFlags = CTL_DISPLAY_SETTING_FLAG_LOW_LATENCY | CTL_DISPLAY_SETTING_FLAG_SOURCE_TM;
NewDisplaySettings.LowLatency = CTL_DISPLAY_SETTING_LOW_LATENCY_ENABLED;
NewDisplaySettings.SourceTM = CTL_DISPLAY_SETTING_SOURCETM_ENABLED;

Result = ctlGetSetDisplaySettings(hDisplayOutput, &NewDisplaySettings);
LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (LowLatency_SourceTM SET CALL)");

// GET CALL
AppliedDisplaySettings = { 0 };
AppliedDisplaySettings.Version = API_VERSION;
AppliedDisplaySettings.Size = sizeof(ctl_display_settings_t);
AppliedDisplaySettings.Set = FALSE;
AppliedDisplaySettings.ValidFlags = CTL_DISPLAY_SETTING_FLAG_LOW_LATENCY | CTL_DISPLAY_SETTING_FLAG_SOURCE_TM;

Result = ctlGetSetDisplaySettings(hDisplayOutput, &AppliedDisplaySettings);
LOG_AND_EXIT_ON_ERROR(Result, "ctlGetSetDisplaySettings (LowLatency_SourceTM GET CALL)");
APP_LOG_INFO(" Current LowLatency is %d ", AppliedDisplaySettings.LowLatency);
APP_LOG_INFO(" Current SourceTM is %d ", AppliedDisplaySettings.SourceTM);

Exit:
return Result;
}

/***************************************************************
* @brief
* Sample test for Get/Set Audio settings
Expand Down Expand Up @@ -465,13 +538,26 @@ ctl_result_t EnumerateDisplayHandles(ctl_display_output_handle_t *hDisplayOutput
Result = TestToGetSetContentType(hDisplayOutput[DisplayIndex]);
STORE_AND_RESET_ERROR(Result);

// Get/Set HDR10+ Low Latency Flag
Result = TestToGetSetLowLatency(hDisplayOutput[DisplayIndex]);
STORE_AND_RESET_ERROR(Result);
if (DisplayProperties.FeatureSupportedFlags & CTL_STD_DISPLAY_FEATURE_FLAG_HDR10_PLUS_CERTIFIED)
{
APP_LOG_INFO("HDR10+ Certified Display is detected");

// Get/Set HDR10+ Source Tonemapping Flag
Result = TestToGetSetSourceTonemapping(hDisplayOutput[DisplayIndex]);
STORE_AND_RESET_ERROR(Result);
// Get/Set HDR10+ Low Latency & SourceTM Flag
Result = TestHDR10Plus(hDisplayOutput[DisplayIndex]);
STORE_AND_RESET_ERROR(Result);
}
else
{
APP_LOG_INFO("HDR10+ Certified Display not detected");

// Get/Set HDR10+ Low Latency Flag
Result = TestToGetSetLowLatency(hDisplayOutput[DisplayIndex]);
STORE_AND_RESET_ERROR(Result);

// Get/Set HDR10+ Source Tonemapping Flag
Result = TestToGetSetSourceTonemapping(hDisplayOutput[DisplayIndex]);
STORE_AND_RESET_ERROR(Result);
}

// Get/Set Audio Endpoint
Result = TestToGetSetAudioEndpoint(hDisplayOutput[DisplayIndex]);
Expand Down
11 changes: 9 additions & 2 deletions Samples/Generic_Sample/Sample_ControlAPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,13 @@ ctl_result_t CtlGetDisplayPropertiesTest(ctl_device_adapter_handle_t hAdapter, c
std::cout << "DisplayConfigFlags is " << pStdisplayproperties->DisplayConfigFlags << "\n";
std::cout << "Is Display Active : " << Isdisplay_active << "\n";
std::cout << "Is Display Attached : " << Isdisplay_attached << "\n";

std::cout << "Supported features\n";
PrintStdDisplayFeatureFlags(pStdisplayproperties->FeatureSupportedFlags);
PrintIntelDisplayFeatureFlags(pStdisplayproperties->AdvancedFeatureSupportedFlags);
std::cout << "Enabled features\n ";
PrintStdDisplayFeatureFlags(pStdisplayproperties->FeatureEnabledFlags);
PrintIntelDisplayFeatureFlags(pStdisplayproperties->AdvancedFeatureEnabledFlags);
}
pStdisplayproperties->DisplayConfigFlags = 0;
pStdisplayproperties->Os_display_encoder_handle.WindowsDisplayEncoderID = 0;
Expand Down Expand Up @@ -926,8 +933,8 @@ ctl_result_t CtlAdapterTesting(ctl_device_adapter_handle_t *hDevices, uint32_t A

if (StDeviceAdapterProperties.pDeviceID != nullptr)
{
free(StDeviceAdapterProperties.pDeviceID);
StDeviceAdapterProperties.pDeviceID = nullptr;
free(StDeviceAdapterProperties.pDeviceID);
StDeviceAdapterProperties.pDeviceID = nullptr;
}

return Result;
Expand Down
221 changes: 221 additions & 0 deletions Samples/I2C_AUX_Samples/I2C_AUX_Sample_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,211 @@ ctl_result_t TestI2CAUXAccess(ctl_display_output_handle_t hDisplayOutput)
return Result;
}

/***************************************************************
* @brief TestI2CAccessWithDriverOverrideFlagsForMultipleReadTransactions
* Reference code to show how to use the I2C driver flags for multiple read transactions for HDMI displays
* @param hDisplayOutput
* @return ctl_result_t
***************************************************************/
ctl_result_t TestI2CAccessWithDriverOverrideFlagsForMultipleReadTransactions(ctl_display_output_handle_t hDisplayOutput)
{
#define READ_DATA_SIZE 11 // the total read data size to
#define READ_SIZE_LIMIT 2 // the read data size limit for each I2C read transaction

ctl_result_t Result = CTL_RESULT_SUCCESS;
ctl_i2c_access_args_t I2CArgs = { 0 }; // I2C Access
uint32_t ReadDataLeft = 0;
uint32_t ReadDataSent = 0;
uint32_t ReadDataSizeLimit = 0;
bool IsFirstReadTransaction = TRUE;

// I2C WRITE : 82 01 10 AC at address 6E and subaddress 51
// If we write these BYTEs ( 82 01 10 AC) to address 6E and
// subaddress 51, it should update the current brightness to the 10th
// byte at address 6E and subaddress 51. One can verify by changing
// panel brightness from panel buttons, writing to address 6E
// and subaddress 51 ( 82 01 10 AC), and then reading 10th byte at
// address 6E and subaddress 51. Here is an example of an 11 byte output:
// 6E 88 02 00 10 00 00 64 00 19 D9. The 10th byte value is the current brightness value of the
// panel. To confirm whether this value is correct or not, convert the Hex
// value to Decimal. In this example, the 10th byte is 0x19, which represents 25% panel brightness.
I2CArgs.Size = sizeof(ctl_i2c_access_args_t);
I2CArgs.OpType = CTL_OPERATION_TYPE_WRITE;
I2CArgs.Address = 0x6E; // Address used for demonstration purpose
I2CArgs.Offset = 0x51; // Offset used for demonstration purpose
I2CArgs.DataSize = 4;
I2CArgs.Data[0] = 0x82;
I2CArgs.Data[1] = 0x01;
I2CArgs.Data[2] = 0x10;
I2CArgs.Data[3] = 0xAC;

EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput, "hDisplayOutput");

APP_LOG_INFO("I2C Write Test using I2C driver override flags for multiple read transactions");

Result = ctlI2CAccess(hDisplayOutput, &I2CArgs);

if (CTL_RESULT_SUCCESS != Result)
{
APP_LOG_ERROR("ctlI2CAccess for I2C write returned failure code: 0x%X", Result);
STORE_AND_RESET_ERROR(Result);
}

// I2C READ : 82 01 10 AC at address 6E and subaddress 51
APP_LOG_INFO("I2C Read Transaction Test using I2C driver override flags for multiple read transactions");

ZeroMemory(&I2CArgs, sizeof(I2CArgs));
I2CArgs.Size = sizeof(ctl_i2c_access_args_t);
I2CArgs.OpType = CTL_OPERATION_TYPE_READ;
I2CArgs.Address = 0x6E; // Address used for demonstration purpose
I2CArgs.Offset = 0x51; // Offset used for demonstration purpose
I2CArgs.DataSize = READ_SIZE_LIMIT;

I2CArgs.Flags |= CTL_I2C_FLAG_DRIVER_OVERRIDE; // must be enabled to use the driver override I2C flags
I2CArgs.Flags |= CTL_I2C_FLAG_SPEED_BIT_BASH; // bit bash flag is required for driver override feature

ReadDataLeft = READ_DATA_SIZE;
ReadDataSizeLimit = READ_SIZE_LIMIT;
ReadDataSent = 0;
IsFirstReadTransaction = TRUE;

for (uint32_t i = 0; ReadDataLeft > 0; i++)
{
I2CArgs.Offset = ReadDataSent;

if (TRUE == IsFirstReadTransaction)
{
if (ReadDataLeft <= ReadDataSizeLimit) // single read transaction: enable start and stop
{
APP_LOG_INFO("Single Transaction");
I2CArgs.DataSize = ReadDataLeft;
I2CArgs.Flags |= CTL_I2C_FLAG_START;
I2CArgs.Flags |= CTL_I2C_FLAG_STOP;
}
else // first read transaction: enable start, disable stop
{
APP_LOG_INFO("First Transaction: %i", i + 1);
I2CArgs.DataSize = ReadDataSizeLimit;
I2CArgs.Flags |= CTL_I2C_FLAG_START;
I2CArgs.Flags &= ~CTL_I2C_FLAG_STOP;
}

IsFirstReadTransaction = FALSE;
}
else
{
if (ReadDataLeft <= ReadDataSizeLimit) // last read transaction: disable start, enable stop
{
APP_LOG_INFO("Last Transaction: %i", i + 1);
I2CArgs.DataSize = ReadDataLeft;
I2CArgs.Flags &= ~CTL_I2C_FLAG_START;
I2CArgs.Flags |= CTL_I2C_FLAG_STOP;
}
else // middle range read transaction: disable start and stop
{
APP_LOG_INFO("Middle Range Transaction: %i", i + 1);
I2CArgs.Flags &= ~CTL_I2C_FLAG_START;
I2CArgs.Flags &= ~CTL_I2C_FLAG_STOP;
}
}

memset(I2CArgs.Data, 0xFF, I2CArgs.DataSize); // Clear the data buffer before reading

Result = ctlI2CAccess(hDisplayOutput, &I2CArgs);
LOG_AND_EXIT_ON_ERROR(Result, "ctlI2CAccess for I2C Read Transaction Test using I2C driver override flags");

// Print the data
for (uint32_t j = 0; j < I2CArgs.DataSize; j++)
{
APP_LOG_INFO("Read data[%d] = : 0x%X", j, I2CArgs.Data[j]);
}

ReadDataSent += I2CArgs.DataSize;
ReadDataLeft -= I2CArgs.DataSize;
}

Exit:
return Result;
}

/***************************************************************
* @brief TestI2CAccessWithRestartDriverOverrideFlag
* Reference code to show how to use the I2C Restart driver override flag for HDMI displays
* @param hDisplayOutput
* @return ctl_result_t
***************************************************************/
ctl_result_t TestI2CAccessWithRestartDriverOverrideFlag(ctl_display_output_handle_t hDisplayOutput)
{
ctl_result_t Result = CTL_RESULT_SUCCESS;
ctl_i2c_access_args_t I2CArgs = { 0 }; // I2C Access

// I2C WRITE : 82 01 10 AC at address 6E and subaddress 51
// If we write these BYTEs ( 82 01 10 AC) to address 6E and
// subaddress 51, it should update the current brightness to the 10th
// byte at address 6E and subaddress 51. One can verify by changing
// panel brightness from panel buttons, writing to address 6E
// and subaddress 51 ( 82 01 10 AC), and then reading 10th byte at
// address 6E and subaddress 51. Here is an example of an 11 byte output:
// 6E 88 02 00 10 00 00 64 00 19 D9. The 10th byte value is the current brightness value of the
// panel. To confirm whether this value is correct or not, convert the Hex
// value to Decimal. In this example, the 10th byte is 0x19, which represents 25% panel brightness.
I2CArgs.Size = sizeof(ctl_i2c_access_args_t);
I2CArgs.OpType = CTL_OPERATION_TYPE_WRITE;
I2CArgs.Address = 0x6E; // Address used for demonstration purpose
I2CArgs.Offset = 0x51; // Offset used for demonstration purpose
I2CArgs.DataSize = 4;
I2CArgs.Data[0] = 0x82;
I2CArgs.Data[1] = 0x01;
I2CArgs.Data[2] = 0x10;
I2CArgs.Data[3] = 0xAC;

EXIT_ON_MEM_ALLOC_FAILURE(hDisplayOutput, "hDisplayOutput");

APP_LOG_INFO("I2C Write Test using I2C Restart driver override flag for read");

I2CArgs.Flags |= CTL_I2C_FLAG_DRIVER_OVERRIDE; // must be enabled to use the driver override I2C flags
I2CArgs.Flags |= CTL_I2C_FLAG_SPEED_BIT_BASH; // bit bash flag is required for driver override feature
I2CArgs.Flags |= CTL_I2C_FLAG_START; // enable start flag for the write operation

Result = ctlI2CAccess(hDisplayOutput, &I2CArgs);

if (CTL_RESULT_SUCCESS != Result)
{
APP_LOG_ERROR("ctlI2CAccess for I2C write returned failure code: 0x%X", Result);
STORE_AND_RESET_ERROR(Result);
}

// I2C READ : 82 01 10 AC at address 6E and subaddress 51
APP_LOG_INFO("I2C Read Transaction Test using I2C Restart driver override flag for read");

ZeroMemory(&I2CArgs, sizeof(I2CArgs));
I2CArgs.Size = sizeof(ctl_i2c_access_args_t);
I2CArgs.OpType = CTL_OPERATION_TYPE_READ;
I2CArgs.Address = 0x6E; // Address used for demonstration purpose
I2CArgs.Offset = 0x51; // Offset used for demonstration purpose
I2CArgs.DataSize = 11;

// Perform I2C repeated start transaction for read by enabling Restart flag
I2CArgs.Flags |= CTL_I2C_FLAG_DRIVER_OVERRIDE; // must be enabled to use the driver override I2C flags
I2CArgs.Flags |= CTL_I2C_FLAG_SPEED_BIT_BASH; // bit bash flag is required for driver override feature
I2CArgs.Flags |= CTL_I2C_FLAG_RESTART; // enable restart flag for the read operation
I2CArgs.Flags |= CTL_I2C_FLAG_STOP; // issue a stop after the read operation is completed

memset(I2CArgs.Data, 0xFF, I2CArgs.DataSize); // Clear the data buffer before reading

Result = ctlI2CAccess(hDisplayOutput, &I2CArgs);
LOG_AND_EXIT_ON_ERROR(Result, "ctlI2CAccess for I2C read with Restart flag");

// Print the data
for (uint32_t j = 0; j < I2CArgs.DataSize; j++)
{
APP_LOG_INFO("Read data[%d] = : 0x%X", j, I2CArgs.Data[j]);
}

Exit:
return Result;
}

/***************************************************************
* @brief Tests I2C Access on enumerated Pin Pairs.
* Reference code to use ctlI2CAccessOnPinPair API
Expand Down Expand Up @@ -241,6 +446,22 @@ ctl_result_t EnumerateDisplayHandles(ctl_display_output_handle_t *hDisplayOutput

Result = TestI2CAUXAccess(hDisplayOutput[DisplayIndex]);
STORE_AND_RESET_ERROR(Result);

ctl_adapter_display_encoder_properties_t stDisplayEncoderProperties = {};
stDisplayEncoderProperties.Size = sizeof(ctl_adapter_display_encoder_properties_t);

Result = ctlGetAdaperDisplayEncoderProperties(hDisplayOutput[DisplayIndex], &stDisplayEncoderProperties);
LOG_AND_EXIT_ON_ERROR(Result, "ctlGetAdaperDisplayEncoderProperties");

// Currently the driver override flags are limited to HDMI only
if (CTL_DISPLAY_OUTPUT_TYPES_HDMI == stDisplayEncoderProperties.Type)
{
Result = TestI2CAccessWithDriverOverrideFlagsForMultipleReadTransactions(hDisplayOutput[DisplayIndex]);
STORE_AND_RESET_ERROR(Result);

Result = TestI2CAccessWithRestartDriverOverrideFlag(hDisplayOutput[DisplayIndex]);
STORE_AND_RESET_ERROR(Result);
}
}

Exit:
Expand Down
2 changes: 1 addition & 1 deletion Samples/Overclocking_Sample/Sample_OverclockAPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ void OverclockTemperatureLimit(ctl_device_adapter_handle_t hDAhandle)

// Step 3: Writing New Temperature Limit by increasing it by (Step * 5.0) from min value
// Input Temperature Limit units are given in ctl_oc_properties_t::temperatureLimit::units returned from ctlOverclockGetProperties()
// Currently ctl_oc_properties_t::temperatureLimit::units for Alchemist are CTL_UNITS_TEMPERATURE_CELSIUS units, for Battlemage are CTL_UNITS_PERCENT units
// Currently ctl_oc_properties_t::temperatureLimit::units for Alchemist and BMG G31 are CTL_UNITS_TEMPERATURE_CELSIUS units, for Battlemage (excluding G31) are CTL_UNITS_PERCENT units
CurrentTemperatureLimit = OcProperties.temperatureLimit.min + (OcProperties.temperatureLimit.step * 5.0);
Status = ctlOverclockTemperatureLimitSetV2(hDAhandle, CurrentTemperatureLimit);
if (Status != ctl_result_t::CTL_RESULT_SUCCESS)
Expand Down
Loading