#include "devices/CECPlaybackDevice.h"
#include "devices/CECAudioSystem.h"
#include "devices/CECTV.h"
+#include "implementations/CECCommandHandler.h"
using namespace CEC;
using namespace PLATFORM;
// set the physical address
SetPhysicalAddress(m_configuration);
- // ensure that we know the vendor id of the TV, so we are using the correct handler
- m_processor->GetTV()->GetVendorId(GetPrimaryLogicalAdddress());
-
// make the primary device the active source if the option is set
if (m_configuration.bActivateSource == 1)
GetPrimaryDevice()->ActivateSource();
return true;
}
+void CCECClient::SetSupportedDeviceTypes(void)
+{
+ cec_device_type_list types;
+ types.Clear();
+
+ // get the command handler for the tv
+ CCECCommandHandler *tvHandler = m_processor->GetTV()->GetHandler();
+ if (!tvHandler)
+ return;
+
+ // check all device types
+ for (uint8_t iPtr = 0; iPtr < 5; iPtr++)
+ {
+ if (m_configuration.deviceTypes.types[iPtr] == CEC_DEVICE_TYPE_RESERVED)
+ continue;
+
+ // get the supported device type. the handler will replace types it doesn't support by one it does support
+ cec_device_type type = tvHandler->GetReplacementDeviceType(m_configuration.deviceTypes.types[iPtr]);
+ if (!types.IsSet(type))
+ types.Add(type);
+ }
+
+ // set the new type list
+ m_configuration.deviceTypes = types;
+}
+
bool CCECClient::AllocateLogicalAddresses(void)
{
// reset all previous LAs that were set
m_configuration.logicalAddresses.Clear();
+ // get the supported device types from the command handler of the TV
+ SetSupportedDeviceTypes();
+
// display an error if no device types are set
if (m_configuration.deviceTypes.IsEmpty())
{
*/
virtual bool AutodetectPhysicalAddress(void);
+ /*!
+ * @brief Replaces all device types in m_configuration by types that are supported by the command handler of the TV
+ */
+ virtual void SetSupportedDeviceTypes(void);
+
CCECProcessor * m_processor; /**< a pointer to the processor */
libcec_configuration m_configuration; /**< the configuration of this client */
bool m_bInitialised; /**< true when initialised, false otherwise */
return false;
}
+ // ensure that we know the vendor id of the TV
+ GetTV()->GetVendorId(CECDEVICE_UNREGISTERED);
+
// unregister the client first if it's already been marked as registered
if (client->IsRegistered())
UnregisterClient(client);
client->Alert(CEC_ALERT_SERVICE_DEVICE, param);
}
+ // ensure that the command handler for the TV is initialised
+ if (bReturn)
+ {
+ CCECCommandHandler *handler = GetTV()->GetHandler();
+ if (handler)
+ handler->InitHandler();
+ }
+
return bReturn;
}
if (bInitHandler)
{
- m_handler->InitHandler();
+ CCECBusDevice *primary = GetProcessor()->GetPrimaryDevice();
+ if (primary->GetLogicalAddress() != CECDEVICE_UNREGISTERED)
+ {
+ m_handler->InitHandler();
- if (bActivateSource && IsHandledByLibCEC() && IsActiveSource())
- m_handler->ActivateSource();
+ if (bActivateSource && IsHandledByLibCEC() && IsActiveSource())
+ m_handler->ActivateSource();
+ }
}
MarkReady();
virtual void SignalOpcode(cec_opcode opcode);
virtual bool ActiveSourcePending(void);
+ virtual bool SupportsDeviceType(const cec_device_type UNUSED(type)) const { return true; };
+ cec_device_type GetReplacementDeviceType(const cec_device_type type) const { return type; }
protected:
virtual bool HandleActiveSource(const cec_command &command);
CCECCommandHandler(busDevice)
{
m_vendorId = CEC_VENDOR_TOSHIBA;
- CCECBusDevice *primary = m_processor->GetPrimaryDevice();
-
- /* imitate Toshiba devices */
- if (primary && m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
- {
- primary->SetVendorId(CEC_VENDOR_TOSHIBA);
- primary->ReplaceHandler(false);
- }
}
bool CRLCommandHandler::InitHandler(void)
return true;
m_bHandlerInited = true;
- if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
+ CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+ if (primary && primary->GetLogicalAddress() != CECDEVICE_UNREGISTERED)
{
- CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+ /* imitate Toshiba devices */
+ if (m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
+ {
+ primary->SetVendorId(CEC_VENDOR_TOSHIBA);
+ primary->ReplaceHandler(false);
+ }
- /* send the vendor id */
- primary->TransmitVendorID(CECDEVICE_BROADCAST);
+ if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
+ {
+ /* send the vendor id */
+ primary->TransmitVendorID(CECDEVICE_BROADCAST);
+ }
}
return true;
m_bActiveSourceSent(false)
{
m_vendorId = CEC_VENDOR_LG;
- CCECBusDevice *primary = m_processor->GetPrimaryDevice();
-
- /* imitate LG devices */
- if (primary && m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
- {
- primary->SetVendorId(CEC_VENDOR_LG);
- primary->ReplaceHandler(false);
- }
/* LG devices don't always reply to CEC version requests, so just set it to 1.3a */
m_busDevice->SetCecVersion(CEC_VERSION_1_3A);
return true;
m_bHandlerInited = true;
- if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
+ CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+ if (primary && primary->GetLogicalAddress() != CECDEVICE_UNREGISTERED)
{
- CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+ /* imitate LG devices */
+ if (m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
+ {
+ primary->SetVendorId(CEC_VENDOR_LG);
+ primary->ReplaceHandler(false);
+ }
- /* start as 'in transition standby->on' */
- primary->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
- primary->TransmitPowerState(CECDEVICE_TV);
+ if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
+ {
+ /* start as 'in transition standby->on' */
+ primary->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
+ primary->TransmitPowerState(CECDEVICE_TV);
- /* send the vendor id */
- primary->TransmitVendorID(CECDEVICE_BROADCAST);
+ /* send the vendor id */
+ primary->TransmitVendorID(CECDEVICE_BROADCAST);
+ }
}
return true;
m_bPowerUpEventReceived(false)
{
m_vendorId = CEC_VENDOR_PANASONIC;
-
- /* use the VL commandhandler for the primary device that is handled by libCEC */
- if (busDevice->GetLogicalAddress() == CECDEVICE_TV)
- {
- CCECBusDevice *primary = m_processor->GetPrimaryDevice();
- if (primary && m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
- {
- primary->SetVendorId(CEC_VENDOR_PANASONIC);
- primary->ReplaceHandler(false);
- }
- }
}
bool CVLCommandHandler::InitHandler(void)
{
CCECBusDevice *primary = m_processor->GetPrimaryDevice();
- if (primary->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE)
- return m_processor->GetPrimaryClient()->ChangeDeviceType(CEC_DEVICE_TYPE_RECORDING_DEVICE, CEC_DEVICE_TYPE_PLAYBACK_DEVICE);
+ if (primary && primary->GetLogicalAddress() != CECDEVICE_UNREGISTERED)
+ {
+ /* use the VL commandhandler for the primary device that is handled by libCEC */
+ if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
+ {
+ if (primary && m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
+ {
+ primary->SetVendorId(CEC_VENDOR_PANASONIC);
+ primary->ReplaceHandler(false);
+ }
+ }
+
+ if (primary->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE)
+ return m_processor->GetPrimaryClient()->ChangeDeviceType(CEC_DEVICE_TYPE_RECORDING_DEVICE, CEC_DEVICE_TYPE_PLAYBACK_DEVICE);
+ }
return CCECCommandHandler::InitHandler();
}
bool TransmitPendingActiveSourceCommands(void);
bool PowerUpEventReceived(void);
+ bool SupportsDeviceType(const cec_device_type type) const { return type != CEC_DEVICE_TYPE_RECORDING_DEVICE; };
+ cec_device_type GetReplacementDeviceType(const cec_device_type type) const { return type == CEC_DEVICE_TYPE_RECORDING_DEVICE ? CEC_DEVICE_TYPE_PLAYBACK_DEVICE : type; }
private:
PLATFORM::CMutex m_mutex;