The High-Definition Multimedia Interface Consumer Electronics Control (HDMI-CEC) standard allows mulitmedia consumer products to communicate and exchange information with each other. HDMI-CEC supports many features, such as Remote Control Passthrough and System Audio Control, but one of the most popular is One Touch Play. One Touch Play allows a media source device to turn on the TV and switch its input port automatically, so you don’t have to search for the TV remote to switch from your Chromecast to Blu-ray player.
With Android 12, power control of the HDMI-connected display aligns with power control of the internal display. When an HDMI playback device wakes up, it attempts to wake the connected TV and become the current active source through HDMI CEC One Touch Play. If the device goes to sleep while it is the current active source, it then attempts to turn off the connected TV.
Supporting HDMI-CEC is generally optional. However, most manufacturers have adopted HDMI-CEC so their devices work with other companies’ devices. Each manufacturer implements the HDMI-CEC standard in different ways, so devices don't always understand each other and supported features vary between devices. Because of this variance, consumers can’t safely assume that two products that claim CEC support are completely compatible.
Support for HDMI-CEC 2.0 helps improves compatibility between HDMI devices if both the sending and receiving device support this version of the standard.
Solution
With the introduction of the Android TV Input Framework (TIF), HDMI-CEC
brings together all connected devices and minimizes compatibility issues.
Android has created a system service called HdmiControlService
to
alleviate these pain points.
By offering HdmiControlService
as a part of the Android
ecosystem, Android hopes to provide:
- A standard implementation of HDMI-CEC for all manufacturers, which will reduce device incompatibility. Previously, manufacturers had to develop their own implementations of HDMI-CEC or use third-party solutions.
- A service that is well-tested against numerous HDMI-CEC devices already in the market. Android has been conducting rigorous research on compatibility issues found among the products and collecting useful advice from device implementers experienced in the technology. The CEC service is designed to keep a healthy balance between the standard and modifications to that standard so that it works with the products that people already use.
Overall design
HdmiControlService
is connected with the rest of the system like
TV Input Framework (TIF), Audio service, and Power service to implement the
various features the standard specifies.
See the following diagram for a depiction of the switch from a custom CEC controller to an implementation of the simpler HDMI-CEC hardware abstraction layer (HAL).
Implementation
See the following diagram for a detailed view of the HDMI control service.
Here are the key ingredients to a proper Android HDMI-CEC implementation:
- A manager class
HdmiControlManager
provides privileged apps with the API. System services like TV Input Manager service and Audio service can use the service directly. - The service is designed to allow hosting more than one type of logical device.
- HDMI-CEC is connected with the hardware via a hardware abstraction layer (HAL) to simplify handling differences of the protocol and signalling mechanisms between the devices. The HAL definition is available for device manufacturers to use to implement the HAL layer.
Note: Device manufacturers should add the
following line into PRODUCT_COPY_FILES
in device.mk
.
PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.hdmi.cec.xml:system/etc/permissions/android.hardware.hdmi.cec.xml
Depending on whether your device is a HDMI sink device or a HDMI source device,
device manufacturers need to set ro.hdmi.device_type
in
device.mk
for HdmiControlService
to work correctly.
For HDMI source devices, such as Over the Top (OTT) or Set-top box (STB) devices, set:
PRODUCT_PROPERTY_OVERRIDES += ro.hdmi.device_type=4
For HDMI sink devices, like panel TVs, set:
PRODUCT_PROPERTY_OVERRIDES += ro.hdmi.device_type=0
- A device manufacturer-provided proprietary CEC controller cannot coexist
with
HdmiControlService
. It must be disabled or removed. Common requirements for this come from the need to handle manufacturer-specific commands. The manufacturer-specific command handler should be incorporated into the service by extending/modifying it. This work is left to the device manufacturer and not specified by Android. Note that any change made in the service for manufacturer-specific commands must not interfere with the way standard commands are handled or the device will not be Android compatible. - Access to the HDMI-CEC service is guarded with the protection level
SignatureOrSystem
. Only system components or the apps placed in/system/priv-app
can access the service. This is to protect the service from abuse by apps with malicious intent.
Android supports type TV/Display(0)
, Playback
device(4)
which can issue the One Touch Play command to become the active
source and Audio System (5)
which handles system audio mode and ARC.
Other device types (Tuner and Recorder) are currently not supported.
HDMI-CEC HAL
The HDMI-CEC HAL API lets the HdmiControlService
make use of the
hardware resource to send/receive HDMI-CEC commands, configure necessary settings,
and (optionally) communicate with the microprocessor in the underlying platform that
will take over the CEC control while the Android system is in standby mode.
Version | Features | HAL files |
---|---|---|
1.0 | Configure HAL data (addresses, features). Send HDMI-CEC commands. Register callback to receive HDMI-CEC commands and hotplug events. | IHdmiCec.hal IHdmiCecCallback.hal |
1.1 | Introduce HDMI-CEC 2.0 types | @1.1::IHdmiCec.hal @1.1::IHdmiCecCallback.hal |
Testing
HDMI-CEC implementations of devices are tested and verified via CTS tests according to the HDMI-CEC CTS documentation.
HDMI-CEC 2.0
Android source (playback) and sink (TV panel) devices support HDMI-CEC 2.0. HDMI-CEC 2.0 offers better interoperability between HDMI devices, improvements to Remote Control Passthrough and more extensive certification testing. Generally, HDMI-CEC 2.0 interactions with other devices are more efficient, resulting in less HDMI-CEC traffic as well as faster interactions.
For a device to support HDMI-CEC 2.0 the device and user configuration must be
set to use HDMI-CEC 2.0. The HAL implementation must also report support for HDMI-CEC 2.0
in calls to IHdmiCec#getCecVersion
.
CEC configuration
HDMI-CEC behavior can be configured at both build time (by OEMs using RROs) and runtime
(by HdmiControlManager
@SystemApi).
Examples of HDMI-CEC settings:
Setting | Option |
---|---|
Whether the HDMI-CEC is enabled or disabled. | Enabled Disabled |
Scope of HDMI-CEC power control messages sent by a playback device. | To TV only To TV and Audio System Broadcast None |
For each setting currently available and allowed options can be queried by apps at run time.