CEC Adapter — Setting Up libcec on Linux

Modified on Mon, 27 Apr at 8:50 PM

libcec is the software that powers the Pulse-Eight USB-CEC Adapter and allows it to communicate with your TV over HDMI. This article covers how to build and install libcec on Linux (Debian/Ubuntu). For Raspberry Pi, see: CEC Adapter — Using libcec with a Raspberry Pi

The current version of libcec is 7.1.1. The full source code is available at: github.com/Pulse-Eight/libcec

Prerequisites

libcec requires the following to function correctly:

  • p8-platform 2.0 or later — github.com/Pulse-Eight/platform
  • udev v151 or later
  • cdc-acm kernel support — either compiled into the kernel or available as a loadable module

To compile libcec you will also need:

  • cmake 2.6 or later
  • A C++11 compatible compiler (GCC or Clang)
  • Recommended: pkg-config, udev development headers v151 or later, and X RandR development headers — without these, the adapter may not be fully auto-detected

Installing on Debian or Ubuntu

On a new Debian or Ubuntu installation, run the following commands in order:

sudo apt-get update sudo apt-get install cmake libudev-dev libxrandr-dev python3-dev swig git clone https://github.com/Pulse-Eight/libcec.git mkdir libcec/build cd libcec/build cmake .. make -j4 sudo make install sudo ldconfig

Once complete, libcec is installed and the cec-client command-line tool is available.


Testing the Installation

With the USB-CEC Adapter connected and your TV powered on, run:

cec-client -l

This lists detected CEC adapters. You should see the Pulse-Eight adapter listed. To scan the CEC network and see all connected devices:

echo "scan" | cec-client -s -d 1

Common Commands

Turn TV on:

echo "on 0" | cec-client -s -d 1

Turn TV off / standby:

echo "standby 0" | cec-client -s -d 1

Monitor all CEC traffic:

cec-client -m

Press Ctrl+C to stop monitoring. See: CEC Adapter — Monitoring Mode


Building for Other Hardware Platforms

libcec supports additional hardware platforms beyond the USB-CEC Adapter. Pass the relevant argument to cmake when compiling:

Platformcmake argument
Exynos SoC-DHAVE_EXYNOS_API=1
Amlogic AOCEC-DHAVE_AOCEC_API=1
NXP TDA995x-DHAVE_TDA995X_API=1
Linux CEC Framework (kernel 4.10+)-DHAVE_LINUX_API=1

For example, to build with Linux CEC Framework support:

cmake -DHAVE_LINUX_API=1 ..

Using systemd

Example systemd unit files for common libcec use cases are included in the libcec source repository in the systemd/ folder. These can be used to run cec-client as a background service that starts automatically on boot.


Debian/Ubuntu Package (.deb)

Instructions for building a .deb package for Debian or Ubuntu are available in the libcec repository at docs/README.debian.md. This is useful if you want to deploy libcec across multiple machines.

Further help:
libcec source and documentation: github.com/Pulse-Eight/libcec
Email: cs@pulse-eight.com  |  Submit a support ticket

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article