CEC Driver



Download Extron software, control drivers, firmware, HID modules, architectural design resources, GUI design resources, TouchLink touchpanel themes, and more. This driver adds support for the Tegra CEC IP. It is based on the NVIDIA drivers/misc/tegra-cec driver in their 3.10 kernel. This has been converted to the CEC framework and cleaned up. Tested with my Jetson TK1 board.

The CEC framework provides a unified kernel interface for use with HDMI CEChardware. It is designed to handle a multiple types of hardware (receivers,transmitters, USB dongles). The framework also gives the option to decidewhat to do in the kernel driver and what should be handled by userspaceapplications. In addition it integrates the remote control passthroughfeature into the kernel’s remote control framework.

5.1. The CEC Protocol¶

The CEC protocol enables consumer electronic devices to communicate with eachother through the HDMI connection. The protocol uses logical addresses in thecommunication. The logical address is strictly connected with the functionalityprovided by the device. The TV acting as the communication hub is alwaysassigned address 0. The physical address is determined by the physicalconnection between devices.

The CEC framework described here is up to date with the CEC 2.0 specification.It is documented in the HDMI 1.4 specification with the new 2.0 bits documentedin the HDMI 2.0 specification. But for most of the features the freely availableHDMI 1.3a specification is sufficient:

5.2. CEC Adapter Interface¶

The struct cec_adapter represents the CEC adapter hardware. It is created bycalling cec_allocate_adapter() and deleted by calling cec_delete_adapter():

Driverless
struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops, void *priv, const char *name, u32 caps, u8 available_las);
void cec_delete_adapter(struct cec_adapter *adap);

To create an adapter you need to pass the following information:

ops:
adapter operations which are called by the CEC framework and that youhave to implement.
priv:
will be stored in adap->priv and can be used by the adapter ops.Use cec_get_drvdata(adap) to get the priv pointer.
name:
the name of the CEC adapter. Note: this name will be copied.
caps:
capabilities of the CEC adapter. These capabilities determine thecapabilities of the hardware and which parts are to be handledby userspace and which parts are handled by kernelspace. Thecapabilities are returned by CEC_ADAP_G_CAPS.
available_las:
the number of simultaneous logical addresses that thisadapter can handle. Must be 1 <= available_las <= CEC_MAX_LOG_ADDRS.

To obtain the priv pointer use this helper function:

void *cec_get_drvdata(const struct cec_adapter *adap);

To register the /dev/cecX device node and the remote control device (ifCEC_CAP_RC is set) you call:

int cec_register_adapter(struct cec_adapter *adap, struct device *parent);

where parent is the parent device.

To unregister the devices call:

void cec_unregister_adapter(struct cec_adapter *adap);

Note: if cec_register_adapter() fails, then call cec_delete_adapter() toclean up. But if cec_register_adapter() succeeded, then only callcec_unregister_adapter() to clean up, never cec_delete_adapter(). Theunregister function will delete the adapter automatically once the last userof that /dev/cecX device has closed its file handle.

5.3. Implementing the Low-Level CEC Adapter¶

The following low-level adapter operations have to be implemented inyour driver:

cec_adap_ops

The seven low-level ops deal with various aspects of controlling the CEC adapterhardware:

To enable/disable the hardware:

This callback enables or disables the CEC hardware. Enabling the CEC hardwaremeans powering it up in a state where no logical addresses are claimed. Thisop assumes that the physical address (adap->phys_addr) is valid when enable istrue and will not change while the CEC adapter remains enabled. The initialstate of the CEC adapter after calling cec_allocate_adapter() is disabled.

Note that adap_enable must return 0 if enable is false.

To enable/disable the ‘monitor all’ mode:

If enabled, then the adapter should be put in a mode to also monitor messagesthat are not for us. Not all hardware supports this and this function is onlycalled if the CEC_CAP_MONITOR_ALL capability is set. This callback is optional(some hardware may always be in ‘monitor all’ mode).

Note that adap_monitor_all_enable must return 0 if enable is false.

