CEC (Consumer Electronics Control) over HDMI

From eLinux.org
Jump to: navigation, search

The Raspberry Pi (Broadcom BCM2835 SoC) hardware has integrated support for CEC (Consumer Electronics Control) over the HDMI port.

CEC (Consumer Electronics Control) is the control protocol found in HDMI. Trade names for CEC are Anynet+ (Samsung); Aquos Link (Sharp); BRAVIA Link and BRAVIA Sync (Sony); HDMI-CEC (Hitachi); E-link (AOC); Kuro Link (Pioneer); CE-Link and Regza Link (Toshiba); RIHD (Remote Interactive over HDMI) (Onkyo); RuncoLink (Runco International); SimpLink (LG); HDAVI Control, EZ-Sync, VIERA Link (Panasonic); EasyLink (Philips); and NetCommand for HDMI (Mitsubishi).

Media center systems XBMC and MythTV already support HDMI-CEC via libCEC[1][2]; libCEC gained support for the Raspberry Pi in version 1.8.0[3], allowing you to control them via your television remote control without having a dedicated HTPC / MCE remote for your Raspberry Pi.

Once you have connected your Raspberry Pi to your TV and receiver with HDMI you should be able automatically to turn on and off your TV, receivers, and other home theater equipment, control your amplifier's volume, manage your DVD or Blu-Ray player, and redirect the active source on your TV to other equipment, all from one remote control. No line of sight is required and cables can be hidden neatly out of sight!

What is HDMI CEC?

Consumer Electronics Control (CEC) is an HDMI feature designed to allow the user to command and control up to ten CEC-enabled devices connected through HDMI by using just one of their remote controls (for example by controlling a television set, set-top box, PVR/DVR, and DVD player using only the remote control of the TV). CEC also allows for individual CEC-enabled devices to command and control each other without user intervention.

HDMI-CEC is a one-wire bidirectional serial bus that uses the industry-standard AV.link protocol to perform remote control functions. CEC wiring is mandatory, although implementation of CEC in a product is optional. It was defined in HDMI Specification 1.0 and updated in HDMI 1.2, HDMI 1.2a and HDMI 1.3a (the last added timer and audio commands to the bus). USB to CEC Adapters exist that allow a computer to control CEC-enabled devices.

Some of the available HDMI-CEC commands

  • One Touch Play: the device will become active source when playback starts
  • System Standby: switches all connected devices to standby
  • Preset Transfer: transfers the tuner channel setup to another TV set
  • One Touch Record: start recording immediately
  • Timer Programming: allow one device (e.g. a TV set or HTPC) to set the timer programming of another (e.g. a PVR/DVR or DVD-recorder)
  • System Information: checks all components for bus addresses and configuration
  • Deck Control: playback control
  • Tuner Control: control the tuner of another device
  • OSD Display: use the OSD of the TV set to display text
  • Device Menu Control: use the menus of another device
  • Routing Control: control the switching of signal sources
  • Remote Control Pass Through: pass through remote control commands
  • Device OSD Name Transfer: transfer the preferred device names to the TV set

Technical concept

CEC stands for Consumer Electronics Control. It is implemented as a single wire bus in the HDMI connector (pin 13). It allows various HDMI-enabled products to connect and communicate with each other. It allows various HDMI-enabled products to connect and communicate with each other. The intent is to enable one remote control to interface with all the A/V components. Various message opcodes can be exchanged between the connected systems in order to do device specific actions (like recording on a STB/DVR) or get general information across (like transferring remote control key press details).

In any HDMI setup, the display is considered to be the root, and gets allocated two special tags, a physical address of and a logical address of 0. In any given system, all CEC enabled devices have both physical and logical addresses, while the non-CEC devices have only physical addresses. Physical addresses are taken up based on the position of the device with respect to the root. For example, if an A/V receiver's output is connected to HDMI1 of the TV, it gets the physical address A device connected to the first HDMI input port of the A/V receiver would get the address, while one connected to the second HDMI port would get Logical addresses are taken on by the devices depending on their functionality (as mandated by the CEC specifications document). When the HDMI device menu is brought up on the display (On a Sony KDL46EX720, this is achieved by pressing the Sync Menu button), the display sends a broadcast over the CEC wire to all the downstream devices. It then collects the responses arriving over the CEC wire and presents the user with a list of CEC enabled devices. Choosing one of them ensures that future remote key presses are transferred by the TV to that particular address.

If you are interested in learning about the bus protocol and a bit more in-depth overview, I suggest taking a look at QuantumData's excellent CEC whitepaper (PDF). For more details on the various messages which can be exchanged between the devices, the full CEC specifications from the official HDMI documentation may be perused (PDF).

CEC with XBMC Media Center software

CEC allows XBMC to turn your TV, receivers, and other attached equipment on and off (if they support HDMI CEC) adjust the volume or eject the disk from a drive. Start playback, etc. and much more.

Likewise these same devices can tell XBMC what to do, for example, your TV remote can also control XBMC, or vice versa. With this device you can move that step closer to a clutter free living space while maintaining simple remote control for friends and family who may not be familiar with all of the features of a professional remote control.

See CEC in action and read about what it can do with XBMC:


libCEC is an open-source dual licensed library originally designed for communicating with the Pulse-Eight USB - HDMI CEC Adaptor.

libCEC needs the following dependencies in order to work correctly:

  • udev v151 or later
  • cdc-acm support compiled into the kernel or available as module

libCEC Features

  • Windows, Mac OS X, and Linux support
  • Turns on/off TV and receivers (e.g. when the screensaver becomes active, to save power)
  • Switch the TV and receivers to the correct HDMI port when starting your media center software
  • Send and receive key presses from your TV's remote
  • Control the volume of a CEC capable A/V receiver from your media center software
  • Sniff active traffic on CEC bus
  • Interfaces for C, C++ and .NET/CLR
  • No binary-only or obfuscated code; everything is open and can be modified
  • Example implementations in C++ and C#
  • And much more...

libCEC supported software

  • XBMC v11.0 "Eden" or higher
  • MythTV v0.25 or higher

Alternative open source libraries and code for CEC

Alternative, a cross-platform CEC library designed for Realtek SoC, a GPL v3 libraries exists for Arduino board (tmega series chip) and the TI msp430 chip the TI MSP430 chip, that could probably also be modified to work on the Broadcom BCM2835 SoC in the Raspberry Pi.

Realtek 1283 SoC ('MARS') platforms with CEC, a cross CEC library and a CEC daemon/service

cec-arduino - Arduino library for communicating with HDMI CEC equipment

TI msp430 linux changes and CEC library repository

SH4 duckbox

External links with more information for developers