X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fadapter%2FAdapterFactory.cpp;h=d585154212245e87332eed7bc7e63a861a2a07a4;hb=5b6d80327d783e8b6df03f631975503dc6a3637e;hp=ec216abf9df0235a192bc55c223714d4f1315bdf;hpb=2b44051cbfa70deafc30d9767323214debbc1a75;p=deb_libcec.git diff --git a/src/lib/adapter/AdapterFactory.cpp b/src/lib/adapter/AdapterFactory.cpp index ec216ab..d585154 100644 --- a/src/lib/adapter/AdapterFactory.cpp +++ b/src/lib/adapter/AdapterFactory.cpp @@ -1,7 +1,7 @@ /* * This file is part of the libCEC(R) library. * - * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved. + * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited. All rights reserved. * libCEC(R) is an original work, containing original code. * * libCEC(R) is a trademark of Pulse-Eight Limited. @@ -42,10 +42,37 @@ #include "Pulse-Eight/USBCECAdapterCommunication.h" #endif +#if defined(HAVE_RPI_API) +#include "RPi/RPiCECAdapterDetection.h" +#include "RPi/RPiCECAdapterCommunication.h" +#endif + +#if defined(HAVE_TDA995X_API) +#include "TDA995x/TDA995xCECAdapterDetection.h" +#include "TDA995x/TDA995xCECAdapterCommunication.h" +#endif + +#if defined(HAVE_EXYNOS_API) +#include "Exynos/ExynosCECAdapterDetection.h" +#include "Exynos/ExynosCECAdapterCommunication.h" +#endif + using namespace std; using namespace CEC; int8_t CAdapterFactory::FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */) +{ + cec_adapter_descriptor devices[50]; + int8_t iReturn = DetectAdapters(devices, iBufSize, strDevicePath); + for (int8_t iPtr = 0; iPtr < iReturn; iPtr++) + { + strncpy(deviceList[iPtr].comm, devices[iPtr].strComName, sizeof(deviceList[iPtr].comm)); + strncpy(deviceList[iPtr].path, devices[iPtr].strComPath, sizeof(deviceList[iPtr].path)); + } + return iReturn; +} + +int8_t CAdapterFactory::DetectAdapters(cec_adapter_descriptor *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */) { int8_t iAdaptersFound(0); @@ -61,7 +88,46 @@ int8_t CAdapterFactory::FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, m_lib->AddLog(CEC_LOG_WARNING, "libCEC has not been compiled with support for the Pulse-Eight USB-CEC Adapter"); #endif -#if !defined(HAVE_P8_USB) +#if defined(HAVE_RPI_API) + if (iAdaptersFound < iBufSize && CRPiCECAdapterDetection::FindAdapter() && + (!strDevicePath || !strcmp(strDevicePath, CEC_RPI_VIRTUAL_COM))) + { + snprintf(deviceList[iAdaptersFound].strComPath, sizeof(deviceList[iAdaptersFound].strComPath), CEC_RPI_VIRTUAL_PATH); + snprintf(deviceList[iAdaptersFound].strComName, sizeof(deviceList[iAdaptersFound].strComName), CEC_RPI_VIRTUAL_COM); + deviceList[iAdaptersFound].iVendorId = RPI_ADAPTER_VID; + deviceList[iAdaptersFound].iProductId = RPI_ADAPTER_PID; + deviceList[iAdaptersFound].adapterType = ADAPTERTYPE_RPI; + iAdaptersFound++; + } +#endif + +#if defined(HAVE_TDA995X_API) + if (iAdaptersFound < iBufSize && CTDA995xCECAdapterDetection::FindAdapter() && + (!strDevicePath || !strcmp(strDevicePath, CEC_TDA995x_VIRTUAL_COM))) + { + snprintf(deviceList[iAdaptersFound].strComPath, sizeof(deviceList[iAdaptersFound].strComPath), CEC_TDA995x_PATH); + snprintf(deviceList[iAdaptersFound].strComName, sizeof(deviceList[iAdaptersFound].strComName), CEC_TDA995x_VIRTUAL_COM); + deviceList[iAdaptersFound].iVendorId = TDA995X_ADAPTER_VID; + deviceList[iAdaptersFound].iProductId = TDA995X_ADAPTER_PID; + deviceList[iAdaptersFound].adapterType = ADAPTERTYPE_TDA995x; + iAdaptersFound++; + } +#endif + +#if defined(HAVE_EXYNOS_API) + if (iAdaptersFound < iBufSize && CExynosCECAdapterDetection::FindAdapter()) + { + snprintf(deviceList[iAdaptersFound].strComPath, sizeof(deviceList[iAdaptersFound].strComPath), CEC_EXYNOS_PATH); + snprintf(deviceList[iAdaptersFound].strComName, sizeof(deviceList[iAdaptersFound].strComName), CEC_EXYNOS_VIRTUAL_COM); + deviceList[iAdaptersFound].iVendorId = 0; + deviceList[iAdaptersFound].iProductId = 0; + deviceList[iAdaptersFound].adapterType = ADAPTERTYPE_EXYNOS; + iAdaptersFound++; + } +#endif + + +#if !defined(HAVE_RPI_API) && !defined(HAVE_P8_USB) && !defined(HAVE_TDA995X_API) #error "libCEC doesn't have support for any type of adapter. please check your build system or configuration" #endif @@ -70,15 +136,33 @@ int8_t CAdapterFactory::FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, IAdapterCommunication *CAdapterFactory::GetInstance(const char *strPort, uint16_t iBaudRate) { +#if defined(HAVE_TDA995X_API) + if (!strcmp(strPort, CEC_TDA995x_VIRTUAL_COM)) + return new CTDA995xCECAdapterCommunication(m_lib->m_cec); +#endif + +#if defined(HAVE_EXYNOS_API) + if (!strcmp(strPort, CEC_EXYNOS_VIRTUAL_COM)) + return new CExynosCECAdapterCommunication(m_lib->m_cec); +#endif + +#if defined(HAVE_RPI_API) + if (!strcmp(strPort, CEC_RPI_VIRTUAL_COM)) + return new CRPiCECAdapterCommunication(m_lib->m_cec); +#endif + #if defined(HAVE_P8_USB) return new CUSBCECAdapterCommunication(m_lib->m_cec, strPort, iBaudRate); #endif -#if !defined(HAVE_P8_USB) +#if !defined(HAVE_RPI_API) && !defined(HAVE_P8_USB) && !defined(HAVE_TDA995X_API) && !defined(HAVE_EXYNOS_API) return NULL; #endif } void CAdapterFactory::InitVideoStandalone(void) { +#if defined(HAVE_RPI_API) + CRPiCECAdapterCommunication::InitHost(); +#endif }