1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
2 /*
3  * cec - HDMI Consumer Electronics Control public header
4  *
5  * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
6  */
7 
8 #ifndef _CEC_UAPI_H
9 #define _CEC_UAPI_H
10 
11 #include <linux/types.h>
12 #include <linux/string.h>
13 
14 #define CEC_MAX_MSG_SIZE	16
15 
16 /**
17  * struct cec_msg - CEC message structure.
18  * @tx_ts:	Timestamp in nanoseconds using CLOCK_MONOTONIC. Set by the
19  *		driver when the message transmission has finished.
20  * @rx_ts:	Timestamp in nanoseconds using CLOCK_MONOTONIC. Set by the
21  *		driver when the message was received.
22  * @len:	Length in bytes of the message.
23  * @timeout:	The timeout (in ms) that is used to timeout CEC_RECEIVE.
24  *		Set to 0 if you want to wait forever. This timeout can also be
25  *		used with CEC_TRANSMIT as the timeout for waiting for a reply.
26  *		If 0, then it will use a 1 second timeout instead of waiting
27  *		forever as is done with CEC_RECEIVE.
28  * @sequence:	The framework assigns a sequence number to messages that are
29  *		sent. This can be used to track replies to previously sent
30  *		messages.
31  * @flags:	Set to 0.
32  * @msg:	The message payload.
33  * @reply:	This field is ignored with CEC_RECEIVE and is only used by
34  *		CEC_TRANSMIT. If non-zero, then wait for a reply with this
35  *		opcode. Set to CEC_MSG_FEATURE_ABORT if you want to wait for
36  *		a possible ABORT reply. If there was an error when sending the
37  *		msg or FeatureAbort was returned, then reply is set to 0.
38  *		If reply is non-zero upon return, then len/msg are set to
39  *		the received message.
40  *		If reply is zero upon return and status has the
41  *		CEC_TX_STATUS_FEATURE_ABORT bit set, then len/msg are set to
42  *		the received feature abort message.
43  *		If reply is zero upon return and status has the
44  *		CEC_TX_STATUS_MAX_RETRIES bit set, then no reply was seen at
45  *		all. If reply is non-zero for CEC_TRANSMIT and the message is a
46  *		broadcast, then -EINVAL is returned.
47  *		if reply is non-zero, then timeout is set to 1000 (the required
48  *		maximum response time).
49  * @rx_status:	The message receive status bits. Set by the driver.
50  * @tx_status:	The message transmit status bits. Set by the driver.
51  * @tx_arb_lost_cnt: The number of 'Arbitration Lost' events. Set by the driver.
52  * @tx_nack_cnt: The number of 'Not Acknowledged' events. Set by the driver.
53  * @tx_low_drive_cnt: The number of 'Low Drive Detected' events. Set by the
54  *		driver.
55  * @tx_error_cnt: The number of 'Error' events. Set by the driver.
56  */
57 struct cec_msg {
58 	__u64 tx_ts;
59 	__u64 rx_ts;
60 	__u32 len;
61 	__u32 timeout;
62 	__u32 sequence;
63 	__u32 flags;
64 	__u8 msg[CEC_MAX_MSG_SIZE];
65 	__u8 reply;
66 	__u8 rx_status;
67 	__u8 tx_status;
68 	__u8 tx_arb_lost_cnt;
69 	__u8 tx_nack_cnt;
70 	__u8 tx_low_drive_cnt;
71 	__u8 tx_error_cnt;
72 };
73 
74 /**
75  * cec_msg_initiator - return the initiator's logical address.
76  * @msg:	the message structure
77  */
cec_msg_initiator(const struct cec_msg * msg)78 static inline __u8 cec_msg_initiator(const struct cec_msg *msg)
79 {
80 	return msg->msg[0] >> 4;
81 }
82 
83 /**
84  * cec_msg_destination - return the destination's logical address.
85  * @msg:	the message structure
86  */
cec_msg_destination(const struct cec_msg * msg)87 static inline __u8 cec_msg_destination(const struct cec_msg *msg)
88 {
89 	return msg->msg[0] & 0xf;
90 }
91 
92 /**
93  * cec_msg_opcode - return the opcode of the message, -1 for poll
94  * @msg:	the message structure
95  */
cec_msg_opcode(const struct cec_msg * msg)96 static inline int cec_msg_opcode(const struct cec_msg *msg)
97 {
98 	return msg->len > 1 ? msg->msg[1] : -1;
99 }
100 
101 /**
102  * cec_msg_is_broadcast - return true if this is a broadcast message.
103  * @msg:	the message structure
104  */
cec_msg_is_broadcast(const struct cec_msg * msg)105 static inline int cec_msg_is_broadcast(const struct cec_msg *msg)
106 {
107 	return (msg->msg[0] & 0xf) == 0xf;
108 }
109 
110 /**
111  * cec_msg_init - initialize the message structure.
112  * @msg:	the message structure
113  * @initiator:	the logical address of the initiator
114  * @destination:the logical address of the destination (0xf for broadcast)
115  *
116  * The whole structure is zeroed, the len field is set to 1 (i.e. a poll
117  * message) and the initiator and destination are filled in.
118  */
cec_msg_init(struct cec_msg * msg,__u8 initiator,__u8 destination)119 static inline void cec_msg_init(struct cec_msg *msg,
120 				__u8 initiator, __u8 destination)
121 {
122 	memset(msg, 0, sizeof(*msg));
123 	msg->msg[0] = (initiator << 4) | destination;
124 	msg->len = 1;
125 }
126 
127 /**
128  * cec_msg_set_reply_to - fill in destination/initiator in a reply message.
129  * @msg:	the message structure for the reply
130  * @orig:	the original message structure
131  *
132  * Set the msg destination to the orig initiator and the msg initiator to the
133  * orig destination. Note that msg and orig may be the same pointer, in which
134  * case the change is done in place.
135  */
cec_msg_set_reply_to(struct cec_msg * msg,struct cec_msg * orig)136 static inline void cec_msg_set_reply_to(struct cec_msg *msg,
137 					struct cec_msg *orig)
138 {
139 	/* The destination becomes the initiator and vice versa */
140 	msg->msg[0] = (cec_msg_destination(orig) << 4) |
141 		      cec_msg_initiator(orig);
142 	msg->reply = msg->timeout = 0;
143 }
144 
145 /* cec_msg flags field */
146 #define CEC_MSG_FL_REPLY_TO_FOLLOWERS	(1 << 0)
147 
148 /* cec_msg tx/rx_status field */
149 #define CEC_TX_STATUS_OK		(1 << 0)
150 #define CEC_TX_STATUS_ARB_LOST		(1 << 1)
151 #define CEC_TX_STATUS_NACK		(1 << 2)
152 #define CEC_TX_STATUS_LOW_DRIVE		(1 << 3)
153 #define CEC_TX_STATUS_ERROR		(1 << 4)
154 #define CEC_TX_STATUS_MAX_RETRIES	(1 << 5)
155 #define CEC_TX_STATUS_ABORTED		(1 << 6)
156 #define CEC_TX_STATUS_TIMEOUT		(1 << 7)
157 
158 #define CEC_RX_STATUS_OK		(1 << 0)
159 #define CEC_RX_STATUS_TIMEOUT		(1 << 1)
160 #define CEC_RX_STATUS_FEATURE_ABORT	(1 << 2)
161 #define CEC_RX_STATUS_ABORTED		(1 << 3)
162 
cec_msg_status_is_ok(const struct cec_msg * msg)163 static inline int cec_msg_status_is_ok(const struct cec_msg *msg)
164 {
165 	if (msg->tx_status && !(msg->tx_status & CEC_TX_STATUS_OK))
166 		return 0;
167 	if (msg->rx_status && !(msg->rx_status & CEC_RX_STATUS_OK))
168 		return 0;
169 	if (!msg->tx_status && !msg->rx_status)
170 		return 0;
171 	return !(msg->rx_status & CEC_RX_STATUS_FEATURE_ABORT);
172 }
173 
174 #define CEC_LOG_ADDR_INVALID		0xff
175 #define CEC_PHYS_ADDR_INVALID		0xffff
176 
177 /*
178  * The maximum number of logical addresses one device can be assigned to.
179  * The CEC 2.0 spec allows for only 2 logical addresses at the moment. The
180  * Analog Devices CEC hardware supports 3. So let's go wild and go for 4.
181  */
182 #define CEC_MAX_LOG_ADDRS 4
183 
184 /* The logical addresses defined by CEC 2.0 */
185 #define CEC_LOG_ADDR_TV			0
186 #define CEC_LOG_ADDR_RECORD_1		1
187 #define CEC_LOG_ADDR_RECORD_2		2
188 #define CEC_LOG_ADDR_TUNER_1		3
189 #define CEC_LOG_ADDR_PLAYBACK_1		4
190 #define CEC_LOG_ADDR_AUDIOSYSTEM	5
191 #define CEC_LOG_ADDR_TUNER_2		6
192 #define CEC_LOG_ADDR_TUNER_3		7
193 #define CEC_LOG_ADDR_PLAYBACK_2		8
194 #define CEC_LOG_ADDR_RECORD_3		9
195 #define CEC_LOG_ADDR_TUNER_4		10
196 #define CEC_LOG_ADDR_PLAYBACK_3		11
197 #define CEC_LOG_ADDR_BACKUP_1		12
198 #define CEC_LOG_ADDR_BACKUP_2		13
199 #define CEC_LOG_ADDR_SPECIFIC		14
200 #define CEC_LOG_ADDR_UNREGISTERED	15 /* as initiator address */
201 #define CEC_LOG_ADDR_BROADCAST		15 /* as destination address */
202 
203 /* The logical address types that the CEC device wants to claim */
204 #define CEC_LOG_ADDR_TYPE_TV		0
205 #define CEC_LOG_ADDR_TYPE_RECORD	1
206 #define CEC_LOG_ADDR_TYPE_TUNER		2
207 #define CEC_LOG_ADDR_TYPE_PLAYBACK	3
208 #define CEC_LOG_ADDR_TYPE_AUDIOSYSTEM	4
209 #define CEC_LOG_ADDR_TYPE_SPECIFIC	5
210 #define CEC_LOG_ADDR_TYPE_UNREGISTERED	6
211 /*
212  * Switches should use UNREGISTERED.
213  * Processors should use SPECIFIC.
214  */
215 
216 #define CEC_LOG_ADDR_MASK_TV		(1 << CEC_LOG_ADDR_TV)
217 #define CEC_LOG_ADDR_MASK_RECORD	((1 << CEC_LOG_ADDR_RECORD_1) | \
218 					 (1 << CEC_LOG_ADDR_RECORD_2) | \
219 					 (1 << CEC_LOG_ADDR_RECORD_3))
220 #define CEC_LOG_ADDR_MASK_TUNER		((1 << CEC_LOG_ADDR_TUNER_1) | \
221 					 (1 << CEC_LOG_ADDR_TUNER_2) | \
222 					 (1 << CEC_LOG_ADDR_TUNER_3) | \
223 					 (1 << CEC_LOG_ADDR_TUNER_4))
224 #define CEC_LOG_ADDR_MASK_PLAYBACK	((1 << CEC_LOG_ADDR_PLAYBACK_1) | \
225 					 (1 << CEC_LOG_ADDR_PLAYBACK_2) | \
226 					 (1 << CEC_LOG_ADDR_PLAYBACK_3))
227 #define CEC_LOG_ADDR_MASK_AUDIOSYSTEM	(1 << CEC_LOG_ADDR_AUDIOSYSTEM)
228 #define CEC_LOG_ADDR_MASK_BACKUP	((1 << CEC_LOG_ADDR_BACKUP_1) | \
229 					 (1 << CEC_LOG_ADDR_BACKUP_2))
230 #define CEC_LOG_ADDR_MASK_SPECIFIC	(1 << CEC_LOG_ADDR_SPECIFIC)
231 #define CEC_LOG_ADDR_MASK_UNREGISTERED	(1 << CEC_LOG_ADDR_UNREGISTERED)
232 
cec_has_tv(__u16 log_addr_mask)233 static inline int cec_has_tv(__u16 log_addr_mask)
234 {
235 	return log_addr_mask & CEC_LOG_ADDR_MASK_TV;
236 }
237 
cec_has_record(__u16 log_addr_mask)238 static inline int cec_has_record(__u16 log_addr_mask)
239 {
240 	return log_addr_mask & CEC_LOG_ADDR_MASK_RECORD;
241 }
242 
cec_has_tuner(__u16 log_addr_mask)243 static inline int cec_has_tuner(__u16 log_addr_mask)
244 {
245 	return log_addr_mask & CEC_LOG_ADDR_MASK_TUNER;
246 }
247 
cec_has_playback(__u16 log_addr_mask)248 static inline int cec_has_playback(__u16 log_addr_mask)
249 {
250 	return log_addr_mask & CEC_LOG_ADDR_MASK_PLAYBACK;
251 }
252 
cec_has_audiosystem(__u16 log_addr_mask)253 static inline int cec_has_audiosystem(__u16 log_addr_mask)
254 {
255 	return log_addr_mask & CEC_LOG_ADDR_MASK_AUDIOSYSTEM;
256 }
257 
cec_has_backup(__u16 log_addr_mask)258 static inline int cec_has_backup(__u16 log_addr_mask)
259 {
260 	return log_addr_mask & CEC_LOG_ADDR_MASK_BACKUP;
261 }
262 
cec_has_specific(__u16 log_addr_mask)263 static inline int cec_has_specific(__u16 log_addr_mask)
264 {
265 	return log_addr_mask & CEC_LOG_ADDR_MASK_SPECIFIC;
266 }
267 
cec_is_unregistered(__u16 log_addr_mask)268 static inline int cec_is_unregistered(__u16 log_addr_mask)
269 {
270 	return log_addr_mask & CEC_LOG_ADDR_MASK_UNREGISTERED;
271 }
272 
cec_is_unconfigured(__u16 log_addr_mask)273 static inline int cec_is_unconfigured(__u16 log_addr_mask)
274 {
275 	return log_addr_mask == 0;
276 }
277 
278 /*
279  * Use this if there is no vendor ID (CEC_G_VENDOR_ID) or if the vendor ID
280  * should be disabled (CEC_S_VENDOR_ID)
281  */
282 #define CEC_VENDOR_ID_NONE		0xffffffff
283 
284 /* The message handling modes */
285 /* Modes for initiator */
286 #define CEC_MODE_NO_INITIATOR		(0x0 << 0)
287 #define CEC_MODE_INITIATOR		(0x1 << 0)
288 #define CEC_MODE_EXCL_INITIATOR		(0x2 << 0)
289 #define CEC_MODE_INITIATOR_MSK		0x0f
290 
291 /* Modes for follower */
292 #define CEC_MODE_NO_FOLLOWER		(0x0 << 4)
293 #define CEC_MODE_FOLLOWER		(0x1 << 4)
294 #define CEC_MODE_EXCL_FOLLOWER		(0x2 << 4)
295 #define CEC_MODE_EXCL_FOLLOWER_PASSTHRU	(0x3 << 4)
296 #define CEC_MODE_MONITOR_PIN		(0xd << 4)
297 #define CEC_MODE_MONITOR		(0xe << 4)
298 #define CEC_MODE_MONITOR_ALL		(0xf << 4)
299 #define CEC_MODE_FOLLOWER_MSK		0xf0
300 
301 /* Userspace has to configure the physical address */
302 #define CEC_CAP_PHYS_ADDR	(1 << 0)
303 /* Userspace has to configure the logical addresses */
304 #define CEC_CAP_LOG_ADDRS	(1 << 1)
305 /* Userspace can transmit messages (and thus become follower as well) */
306 #define CEC_CAP_TRANSMIT	(1 << 2)
307 /*
308  * Passthrough all messages instead of processing them.
309  */
310 #define CEC_CAP_PASSTHROUGH	(1 << 3)
311 /* Supports remote control */
312 #define CEC_CAP_RC		(1 << 4)
313 /* Hardware can monitor all messages, not just directed and broadcast. */
314 #define CEC_CAP_MONITOR_ALL	(1 << 5)
315 /* Hardware can use CEC only if the HDMI HPD pin is high. */
316 #define CEC_CAP_NEEDS_HPD	(1 << 6)
317 /* Hardware can monitor CEC pin transitions */
318 #define CEC_CAP_MONITOR_PIN	(1 << 7)
319 
320 /**
321  * struct cec_caps - CEC capabilities structure.
322  * @driver: name of the CEC device driver.
323  * @name: name of the CEC device. @driver + @name must be unique.
324  * @available_log_addrs: number of available logical addresses.
325  * @capabilities: capabilities of the CEC adapter.
326  * @version: version of the CEC adapter framework.
327  */
328 struct cec_caps {
329 	char driver[32];
330 	char name[32];
331 	__u32 available_log_addrs;
332 	__u32 capabilities;
333 	__u32 version;
334 };
335 
336 /**
337  * struct cec_log_addrs - CEC logical addresses structure.
338  * @log_addr: the claimed logical addresses. Set by the driver.
339  * @log_addr_mask: current logical address mask. Set by the driver.
340  * @cec_version: the CEC version that the adapter should implement. Set by the
341  *	caller.
342  * @num_log_addrs: how many logical addresses should be claimed. Set by the
343  *	caller.
344  * @vendor_id: the vendor ID of the device. Set by the caller.
345  * @flags: flags.
346  * @osd_name: the OSD name of the device. Set by the caller.
347  * @primary_device_type: the primary device type for each logical address.
348  *	Set by the caller.
349  * @log_addr_type: the logical address types. Set by the caller.
350  * @all_device_types: CEC 2.0: all device types represented by the logical
351  *	address. Set by the caller.
352  * @features:	CEC 2.0: The logical address features. Set by the caller.
353  */
354 struct cec_log_addrs {
355 	__u8 log_addr[CEC_MAX_LOG_ADDRS];
356 	__u16 log_addr_mask;
357 	__u8 cec_version;
358 	__u8 num_log_addrs;
359 	__u32 vendor_id;
360 	__u32 flags;
361 	char osd_name[15];
362 	__u8 primary_device_type[CEC_MAX_LOG_ADDRS];
363 	__u8 log_addr_type[CEC_MAX_LOG_ADDRS];
364 
365 	/* CEC 2.0 */
366 	__u8 all_device_types[CEC_MAX_LOG_ADDRS];
367 	__u8 features[CEC_MAX_LOG_ADDRS][12];
368 };
369 
370 /* Allow a fallback to unregistered */
371 #define CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK	(1 << 0)
372 /* Passthrough RC messages to the input subsystem */
373 #define CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU	(1 << 1)
374 /* CDC-Only device: supports only CDC messages */
375 #define CEC_LOG_ADDRS_FL_CDC_ONLY		(1 << 2)
376 
377 /* Events */
378 
379 /* Event that occurs when the adapter state changes */
380 #define CEC_EVENT_STATE_CHANGE		1
381 /*
382  * This event is sent when messages are lost because the application
383  * didn't empty the message queue in time
384  */
385 #define CEC_EVENT_LOST_MSGS		2
386 #define CEC_EVENT_PIN_CEC_LOW		3
387 #define CEC_EVENT_PIN_CEC_HIGH		4
388 #define CEC_EVENT_PIN_HPD_LOW		5
389 #define CEC_EVENT_PIN_HPD_HIGH		6
390 #define CEC_EVENT_PIN_5V_LOW		7
391 #define CEC_EVENT_PIN_5V_HIGH		8
392 
393 #define CEC_EVENT_FL_INITIAL_STATE	(1 << 0)
394 #define CEC_EVENT_FL_DROPPED_EVENTS	(1 << 1)
395 
396 /**
397  * struct cec_event_state_change - used when the CEC adapter changes state.
398  * @phys_addr: the current physical address
399  * @log_addr_mask: the current logical address mask
400  */
401 struct cec_event_state_change {
402 	__u16 phys_addr;
403 	__u16 log_addr_mask;
404 };
405 
406 /**
407  * struct cec_event_lost_msgs - tells you how many messages were lost.
408  * @lost_msgs: how many messages were lost.
409  */
410 struct cec_event_lost_msgs {
411 	__u32 lost_msgs;
412 };
413 
414 /**
415  * struct cec_event - CEC event structure
416  * @ts: the timestamp of when the event was sent.
417  * @event: the event.
418  * array.
419  * @state_change: the event payload for CEC_EVENT_STATE_CHANGE.
420  * @lost_msgs: the event payload for CEC_EVENT_LOST_MSGS.
421  * @raw: array to pad the union.
422  */
423 struct cec_event {
424 	__u64 ts;
425 	__u32 event;
426 	__u32 flags;
427 	union {
428 		struct cec_event_state_change state_change;
429 		struct cec_event_lost_msgs lost_msgs;
430 		__u32 raw[16];
431 	};
432 };
433 
434 /* ioctls */
435 
436 /* Adapter capabilities */
437 #define CEC_ADAP_G_CAPS		_IOWR('a',  0, struct cec_caps)
438 
439 /*
440  * phys_addr is either 0 (if this is the CEC root device)
441  * or a valid physical address obtained from the sink's EDID
442  * as read by this CEC device (if this is a source device)
443  * or a physical address obtained and modified from a sink
444  * EDID and used for a sink CEC device.
445  * If nothing is connected, then phys_addr is 0xffff.
446  * See HDMI 1.4b, section 8.7 (Physical Address).
447  *
448  * The CEC_ADAP_S_PHYS_ADDR ioctl may not be available if that is handled
449  * internally.
450  */
451 #define CEC_ADAP_G_PHYS_ADDR	_IOR('a',  1, __u16)
452 #define CEC_ADAP_S_PHYS_ADDR	_IOW('a',  2, __u16)
453 
454 /*
455  * Configure the CEC adapter. It sets the device type and which
456  * logical types it will try to claim. It will return which
457  * logical addresses it could actually claim.
458  * An error is returned if the adapter is disabled or if there
459  * is no physical address assigned.
460  */
461 
462 #define CEC_ADAP_G_LOG_ADDRS	_IOR('a',  3, struct cec_log_addrs)
463 #define CEC_ADAP_S_LOG_ADDRS	_IOWR('a',  4, struct cec_log_addrs)
464 
465 /* Transmit/receive a CEC command */
466 #define CEC_TRANSMIT		_IOWR('a',  5, struct cec_msg)
467 #define CEC_RECEIVE		_IOWR('a',  6, struct cec_msg)
468 
469 /* Dequeue CEC events */
470 #define CEC_DQEVENT		_IOWR('a',  7, struct cec_event)
471 
472 /*
473  * Get and set the message handling mode for this filehandle.
474  */
475 #define CEC_G_MODE		_IOR('a',  8, __u32)
476 #define CEC_S_MODE		_IOW('a',  9, __u32)
477 
478 /*
479  * The remainder of this header defines all CEC messages and operands.
480  * The format matters since it the cec-ctl utility parses it to generate
481  * code for implementing all these messages.
482  *
483  * Comments ending with 'Feature' group messages for each feature.
484  * If messages are part of multiple features, then the "Has also"
485  * comment is used to list the previously defined messages that are
486  * supported by the feature.
487  *
488  * Before operands are defined a comment is added that gives the
489  * name of the operand and in brackets the variable name of the
490  * corresponding argument in the cec-funcs.h function.
491  */
492 
493 /* Messages */
494 
495 /* One Touch Play Feature */
496 #define CEC_MSG_ACTIVE_SOURCE				0x82
497 #define CEC_MSG_IMAGE_VIEW_ON				0x04
498 #define CEC_MSG_TEXT_VIEW_ON				0x0d
499 
500 
501 /* Routing Control Feature */
502 
503 /*
504  * Has also:
505  *	CEC_MSG_ACTIVE_SOURCE
506  */
507 
508 #define CEC_MSG_INACTIVE_SOURCE				0x9d
509 #define CEC_MSG_REQUEST_ACTIVE_SOURCE			0x85
510 #define CEC_MSG_ROUTING_CHANGE				0x80
511 #define CEC_MSG_ROUTING_INFORMATION			0x81
512 #define CEC_MSG_SET_STREAM_PATH				0x86
513 
514 
515 /* Standby Feature */
516 #define CEC_MSG_STANDBY					0x36
517 
518 
519 /* One Touch Record Feature */
520 #define CEC_MSG_RECORD_OFF				0x0b
521 #define CEC_MSG_RECORD_ON				0x09
522 /* Record Source Type Operand (rec_src_type) */
523 #define CEC_OP_RECORD_SRC_OWN				1
524 #define CEC_OP_RECORD_SRC_DIGITAL			2
525 #define CEC_OP_RECORD_SRC_ANALOG			3
526 #define CEC_OP_RECORD_SRC_EXT_PLUG			4
527 #define CEC_OP_RECORD_SRC_EXT_PHYS_ADDR			5
528 /* Service Identification Method Operand (service_id_method) */
529 #define CEC_OP_SERVICE_ID_METHOD_BY_DIG_ID		0
530 #define CEC_OP_SERVICE_ID_METHOD_BY_CHANNEL		1
531 /* Digital Service Broadcast System Operand (dig_bcast_system) */
532 #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ARIB_GEN	0x00
533 #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_GEN	0x01
534 #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_GEN		0x02
535 #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ARIB_BS		0x08
536 #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ARIB_CS		0x09
537 #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ARIB_T		0x0a
538 #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_CABLE	0x10
539 #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_SAT	0x11
540 #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_T		0x12
541 #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_C		0x18
542 #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_S		0x19
543 #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_S2		0x1a
544 #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_T		0x1b
545 /* Analogue Broadcast Type Operand (ana_bcast_type) */
546 #define CEC_OP_ANA_BCAST_TYPE_CABLE			0
547 #define CEC_OP_ANA_BCAST_TYPE_SATELLITE			1
548 #define CEC_OP_ANA_BCAST_TYPE_TERRESTRIAL		2
549 /* Broadcast System Operand (bcast_system) */
550 #define CEC_OP_BCAST_SYSTEM_PAL_BG			0x00
551 #define CEC_OP_BCAST_SYSTEM_SECAM_LQ			0x01 /* SECAM L' */
552 #define CEC_OP_BCAST_SYSTEM_PAL_M			0x02
553 #define CEC_OP_BCAST_SYSTEM_NTSC_M			0x03
554 #define CEC_OP_BCAST_SYSTEM_PAL_I			0x04
555 #define CEC_OP_BCAST_SYSTEM_SECAM_DK			0x05
556 #define CEC_OP_BCAST_SYSTEM_SECAM_BG			0x06
557 #define CEC_OP_BCAST_SYSTEM_SECAM_L			0x07
558 #define CEC_OP_BCAST_SYSTEM_PAL_DK			0x08
559 #define CEC_OP_BCAST_SYSTEM_OTHER			0x1f
560 /* Channel Number Format Operand (channel_number_fmt) */
561 #define CEC_OP_CHANNEL_NUMBER_FMT_1_PART		0x01
562 #define CEC_OP_CHANNEL_NUMBER_FMT_2_PART		0x02
563 
564 #define CEC_MSG_RECORD_STATUS				0x0a
565 /* Record Status Operand (rec_status) */
566 #define CEC_OP_RECORD_STATUS_CUR_SRC			0x01
567 #define CEC_OP_RECORD_STATUS_DIG_SERVICE		0x02
568 #define CEC_OP_RECORD_STATUS_ANA_SERVICE		0x03
569 #define CEC_OP_RECORD_STATUS_EXT_INPUT			0x04
570 #define CEC_OP_RECORD_STATUS_NO_DIG_SERVICE		0x05
571 #define CEC_OP_RECORD_STATUS_NO_ANA_SERVICE		0x06
572 #define CEC_OP_RECORD_STATUS_NO_SERVICE			0x07
573 #define CEC_OP_RECORD_STATUS_INVALID_EXT_PLUG		0x09
574 #define CEC_OP_RECORD_STATUS_INVALID_EXT_PHYS_ADDR	0x0a
575 #define CEC_OP_RECORD_STATUS_UNSUP_CA			0x0b
576 #define CEC_OP_RECORD_STATUS_NO_CA_ENTITLEMENTS		0x0c
577 #define CEC_OP_RECORD_STATUS_CANT_COPY_SRC		0x0d
578 #define CEC_OP_RECORD_STATUS_NO_MORE_COPIES		0x0e
579 #define CEC_OP_RECORD_STATUS_NO_MEDIA			0x10
580 #define CEC_OP_RECORD_STATUS_PLAYING			0x11
581 #define CEC_OP_RECORD_STATUS_ALREADY_RECORDING		0x12
582 #define CEC_OP_RECORD_STATUS_MEDIA_PROT			0x13
583 #define CEC_OP_RECORD_STATUS_NO_SIGNAL			0x14
584 #define CEC_OP_RECORD_STATUS_MEDIA_PROBLEM		0x15
585 #define CEC_OP_RECORD_STATUS_NO_SPACE			0x16
586 #define CEC_OP_RECORD_STATUS_PARENTAL_LOCK		0x17
587 #define CEC_OP_RECORD_STATUS_TERMINATED_OK		0x1a
588 #define CEC_OP_RECORD_STATUS_ALREADY_TERM		0x1b
589 #define CEC_OP_RECORD_STATUS_OTHER			0x1f
590 
591 #define CEC_MSG_RECORD_TV_SCREEN			0x0f
592 
593 
594 /* Timer Programming Feature */
595 #define CEC_MSG_CLEAR_ANALOGUE_TIMER			0x33
596 /* Recording Sequence Operand (recording_seq) */
597 #define CEC_OP_REC_SEQ_SUNDAY				0x01
598 #define CEC_OP_REC_SEQ_MONDAY				0x02
599 #define CEC_OP_REC_SEQ_TUESDAY				0x04
600 #define CEC_OP_REC_SEQ_WEDNESDAY			0x08
601 #define CEC_OP_REC_SEQ_THURSDAY				0x10
602 #define CEC_OP_REC_SEQ_FRIDAY				0x20
603 #define CEC_OP_REC_SEQ_SATERDAY				0x40
604 #define CEC_OP_REC_SEQ_ONCE_ONLY			0x00
605 
606 #define CEC_MSG_CLEAR_DIGITAL_TIMER			0x99
607 
608 #define CEC_MSG_CLEAR_EXT_TIMER				0xa1
609 /* External Source Specifier Operand (ext_src_spec) */
610 #define CEC_OP_EXT_SRC_PLUG				0x04
611 #define CEC_OP_EXT_SRC_PHYS_ADDR			0x05
612 
613 #define CEC_MSG_SET_ANALOGUE_TIMER			0x34
614 #define CEC_MSG_SET_DIGITAL_TIMER			0x97
615 #define CEC_MSG_SET_EXT_TIMER				0xa2
616 
617 #define CEC_MSG_SET_TIMER_PROGRAM_TITLE			0x67
618 #define CEC_MSG_TIMER_CLEARED_STATUS			0x43
619 /* Timer Cleared Status Data Operand (timer_cleared_status) */
620 #define CEC_OP_TIMER_CLR_STAT_RECORDING			0x00
621 #define CEC_OP_TIMER_CLR_STAT_NO_MATCHING		0x01
622 #define CEC_OP_TIMER_CLR_STAT_NO_INFO			0x02
623 #define CEC_OP_TIMER_CLR_STAT_CLEARED			0x80
624 
625 #define CEC_MSG_TIMER_STATUS				0x35
626 /* Timer Overlap Warning Operand (timer_overlap_warning) */
627 #define CEC_OP_TIMER_OVERLAP_WARNING_NO_OVERLAP		0
628 #define CEC_OP_TIMER_OVERLAP_WARNING_OVERLAP		1
629 /* Media Info Operand (media_info) */
630 #define CEC_OP_MEDIA_INFO_UNPROT_MEDIA			0
631 #define CEC_OP_MEDIA_INFO_PROT_MEDIA			1
632 #define CEC_OP_MEDIA_INFO_NO_MEDIA			2
633 /* Programmed Indicator Operand (prog_indicator) */
634 #define CEC_OP_PROG_IND_NOT_PROGRAMMED			0
635 #define CEC_OP_PROG_IND_PROGRAMMED			1
636 /* Programmed Info Operand (prog_info) */
637 #define CEC_OP_PROG_INFO_ENOUGH_SPACE			0x08
638 #define CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE		0x09
639 #define CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE	0x0b
640 #define CEC_OP_PROG_INFO_NONE_AVAILABLE			0x0a
641 /* Not Programmed Error Info Operand (prog_error) */
642 #define CEC_OP_PROG_ERROR_NO_FREE_TIMER			0x01
643 #define CEC_OP_PROG_ERROR_DATE_OUT_OF_RANGE		0x02
644 #define CEC_OP_PROG_ERROR_REC_SEQ_ERROR			0x03
645 #define CEC_OP_PROG_ERROR_INV_EXT_PLUG			0x04
646 #define CEC_OP_PROG_ERROR_INV_EXT_PHYS_ADDR		0x05
647 #define CEC_OP_PROG_ERROR_CA_UNSUPP			0x06
648 #define CEC_OP_PROG_ERROR_INSUF_CA_ENTITLEMENTS		0x07
649 #define CEC_OP_PROG_ERROR_RESOLUTION_UNSUPP		0x08
650 #define CEC_OP_PROG_ERROR_PARENTAL_LOCK			0x09
651 #define CEC_OP_PROG_ERROR_CLOCK_FAILURE			0x0a
652 #define CEC_OP_PROG_ERROR_DUPLICATE			0x0e
653 
654 
655 /* System Information Feature */
656 #define CEC_MSG_CEC_VERSION				0x9e
657 /* CEC Version Operand (cec_version) */
658 #define CEC_OP_CEC_VERSION_1_3A				4
659 #define CEC_OP_CEC_VERSION_1_4				5
660 #define CEC_OP_CEC_VERSION_2_0				6
661 
662 #define CEC_MSG_GET_CEC_VERSION				0x9f
663 #define CEC_MSG_GIVE_PHYSICAL_ADDR			0x83
664 #define CEC_MSG_GET_MENU_LANGUAGE			0x91
665 #define CEC_MSG_REPORT_PHYSICAL_ADDR			0x84
666 /* Primary Device Type Operand (prim_devtype) */
667 #define CEC_OP_PRIM_DEVTYPE_TV				0
668 #define CEC_OP_PRIM_DEVTYPE_RECORD			1
669 #define CEC_OP_PRIM_DEVTYPE_TUNER			3
670 #define CEC_OP_PRIM_DEVTYPE_PLAYBACK			4
671 #define CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM			5
672 #define CEC_OP_PRIM_DEVTYPE_SWITCH			6
673 #define CEC_OP_PRIM_DEVTYPE_PROCESSOR			7
674 
675 #define CEC_MSG_SET_MENU_LANGUAGE			0x32
676 #define CEC_MSG_REPORT_FEATURES				0xa6	/* HDMI 2.0 */
677 /* All Device Types Operand (all_device_types) */
678 #define CEC_OP_ALL_DEVTYPE_TV				0x80
679 #define CEC_OP_ALL_DEVTYPE_RECORD			0x40
680 #define CEC_OP_ALL_DEVTYPE_TUNER			0x20
681 #define CEC_OP_ALL_DEVTYPE_PLAYBACK			0x10
682 #define CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM			0x08
683 #define CEC_OP_ALL_DEVTYPE_SWITCH			0x04
684 /*
685  * And if you wondering what happened to PROCESSOR devices: those should
686  * be mapped to a SWITCH.
687  */
688 
689 /* Valid for RC Profile and Device Feature operands */
690 #define CEC_OP_FEAT_EXT					0x80	/* Extension bit */
691 /* RC Profile Operand (rc_profile) */
692 #define CEC_OP_FEAT_RC_TV_PROFILE_NONE			0x00
693 #define CEC_OP_FEAT_RC_TV_PROFILE_1			0x02
694 #define CEC_OP_FEAT_RC_TV_PROFILE_2			0x06
695 #define CEC_OP_FEAT_RC_TV_PROFILE_3			0x0a
696 #define CEC_OP_FEAT_RC_TV_PROFILE_4			0x0e
697 #define CEC_OP_FEAT_RC_SRC_HAS_DEV_ROOT_MENU		0x50
698 #define CEC_OP_FEAT_RC_SRC_HAS_DEV_SETUP_MENU		0x48
699 #define CEC_OP_FEAT_RC_SRC_HAS_CONTENTS_MENU		0x44
700 #define CEC_OP_FEAT_RC_SRC_HAS_MEDIA_TOP_MENU		0x42
701 #define CEC_OP_FEAT_RC_SRC_HAS_MEDIA_CONTEXT_MENU	0x41
702 /* Device Feature Operand (dev_features) */
703 #define CEC_OP_FEAT_DEV_HAS_RECORD_TV_SCREEN		0x40
704 #define CEC_OP_FEAT_DEV_HAS_SET_OSD_STRING		0x20
705 #define CEC_OP_FEAT_DEV_HAS_DECK_CONTROL		0x10
706 #define CEC_OP_FEAT_DEV_HAS_SET_AUDIO_RATE		0x08
707 #define CEC_OP_FEAT_DEV_SINK_HAS_ARC_TX			0x04
708 #define CEC_OP_FEAT_DEV_SOURCE_HAS_ARC_RX		0x02
709 
710 #define CEC_MSG_GIVE_FEATURES				0xa5	/* HDMI 2.0 */
711 
712 
713 /* Deck Control Feature */
714 #define CEC_MSG_DECK_CONTROL				0x42
715 /* Deck Control Mode Operand (deck_control_mode) */
716 #define CEC_OP_DECK_CTL_MODE_SKIP_FWD			1
717 #define CEC_OP_DECK_CTL_MODE_SKIP_REV			2
718 #define CEC_OP_DECK_CTL_MODE_STOP			3
719 #define CEC_OP_DECK_CTL_MODE_EJECT			4
720 
721 #define CEC_MSG_DECK_STATUS				0x1b
722 /* Deck Info Operand (deck_info) */
723 #define CEC_OP_DECK_INFO_PLAY				0x11
724 #define CEC_OP_DECK_INFO_RECORD				0x12
725 #define CEC_OP_DECK_INFO_PLAY_REV			0x13
726 #define CEC_OP_DECK_INFO_STILL				0x14
727 #define CEC_OP_DECK_INFO_SLOW				0x15
728 #define CEC_OP_DECK_INFO_SLOW_REV			0x16
729 #define CEC_OP_DECK_INFO_FAST_FWD			0x17
730 #define CEC_OP_DECK_INFO_FAST_REV			0x18
731 #define CEC_OP_DECK_INFO_NO_MEDIA			0x19
732 #define CEC_OP_DECK_INFO_STOP				0x1a
733 #define CEC_OP_DECK_INFO_SKIP_FWD			0x1b
734 #define CEC_OP_DECK_INFO_SKIP_REV			0x1c
735 #define CEC_OP_DECK_INFO_INDEX_SEARCH_FWD		0x1d
736 #define CEC_OP_DECK_INFO_INDEX_SEARCH_REV		0x1e
737 #define CEC_OP_DECK_INFO_OTHER				0x1f
738 
739 #define CEC_MSG_GIVE_DECK_STATUS			0x1a
740 /* Status Request Operand (status_req) */
741 #define CEC_OP_STATUS_REQ_ON				1
742 #define CEC_OP_STATUS_REQ_OFF				2
743 #define CEC_OP_STATUS_REQ_ONCE				3
744 
745 #define CEC_MSG_PLAY					0x41
746 /* Play Mode Operand (play_mode) */
747 #define CEC_OP_PLAY_MODE_PLAY_FWD			0x24
748 #define CEC_OP_PLAY_MODE_PLAY_REV			0x20
749 #define CEC_OP_PLAY_MODE_PLAY_STILL			0x25
750 #define CEC_OP_PLAY_MODE_PLAY_FAST_FWD_MIN		0x05
751 #define CEC_OP_PLAY_MODE_PLAY_FAST_FWD_MED		0x06
752 #define CEC_OP_PLAY_MODE_PLAY_FAST_FWD_MAX		0x07
753 #define CEC_OP_PLAY_MODE_PLAY_FAST_REV_MIN		0x09
754 #define CEC_OP_PLAY_MODE_PLAY_FAST_REV_MED		0x0a
755 #define CEC_OP_PLAY_MODE_PLAY_FAST_REV_MAX		0x0b
756 #define CEC_OP_PLAY_MODE_PLAY_SLOW_FWD_MIN		0x15
757 #define CEC_OP_PLAY_MODE_PLAY_SLOW_FWD_MED		0x16
758 #define CEC_OP_PLAY_MODE_PLAY_SLOW_FWD_MAX		0x17
759 #define CEC_OP_PLAY_MODE_PLAY_SLOW_REV_MIN		0x19
760 #define CEC_OP_PLAY_MODE_PLAY_SLOW_REV_MED		0x1a
761 #define CEC_OP_PLAY_MODE_PLAY_SLOW_REV_MAX		0x1b
762 
763 
764 /* Tuner Control Feature */
765 #define CEC_MSG_GIVE_TUNER_DEVICE_STATUS		0x08
766 #define CEC_MSG_SELECT_ANALOGUE_SERVICE			0x92
767 #define CEC_MSG_SELECT_DIGITAL_SERVICE			0x93
768 #define CEC_MSG_TUNER_DEVICE_STATUS			0x07
769 /* Recording Flag Operand (rec_flag) */
770 #define CEC_OP_REC_FLAG_NOT_USED			0
771 #define CEC_OP_REC_FLAG_USED				1
772 /* Tuner Display Info Operand (tuner_display_info) */
773 #define CEC_OP_TUNER_DISPLAY_INFO_DIGITAL		0
774 #define CEC_OP_TUNER_DISPLAY_INFO_NONE			1
775 #define CEC_OP_TUNER_DISPLAY_INFO_ANALOGUE		2
776 
777 #define CEC_MSG_TUNER_STEP_DECREMENT			0x06
778 #define CEC_MSG_TUNER_STEP_INCREMENT			0x05
779 
780 
781 /* Vendor Specific Commands Feature */
782 
783 /*
784  * Has also:
785  *	CEC_MSG_CEC_VERSION
786  *	CEC_MSG_GET_CEC_VERSION
787  */
788 #define CEC_MSG_DEVICE_VENDOR_ID			0x87
789 #define CEC_MSG_GIVE_DEVICE_VENDOR_ID			0x8c
790 #define CEC_MSG_VENDOR_COMMAND				0x89
791 #define CEC_MSG_VENDOR_COMMAND_WITH_ID			0xa0
792 #define CEC_MSG_VENDOR_REMOTE_BUTTON_DOWN		0x8a
793 #define CEC_MSG_VENDOR_REMOTE_BUTTON_UP			0x8b
794 
795 
796 /* OSD Display Feature */
797 #define CEC_MSG_SET_OSD_STRING				0x64
798 /* Display Control Operand (disp_ctl) */
799 #define CEC_OP_DISP_CTL_DEFAULT				0x00
800 #define CEC_OP_DISP_CTL_UNTIL_CLEARED			0x40
801 #define CEC_OP_DISP_CTL_CLEAR				0x80
802 
803 
804 /* Device OSD Transfer Feature */
805 #define CEC_MSG_GIVE_OSD_NAME				0x46
806 #define CEC_MSG_SET_OSD_NAME				0x47
807 
808 
809 /* Device Menu Control Feature */
810 #define CEC_MSG_MENU_REQUEST				0x8d
811 /* Menu Request Type Operand (menu_req) */
812 #define CEC_OP_MENU_REQUEST_ACTIVATE			0x00
813 #define CEC_OP_MENU_REQUEST_DEACTIVATE			0x01
814 #define CEC_OP_MENU_REQUEST_QUERY			0x02
815 
816 #define CEC_MSG_MENU_STATUS				0x8e
817 /* Menu State Operand (menu_state) */
818 #define CEC_OP_MENU_STATE_ACTIVATED			0x00
819 #define CEC_OP_MENU_STATE_DEACTIVATED			0x01
820 
821 #define CEC_MSG_USER_CONTROL_PRESSED			0x44
822 /* UI Broadcast Type Operand (ui_bcast_type) */
823 #define CEC_OP_UI_BCAST_TYPE_TOGGLE_ALL			0x00
824 #define CEC_OP_UI_BCAST_TYPE_TOGGLE_DIG_ANA		0x01
825 #define CEC_OP_UI_BCAST_TYPE_ANALOGUE			0x10
826 #define CEC_OP_UI_BCAST_TYPE_ANALOGUE_T			0x20
827 #define CEC_OP_UI_BCAST_TYPE_ANALOGUE_CABLE		0x30
828 #define CEC_OP_UI_BCAST_TYPE_ANALOGUE_SAT		0x40
829 #define CEC_OP_UI_BCAST_TYPE_DIGITAL			0x50
830 #define CEC_OP_UI_BCAST_TYPE_DIGITAL_T			0x60
831 #define CEC_OP_UI_BCAST_TYPE_DIGITAL_CABLE		0x70
832 #define CEC_OP_UI_BCAST_TYPE_DIGITAL_SAT		0x80
833 #define CEC_OP_UI_BCAST_TYPE_DIGITAL_COM_SAT		0x90
834 #define CEC_OP_UI_BCAST_TYPE_DIGITAL_COM_SAT2		0x91
835 #define CEC_OP_UI_BCAST_TYPE_IP				0xa0
836 /* UI Sound Presentation Control Operand (ui_snd_pres_ctl) */
837 #define CEC_OP_UI_SND_PRES_CTL_DUAL_MONO		0x10
838 #define CEC_OP_UI_SND_PRES_CTL_KARAOKE			0x20
839 #define CEC_OP_UI_SND_PRES_CTL_DOWNMIX			0x80
840 #define CEC_OP_UI_SND_PRES_CTL_REVERB			0x90
841 #define CEC_OP_UI_SND_PRES_CTL_EQUALIZER		0xa0
842 #define CEC_OP_UI_SND_PRES_CTL_BASS_UP			0xb1
843 #define CEC_OP_UI_SND_PRES_CTL_BASS_NEUTRAL		0xb2
844 #define CEC_OP_UI_SND_PRES_CTL_BASS_DOWN		0xb3
845 #define CEC_OP_UI_SND_PRES_CTL_TREBLE_UP		0xc1
846 #define CEC_OP_UI_SND_PRES_CTL_TREBLE_NEUTRAL		0xc2
847 #define CEC_OP_UI_SND_PRES_CTL_TREBLE_DOWN		0xc3
848 
849 #define CEC_MSG_USER_CONTROL_RELEASED			0x45
850 
851 
852 /* Remote Control Passthrough Feature */
853 
854 /*
855  * Has also:
856  *	CEC_MSG_USER_CONTROL_PRESSED
857  *	CEC_MSG_USER_CONTROL_RELEASED
858  */
859 
860 
861 /* Power Status Feature */
862 #define CEC_MSG_GIVE_DEVICE_POWER_STATUS		0x8f
863 #define CEC_MSG_REPORT_POWER_STATUS			0x90
864 /* Power Status Operand (pwr_state) */
865 #define CEC_OP_POWER_STATUS_ON				0
866 #define CEC_OP_POWER_STATUS_STANDBY			1
867 #define CEC_OP_POWER_STATUS_TO_ON			2
868 #define CEC_OP_POWER_STATUS_TO_STANDBY			3
869 
870 
871 /* General Protocol Messages */
872 #define CEC_MSG_FEATURE_ABORT				0x00
873 /* Abort Reason Operand (reason) */
874 #define CEC_OP_ABORT_UNRECOGNIZED_OP			0
875 #define CEC_OP_ABORT_INCORRECT_MODE			1
876 #define CEC_OP_ABORT_NO_SOURCE				2
877 #define CEC_OP_ABORT_INVALID_OP				3
878 #define CEC_OP_ABORT_REFUSED				4
879 #define CEC_OP_ABORT_UNDETERMINED			5
880 
881 #define CEC_MSG_ABORT					0xff
882 
883 
884 /* System Audio Control Feature */
885 
886 /*
887  * Has also:
888  *	CEC_MSG_USER_CONTROL_PRESSED
889  *	CEC_MSG_USER_CONTROL_RELEASED
890  */
891 #define CEC_MSG_GIVE_AUDIO_STATUS			0x71
892 #define CEC_MSG_GIVE_SYSTEM_AUDIO_MODE_STATUS		0x7d
893 #define CEC_MSG_REPORT_AUDIO_STATUS			0x7a
894 /* Audio Mute Status Operand (aud_mute_status) */
895 #define CEC_OP_AUD_MUTE_STATUS_OFF			0
896 #define CEC_OP_AUD_MUTE_STATUS_ON			1
897 
898 #define CEC_MSG_REPORT_SHORT_AUDIO_DESCRIPTOR		0xa3
899 #define CEC_MSG_REQUEST_SHORT_AUDIO_DESCRIPTOR		0xa4
900 #define CEC_MSG_SET_SYSTEM_AUDIO_MODE			0x72
901 /* System Audio Status Operand (sys_aud_status) */
902 #define CEC_OP_SYS_AUD_STATUS_OFF			0
903 #define CEC_OP_SYS_AUD_STATUS_ON			1
904 
905 #define CEC_MSG_SYSTEM_AUDIO_MODE_REQUEST		0x70
906 #define CEC_MSG_SYSTEM_AUDIO_MODE_STATUS		0x7e
907 /* Audio Format ID Operand (audio_format_id) */
908 #define CEC_OP_AUD_FMT_ID_CEA861			0
909 #define CEC_OP_AUD_FMT_ID_CEA861_CXT			1
910 
911 
912 /* Audio Rate Control Feature */
913 #define CEC_MSG_SET_AUDIO_RATE				0x9a
914 /* Audio Rate Operand (audio_rate) */
915 #define CEC_OP_AUD_RATE_OFF				0
916 #define CEC_OP_AUD_RATE_WIDE_STD			1
917 #define CEC_OP_AUD_RATE_WIDE_FAST			2
918 #define CEC_OP_AUD_RATE_WIDE_SLOW			3
919 #define CEC_OP_AUD_RATE_NARROW_STD			4
920 #define CEC_OP_AUD_RATE_NARROW_FAST			5
921 #define CEC_OP_AUD_RATE_NARROW_SLOW			6
922 
923 
924 /* Audio Return Channel Control Feature */
925 #define CEC_MSG_INITIATE_ARC				0xc0
926 #define CEC_MSG_REPORT_ARC_INITIATED			0xc1
927 #define CEC_MSG_REPORT_ARC_TERMINATED			0xc2
928 #define CEC_MSG_REQUEST_ARC_INITIATION			0xc3
929 #define CEC_MSG_REQUEST_ARC_TERMINATION			0xc4
930 #define CEC_MSG_TERMINATE_ARC				0xc5
931 
932 
933 /* Dynamic Audio Lipsync Feature */
934 /* Only for CEC 2.0 and up */
935 #define CEC_MSG_REQUEST_CURRENT_LATENCY			0xa7
936 #define CEC_MSG_REPORT_CURRENT_LATENCY			0xa8
937 /* Low Latency Mode Operand (low_latency_mode) */
938 #define CEC_OP_LOW_LATENCY_MODE_OFF			0
939 #define CEC_OP_LOW_LATENCY_MODE_ON			1
940 /* Audio Output Compensated Operand (audio_out_compensated) */
941 #define CEC_OP_AUD_OUT_COMPENSATED_NA			0
942 #define CEC_OP_AUD_OUT_COMPENSATED_DELAY		1
943 #define CEC_OP_AUD_OUT_COMPENSATED_NO_DELAY		2
944 #define CEC_OP_AUD_OUT_COMPENSATED_PARTIAL_DELAY	3
945 
946 
947 /* Capability Discovery and Control Feature */
948 #define CEC_MSG_CDC_MESSAGE				0xf8
949 /* Ethernet-over-HDMI: nobody ever does this... */
950 #define CEC_MSG_CDC_HEC_INQUIRE_STATE			0x00
951 #define CEC_MSG_CDC_HEC_REPORT_STATE			0x01
952 /* HEC Functionality State Operand (hec_func_state) */
953 #define CEC_OP_HEC_FUNC_STATE_NOT_SUPPORTED		0
954 #define CEC_OP_HEC_FUNC_STATE_INACTIVE			1
955 #define CEC_OP_HEC_FUNC_STATE_ACTIVE			2
956 #define CEC_OP_HEC_FUNC_STATE_ACTIVATION_FIELD		3
957 /* Host Functionality State Operand (host_func_state) */
958 #define CEC_OP_HOST_FUNC_STATE_NOT_SUPPORTED		0
959 #define CEC_OP_HOST_FUNC_STATE_INACTIVE			1
960 #define CEC_OP_HOST_FUNC_STATE_ACTIVE			2
961 /* ENC Functionality State Operand (enc_func_state) */
962 #define CEC_OP_ENC_FUNC_STATE_EXT_CON_NOT_SUPPORTED	0
963 #define CEC_OP_ENC_FUNC_STATE_EXT_CON_INACTIVE		1
964 #define CEC_OP_ENC_FUNC_STATE_EXT_CON_ACTIVE		2
965 /* CDC Error Code Operand (cdc_errcode) */
966 #define CEC_OP_CDC_ERROR_CODE_NONE			0
967 #define CEC_OP_CDC_ERROR_CODE_CAP_UNSUPPORTED		1
968 #define CEC_OP_CDC_ERROR_CODE_WRONG_STATE		2
969 #define CEC_OP_CDC_ERROR_CODE_OTHER			3
970 /* HEC Support Operand (hec_support) */
971 #define CEC_OP_HEC_SUPPORT_NO				0
972 #define CEC_OP_HEC_SUPPORT_YES				1
973 /* HEC Activation Operand (hec_activation) */
974 #define CEC_OP_HEC_ACTIVATION_ON			0
975 #define CEC_OP_HEC_ACTIVATION_OFF			1
976 
977 #define CEC_MSG_CDC_HEC_SET_STATE_ADJACENT		0x02
978 #define CEC_MSG_CDC_HEC_SET_STATE			0x03
979 /* HEC Set State Operand (hec_set_state) */
980 #define CEC_OP_HEC_SET_STATE_DEACTIVATE			0
981 #define CEC_OP_HEC_SET_STATE_ACTIVATE			1
982 
983 #define CEC_MSG_CDC_HEC_REQUEST_DEACTIVATION		0x04
984 #define CEC_MSG_CDC_HEC_NOTIFY_ALIVE			0x05
985 #define CEC_MSG_CDC_HEC_DISCOVER			0x06
986 /* Hotplug Detect messages */
987 #define CEC_MSG_CDC_HPD_SET_STATE			0x10
988 /* HPD State Operand (hpd_state) */
989 #define CEC_OP_HPD_STATE_CP_EDID_DISABLE		0
990 #define CEC_OP_HPD_STATE_CP_EDID_ENABLE			1
991 #define CEC_OP_HPD_STATE_CP_EDID_DISABLE_ENABLE		2
992 #define CEC_OP_HPD_STATE_EDID_DISABLE			3
993 #define CEC_OP_HPD_STATE_EDID_ENABLE			4
994 #define CEC_OP_HPD_STATE_EDID_DISABLE_ENABLE		5
995 #define CEC_MSG_CDC_HPD_REPORT_STATE			0x11
996 /* HPD Error Code Operand (hpd_error) */
997 #define CEC_OP_HPD_ERROR_NONE				0
998 #define CEC_OP_HPD_ERROR_INITIATOR_NOT_CAPABLE		1
999 #define CEC_OP_HPD_ERROR_INITIATOR_WRONG_STATE		2
1000 #define CEC_OP_HPD_ERROR_OTHER				3
1001 #define CEC_OP_HPD_ERROR_NONE_NO_VIDEO			4
1002 
1003 /* End of Messages */
1004 
1005 /* Helper functions to identify the 'special' CEC devices */
1006 
cec_is_2nd_tv(const struct cec_log_addrs * las)1007 static inline int cec_is_2nd_tv(const struct cec_log_addrs *las)
1008 {
1009 	/*
1010 	 * It is a second TV if the logical address is 14 or 15 and the
1011 	 * primary device type is a TV.
1012 	 */
1013 	return las->num_log_addrs &&
1014 	       las->log_addr[0] >= CEC_LOG_ADDR_SPECIFIC &&
1015 	       las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_TV;
1016 }
1017 
cec_is_processor(const struct cec_log_addrs * las)1018 static inline int cec_is_processor(const struct cec_log_addrs *las)
1019 {
1020 	/*
1021 	 * It is a processor if the logical address is 12-15 and the
1022 	 * primary device type is a Processor.
1023 	 */
1024 	return las->num_log_addrs &&
1025 	       las->log_addr[0] >= CEC_LOG_ADDR_BACKUP_1 &&
1026 	       las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_PROCESSOR;
1027 }
1028 
cec_is_switch(const struct cec_log_addrs * las)1029 static inline int cec_is_switch(const struct cec_log_addrs *las)
1030 {
1031 	/*
1032 	 * It is a switch if the logical address is 15 and the
1033 	 * primary device type is a Switch and the CDC-Only flag is not set.
1034 	 */
1035 	return las->num_log_addrs == 1 &&
1036 	       las->log_addr[0] == CEC_LOG_ADDR_UNREGISTERED &&
1037 	       las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_SWITCH &&
1038 	       !(las->flags & CEC_LOG_ADDRS_FL_CDC_ONLY);
1039 }
1040 
cec_is_cdc_only(const struct cec_log_addrs * las)1041 static inline int cec_is_cdc_only(const struct cec_log_addrs *las)
1042 {
1043 	/*
1044 	 * It is a CDC-only device if the logical address is 15 and the
1045 	 * primary device type is a Switch and the CDC-Only flag is set.
1046 	 */
1047 	return las->num_log_addrs == 1 &&
1048 	       las->log_addr[0] == CEC_LOG_ADDR_UNREGISTERED &&
1049 	       las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_SWITCH &&
1050 	       (las->flags & CEC_LOG_ADDRS_FL_CDC_ONLY);
1051 }
1052 
1053 #endif
1054