Cdc driver windows 7

To enable/disable the ‘monitor pin’ mode:

If enabled, then the adapter should be put in a mode to also monitor CEC pinchanges. Not all hardware supports this and this function is only called ifthe CEC_CAP_MONITOR_PIN capability is set. This callback is optional(some hardware may always be in ‘monitor pin’ mode).

Note that adap_monitor_pin_enable must return 0 if enable is false.

To program a new logical address:

If logical_addr CEC_LOG_ADDR_INVALID then all programmed logical addressesare to be erased. Otherwise the given logical address should be programmed.If the maximum number of available logical addresses is exceeded, then itshould return -ENXIO. Once a logical address is programmed the CEC hardwarecan receive directed messages to that address.

Note that adap_log_addr must return 0 if logical_addr is CEC_LOG_ADDR_INVALID.

To transmit a new message:

This transmits a new message. The attempts argument is the suggested number ofattempts for the transmit.

The signal_free_time is the number of data bit periods that the adapter shouldwait when the line is free before attempting to send a message. This valuedepends on whether this transmit is a retry, a message from a new initiator ora new message for the same initiator. Most hardware will handle thisautomatically, but in some cases this information is needed.

The CEC_FREE_TIME_TO_USEC macro can be used to convert signal_free_time tomicroseconds (one data bit period is 2.4 ms).

To log the current CEC hardware status:

This optional callback can be used to show the status of the CEC hardware.The status is available through debugfs: cat /sys/kernel/debug/cec/cecX/status

To free any resources when the adapter is deleted:

This optional callback can be used to free any resources that might have beenallocated by the driver. It’s called from cec_delete_adapter.

Your adapter driver will also have to react to events (typically interruptdriven) by calling into the framework in the following situations:

When a transmit finished (successfully or otherwise):

or:

The status can be one of:

CEC_TX_STATUS_OK:
the transmit was successful.
CEC_TX_STATUS_ARB_LOST:
arbitration was lost: another CEC initiatortook control of the CEC line and you lost the arbitration.
CEC_TX_STATUS_NACK:
the message was nacked (for a directed message) oracked (for a broadcast message). A retransmission is needed.
CEC_TX_STATUS_LOW_DRIVE:
low drive was detected on the CEC bus. This indicates thata follower detected an error on the bus and requested aretransmission.
CEC_TX_STATUS_ERROR:
some unspecified error occurred: this can be one of ARB_LOSTor LOW_DRIVE if the hardware cannot differentiate or somethingelse entirely. Some hardware only supports OK and FAIL as theresult of a transmit, i.e. there is no way to differentiatebetween the different possible errors. In that case map FAILto CEC_TX_STATUS_NACK and not to CEC_TX_STATUS_ERROR.
CEC_TX_STATUS_MAX_RETRIES:
could not transmit the message after trying multiple times.Should only be set by the driver if it has hardware support forretrying messages. If set, then the framework assumes that itdoesn’t have to make another attempt to transmit the messagesince the hardware did that already.

The hardware must be able to differentiate between OK, NACK and ‘somethingelse’.

The *_cnt arguments are the number of error conditions that were seen.This may be 0 if no information is available. Drivers that do not supporthardware retry can just set the counter corresponding to the transmit errorto 1, if the hardware does support retry then either set these counters to0 if the hardware provides no feedback of which errors occurred and how manytimes, or fill in the correct values as reported by the hardware.

Be aware that calling these functions can immediately start a new transmitif there is one pending in the queue. So make sure that the hardware is ina state where new transmits can be started before calling these functions.

The cec_transmit_attempt_done() function is a helper for cases where thehardware never retries, so the transmit is always for just a singleattempt. It will call cec_transmit_done() in turn, filling in 1 for thecount argument corresponding to the status. Or all 0 if the status was OK.

When a CEC message was received:

void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg);

Speaks for itself.

5.4. Implementing the interrupt handler¶

Typically the CEC hardware provides interrupts that signal when a transmitfinished and whether it was successful or not, and it provides and interruptwhen a CEC message was received.

