X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fadapter%2FAdapterFactory.cpp;h=42cdd0beacb7b088cd3a8935c09d9ad38d536121;hb=8f69060da89a711b1a45bc7d5958a3436b71ac4a;hp=d1dae84ac69b0de80e7f0ceebcbaeefe272277ab;hpb=51cf495d05ba1cce3edb750d3afdc60067f9e7af;p=deb_libcec.git diff --git a/src/lib/adapter/AdapterFactory.cpp b/src/lib/adapter/AdapterFactory.cpp index d1dae84..42cdd0b 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. @@ -48,14 +48,26 @@ #endif #if defined(HAVE_TDA995X_API) -#include "CuBox/NxpCECAdapterDetection.h" -#include "CuBox/NxpCECAdapterCommunication.h" +#include "TDA995x/TDA995xCECAdapterDetection.h" +#include "TDA995x/TDA995xCECAdapterCommunication.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); @@ -75,17 +87,25 @@ int8_t CAdapterFactory::FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, if (iAdaptersFound < iBufSize && CRPiCECAdapterDetection::FindAdapter() && (!strDevicePath || !strcmp(strDevicePath, CEC_RPI_VIRTUAL_COM))) { - snprintf(deviceList[iAdaptersFound].path, 1024, CEC_RPI_VIRTUAL_PATH); - snprintf(deviceList[iAdaptersFound++].comm, 1024, 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 && CNxpCECAdapterDetection::FindAdapter() && + if (iAdaptersFound < iBufSize && CTDA995xCECAdapterDetection::FindAdapter() && (!strDevicePath || !strcmp(strDevicePath, CEC_TDA995x_VIRTUAL_COM))) { - snprintf(deviceList[iAdaptersFound].path, 1024, CEC_TDA995x_PATH); - snprintf(deviceList[iAdaptersFound++].comm, 1024, 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 @@ -100,7 +120,7 @@ IAdapterCommunication *CAdapterFactory::GetInstance(const char *strPort, uint16_ { #if defined(HAVE_TDA995X_API) if (!strcmp(strPort, CEC_TDA995x_VIRTUAL_COM)) - return new CNxpCECAdapterCommunication(m_lib->m_cec); + return new CTDA995xCECAdapterCommunication(m_lib->m_cec); #endif #if defined(HAVE_RPI_API)