cec: add setting 'HDMI port'
authorLars Op den Kamp <lars@opdenkamp.eu>
Fri, 14 Oct 2011 09:36:57 +0000 (11:36 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Fri, 14 Oct 2011 17:48:01 +0000 (19:48 +0200)
language/English/strings.xml
system/peripherals.xml
xbmc/peripherals/devices/PeripheralCecAdapter.cpp
xbmc/peripherals/devices/PeripheralCecAdapter.h

index c734803..c626923 100644 (file)
   <string id="36012">Could not detect the CEC adapter.</string>
   <string id="36013">Unsupported libcec interface version. %d is greater than the version XBMC supports (%d)</string>
   <string id="36014">Put this PC in standby mode when the TV is switched off</string>
+  <string id="36015">HDMI port number</string>
 </strings>
index 592fa95..aa7ed0c 100644 (file)
@@ -19,6 +19,7 @@
   <peripheral vendor="2548" product="1001" bus="usb" name="Pulse-Eight CEC Adaptor" mapTo="cec">
     <setting key="enabled" type="bool" value="1" label="305" />
     <setting key="port" type="string" value="" label="792" />
+    <setting key="cec_hdmi_port" type="int" value="1" min="1" max="16" label="36015" />
     <setting key="cec_power_on_startup" type="bool" value="1" label="36007" />
     <setting key="cec_power_off_shutdown" type="bool" value="1" label="36008" />
     <setting key="cec_standby_screensaver" type="bool" value="1" label="36009" />
index 500e35e..965a352 100644 (file)
@@ -209,6 +209,12 @@ void CPeripheralCecAdapter::Process(void)
     }
   }
 
+  // set the correct physical address
+  int iHdmiPort = GetSettingInt("cec_hdmi_port");
+  if (iHdmiPort <= 0 || iHdmiPort > 16)
+    iHdmiPort = 1;
+  m_cecAdapter->SetPhysicalAddress(iHdmiPort << 12);
+
   // open the CEC adapter
   CLog::Log(LOGDEBUG, "%s - opening a connection to the CEC adapter: %s", __FUNCTION__, strPort.c_str());
 
@@ -295,6 +301,20 @@ bool CPeripheralCecAdapter::StartBootloader(void)
   return bReturn;
 }
 
+bool CPeripheralCecAdapter::SetHdmiPort(int iHdmiPort)
+{
+  bool bReturn(false);
+  if (m_cecAdapter && m_bIsReady)
+  {
+    if (iHdmiPort <= 0 || iHdmiPort > 16)
+      iHdmiPort = 1;
+    CLog::Log(LOGDEBUG, "%s - changing active HDMI port to %d", __FUNCTION__, iHdmiPort);
+    bReturn = m_cecAdapter->SetPhysicalAddress(iHdmiPort << 12);
+  }
+
+  return bReturn;
+}
+
 void CPeripheralCecAdapter::ProcessNextCommand(void)
 {
   cec_command command;
@@ -551,6 +571,10 @@ void CPeripheralCecAdapter::OnSettingChanged(const CStdString &strChangedSetting
     else if (bEnabled && !m_cecAdapter && m_bStarted)
       InitialiseFeature(FEATURE_CEC);
   }
+  else if (strChangedSetting.Equals("cec_hdmi_port"))
+  {
+    SetHdmiPort(GetSettingInt("cec_hdmi_port"));
+  }
 }
 
 void CPeripheralCecAdapter::FlushLog(void)
index 8f2b021..5d8950e 100644 (file)
@@ -55,6 +55,7 @@ namespace PERIPHERALS
 
     virtual bool SendPing(void);
     virtual bool StartBootloader(void);
+    virtual bool SetHdmiPort(int iHdmiPort);
 
     virtual void OnSettingChanged(const CStdString &strChangedSetting);