Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default HDMI port to fall back to when resetting #608

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions include/cectypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,7 @@ struct libcec_configuration
uint16_t iPhysicalAddress; /*!< the physical address of the CEC adapter */
cec_logical_address baseDevice; /*!< the logical address of the device to which the adapter is connected. only used when iPhysicalAddress = 0 or when the adapter doesn't support autodetection */
uint8_t iHDMIPort; /*!< the HDMI port to which the adapter is connected. only used when iPhysicalAddress = 0 or when the adapter doesn't support autodetection */
uint8_t iDefaultHDMIPort; /*!< the default HDMI port to fall back to when resetting. */
uint32_t tvVendor; /*!< override the vendor ID of the TV. leave this untouched to autodetect */
cec_logical_addresses wakeDevices; /*!< list of devices to wake when initialising libCEC or when calling PowerOnDevices() without any parameter. */
cec_logical_addresses powerOffDevices; /*!< list of devices to power off when calling StandbyDevices() without any parameter. */
Expand Down Expand Up @@ -1526,6 +1527,7 @@ struct libcec_configuration
iPhysicalAddress == other.iPhysicalAddress &&
baseDevice == other.baseDevice &&
iHDMIPort == other.iHDMIPort &&
iDefaultHDMIPort == other.iDefaultHDMIPort &&
tvVendor == other.tvVendor &&
wakeDevices == other.wakeDevices &&
powerOffDevices == other.powerOffDevices &&
Expand Down Expand Up @@ -1565,6 +1567,7 @@ struct libcec_configuration
iPhysicalAddress = CEC_PHYSICAL_ADDRESS_TV;
baseDevice = (cec_logical_address)CEC_DEFAULT_BASE_DEVICE;
iHDMIPort = CEC_DEFAULT_HDMI_PORT;
iDefaultHDMIPort = CEC_DEFAULT_HDMI_PORT;
tvVendor = (uint32_t)CEC_VENDOR_UNKNOWN;
clientVersion = LIBCEC_VERSION_CURRENT;
serverVersion = LIBCEC_VERSION_CURRENT;
Expand Down
17 changes: 17 additions & 0 deletions src/cec-client/cec-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ void ShowHelpCommandLine(const char* strExec)
" -l --list-devices List all devices on this system" << std::endl <<
" -t --type {p|r|t|a} The device type to use. More than one is possible." << std::endl <<
" -p --port {int} The HDMI port to use as active source." << std::endl <<
" -dp --default-port {int} The default HDMI port to fall back to when resetting." << std::endl <<
" -b --base {int} The logical address of the device to which this " << std::endl <<
" adapter is connected." << std::endl <<
" -f --log-file {file} Writes all libCEC log message to a file" << std::endl <<
Expand Down Expand Up @@ -1168,6 +1169,22 @@ bool ProcessCommandLineArguments(int argc, char *argv[])
}
++iArgPtr;
}
else if (!strcmp(argv[iArgPtr], "-dp") ||
!strcmp(argv[iArgPtr], "--default-port"))
{
if (argc >= iArgPtr + 2)
{
uint8_t hdmiport = (int8_t)atoi(argv[iArgPtr + 1]);
if (hdmiport < 1)
hdmiport = 1;
if (hdmiport > 15)
hdmiport = 15;
g_config.iDefaultHDMIPort = hdmiport;
std::cout << "using default HDMI port '" << (int)g_config.iDefaultHDMIPort << "'" << std::endl;
++iArgPtr;
}
++iArgPtr;
}
else if (!strcmp(argv[iArgPtr], "-r") ||
!strcmp(argv[iArgPtr], "--rom"))
{
Expand Down
16 changes: 16 additions & 0 deletions src/cecc-client/cecc-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,22 @@ static int cec_process_command_line_arguments(int argc, char *argv[])
}
++iArgPtr;
}
else if (!strcmp(argv[iArgPtr], "-dp") ||
!strcmp(argv[iArgPtr], "--default-port"))
{
if (argc >= iArgPtr + 2)
{
uint8_t hdmiport = (int8_t)atoi(argv[iArgPtr + 1]);
if (hdmiport < 1)
hdmiport = 1;
if (hdmiport > 15)
hdmiport = 15;
g_config.iDefaultHDMIPort = hdmiport;
printf("using default HDMI port '%d'\n", (int)g_config.iDefaultHDMIPort);
++iArgPtr;
}
++iArgPtr;
}
else if (!strcmp(argv[iArgPtr], "-r") ||
!strcmp(argv[iArgPtr], "--rom"))
{
Expand Down
8 changes: 8 additions & 0 deletions src/dotnetlib/CecSharpTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,7 @@ namespace CecSharp
PhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS;
BaseDevice = (CecLogicalAddress)CEC_DEFAULT_BASE_DEVICE;
HDMIPort = CEC_DEFAULT_HDMI_PORT;
DefaultHDMIPort = CEC_DEFAULT_HDMI_PORT;
ClientVersion = _LIBCEC_VERSION_CURRENT;
ServerVersion = 0;
TvVendor = CecVendorId::Unknown;
Expand Down Expand Up @@ -1688,6 +1689,7 @@ namespace CecSharp
PhysicalAddress = config.iPhysicalAddress;
BaseDevice = (CecLogicalAddress)config.baseDevice;
HDMIPort = config.iHDMIPort;
DefaultHDMIPort = config.iDefaultHDMIPort;
ClientVersion = config.clientVersion;
ServerVersion = config.serverVersion;
TvVendor = (CecVendorId)config.tvVendor;
Expand Down Expand Up @@ -1727,6 +1729,7 @@ namespace CecSharp
PhysicalAddress = config->PhysicalAddress;
BaseDevice = config->BaseDevice;
HDMIPort = config->HDMIPort;
DefaultHDMIPort = config->DefaultHDMIPort;
ClientVersion = config->ClientVersion;
ServerVersion = config->ServerVersion;
TvVendor = config->TvVendor;
Expand Down Expand Up @@ -1780,6 +1783,11 @@ namespace CecSharp
/// </summary>
property uint8_t HDMIPort;

/// <summary>
/// The default HDMI port to fall back to when resetting.
/// </summary>
property uint8_t DefaultHDMIPort;

/// <summary>
/// The client API version to use
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/dotnetlib/LibCecSharp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ namespace CecSharp
config.iPhysicalAddress = netConfig->PhysicalAddress;
config.baseDevice = (cec_logical_address)netConfig->BaseDevice;
config.iHDMIPort = netConfig->HDMIPort;
config.iDefaultHDMIPort = netConfig->DefaultHDMIPort;
config.clientVersion = netConfig->ClientVersion;
config.bGetSettingsFromROM = netConfig->GetSettingsFromROM ? 1 : 0;
config.bActivateSource = netConfig->ActivateSource ? 1 : 0;
Expand Down
4 changes: 3 additions & 1 deletion src/libcec/CECClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ bool CCECClient::SetHDMIPort(const cec_logical_address iBaseDevice, const uint8_
void CCECClient::ResetPhysicalAddress(void)
{
LIB_CEC->AddLog(CEC_LOG_DEBUG, "resetting HDMI port and base device to defaults");
SetHDMIPort(CECDEVICE_TV, CEC_DEFAULT_HDMI_PORT);
SetHDMIPort(CECDEVICE_TV, m_configuration.iDefaultHDMIPort);
}

bool CCECClient::SetPhysicalAddress(const libcec_configuration &configuration)
Expand Down Expand Up @@ -855,6 +855,7 @@ bool CCECClient::GetCurrentConfiguration(libcec_configuration &configuration)
configuration.iPhysicalAddress = m_configuration.iPhysicalAddress;
configuration.baseDevice = m_configuration.baseDevice;
configuration.iHDMIPort = m_configuration.iHDMIPort;
configuration.iDefaultHDMIPort = m_configuration.iDefaultHDMIPort;
configuration.clientVersion = m_configuration.clientVersion;
configuration.serverVersion = LIBCEC_VERSION_CURRENT;
configuration.tvVendor = m_configuration.tvVendor;
Expand Down Expand Up @@ -906,6 +907,7 @@ bool CCECClient::SetConfiguration(const libcec_configuration &configuration)
CLockObject lock(m_mutex);
m_configuration.bActivateSource = configuration.bActivateSource;
m_configuration.bGetSettingsFromROM = configuration.bGetSettingsFromROM;
m_configuration.iDefaultHDMIPort = configuration.iDefaultHDMIPort;
m_configuration.wakeDevices = configuration.wakeDevices;
m_configuration.powerOffDevices = configuration.powerOffDevices;
memcpy(m_configuration.strDeviceLanguage, configuration.strDeviceLanguage, 3);
Expand Down