Skip to content

Commit

Permalink
Add Linux CEC Adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwiboo committed Jan 14, 2019
1 parent 3bbd432 commit 467cc79
Show file tree
Hide file tree
Showing 12 changed files with 700 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/README.linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,11 @@ Pass the argument `-DHAVE_TDA995X_API=1` to the cmake command in the compilation
cmake -DHAVE_TDA995X_API=1 ..
```

### Linux CEC Framework (v4.10+)
Pass the argument `-DHAVE_LINUX_API=1` to the cmake command in the compilation instructions:
```
cmake -DHAVE_LINUX_API=1 ..
```

### Debian / Ubuntu .deb packaging
See [docs/README.debian.md](README.debian.md).
11 changes: 11 additions & 0 deletions include/cectypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,16 @@ namespace CEC {
*/
#define CEC_MAX_DATA_PACKET_SIZE (16 * 4)

/*!
* the path to use for the Linux CEC device
*/
#define CEC_LINUX_PATH "/dev/cec0"

/*!
* the name of the virtual COM port to use for the Linux' CEC wire
*/
#define CEC_LINUX_VIRTUAL_COM "Linux"

/*!
* the path to use for the AOCEC HDMI CEC device
*/
Expand Down Expand Up @@ -861,6 +871,7 @@ typedef enum cec_adapter_type
ADAPTERTYPE_RPI = 0x100,
ADAPTERTYPE_TDA995x = 0x200,
ADAPTERTYPE_EXYNOS = 0x300,
ADAPTERTYPE_LINUX = 0x400,
ADAPTERTYPE_AOCEC = 0x500
} cec_adapter_type;

Expand Down
2 changes: 2 additions & 0 deletions src/libcec/CECTypeUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,8 @@ namespace CEC
return "Raspberry Pi";
case ADAPTERTYPE_TDA995x:
return "TDA995x";
case ADAPTERTYPE_LINUX:
return "Linux";
default:
return "unknown";
}
Expand Down
2 changes: 2 additions & 0 deletions src/libcec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ set(CEC_HEADERS devices/CECRecordingDevice.h
adapter/Exynos/ExynosCEC.h
adapter/Exynos/ExynosCECAdapterDetection.h
adapter/Exynos/ExynosCECAdapterCommunication.h
adapter/Linux/LinuxCECAdapterDetection.h
adapter/Linux/LinuxCECAdapterCommunication.h
adapter/AOCEC/AOCEC.h
adapter/AOCEC/AOCECAdapterDetection.h
adapter/AOCEC/AOCECAdapterCommunication.h
Expand Down
26 changes: 24 additions & 2 deletions src/libcec/adapter/AdapterFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
#include "Exynos/ExynosCECAdapterCommunication.h"
#endif

#if defined(HAVE_LINUX_API)
#include "Linux/LinuxCECAdapterDetection.h"
#include "Linux/LinuxCECAdapterCommunication.h"
#endif

#if defined(HAVE_AOCEC_API)
#include "AOCEC/AOCECAdapterDetection.h"
#include "AOCEC/AOCECAdapterCommunication.h"
Expand Down Expand Up @@ -131,6 +136,18 @@ int8_t CAdapterFactory::DetectAdapters(cec_adapter_descriptor *deviceList, uint8
}
#endif

#if defined(HAVE_LINUX_API)
if (iAdaptersFound < iBufSize && CLinuxCECAdapterDetection::FindAdapter())
{
snprintf(deviceList[iAdaptersFound].strComPath, sizeof(deviceList[iAdaptersFound].strComPath), CEC_LINUX_PATH);
snprintf(deviceList[iAdaptersFound].strComName, sizeof(deviceList[iAdaptersFound].strComName), CEC_LINUX_VIRTUAL_COM);
deviceList[iAdaptersFound].iVendorId = 0;
deviceList[iAdaptersFound].iProductId = 0;
deviceList[iAdaptersFound].adapterType = ADAPTERTYPE_LINUX;
iAdaptersFound++;
}
#endif

#if defined(HAVE_AOCEC_API)
if (iAdaptersFound < iBufSize && CAOCECAdapterDetection::FindAdapter())
{
Expand All @@ -144,7 +161,7 @@ int8_t CAdapterFactory::DetectAdapters(cec_adapter_descriptor *deviceList, uint8
#endif


#if !defined(HAVE_RPI_API) && !defined(HAVE_P8_USB) && !defined(HAVE_TDA995X_API) && !defined(HAVE_AOCEC_API)
#if !defined(HAVE_RPI_API) && !defined(HAVE_P8_USB) && !defined(HAVE_TDA995X_API) && !defined(HAVE_LINUX_API) && !defined(HAVE_AOCEC_API)
#error "libCEC doesn't have support for any type of adapter. please check your build system or configuration"
#endif

Expand All @@ -163,6 +180,11 @@ IAdapterCommunication *CAdapterFactory::GetInstance(const char *strPort, uint16_
return new CExynosCECAdapterCommunication(m_lib->m_cec);
#endif

#if defined(HAVE_LINUX_API)
if (!strcmp(strPort, CEC_LINUX_VIRTUAL_COM))
return new CLinuxCECAdapterCommunication(m_lib->m_cec);
#endif

#if defined(HAVE_AOCEC_API)
if (!strcmp(strPort, CEC_AOCEC_VIRTUAL_COM))
return new CAOCECAdapterCommunication(m_lib->m_cec);
Expand All @@ -177,7 +199,7 @@ IAdapterCommunication *CAdapterFactory::GetInstance(const char *strPort, uint16_
return new CUSBCECAdapterCommunication(m_lib->m_cec, strPort, iBaudRate);
#endif

#if !defined(HAVE_RPI_API) && !defined(HAVE_P8_USB) && !defined(HAVE_TDA995X_API) && !defined(HAVE_EXYNOS_API) && !defined(HAVE_AOCEC_API)
#if !defined(HAVE_RPI_API) && !defined(HAVE_P8_USB) && !defined(HAVE_TDA995X_API) && !defined(HAVE_EXYNOS_API) && !defined(HAVE_LINUX_API) && !defined(HAVE_AOCEC_API)
return NULL;
#endif
}
Expand Down
Loading

0 comments on commit 467cc79

Please sign in to comment.