The CEC driver should always process the transmit interrupts first beforehandling the receive interrupt. The framework expects to see the cec_transmit_donecall before the cec_received_msg call, otherwise it can get confused if thereceived message was in reply to the transmitted message.

5.5. Optional: Implementing Error Injection Support¶

If the CEC adapter supports Error Injection functionality, then that canbe exposed through the Error Injection callbacks:

If both callbacks are set, then an error-inj file will appear in debugfs.The basic syntax is as follows:

Leading spaces/tabs are ignored. If the next character is a # or the end of theline was reached, then the whole line is ignored. Otherwise a command is expected.

This basic parsing is done in the CEC Framework. It is up to the driver to decidewhat commands to implement. The only requirement is that the command clear withoutany arguments must be implemented and that it will remove all current error injectioncommands.

This ensures that you can always do echoclear>error-inj to clear any errorinjections without having to know the details of the driver-specific commands.

Note that the output of error-inj shall be valid as input to error-inj.So this must work:

The first callback is called when this file is read and it should show thecurrent error injection state:

It is recommended that it starts with a comment block with basic usageinformation. It returns 0 for success and an error otherwise.

The second callback will parse commands written to the error-inj file:

The line argument points to the start of the command. Any leadingspaces or tabs have already been skipped. It is a single line only (so thereare no embedded newlines) and it is 0-terminated. The callback is free tomodify the contents of the buffer. It is only called for lines containing acommand, so this callback is never called for empty lines or comment lines.

Return true if the command was valid or false if there were syntax errors.

5.6. Implementing the High-Level CEC Adapter¶

The low-level operations drive the hardware, the high-level operations areCEC protocol driven. The following high-level callbacks are available:

The received() callback allows the driver to optionally handle a newlyreceived CEC message:

If the driver wants to process a CEC message, then it can implement thiscallback. If it doesn’t want to handle this message, then it should return-ENOMSG, otherwise the CEC framework assumes it processed this message andit will not do anything with it.

Ces Driver

5.7. CEC framework functions¶

CEC Adapter drivers can call the following CEC framework functions:

int cec_transmit_msg(struct cec_adapter *adap, struct cec_msg *msg, bool block);

Transmit a CEC message. If block is true, then wait until the message has beentransmitted, otherwise just queue it and return.

Driver
void cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, bool block);

Change the physical address. This function will set adap->phys_addr andsend an event if it has changed. If cec_s_log_addrs() has been called andthe physical address has become valid, then the CEC framework will startclaiming the logical addresses. If block is true, then this function won’treturn until this process has finished.

When the physical address is set to a valid value the CEC adapter willbe enabled (see the adap_enable op). When it is set to CEC_PHYS_ADDR_INVALID,then the CEC adapter will be disabled. If you change a valid physical addressto another valid physical address, then this function will first set theaddress to CEC_PHYS_ADDR_INVALID before enabling the new physical address.

void cec_s_phys_addr_from_edid(struct cec_adapter *adap, const struct edid *edid);

A helper function that extracts the physical address from the edid structand calls cec_s_phys_addr() with that address, or CEC_PHYS_ADDR_INVALIDif the EDID did not contain a physical address or edid was a NULL pointer.

int cec_s_log_addrs(struct cec_adapter *adap, struct cec_log_addrs *log_addrs, bool block);

Claim the CEC logical addresses. Should never be called if CEC_CAP_LOG_ADDRSis set. If block is true, then wait until the logical addresses have beenclaimed, otherwise just queue it and return. To unconfigure all logicaladdresses call this function with log_addrs set to NULL or withlog_addrs->num_log_addrs set to 0. The block argument is ignored whenunconfiguring. This function will just return if the physical address isinvalid. Once the physical address becomes valid, then the framework willattempt to claim these logical addresses.

5.8. CEC Pin framework¶

Most CEC hardware operates on full CEC messages where the software providesthe message and the hardware handles the low-level CEC protocol. But somehardware only drives the CEC pin and software has to handle the low-levelCEC protocol. The CEC pin framework was created to handle such devices.

