• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef HDMI_CEC_H
10 #define HDMI_CEC_H
11 
12 #include "hdf_base.h"
13 
14 #ifdef __cplusplus
15 #if __cplusplus
16 extern "C" {
17 #endif
18 #endif /* __cplusplus */
19 
20 /*
21  * CEC(Consumer Electronics Control).
22  * CEC is a protocol that provides high-level control functions between all of the various audiovisual products
23  * in a user's environment.
24  */
25 
26 /*
27  * One Touch Play Feature/Routing Control Feature.
28  * <Active Source> Used by a new source to indicate that it has started to transmit a stream OR
29  * used in response to a <Request Active Source>.
30  * Param: [Physical Address], 2 bytes.
31  * Broadcast message.
32  */
33 #define HDMI_CEC_OPCODE_ACTIVE_SOURCE 0x82
34 
35 #define HDMI_CEC_ACTIVE_SOURCE_MSG_PARAM_LEN 2
36 
37 /*
38  * One Touch Play Feature.
39  * <Image View On> Sent by a source device to the TV whenever it enters the
40  * active state(alternatively it may send <Text View On>).
41  * Param: None.
42  */
43 #define HDMI_CEC_OPCODE_IMAGE_VIEW_ON 0x04
44 
45 /*
46  * One Touch Play Feature.
47  * <Text View On> As <Image View On>, but should also remove any text, menus and PIP windows from the TV's display.
48  * Param: None.
49  */
50 #define HDMI_CEC_OPCODE_TEXT_VIEW_ON 0x0D
51 
52 /*
53  * Routing Control Feature.
54  * <Inactive Source> Used by currently active source to inform the TV that it has no video to be presented to the user,
55  * or is going into the Standby state as the result of a local user command on the device.
56  * Param: [Physical Address], 2 bytes.
57  */
58 #define HDMI_CEC_OPCODE_INACTIVE_SOURCE 0x9D
59 
60 #define HDMI_CEC_INACTIVE_SOURCE_MSG_PARAM_LEN 2
61 
62 /*
63  * Routing Control Feature.
64  * <Request Active Source> Used by a new device to discover the status of the system.
65  * Param: None.
66  * Broadcast message.
67  */
68 #define HDMI_CEC_OPCODE_REQUEST_ACTIVE_SOURCE 0x85
69 
70 /*
71  * Routing Control Feature.
72  * <Routing Change> Sent By CEC Switch when it is manually switched to inform all other devices on the network that
73  * the active route below the switch has changed.
74  * Param: [Original(Physical) Address], 2 bytes. [New(Physical) Address], 2 bytes.
75  * Broadcast message.
76  */
77 #define HDMI_CEC_OPCODE_ROUTING_CHANGE 0x80
78 
79 #define HDMI_CEC_ROUTING_CHANGE_MSG_PARAM_LEN 4
80 
81 /*
82  * Routing Control Feature.
83  * <Routing Infomation> Sent By a CEC Switch to indicate the active route below the switch.
84  * Param: [Physical Address], 2 bytes.
85  * Broadcast message.
86  */
87 #define HDMI_CEC_OPCODE_ROUTING_INFORMATION 0x81
88 
89 #define HDMI_CEC_ROUTING_INFORMATIO_MSG_PARAM_LEN 2
90 
91 /*
92  * Routing Control Feature.
93  * <Set Stream Path> Used by the TV to request a streaming path from the specified Physical Address.
94  * Param: [Physical Address], 2 bytes.
95  * Broadcast message.
96  */
97 #define HDMI_CEC_OPCODE_SET_STREAM_PATH 0x86
98 
99 #define HDMI_CEC_SET_STREAM_PATH_MSG_PARAM_LEN 2
100 
101 /*
102  * Routing Control Feature.
103  * <Standby> Switches one or all devices into the Standby state.
104  * Can be used as a broadcast message or be addressed to a specific device.
105  * Param: None.
106  */
107 #define HDMI_CEC_OPCODE_STANDBY 0x36
108 
109 /*
110  * One Touch Record Feature.
111  * <Record Off> Request a device stop a recording.
112  * Param: None.
113  */
114 #define HDMI_CEC_OPCODE_RECORD_OFF 0x0B
115 
116 /*
117  * One Touch Record Feature.
118  * <Record On> Attempt to record the specified source.
119  * Param: [Record Source], 1~8 bytes.
120  */
121 #define HDMI_CEC_OPCODE_RECORD_ON 0x09
122 
123 /* Record Source Type, 1 byte. */
124 #define HDMI_CEC_RECORD_SOURCE_TYPE_LEN 1
125 enum HdmiCecRecordSourceType {
126     HDMI_CEC_RECORD_SRC_OWN = 1,
127     HDMI_CEC_RECORD_SRC_DIGITAL = 2,
128     HDMI_CEC_RECORD_SRC_ANALOG = 3,
129     HDMI_CEC_RECORD_SRC_EXT_PLUG = 4,
130     HDMI_CEC_RECORD_SRC_EXT_PHY_ADDR = 5,
131 };
132 
133 /*
134  * Digital Service Identification. 7 bytes.
135  * [Service Identification Method] 1 bit
136  * [Digital Broadcast System] 7 bits
137  * [Service Identification] 6 bytes
138  */
139 #define HDMI_CEC_DIGITAL_SERVICE_ID_LEN 7
140 #define HDMI_CEC_SERVICE_ID_METHOD_BY_DIGITAL_IDS 0
141 #define HDMI_CEC_SERVICE_ID_METHOD_BY_CHANNEL 1
142 
143 enum HdmiCecDigitalBroadcastSystem {
144     HDMI_CEC_DIG_SERVICE_BCAST_SYSTEM_ARIB_GEN = 0x00,
145     HDMI_CEC_DIG_SERVICE_BCAST_SYSTEM_ATSC_GEN = 0x01,
146     HDMI_CEC_DIG_SERVICE_BCAST_SYSTEM_DVB_GEN = 0x02,
147     HDMI_CEC_DIG_SERVICE_BCAST_SYSTEM_ARIB_BS = 0x08,
148     HDMI_CEC_DIG_SERVICE_BCAST_SYSTEM_ARIB_CS = 0x09,
149     HDMI_CEC_DIG_SERVICE_BCAST_SYSTEM_ARIB_T = 0x0A,
150     HDMI_CEC_DIG_SERVICE_BCAST_SYSTEM_ATSC_CABLE = 0x10,
151     HDMI_CEC_DIG_SERVICE_BCAST_SYSTEM_ATSC_SATELLITE = 0x11,
152     HDMI_CEC_DIG_SERVICE_BCAST_SYSTEM_ATSC_TERRESTRIAL = 0x12,
153     HDMI_CEC_DIG_SERVICE_BCAST_SYSTEM_DVB_C = 0x18,
154     HDMI_CEC_DIG_SERVICE_BCAST_SYSTEM_DVB_S = 0x19,
155     HDMI_CEC_DIG_SERVICE_BCAST_SYSTEM_DVB_S2 = 0x1A,
156     HDMI_CEC_DIG_SERVICE_BCAST_SYSTEM_DVB_T = 0x1B,
157 };
158 
159 /*
160  * Service Identification, 6 bytes.
161  * [ARIB Data] | [ATSC Data] | [DVB Data] | [Channel Data]
162  * Channel Data, 6 bytes.
163  * [Channel Identifier] 4 bytes, [Reserved] 2 bytes.
164  * Channel Identifier, 4 bytes.
165  * [Channel Number Format] 6 bits.
166  * [Major Channel Number] 10 bits.
167  * [Minor Channel Number] 16 bits
168  */
169 #define HDMI_CEC_CHANNEL_NUMBER_FORMAT_1_PART 0x01
170 #define HDMI_CEC_CHANNEL_NUMBER_FORMAT_2_PART 0x02
171 #define HDMI_CEC_CHANNEL_NUMBER_FORMAT_SHIFT 2
172 
173 struct HdmiCecDigitalServiceAribData {
174     uint16_t transportId;
175     uint16_t serviceId;
176     uint16_t orgNetworkId;
177 };
178 
179 struct HdmiCecDigitalServiceAtscData {
180     uint16_t transportId;
181     uint16_t programNumber;
182 };
183 
184 struct HdmiCecDigitalServiceDvbData {
185     uint16_t transportId;
186     uint16_t serviceId;
187     uint16_t orgNetworkId;
188 };
189 
190 #define HDMI_CEC_CHANNEL_IDENTIFIER_LEN 4
191 struct HdmiCecChannelIdentifier {
192     uint8_t format;
193     uint16_t major;
194     uint16_t minor;
195 };
196 
197 #define HDMI_CEC_DIGITAL_SERVICE_ID_METHOD_SHIFT 7
198 
199 struct HdmiCecDigitalServiceId {
200     uint8_t method;
201     uint8_t system;
202     union {
203         struct HdmiCecDigitalServiceAribData arib;
204         struct HdmiCecDigitalServiceAtscData atsc;
205         struct HdmiCecDigitalServiceDvbData dvb;
206         struct HdmiCecChannelIdentifier channel;
207     } systemData;
208 };
209 
210 /*
211  * Record Source.
212  * {[Record Source Type]} | {[Record Source Type] [Digital Service Identification]} |
213  * {[Record Source Type] [Analogue Broadcast Type] [Analogue Frequency] [Broadcast System]} |
214  * {[Record Source Type] [External Plug]} | {[Record Source Type] [External Physical Address]}
215  */
216 #define HDMI_CEC_ANALOGUE_BROADCAST_TYPE_LEN 1
217 #define HDMI_CEC_ANALOGUE_FREQ_LEN 2
218 #define HDMI_CEC_BROADCAST_SYSTEM_LEN 1
219 #define HDMI_CEC_EXT_PLUG_LEN 1
220 #define HDMI_CEC_EXT_PHY_ADDRESS_LEN 2
221 #define HDMI_CEC_RECORD_ON_OWN_MSG_PARAM_LEN HDMI_CEC_RECORD_SOURCE_TYPE_LEN
222 #define HDMI_CEC_RECORD_ON_DIGITAL_MSG_PARAM_LEN (HDMI_CEC_RECORD_SOURCE_TYPE_LEN + HDMI_CEC_DIGITAL_SERVICE_ID_LEN)
223 #define HDMI_CEC_RECORD_ON_ANALOG_MSG_PARAM_LEN (HDMI_CEC_RECORD_SOURCE_TYPE_LEN + \
224     HDMI_CEC_ANALOGUE_BROADCAST_TYPE_LEN + HDMI_CEC_ANALOGUE_FREQ_LEN + HDMI_CEC_BROADCAST_SYSTEM_LEN)
225 #define HDMI_CEC_RECORD_ON_EXT_PLUG_MSG_PARAM_LEN (HDMI_CEC_RECORD_SOURCE_TYPE_LEN + HDMI_CEC_EXT_PLUG_LEN)
226 #define HDMI_CEC_RECORD_ON_EXT_PHY_ADDR_MSG_PARAM_LEN (HDMI_CEC_RECORD_SOURCE_TYPE_LEN + HDMI_CEC_EXT_PHY_ADDRESS_LEN)
227 
228 struct HdmiCecRecordSource {
229     uint8_t type;
230     union {
231         struct HdmiCecDigitalServiceId id;
232         struct {
233             uint8_t anaBcastType;
234             uint16_t anaFreq;
235             uint8_t bcstSystem;
236         } analog;
237         uint8_t extPlug;
238         uint16_t extPhyAddr;
239     } data;
240 };
241 
242 /*
243  * One Touch Record Feature.
244  * <Record Status> Used by a Recording Device to inform the Initiator of the message <Record On> about its status.
245  * Param: [Record Status Info], 1 byte.
246  */
247 #define HDMI_CEC_OPCODE_RECORD_STATUS 0x0A
248 
249 #define HDMI_CEC_RECORD_STATUS_MSG_PARAM_LEN 1
250 
251 /* Record Status Info */
252 enum HdmiCecRecordStatusInfo {
253     HDMI_CEC_RECORD_STATUS_CUR_SRC = 0x01,
254     HDMI_CEC_RECORD_STATUS_DIG_SERVICE = 0x02,
255     HDMI_CEC_RECORD_STATUS_ANA_SERVICE = 0x03,
256     HDMI_CEC_RECORD_STATUS_EXT_INPUT = 0x04,
257     HDMI_CEC_RECORD_STATUS_NO_DIG_SERVICE = 0x05,
258     HDMI_CEC_RECORD_STATUS_NO_ANA_SERVICE = 0x06,
259     HDMI_CEC_RECORD_STATUS_NO_SERVICE = 0x07,
260     HDMI_CEC_RECORD_STATUS_INVALID_EXT_PLUG = 0x09,
261     HDMI_CEC_RECORD_STATUS_INVALID_EXT_PHYS_ADDR = 0x0A,
262     HDMI_CEC_RECORD_STATUS_UNSUP_CA = 0x0B,
263     HDMI_CEC_RECORD_STATUS_NO_CA_ENTITLEMENTS = 0x0C,
264     HDMI_CEC_RECORD_STATUS_NO_COPY_SRC = 0x0D,
265     HDMI_CEC_RECORD_STATUS_NO_MORE_COPIES = 0x0E,
266     HDMI_CEC_RECORD_STATUS_NO_MEDIA = 0x10,
267     HDMI_CEC_RECORD_STATUS_PLAYING = 0x11,
268     HDMI_CEC_RECORD_STATUS_ALREADY_RECORDING = 0x12,
269     HDMI_CEC_RECORD_STATUS_MEDIA_PROTECTED = 0x13,
270     HDMI_CEC_RECORD_STATUS_NO_SRC_SIGNAL = 0x14,
271     HDMI_CEC_RECORD_STATUS_MEDIA_PROBLEM = 0x15,
272     HDMI_CEC_RECORD_STATUS_NO_SPACE = 0x16,
273     HDMI_CEC_RECORD_STATUS_PARENTAL_LOCK = 0x17,
274     HDMI_CEC_RECORD_STATUS_TERMINATED_OK = 0x1A,
275     HDMI_CEC_RECORD_STATUS_ALREADY_TERMINATED = 0x1B,
276     HDMI_CEC_RECORD_STATUS_OTHER = 0x1F,
277 };
278 
279 /*
280  * One Touch Record Feature.
281  * <Record TV Screen> Request by The Recording Device to record the presently displayed source.
282  */
283 #define HDMI_CEC_OPCODE_RECORD_TV_SCREEN 0x0F
284 
285 /*
286  * Timer Programming Feature.
287  * <Clear Analogue Timer> Used to clear an Analogue timer block of a device.
288  * Param: see <Set Analogue Timer> param.
289  */
290 #define HDMI_CEC_OPCODE_CLEAR_ANALOGUE_TIMER 0x33
291 
292 /*
293  * Timer Programming Feature.
294  * <Clear Digital Timer> Used to clear a Digital timer block of a device.
295  * Param: see <Set Digital Timer> param.
296  */
297 #define HDMI_CEC_OPCODE_CLEAR_DIGITAL_TIMER 0x99
298 
299 /*
300  * Timer Programming Feature.
301  * <Clear External Timer> Used to clear a External timer block of a device.
302  * Param: see <Set External Timer> param.
303  */
304 #define HDMI_CEC_OPCODE_CLEAR_EXTERNAL_TIMER 0xA1
305 
306 /*
307  * Timer Programming Feature.
308  * <Set Analogue Timer> Used to set a single timer block on an Analogue Recording device.
309  * Param: [Day of Month], 1 byte; [Month of Year], 1 byte; [Start Time], 2 byte; [Duration], 2 byte;
310  * [Recording Sequence], 1 byte; [Analogue Broadcast Type], 1 byte; [Analogue Frequency], 2 byte;
311  * [Broadcast System], 1 byte.
312  */
313 #define HDMI_CEC_OPCODE_SET_ANALOGUE_TIMER 0x34
314 
315 /* Analogue Broadcast Type, 1 byte. */
316 enum HdmiCecAnalogueBroadcastType {
317     HDMI_CEC_ANALOGUE_BROADCAST_CABLE = 0,
318     HDMI_CEC_ANALOGUE_BROADCAST_SATELITE = 1,
319     HDMI_CEC_ANALOGUE_BROADCAST_TERRESTRIAL = 2,
320 };
321 
322 /* Recording Sequence, 8 bits. */
323 enum HdmiCecRecordingSequence {
324     HDMI_CEC_RECORDING_SEQ_ONCE_ONLY = 0x00,
325     HDMI_CEC_RECORDING_SEQ_SUNDAY = 0x01,
326     HDMI_CEC_RECORDING_SEQ_MONDAY = 0x02,
327     HDMI_CEC_RECORDING_SEQ_TUESDAY = 0x04,
328     HDMI_CEC_RECORDING_SEQ_WEDNESDAY = 0x08,
329     HDMI_CEC_RECORDING_SEQ_THURSDAY = 0x10,
330     HDMI_CEC_RECORDING_SEQ_FRIDAY = 0x20,
331     HDMI_CEC_RECORDING_SEQ_SATERDAY = 0x40,
332 };
333 
334 #define HDMI_CEC_ANALOGUE_TIMER_INFO_LEN 11
335 /* Hour and Minute are in BCD format. */
336 #define HDMI_CEC_BCD_FORMAT_TIME(time) ((((time) / 10) << 4) | ((time) % 10))
337 
338 #define HDMI_CEC_COMM_TIMER_INFO_LEN 7
339 struct HdmiCecCommTimerInfo {
340     uint8_t data;
341     uint8_t month;
342     uint8_t startHour;
343     uint8_t startMinute;
344     uint8_t durationHour;
345     uint8_t durationMinute;
346     uint8_t recordingSeq;
347 };
348 
349 struct HdmiCecAnalogueTimerInfo {
350     struct HdmiCecCommTimerInfo commInfo;
351     uint8_t anaBcastType;
352     uint16_t anaFreq;
353     uint8_t bcstSystem;
354 };
355 
356 /*
357  * Timer Programming Feature.
358  * <Set Digital Timer> Used to set a single timer block on a Digital Recording device.
359  * Param: [Day of Month], 1 byte; [Month of Year], 1 byte; [Start Time], 2 byte; [Duration], 2 byte;
360  * [Recording Sequence], 1 byte; [Digtial Service Identification], 7 byte.
361  */
362 #define HDMI_CEC_OPCODE_SET_DIGITAL_TIMER 0x97
363 
364 #define HDMI_CEC_DIGITAL_TIMER_INFO_LEN 14
365 struct HdmiCecDigitalTimerInfo {
366     struct HdmiCecCommTimerInfo commInfo;
367     struct HdmiCecDigitalServiceId id;
368 };
369 
370 /*
371  * Timer Programming Feature.
372  * <Set External Timer> Used to set a single timer block to record from an External device.
373  * Param: [Day of Month], 1 byte; [Month of Year], 1 byte; [Start Time], 2 byte; [Duration], 2 byte;
374  * [Recording Sequence], 1 byte; [External Source Specifier], 1 byte; [External Plug], 1 byte;
375  * [External Physical address], 2 byte.
376  */
377 #define HDMI_CEC_OPCODE_SET_EXTERNAL_TIMER 0xA2
378 
379 #define HDMI_CEC_EXTERNAL_TIMER_INFO_LEN 11
380 
381 /* External Source Specifier */
382 #define HDMI_CEC_EXT_PLUG 4
383 #define HDMI_CEC_EXT_PHYS_ADDR 5
384 
385 struct HdmiCecExternalTimerInfo {
386     struct HdmiCecCommTimerInfo commInfo;
387     uint8_t extSrcSpec;
388     uint8_t extPlug;
389     uint16_t extPhyAddr;
390 };
391 
392 /*
393  * Timer Programming Feature.
394  * <Set Timer Program Title> Used to set the name of a program associate with a timer block.
395  * Sent directly after sending a <Set Analogue Timer> or <Set Digital Timer> message.
396  * The name is then associated with that timer block.
397  * Param: [Program Title String], 1~14 bytes.
398  */
399 #define HDMI_CEC_OPCODE_SET_TIMER_PROGRAM_TITLE 0x67
400 
401 #define HDMI_CEC_PROGRAM_TITLE_STR_MIN_LEN 1
402 #define HDMI_CEC_PROGRAM_TITLE_STR_MAX_LEN 14
403 
404 /*
405  * Timer Programming Feature.
406  * <Timer Clear Status> Used to give the status of a <Clear Analogue Timer>,
407  * <Clear Digital Timer> or <Clear External Timer> message.
408  * Param: [Timer Cleared Status Data], 1 byte.
409  */
410 #define HDMI_CEC_OPCODE_TIMER_CLEARED_STATUS 0x43
411 
412 #define HDMI_CEC_TIMER_CLEARED_STATUS_MSG_PARAM_LEN 1
413 
414 /* Timer Cleared Status Data */
415 enum HdmiCecTimerClearedStatus {
416     HDMI_CEC_TIMER_CLR_STAT_NO_CLEARED_RECORDING = 0x00,
417     HDMI_CEC_TIMER_CLR_STAT_NO_CLEARED_NO_MATCHING = 0x01,
418     HDMI_CEC_TIMER_CLR_STAT_NO_CLEARED_NO_INFO = 0x02,
419     HDMI_CEC_TIMER_CLR_STAT_CLEARED = 0x80,
420 };
421 
422 /*
423  * Timer Programming Feature.
424  * <Timer Status> Used to send timer status to the Initiator of a <Set Timer> message.
425  * Param: [Timer Status Data], 1 byte or 3 bytes.
426  */
427 #define HDMI_CEC_OPCODE_TIMER_STATUS 0x35
428 
429 #define HDMI_CEC_TIMER_STATUS_DATA_MIN_LEN 1
430 #define HDMI_CEC_TIMER_STATUS_DATA_MAX_LEN 3
431 
432 /*
433  * Timer Status Data. 1 byte or 3 bytes.
434  * [Timer overlap warning] 1bit.
435  * [Media Info] 2 bits.
436  * [Timer Progremmed Info] 5 bits or 21 bits.
437  */
438 #define HDMI_CEC_TIMER_OVERLAP_WARNING_NO_OVERLAP 0
439 #define HDMI_CEC_TIMER_OVERLAP_WARNING_TIMER_BLOCK_OVERLAP 1
440 #define HDMI_CEC_TIMER_OVERLAP_WARNING_SHIFT 7
441 
442 #define HDMI_CEC_MEDIA_INFO_SHIFT 5
443 enum HdmiCecMediaInfo {
444     HDMI_CEC_MEDIA_PRESENT_NOT_POTECTED = 0,
445     HDMI_CEC_MEDIA_PRESENT_POTECTED = 1,
446     HDMI_CEC_MEDIA_NOT_PRESENT = 2,
447     HDMI_CEC_MEDIA_BUTT,
448 };
449 
450 /*
451  * Timer Progremmed Info, 5 bits or 21 bits.
452  * [Progremmed Indicator], 1 bit.
453  * {[Progremmed Info], 4 bits. [Duration Available], 2bytes.} |
454  * {[Not Progremmed Error Info], 4 bits. [Duration Available], 2bytes.}
455  */
456 /* Progremmed Indicator, 1 bit */
457 #define HDMI_CEC_PROG_IND_NOT_PROGRAMMED 0
458 #define HDMI_CEC_PROG_IND_PROGRAMMED 1
459 #define HDMI_CEC_PROG_IND_SHIFT 4
460 
461 /* Progremmed Info, 4 bits */
462 enum HdmiCecProgremmedInfo {
463     HDMI_CEC_PROGRAMMED_INFO_ENOUGH_SPAC = 0x08,
464     HDMI_CEC_PROGRAMMED_INFO_NOT_ENOUGH_SPAC = 0x09,
465     HDMI_CEC_PROGRAMMED_INFO_NO_MEDIA_INFO = 0x0A,
466     HDMI_CEC_PROGRAMMED_INFO_MIGHT_NOT_BE_ENOUGH_SPACE = 0x0B,
467 };
468 
469 /* Not Progremmed Error Info */
470 enum HdmiCecNotProgremmedErrorInfo {
471     HDMI_CEC_NOT_PROG_ERR_NO_FREE_TIMER = 0x01,
472     HDMI_CEC_NOT_PROG_ERR_DATE_OUT_OF_RANGE = 0x02,
473     HDMI_CEC_NOT_PROG_ERR_RECORDING_SEQ_ERROR = 0x03,
474     HDMI_CEC_NOT_PROG_ERR_INVALID_EXT_PLUG = 0x04,
475     HDMI_CEC_NOT_PROG_ERR_INVALID_EXT_PHYS_ADDR = 0x05,
476     HDMI_CEC_NOT_PROG_ERR_CA_UNSUPP = 0x06,
477     HDMI_CEC_NOT_PROG_ERR_INSUF_CA_ENTITLEMENTS = 0x07,
478     HDMI_CEC_NOT_PROG_ERR_RESOLUTION_UNSUPP = 0x08,
479     HDMI_CEC_NOT_PROG_ERR_PARENTAL_LOCK = 0x09,
480     HDMI_CEC_NOT_PROG_ERR_CLOCK_FAILURE = 0x0A,
481     HDMI_CEC_NOT_PROG_ERR_DUPLICATE = 0x0E,
482 };
483 
484 struct HdmiCecTimerProgremmedInfo {
485     uint8_t indicator;
486     uint8_t info;       /* Progremmed Info/Not Progremmed Error Info */
487     uint8_t durationHour;
488     uint8_t durationMinute;
489 };
490 
491 struct HdmiCecTimerStatusData {
492     uint8_t timerOverlap;
493     uint8_t mediaInfo;
494     struct HdmiCecTimerProgremmedInfo progInfo;
495 };
496 
497 /*
498  * System Information Feature/Vendor Specific Commands Feature.
499  * <CEC Version> Used to indicate the version number of the CEC Specification which was used to design the device,
500  * in response to a <Get CEC Version>.
501  * Param: [CEC Version], 1 byte.
502  */
503 #define HDMI_CEC_OPCODE_CEC_VERSION 0x9E
504 
505 #define HDMI_CEC_CEC_VERSION_MSG_PARAM_LEN 1
506 
507 /* CEC Version */
508 #define HDMI_CEC_VERSION_1_3A 4
509 #define HDMI_CEC_VERSION_1_4 5
510 #define HDMI_CEC_VERSION_2_0 6
511 
512 /*
513  * System Information Feature/Vendor Specific Commands Feature.
514  * <Get CEC Version> Used by a device to enquire which version number of the CEC Specification
515  * was used to design the Follwer device.
516  * Param: None.
517  */
518 #define HDMI_CEC_OPCODE_GET_CEC_VERSION 0x9F
519 
520 /*
521  * System Information Feature.
522  * <Give Physical Address> A request to a device return its Physical Address.
523  * Param: None.
524  */
525 #define HDMI_CEC_OPCODE_GIVE_PHYSICAL_ADDRESS 0x83
526 
527 /*
528  * System Information Feature.
529  * <Get Menu Language> Sent by a device capable of character generation(for OSD and Menus) to a TV in order to
530  * discover the currently selected Menu language on the TV.
531  * Param: None.
532  */
533 #define HDMI_CEC_OPCODE_GET_MENU_LANGUAGE 0x91
534 
535 /*
536  * System Information Feature.
537  * <Report Physical Address> Used to inform all other devices of the mapping between
538  * physical and Logical address of the Initiator.
539  * Param: [Physical Address], 2 bytes. [Device Type], 1 byte.
540  * Broadcast message.
541  */
542 #define HDMI_CEC_OPCODE_REPORT_PHYSICAL_ADDRESS 0x84
543 
544 #define HDMI_CEC_REPORT_PHYSICAL_ADDRESS_MSG_PARAM_LEN 3
545 
546 /*
547  * Device Type/Primary Device Type.
548  * The HDMI 1.4b operand [Device Type] has been extended as [Primary Device Type].
549  */
550 enum HdmiCecDeviceType {
551     HDMI_CEC_DEVICE_TYPE_TV = 0,
552     HDMI_CEC_DEVICE_TYPE_RECORDING_DEVICE = 1,
553     HDMI_CEC_DEVICE_TYPE_RESERVED = 2,
554     HDMI_CEC_DEVICE_TYPE_TUNER = 3,
555     HDMI_CEC_DEVICE_TYPE_PLAYBACK_DEVICE = 4,
556     HDMI_CEC_DEVICE_TYPE_AUDIO_SYSTEM = 5,
557     HDMI_CEC_DEVICE_TYPE_PURE_CEC_SWITCH = 6,
558     HDMI_CEC_DEVICE_TYPE_PROCESSOR = 7,
559 };
560 
561 /*
562  * System Information Feature.
563  * <Set Menu Language> Used by a TV to indicate its currently selected menu language.
564  * Param: [Language], 3 bytes.
565  * Broadcast message.
566  */
567 #define HDMI_CEC_OPCODE_SET_MENU_LANGUAGE 0x32
568 
569 #define HDMI_CEC_SET_MENU_LANGUAGE_MSG_PARAM_LEN 3
570 
571 /*
572  * System Information Feature.
573  * <Report Features> Used by a device to announce its version, features and device type.
574  * Param: [CEC Version], 1 byte. [All Device Types], 1 byte. [RC Profile], 1..N bytes. [Device Features], 1..N bytes.
575  */
576 #define HDMI_CEC_OPCODE_REPORT_FEATURES 0xA6
577 
578 #define HDMI_CEC_REPORT_FEATURES_MSG_PARAM_MIN_LEN 4
579 
580 /* All Device Types */
581 enum HdmiCecAllDevType {
582     HDMI_CEC_ALL_DEV_TYPE_CEC_SWITCH = 0x04,
583     HDMI_CEC_ALL_DEV_TYPE_AUDIO_SYSTEM = 0x08,
584     HDMI_CEC_ALL_DEV_TYPE_PLAYBACK = 0x10,
585     HDMI_CEC_ALL_DEV_TYPE_TUNER = 0x20,
586     HDMI_CEC_ALL_DEV_TYPE_RECORD = 0x40,
587     HDMI_CEC_ALL_DEV_TYPE_TV = 0x80,
588 };
589 
590 /*
591  * RC Profile, 1..N bytes.
592  * [RC Profile 1]; or [RC Profile 1]..[RC Profile N](where N >= 2)
593  * RC Profile 1, 1 byte.
594  * [RC Profile Externsion], bit 7
595  * if bit6 is 0, [RC Profile TV] in bit5-0; if bit6 is 1, [RC Profile Source] in bit5-0.
596  */
597 #define HDMI_CEC_RC_PROFILE_MAX_NUM 6
598 #define HDMI_CEC_RC_PROFILE_EXTERNSION_MARK (1 << 7)
599 #define HDMI_CEC_RC_PROFILE_TV_OR_SOURCE_MARK (1 << 6)
600 
601 /* RC Profile Source, 6 bits. */
602 #define HDMI_CEC_RC_PROFILE_SOURCE_ROOT_MENU (1 << 4)
603 #define HDMI_CEC_RC_PROFILE_SOURCE_SETUP_MENU (1 << 3)
604 #define HDMI_CEC_RC_PROFILE_SOURCE_CONTENTS_MENU (1 << 2)
605 #define HDMI_CEC_RC_PROFILE_SOURCE_MEDIA_TOP_MENU (1 << 1)
606 #define HDMI_CEC_RC_PROFILE_SOURCE_MEDIA_CONTEXT_SENSITIVE_MENU (1 << 0)
607 
608 /*
609  * RC Profile TV, 6 bits.
610  * [RC Profile ID], Bit3-0.
611  */
612 enum HdmiCecRcProfileId {
613     HDMI_CEC_RC_PROFILE_NONE = 0x00,
614     HDMI_CEC_RC_PROFILE_1 = 0x02,
615     HDMI_CEC_RC_PROFILE_2 = 0x06,
616     HDMI_CEC_RC_PROFILE_3 = 0x0A,
617     HDMI_CEC_RC_PROFILE_4 = 0x0E,
618     HDMI_CEC_RC_PROFILE_BUTT,
619 };
620 
621 /*
622  * Device Features, 1..N bytes.
623  * [Device Features 1], 1 byte.
624  */
625 #define HDMI_CEC_DEVICE_FEATURES_MAX_NUM 6
626 #define HDMI_CEC_DEVICE_FEATURES_EXTERNSION_MARK (1 << 7)  /* 0 the last; 1 continues. */
627 #define HDMI_CEC_DEVICE_FEATURES_TV_SUPP_RECORD_TV_SCREEN (1 << 6)
628 #define HDMI_CEC_DEVICE_FEATURES_TV_SUPP_SET_OSD_STRING (1 << 5)
629 #define HDMI_CEC_DEVICE_FEATURES_DECK_SUPP_CONTROL (1 << 4)
630 #define HDMI_CEC_DEVICE_FEATURES_SRC_SUPP_SET_AUDIO_RATE (1 << 3)
631 #define HDMI_CEC_DEVICE_FEATURES_SINK_SUPP_ARC_TX (1 << 2)
632 #define HDMI_CEC_DEVICE_FEATURES_SRC_SUPP_ARC_RX (1 << 1)
633 
634 /*
635  * System Information Feature.
636  * <Give Features> Used by a device to request another device's features.
637  * Param: None.
638  */
639 #define HDMI_CEC_OPCODE_GIVE_FEATURES 0xA5
640 
641 /*
642  * Deck Control Feature.
643  * <Deck Control> Used to control a device's media functions.
644  * Param: [Deck Control Mode], 1 byte.
645  */
646 #define HDMI_CEC_OPCODE_DECK_CONTROL 0x42
647 
648 #define HDMI_CEC_DECK_CONTROL_MSG_PARAM_LEN 1
649 
650 /* Deck Control Mode */
651 enum HdmiCecDeckControlMode {
652     HDMI_CEC_DECK_CONTROL_MODE_SKIP_FWD = 1,
653     HDMI_CEC_DECK_CONTROL_MODE_SKIP_REV = 2,
654     HDMI_CEC_DECK_CONTROL_MODE_STOP = 3,
655     HDMI_CEC_DECK_CONTROL_MODE_EJECT = 4,
656 };
657 
658 /*
659  * Deck Control Feature.
660  * <Deck Status> Used to provide a deck's status to the indicate of the <Give Deck Status> message.
661  * Param: [Deck Info], 1 byte.
662  */
663 #define HDMI_CEC_OPCODE_DECK_STATUS 0x1B
664 
665 #define HDMI_CEC_DECK_STATUS_MSG_PARAM_LEN 1
666 
667 /* Deck Info. Indicate the current status of a tape or disk deck. */
668 enum HdmiCecDeckInfo {
669     HDMI_CEC_DECK_PLAY = 0x11,
670     HDMI_CEC_DECK_RECORD = 0x12,
671     HDMI_CEC_DECK_PLAY_REVERSE = 0x13,
672     HDMI_CEC_DECK_STILL = 0x14,
673     HDMI_CEC_DECK_SLOW = 0x15,
674     HDMI_CEC_DECK_SLOW_REVERSE = 0x16,
675     HDMI_CEC_DECK_FAST_FORWARD = 0x17,
676     HDMI_CEC_DECK_FAST_REVERSE = 0x18,
677     HDMI_CEC_DECK_NO_MEDIA = 0x19,
678     HDMI_CEC_DECK_STOP = 0x1A,
679     HDMI_CEC_DECK_SKIP_FORWARD = 0x1B,
680     HDMI_CEC_DECK_SKIP_REVERSE = 0x1C,
681     HDMI_CEC_DECK_INDEX_SEARCH_FORWARD = 0x1D,
682     HDMI_CEC_DECK_INDEX_SEARCH_REVERSE = 0x1E,
683     HDMI_CEC_DECK_OTHER_STATUS = 0x1F,
684 };
685 
686 /*
687  * Deck Control Feature.
688  * <Give Deck Status> Used to request the status of a device,
689  * regardless of whether or not it is the current active source.
690  * Param: [Status Request], 1 byte.
691  */
692 #define HDMI_CEC_OPCODE_GIVE_DECK_STATUS 0x1A
693 
694 #define HDMI_CEC_GIVE_DECK_STATUS_MSG_PARAM_LEN 1
695 
696 /* Status Request */
697 enum HdmiCecStatusRequest {
698     HDMI_CEC_STATUS_REQUEST_ON = 1,
699     HDMI_CEC_STATUS_REQUEST_OFF = 2,
700     HDMI_CEC_STATUS_REQUEST_ONCE = 3,
701 };
702 
703 /*
704  * Deck Control Feature.
705  * <Play> Used to control the playback behavior of a source device.
706  * Param: [Play Mode], 1 byte.
707  */
708 #define HDMI_CEC_OPCODE_PLAY 0x41
709 
710 #define HDMI_CEC_PLAY_MSG_PARAM_LEN 1
711 
712 /* Play Mode */
713 enum HdmiCecPlayMode {
714     HDMI_CEC_PLAY_MODE_PLAY_FAST_FWD_MIN = 0x05,
715     HDMI_CEC_PLAY_MODE_PLAY_FAST_FWD_MED = 0x06,
716     HDMI_CEC_PLAY_MODE_PLAY_FAST_FWD_MAX = 0x07,
717     HDMI_CEC_PLAY_MODE_PLAY_FAST_REV_MIN = 0x09,
718     HDMI_CEC_PLAY_MODE_PLAY_FAST_REV_MED = 0x0A,
719     HDMI_CEC_PLAY_MODE_PLAY_FAST_REV_MAX = 0x0B,
720     HDMI_CEC_PLAY_MODE_PLAY_SLOW_FWD_MIN = 0x15,
721     HDMI_CEC_PLAY_MODE_PLAY_SLOW_FWD_MED = 0x16,
722     HDMI_CEC_PLAY_MODE_PLAY_SLOW_FWD_MAX = 0x17,
723     HDMI_CEC_PLAY_MODE_PLAY_SLOW_REV_MIN = 0x19,
724     HDMI_CEC_PLAY_MODE_PLAY_SLOW_REV_MED = 0x1A,
725     HDMI_CEC_PLAY_MODE_PLAY_SLOW_REV_MAX = 0x1B,
726     HDMI_CEC_PLAY_MODE_PLAY_REV = 0x20,
727     HDMI_CEC_PLAY_MODE_PLAY_FWD = 0x24,
728     HDMI_CEC_PLAY_MODE_PLAY_STILL = 0x25,
729 };
730 
731 /*
732  * Tuner Control Feature.
733  * <Give Tuner Device Status> Used to request the status of a tuner device.
734  * Param: [Status Request], 1 byte.
735  */
736 #define HDMI_CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS 0x08
737 
738 #define HDMI_CEC_GIVE_TUNER_DEVICE_STATU_MSG_PARAM_LEN 1
739 
740 /*
741  * Tuner Control Feature.
742  * <Select Analogue Service> Directly selects an Analogue TV service.
743  * Param: [Analogue Broadcast Type], 1 byte. [Analogue Frequency], 2 bytes. [Broadcast System], 1 byte.
744  */
745 #define HDMI_CEC_OPCODE_SELECT_ANALOGUE_SERVICE 0x92
746 
747 #define HDMI_CEC_SELECT_ANALOGUE_SERVICE_MSG_PARAM_LEN 4
748 
749 /*
750  * Tuner Control Feature.
751  * <Select Digital Service> Directly selects a Digital TV, Radio or Data Briadcast service.
752  * Param: [Digital Service Identification], 7 bytes.
753  */
754 #define HDMI_CEC_OPCODE_SELECT_DIGITAL_SERVICE 0x93
755 
756 #define HDMI_CEC_SELECT_DIGITAL_SERVICE_MSG_PARAM_LEN HDMI_CEC_DIGITAL_SERVICE_ID_LEN
757 
758 /*
759  * Tuner Control Feature.
760  * <Tuner Device Status> Used by a tuner device to provide its status to the initiator of
761  * the <Give Tuner Device Status> message.
762  * Param: [Tuner Device Info], 5 bytes(analogue service), 8 bytes(digital service).
763  */
764 #define HDMI_CEC_OPCODE_TUNER_DEVICE_STATUS 0x07
765 
766 #define HDMI_CEC_TUNER_DEVICE_STATUS_MSG_ANA_PARAM_LEN 5
767 #define HDMI_CEC_TUNER_DEVICE_STATUS_MSG_DIG_PARAM_LEN 8
768 
769 /*
770  * Tuner Device Info, 5 bytes(analogue service), 8 bytes(digital service).
771  * [Recording Flag], 1 bit. [Tuner Display Info], 7 bits.
772  * {[Analogue Broadcast Type], 1 byte. [Analogue Frequency], 2 bytes. [Broadcast System], 1 byte.} |
773  * {[Digital Service Identification], 7 bytes}.
774  */
775 #define HDMI_CEC_RECORDING_FALG_NOT_USED 0
776 #define HDMI_CEC_RECORDING_FALG_USED 1
777 #define HDMI_CEC_RECORDING_FALG_SHIFT 7
778 
779 enum HdmiCecTunerDisplayInfo {
780     HDMI_CEC_TUNER_DISP_DIGITAL = 0,
781     HDMI_CEC_TUNER_DISP_NOT_DISP = 1,
782     HDMI_CEC_TUNER_DISP_ANALOGUE = 2,
783 };
784 
785 struct HdmiCecTunerDeviceInfo {
786     uint8_t recordingFlag;
787     uint8_t dispInfo;
788     bool isAnalogService;
789     union {
790         struct HdmiCecDigitalServiceId digital;
791         struct {
792             uint8_t anaBcastType;
793             uint16_t anaFreq;
794             uint8_t bcstSystem;
795         } analog;
796     } data;
797 };
798 
799 /*
800  * Tuner Control Feature.
801  * <Tuner Step Decrement> Used to tune to next lowest service in a tuner's service list. Can used for PIP.
802  * Param: None.
803  */
804 #define HDMI_CEC_OPCODE_TUNER_STEP_DECREMENT 0x06
805 
806 /*
807  * Tuner Control Feature.
808  * <Tuner Step Increment> Used to tune to next highest service in a tuner's service list. Can used for PIP.
809  * Param: None.
810  */
811 #define HDMI_CEC_OPCODE_TUNER_STEP_INCREMENT 0x05
812 
813 /*
814  * Vendor Specific Commands Feature.
815  * <Device Vendor ID> Reports the vendor ID of this device.
816  * Param: [Vendor ID], 3 bytes.
817  * Broadcast message.
818  */
819 #define HDMI_CEC_OPCODE_DEVICE_VENDOR_ID 0x87
820 
821 #define HDMI_CEC_DEVICE_VENDOR_ID_MSG_PARAM_LEN 3
822 
823 /*
824  * Indicates the vendor ID should be disabled.
825  */
826 #define HDMI_CEC_VENDOR_ID_UNKNOWN 0xFFFFFFFF
827 
828 /*
829  * Vendor Specific Commands Feature.
830  * <Give Device Vendor ID> Requests the Vendor ID from a device.
831  * Param: None.
832  */
833 #define HDMI_CEC_OPCODE_GIVE_DEVICE_VENDOR_ID 0x8C
834 
835 /*
836  * Vendor Specific Commands Feature.
837  * <Vendor Command> Allows vendor specific commands to be sent between two devices.
838  * Param: [Vendor Specific Data], <= 14 bytes.
839  */
840 #define HDMI_CEC_OPCODE_VENDOR_COMMAND 0x89
841 
842 #define HDMI_CEC_VENDOR_SPECIFIC_DATA_MAX_LEN 14
843 
844 /*
845  * Vendor Specific Commands Feature.
846  * <Vendor Command With ID> Allows vendor specific commands to be sent between two devices or broadcast.
847  * Param: [Vendor ID], 3 bytes. [Vendor Specific Data], <= 11 bytes.
848  * Broadcast/Directly addressed message.
849  */
850 #define HDMI_CEC_OPCODE_VENDOR_COMMAND_WITH_ID 0xA0
851 
852 #define HDMI_CEC_VENDOR_ID_LEN 3
853 #define HDMI_CEC_VENDOR_SPECIFIC_DATA_WITH_ID_MAX_LEN 11
854 
855 /*
856  * Vendor Specific Commands Feature.
857  * <Vendor Remote Button Down> Indicates that a remote control button has been depressed.
858  * Param: [Vendor Specific RC Code], <= 14 bytes.
859  * Broadcast/Directly addressed message.
860  */
861 #define HDMI_CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN 0x8A
862 
863 #define HDMI_CEC_VENDOR_SPECIFIC_RC_CODE_MAX_LEN 14
864 
865 /*
866  * Vendor Specific Commands Feature.
867  * <Vendor Remote Button Up> Indicates that a remote control button(the last button pressed indicated
868  * by the Vendor Remote Button Down message) has been released.
869  * Param: None.
870  * Broadcast/Directly addressed message.
871  */
872 #define HDMI_CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP 0x8B
873 
874 /*
875  * OSD Display Feature.
876  * <Set OSD String> Used to send a text massage to output on a TV.
877  * OSD(on-screen display).
878  * Param: [Display Control], 1 byte. [OSD String], 1-13 bits.
879  */
880 #define HDMI_CEC_OPCODE_SET_OSD_STRING 0x64
881 
882 #define HDMI_CEC_DISPLAY_CONTROL_LEN 1
883 #define HDMI_CEC_OSD_STRING_MAX_LEN 13
884 
885 /* Display Control */
886 enum HdmiCecDisplayControl {
887     HDMI_CEC_DISPLAY_FOR_DEFAULT_TIME = 0x00,
888     HDMI_CEC_DISPLAY_UNTIL_CLEARED = 0x40,
889     HDMI_CEC_DISPLAY_CLEAR_PREVIOUS_MESSAGE = 0x80,
890     HDMI_CEC_DISPLAY_BUTT,
891 };
892 
893 /*
894  * OSD Display Feature.
895  * <Give OSD Name> Used to request the preferred OSD name of a device for use in menus associated with that device.
896  * Param: None.
897  */
898 #define HDMI_CEC_OPCODE_GIVE_OSD_NAME 0x46
899 
900 /*
901  * OSD Display Feature.
902  * <Set OSD Name> Used to set the preferred OSD name of a device for use in menus associated with that device.
903  * Param: [OSD Name], 1-14 bytes.
904  */
905 #define HDMI_CEC_OPCODE_SET_OSD_NAME 0x47
906 
907 #define HDMI_CEC_OSD_NAME_MAX_LEN 14
908 
909 /*
910  * Device Menu Control Feature.
911  * <Menu Request> A request from the TV for a device to show/remove a menu or to
912  * query if a device is currently showing a menu.
913  * Param: [Menu Request Type], 1 byte.
914  */
915 #define HDMI_CEC_OPCODE_MENU_REQUEST 0x8D
916 
917 #define HDMI_CEC_MENU_REQUEST_MSG_PARAM_LEN 1
918 
919 /* Menu Request Type */
920 enum HdmiCecMenuRequestType {
921     HDMI_CEC_MENU_REQUEST_ACTIVE = 0,
922     HDMI_CEC_MENU_REQUEST_DEACTIVE = 1,
923     HDMI_CEC_MENU_REQUEST_QUERY = 2,
924 };
925 
926 /*
927  * Device Menu Control Feature.
928  * <Menu Status> Used to indicate to the TV that the device is showing/has removed a menu and
929  * requests the remote control keys to be passed throuh.
930  * Param: [Menu State], 1 byte.
931  */
932 #define HDMI_CEC_OPCODE_MENU_STATUS 0x8E
933 
934 #define HDMI_CEC_MENU_STATUS_MSG_PARAM_LEN 1
935 
936 /* Menu State */
937 #define HDMI_CEC_MENU_STATE_ACTIVE 0
938 #define HDMI_CEC_MENU_STATE_DEACTIVE 1
939 
940 /*
941  * Device Menu Control Feature/Remote Contro Passthrough Feature/System Audio Control Feature.
942  * <User Control Pressed> Used to indicate that the user pressed a remote control button or switched from
943  * one remote control button to another. Can also be used as a command that is not directly initiated by the user.
944  * Param: [UI Command], 1 byte.
945  * Note that some [UI Command] messages also have further operands. See CEC Table 6 and CEC Table 7.
946  */
947 #define HDMI_CEC_OPCODE_USER_CONTROL_PRESSED 0x44
948 
949 #define HDMI_CEC_UI_COMMAND_LEN 1
950 
951 /* UI Command */
952 enum HdmiCecUiCmdType {
953     HDMI_CEC_UI_CMD_SELECT = 0x00,
954     HDMI_CEC_UI_CMD_UP = 0x01,
955     HDMI_CEC_UI_CMD_DOWN = 0x02,
956     HDMI_CEC_UI_CMD_LEFT = 0x03,
957     HDMI_CEC_UI_CMD_RIGHT = 0x04,
958     HDMI_CEC_UI_CMD_RIGHT_UP = 0x05,
959     HDMI_CEC_UI_CMD_RIGHT_DOWN = 0x06,
960     HDMI_CEC_UI_CMD_LEFT_UP = 0x07,
961     HDMI_CEC_UI_CMD_LEFT_DOWN = 0x08,
962     HDMI_CEC_UI_CMD_DEVICE_ROOT_MENU = 0x09,
963     HDMI_CEC_UI_CMD_DEVICE_SETUP_MENU = 0x0a,
964     HDMI_CEC_UI_CMD_CONTENTS_MENU = 0x0b,
965     HDMI_CEC_UI_CMD_FAVORITE_MENU = 0x0c,
966     HDMI_CEC_UI_CMD_EXIT = 0x0d,
967     HDMI_CEC_UI_CMD_MEDIA_TOP_MENU = 0x10,
968     HDMI_CEC_UI_CMD_MEDIA_CONTEXT_SENSITIVE_MENU = 0x11,
969     HDMI_CEC_UI_CMD_NUMBER_ENTRY_MODE = 0x1d,
970     HDMI_CEC_UI_CMD_NUMBER_11 = 0x1e,
971     HDMI_CEC_UI_CMD_NUMBER_12 = 0x1f,
972     HDMI_CEC_UI_CMD_NUMBER_0_OR_NUMBER_10 = 0x20,
973     HDMI_CEC_UI_CMD_NUMBER_1 = 0x21,
974     HDMI_CEC_UI_CMD_NUMBER_2 = 0x22,
975     HDMI_CEC_UI_CMD_NUMBER_3 = 0x23,
976     HDMI_CEC_UI_CMD_NUMBER_4 = 0x24,
977     HDMI_CEC_UI_CMD_NUMBER_5 = 0x25,
978     HDMI_CEC_UI_CMD_NUMBER_6 = 0x26,
979     HDMI_CEC_UI_CMD_NUMBER_7 = 0x27,
980     HDMI_CEC_UI_CMD_NUMBER_8 = 0x28,
981     HDMI_CEC_UI_CMD_NUMBER_9 = 0x29,
982     HDMI_CEC_UI_CMD_DOT = 0x2a,
983     HDMI_CEC_UI_CMD_ENTER = 0x2b,
984     HDMI_CEC_UI_CMD_CLEAR = 0x2c,
985     HDMI_CEC_UI_CMD_NEXT_FAVORITE = 0x2f,
986     HDMI_CEC_UI_CMD_CHANNEL_UP = 0x30,
987     HDMI_CEC_UI_CMD_CHANNEL_DOWN = 0x31,
988     HDMI_CEC_UI_CMD_PREVIOUS_CHANNEL = 0x32,
989     HDMI_CEC_UI_CMD_SOUND_SELECT = 0x33,
990     HDMI_CEC_UI_CMD_INPUT_SELECT = 0x34,
991     HDMI_CEC_UI_CMD_DISPLAY_INFORMATION = 0x35,
992     HDMI_CEC_UI_CMD_HELP = 0x36,
993     HDMI_CEC_UI_CMD_PAGE_UP = 0x37,
994     HDMI_CEC_UI_CMD_PAGE_DOWN = 0x38,
995     HDMI_CEC_UI_CMD_POWER = 0x40,
996     HDMI_CEC_UI_CMD_VOLUME_UP = 0x41,
997     HDMI_CEC_UI_CMD_VOLUME_DOWN = 0x42,
998     HDMI_CEC_UI_CMD_MUTE = 0x43,
999     HDMI_CEC_UI_CMD_PLAY = 0x44,
1000     HDMI_CEC_UI_CMD_STOP = 0x45,
1001     HDMI_CEC_UI_CMD_PAUSE = 0x46,
1002     HDMI_CEC_UI_CMD_RECORD = 0x47,
1003     HDMI_CEC_UI_CMD_REWIND = 0x48,
1004     HDMI_CEC_UI_CMD_FAST_FORWARD = 0x49,
1005     HDMI_CEC_UI_CMD_EJECT = 0x4a,
1006     HDMI_CEC_UI_CMD_SKIP_FORWARD = 0x4b,
1007     HDMI_CEC_UI_CMD_SKIP_BACKWARD = 0x4c,
1008     HDMI_CEC_UI_CMD_STOP_RECORD = 0x4d,
1009     HDMI_CEC_UI_CMD_PAUSE_RECORD = 0x4e,
1010     HDMI_CEC_UI_CMD_ANGLE = 0x50,
1011     HDMI_CEC_UI_CMD_SUB_PICTURE = 0x51,
1012     HDMI_CEC_UI_CMD_VIDEO_ON_DEMAND = 0x52,
1013     HDMI_CEC_UI_CMD_ELECTRONIC_PROGRAM_GUIDE = 0x53,
1014     HDMI_CEC_UI_CMD_TIMER_PROGRAMMING = 0x54,
1015     HDMI_CEC_UI_CMD_INITIAL_CONFIGURATION = 0x55,
1016     HDMI_CEC_UI_CMD_SELECT_BROADCAST_TYPE = 0x56,          /* Additional Operands: [UI Broadcast Type] */
1017     HDMI_CEC_UI_CMD_SELECT_SOUND_PRESENTATION = 0x57,      /* Additional Operands: [UI Sound Presentation Control] */
1018     HDMI_CEC_UI_CMD_AUDIO_DESCRIPTION = 0x58,
1019     HDMI_CEC_UI_CMD_INTERNET = 0x59,
1020     HDMI_CEC_UI_CMD_3D_MODE = 0x5a,
1021     HDMI_CEC_UI_CMD_PLAY_FUNCTION = 0x60,                  /* Additional Operands: [Play Mode] */
1022     HDMI_CEC_UI_CMD_PAUSE_PLAY_FUNCTION = 0x61,
1023     HDMI_CEC_UI_CMD_RECORD_FUNCTION = 0x62,
1024     HDMI_CEC_UI_CMD_PAUSE_RECORD_FUNCTION = 0x63,
1025     HDMI_CEC_UI_CMD_STOP_FUNCTION = 0x64,
1026     HDMI_CEC_UI_CMD_MUTE_FUNCTION = 0x65,
1027     HDMI_CEC_UI_CMD_RESTORE_VOLUME_FUNCTION = 0x66,
1028     HDMI_CEC_UI_CMD_TUNE_FUNCTION = 0x67,                  /* Additional Operands: [Channel Identifier] */
1029     HDMI_CEC_UI_CMD_SELECT_MEDIA_FUNCTION = 0x68,          /* Additional Operands: [UI Function Media] */
1030     HDMI_CEC_UI_CMD_SELECT_AV_INPUT_FUNCTION = 0x69,       /* Additional Operands: [UI Function Select A/V Input] */
1031     HDMI_CEC_UI_CMD_SELECT_AUDIO_INPUT_FUNCTION = 0x6a,    /* Additional Operands: [UI Function Select Audio Input] */
1032     HDMI_CEC_UI_CMD_POWER_TOGGLE_FUNCTION = 0x6b,
1033     HDMI_CEC_UI_CMD_POWER_OFF_FUNCTION = 0x6c,
1034     HDMI_CEC_UI_CMD_POWER_ON_FUNCTION = 0x6d,
1035     HDMI_CEC_UI_CMD_F1_BLUE = 0x71,
1036     HDMI_CEC_UI_CMD_F2_RED = 0x72,
1037     HDMI_CEC_UI_CMD_F3_GREEN = 0x73,
1038     HDMI_CEC_UI_CMD_F4_YELLOW = 0x74,
1039     HDMI_CEC_UI_CMD_F5 = 0x75,
1040     HDMI_CEC_UI_CMD_DATA = 0x76,
1041 };
1042 
1043 enum HdmiCecUiBroadcastType {
1044     HDMI_CEC_UI_BROADCAST_TYPE_TOGGLE_ALL = 0x00,
1045     HDMI_CEC_UI_BROADCAST_TYPE_TOGGLE_DIG_ANA = 0x01,
1046     HDMI_CEC_UI_BROADCAST_TYPE_ANA = 0x10,
1047     HDMI_CEC_UI_BROADCAST_TYPE_ANA_TERRESTRIAL = 0x20,
1048     HDMI_CEC_UI_BROADCAST_TYPE_ANA_CABLE = 0x30,
1049     HDMI_CEC_UI_BROADCAST_TYPE_ANA_SATELLITE = 0x40,
1050     HDMI_CEC_UI_BROADCAST_TYPE_DIG = 0x50,
1051     HDMI_CEC_UI_BROADCAST_TYPE_DIG_TERRESTRIAL = 0x60,
1052     HDMI_CEC_UI_BROADCAST_TYPE_DIG_CABLE = 0x70,
1053     HDMI_CEC_UI_BROADCAST_TYPE_DIG_SATELLITE = 0x80,
1054     HDMI_CEC_UI_BROADCAST_TYPE_DIG_COM_SATELLITE = 0x90,
1055     HDMI_CEC_UI_BROADCAST_TYPE_DIG_COM_SATELLITE2 = 0x91,
1056     HDMI_CEC_UI_BROADCAST_TYPE_IP = 0xA0,
1057 };
1058 
1059 /* UI Sound Presentation Control */
1060 enum HdmiCecUiSoundPresCtl {
1061     HDMI_CEC_UI_SOUND_PRES_CTL_DUAL_MONO = 0x20,
1062     HDMI_CEC_UI_SOUND_PRES_CTL_KARAOKE = 0x30,
1063     HDMI_CEC_UI_SOUND_PRES_CTL_DOWNMIX = 0x80,
1064     HDMI_CEC_UI_SOUND_PRES_CTL_REVERB_PROCESS = 0x90,
1065     HDMI_CEC_UI_SOUND_PRES_CTL_EQUALIZER = 0xA0,
1066     HDMI_CEC_UI_SOUND_PRES_CTL_BASS_STEP_UP = 0xB1,
1067     HDMI_CEC_UI_SOUND_PRES_CTL_BASS_NEUTRAL = 0xB2,
1068     HDMI_CEC_UI_SOUND_PRES_CTL_BASS_STEP_DOWN = 0xB3,
1069     HDMI_CEC_UI_SOUND_PRES_CTL_TREBLE_STEP_UP = 0xC1,
1070     HDMI_CEC_UI_SOUND_PRES_CTL_TREBLE_NEUTRAL = 0xC2,
1071     HDMI_CEC_UI_SOUND_PRES_CTL_TREBLE_STEP_DOWN = 0xC3,
1072 };
1073 
1074 struct HdmiCecUiCmd {
1075     uint8_t cmdType;
1076     bool hasAddOp;
1077     union {
1078         uint8_t uiBroadcastType;
1079         uint8_t uiSoundPresCtl;
1080         uint8_t playMode;
1081         uint8_t uiFunctionMedia;
1082         uint8_t uiFunctionSelectAvInput;
1083         uint8_t uiFunctionSelectAudioInput;
1084         struct HdmiCecChannelIdentifier channel;
1085     } addOperands;
1086 };
1087 
1088 /*
1089  * Device Menu Control Feature/Remote Contro Passthrough Feature/System Audio Control Feature.
1090  * <User Control Released> Indicates that user released a remote control button(the last one indicated by the
1091  * <User Control Pressed> message). Also used after a command that is not directly initiated by the user.
1092  * Param: None.
1093  */
1094 #define HDMI_CEC_OPCODE_USER_CONTROL_RELEASED 0x45
1095 
1096 /*
1097  * Remote Contro Passthrough Feature.
1098  * <Give Device Power Status> Used to determine the current power status of a target device.
1099  * Param: None.
1100  */
1101 #define HDMI_CEC_OPCODE_GIVE_DEVICE_POWER_STATUS 0x8F
1102 
1103 /*
1104  * Remote Contro Passthrough Feature.
1105  * <Report Power Status> Used to inform a requesting device of the current power status.
1106  * Param: [Power Status], 1 byte.
1107  * Broadcast(Hdmi Spec2.0)/Directly addressed message.
1108  */
1109 #define HDMI_CEC_OPCODE_REPORT_POWER_STATUS 0x90
1110 
1111 #define HDMI_CEC_REPORT_POWER_STATUS_MSG_PARA_LEN 1
1112 
1113 /* Power Status */
1114 enum HdmiCecPowerStatus {
1115     HDMI_CEC_POWER_STATUS_ON = 0x00,
1116     HDMI_CEC_POWER_STATUS_STANDBY = 0x01,
1117     HDMI_CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON = 0x02,
1118     HDMI_CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY = 0x03,
1119 };
1120 
1121 /*
1122  * General Protocol Messages.
1123  * <Feature Abort> Used as a response to indicate that the device does not support the requested message type,
1124  * or that is cannot execute it at the present time.
1125  * Param: [Feature Opcode], 1 byte. [Abort Reason], 1 byte.
1126  */
1127 #define HDMI_CEC_OPCODE_FEATURE_ABORT 0x00
1128 
1129 #define HDMI_CEC_FEATURE_ABORT_MSG_PARA_LEN 2
1130 
1131 /* Abort Reason */
1132 enum HdmiCecAbortReason {
1133     HDMI_CEC_ABORT_UNRECOGNIZED_OPCODE = 0,
1134     HDMI_CEC_ABORT_NOT_IN_CORRECT_MODE_TO_RESPOND = 1,
1135     HDMI_CEC_ABORT_CANNOT_PROVIDE_SOURCE = 2,
1136     HDMI_CEC_ABORT_INVALID_OPERAND = 3,
1137     HDMI_CEC_ABORT_REFUSED = 4,
1138     HDMI_CEC_ABORT_UNABLE_TO_DETERMINE = 5,
1139 };
1140 
1141 /*
1142  * General Protocol Messages.
1143  * <Abort> This message is reversed for testing purposes.
1144  * Param: None.
1145  */
1146 #define HDMI_CEC_OPCODE_ABORT 0xFF
1147 
1148 /*
1149  * System Audio Control Feature.
1150  * <Give Audio Status> Requests an Amplifier to send its volume and mute status.
1151  * Param: None.
1152  */
1153 #define HDMI_CEC_OPCODE_GIVE_AUDIO_STATUS 0x71
1154 
1155 /*
1156  * System Audio Control Feature.
1157  * <Give System Audio Mode Status> Requests the status of the System Audio Mode.
1158  * Param: None.
1159  */
1160 #define HDMI_CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS 0x7D
1161 
1162 /*
1163  * System Audio Control Feature.
1164  * <Report Audio Status> Reports an Amplifier's volume and mute status.
1165  * Param: [Audio Status], 1 byte.
1166  */
1167 #define HDMI_CEC_OPCODE_REPORT_AUDIO_STATUS 0x7A
1168 
1169 #define HDMI_CEC_REPORT_AUDIO_STATUSMSG_PARAM_LEN 1
1170 
1171 /*
1172  * Audio Status, 1 byte.
1173  * [Audio Mute Status], Bit 7; [Audio Volume Status], Bits 6-0.
1174  */
1175 #define HDMI_CEC_AUDIO_MUTE_STATUS_MARK 0x80
1176 #define HDMI_CEC_AUDIO_MUTE_STATUS_SHIFT 7
1177 #define HDMI_CEC_AUDIO_VOLUME_STATUS_MARK 0x7F
1178 /* Audio Mute Status */
1179 #define HDMI_CEC_AUDIO_MUTE_STATUS_OFF 0
1180 #define HDMI_CEC_AUDIO_MUTE_STATUS_ON 1
1181 /* Audio Volume Status, 0%~100% */
1182 #define HDMI_CEC_AUDIO_VOLUME_STATUS_MIN_VAL 0x00
1183 #define HDMI_CEC_AUDIO_VOLUME_STATUS_MAX_VAL 0x64
1184 #define HDMI_CEC_AUDIO_VOLUME_STATUS_UNKNOWN 0x7F
1185 
1186 /*
1187  * System Audio Control Feature.
1188  * <Report Short Audio Descriptor> Report Audio Capability.
1189  * Param: [Short Audio Descriptor], 3 bytes. Up to 4 Short Audio Descriptor identifying supported audio formats.
1190  */
1191 #define HDMI_CEC_OPCODE_REPORT_SHORT_AUDIO_DESCRIPTOR 0xA3
1192 
1193 #define HDMI_CEC_SHORT_AUDIO_DESCRIPTOR_LEN 3
1194 #define HDMI_CEC_MAX_SHORT_AUDIO_DESCRIPTOR_NUM 4
1195 
1196 /*
1197  * System Audio Control Feature.
1198  * <Request Short Audio Descriptor> Report Audio Capability.
1199  * Param: [Audio Format ID], 2 bits. [Audio Format Code], 6 bits. Up to 4 Audio Format ID and Audio Format Code.
1200  */
1201 #define HDMI_CEC_OPCODE_REQUEST_SHORT_AUDIO_DESCRIPTOR 0xA4
1202 
1203 #define HDMI_CEC_AUDIO_FORMAT_LEN 1
1204 #define HDMI_CEC_MAX_AUDIO_FORMAT_NUM 4
1205 #define HDMI_CEC_AUDIO_FORMAT_ID_SHIFT 6
1206 #define HDMI_CEC_AUDIO_FORMAT_CODE_MARK 0x3F
1207 
1208 /*
1209  * System Audio Control Feature.
1210  * <Set System Audio Mode> Turns the System Audio Mode On or Off.
1211  * Param: [System Audio Status], 1 byte.
1212  * Broadcast/Directly addressed message.
1213  */
1214 #define HDMI_CEC_OPCODE_SET_SYSTEM_AUDIO_MODE 0x72
1215 
1216 #define HDMI_CEC_SYSTEM_AUDIO_STATUS_LEN 1
1217 
1218 /* System Audio Status */
1219 #define HDMI_CEC_SYSTEM_AUDIO_STATUS_OFF 0
1220 #define HDMI_CEC_SYSTEM_AUDIO_STATUS_ON 1
1221 
1222 /*
1223  * System Audio Control Feature.
1224  * <System Audio Mode Request> A device implementing System Audio Control and which has volume control
1225  * RC buttons(e.g. TV or STB) requests to use System Audio Mode to the Amplifier.
1226  # Param: [Physical Address], 2 bytes.
1227  */
1228 #define HDMI_CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST 0x70
1229 
1230 #define HDMI_CEC_SYSTEM_AUDIO_MODE_REQUEST_PARAM_LEN 2
1231 
1232 /*
1233  * System Audio Control Feature.
1234  * <System Audio Mode Status> Reports the current status of the System Audio Mode.
1235  * Param: [System Audio Status], 1 byte.
1236  */
1237 #define HDMI_CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS 0x7E
1238 
1239 /*
1240  * Audio Rate Control Feature.
1241  * <Set Audio Rate> Used to control audio rate from Source Device.
1242  * Param: [Audio Rate], 1 byte.
1243  */
1244 #define HDMI_CEC_OPCODE_SET_AUDIO_RATE 0x9A
1245 
1246 #define HDMI_CEC_SET_AUDIO_RATE_PARAM_LEN 1
1247 
1248 /* Audio Rate */
1249 enum HdmiCecAudioRate {
1250     HDMI_CEC_AUDIO_RATE_OFF = 0,         /* Rate Control Off */
1251     HDMI_CEC_AUDIO_RATE_WIDE_STD = 1,    /* Standard Rate: 100% rate */
1252     HDMI_CEC_AUDIO_RATE_WIDE_FAST = 2,   /* Fast Rate: Max 101% rate */
1253     HDMI_CEC_AUDIO_RATE_WIDE_SLOW = 3,   /* Slow Rate: Min 99% rate */
1254     HDMI_CEC_AUDIO_RATE_NARROW_STD = 4,  /* Standard Rate: 100.0% rate */
1255     HDMI_CEC_AUDIO_RATE_NARROW_FAST = 5, /* Fast Rate: Max 100.1% rate */
1256     HDMI_CEC_AUDIO_RATE_NARROW_SLOW = 6, /* Slow Rate: Min 99.9% rate */
1257 };
1258 
1259 /*
1260  * Audio Return Channel Control Feature.
1261  * <Initiate ARC> Used by an ARC RX device to active the ARC functionality in an ARC TX device.
1262  * Param: None.
1263  */
1264 #define HDMI_CEC_OPCODE_INITIATE_ARC 0xC0
1265 
1266 /*
1267  * Audio Return Channel Control Feature.
1268  * <Report ARC Initiated> Used by an ARC RX device to indicate that its ARC functionality has been activated.
1269  * Param: None.
1270  */
1271 #define HDMI_CEC_OPCODE_REPORT_ARC_INITIATED 0xC1
1272 
1273 /*
1274  * Audio Return Channel Control Feature.
1275  * <Report ARC Termination> Used by an ARC RX device to indicate that its ARC functionality has been deactivated.
1276  * Param: None.
1277  */
1278 #define HDMI_CEC_OPCODE_REPORT_ARC_TERMINATION 0xC2
1279 
1280 /*
1281  * Audio Return Channel Control Feature.
1282  * <Request ARC Initiation> Used by an ARC TX device to request an ARC RX device to
1283  * active the ARC functionality in the ARC TX device.
1284  * Param: None.
1285  */
1286 #define HDMI_CEC_OPCODE_REQUEST_ARC_INITIATION 0xC3
1287 
1288 /*
1289  * Audio Return Channel Control Feature.
1290  * <Request ARC Termination> Used by an ARC TX device to request an ARC RX device to
1291  * deactive the ARC functionality in the ARC TX device.
1292  * Param: None.
1293  */
1294 #define HDMI_CEC_OPCODE_REQUEST_ARC_TERMINATION 0xC4
1295 
1296 /*
1297  * Audio Return Channel Control Feature.
1298  * <Terminate ARC> Used by an ARC TX device to deactive the ARC functionality in the ARC TX device.
1299  * Param: None.
1300  */
1301 #define HDMI_CEC_OPCODE_TERMINATE_ARC 0xC5
1302 
1303 /*
1304  * Capability Discovery and Control Feature.
1305  * <CDC Message> Used for Capability Discovery and Control.
1306  * Broadcast message.
1307  */
1308 #define HDMI_CEC_OPCODE_CDC_MESSAGE 0xF8
1309 
1310 /*
1311  * Dynamic Auto Lispync Feature.
1312  * <Request Current Latency> Used by Amplifier(or other device) to request current latency values.
1313  * Param: [Physical Address], 2 byte.
1314  */
1315 #define HDMI_CEC_OPCODE_REQUEST_CURRENT_LATENCY 0xA7
1316 
1317 #define HDMI_CEC_REQUEST_CURRENT_LATENCY_MSG_LEN 2
1318 
1319 /*
1320  * Dynamic Auto Lispync Feature.
1321  * <Report Current Latency> Used by TV(or other Initiator) to report updates of latency.
1322  * Param: [Physical Address], 2 byte. [Video Latency], 1 byte. [Latency Flags], 1 byte.
1323  * [Audio Output Delay], 1 byte, optional.
1324  */
1325 #define HDMI_CEC_OPCODE_REPORT_CURRENT_LATENCY 0xA8
1326 
1327 #define HDMI_CEC_REPORT_CURRENT_LATENCY_MSG_PARAM_MAX_LEN 5
1328 #define HDMI_CEC_REPORT_CURRENT_LATENCY_MSG_PARAM_MIN_LEN 4
1329 
1330 /*
1331  * Latency Flags, 1 byte.
1332  * Bit 7..3 reversed; Bit 2 [Low Latency Mode]; Bit 1-0 [Audio Output Compensated].
1333  */
1334 #define HDMI_CEC_LOW_LATENCY_MODE_SHIFT 2
1335 #define HDMI_CEC_NORMAL_LATENCY_MODE 0
1336 #define HDMI_CEC_LOW_LATENCY_MODE 1
1337 
1338 #define HDMI_CEC_AUDIO_OUTPUT_COMPENSATED_NA 0
1339 #define HDMI_CEC_AUDIO_OUTPUT_COMPENSATED_DELAY 1
1340 #define HDMI_CEC_AUDIO_OUTPUT_COMPENSATED_NO_DELAY 2
1341 #define HDMI_CEC_AUDIO_OUTPUT_COMPENSATED_PARTIAL_DELAY 3
1342 
1343 struct HdmiCecLatencyInfo {
1344     uint8_t videoLatency;
1345     uint8_t lowLatencyMode;
1346     uint8_t audioOutputCompensated;
1347     uint8_t audioOutputDelay;
1348 };
1349 
1350 
1351 /* Broadcast System, 0~31. See hdmi spec1.4, CEC Table 31. */
1352 enum HdmiCecBroadcastSystem {
1353     HDMI_CEC_BROADCAST_SYSTEM_PAL_BG = 0,
1354     HDMI_CEC_BROADCAST_SYSTEM_SECAM_LQ = 1,
1355     HDMI_CEC_BROADCAST_SYSTEM_PAL_M = 2,
1356     HDMI_CEC_BROADCAST_SYSTEM_NTSC_M = 3,
1357     HDMI_CEC_BROADCAST_SYSTEM_PAL_I = 4,
1358     HDMI_CEC_BROADCAST_SYSTEM_SECAM_DK = 5,
1359     HDMI_CEC_BROADCAST_SYSTEM_SECAM_BG = 6,
1360     HDMI_CEC_BROADCAST_SYSTEM_SECAM_L = 7,
1361     HDMI_CEC_BROADCAST_SYSTEM_PAL_DK = 8,
1362     HDMI_CEC_BROADCAST_SYSTEM_OTHER = 31,
1363 };
1364 
1365 /* CDC(Capability Discovery and Control) Message */
1366 
1367 /*
1368  * HDMI Ethernet Channel Feature.
1369  * <CDC_HEC_InquireState> Used to inquire the state of an HDMI Ethernet Channel.
1370  * Param: [Physical Address], 2 byte. [Physical Address], 2 byte.
1371  */
1372 #define HDMI_CDC_HEC_INQUIRE_STATE 0x00
1373 
1374 #define HDMI_CDC_HEC_INQUIRE_STATE_MSG_PARAM_LEN 4
1375 
1376 /*
1377  * HDMI Ethernet Channel Feature.
1378  * <CDC_HEC_ReportState> Used to report capabilities and states of a device that supports functionality.
1379  * Param: [Physical Address], 2 bytes. [HEC State], 1 byte. [HEC Support Field], 2 bytes.
1380  * [HEC Activation Field], 2 bytes.
1381  */
1382 #define HDMI_CDC_HEC_REPORT_STATE 0x01
1383 
1384 #define HDMI_CDC_HEC_REPORT_STATE_MSG_PARAM_MAX_LEN 5
1385 #define HDMI_CDC_HEC_REPORT_STATE_MSG_PARAM_MIN_LEN 3
1386 
1387 /*
1388  * HEC State, 1 byte
1389  * [HEC Functionality State], 2 bits.
1390  * [Host Functionality State], 2 bits.
1391  * [ENC Functionality State], 2 bits.
1392  * [CDC Error Code], 2 bits.
1393  */
1394 #define HDMI_CDC_HEC_FUNC_STATE_SHIFT 6
1395 #define HDMI_CDC_HOST_FUNC_STATE_SHIFT 4
1396 #define HDMI_CDC_ENC_FUNC_STATE_SHIFT 2
1397 
1398 enum HdmiCdcHecFuncState {
1399     HDMI_CDC_HEC_FUNC_STATE_NOT_SUPPORTED = 0,
1400     HDMI_CDC_HEC_FUNC_STATE_INACTIVE = 1,
1401     HDMI_CDC_HEC_FUNC_STATE_ACTIVE = 2,
1402     HDMI_CDC_HEC_FUNC_STATE_ACTIVATION_FIELD = 3,
1403 };
1404 
1405 enum HdmiCdcHostFuncState {
1406     HDMI_CDC_HOST_HEC_STATE_NOT_SUPPORTED = 0,
1407     HDMI_CDC_HOST_HEC_STATE_NOT_INACTIVE = 1,
1408     HDMI_CDC_HOST_HEC_STATE_NOT_ACTIVE = 2,
1409 };
1410 
1411 enum HdmiCdcEncFuncState {
1412     HDMI_CDC_ENC_FUNC_STATE_EXT_CON_NOT_SUPPORTED = 0,
1413     HDMI_CDC_ENC_FUNC_STATE_EXT_CON_INACTIVE = 1,
1414     HDMI_CDC_ENC_FUNC_STATE_EXT_CON_ACTIVE = 2,
1415 };
1416 
1417 enum HdmiCdcErrCode {
1418     HDMI_CDC_ERR_CODE_NO_ERROR = 0,
1419     HDMI_CDC_ERR_CODE_CAP_UNSUPPORTED = 1,
1420     HDMI_CDC_ERR_CODE_WRONG_STATE = 2,
1421     HDMI_CDC_ERR_CODE_OTHER = 3,
1422 };
1423 
1424 /*
1425  * HEC Support Field, 2 bytes.
1426  * [HEC Support], Bit 14. {14[HEC Support]}, Bit 13-0.
1427  */
1428 #define HDMI_CDC_HEC_SUPPORT_MAKR (1 << 14)
1429 #define HDMI_CDC_HEC_NOT_SUPPORT 0
1430 #define HDMI_CDC_HEC_SUPPORT 1
1431 
1432 /*
1433  * HEC Activation Field, 2 bytes.
1434  * [HEC Activation], Bit 14. {14[HEC Activation]}, Bit 13-0.
1435  */
1436 #define HDMI_CDC_HEC_ACTIVATION_MAKR (1 << 14)
1437 #define HDMI_CDC_HEC_INACTIVE 0
1438 #define HDMI_CDC_HEC_ACTIVE 1
1439 
1440 struct HdmiCdcHecState {
1441     uint8_t hecFuncState;
1442     uint8_t hostFuncState;
1443     uint8_t encFuncState;
1444     uint8_t cdcErrCode;
1445     bool haveHecField;
1446     uint16_t hecField;
1447 };
1448 
1449 /*
1450  * HDMI Ethernet Channel Feature.
1451  * <CDC_HEC_SetStateAdjacent> Used to active or de-active an HDMI Ethernet Channel to an adjacent device.
1452  * Param: [Physical Address], 2 bytes. [HEC Set State], 1 byte.
1453  */
1454 #define HDMI_CDC_HEC_SET_STATE_ADJACENT 0x02
1455 
1456 #define HDMI_CDC_HEC_SET_STATE_ADJACENT_MSG_PARAM_LEN 3
1457 
1458 /* HEC Set State, 1 byte. */
1459 #define HDMI_CDC_DEACTIVATE_HEC 0
1460 #define HDMI_CDC_ACTIVATE_HEC 1
1461 
1462 /*
1463  * HDMI Ethernet Channel Feature.
1464  * <CDC_HEC_SetState> Used to active or de-active an HDMI Ethernet Channel to an adjacent device.
1465  * Param: [Physical Address], 2 bytes. [Physical Address], 2 bytes. [HEC Set State], 1 byte.
1466  * [Physical Address], 2 bytes. [Physical Address], 2 bytes. [Physical Address], 2 bytes.
1467  * The last three [PA] parameters shall not be incorporated if only one HEC shall activated.
1468  */
1469 #define HDMI_CDC_HEC_SET_STATE 0x03
1470 
1471 #define HDMI_CDC_HEC_SET_STATE_MSG_MIN_LEN 5
1472 #define HDMI_CDC_HEC_SET_STATE_MSG_OPTIONAL_PA_MAX_NUM 3
1473 
1474 struct HemiCdcHecStateInfo {
1475     uint16_t phyAddr1;
1476     uint16_t phyAddr2;
1477     uint8_t hecSetState;
1478     uint16_t phyAddr[HDMI_CDC_HEC_SET_STATE_MSG_OPTIONAL_PA_MAX_NUM];
1479     uint32_t phyAddrLen;
1480 };
1481 
1482 /*
1483  * HDMI Ethernet Channel Feature.
1484  * <CDC_HEC_RequestDeactivation> Used to request the deactivation of an HDMI Ethernet Channel.
1485  * Param: [Physical Address], 2 bytes. [Physical Address], 2 bytes. [Physical Address], 2 bytes.
1486  */
1487 #define HDMI_CDC_HEC_REQUEST_DEACTIVATION 0x04
1488 
1489 #define HDMI_CDC_HEC_REQUEST_DEACTIVATION_MSG_PHY_ADDR_NUM 3
1490 #define HDMI_CDC_HEC_REQUEST_DEACTIVATION_MSG_PARAM_LEN 6
1491 
1492 /*
1493  * HDMI Ethernet Channel Feature.
1494  * <CDC_HEC_NotifyAlive> Used to keep alive HDMI Ethernet Channels active.
1495  */
1496 #define HDMI_CDC_HEC_NOTIFY_ALIVE 0x05
1497 
1498 /*
1499  * HDMI Ethernet Channel Feature.
1500  * <CDC_HEC_Discover> Used to discover all HEC capabilities of devices within the HDMI network.
1501  */
1502 #define HDMI_CDC_HEC_DISCOVER 0x06
1503 
1504 /*
1505  * CDC HPD Feature.
1506  * <CDC_HPD_SetState> Used to substitute physical HPD pin signaling.
1507  * Param: [Input port number], 4 bits. [HPD State], 4 bits.
1508  */
1509 #define HDMI_CDC_HPD_SET_STATE 0x10
1510 
1511 #define HDMI_CDC_HPD_SET_STATE_MSG_LEN 1
1512 #define HDMI_CDC_INPUT_PORT_NUMBER_SHIFT 4
1513 
1514 enum HdmiCdcHpdState {
1515     HDMI_CDC_HDP_STATE_CP_EDID_DISABLE = 0,
1516     HDMI_CDC_HDP_STATE_CP_EDID_ENABLE = 1,
1517     HDMI_CDC_HDP_STATE_CP_EDID_DISABLE_ENABLE = 2,
1518     HDMI_CDC_HDP_STATE_EDID_DISABLE = 3,
1519     HDMI_CDC_HDP_STATE_EDID_ENABLE = 4,
1520     HDMI_CDC_HDP_STATE_EDID_DISABLE_ENABLE = 5,
1521     HDMI_CDC_HDP_STATE_BUTT,
1522 };
1523 
1524 /*
1525  * CDC HPD Feature.
1526  * <CDC_HPD_ReportState> Used to report the state of a device using the CDC HPD signaling.
1527  * Param: [HPD State], 4 bits. [CDC_HPD_Error_Code], 4 bits.
1528  */
1529 #define CEC_MSG_CDC_HPD_REPORT_STATE 0x11
1530 
1531 #define HDMI_CDC_HPD_REPORT_STATE_MSG_LEN 1
1532 #define HDMI_CDC_HPD_STATE_SHIFT 4
1533 
1534 enum HdmiCdcHpdErrCode {
1535     HDMI_CDC_HPD_NO_ERR = 0,
1536     HDMI_CDC_HPD_ERR_INITIATOR_NOT_CAPABLE = 1,
1537     HDMI_CDC_HPD_ERR_INITIATOR_WRONG_STATE = 2,
1538     HDMI_CDC_HPD_ERR_OTHER = 3,
1539     HDMI_CDC_HPD_NO_ERR_NO_VIDEO_STREAM = 4,
1540     HDMI_CDC_HPD_ERR_BUTT,
1541 };
1542 
1543 /*
1544  * CEC message frame.
1545  *
1546  *                 1 block           1 block          0-14 blocks
1547  * Start_Bit  CEC_Header_Block  CEC_Opcode_Block   CEC_Operand_Blocks
1548  *
1549  * CDC message frame.
1550  *
1551  *                 1 block           1 block                 2 blocks           1 block     0~11 blocks
1552  * Start_Bit  CEC_Header_Block  CEC_Opcode_Block(0xF8)  Initiator_Phy_Address  CDC_Opcode  CDC_Parameters
1553  *
1554  * Header Block.
1555  *          high 4 bits                      low 4 bits
1556  * Initiator Logic Address field    Destination Logic Address field
1557  *
1558  */
1559 #define HDMI_CEC_MSG_MAX_LEN 20  /* Make sure it has enough space. */
1560 #define HDMI_CEC_HEADER_LEN 1
1561 #define HDMI_CEC_OPCODE_LEN 1
1562 #define HDMI_CEC_MSG_MIN_LEN (HDMI_CEC_HEADER_LEN + HDMI_CEC_OPCODE_LEN)
1563 #define HDMI_POLLING_MSG_LEN 1
1564 #define HDMI_CEC_INITIATOR_PHY_ADDRESS_LEN 2
1565 #define HDMI_CEC_GET_MSG_LEN(len) (HDMI_CEC_HEADER_LEN + HDMI_CEC_OPCODE_LEN + (len))
1566 #define HDMI_CDC_OPCODE_LEN 1
1567 #define HDMI_CDC_GET_MSG_LEN(len) \
1568     (HDMI_CEC_HEADER_LEN + HDMI_CEC_OPCODE_LEN + HDMI_CEC_INITIATOR_PHY_ADDRESS_LEN + HDMI_CDC_OPCODE_LEN + (len))
1569 
1570 #define HDMI_CEC_HEADER_BLOCK_INITIATOR_MARK 0xF0
1571 #define HDMI_CEC_HEADER_BLOCK_DESTINATION_MARK 0x0F
1572 #define HDMI_CEC_HEADER_BLOCK_INITIATOR_SHIFT 4
1573 
1574 #define HDMI_CEC_INVALID_PHY_ADDR 0xFFFF
1575 #define HDMI_CEC_INVALID_LOGICAL_ADDR 0xFF
1576 
1577 enum HdmiCecLogicalAddr {
1578     HDMI_CEC_LOG_ADDR_TV = 0,
1579     HDMI_CEC_LOG_ADDR_RECORDING_DEVICE_1 = 1,
1580     HDMI_CEC_LOG_ADDR_RECORDING_DEVICE_2 = 2,
1581     HDMI_CEC_LOG_ADDR_TUNER_1 = 3,
1582     HDMI_CEC_LOG_ADDR_PLAYBACK_DEVICE_1 = 4,
1583     HDMI_CEC_LOG_ADDR_AUDIO_SYSTEM = 5,
1584     HDMI_CEC_LOG_ADDR_TUNER_2 = 6,
1585     HDMI_CEC_LOG_ADDR_TUNER_3 = 7,
1586     HDMI_CEC_LOG_ADDR_PLAYBACK_DEVICE_2 = 8,
1587     HDMI_CEC_LOG_ADDR_RECORDING_DEVICE_3 = 9,
1588     HDMI_CEC_LOG_ADDR_TUNER_4 = 10,
1589     HDMI_CEC_LOG_ADDR_PLAYBACK_DEVICE_3 = 11,
1590     HDMI_CEC_LOG_ADDR_BACKUP_1 = 12,
1591     HDMI_CEC_LOG_ADDR_BACKUP_2 = 13,
1592     HDMI_CEC_LOG_ADDR_SPECIFIC_USE = 14,
1593     HDMI_CEC_LOG_ADDR_UNREGISTERED_OR_BROADCAST = 15, /*
1594                                                        * Unregistered(as initiator address);
1595                                                        * Broadcast(as destination address).
1596                                                        */
1597     HDMI_CEC_LOG_ADDR_BUTT,
1598 };
1599 
1600 enum HdmiCecLogicalAddrMark {
1601     HDMI_CEC_LOG_ADDR_MASK_TV = (1 << HDMI_CEC_LOG_ADDR_TV),
1602     HDMI_CEC_LOG_ADDR_MASK_RECORD = ((1 << HDMI_CEC_LOG_ADDR_RECORDING_DEVICE_1) |
1603         (1 << HDMI_CEC_LOG_ADDR_RECORDING_DEVICE_2) | (1 << HDMI_CEC_LOG_ADDR_RECORDING_DEVICE_3)),
1604     HDMI_CEC_LOG_ADDR_MASK_TUNER = ((1 << HDMI_CEC_LOG_ADDR_TUNER_1) | (1 << HDMI_CEC_LOG_ADDR_TUNER_2) |
1605         (1 << HDMI_CEC_LOG_ADDR_TUNER_3) | (1 << HDMI_CEC_LOG_ADDR_TUNER_4)),
1606     HDMI_CEC_LOG_ADDR_MASK_PLAYBACK = ((1 << HDMI_CEC_LOG_ADDR_PLAYBACK_DEVICE_1) |
1607         (1 << HDMI_CEC_LOG_ADDR_PLAYBACK_DEVICE_2) | (1 << HDMI_CEC_LOG_ADDR_PLAYBACK_DEVICE_3)),
1608     HDMI_CEC_LOG_ADDR_MASK_AUDIOSYSTEM = (1 << HDMI_CEC_LOG_ADDR_AUDIO_SYSTEM),
1609     HDMI_CEC_LOG_ADDR_MASK_BACKUP = ((1 << HDMI_CEC_LOG_ADDR_BACKUP_1) | (1 << HDMI_CEC_LOG_ADDR_BACKUP_2)),
1610     HDMI_CEC_LOG_ADDR_MASK_SPECIFIC = (1 << HDMI_CEC_LOG_ADDR_SPECIFIC_USE),
1611     HDMI_CEC_LOG_ADDR_MASK_UNREGISTERED = (1 << HDMI_CEC_LOG_ADDR_UNREGISTERED_OR_BROADCAST),
1612 };
1613 
1614 enum HdmiCecLogicalAddrType {
1615     HDMI_CEC_LOG_ADDR_TYPE_TV = 0,
1616     HDMI_CEC_LOG_ADDR_TYPE_RECORD = 1,
1617     HDMI_CEC_LOG_ADDR_TYPE_TUNER = 2,
1618     HDMI_CEC_LOG_ADDR_TYPE_PLAYBACK = 3,
1619     HDMI_CEC_LOG_ADDR_TYPE_AUDIOSYSTEM = 4,
1620     HDMI_CEC_LOG_ADDR_TYPE_SPECIFIC = 5,
1621     HDMI_CEC_LOG_ADDR_TYPE_UNREGISTERED = 6,
1622 };
1623 
1624 enum HdmiCecMsgType {
1625     HDMI_CEC_MSG_BROADCAST_1_4 = 0x01,
1626     HDMI_CEC_MSG_BROADCAST_2_0 = 0x02,
1627     HDMI_CEC_MSG_BROADCAST = 0x03,
1628     HDMI_CEC_MSG_DIRECTED = 0x04,
1629     HDMI_CEC_MSG_DIRECTED_OR_BROADCAST_1_4 = 0x05,
1630     HDMI_CEC_MSG_DIRECTED_OR_BROADCAST_2_0 = 0x06,
1631     HDMI_CEC_MSG_ALL = 0x07,
1632 };
1633 
1634 struct HdmiCecMsgLenInfo {
1635     uint8_t opcode;
1636     uint8_t minLen;
1637     uint8_t type;
1638 };
1639 
1640 #define HDMI_CEC_WAIT_RESPONSE_MSG_MAX_TIME 1000 /* 1s */
1641 struct HdmiCecMsg {
1642     uint32_t len;
1643     uint8_t data[HDMI_CEC_MSG_MAX_LEN];
1644     uint8_t rspMsg;
1645     bool response;
1646     uint32_t timeout; /* Indicates the maximum time(in ms) for the peer to reply to a message. */
1647 };
1648 
1649 #define HDMI_CEC_MSG_DATA_ZEROTH_ELEMENT 0
1650 #define HDMI_CEC_MSG_DATA_FIRST_ELEMENT 1
1651 #define HDMI_CEC_MSG_DATA_SECOND_ELEMENT 2
1652 #define HDMI_CEC_MSG_DATA_THIRD_ELEMENT 3
1653 #define HDMI_CEC_MSG_DATA_FORTH_ELEMENT 4
1654 #define HDMI_CEC_MSG_DATA_FIFTH_ELEMENT 5
1655 #define HDMI_CEC_MSG_DATA_SIXTH_ELEMENT 6
1656 #define HDMI_CEC_MSG_DATA_SEVENTH_ELEMENT 7
1657 #define HDMI_CEC_MSG_DATA_EIGHTH_ELEMENT 8
1658 #define HDMI_CEC_MSG_DATA_NINTH_ELEMENT 9
1659 
1660 #define DATA_ZEROTH_OFFSET_ELEMENT 0
1661 #define DATA_FIRST_OFFSET_ELEMENT 1
1662 #define DATA_SECOND_OFFSET_ELEMENT 2
1663 #define DATA_THIRD_OFFSET_ELEMENT 3
1664 #define DATA_FORTH_OFFSET_ELEMENT 4
1665 #define DATA_FIFTH_OFFSET_ELEMENT 5
1666 #define DATA_SIXTH_OFFSET_ELEMENT 6
1667 #define DATA_SEVENTH_OFFSET_ELEMENT 7
1668 #define DATA_EIGHTH_OFFSET_ELEMENT 8
1669 #define DATA_NINTH_OFFSET_ELEMENT 9
1670 #define DATA_TENTH_OFFSET_ELEMENT 10
1671 
1672 struct HdmiCecInfo {
1673     uint8_t logAddr;
1674     uint8_t logAddrType;
1675     uint16_t logAddrMask;
1676     uint8_t primaryDeviceType;
1677     uint8_t cecVersion;
1678     uint16_t phyAddr;
1679     uint32_t vendorId;
1680     uint32_t flags;
1681     uint8_t osdName[HDMI_CEC_OSD_NAME_MAX_LEN + 1];
1682     uint8_t osdNameLen;
1683     uint8_t allDeviceType;
1684     uint8_t rcProfile[HDMI_CEC_RC_PROFILE_MAX_NUM];
1685     uint8_t devFeatures[HDMI_CEC_DEVICE_FEATURES_MAX_NUM];
1686     bool isWaitingResponse;
1687     uint8_t response;
1688 };
1689 
1690 struct HdmiCec {
1691     struct HdmiCecInfo info;
1692     void *priv;
1693 };
1694 
HdmiCecIsBroadcastMsg(struct HdmiCecMsg * msg)1695 static inline bool HdmiCecIsBroadcastMsg(struct HdmiCecMsg *msg)
1696 {
1697     if ((msg->data[0] & HDMI_CEC_HEADER_BLOCK_DESTINATION_MARK) ==
1698         HDMI_CEC_LOG_ADDR_UNREGISTERED_OR_BROADCAST) {
1699         return true;
1700     }
1701     return false;
1702 }
1703 
HdmiCecGetMsgInitiator(const struct HdmiCecMsg * msg)1704 static inline uint8_t HdmiCecGetMsgInitiator(const struct HdmiCecMsg *msg)
1705 {
1706     return ((msg->data[0] & HDMI_CEC_HEADER_BLOCK_INITIATOR_MARK) >> HDMI_CEC_HEADER_BLOCK_INITIATOR_SHIFT);
1707 }
1708 
HdmiCecGetMsgDestination(const struct HdmiCecMsg * msg)1709 static inline uint8_t HdmiCecGetMsgDestination(const struct HdmiCecMsg *msg)
1710 {
1711     return (msg->data[0] & HDMI_CEC_HEADER_BLOCK_DESTINATION_MARK);
1712 }
1713 
HdmiCecLogAddrValid(struct HdmiCec * cec,uint8_t logAddr)1714 static inline bool HdmiCecLogAddrValid(struct HdmiCec *cec, uint8_t logAddr)
1715 {
1716     return (cec->info.logAddr & (1 << logAddr));
1717 }
1718 
HdmiCecIsCdcOnlyDevice(struct HdmiCec * cec)1719 static inline bool HdmiCecIsCdcOnlyDevice(struct HdmiCec *cec)
1720 {
1721     return ((cec->info.logAddr == HDMI_CEC_LOG_ADDR_UNREGISTERED_OR_BROADCAST) &&
1722         (cec->info.primaryDeviceType == HDMI_CEC_DEVICE_TYPE_PURE_CEC_SWITCH));
1723 }
1724 
HdmiCecFillMsgHeader(struct HdmiCecMsg * destMsg,const struct HdmiCecMsg * srcMsg)1725 static inline void HdmiCecFillMsgHeader(struct HdmiCecMsg *destMsg, const struct HdmiCecMsg *srcMsg)
1726 {
1727     destMsg->data[0] = (HdmiCecGetMsgDestination(srcMsg) << HDMI_CEC_HEADER_BLOCK_INITIATOR_SHIFT) |
1728         HdmiCecGetMsgInitiator(srcMsg);
1729 }
1730 
1731 int32_t HdmiCecReceivedMsg(struct HdmiCec *cec, struct HdmiCecMsg *msg);
1732 void HdmiCecEncodingTimerStatusMsg(struct HdmiCecMsg *msg, const struct HdmiCecTimerStatusData *status);
1733 void HdmiCecEncodingTunerDeviceStatusMsg(struct HdmiCecMsg *msg, const struct HdmiCecTunerDeviceInfo *info);
1734 void HdmiCecEncodingUserControlPrtessedMsg(struct HdmiCecMsg *msg, const struct HdmiCecUiCmd *cmd);
1735 
1736 void HdmiCdcEncodingHecDiscoverMsg(struct HdmiCecMsg *msg, uint16_t initiatorPhyAddr, bool response);
1737 void HdmiCdcEncodingHecInquireStateMsg(struct HdmiCecMsg *msg, uint16_t initiatorPhyAddr,
1738     uint16_t phyAddr1, uint16_t phyAddr2, bool response);
1739 void HdmiCdcEncodingHecNotifyAliveMsg(struct HdmiCecMsg *msg, uint16_t initiatorPhyAddr);
1740 void HdmiCdcEncodingHecReportStateMsg(struct HdmiCecMsg *msg, uint16_t initiatorPhyAddr,
1741     uint16_t phyAddr, const struct HdmiCdcHecState *state);
1742 void HdmiCdcEncodingHecSetStateMsg(struct HdmiCecMsg *msg, uint16_t initiatorPhyAddr,
1743     struct HemiCdcHecStateInfo *info, bool response);
1744 void HdmiCdcEncodingHpdReportStateMsg(struct HdmiCecMsg *msg, uint16_t initiatorPhyAddr,
1745     uint8_t hpdState, uint8_t errCode);
1746 void HdmiCdcEncodingHpdSetStateMsg(struct HdmiCecMsg *msg, uint16_t initiatorPhyAddr,
1747     uint8_t portNum, uint8_t hpdState, bool response);
1748 void HdmiCecEncodingAbortMsg(struct HdmiCecMsg *msg);
1749 void HdmiCecEncodingActiveSourceMsg(struct HdmiCecMsg *msg, uint16_t phyAddr);
1750 void HdmiCecEncodingClearAnalogueTimerMsg(struct HdmiCecMsg *msg, struct HdmiCecAnalogueTimerInfo *info,
1751     bool response);
1752 void HdmiCecEncodingClearDigitalTimerMsg(struct HdmiCecMsg *msg, struct HdmiCecDigitalTimerInfo *info, bool response);
1753 void HdmiCecEncodingClearExternalTimerMsg(struct HdmiCecMsg *msg, struct HdmiCecExternalTimerInfo *info,
1754     bool response);
1755 void HdmiCecEncodingDeckControlMsg(struct HdmiCecMsg *msg, uint8_t mode);
1756 void HdmiCecEncodingDeckStatusMsg(struct HdmiCecMsg *msg, uint8_t info);
1757 void HdmiCecEncodingGetCecVersionMsg(struct HdmiCecMsg *msg, bool response);
1758 void HdmiCecEncodingGetMenuLanguageMsg(struct HdmiCecMsg *msg, bool response);
1759 void HdmiCecEncodingGetPhyAddressMsg(struct HdmiCecMsg *msg, bool response);
1760 void HdmiCecEncodingGiveAudioStatusMsg(struct HdmiCecMsg *msg, bool response);
1761 void HdmiCecEncodingGiveDeckStatusMsg(struct HdmiCecMsg *msg, uint8_t statusReq, bool response);
1762 void HdmiCecEncodingGiveDevicePowerStatusMsg(struct HdmiCecMsg *msg, bool response);
1763 void HdmiCecEncodingGiveDeviceVendorIdMsg(struct HdmiCecMsg *msg, bool response);
1764 void HdmiCecEncodingGiveFeaturesMsg(struct HdmiCecMsg *msg, bool response);
1765 void HdmiCecEncodingGiveOsdNameMsg(struct HdmiCecMsg *msg, bool response);
1766 void HdmiCecEncodingGiveSystemAudioModeMsg(struct HdmiCecMsg *msg, bool response);
1767 void HdmiCecEncodingGiveTunerDeviceStatusMsg(struct HdmiCecMsg *msg, uint8_t statusReq, bool response);
1768 void HdmiCecEncodingImageViewOnMsg(struct HdmiCecMsg *msg);
1769 void HdmiCecEncodingInactiveSourceMsg(struct HdmiCecMsg *msg, uint16_t phyAddr);
1770 void HdmiCecEncodingInitiateArcMsg(struct HdmiCecMsg *msg, bool response);
1771 void HdmiCecEncodingMenuRequestMsg(struct HdmiCecMsg *msg, uint8_t menuReq, bool response);
1772 void HdmiCecEncodingMenuStatusMsg(struct HdmiCecMsg *msg, uint8_t menuStatus);
1773 void HdmiCecEncodingPlayMsg(struct HdmiCecMsg *msg, uint8_t playMode);
1774 void HdmiCecEncodingRecordOffMsg(struct HdmiCecMsg *msg, bool response);
1775 void HdmiCecEncodingRecordOnMsg(struct HdmiCecMsg *msg, struct HdmiCecRecordSource *src, bool response);
1776 void HdmiCecEncodingRecordStatusMsg(struct HdmiCecMsg *msg, uint8_t recordStatusInfo);
1777 void HdmiCecEncodingRecordTvScreenMsg(struct HdmiCecMsg *msg, bool response);
1778 void HdmiCecEncodingReportArcInitiatedMsg(struct HdmiCecMsg *msg);
1779 void HdmiCecEncodingReportArcTerminationMsg(struct HdmiCecMsg *msg);
1780 void HdmiCecEncodingReportAudioStatusMsg(struct HdmiCecMsg *msg, uint8_t audioMuteStatus, uint8_t audioVolumeStatus);
1781 void HdmiCecEncodingReportCurrentLatencyMsg(struct HdmiCecMsg *msg, uint16_t phyAddr, struct HdmiCecLatencyInfo *info);
1782 void HdmiCecEncodingReportDevicePowerStatusMsg(struct HdmiCecMsg *msg, uint8_t powerStatus);
1783 void HdmiCecEncodingReportShortAudioDescriptorMsg(struct HdmiCecMsg *msg, const uint32_t *descriptor, uint32_t len);
1784 void HdmiCecEncodingRequestActiveSourceMsg(struct HdmiCecMsg *msg, bool response);
1785 void HdmiCecEncodingRequestArcInitiationMsg(struct HdmiCecMsg *msg, bool response);
1786 void HdmiCecEncodingRequestArcTerminationMsg(struct HdmiCecMsg *msg, bool response);
1787 void HdmiCecEncodingRequestCurrentLatencyMsg(struct HdmiCecMsg *msg, uint16_t phyAddr, bool response);
1788 void HdmiCecEncodingRequestShortAudioDescriptorMsg(struct HdmiCecMsg *msg, const uint8_t *id, const uint8_t *code,
1789     uint32_t len, bool response);
1790 void HdmiCecEncodingRoutingChangeMsg(struct HdmiCecMsg *msg, uint16_t orgAddr, uint16_t newAddr, bool response);
1791 void HdmiCecEncodingRoutingInfomationMsg(struct HdmiCecMsg *msg, uint16_t phyAddr);
1792 void HdmiCecEncodingSelectAnalogueServiceMsg(struct HdmiCecMsg *msg, uint8_t anaBcastType, uint16_t anaFreq,
1793     uint8_t bcstSystem);
1794 void HdmiCecEncodingSelectDigitalServiceMsg(struct HdmiCecMsg *msg, struct HdmiCecDigitalServiceId *digital);
1795 void HdmiCecEncodingSetAnalogueTimerMsg(struct HdmiCecMsg *msg, struct HdmiCecAnalogueTimerInfo *info, bool response);
1796 void HdmiCecEncodingSetAudioRateMsg(struct HdmiCecMsg *msg, uint8_t rate);
1797 void HdmiCecEncodingSetDigitalTimerMsg(struct HdmiCecMsg *msg, struct HdmiCecDigitalTimerInfo *info, bool response);
1798 void HdmiCecEncodingSetExternalTimerMsg(struct HdmiCecMsg *msg, struct HdmiCecExternalTimerInfo *info, bool response);
1799 void HdmiCecEncodingSetMenuLanguageMsg(struct HdmiCecMsg *msg, uint8_t *language, uint32_t len);
1800 void HdmiCecEncodingSetOsdStringMsg(struct HdmiCecMsg *msg, uint8_t dispControl, uint8_t *str, uint32_t len);
1801 void HdmiCecEncodingSetStreamPathMsg(struct HdmiCecMsg *msg, uint16_t phyAddr);
1802 void HdmiCecEncodingSetSystemAudioModeMsg(struct HdmiCecMsg *msg, uint8_t status);
1803 void HdmiCecEncodingSetTimerProgramTitleMsg(struct HdmiCecMsg *msg, uint8_t *title, uint32_t len);
1804 void HdmiCecEncodingStandbyMsg(struct HdmiCecMsg *msg);
1805 void HdmiCecEncodingSystemAudioModeRequestMsg(struct HdmiCecMsg *msg, uint16_t phyAddr, bool response);
1806 void HdmiCecEncodingSystemAudioModeStatusMsg(struct HdmiCecMsg *msg, uint8_t status);
1807 void HdmiCecEncodingTerminateArcMsg(struct HdmiCecMsg *msg, bool response);
1808 void HdmiCecEncodingTextViewOnMsg(struct HdmiCecMsg *msg);
1809 void HdmiCecEncodingTimerClearedStatusMsg(struct HdmiCecMsg *msg, uint8_t status);
1810 void HdmiCecEncodingTimerStatusMsg(struct HdmiCecMsg *msg, const struct HdmiCecTimerStatusData *status);
1811 void HdmiCecEncodingTunerDeviceStatusMsg(struct HdmiCecMsg *msg, const struct HdmiCecTunerDeviceInfo *info);
1812 void HdmiCecEncodingTunerStepDecrementMsg(struct HdmiCecMsg *msg);
1813 void HdmiCecEncodingTunerStepIncrementMsg(struct HdmiCecMsg *msg);
1814 void HdmiCecEncodingUserControlPrtessedMsg(struct HdmiCecMsg *msg, const struct HdmiCecUiCmd *cmd);
1815 void HdmiCecEncodingUserControlReleasedMsg(struct HdmiCecMsg *msg);
1816 void HdmiCecEncodingVendorCommandMsg(struct HdmiCecMsg *msg, uint8_t *data, uint32_t len);
1817 void HdmiCecEncodingVendorCommandWithIdMsg(struct HdmiCecMsg *msg, uint32_t vendorId, uint8_t *data, uint32_t len);
1818 void HdmiCecEncodingVendorRemoteButtonDownMsg(struct HdmiCecMsg *msg, uint8_t *rcCode, uint32_t len);
1819 void HdmiCecEncodingVendorRemoteButtonUpMsg(struct HdmiCecMsg *msg);
1820 
1821 #ifdef __cplusplus
1822 #if __cplusplus
1823 }
1824 #endif
1825 #endif /* __cplusplus */
1826 
1827 #endif /* HDMI_CEC_H */
1828