xref: /linux/include/uapi/linux/cec.h (revision 333ef6bd10c3ffdaf6da94e34dc6cae675ed27fc)
10dbacebeSHans Verkuil /*
20dbacebeSHans Verkuil  * cec - HDMI Consumer Electronics Control public header
30dbacebeSHans Verkuil  *
40dbacebeSHans Verkuil  * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
50dbacebeSHans Verkuil  *
60dbacebeSHans Verkuil  * This program is free software; you may redistribute it and/or modify
70dbacebeSHans Verkuil  * it under the terms of the GNU General Public License as published by
80dbacebeSHans Verkuil  * the Free Software Foundation; version 2 of the License.
90dbacebeSHans Verkuil  *
100dbacebeSHans Verkuil  * Alternatively you can redistribute this file under the terms of the
110dbacebeSHans Verkuil  * BSD license as stated below:
120dbacebeSHans Verkuil  *
130dbacebeSHans Verkuil  * Redistribution and use in source and binary forms, with or without
140dbacebeSHans Verkuil  * modification, are permitted provided that the following conditions
150dbacebeSHans Verkuil  * are met:
160dbacebeSHans Verkuil  * 1. Redistributions of source code must retain the above copyright
170dbacebeSHans Verkuil  *    notice, this list of conditions and the following disclaimer.
180dbacebeSHans Verkuil  * 2. Redistributions in binary form must reproduce the above copyright
190dbacebeSHans Verkuil  *    notice, this list of conditions and the following disclaimer in
200dbacebeSHans Verkuil  *    the documentation and/or other materials provided with the
210dbacebeSHans Verkuil  *    distribution.
220dbacebeSHans Verkuil  * 3. The names of its contributors may not be used to endorse or promote
230dbacebeSHans Verkuil  *    products derived from this software without specific prior written
240dbacebeSHans Verkuil  *    permission.
250dbacebeSHans Verkuil  *
260dbacebeSHans Verkuil  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
270dbacebeSHans Verkuil  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
280dbacebeSHans Verkuil  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
290dbacebeSHans Verkuil  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
300dbacebeSHans Verkuil  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
310dbacebeSHans Verkuil  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
320dbacebeSHans Verkuil  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
330dbacebeSHans Verkuil  * SOFTWARE.
340dbacebeSHans Verkuil  */
350dbacebeSHans Verkuil 
360dbacebeSHans Verkuil #ifndef _CEC_UAPI_H
370dbacebeSHans Verkuil #define _CEC_UAPI_H
380dbacebeSHans Verkuil 
390dbacebeSHans Verkuil #include <linux/types.h>
403145c754SHans Verkuil #include <linux/string.h>
410dbacebeSHans Verkuil 
420dbacebeSHans Verkuil #define CEC_MAX_MSG_SIZE	16
430dbacebeSHans Verkuil 
440dbacebeSHans Verkuil /**
450dbacebeSHans Verkuil  * struct cec_msg - CEC message structure.
460dbacebeSHans Verkuil  * @tx_ts:	Timestamp in nanoseconds using CLOCK_MONOTONIC. Set by the
470dbacebeSHans Verkuil  *		driver when the message transmission has finished.
480dbacebeSHans Verkuil  * @rx_ts:	Timestamp in nanoseconds using CLOCK_MONOTONIC. Set by the
490dbacebeSHans Verkuil  *		driver when the message was received.
500dbacebeSHans Verkuil  * @len:	Length in bytes of the message.
510dbacebeSHans Verkuil  * @timeout:	The timeout (in ms) that is used to timeout CEC_RECEIVE.
520dbacebeSHans Verkuil  *		Set to 0 if you want to wait forever. This timeout can also be
530dbacebeSHans Verkuil  *		used with CEC_TRANSMIT as the timeout for waiting for a reply.
540dbacebeSHans Verkuil  *		If 0, then it will use a 1 second timeout instead of waiting
550dbacebeSHans Verkuil  *		forever as is done with CEC_RECEIVE.
560dbacebeSHans Verkuil  * @sequence:	The framework assigns a sequence number to messages that are
570dbacebeSHans Verkuil  *		sent. This can be used to track replies to previously sent
580dbacebeSHans Verkuil  *		messages.
590dbacebeSHans Verkuil  * @flags:	Set to 0.
600dbacebeSHans Verkuil  * @msg:	The message payload.
610dbacebeSHans Verkuil  * @reply:	This field is ignored with CEC_RECEIVE and is only used by
620dbacebeSHans Verkuil  *		CEC_TRANSMIT. If non-zero, then wait for a reply with this
630dbacebeSHans Verkuil  *		opcode. Set to CEC_MSG_FEATURE_ABORT if you want to wait for
640dbacebeSHans Verkuil  *		a possible ABORT reply. If there was an error when sending the
650dbacebeSHans Verkuil  *		msg or FeatureAbort was returned, then reply is set to 0.
660dbacebeSHans Verkuil  *		If reply is non-zero upon return, then len/msg are set to
670dbacebeSHans Verkuil  *		the received message.
680dbacebeSHans Verkuil  *		If reply is zero upon return and status has the
690dbacebeSHans Verkuil  *		CEC_TX_STATUS_FEATURE_ABORT bit set, then len/msg are set to
700dbacebeSHans Verkuil  *		the received feature abort message.
710dbacebeSHans Verkuil  *		If reply is zero upon return and status has the
720dbacebeSHans Verkuil  *		CEC_TX_STATUS_MAX_RETRIES bit set, then no reply was seen at
730dbacebeSHans Verkuil  *		all. If reply is non-zero for CEC_TRANSMIT and the message is a
740dbacebeSHans Verkuil  *		broadcast, then -EINVAL is returned.
750dbacebeSHans Verkuil  *		if reply is non-zero, then timeout is set to 1000 (the required
760dbacebeSHans Verkuil  *		maximum response time).
770dbacebeSHans Verkuil  * @rx_status:	The message receive status bits. Set by the driver.
780dbacebeSHans Verkuil  * @tx_status:	The message transmit status bits. Set by the driver.
790dbacebeSHans Verkuil  * @tx_arb_lost_cnt: The number of 'Arbitration Lost' events. Set by the driver.
800dbacebeSHans Verkuil  * @tx_nack_cnt: The number of 'Not Acknowledged' events. Set by the driver.
810dbacebeSHans Verkuil  * @tx_low_drive_cnt: The number of 'Low Drive Detected' events. Set by the
820dbacebeSHans Verkuil  *		driver.
830dbacebeSHans Verkuil  * @tx_error_cnt: The number of 'Error' events. Set by the driver.
840dbacebeSHans Verkuil  */
850dbacebeSHans Verkuil struct cec_msg {
860dbacebeSHans Verkuil 	__u64 tx_ts;
870dbacebeSHans Verkuil 	__u64 rx_ts;
880dbacebeSHans Verkuil 	__u32 len;
890dbacebeSHans Verkuil 	__u32 timeout;
900dbacebeSHans Verkuil 	__u32 sequence;
910dbacebeSHans Verkuil 	__u32 flags;
920dbacebeSHans Verkuil 	__u8 msg[CEC_MAX_MSG_SIZE];
930dbacebeSHans Verkuil 	__u8 reply;
940dbacebeSHans Verkuil 	__u8 rx_status;
950dbacebeSHans Verkuil 	__u8 tx_status;
960dbacebeSHans Verkuil 	__u8 tx_arb_lost_cnt;
970dbacebeSHans Verkuil 	__u8 tx_nack_cnt;
980dbacebeSHans Verkuil 	__u8 tx_low_drive_cnt;
990dbacebeSHans Verkuil 	__u8 tx_error_cnt;
1000dbacebeSHans Verkuil };
1010dbacebeSHans Verkuil 
1020dbacebeSHans Verkuil /**
1030dbacebeSHans Verkuil  * cec_msg_initiator - return the initiator's logical address.
1040dbacebeSHans Verkuil  * @msg:	the message structure
1050dbacebeSHans Verkuil  */
1060dbacebeSHans Verkuil static inline __u8 cec_msg_initiator(const struct cec_msg *msg)
1070dbacebeSHans Verkuil {
1080dbacebeSHans Verkuil 	return msg->msg[0] >> 4;
1090dbacebeSHans Verkuil }
1100dbacebeSHans Verkuil 
1110dbacebeSHans Verkuil /**
1120dbacebeSHans Verkuil  * cec_msg_destination - return the destination's logical address.
1130dbacebeSHans Verkuil  * @msg:	the message structure
1140dbacebeSHans Verkuil  */
1150dbacebeSHans Verkuil static inline __u8 cec_msg_destination(const struct cec_msg *msg)
1160dbacebeSHans Verkuil {
1170dbacebeSHans Verkuil 	return msg->msg[0] & 0xf;
1180dbacebeSHans Verkuil }
1190dbacebeSHans Verkuil 
1200dbacebeSHans Verkuil /**
1210dbacebeSHans Verkuil  * cec_msg_opcode - return the opcode of the message, -1 for poll
1220dbacebeSHans Verkuil  * @msg:	the message structure
1230dbacebeSHans Verkuil  */
1240dbacebeSHans Verkuil static inline int cec_msg_opcode(const struct cec_msg *msg)
1250dbacebeSHans Verkuil {
1260dbacebeSHans Verkuil 	return msg->len > 1 ? msg->msg[1] : -1;
1270dbacebeSHans Verkuil }
1280dbacebeSHans Verkuil 
1290dbacebeSHans Verkuil /**
1300dbacebeSHans Verkuil  * cec_msg_is_broadcast - return true if this is a broadcast message.
1310dbacebeSHans Verkuil  * @msg:	the message structure
1320dbacebeSHans Verkuil  */
1333145c754SHans Verkuil static inline int cec_msg_is_broadcast(const struct cec_msg *msg)
1340dbacebeSHans Verkuil {
1350dbacebeSHans Verkuil 	return (msg->msg[0] & 0xf) == 0xf;
1360dbacebeSHans Verkuil }
1370dbacebeSHans Verkuil 
1380dbacebeSHans Verkuil /**
1390dbacebeSHans Verkuil  * cec_msg_init - initialize the message structure.
1400dbacebeSHans Verkuil  * @msg:	the message structure
1410dbacebeSHans Verkuil  * @initiator:	the logical address of the initiator
1420dbacebeSHans Verkuil  * @destination:the logical address of the destination (0xf for broadcast)
1430dbacebeSHans Verkuil  *
1440dbacebeSHans Verkuil  * The whole structure is zeroed, the len field is set to 1 (i.e. a poll
1450dbacebeSHans Verkuil  * message) and the initiator and destination are filled in.
1460dbacebeSHans Verkuil  */
1470dbacebeSHans Verkuil static inline void cec_msg_init(struct cec_msg *msg,
1480dbacebeSHans Verkuil 				__u8 initiator, __u8 destination)
1490dbacebeSHans Verkuil {
1500dbacebeSHans Verkuil 	memset(msg, 0, sizeof(*msg));
1510dbacebeSHans Verkuil 	msg->msg[0] = (initiator << 4) | destination;
1520dbacebeSHans Verkuil 	msg->len = 1;
1530dbacebeSHans Verkuil }
1540dbacebeSHans Verkuil 
1550dbacebeSHans Verkuil /**
1560dbacebeSHans Verkuil  * cec_msg_set_reply_to - fill in destination/initiator in a reply message.
1570dbacebeSHans Verkuil  * @msg:	the message structure for the reply
1580dbacebeSHans Verkuil  * @orig:	the original message structure
1590dbacebeSHans Verkuil  *
1600dbacebeSHans Verkuil  * Set the msg destination to the orig initiator and the msg initiator to the
1610dbacebeSHans Verkuil  * orig destination. Note that msg and orig may be the same pointer, in which
1620dbacebeSHans Verkuil  * case the change is done in place.
1630dbacebeSHans Verkuil  */
1640dbacebeSHans Verkuil static inline void cec_msg_set_reply_to(struct cec_msg *msg,
1650dbacebeSHans Verkuil 					struct cec_msg *orig)
1660dbacebeSHans Verkuil {
1670dbacebeSHans Verkuil 	/* The destination becomes the initiator and vice versa */
1680dbacebeSHans Verkuil 	msg->msg[0] = (cec_msg_destination(orig) << 4) |
1690dbacebeSHans Verkuil 		      cec_msg_initiator(orig);
1700dbacebeSHans Verkuil 	msg->reply = msg->timeout = 0;
1710dbacebeSHans Verkuil }
1720dbacebeSHans Verkuil 
1730dbacebeSHans Verkuil /* cec_msg flags field */
1740dbacebeSHans Verkuil #define CEC_MSG_FL_REPLY_TO_FOLLOWERS	(1 << 0)
1750dbacebeSHans Verkuil 
1760dbacebeSHans Verkuil /* cec_msg tx/rx_status field */
1770dbacebeSHans Verkuil #define CEC_TX_STATUS_OK		(1 << 0)
1780dbacebeSHans Verkuil #define CEC_TX_STATUS_ARB_LOST		(1 << 1)
1790dbacebeSHans Verkuil #define CEC_TX_STATUS_NACK		(1 << 2)
1800dbacebeSHans Verkuil #define CEC_TX_STATUS_LOW_DRIVE		(1 << 3)
1810dbacebeSHans Verkuil #define CEC_TX_STATUS_ERROR		(1 << 4)
1820dbacebeSHans Verkuil #define CEC_TX_STATUS_MAX_RETRIES	(1 << 5)
1830dbacebeSHans Verkuil 
1840dbacebeSHans Verkuil #define CEC_RX_STATUS_OK		(1 << 0)
1850dbacebeSHans Verkuil #define CEC_RX_STATUS_TIMEOUT		(1 << 1)
1860dbacebeSHans Verkuil #define CEC_RX_STATUS_FEATURE_ABORT	(1 << 2)
1870dbacebeSHans Verkuil 
1883145c754SHans Verkuil static inline int cec_msg_status_is_ok(const struct cec_msg *msg)
1890dbacebeSHans Verkuil {
1900dbacebeSHans Verkuil 	if (msg->tx_status && !(msg->tx_status & CEC_TX_STATUS_OK))
1913145c754SHans Verkuil 		return 0;
1920dbacebeSHans Verkuil 	if (msg->rx_status && !(msg->rx_status & CEC_RX_STATUS_OK))
1933145c754SHans Verkuil 		return 0;
1940dbacebeSHans Verkuil 	if (!msg->tx_status && !msg->rx_status)
1953145c754SHans Verkuil 		return 0;
1960dbacebeSHans Verkuil 	return !(msg->rx_status & CEC_RX_STATUS_FEATURE_ABORT);
1970dbacebeSHans Verkuil }
1980dbacebeSHans Verkuil 
1990dbacebeSHans Verkuil #define CEC_LOG_ADDR_INVALID		0xff
2000dbacebeSHans Verkuil #define CEC_PHYS_ADDR_INVALID		0xffff
2010dbacebeSHans Verkuil 
2020dbacebeSHans Verkuil /*
2030dbacebeSHans Verkuil  * The maximum number of logical addresses one device can be assigned to.
2040dbacebeSHans Verkuil  * The CEC 2.0 spec allows for only 2 logical addresses at the moment. The
2050dbacebeSHans Verkuil  * Analog Devices CEC hardware supports 3. So let's go wild and go for 4.
2060dbacebeSHans Verkuil  */
2070dbacebeSHans Verkuil #define CEC_MAX_LOG_ADDRS 4
2080dbacebeSHans Verkuil 
2090dbacebeSHans Verkuil /* The logical addresses defined by CEC 2.0 */
2100dbacebeSHans Verkuil #define CEC_LOG_ADDR_TV			0
2110dbacebeSHans Verkuil #define CEC_LOG_ADDR_RECORD_1		1
2120dbacebeSHans Verkuil #define CEC_LOG_ADDR_RECORD_2		2
2130dbacebeSHans Verkuil #define CEC_LOG_ADDR_TUNER_1		3
2140dbacebeSHans Verkuil #define CEC_LOG_ADDR_PLAYBACK_1		4
2150dbacebeSHans Verkuil #define CEC_LOG_ADDR_AUDIOSYSTEM	5
2160dbacebeSHans Verkuil #define CEC_LOG_ADDR_TUNER_2		6
2170dbacebeSHans Verkuil #define CEC_LOG_ADDR_TUNER_3		7
2180dbacebeSHans Verkuil #define CEC_LOG_ADDR_PLAYBACK_2		8
2190dbacebeSHans Verkuil #define CEC_LOG_ADDR_RECORD_3		9
2200dbacebeSHans Verkuil #define CEC_LOG_ADDR_TUNER_4		10
2210dbacebeSHans Verkuil #define CEC_LOG_ADDR_PLAYBACK_3		11
2220dbacebeSHans Verkuil #define CEC_LOG_ADDR_BACKUP_1		12
2230dbacebeSHans Verkuil #define CEC_LOG_ADDR_BACKUP_2		13
2240dbacebeSHans Verkuil #define CEC_LOG_ADDR_SPECIFIC		14
2250dbacebeSHans Verkuil #define CEC_LOG_ADDR_UNREGISTERED	15 /* as initiator address */
2266e9b73c6SHans Verkuil #define CEC_LOG_ADDR_BROADCAST		15 /* as destination address */
2270dbacebeSHans Verkuil 
2280dbacebeSHans Verkuil /* The logical address types that the CEC device wants to claim */
2290dbacebeSHans Verkuil #define CEC_LOG_ADDR_TYPE_TV		0
2300dbacebeSHans Verkuil #define CEC_LOG_ADDR_TYPE_RECORD	1
2310dbacebeSHans Verkuil #define CEC_LOG_ADDR_TYPE_TUNER		2
2320dbacebeSHans Verkuil #define CEC_LOG_ADDR_TYPE_PLAYBACK	3
2330dbacebeSHans Verkuil #define CEC_LOG_ADDR_TYPE_AUDIOSYSTEM	4
2340dbacebeSHans Verkuil #define CEC_LOG_ADDR_TYPE_SPECIFIC	5
2350dbacebeSHans Verkuil #define CEC_LOG_ADDR_TYPE_UNREGISTERED	6
2360dbacebeSHans Verkuil /*
2370dbacebeSHans Verkuil  * Switches should use UNREGISTERED.
2380dbacebeSHans Verkuil  * Processors should use SPECIFIC.
2390dbacebeSHans Verkuil  */
2400dbacebeSHans Verkuil 
2410dbacebeSHans Verkuil #define CEC_LOG_ADDR_MASK_TV		(1 << CEC_LOG_ADDR_TV)
2420dbacebeSHans Verkuil #define CEC_LOG_ADDR_MASK_RECORD	((1 << CEC_LOG_ADDR_RECORD_1) | \
2430dbacebeSHans Verkuil 					 (1 << CEC_LOG_ADDR_RECORD_2) | \
2440dbacebeSHans Verkuil 					 (1 << CEC_LOG_ADDR_RECORD_3))
2450dbacebeSHans Verkuil #define CEC_LOG_ADDR_MASK_TUNER		((1 << CEC_LOG_ADDR_TUNER_1) | \
2460dbacebeSHans Verkuil 					 (1 << CEC_LOG_ADDR_TUNER_2) | \
2470dbacebeSHans Verkuil 					 (1 << CEC_LOG_ADDR_TUNER_3) | \
2480dbacebeSHans Verkuil 					 (1 << CEC_LOG_ADDR_TUNER_4))
2490dbacebeSHans Verkuil #define CEC_LOG_ADDR_MASK_PLAYBACK	((1 << CEC_LOG_ADDR_PLAYBACK_1) | \
2500dbacebeSHans Verkuil 					 (1 << CEC_LOG_ADDR_PLAYBACK_2) | \
2510dbacebeSHans Verkuil 					 (1 << CEC_LOG_ADDR_PLAYBACK_3))
2520dbacebeSHans Verkuil #define CEC_LOG_ADDR_MASK_AUDIOSYSTEM	(1 << CEC_LOG_ADDR_AUDIOSYSTEM)
2530dbacebeSHans Verkuil #define CEC_LOG_ADDR_MASK_BACKUP	((1 << CEC_LOG_ADDR_BACKUP_1) | \
2540dbacebeSHans Verkuil 					 (1 << CEC_LOG_ADDR_BACKUP_2))
2550dbacebeSHans Verkuil #define CEC_LOG_ADDR_MASK_SPECIFIC	(1 << CEC_LOG_ADDR_SPECIFIC)
2560dbacebeSHans Verkuil #define CEC_LOG_ADDR_MASK_UNREGISTERED	(1 << CEC_LOG_ADDR_UNREGISTERED)
2570dbacebeSHans Verkuil 
2583145c754SHans Verkuil static inline int cec_has_tv(__u16 log_addr_mask)
2590dbacebeSHans Verkuil {
2600dbacebeSHans Verkuil 	return log_addr_mask & CEC_LOG_ADDR_MASK_TV;
2610dbacebeSHans Verkuil }
2620dbacebeSHans Verkuil 
2633145c754SHans Verkuil static inline int cec_has_record(__u16 log_addr_mask)
2640dbacebeSHans Verkuil {
2650dbacebeSHans Verkuil 	return log_addr_mask & CEC_LOG_ADDR_MASK_RECORD;
2660dbacebeSHans Verkuil }
2670dbacebeSHans Verkuil 
2683145c754SHans Verkuil static inline int cec_has_tuner(__u16 log_addr_mask)
2690dbacebeSHans Verkuil {
2700dbacebeSHans Verkuil 	return log_addr_mask & CEC_LOG_ADDR_MASK_TUNER;
2710dbacebeSHans Verkuil }
2720dbacebeSHans Verkuil 
2733145c754SHans Verkuil static inline int cec_has_playback(__u16 log_addr_mask)
2740dbacebeSHans Verkuil {
2750dbacebeSHans Verkuil 	return log_addr_mask & CEC_LOG_ADDR_MASK_PLAYBACK;
2760dbacebeSHans Verkuil }
2770dbacebeSHans Verkuil 
2783145c754SHans Verkuil static inline int cec_has_audiosystem(__u16 log_addr_mask)
2790dbacebeSHans Verkuil {
2800dbacebeSHans Verkuil 	return log_addr_mask & CEC_LOG_ADDR_MASK_AUDIOSYSTEM;
2810dbacebeSHans Verkuil }
2820dbacebeSHans Verkuil 
2833145c754SHans Verkuil static inline int cec_has_backup(__u16 log_addr_mask)
2840dbacebeSHans Verkuil {
2850dbacebeSHans Verkuil 	return log_addr_mask & CEC_LOG_ADDR_MASK_BACKUP;
2860dbacebeSHans Verkuil }
2870dbacebeSHans Verkuil 
2883145c754SHans Verkuil static inline int cec_has_specific(__u16 log_addr_mask)
2890dbacebeSHans Verkuil {
2900dbacebeSHans Verkuil 	return log_addr_mask & CEC_LOG_ADDR_MASK_SPECIFIC;
2910dbacebeSHans Verkuil }
2920dbacebeSHans Verkuil 
2933145c754SHans Verkuil static inline int cec_is_unregistered(__u16 log_addr_mask)
2940dbacebeSHans Verkuil {
2950dbacebeSHans Verkuil 	return log_addr_mask & CEC_LOG_ADDR_MASK_UNREGISTERED;
2960dbacebeSHans Verkuil }
2970dbacebeSHans Verkuil 
2983145c754SHans Verkuil static inline int cec_is_unconfigured(__u16 log_addr_mask)
2990dbacebeSHans Verkuil {
3000dbacebeSHans Verkuil 	return log_addr_mask == 0;
3010dbacebeSHans Verkuil }
3020dbacebeSHans Verkuil 
3030dbacebeSHans Verkuil /*
3040dbacebeSHans Verkuil  * Use this if there is no vendor ID (CEC_G_VENDOR_ID) or if the vendor ID
3050dbacebeSHans Verkuil  * should be disabled (CEC_S_VENDOR_ID)
3060dbacebeSHans Verkuil  */
3070dbacebeSHans Verkuil #define CEC_VENDOR_ID_NONE		0xffffffff
3080dbacebeSHans Verkuil 
3090dbacebeSHans Verkuil /* The message handling modes */
3100dbacebeSHans Verkuil /* Modes for initiator */
3110dbacebeSHans Verkuil #define CEC_MODE_NO_INITIATOR		(0x0 << 0)
3120dbacebeSHans Verkuil #define CEC_MODE_INITIATOR		(0x1 << 0)
3130dbacebeSHans Verkuil #define CEC_MODE_EXCL_INITIATOR		(0x2 << 0)
3140dbacebeSHans Verkuil #define CEC_MODE_INITIATOR_MSK		0x0f
3150dbacebeSHans Verkuil 
3160dbacebeSHans Verkuil /* Modes for follower */
3170dbacebeSHans Verkuil #define CEC_MODE_NO_FOLLOWER		(0x0 << 4)
3180dbacebeSHans Verkuil #define CEC_MODE_FOLLOWER		(0x1 << 4)
3190dbacebeSHans Verkuil #define CEC_MODE_EXCL_FOLLOWER		(0x2 << 4)
3200dbacebeSHans Verkuil #define CEC_MODE_EXCL_FOLLOWER_PASSTHRU	(0x3 << 4)
3216303d978SHans Verkuil #define CEC_MODE_MONITOR_PIN		(0xd << 4)
3220dbacebeSHans Verkuil #define CEC_MODE_MONITOR		(0xe << 4)
3230dbacebeSHans Verkuil #define CEC_MODE_MONITOR_ALL		(0xf << 4)
3240dbacebeSHans Verkuil #define CEC_MODE_FOLLOWER_MSK		0xf0
3250dbacebeSHans Verkuil 
3260dbacebeSHans Verkuil /* Userspace has to configure the physical address */
3270dbacebeSHans Verkuil #define CEC_CAP_PHYS_ADDR	(1 << 0)
3280dbacebeSHans Verkuil /* Userspace has to configure the logical addresses */
3290dbacebeSHans Verkuil #define CEC_CAP_LOG_ADDRS	(1 << 1)
3300dbacebeSHans Verkuil /* Userspace can transmit messages (and thus become follower as well) */
3310dbacebeSHans Verkuil #define CEC_CAP_TRANSMIT	(1 << 2)
3320dbacebeSHans Verkuil /*
3330dbacebeSHans Verkuil  * Passthrough all messages instead of processing them.
3340dbacebeSHans Verkuil  */
3350dbacebeSHans Verkuil #define CEC_CAP_PASSTHROUGH	(1 << 3)
3360dbacebeSHans Verkuil /* Supports remote control */
3370dbacebeSHans Verkuil #define CEC_CAP_RC		(1 << 4)
3380dbacebeSHans Verkuil /* Hardware can monitor all messages, not just directed and broadcast. */
3390dbacebeSHans Verkuil #define CEC_CAP_MONITOR_ALL	(1 << 5)
340f902c1e9SHans Verkuil /* Hardware can use CEC only if the HDMI HPD pin is high. */
341f902c1e9SHans Verkuil #define CEC_CAP_NEEDS_HPD	(1 << 6)
3426303d978SHans Verkuil /* Hardware can monitor CEC pin transitions */
3436303d978SHans Verkuil #define CEC_CAP_MONITOR_PIN	(1 << 7)
3440dbacebeSHans Verkuil 
3450dbacebeSHans Verkuil /**
3460dbacebeSHans Verkuil  * struct cec_caps - CEC capabilities structure.
3470dbacebeSHans Verkuil  * @driver: name of the CEC device driver.
3480dbacebeSHans Verkuil  * @name: name of the CEC device. @driver + @name must be unique.
3490dbacebeSHans Verkuil  * @available_log_addrs: number of available logical addresses.
3500dbacebeSHans Verkuil  * @capabilities: capabilities of the CEC adapter.
3510dbacebeSHans Verkuil  * @version: version of the CEC adapter framework.
3520dbacebeSHans Verkuil  */
3530dbacebeSHans Verkuil struct cec_caps {
3540dbacebeSHans Verkuil 	char driver[32];
3550dbacebeSHans Verkuil 	char name[32];
3560dbacebeSHans Verkuil 	__u32 available_log_addrs;
3570dbacebeSHans Verkuil 	__u32 capabilities;
3580dbacebeSHans Verkuil 	__u32 version;
3590dbacebeSHans Verkuil };
3600dbacebeSHans Verkuil 
3610dbacebeSHans Verkuil /**
3620dbacebeSHans Verkuil  * struct cec_log_addrs - CEC logical addresses structure.
3630dbacebeSHans Verkuil  * @log_addr: the claimed logical addresses. Set by the driver.
3640dbacebeSHans Verkuil  * @log_addr_mask: current logical address mask. Set by the driver.
3650dbacebeSHans Verkuil  * @cec_version: the CEC version that the adapter should implement. Set by the
3660dbacebeSHans Verkuil  *	caller.
3670dbacebeSHans Verkuil  * @num_log_addrs: how many logical addresses should be claimed. Set by the
3680dbacebeSHans Verkuil  *	caller.
3690dbacebeSHans Verkuil  * @vendor_id: the vendor ID of the device. Set by the caller.
3700dbacebeSHans Verkuil  * @flags: flags.
3710dbacebeSHans Verkuil  * @osd_name: the OSD name of the device. Set by the caller.
3720dbacebeSHans Verkuil  * @primary_device_type: the primary device type for each logical address.
3730dbacebeSHans Verkuil  *	Set by the caller.
3740dbacebeSHans Verkuil  * @log_addr_type: the logical address types. Set by the caller.
3750dbacebeSHans Verkuil  * @all_device_types: CEC 2.0: all device types represented by the logical
3760dbacebeSHans Verkuil  *	address. Set by the caller.
3770dbacebeSHans Verkuil  * @features:	CEC 2.0: The logical address features. Set by the caller.
3780dbacebeSHans Verkuil  */
3790dbacebeSHans Verkuil struct cec_log_addrs {
3800dbacebeSHans Verkuil 	__u8 log_addr[CEC_MAX_LOG_ADDRS];
3810dbacebeSHans Verkuil 	__u16 log_addr_mask;
3820dbacebeSHans Verkuil 	__u8 cec_version;
3830dbacebeSHans Verkuil 	__u8 num_log_addrs;
3840dbacebeSHans Verkuil 	__u32 vendor_id;
3850dbacebeSHans Verkuil 	__u32 flags;
3860dbacebeSHans Verkuil 	char osd_name[15];
3870dbacebeSHans Verkuil 	__u8 primary_device_type[CEC_MAX_LOG_ADDRS];
3880dbacebeSHans Verkuil 	__u8 log_addr_type[CEC_MAX_LOG_ADDRS];
3890dbacebeSHans Verkuil 
3900dbacebeSHans Verkuil 	/* CEC 2.0 */
3910dbacebeSHans Verkuil 	__u8 all_device_types[CEC_MAX_LOG_ADDRS];
3920dbacebeSHans Verkuil 	__u8 features[CEC_MAX_LOG_ADDRS][12];
3930dbacebeSHans Verkuil };
3940dbacebeSHans Verkuil 
3950dbacebeSHans Verkuil /* Allow a fallback to unregistered */
3960dbacebeSHans Verkuil #define CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK	(1 << 0)
3970dbacebeSHans Verkuil /* Passthrough RC messages to the input subsystem */
3980dbacebeSHans Verkuil #define CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU	(1 << 1)
3990dbacebeSHans Verkuil /* CDC-Only device: supports only CDC messages */
4000dbacebeSHans Verkuil #define CEC_LOG_ADDRS_FL_CDC_ONLY		(1 << 2)
4010dbacebeSHans Verkuil 
4020dbacebeSHans Verkuil /* Events */
4030dbacebeSHans Verkuil 
4040dbacebeSHans Verkuil /* Event that occurs when the adapter state changes */
4050dbacebeSHans Verkuil #define CEC_EVENT_STATE_CHANGE		1
4060dbacebeSHans Verkuil /*
4070dbacebeSHans Verkuil  * This event is sent when messages are lost because the application
4080dbacebeSHans Verkuil  * didn't empty the message queue in time
4090dbacebeSHans Verkuil  */
4100dbacebeSHans Verkuil #define CEC_EVENT_LOST_MSGS		2
4119a6b2a87SHans Verkuil #define CEC_EVENT_PIN_CEC_LOW		3
4129a6b2a87SHans Verkuil #define CEC_EVENT_PIN_CEC_HIGH		4
413*333ef6bdSHans Verkuil #define CEC_EVENT_PIN_HPD_LOW		5
414*333ef6bdSHans Verkuil #define CEC_EVENT_PIN_HPD_HIGH		6
4150dbacebeSHans Verkuil 
4160dbacebeSHans Verkuil #define CEC_EVENT_FL_INITIAL_STATE	(1 << 0)
4176b2bbb08SHans Verkuil #define CEC_EVENT_FL_DROPPED_EVENTS	(1 << 1)
4180dbacebeSHans Verkuil 
4190dbacebeSHans Verkuil /**
4200dbacebeSHans Verkuil  * struct cec_event_state_change - used when the CEC adapter changes state.
4210dbacebeSHans Verkuil  * @phys_addr: the current physical address
4220dbacebeSHans Verkuil  * @log_addr_mask: the current logical address mask
4230dbacebeSHans Verkuil  */
4240dbacebeSHans Verkuil struct cec_event_state_change {
4250dbacebeSHans Verkuil 	__u16 phys_addr;
4260dbacebeSHans Verkuil 	__u16 log_addr_mask;
4270dbacebeSHans Verkuil };
4280dbacebeSHans Verkuil 
4290dbacebeSHans Verkuil /**
4306b2bbb08SHans Verkuil  * struct cec_event_lost_msgs - tells you how many messages were lost.
4310dbacebeSHans Verkuil  * @lost_msgs: how many messages were lost.
4320dbacebeSHans Verkuil  */
4330dbacebeSHans Verkuil struct cec_event_lost_msgs {
4340dbacebeSHans Verkuil 	__u32 lost_msgs;
4350dbacebeSHans Verkuil };
4360dbacebeSHans Verkuil 
4370dbacebeSHans Verkuil /**
4380dbacebeSHans Verkuil  * struct cec_event - CEC event structure
4390dbacebeSHans Verkuil  * @ts: the timestamp of when the event was sent.
4400dbacebeSHans Verkuil  * @event: the event.
4410dbacebeSHans Verkuil  * array.
4420dbacebeSHans Verkuil  * @state_change: the event payload for CEC_EVENT_STATE_CHANGE.
4430dbacebeSHans Verkuil  * @lost_msgs: the event payload for CEC_EVENT_LOST_MSGS.
4440dbacebeSHans Verkuil  * @raw: array to pad the union.
4450dbacebeSHans Verkuil  */
4460dbacebeSHans Verkuil struct cec_event {
4470dbacebeSHans Verkuil 	__u64 ts;
4480dbacebeSHans Verkuil 	__u32 event;
4490dbacebeSHans Verkuil 	__u32 flags;
4500dbacebeSHans Verkuil 	union {
4510dbacebeSHans Verkuil 		struct cec_event_state_change state_change;
4520dbacebeSHans Verkuil 		struct cec_event_lost_msgs lost_msgs;
4530dbacebeSHans Verkuil 		__u32 raw[16];
4540dbacebeSHans Verkuil 	};
4550dbacebeSHans Verkuil };
4560dbacebeSHans Verkuil 
4570dbacebeSHans Verkuil /* ioctls */
4580dbacebeSHans Verkuil 
4590dbacebeSHans Verkuil /* Adapter capabilities */
4600dbacebeSHans Verkuil #define CEC_ADAP_G_CAPS		_IOWR('a',  0, struct cec_caps)
4610dbacebeSHans Verkuil 
4620dbacebeSHans Verkuil /*
4630dbacebeSHans Verkuil  * phys_addr is either 0 (if this is the CEC root device)
4640dbacebeSHans Verkuil  * or a valid physical address obtained from the sink's EDID
4650dbacebeSHans Verkuil  * as read by this CEC device (if this is a source device)
4660dbacebeSHans Verkuil  * or a physical address obtained and modified from a sink
4670dbacebeSHans Verkuil  * EDID and used for a sink CEC device.
4680dbacebeSHans Verkuil  * If nothing is connected, then phys_addr is 0xffff.
4690dbacebeSHans Verkuil  * See HDMI 1.4b, section 8.7 (Physical Address).
4700dbacebeSHans Verkuil  *
4710dbacebeSHans Verkuil  * The CEC_ADAP_S_PHYS_ADDR ioctl may not be available if that is handled
4720dbacebeSHans Verkuil  * internally.
4730dbacebeSHans Verkuil  */
4740dbacebeSHans Verkuil #define CEC_ADAP_G_PHYS_ADDR	_IOR('a',  1, __u16)
4750dbacebeSHans Verkuil #define CEC_ADAP_S_PHYS_ADDR	_IOW('a',  2, __u16)
4760dbacebeSHans Verkuil 
4770dbacebeSHans Verkuil /*
4780dbacebeSHans Verkuil  * Configure the CEC adapter. It sets the device type and which
4790dbacebeSHans Verkuil  * logical types it will try to claim. It will return which
4800dbacebeSHans Verkuil  * logical addresses it could actually claim.
4810dbacebeSHans Verkuil  * An error is returned if the adapter is disabled or if there
4820dbacebeSHans Verkuil  * is no physical address assigned.
4830dbacebeSHans Verkuil  */
4840dbacebeSHans Verkuil 
4850dbacebeSHans Verkuil #define CEC_ADAP_G_LOG_ADDRS	_IOR('a',  3, struct cec_log_addrs)
4860dbacebeSHans Verkuil #define CEC_ADAP_S_LOG_ADDRS	_IOWR('a',  4, struct cec_log_addrs)
4870dbacebeSHans Verkuil 
4880dbacebeSHans Verkuil /* Transmit/receive a CEC command */
4890dbacebeSHans Verkuil #define CEC_TRANSMIT		_IOWR('a',  5, struct cec_msg)
4900dbacebeSHans Verkuil #define CEC_RECEIVE		_IOWR('a',  6, struct cec_msg)
4910dbacebeSHans Verkuil 
4920dbacebeSHans Verkuil /* Dequeue CEC events */
4930dbacebeSHans Verkuil #define CEC_DQEVENT		_IOWR('a',  7, struct cec_event)
4940dbacebeSHans Verkuil 
4950dbacebeSHans Verkuil /*
4960dbacebeSHans Verkuil  * Get and set the message handling mode for this filehandle.
4970dbacebeSHans Verkuil  */
4980dbacebeSHans Verkuil #define CEC_G_MODE		_IOR('a',  8, __u32)
4990dbacebeSHans Verkuil #define CEC_S_MODE		_IOW('a',  9, __u32)
5000dbacebeSHans Verkuil 
5010dbacebeSHans Verkuil /*
5020dbacebeSHans Verkuil  * The remainder of this header defines all CEC messages and operands.
5030dbacebeSHans Verkuil  * The format matters since it the cec-ctl utility parses it to generate
5040dbacebeSHans Verkuil  * code for implementing all these messages.
5050dbacebeSHans Verkuil  *
5060dbacebeSHans Verkuil  * Comments ending with 'Feature' group messages for each feature.
5070dbacebeSHans Verkuil  * If messages are part of multiple features, then the "Has also"
5080dbacebeSHans Verkuil  * comment is used to list the previously defined messages that are
5090dbacebeSHans Verkuil  * supported by the feature.
5100dbacebeSHans Verkuil  *
5110dbacebeSHans Verkuil  * Before operands are defined a comment is added that gives the
5120dbacebeSHans Verkuil  * name of the operand and in brackets the variable name of the
5130dbacebeSHans Verkuil  * corresponding argument in the cec-funcs.h function.
5140dbacebeSHans Verkuil  */
5150dbacebeSHans Verkuil 
5160dbacebeSHans Verkuil /* Messages */
5170dbacebeSHans Verkuil 
5180dbacebeSHans Verkuil /* One Touch Play Feature */
5190dbacebeSHans Verkuil #define CEC_MSG_ACTIVE_SOURCE				0x82
5200dbacebeSHans Verkuil #define CEC_MSG_IMAGE_VIEW_ON				0x04
5210dbacebeSHans Verkuil #define CEC_MSG_TEXT_VIEW_ON				0x0d
5220dbacebeSHans Verkuil 
5230dbacebeSHans Verkuil 
5240dbacebeSHans Verkuil /* Routing Control Feature */
5250dbacebeSHans Verkuil 
5260dbacebeSHans Verkuil /*
5270dbacebeSHans Verkuil  * Has also:
5280dbacebeSHans Verkuil  *	CEC_MSG_ACTIVE_SOURCE
5290dbacebeSHans Verkuil  */
5300dbacebeSHans Verkuil 
5310dbacebeSHans Verkuil #define CEC_MSG_INACTIVE_SOURCE				0x9d
5320dbacebeSHans Verkuil #define CEC_MSG_REQUEST_ACTIVE_SOURCE			0x85
5330dbacebeSHans Verkuil #define CEC_MSG_ROUTING_CHANGE				0x80
5340dbacebeSHans Verkuil #define CEC_MSG_ROUTING_INFORMATION			0x81
5350dbacebeSHans Verkuil #define CEC_MSG_SET_STREAM_PATH				0x86
5360dbacebeSHans Verkuil 
5370dbacebeSHans Verkuil 
5380dbacebeSHans Verkuil /* Standby Feature */
5390dbacebeSHans Verkuil #define CEC_MSG_STANDBY					0x36
5400dbacebeSHans Verkuil 
5410dbacebeSHans Verkuil 
5420dbacebeSHans Verkuil /* One Touch Record Feature */
5430dbacebeSHans Verkuil #define CEC_MSG_RECORD_OFF				0x0b
5440dbacebeSHans Verkuil #define CEC_MSG_RECORD_ON				0x09
5450dbacebeSHans Verkuil /* Record Source Type Operand (rec_src_type) */
5460dbacebeSHans Verkuil #define CEC_OP_RECORD_SRC_OWN				1
5470dbacebeSHans Verkuil #define CEC_OP_RECORD_SRC_DIGITAL			2
5480dbacebeSHans Verkuil #define CEC_OP_RECORD_SRC_ANALOG			3
5490dbacebeSHans Verkuil #define CEC_OP_RECORD_SRC_EXT_PLUG			4
5500dbacebeSHans Verkuil #define CEC_OP_RECORD_SRC_EXT_PHYS_ADDR			5
5510dbacebeSHans Verkuil /* Service Identification Method Operand (service_id_method) */
5520dbacebeSHans Verkuil #define CEC_OP_SERVICE_ID_METHOD_BY_DIG_ID		0
5530dbacebeSHans Verkuil #define CEC_OP_SERVICE_ID_METHOD_BY_CHANNEL		1
5540dbacebeSHans Verkuil /* Digital Service Broadcast System Operand (dig_bcast_system) */
5550dbacebeSHans Verkuil #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ARIB_GEN	0x00
5560dbacebeSHans Verkuil #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_GEN	0x01
5570dbacebeSHans Verkuil #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_GEN		0x02
5580dbacebeSHans Verkuil #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ARIB_BS		0x08
5590dbacebeSHans Verkuil #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ARIB_CS		0x09
5600dbacebeSHans Verkuil #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ARIB_T		0x0a
5610dbacebeSHans Verkuil #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_CABLE	0x10
5620dbacebeSHans Verkuil #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_SAT	0x11
5630dbacebeSHans Verkuil #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_T		0x12
5640dbacebeSHans Verkuil #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_C		0x18
5650dbacebeSHans Verkuil #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_S		0x19
5660dbacebeSHans Verkuil #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_S2		0x1a
5670dbacebeSHans Verkuil #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_T		0x1b
5680dbacebeSHans Verkuil /* Analogue Broadcast Type Operand (ana_bcast_type) */
5690dbacebeSHans Verkuil #define CEC_OP_ANA_BCAST_TYPE_CABLE			0
5700dbacebeSHans Verkuil #define CEC_OP_ANA_BCAST_TYPE_SATELLITE			1
5710dbacebeSHans Verkuil #define CEC_OP_ANA_BCAST_TYPE_TERRESTRIAL		2
5720dbacebeSHans Verkuil /* Broadcast System Operand (bcast_system) */
5730dbacebeSHans Verkuil #define CEC_OP_BCAST_SYSTEM_PAL_BG			0x00
5740dbacebeSHans Verkuil #define CEC_OP_BCAST_SYSTEM_SECAM_LQ			0x01 /* SECAM L' */
5750dbacebeSHans Verkuil #define CEC_OP_BCAST_SYSTEM_PAL_M			0x02
5760dbacebeSHans Verkuil #define CEC_OP_BCAST_SYSTEM_NTSC_M			0x03
5770dbacebeSHans Verkuil #define CEC_OP_BCAST_SYSTEM_PAL_I			0x04
5780dbacebeSHans Verkuil #define CEC_OP_BCAST_SYSTEM_SECAM_DK			0x05
5790dbacebeSHans Verkuil #define CEC_OP_BCAST_SYSTEM_SECAM_BG			0x06
5800dbacebeSHans Verkuil #define CEC_OP_BCAST_SYSTEM_SECAM_L			0x07
5810dbacebeSHans Verkuil #define CEC_OP_BCAST_SYSTEM_PAL_DK			0x08
5820dbacebeSHans Verkuil #define CEC_OP_BCAST_SYSTEM_OTHER			0x1f
5830dbacebeSHans Verkuil /* Channel Number Format Operand (channel_number_fmt) */
5840dbacebeSHans Verkuil #define CEC_OP_CHANNEL_NUMBER_FMT_1_PART		0x01
5850dbacebeSHans Verkuil #define CEC_OP_CHANNEL_NUMBER_FMT_2_PART		0x02
5860dbacebeSHans Verkuil 
5870dbacebeSHans Verkuil #define CEC_MSG_RECORD_STATUS				0x0a
5880dbacebeSHans Verkuil /* Record Status Operand (rec_status) */
5890dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_CUR_SRC			0x01
5900dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_DIG_SERVICE		0x02
5910dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_ANA_SERVICE		0x03
5920dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_EXT_INPUT			0x04
5930dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_NO_DIG_SERVICE		0x05
5940dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_NO_ANA_SERVICE		0x06
5950dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_NO_SERVICE			0x07
5960dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_INVALID_EXT_PLUG		0x09
5970dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_INVALID_EXT_PHYS_ADDR	0x0a
5980dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_UNSUP_CA			0x0b
5990dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_NO_CA_ENTITLEMENTS		0x0c
6000dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_CANT_COPY_SRC		0x0d
6010dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_NO_MORE_COPIES		0x0e
6020dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_NO_MEDIA			0x10
6030dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_PLAYING			0x11
6040dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_ALREADY_RECORDING		0x12
6050dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_MEDIA_PROT			0x13
6060dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_NO_SIGNAL			0x14
6070dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_MEDIA_PROBLEM		0x15
6080dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_NO_SPACE			0x16
6090dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_PARENTAL_LOCK		0x17
6100dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_TERMINATED_OK		0x1a
6110dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_ALREADY_TERM		0x1b
6120dbacebeSHans Verkuil #define CEC_OP_RECORD_STATUS_OTHER			0x1f
6130dbacebeSHans Verkuil 
6140dbacebeSHans Verkuil #define CEC_MSG_RECORD_TV_SCREEN			0x0f
6150dbacebeSHans Verkuil 
6160dbacebeSHans Verkuil 
6170dbacebeSHans Verkuil /* Timer Programming Feature */
6180dbacebeSHans Verkuil #define CEC_MSG_CLEAR_ANALOGUE_TIMER			0x33
6190dbacebeSHans Verkuil /* Recording Sequence Operand (recording_seq) */
6200dbacebeSHans Verkuil #define CEC_OP_REC_SEQ_SUNDAY				0x01
6210dbacebeSHans Verkuil #define CEC_OP_REC_SEQ_MONDAY				0x02
6220dbacebeSHans Verkuil #define CEC_OP_REC_SEQ_TUESDAY				0x04
6230dbacebeSHans Verkuil #define CEC_OP_REC_SEQ_WEDNESDAY			0x08
6240dbacebeSHans Verkuil #define CEC_OP_REC_SEQ_THURSDAY				0x10
6250dbacebeSHans Verkuil #define CEC_OP_REC_SEQ_FRIDAY				0x20
6260dbacebeSHans Verkuil #define CEC_OP_REC_SEQ_SATERDAY				0x40
6270dbacebeSHans Verkuil #define CEC_OP_REC_SEQ_ONCE_ONLY			0x00
6280dbacebeSHans Verkuil 
6290dbacebeSHans Verkuil #define CEC_MSG_CLEAR_DIGITAL_TIMER			0x99
6300dbacebeSHans Verkuil 
6310dbacebeSHans Verkuil #define CEC_MSG_CLEAR_EXT_TIMER				0xa1
6320dbacebeSHans Verkuil /* External Source Specifier Operand (ext_src_spec) */
6330dbacebeSHans Verkuil #define CEC_OP_EXT_SRC_PLUG				0x04
6340dbacebeSHans Verkuil #define CEC_OP_EXT_SRC_PHYS_ADDR			0x05
6350dbacebeSHans Verkuil 
6360dbacebeSHans Verkuil #define CEC_MSG_SET_ANALOGUE_TIMER			0x34
6370dbacebeSHans Verkuil #define CEC_MSG_SET_DIGITAL_TIMER			0x97
6380dbacebeSHans Verkuil #define CEC_MSG_SET_EXT_TIMER				0xa2
6390dbacebeSHans Verkuil 
6400dbacebeSHans Verkuil #define CEC_MSG_SET_TIMER_PROGRAM_TITLE			0x67
6410dbacebeSHans Verkuil #define CEC_MSG_TIMER_CLEARED_STATUS			0x43
6420dbacebeSHans Verkuil /* Timer Cleared Status Data Operand (timer_cleared_status) */
6430dbacebeSHans Verkuil #define CEC_OP_TIMER_CLR_STAT_RECORDING			0x00
6440dbacebeSHans Verkuil #define CEC_OP_TIMER_CLR_STAT_NO_MATCHING		0x01
6450dbacebeSHans Verkuil #define CEC_OP_TIMER_CLR_STAT_NO_INFO			0x02
6460dbacebeSHans Verkuil #define CEC_OP_TIMER_CLR_STAT_CLEARED			0x80
6470dbacebeSHans Verkuil 
6480dbacebeSHans Verkuil #define CEC_MSG_TIMER_STATUS				0x35
6490dbacebeSHans Verkuil /* Timer Overlap Warning Operand (timer_overlap_warning) */
6500dbacebeSHans Verkuil #define CEC_OP_TIMER_OVERLAP_WARNING_NO_OVERLAP		0
6510dbacebeSHans Verkuil #define CEC_OP_TIMER_OVERLAP_WARNING_OVERLAP		1
6520dbacebeSHans Verkuil /* Media Info Operand (media_info) */
6530dbacebeSHans Verkuil #define CEC_OP_MEDIA_INFO_UNPROT_MEDIA			0
6540dbacebeSHans Verkuil #define CEC_OP_MEDIA_INFO_PROT_MEDIA			1
6550dbacebeSHans Verkuil #define CEC_OP_MEDIA_INFO_NO_MEDIA			2
6560dbacebeSHans Verkuil /* Programmed Indicator Operand (prog_indicator) */
6570dbacebeSHans Verkuil #define CEC_OP_PROG_IND_NOT_PROGRAMMED			0
6580dbacebeSHans Verkuil #define CEC_OP_PROG_IND_PROGRAMMED			1
6590dbacebeSHans Verkuil /* Programmed Info Operand (prog_info) */
6600dbacebeSHans Verkuil #define CEC_OP_PROG_INFO_ENOUGH_SPACE			0x08
6610dbacebeSHans Verkuil #define CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE		0x09
6620dbacebeSHans Verkuil #define CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE	0x0b
6630dbacebeSHans Verkuil #define CEC_OP_PROG_INFO_NONE_AVAILABLE			0x0a
6640dbacebeSHans Verkuil /* Not Programmed Error Info Operand (prog_error) */
6650dbacebeSHans Verkuil #define CEC_OP_PROG_ERROR_NO_FREE_TIMER			0x01
6660dbacebeSHans Verkuil #define CEC_OP_PROG_ERROR_DATE_OUT_OF_RANGE		0x02
6670dbacebeSHans Verkuil #define CEC_OP_PROG_ERROR_REC_SEQ_ERROR			0x03
6680dbacebeSHans Verkuil #define CEC_OP_PROG_ERROR_INV_EXT_PLUG			0x04
6690dbacebeSHans Verkuil #define CEC_OP_PROG_ERROR_INV_EXT_PHYS_ADDR		0x05
6700dbacebeSHans Verkuil #define CEC_OP_PROG_ERROR_CA_UNSUPP			0x06
6710dbacebeSHans Verkuil #define CEC_OP_PROG_ERROR_INSUF_CA_ENTITLEMENTS		0x07
6720dbacebeSHans Verkuil #define CEC_OP_PROG_ERROR_RESOLUTION_UNSUPP		0x08
6730dbacebeSHans Verkuil #define CEC_OP_PROG_ERROR_PARENTAL_LOCK			0x09
6740dbacebeSHans Verkuil #define CEC_OP_PROG_ERROR_CLOCK_FAILURE			0x0a
6750dbacebeSHans Verkuil #define CEC_OP_PROG_ERROR_DUPLICATE			0x0e
6760dbacebeSHans Verkuil 
6770dbacebeSHans Verkuil 
6780dbacebeSHans Verkuil /* System Information Feature */
6790dbacebeSHans Verkuil #define CEC_MSG_CEC_VERSION				0x9e
6800dbacebeSHans Verkuil /* CEC Version Operand (cec_version) */
6810dbacebeSHans Verkuil #define CEC_OP_CEC_VERSION_1_3A				4
6820dbacebeSHans Verkuil #define CEC_OP_CEC_VERSION_1_4				5
6830dbacebeSHans Verkuil #define CEC_OP_CEC_VERSION_2_0				6
6840dbacebeSHans Verkuil 
6850dbacebeSHans Verkuil #define CEC_MSG_GET_CEC_VERSION				0x9f
6860dbacebeSHans Verkuil #define CEC_MSG_GIVE_PHYSICAL_ADDR			0x83
6870dbacebeSHans Verkuil #define CEC_MSG_GET_MENU_LANGUAGE			0x91
6880dbacebeSHans Verkuil #define CEC_MSG_REPORT_PHYSICAL_ADDR			0x84
6890dbacebeSHans Verkuil /* Primary Device Type Operand (prim_devtype) */
6900dbacebeSHans Verkuil #define CEC_OP_PRIM_DEVTYPE_TV				0
6910dbacebeSHans Verkuil #define CEC_OP_PRIM_DEVTYPE_RECORD			1
6920dbacebeSHans Verkuil #define CEC_OP_PRIM_DEVTYPE_TUNER			3
6930dbacebeSHans Verkuil #define CEC_OP_PRIM_DEVTYPE_PLAYBACK			4
6940dbacebeSHans Verkuil #define CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM			5
6950dbacebeSHans Verkuil #define CEC_OP_PRIM_DEVTYPE_SWITCH			6
6960dbacebeSHans Verkuil #define CEC_OP_PRIM_DEVTYPE_PROCESSOR			7
6970dbacebeSHans Verkuil 
6980dbacebeSHans Verkuil #define CEC_MSG_SET_MENU_LANGUAGE			0x32
6990dbacebeSHans Verkuil #define CEC_MSG_REPORT_FEATURES				0xa6	/* HDMI 2.0 */
7000dbacebeSHans Verkuil /* All Device Types Operand (all_device_types) */
7010dbacebeSHans Verkuil #define CEC_OP_ALL_DEVTYPE_TV				0x80
7020dbacebeSHans Verkuil #define CEC_OP_ALL_DEVTYPE_RECORD			0x40
7030dbacebeSHans Verkuil #define CEC_OP_ALL_DEVTYPE_TUNER			0x20
7040dbacebeSHans Verkuil #define CEC_OP_ALL_DEVTYPE_PLAYBACK			0x10
7050dbacebeSHans Verkuil #define CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM			0x08
7060dbacebeSHans Verkuil #define CEC_OP_ALL_DEVTYPE_SWITCH			0x04
7070dbacebeSHans Verkuil /*
7080dbacebeSHans Verkuil  * And if you wondering what happened to PROCESSOR devices: those should
7090dbacebeSHans Verkuil  * be mapped to a SWITCH.
7100dbacebeSHans Verkuil  */
7110dbacebeSHans Verkuil 
7120dbacebeSHans Verkuil /* Valid for RC Profile and Device Feature operands */
7130dbacebeSHans Verkuil #define CEC_OP_FEAT_EXT					0x80	/* Extension bit */
7140dbacebeSHans Verkuil /* RC Profile Operand (rc_profile) */
7150dbacebeSHans Verkuil #define CEC_OP_FEAT_RC_TV_PROFILE_NONE			0x00
7160dbacebeSHans Verkuil #define CEC_OP_FEAT_RC_TV_PROFILE_1			0x02
7170dbacebeSHans Verkuil #define CEC_OP_FEAT_RC_TV_PROFILE_2			0x06
7180dbacebeSHans Verkuil #define CEC_OP_FEAT_RC_TV_PROFILE_3			0x0a
7190dbacebeSHans Verkuil #define CEC_OP_FEAT_RC_TV_PROFILE_4			0x0e
7200dbacebeSHans Verkuil #define CEC_OP_FEAT_RC_SRC_HAS_DEV_ROOT_MENU		0x50
7210dbacebeSHans Verkuil #define CEC_OP_FEAT_RC_SRC_HAS_DEV_SETUP_MENU		0x48
7220dbacebeSHans Verkuil #define CEC_OP_FEAT_RC_SRC_HAS_CONTENTS_MENU		0x44
7230dbacebeSHans Verkuil #define CEC_OP_FEAT_RC_SRC_HAS_MEDIA_TOP_MENU		0x42
7240dbacebeSHans Verkuil #define CEC_OP_FEAT_RC_SRC_HAS_MEDIA_CONTEXT_MENU	0x41
7250dbacebeSHans Verkuil /* Device Feature Operand (dev_features) */
7260dbacebeSHans Verkuil #define CEC_OP_FEAT_DEV_HAS_RECORD_TV_SCREEN		0x40
7270dbacebeSHans Verkuil #define CEC_OP_FEAT_DEV_HAS_SET_OSD_STRING		0x20
7280dbacebeSHans Verkuil #define CEC_OP_FEAT_DEV_HAS_DECK_CONTROL		0x10
7290dbacebeSHans Verkuil #define CEC_OP_FEAT_DEV_HAS_SET_AUDIO_RATE		0x08
7300dbacebeSHans Verkuil #define CEC_OP_FEAT_DEV_SINK_HAS_ARC_TX			0x04
7310dbacebeSHans Verkuil #define CEC_OP_FEAT_DEV_SOURCE_HAS_ARC_RX		0x02
7320dbacebeSHans Verkuil 
7330dbacebeSHans Verkuil #define CEC_MSG_GIVE_FEATURES				0xa5	/* HDMI 2.0 */
7340dbacebeSHans Verkuil 
7350dbacebeSHans Verkuil 
7360dbacebeSHans Verkuil /* Deck Control Feature */
7370dbacebeSHans Verkuil #define CEC_MSG_DECK_CONTROL				0x42
7380dbacebeSHans Verkuil /* Deck Control Mode Operand (deck_control_mode) */
7390dbacebeSHans Verkuil #define CEC_OP_DECK_CTL_MODE_SKIP_FWD			1
7400dbacebeSHans Verkuil #define CEC_OP_DECK_CTL_MODE_SKIP_REV			2
7410dbacebeSHans Verkuil #define CEC_OP_DECK_CTL_MODE_STOP			3
7420dbacebeSHans Verkuil #define CEC_OP_DECK_CTL_MODE_EJECT			4
7430dbacebeSHans Verkuil 
7440dbacebeSHans Verkuil #define CEC_MSG_DECK_STATUS				0x1b
7450dbacebeSHans Verkuil /* Deck Info Operand (deck_info) */
7460dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_PLAY				0x11
7470dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_RECORD				0x12
7480dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_PLAY_REV			0x13
7490dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_STILL				0x14
7500dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_SLOW				0x15
7510dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_SLOW_REV			0x16
7520dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_FAST_FWD			0x17
7530dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_FAST_REV			0x18
7540dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_NO_MEDIA			0x19
7550dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_STOP				0x1a
7560dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_SKIP_FWD			0x1b
7570dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_SKIP_REV			0x1c
7580dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_INDEX_SEARCH_FWD		0x1d
7590dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_INDEX_SEARCH_REV		0x1e
7600dbacebeSHans Verkuil #define CEC_OP_DECK_INFO_OTHER				0x1f
7610dbacebeSHans Verkuil 
7620dbacebeSHans Verkuil #define CEC_MSG_GIVE_DECK_STATUS			0x1a
7630dbacebeSHans Verkuil /* Status Request Operand (status_req) */
7640dbacebeSHans Verkuil #define CEC_OP_STATUS_REQ_ON				1
7650dbacebeSHans Verkuil #define CEC_OP_STATUS_REQ_OFF				2
7660dbacebeSHans Verkuil #define CEC_OP_STATUS_REQ_ONCE				3
7670dbacebeSHans Verkuil 
7680dbacebeSHans Verkuil #define CEC_MSG_PLAY					0x41
7690dbacebeSHans Verkuil /* Play Mode Operand (play_mode) */
7700dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_FWD			0x24
7710dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_REV			0x20
7720dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_STILL			0x25
7730dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_FAST_FWD_MIN		0x05
7740dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_FAST_FWD_MED		0x06
7750dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_FAST_FWD_MAX		0x07
7760dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_FAST_REV_MIN		0x09
7770dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_FAST_REV_MED		0x0a
7780dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_FAST_REV_MAX		0x0b
7790dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_SLOW_FWD_MIN		0x15
7800dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_SLOW_FWD_MED		0x16
7810dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_SLOW_FWD_MAX		0x17
7820dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_SLOW_REV_MIN		0x19
7830dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_SLOW_REV_MED		0x1a
7840dbacebeSHans Verkuil #define CEC_OP_PLAY_MODE_PLAY_SLOW_REV_MAX		0x1b
7850dbacebeSHans Verkuil 
7860dbacebeSHans Verkuil 
7870dbacebeSHans Verkuil /* Tuner Control Feature */
7880dbacebeSHans Verkuil #define CEC_MSG_GIVE_TUNER_DEVICE_STATUS		0x08
7890dbacebeSHans Verkuil #define CEC_MSG_SELECT_ANALOGUE_SERVICE			0x92
7900dbacebeSHans Verkuil #define CEC_MSG_SELECT_DIGITAL_SERVICE			0x93
7910dbacebeSHans Verkuil #define CEC_MSG_TUNER_DEVICE_STATUS			0x07
7920dbacebeSHans Verkuil /* Recording Flag Operand (rec_flag) */
7930dbacebeSHans Verkuil #define CEC_OP_REC_FLAG_USED				0
7940dbacebeSHans Verkuil #define CEC_OP_REC_FLAG_NOT_USED			1
7950dbacebeSHans Verkuil /* Tuner Display Info Operand (tuner_display_info) */
7960dbacebeSHans Verkuil #define CEC_OP_TUNER_DISPLAY_INFO_DIGITAL		0
7970dbacebeSHans Verkuil #define CEC_OP_TUNER_DISPLAY_INFO_NONE			1
7980dbacebeSHans Verkuil #define CEC_OP_TUNER_DISPLAY_INFO_ANALOGUE		2
7990dbacebeSHans Verkuil 
8000dbacebeSHans Verkuil #define CEC_MSG_TUNER_STEP_DECREMENT			0x06
8010dbacebeSHans Verkuil #define CEC_MSG_TUNER_STEP_INCREMENT			0x05
8020dbacebeSHans Verkuil 
8030dbacebeSHans Verkuil 
8040dbacebeSHans Verkuil /* Vendor Specific Commands Feature */
8050dbacebeSHans Verkuil 
8060dbacebeSHans Verkuil /*
8070dbacebeSHans Verkuil  * Has also:
8080dbacebeSHans Verkuil  *	CEC_MSG_CEC_VERSION
8090dbacebeSHans Verkuil  *	CEC_MSG_GET_CEC_VERSION
8100dbacebeSHans Verkuil  */
8110dbacebeSHans Verkuil #define CEC_MSG_DEVICE_VENDOR_ID			0x87
8120dbacebeSHans Verkuil #define CEC_MSG_GIVE_DEVICE_VENDOR_ID			0x8c
8130dbacebeSHans Verkuil #define CEC_MSG_VENDOR_COMMAND				0x89
8140dbacebeSHans Verkuil #define CEC_MSG_VENDOR_COMMAND_WITH_ID			0xa0
8150dbacebeSHans Verkuil #define CEC_MSG_VENDOR_REMOTE_BUTTON_DOWN		0x8a
8160dbacebeSHans Verkuil #define CEC_MSG_VENDOR_REMOTE_BUTTON_UP			0x8b
8170dbacebeSHans Verkuil 
8180dbacebeSHans Verkuil 
8190dbacebeSHans Verkuil /* OSD Display Feature */
8200dbacebeSHans Verkuil #define CEC_MSG_SET_OSD_STRING				0x64
8210dbacebeSHans Verkuil /* Display Control Operand (disp_ctl) */
8220dbacebeSHans Verkuil #define CEC_OP_DISP_CTL_DEFAULT				0x00
8230dbacebeSHans Verkuil #define CEC_OP_DISP_CTL_UNTIL_CLEARED			0x40
8240dbacebeSHans Verkuil #define CEC_OP_DISP_CTL_CLEAR				0x80
8250dbacebeSHans Verkuil 
8260dbacebeSHans Verkuil 
8270dbacebeSHans Verkuil /* Device OSD Transfer Feature */
8280dbacebeSHans Verkuil #define CEC_MSG_GIVE_OSD_NAME				0x46
8290dbacebeSHans Verkuil #define CEC_MSG_SET_OSD_NAME				0x47
8300dbacebeSHans Verkuil 
8310dbacebeSHans Verkuil 
8320dbacebeSHans Verkuil /* Device Menu Control Feature */
8330dbacebeSHans Verkuil #define CEC_MSG_MENU_REQUEST				0x8d
8340dbacebeSHans Verkuil /* Menu Request Type Operand (menu_req) */
8350dbacebeSHans Verkuil #define CEC_OP_MENU_REQUEST_ACTIVATE			0x00
8360dbacebeSHans Verkuil #define CEC_OP_MENU_REQUEST_DEACTIVATE			0x01
8370dbacebeSHans Verkuil #define CEC_OP_MENU_REQUEST_QUERY			0x02
8380dbacebeSHans Verkuil 
8390dbacebeSHans Verkuil #define CEC_MSG_MENU_STATUS				0x8e
8400dbacebeSHans Verkuil /* Menu State Operand (menu_state) */
8410dbacebeSHans Verkuil #define CEC_OP_MENU_STATE_ACTIVATED			0x00
8420dbacebeSHans Verkuil #define CEC_OP_MENU_STATE_DEACTIVATED			0x01
8430dbacebeSHans Verkuil 
8440dbacebeSHans Verkuil #define CEC_MSG_USER_CONTROL_PRESSED			0x44
8450dbacebeSHans Verkuil /* UI Broadcast Type Operand (ui_bcast_type) */
8460dbacebeSHans Verkuil #define CEC_OP_UI_BCAST_TYPE_TOGGLE_ALL			0x00
8470dbacebeSHans Verkuil #define CEC_OP_UI_BCAST_TYPE_TOGGLE_DIG_ANA		0x01
8480dbacebeSHans Verkuil #define CEC_OP_UI_BCAST_TYPE_ANALOGUE			0x10
8490dbacebeSHans Verkuil #define CEC_OP_UI_BCAST_TYPE_ANALOGUE_T			0x20
8500dbacebeSHans Verkuil #define CEC_OP_UI_BCAST_TYPE_ANALOGUE_CABLE		0x30
8510dbacebeSHans Verkuil #define CEC_OP_UI_BCAST_TYPE_ANALOGUE_SAT		0x40
8520dbacebeSHans Verkuil #define CEC_OP_UI_BCAST_TYPE_DIGITAL			0x50
8530dbacebeSHans Verkuil #define CEC_OP_UI_BCAST_TYPE_DIGITAL_T			0x60
8540dbacebeSHans Verkuil #define CEC_OP_UI_BCAST_TYPE_DIGITAL_CABLE		0x70
8550dbacebeSHans Verkuil #define CEC_OP_UI_BCAST_TYPE_DIGITAL_SAT		0x80
8560dbacebeSHans Verkuil #define CEC_OP_UI_BCAST_TYPE_DIGITAL_COM_SAT		0x90
8570dbacebeSHans Verkuil #define CEC_OP_UI_BCAST_TYPE_DIGITAL_COM_SAT2		0x91
8580dbacebeSHans Verkuil #define CEC_OP_UI_BCAST_TYPE_IP				0xa0
8590dbacebeSHans Verkuil /* UI Sound Presentation Control Operand (ui_snd_pres_ctl) */
8600dbacebeSHans Verkuil #define CEC_OP_UI_SND_PRES_CTL_DUAL_MONO		0x10
8610dbacebeSHans Verkuil #define CEC_OP_UI_SND_PRES_CTL_KARAOKE			0x20
8620dbacebeSHans Verkuil #define CEC_OP_UI_SND_PRES_CTL_DOWNMIX			0x80
8630dbacebeSHans Verkuil #define CEC_OP_UI_SND_PRES_CTL_REVERB			0x90
8640dbacebeSHans Verkuil #define CEC_OP_UI_SND_PRES_CTL_EQUALIZER		0xa0
8650dbacebeSHans Verkuil #define CEC_OP_UI_SND_PRES_CTL_BASS_UP			0xb1
8660dbacebeSHans Verkuil #define CEC_OP_UI_SND_PRES_CTL_BASS_NEUTRAL		0xb2
8670dbacebeSHans Verkuil #define CEC_OP_UI_SND_PRES_CTL_BASS_DOWN		0xb3
8680dbacebeSHans Verkuil #define CEC_OP_UI_SND_PRES_CTL_TREBLE_UP		0xc1
8690dbacebeSHans Verkuil #define CEC_OP_UI_SND_PRES_CTL_TREBLE_NEUTRAL		0xc2
8700dbacebeSHans Verkuil #define CEC_OP_UI_SND_PRES_CTL_TREBLE_DOWN		0xc3
8710dbacebeSHans Verkuil 
8720dbacebeSHans Verkuil #define CEC_MSG_USER_CONTROL_RELEASED			0x45
8730dbacebeSHans Verkuil 
8740dbacebeSHans Verkuil 
8750dbacebeSHans Verkuil /* Remote Control Passthrough Feature */
8760dbacebeSHans Verkuil 
8770dbacebeSHans Verkuil /*
8780dbacebeSHans Verkuil  * Has also:
8790dbacebeSHans Verkuil  *	CEC_MSG_USER_CONTROL_PRESSED
8800dbacebeSHans Verkuil  *	CEC_MSG_USER_CONTROL_RELEASED
8810dbacebeSHans Verkuil  */
8820dbacebeSHans Verkuil 
8830dbacebeSHans Verkuil 
8840dbacebeSHans Verkuil /* Power Status Feature */
8850dbacebeSHans Verkuil #define CEC_MSG_GIVE_DEVICE_POWER_STATUS		0x8f
8860dbacebeSHans Verkuil #define CEC_MSG_REPORT_POWER_STATUS			0x90
8870dbacebeSHans Verkuil /* Power Status Operand (pwr_state) */
8880dbacebeSHans Verkuil #define CEC_OP_POWER_STATUS_ON				0
8890dbacebeSHans Verkuil #define CEC_OP_POWER_STATUS_STANDBY			1
8900dbacebeSHans Verkuil #define CEC_OP_POWER_STATUS_TO_ON			2
8910dbacebeSHans Verkuil #define CEC_OP_POWER_STATUS_TO_STANDBY			3
8920dbacebeSHans Verkuil 
8930dbacebeSHans Verkuil 
8940dbacebeSHans Verkuil /* General Protocol Messages */
8950dbacebeSHans Verkuil #define CEC_MSG_FEATURE_ABORT				0x00
8960dbacebeSHans Verkuil /* Abort Reason Operand (reason) */
8970dbacebeSHans Verkuil #define CEC_OP_ABORT_UNRECOGNIZED_OP			0
8980dbacebeSHans Verkuil #define CEC_OP_ABORT_INCORRECT_MODE			1
8990dbacebeSHans Verkuil #define CEC_OP_ABORT_NO_SOURCE				2
9000dbacebeSHans Verkuil #define CEC_OP_ABORT_INVALID_OP				3
9010dbacebeSHans Verkuil #define CEC_OP_ABORT_REFUSED				4
9020dbacebeSHans Verkuil #define CEC_OP_ABORT_UNDETERMINED			5
9030dbacebeSHans Verkuil 
9040dbacebeSHans Verkuil #define CEC_MSG_ABORT					0xff
9050dbacebeSHans Verkuil 
9060dbacebeSHans Verkuil 
9070dbacebeSHans Verkuil /* System Audio Control Feature */
9080dbacebeSHans Verkuil 
9090dbacebeSHans Verkuil /*
9100dbacebeSHans Verkuil  * Has also:
9110dbacebeSHans Verkuil  *	CEC_MSG_USER_CONTROL_PRESSED
9120dbacebeSHans Verkuil  *	CEC_MSG_USER_CONTROL_RELEASED
9130dbacebeSHans Verkuil  */
9140dbacebeSHans Verkuil #define CEC_MSG_GIVE_AUDIO_STATUS			0x71
9150dbacebeSHans Verkuil #define CEC_MSG_GIVE_SYSTEM_AUDIO_MODE_STATUS		0x7d
9160dbacebeSHans Verkuil #define CEC_MSG_REPORT_AUDIO_STATUS			0x7a
9170dbacebeSHans Verkuil /* Audio Mute Status Operand (aud_mute_status) */
9180dbacebeSHans Verkuil #define CEC_OP_AUD_MUTE_STATUS_OFF			0
9190dbacebeSHans Verkuil #define CEC_OP_AUD_MUTE_STATUS_ON			1
9200dbacebeSHans Verkuil 
9210dbacebeSHans Verkuil #define CEC_MSG_REPORT_SHORT_AUDIO_DESCRIPTOR		0xa3
9220dbacebeSHans Verkuil #define CEC_MSG_REQUEST_SHORT_AUDIO_DESCRIPTOR		0xa4
9230dbacebeSHans Verkuil #define CEC_MSG_SET_SYSTEM_AUDIO_MODE			0x72
9240dbacebeSHans Verkuil /* System Audio Status Operand (sys_aud_status) */
9250dbacebeSHans Verkuil #define CEC_OP_SYS_AUD_STATUS_OFF			0
9260dbacebeSHans Verkuil #define CEC_OP_SYS_AUD_STATUS_ON			1
9270dbacebeSHans Verkuil 
9280dbacebeSHans Verkuil #define CEC_MSG_SYSTEM_AUDIO_MODE_REQUEST		0x70
9290dbacebeSHans Verkuil #define CEC_MSG_SYSTEM_AUDIO_MODE_STATUS		0x7e
9300dbacebeSHans Verkuil /* Audio Format ID Operand (audio_format_id) */
9310dbacebeSHans Verkuil #define CEC_OP_AUD_FMT_ID_CEA861			0
9320dbacebeSHans Verkuil #define CEC_OP_AUD_FMT_ID_CEA861_CXT			1
9330dbacebeSHans Verkuil 
9340dbacebeSHans Verkuil 
9350dbacebeSHans Verkuil /* Audio Rate Control Feature */
9360dbacebeSHans Verkuil #define CEC_MSG_SET_AUDIO_RATE				0x9a
9370dbacebeSHans Verkuil /* Audio Rate Operand (audio_rate) */
9380dbacebeSHans Verkuil #define CEC_OP_AUD_RATE_OFF				0
9390dbacebeSHans Verkuil #define CEC_OP_AUD_RATE_WIDE_STD			1
9400dbacebeSHans Verkuil #define CEC_OP_AUD_RATE_WIDE_FAST			2
9410dbacebeSHans Verkuil #define CEC_OP_AUD_RATE_WIDE_SLOW			3
9420dbacebeSHans Verkuil #define CEC_OP_AUD_RATE_NARROW_STD			4
9430dbacebeSHans Verkuil #define CEC_OP_AUD_RATE_NARROW_FAST			5
9440dbacebeSHans Verkuil #define CEC_OP_AUD_RATE_NARROW_SLOW			6
9450dbacebeSHans Verkuil 
9460dbacebeSHans Verkuil 
9470dbacebeSHans Verkuil /* Audio Return Channel Control Feature */
9480dbacebeSHans Verkuil #define CEC_MSG_INITIATE_ARC				0xc0
9490dbacebeSHans Verkuil #define CEC_MSG_REPORT_ARC_INITIATED			0xc1
9500dbacebeSHans Verkuil #define CEC_MSG_REPORT_ARC_TERMINATED			0xc2
9510dbacebeSHans Verkuil #define CEC_MSG_REQUEST_ARC_INITIATION			0xc3
9520dbacebeSHans Verkuil #define CEC_MSG_REQUEST_ARC_TERMINATION			0xc4
9530dbacebeSHans Verkuil #define CEC_MSG_TERMINATE_ARC				0xc5
9540dbacebeSHans Verkuil 
9550dbacebeSHans Verkuil 
9560dbacebeSHans Verkuil /* Dynamic Audio Lipsync Feature */
9570dbacebeSHans Verkuil /* Only for CEC 2.0 and up */
9580dbacebeSHans Verkuil #define CEC_MSG_REQUEST_CURRENT_LATENCY			0xa7
9590dbacebeSHans Verkuil #define CEC_MSG_REPORT_CURRENT_LATENCY			0xa8
9600dbacebeSHans Verkuil /* Low Latency Mode Operand (low_latency_mode) */
9610dbacebeSHans Verkuil #define CEC_OP_LOW_LATENCY_MODE_OFF			0
9620dbacebeSHans Verkuil #define CEC_OP_LOW_LATENCY_MODE_ON			1
9630dbacebeSHans Verkuil /* Audio Output Compensated Operand (audio_out_compensated) */
9640dbacebeSHans Verkuil #define CEC_OP_AUD_OUT_COMPENSATED_NA			0
9650dbacebeSHans Verkuil #define CEC_OP_AUD_OUT_COMPENSATED_DELAY		1
9660dbacebeSHans Verkuil #define CEC_OP_AUD_OUT_COMPENSATED_NO_DELAY		2
9670dbacebeSHans Verkuil #define CEC_OP_AUD_OUT_COMPENSATED_PARTIAL_DELAY	3
9680dbacebeSHans Verkuil 
9690dbacebeSHans Verkuil 
9700dbacebeSHans Verkuil /* Capability Discovery and Control Feature */
9710dbacebeSHans Verkuil #define CEC_MSG_CDC_MESSAGE				0xf8
9720dbacebeSHans Verkuil /* Ethernet-over-HDMI: nobody ever does this... */
9730dbacebeSHans Verkuil #define CEC_MSG_CDC_HEC_INQUIRE_STATE			0x00
9740dbacebeSHans Verkuil #define CEC_MSG_CDC_HEC_REPORT_STATE			0x01
9750dbacebeSHans Verkuil /* HEC Functionality State Operand (hec_func_state) */
9760dbacebeSHans Verkuil #define CEC_OP_HEC_FUNC_STATE_NOT_SUPPORTED		0
9770dbacebeSHans Verkuil #define CEC_OP_HEC_FUNC_STATE_INACTIVE			1
9780dbacebeSHans Verkuil #define CEC_OP_HEC_FUNC_STATE_ACTIVE			2
9790dbacebeSHans Verkuil #define CEC_OP_HEC_FUNC_STATE_ACTIVATION_FIELD		3
9800dbacebeSHans Verkuil /* Host Functionality State Operand (host_func_state) */
9810dbacebeSHans Verkuil #define CEC_OP_HOST_FUNC_STATE_NOT_SUPPORTED		0
9820dbacebeSHans Verkuil #define CEC_OP_HOST_FUNC_STATE_INACTIVE			1
9830dbacebeSHans Verkuil #define CEC_OP_HOST_FUNC_STATE_ACTIVE			2
9840dbacebeSHans Verkuil /* ENC Functionality State Operand (enc_func_state) */
9850dbacebeSHans Verkuil #define CEC_OP_ENC_FUNC_STATE_EXT_CON_NOT_SUPPORTED	0
9860dbacebeSHans Verkuil #define CEC_OP_ENC_FUNC_STATE_EXT_CON_INACTIVE		1
9870dbacebeSHans Verkuil #define CEC_OP_ENC_FUNC_STATE_EXT_CON_ACTIVE		2
9880dbacebeSHans Verkuil /* CDC Error Code Operand (cdc_errcode) */
9890dbacebeSHans Verkuil #define CEC_OP_CDC_ERROR_CODE_NONE			0
9900dbacebeSHans Verkuil #define CEC_OP_CDC_ERROR_CODE_CAP_UNSUPPORTED		1
9910dbacebeSHans Verkuil #define CEC_OP_CDC_ERROR_CODE_WRONG_STATE		2
9920dbacebeSHans Verkuil #define CEC_OP_CDC_ERROR_CODE_OTHER			3
9930dbacebeSHans Verkuil /* HEC Support Operand (hec_support) */
9940dbacebeSHans Verkuil #define CEC_OP_HEC_SUPPORT_NO				0
9950dbacebeSHans Verkuil #define CEC_OP_HEC_SUPPORT_YES				1
9960dbacebeSHans Verkuil /* HEC Activation Operand (hec_activation) */
9970dbacebeSHans Verkuil #define CEC_OP_HEC_ACTIVATION_ON			0
9980dbacebeSHans Verkuil #define CEC_OP_HEC_ACTIVATION_OFF			1
9990dbacebeSHans Verkuil 
10000dbacebeSHans Verkuil #define CEC_MSG_CDC_HEC_SET_STATE_ADJACENT		0x02
10010dbacebeSHans Verkuil #define CEC_MSG_CDC_HEC_SET_STATE			0x03
10020dbacebeSHans Verkuil /* HEC Set State Operand (hec_set_state) */
10030dbacebeSHans Verkuil #define CEC_OP_HEC_SET_STATE_DEACTIVATE			0
10040dbacebeSHans Verkuil #define CEC_OP_HEC_SET_STATE_ACTIVATE			1
10050dbacebeSHans Verkuil 
10060dbacebeSHans Verkuil #define CEC_MSG_CDC_HEC_REQUEST_DEACTIVATION		0x04
10070dbacebeSHans Verkuil #define CEC_MSG_CDC_HEC_NOTIFY_ALIVE			0x05
10080dbacebeSHans Verkuil #define CEC_MSG_CDC_HEC_DISCOVER			0x06
10090dbacebeSHans Verkuil /* Hotplug Detect messages */
10100dbacebeSHans Verkuil #define CEC_MSG_CDC_HPD_SET_STATE			0x10
10110dbacebeSHans Verkuil /* HPD State Operand (hpd_state) */
10120dbacebeSHans Verkuil #define CEC_OP_HPD_STATE_CP_EDID_DISABLE		0
10130dbacebeSHans Verkuil #define CEC_OP_HPD_STATE_CP_EDID_ENABLE			1
10140dbacebeSHans Verkuil #define CEC_OP_HPD_STATE_CP_EDID_DISABLE_ENABLE		2
10150dbacebeSHans Verkuil #define CEC_OP_HPD_STATE_EDID_DISABLE			3
10160dbacebeSHans Verkuil #define CEC_OP_HPD_STATE_EDID_ENABLE			4
10170dbacebeSHans Verkuil #define CEC_OP_HPD_STATE_EDID_DISABLE_ENABLE		5
10180dbacebeSHans Verkuil #define CEC_MSG_CDC_HPD_REPORT_STATE			0x11
10190dbacebeSHans Verkuil /* HPD Error Code Operand (hpd_error) */
10200dbacebeSHans Verkuil #define CEC_OP_HPD_ERROR_NONE				0
10210dbacebeSHans Verkuil #define CEC_OP_HPD_ERROR_INITIATOR_NOT_CAPABLE		1
10220dbacebeSHans Verkuil #define CEC_OP_HPD_ERROR_INITIATOR_WRONG_STATE		2
10230dbacebeSHans Verkuil #define CEC_OP_HPD_ERROR_OTHER				3
10240dbacebeSHans Verkuil #define CEC_OP_HPD_ERROR_NONE_NO_VIDEO			4
10250dbacebeSHans Verkuil 
10260dbacebeSHans Verkuil /* End of Messages */
10270dbacebeSHans Verkuil 
10280dbacebeSHans Verkuil /* Helper functions to identify the 'special' CEC devices */
10290dbacebeSHans Verkuil 
10303145c754SHans Verkuil static inline int cec_is_2nd_tv(const struct cec_log_addrs *las)
10310dbacebeSHans Verkuil {
10320dbacebeSHans Verkuil 	/*
10330dbacebeSHans Verkuil 	 * It is a second TV if the logical address is 14 or 15 and the
10340dbacebeSHans Verkuil 	 * primary device type is a TV.
10350dbacebeSHans Verkuil 	 */
10360dbacebeSHans Verkuil 	return las->num_log_addrs &&
10370dbacebeSHans Verkuil 	       las->log_addr[0] >= CEC_LOG_ADDR_SPECIFIC &&
10380dbacebeSHans Verkuil 	       las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_TV;
10390dbacebeSHans Verkuil }
10400dbacebeSHans Verkuil 
10413145c754SHans Verkuil static inline int cec_is_processor(const struct cec_log_addrs *las)
10420dbacebeSHans Verkuil {
10430dbacebeSHans Verkuil 	/*
10440dbacebeSHans Verkuil 	 * It is a processor if the logical address is 12-15 and the
10450dbacebeSHans Verkuil 	 * primary device type is a Processor.
10460dbacebeSHans Verkuil 	 */
10470dbacebeSHans Verkuil 	return las->num_log_addrs &&
10480dbacebeSHans Verkuil 	       las->log_addr[0] >= CEC_LOG_ADDR_BACKUP_1 &&
10490dbacebeSHans Verkuil 	       las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_PROCESSOR;
10500dbacebeSHans Verkuil }
10510dbacebeSHans Verkuil 
10523145c754SHans Verkuil static inline int cec_is_switch(const struct cec_log_addrs *las)
10530dbacebeSHans Verkuil {
10540dbacebeSHans Verkuil 	/*
10550dbacebeSHans Verkuil 	 * It is a switch if the logical address is 15 and the
10560dbacebeSHans Verkuil 	 * primary device type is a Switch and the CDC-Only flag is not set.
10570dbacebeSHans Verkuil 	 */
10580dbacebeSHans Verkuil 	return las->num_log_addrs == 1 &&
10590dbacebeSHans Verkuil 	       las->log_addr[0] == CEC_LOG_ADDR_UNREGISTERED &&
10600dbacebeSHans Verkuil 	       las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_SWITCH &&
10610dbacebeSHans Verkuil 	       !(las->flags & CEC_LOG_ADDRS_FL_CDC_ONLY);
10620dbacebeSHans Verkuil }
10630dbacebeSHans Verkuil 
10643145c754SHans Verkuil static inline int cec_is_cdc_only(const struct cec_log_addrs *las)
10650dbacebeSHans Verkuil {
10660dbacebeSHans Verkuil 	/*
10670dbacebeSHans Verkuil 	 * It is a CDC-only device if the logical address is 15 and the
10680dbacebeSHans Verkuil 	 * primary device type is a Switch and the CDC-Only flag is set.
10690dbacebeSHans Verkuil 	 */
10700dbacebeSHans Verkuil 	return las->num_log_addrs == 1 &&
10710dbacebeSHans Verkuil 	       las->log_addr[0] == CEC_LOG_ADDR_UNREGISTERED &&
10720dbacebeSHans Verkuil 	       las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_SWITCH &&
10730dbacebeSHans Verkuil 	       (las->flags & CEC_LOG_ADDRS_FL_CDC_ONLY);
10740dbacebeSHans Verkuil }
10750dbacebeSHans Verkuil 
10760dbacebeSHans Verkuil #endif
1077