Note that due to the close-to-realtime requirements it can never be guaranteedto work 100%. This framework uses highres timers internally, but if atimer goes off too late by more than 300 microseconds wrong results canoccur. In reality it appears to be fairly reliable.

One advantage of this low-level implementation is that it can be used asa cheap CEC analyser, especially if interrupts can be used to detectCEC pin transitions from low to high or vice versa.

Driver
struct cec_pin_ops

low-level CEC pin operations

Definition

Members

read
read the CEC pin. Returns > 0 if high, 0 if low, or an errorif negative.
low
drive the CEC pin low.
high
stop driving the CEC pin. The pull-up will drive the pinhigh, unless someone else is driving the pin low.
enable_irq
optional, enable the interrupt to detect pin voltage changes.
disable_irq
optional, disable the interrupt.
free
optional. Free any allocated resources. Called when theadapter is deleted.
status
optional, log status information.
read_hpd
optional. Read the HPD pin. Returns > 0 if high, 0 if low oran error if negative.
read_5v
optional. Read the 5V pin. Returns > 0 if high, 0 if low oran error if negative.
received
optional. High-level CEC message callback. Allows the driverto process CEC messages.

Description

These operations (except for the received op) are used by thecec pin framework to manipulate the CEC pin.

void cec_pin_changed(struct cec_adapter *adap, bool value)

update pin state from interrupt

Parameters

structcec_adapter*adap
pointer to the cec adapter
boolvalue
when true the pin is high, otherwise it is low

Description

If changes of the CEC voltage are detected via an interrupt, thencec_pin_changed is called from the interrupt with the new value.

struct cec_adapter * cec_pin_allocate_adapter(const struct cec_pin_ops *pin_ops, void *priv, const char *name, u32 caps)

allocate a pin-based cec adapter

Cac Drivers Army

Parameters

conststructcec_pin_ops*pin_ops
low-level pin operations
void*priv
will be stored in adap->priv and can be used by the adapter ops.Use cec_get_drvdata(adap) to get the priv pointer.
constchar*name
the name of the CEC adapter. Note: this name will be copied.
u32caps
capabilities of the CEC adapter. This will be ORed withCEC_CAP_MONITOR_ALL and CEC_CAP_MONITOR_PIN.

Description

Allocate a cec adapter using the cec pin framework.

Return

a pointer to the cec adapter or an error pointer

5.9. CEC Notifier framework¶

Most drm HDMI implementations have an integrated CEC implementation and nonotifier support is needed. But some have independent CEC implementationsthat have their own driver. This could be an IP block for an SoC or acompletely separate chip that deals with the CEC pin. For those cases adrm driver can install a notifier and use the notifier to inform theCEC driver about changes in the physical address.

Windows Cdc Driver

struct cec_notifier * cec_notifier_conn_register(struct device *hdmi_dev, const char *port_name, const struct cec_connector_info *conn_info)

find or create a new cec_notifier for the given HDMI device and connector tuple.

Parameters

structdevice*hdmi_dev
HDMI device that sends the events.
constchar*port_name
the connector name from which the event occurs. May be NULLif there is always only one HDMI connector created by the HDMI device.
conststructcec_connector_info*conn_info
the connector info from which the event occurs (may be NULL)

Description

If a notifier for device dev and connector port_name already exists, thenincrease the refcount and return that notifier.

If it doesn’t exist, then allocate a new notifier struct and return apointer to that new struct.

Return NULL if the memory could not be allocated.

void cec_notifier_conn_unregister(struct cec_notifier *n)

decrease refcount and delete when the refcount reaches 0.

Parameters

structcec_notifier*n
notifier. If NULL, then this function does nothing.
struct cec_notifier * cec_notifier_cec_adap_register(struct device *hdmi_dev, const char *port_name, struct cec_adapter *adap)

find or create a new cec_notifier for the given device.

Parameters

