cec: set the device type in the firmware too for v2 firmwares. bugzid: 543
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 8 Mar 2012 19:09:09 +0000 (20:09 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 8 Mar 2012 19:09:09 +0000 (20:09 +0100)
src/lib/LibCEC.cpp
src/lib/LibCEC.h
src/lib/adapter/USBCECAdapterCommunication.cpp
src/lib/adapter/USBCECAdapterCommunication.h

index 46e428ff3e0da2e9ca3160de36a348c1fc3184f4..d676225eaa74ecf9e92fc6bee6f26dfd2aac1f5b 100644 (file)
@@ -618,3 +618,29 @@ bool CLibCEC::IsLibCECActiveSource(void)
       m_cec->m_busDevices[m_cec->GetActiveSource()]->GetStatus(false) == CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC :
       false;
 }
+
+cec_device_type CLibCEC::GetType(cec_logical_address address)
+{
+  switch (address)
+  {
+    case CECDEVICE_AUDIOSYSTEM:
+      return CEC_DEVICE_TYPE_AUDIO_SYSTEM;
+    case CECDEVICE_PLAYBACKDEVICE1:
+    case CECDEVICE_PLAYBACKDEVICE2:
+    case CECDEVICE_PLAYBACKDEVICE3:
+      return CEC_DEVICE_TYPE_PLAYBACK_DEVICE;
+    case CECDEVICE_RECORDINGDEVICE1:
+    case CECDEVICE_RECORDINGDEVICE2:
+    case CECDEVICE_RECORDINGDEVICE3:
+      return CEC_DEVICE_TYPE_RECORDING_DEVICE;
+    case CECDEVICE_TUNER1:
+    case CECDEVICE_TUNER2:
+    case CECDEVICE_TUNER3:
+    case CECDEVICE_TUNER4:
+      return CEC_DEVICE_TYPE_TUNER;
+    case CECDEVICE_TV:
+      return CEC_DEVICE_TYPE_TV;
+    default:
+      return CEC_DEVICE_TYPE_RESERVED;
+  }
+}
index 9241a2c3f8336ce602ee353367f4ca7f52eeb4e7..fb98030fd6e46d96546c9b9eace927638b184b32 100644 (file)
@@ -121,6 +121,8 @@ namespace CEC
       const char *ToString(const cec_vendor_id vendor);
       const char *ToString(const cec_client_version version);
       const char *ToString(const cec_server_version version);
+
+      static cec_device_type GetType(cec_logical_address address);
     //@}
 
       static void AddLog(const cec_log_level level, const char *strFormat, ...);
index 4f477b90d6cfa9df43e29958d6f98bea92d43c4f..030d643516c5c52e8e0772ba4cd8b162c52469d3 100644 (file)
@@ -576,6 +576,7 @@ bool CUSBCECAdapterCommunication::PersistConfiguration(libcec_configuration *con
 
   bool bReturn(true);
   bReturn &= SetAutoEnabled(true);
+  bReturn &= SetDeviceType(CLibCEC::GetType(configuration->logicalAddresses.primary));
   bReturn &= SetDefaultLogicalAddress(configuration->logicalAddresses.primary);
   bReturn &= SetLogicalAddressMask(configuration->logicalAddresses.AckMask());
   bReturn &= SetPhysicalAddress(configuration->iPhysicalAddress);
@@ -636,6 +637,31 @@ bool CUSBCECAdapterCommunication::SetAutoEnabled(bool enabled)
   return true;
 }
 
+bool CUSBCECAdapterCommunication::SetDeviceType(cec_device_type type)
+{
+  CLockObject lock(m_mutex);
+  CLibCEC::AddLog(CEC_LOG_DEBUG, "setting the device type to %1X", (uint8_t)type);
+
+  CCECAdapterMessage *output = new CCECAdapterMessage;
+
+  output->PushBack(MSGSTART);
+  output->PushEscaped(MSGCODE_SET_DEVICE_TYPE);
+  output->PushEscaped((uint8_t)type);
+  output->PushBack(MSGEND);
+  output->isTransmission = false;
+
+  SendMessageToAdapter(output);
+  bool bWriteOk = output->state == ADAPTER_MESSAGE_STATE_SENT_ACKED;
+  delete output;
+  if (!bWriteOk)
+  {
+    CLibCEC::AddLog(CEC_LOG_ERROR, "could not set the device type");
+    return false;
+  }
+
+  return true;
+}
+
 bool CUSBCECAdapterCommunication::SetDefaultLogicalAddress(cec_logical_address address)
 {
   CLockObject lock(m_mutex);
index 98f72fc427c9a2a9d6cde09c675de8d74bab07a6..8d1e2cb9ea5414848cfbe574a7679b5bf5e588a3 100644 (file)
@@ -90,6 +90,7 @@ namespace CEC
     void *Process(void);
   private:
     bool SetAutoEnabled(bool enabled);
+    bool SetDeviceType(cec_device_type type);
     bool SetDefaultLogicalAddress(cec_logical_address address);
     bool SetLogicalAddressMask(uint16_t iMask);
     bool SetPhysicalAddress(uint16_t iPhysicalAddress);