structdevice*hdmi_dev
HDMI device that sends the events.
constchar*port_name
the connector name from which the event occurs. May be NULLif there is always only one HDMI connector created by the HDMI device.
structcec_adapter*adap
the cec adapter that registered this notifier.

Description

If a notifier for device dev and connector port_name already exists, thenincrease the refcount and return that notifier.

If it doesn’t exist, then allocate a new notifier struct and return apointer to that new struct.

Return NULL if the memory could not be allocated.

void cec_notifier_cec_adap_unregister(struct cec_notifier *n, struct cec_adapter *adap)

decrease refcount and delete when the refcount reaches 0.

Parameters

structcec_notifier*n
notifier. If NULL, then this function does nothing.
structcec_adapter*adap
the cec adapter that registered this notifier.
void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa)

set a new physical address.

Parameters

Ces driver
structcec_notifier*n
the CEC notifier
u16pa
the CEC physical address

Description

Set a new CEC physical address.Does nothing if n NULL.

void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n, const struct edid *edid)

set parse the PA from the EDID.

Parameters

structcec_notifier*n
the CEC notifier
conststructedid*edid
the struct edid pointer

Description

Parses the EDID to obtain the new CEC physical address and set it.Does nothing if n NULL.

struct device * cec_notifier_parse_hdmi_phandle(struct device *dev)

find the hdmi device from “hdmi-phandle”

Parameters

structdevice*dev
the device with the “hdmi-phandle” device tree property

Description

Returns the device pointer referenced by the “hdmi-phandle” property.Note that the refcount of the returned device is not incremented.This device pointer is only used as a key value in the notifierlist, but it is never accessed by the CEC driver.

void cec_notifier_phys_addr_invalidate(struct cec_notifier *n)

set the physical address to INVALID

Hdmi Cec Driver For Windows

Parameters

Cdc Driver Install

structcec_notifier*n
the CEC notifier

Description

This is a simple helper function to invalidate the physicaladdress. Does nothing if n NULL.

DescriptionTypeOSVersionDate
BIOS Update for Compute Stick - CCSKLm30

This download record contains options for updating the BIOS of Intel® Compute Sticks STK2m364CC and STK2m3W64CC (0064).

BIOSOS Independent0064
Latest
11/4/2020
Intel® Wireless Technology-Based Driver for Windows® 10 for STK1AW32SC

Installs the wireless (WiFi) driver for the Intel® Wireless Adapter installed in the Intel® Compute Stick STK1AW32SC.

DriverWindows 10, 32-bit*21.120.2
Latest
9/30/2020
Intel® Wireless Technology-Based Driver for Windows® 10 for STK2M3W64CC, STK2MV64CC, STK2M364CC

Installs wireless (WiFi) driver for Windows® 10, for Intel® Wireless Adapter in Intel® Compute Sticks STK2M3W64CC, STK2mV64CC, and STK2m364CC.

DriverWindows 10, 64-bit*21.120.2
Latest
9/30/2020
Intel® Wireless Bluetooth® Driver for Windows® 10 32-Bit for STK1AW32SC

Installs the Intel® PROSet/Wireless Software for Bluetooth® technology driver for the device installed in the Intel® Compute Stick STK1AW32SC.

DriverWindows 10, 32-bit*21.120.0
Latest
9/30/2020
Intel® Wireless Bluetooth® Driver for Windows® 10 for STK2m364CC, STK2m3W64CC, STK2mv64CC

Installs the Intel® PROSet/Wireless Software for Bluetooth® technology driver for the Intel® Bluetooth device installed in the Intel® Compute Sticks STK2M364CC, STK2m3W64CC, and STK2MV64CC.

DriverWindows 10, 64-bit*20.120.0
Latest
9/30/2020
Intel® Wireless Bluetooth® Driver for Windows® 10 for STK1A32SC

Installs the Intel® PROSet/Wireless Software for Bluetooth® technology-based driver for the Bluetooth® device installed in the Intel® Compute Stick STK1A32SC.

DriverWindows 10, 32-bit*
Windows 10, 64-bit*
21.120.0
Latest
9/30/2020
Intel® Wireless Technology-Based Driver for Windows® 10 for STK1A32SC

Installs the wireless driver for the Intel® Wireless Adapter installed in the Intel® Compute Stick STK1A32SC.

DriverWindows 10, 32-bit*
Windows 10, 64-bit*
21.120.2
Latest
9/30/2020
BIOS Update for Intel® Compute Stick - CCSKLm5v

This download record contains options for updating the BIOS of Intel® Compute Stick STK2mv64CC.

BIOSOS Independent0063
Latest
5/6/2020
Intel® HD Graphics Driver for Windows® 10 for Intel® Compute Stick STK2M3W64CC

Installs Intel® HD Graphics Driver for the Intel® Compute Stick STK2M3W64CC.

DriverWindows 10, 64-bit*26.20.100.7985
Latest
4/18/2020
Intel® HD Graphics Driver for Windows® 10 for Intel® Compute Stick STK2MV64CC, STK2M364CC

Installs Intel® HD Graphics Driver for the Intel® Compute Stick STK2MV64CC and STK2M364CC using Windows® 10.

DriverWindows 10, 64-bit*26.20.100.7529
Latest
4/18/2020
Intel® Integrator Toolkit

Intel® Integrator Toolkit is a command line utility used to customize BIOS on Intel® NUC and Intel® Compute Stick products.

SoftwareOS Independent6.1.10
Latest
1/22/2020
BIOS Update for Compute Stick - SCCHTAX5

This download record contains the BIOS update package for Intel® Compute Stick STK1AW32SC and STK1A32SC.

BIOSOS Independent0047
Latest
1/13/2020
BIOS Update for Compute Stick - FCBYT10H

Options for updating the BIOS of the Intel® Compute Stick STCK1A32WFC and STCK1A8LFC.

BIOSOS Independent0040
Latest
6/20/2019
Intel® Trusted Execution Engine (Intel® TXE) Driver for STK1A32SC, STK1AW32SC

This download installs the Intel® Trusted Execution Engine driver and firmware.

DriverWindows 10, 32-bit*
Windows 10, 64-bit*
Windows 8.1, 64-bit*
2.0.5.3117
Latest
5/28/2019
Intel® Software Guard Extensions (Intel® SGX) for Intel® Compute Stick

Provides Information about the Intel® Software Guard Extensions (Intel® SGX) for Intel® Compute Stick Products.

DriverOS IndependentNA
Latest
4/2/2019
Intel® Management Engine Consumer Driver for STK2m3W64CC

Installs the Intel® Management Engine (Intel® ME) components for Intel® Compute Stick STK2m3W64CC.

DriverWindows 10, 64-bit*1909.12.0.1236
Latest
3/27/2019
Intel® Management Engine Corporate Driver for STK2mv64CC

Installs the Intel® Management Engine (Intel® ME) components for Intel® Compute Stick STK2mv64CC.

DriverWindows 10, 64-bit*
Windows 10 IoT Enterprise*
Windows Embedded 8.1 Industry*
1909.12.0.1236
Latest
3/27/2019
Intel® HD Graphics Driver for Windows® 10 and Windows 8.1* for STK1A32SC

Installs the Intel® HD Graphics Driver for Intel® Compute Stick STK1A32SC.

DriverWindows 10, 32-bit*
Windows 10, 64-bit*
Windows 8.1, 32-bit*
Windows 8.1, 64-bit*
15.40.41.5058
Latest
10/5/2018
Intel® HD Graphics Driver for STK1AW32SC

Installs Intel® HD Graphics for Intel® Compute Stick STK1AW32SC.

DriverWindows 10, 32-bit*15.40.41.5058
Latest
9/27/2018
Intel® HD Graphics Driver for Windows 8.1* for STK2MV64CC, STK2M364CC

Installs Intel® HD Graphics Driver for the Intel® Compute Stick STK2MV64CC and STK2M364CC using Windows 8.1*.

DriverWindows 8.1, 64-bit*
Windows Embedded 8.1 Industry*
15.45.23.4860
Latest
12/14/2017