1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | /* |
29 | * CEC related constants - shared by both host and vc. |
30 | */ |
31 | |
32 | #ifndef _VC_CEC_H_ |
33 | #define _VC_CEC_H_ |
34 | |
35 | #ifndef STRINGIFY |
36 | #define STRINGIFY(x) #x |
37 | #define TOSTRING(x) STRINGIFY(x) |
38 | #endif |
39 | |
40 | //Broadcast address and TV logical address |
41 | #define CEC_BROADCAST_ADDR 0x0F |
42 | #define CEC_TV_ADDRESS 0x00 |
43 | |
44 | //Maximum transmit length excluding the header byte */ |
45 | #define CEC_MAX_XMIT_LENGTH 15 /* +1 for CEC Header Length */ |
46 | //Invalid physical address |
47 | #define CEC_CLEAR_ADDR 0xFFFF /* packed 16 bits of F.F.F.F */ |
48 | |
49 | /* ---------------------------------------------------------------------- |
50 | * general CEC defines |
51 | * -------------------------------------------------------------------- */ |
52 | //Maximum transmission length and invalid physical address are now in vc_cec.h |
53 | #define CEC_VERSION 0x04 /* HDMI 1.3a */ |
54 | //This OUI ID is registered at the current HQ address in Irvine |
55 | #define CEC_VENDOR_ID_BROADCOM (0x18C086L) // 24 bit OUI company id from IEEE. = Broadcom |
56 | //These three OUI IDs are registered with the old address of Irvine office in case you need them |
57 | //#define CEC_VENDOR_ID_BROADCOM (0x000AF7L) |
58 | //#define CEC_VENDOR_ID_BROADCOM (0x001018L) |
59 | //#define CEC_VENDOR_ID_BROADCOM (0x001BE9L) |
60 | #define CEC_VENDOR_ID_ONKYO (0x0009B0L) |
61 | #define CEC_VENDOR_ID_PANASONIC_EUROPE (0x000F12L) |
62 | |
63 | //If we want to "pretend" to be somebody else use a different company id |
64 | #define CEC_VENDOR_ID (0x000000L) //We should set the vendor id |
65 | |
66 | #define CEC_BLOCKING 1 |
67 | #define CEC_NONBLOCKING 0 |
68 | |
69 | /** |
70 | * These are the logical addresses for all possible attached devices |
71 | */ |
72 | typedef enum CEC_AllDevices { |
73 | CEC_AllDevices_eTV = 0, /**<TV only */ |
74 | CEC_AllDevices_eRec1, /**<Address for 1st Recording Device */ |
75 | CEC_AllDevices_eRec2, /**<Address for 2nd Recording Device */ |
76 | CEC_AllDevices_eSTB1, /**<Address for 1st SetTop Box Device */ |
77 | CEC_AllDevices_eDVD1, /**<Address for 1st DVD Device */ |
78 | CEC_AllDevices_eAudioSystem, /**<Address for Audio Device */ |
79 | CEC_AllDevices_eSTB2, /**<Address for 2nd SetTop Box Device */ |
80 | CEC_AllDevices_eSTB3, /**<Address for 3rd SetTop Box Device */ |
81 | CEC_AllDevices_eDVD2, /**<Address for 2nd DVD Device */ |
82 | CEC_AllDevices_eRec3, /**<Address for 3rd Recording Device */ |
83 | CEC_AllDevices_eSTB4, /**<10 Address for 4th Tuner Device */ |
84 | CEC_AllDevices_eDVD3, /**<11 Address for 3rd DVD Device */ |
85 | CEC_AllDevices_eRsvd3, /**<Reserved and cannot be used */ |
86 | CEC_AllDevices_eRsvd4, /**<Reserved and cannot be used */ |
87 | CEC_AllDevices_eFreeUse, /**<Free Address, use for any device */ |
88 | CEC_AllDevices_eUnRegistered = 15 /**<UnRegistered Devices */ |
89 | } CEC_AllDevices_T; |
90 | |
91 | /** |
92 | * define device types for <Report Physical Address> |
93 | */ |
94 | typedef enum CEC_DeviceTypes{ |
95 | CEC_DeviceType_TV = 0, /**<TV only */ |
96 | CEC_DeviceType_Rec = 1, /**<Recoding device */ |
97 | CEC_DeviceType_Reserved = 2, /**<Reserved */ |
98 | CEC_DeviceType_Tuner = 3, /**<STB */ |
99 | CEC_DeviceType_Playback = 4, /**<DVD player */ |
100 | CEC_DeviceType_Audio = 5, /**<AV receiver */ |
101 | CEC_DeviceType_Switch = 6, /**<CEC switch */ |
102 | CEC_DeviceType_VidProc = 7, /**<Video processor */ |
103 | |
104 | CEC_DeviceType_Invalid = 0xF, //RESERVED - DO NOT USE |
105 | } CEC_DEVICE_TYPE_T; |
106 | |
107 | /** |
108 | * Generic CEC opcode |
109 | */ |
110 | typedef enum { |
111 | CEC_Opcode_FeatureAbort = 0x00, |
112 | CEC_Opcode_ImageViewOn = 0x04, |
113 | CEC_Opcode_TunerStepIncrement = 0x05, |
114 | CEC_Opcode_TunerStepDecrement = 0x06, |
115 | CEC_Opcode_TunerDeviceStatus = 0x07, |
116 | CEC_Opcode_GiveTunerDeviceStatus = 0x08, |
117 | CEC_Opcode_RecordOn = 0x09, |
118 | CEC_Opcode_RecordStatus = 0x0A, |
119 | CEC_Opcode_RecordOff = 0x0B, |
120 | CEC_Opcode_TextViewOn = 0x0D, |
121 | CEC_Opcode_RecordTVScreen = 0x0F, |
122 | CEC_Opcode_GiveDeckStatus = 0x1A, |
123 | CEC_Opcode_DeckStatus = 0x1B, |
124 | = 0x32, |
125 | CEC_Opcode_ClearAnalogTimer = 0x33, |
126 | CEC_Opcode_SetAnalogTimer = 0x34, |
127 | CEC_Opcode_TimerStatus = 0x35, |
128 | CEC_Opcode_Standby = 0x36, |
129 | CEC_Opcode_Play = 0x41, |
130 | CEC_Opcode_DeckControl = 0x42, |
131 | CEC_Opcode_TimerClearedStatus = 0x43, |
132 | CEC_Opcode_UserControlPressed = 0x44, |
133 | CEC_Opcode_UserControlReleased = 0x45, |
134 | CEC_Opcode_GiveOSDName = 0x46, |
135 | CEC_Opcode_SetOSDName = 0x47, |
136 | CEC_Opcode_SetOSDString = 0x64, |
137 | CEC_Opcode_SetTimerProgramTitle = 0x67, |
138 | CEC_Opcode_SystemAudioModeRequest = 0x70, |
139 | CEC_Opcode_GiveAudioStatus = 0x71, |
140 | CEC_Opcode_SetSystemAudioMode = 0x72, |
141 | CEC_Opcode_ReportAudioStatus = 0x7A, |
142 | CEC_Opcode_GiveSystemAudioModeStatus = 0x7D, |
143 | CEC_Opcode_SystemAudioModeStatus = 0x7E, |
144 | CEC_Opcode_RoutingChange = 0x80, |
145 | CEC_Opcode_RoutingInformation = 0x81, |
146 | CEC_Opcode_ActiveSource = 0x82, |
147 | CEC_Opcode_GivePhysicalAddress = 0x83, |
148 | CEC_Opcode_ReportPhysicalAddress = 0x84, |
149 | CEC_Opcode_RequestActiveSource = 0x85, |
150 | CEC_Opcode_SetStreamPath = 0x86, |
151 | CEC_Opcode_DeviceVendorID = 0x87, |
152 | CEC_Opcode_VendorCommand = 0x89, |
153 | CEC_Opcode_VendorRemoteButtonDown = 0x8A, |
154 | CEC_Opcode_VendorRemoteButtonUp = 0x8B, |
155 | CEC_Opcode_GiveDeviceVendorID = 0x8C, |
156 | = 0x8D, |
157 | = 0x8E, |
158 | CEC_Opcode_GiveDevicePowerStatus = 0x8F, |
159 | CEC_Opcode_ReportPowerStatus = 0x90, |
160 | = 0x91, |
161 | CEC_Opcode_SelectAnalogService = 0x92, |
162 | CEC_Opcode_SelectDigitalService = 0x93, |
163 | CEC_Opcode_SetDigitalTimer = 0x97, |
164 | CEC_Opcode_ClearDigitalTimer = 0x99, |
165 | CEC_Opcode_SetAudioRate = 0x9A, |
166 | CEC_Opcode_InactiveSource = 0x9D, |
167 | CEC_Opcode_CECVersion = 0x9E, |
168 | CEC_Opcode_GetCECVersion = 0x9F, |
169 | CEC_Opcode_VendorCommandWithID = 0xA0, |
170 | CEC_Opcode_ClearExternalTimer = 0xA1, |
171 | CEC_Opcode_SetExternalTimer = 0xA2, |
172 | CEC_Opcode_ReportShortAudioDescriptor = 0xA3, |
173 | CEC_Opcode_RequestShortAudioDescriptor = 0xA4, |
174 | CEC_Opcode_InitARC = 0xC0, |
175 | CEC_Opcode_ReportARCInited = 0xC1, |
176 | CEC_Opcode_ReportARCTerminated = 0xC2, |
177 | CEC_Opcode_RequestARCInit = 0xC3, |
178 | CEC_Opcode_RequestARCTermination = 0xC4, |
179 | CEC_Opcode_TerminateARC = 0xC5, |
180 | CEC_Opcode_CDC = 0xF8, |
181 | CEC_Opcode_Abort = 0xFF |
182 | } CEC_OPCODE_T; |
183 | |
184 | /** |
185 | * Reason parameter for <Feature Abort> |
186 | */ |
187 | typedef enum { |
188 | CEC_Abort_Reason_Unrecognised_Opcode = 0, |
189 | CEC_Abort_Reason_Wrong_Mode = 1, |
190 | CEC_Abort_Reason_Cannot_Provide_Source = 2, |
191 | CEC_Abort_Reason_Invalid_Operand = 3, |
192 | CEC_Abort_Reason_Refused = 4, |
193 | CEC_Abort_Reason_Undetermined = 5 |
194 | } CEC_ABORT_REASON_T; |
195 | |
196 | /** |
197 | * Display control parameter for <Set OSD string> |
198 | */ |
199 | typedef enum { |
200 | CEC_DISPLAY_CONTROL_DEFAULT_TIME = 0, |
201 | CEC_DISPLAY_CONTROL_UNTIL_CLEARED = (1<<6), |
202 | CEC_DISPLAY_CONTROL_CLEAR_PREV_MSG = (1<<7) |
203 | } CEC_DISPLAY_CONTROL_T; |
204 | |
205 | /** |
206 | * Power status parameter for <Report Power Status> |
207 | */ |
208 | typedef enum { |
209 | CEC_POWER_STATUS_ON = 0, |
210 | CEC_POWER_STATUS_STANDBY = 1, |
211 | CEC_POWER_STATUS_ON_PENDING = 2, |
212 | CEC_POWER_STATUS_STANDBY_PENDING = 3 |
213 | } CEC_POWER_STATUS_T; |
214 | |
215 | /** |
216 | * Menu state parameter for <Menu Status> |
217 | */ |
218 | typedef enum { |
219 | = 0, |
220 | = 1, |
221 | = 2 |
222 | } ; |
223 | |
224 | /** |
225 | * Deck status parameter for <Deck Status> |
226 | */ |
227 | typedef enum { |
228 | CEC_DECK_INFO_PLAY = 0x11, |
229 | CEC_DECK_INFO_RECORD = 0x12, |
230 | CEC_DECK_INFO_PLAY_REVERSE = 0x13, |
231 | CEC_DECK_INFO_STILL = 0x14, |
232 | CEC_DECK_INFO_SLOW = 0x15, |
233 | CEC_DECK_INFO_SLOW_REVERSE = 0x16, |
234 | CEC_DECK_INFO_SEARCH_FORWARD = 0x17, |
235 | CEC_DECK_INFO_SEARCH_REVERSE = 0x18, |
236 | CEC_DECK_INFO_NO_MEDIA = 0x19, |
237 | CEC_DECK_INFO_STOP = 0x1A, |
238 | CEC_DECK_INFO_WIND = 0x1B, |
239 | CEC_DECK_INFO_REWIND = 0x1C, |
240 | CEC_DECK_IDX_SEARCH_FORWARD = 0x1D, |
241 | CEC_DECK_IDX_SEARCH_REVERSE = 0x1E, |
242 | CEC_DECK_OTHER_STATUS = 0x1F |
243 | } CEC_DECK_INFO_T; |
244 | |
245 | /** |
246 | * Deck control mode for <Deck Control> |
247 | */ |
248 | typedef enum { |
249 | CEC_DECK_CTRL_FORWARD = 1, |
250 | CEC_DECK_CTRL_BACKWARD = 2, |
251 | CEC_DECK_CTRL_STOP = 3, |
252 | CEC_DECK_CTRL_EJECT = 4 |
253 | } CEC_DECK_CTRL_MODE_T; |
254 | |
255 | /** |
256 | * Play mode for <Play> |
257 | */ |
258 | typedef enum { |
259 | CEC_PLAY_FORWARD = 0x24, |
260 | CEC_PLAY_REVERSE = 0x20, |
261 | CEC_PLAY_STILL = 0x25, |
262 | CEC_PLAY_SCAN_FORWARD_MIN_SPEED = 0x05, |
263 | CEC_PLAY_SCAN_FORWARD_MED_SPEED = 0x06, |
264 | CEC_PLAY_SCAN_FORWARD_MAX_SPEED = 0x07, |
265 | CEC_PLAY_SCAN_REVERSE_MIN_SPEED = 0x09, |
266 | CEC_PLAY_SCAN_REVERSE_MED_SPEED = 0x0A, |
267 | CEC_PLAY_SCAN_REVERSE_MAX_SPEED = 0x0B, |
268 | CEC_PLAY_SLOW_FORWARD_MIN_SPEED = 0x15, |
269 | CEC_PLAY_SLOW_FORWARD_MED_SPEED = 0x16, |
270 | CEC_PLAY_SLOW_FORWARD_MAX_SPEED = 0x17, |
271 | CEC_PLAY_SLOW_REVERSE_MIN_SPEED = 0x19, |
272 | CEC_PLAY_SLOW_REVERSE_MED_SPEED = 0x1A, |
273 | CEC_PLAY_SLOW_REVERSE_MAX_SPEED = 0x1B |
274 | } CEC_PLAY_MODE_T; |
275 | |
276 | /** |
277 | * Status request for <Give Deck Status> |
278 | */ |
279 | typedef enum { |
280 | CEC_DECK_STATUS_ON = 1, |
281 | CEC_DECK_STATUS_OFF = 2, |
282 | CEC_DECK_STATUS_ONCE = 3 |
283 | } CEC_DECK_STATUS_REQUEST_T; |
284 | |
285 | /** |
286 | * Button code for <User Control Pressed> |
287 | */ |
288 | typedef enum { |
289 | CEC_User_Control_Select = 0x00, |
290 | CEC_User_Control_Up = 0x01, |
291 | CEC_User_Control_Down = 0x02, |
292 | CEC_User_Control_Left = 0x03, |
293 | CEC_User_Control_Right = 0x04, |
294 | CEC_User_Control_RightUp = 0x05, |
295 | CEC_User_Control_RightDown = 0x06, |
296 | CEC_User_Control_LeftUp = 0x07, |
297 | CEC_User_Control_LeftDown = 0x08, |
298 | = 0x09, |
299 | = 0x0A, |
300 | = 0x0B, |
301 | = 0x0C, |
302 | CEC_User_Control_Exit = 0x0D, |
303 | CEC_User_Control_Number0 = 0x20, |
304 | CEC_User_Control_Number1 = 0x21, |
305 | CEC_User_Control_Number2 = 0x22, |
306 | CEC_User_Control_Number3 = 0x23, |
307 | CEC_User_Control_Number4 = 0x24, |
308 | CEC_User_Control_Number5 = 0x25, |
309 | CEC_User_Control_Number6 = 0x26, |
310 | CEC_User_Control_Number7 = 0x27, |
311 | CEC_User_Control_Number8 = 0x28, |
312 | CEC_User_Control_Number9 = 0x29, |
313 | CEC_User_Control_Dot = 0x2A, |
314 | CEC_User_Control_Enter = 0x2B, |
315 | CEC_User_Control_Clear = 0x2C, |
316 | CEC_User_Control_ChannelUp = 0x30, |
317 | CEC_User_Control_ChannelDown = 0x31, |
318 | CEC_User_Control_PreviousChannel = 0x32, |
319 | CEC_User_Control_SoundSelect = 0x33, |
320 | CEC_User_Control_InputSelect = 0x34, |
321 | CEC_User_Control_DisplayInformation = 0x35, |
322 | CEC_User_Control_Help = 0x36, |
323 | CEC_User_Control_PageUp = 0x37, |
324 | CEC_User_Control_PageDown = 0x38, |
325 | CEC_User_Control_Power = 0x40, |
326 | CEC_User_Control_VolumeUp = 0x41, |
327 | CEC_User_Control_VolumeDown = 0x42, |
328 | CEC_User_Control_Mute = 0x43, |
329 | CEC_User_Control_Play = 0x44, |
330 | CEC_User_Control_Stop = 0x45, |
331 | CEC_User_Control_Pause = 0x46, |
332 | CEC_User_Control_Record = 0x47, |
333 | CEC_User_Control_Rewind = 0x48, |
334 | CEC_User_Control_FastForward = 0x49, |
335 | CEC_User_Control_Eject = 0x4A, |
336 | CEC_User_Control_Forward = 0x4B, |
337 | CEC_User_Control_Backward = 0x4C, |
338 | CEC_User_Control_Angle = 0x50, |
339 | CEC_User_Control_Subpicture = 0x51, |
340 | CEC_User_Control_VideoOnDemand = 0x52, |
341 | CEC_User_Control_EPG = 0x53, |
342 | CEC_User_Control_TimerProgramming = 0x54, |
343 | CEC_User_Control_InitialConfig = 0x55, |
344 | CEC_User_Control_PlayFunction = 0x60, |
345 | CEC_User_Control_PausePlayFunction = 0x61, |
346 | CEC_User_Control_RecordFunction = 0x62, |
347 | CEC_User_Control_PauseRecordFunction = 0x63, |
348 | CEC_User_Control_StopFunction = 0x64, |
349 | CEC_User_Control_MuteFunction = 0x65, |
350 | CEC_User_Control_RestoreVolumeFunction = 0x66, |
351 | CEC_User_Control_TuneFunction = 0x67, |
352 | CEC_User_Control_SelectDiskFunction = 0x68, |
353 | CEC_User_Control_SelectAVInputFunction = 0x69, |
354 | CEC_User_Control_SelectAudioInputFunction = 0x6A, |
355 | CEC_User_Control_F1Blue = 0x71, |
356 | CEC_User_Control_F2Red = 0x72, |
357 | CEC_User_Control_F3Green = 0x73, |
358 | CEC_User_Control_F4Yellow = 0x74, |
359 | CEC_User_Control_F5 = 0x75 |
360 | } CEC_USER_CONTROL_T; |
361 | |
362 | /** |
363 | *CEC topology struct |
364 | * |
365 | * Meaning of device_attr is as follows (one per active logical device) |
366 | * bit 3-0 logical address (see CEC_AllDevices_T above) |
367 | * bit 7-4 device type (see CEC_DEVICE_TYPE_T above) |
368 | * bit 11-8 index to upstream device |
369 | * bit 15-12 number of downstream device |
370 | * bit 31-16 index of first 4 downstream devices |
371 | * |
372 | * To keep life simple we only show the first 4 connected downstream devices |
373 | * |
374 | */ |
375 | typedef struct { |
376 | uint16_t active_mask; /**<bit n is set if logical device n is active */ |
377 | uint16_t num_devices; /**<no. of bits set above, save us from counting */ |
378 | uint32_t device_attr[16]; /**<Device attribute, see above for explanation */ |
379 | } VC_CEC_TOPOLOGY_T; |
380 | |
381 | /** |
382 | * CEC message format (provided for host application's convenience |
383 | * for encapsulating a CEC message |
384 | */ |
385 | typedef struct { |
386 | uint32_t length; //Length of CEC message without the header, so zero indicates a poll message |
387 | CEC_AllDevices_T initiator; |
388 | CEC_AllDevices_T follower; |
389 | uint8_t payload[CEC_MAX_XMIT_LENGTH+1]; //We actually only need 15 bytes, this payload does not include header |
390 | } VC_CEC_MESSAGE_T; |
391 | |
392 | /** |
393 | * CEC related notification |
394 | */ |
395 | typedef enum { |
396 | VC_CEC_NOTIFY_NONE = 0, //Reserved - NOT TO BE USED |
397 | VC_CEC_TX = (1 << 0), /**<A message has been transmitted */ |
398 | VC_CEC_RX = (1 << 1), /**<A message has arrived (only for registered commands) */ |
399 | VC_CEC_BUTTON_PRESSED = (1 << 2), /**<<User Control Pressed> */ |
400 | VC_CEC_BUTTON_RELEASE = (1 << 3), /**<<User Control Release> */ |
401 | VC_CEC_REMOTE_PRESSED = (1 << 4), /**<<Vendor Remote Button Down> */ |
402 | VC_CEC_REMOTE_RELEASE = (1 << 5), /**<<Vendor Remote Button Up> */ |
403 | VC_CEC_LOGICAL_ADDR = (1 << 6), /**<New logical address allocated or released */ |
404 | VC_CEC_TOPOLOGY = (1 << 7), /**<Topology is available */ |
405 | VC_CEC_LOGICAL_ADDR_LOST = (1 << 15) /**<Only for passive mode, if the logical address is lost for whatever reason, this will be triggered */ |
406 | } VC_CEC_NOTIFY_T; |
407 | |
408 | |
409 | /** |
410 | * Callback reason and arguments (for sending back to host) All parameters are uint32_t |
411 | * For the reason parameter |
412 | * Bit 15-0 of reason is the reason code, |
413 | * Bit 23-16 is length of valid bytes which follows in the 4 32-bit parameters (0 < length <= 16) |
414 | * Bit 31-24 is any return code (if required for this callback) |
415 | * |
416 | * Length of valid bytes for TX/RX/button press/release callbacks will be the length |
417 | * of the actual CEC message |
418 | * |
419 | * Length of valid bytes for logical address will always be 6 (first parameter + 16-bit physical address) |
420 | * |
421 | * Length of valid bytes for topology callback will always be 2 (16-bit mask) |
422 | * |
423 | * Many CEC callback messages are of variable length so not all bytes 0-15 are available |
424 | * |
425 | * Reason param1 param2 param3 param4 remark |
426 | * VC_CEC_TX bytes 0-3 bytes 4-7 bytes 8-11 bytes 12-15 A message has been transmitted |
427 | * Only a message sent from the host will |
428 | generate this callback |
429 | (non-zero return code means failure) |
430 | |
431 | * VC_CEC_RX bytes 0-3 bytes 4-7 bytes 8-11 bytes 12-15 By definition only successful message will be forwarded |
432 | * |
433 | * VC_CEC_BUTTON_PRESSED bytes 0-3 bytes 4-7 - - User Control pressed (byte 2 will be actual user control code) |
434 | * VC_CEC_BUTTON_RELEASE bytes 0-3 - - - User Control release (byte 2 will be actual user control code) |
435 | |
436 | * VC_CEC_REMOTE_PRESSED bytes 0-3 bytes 4-7 bytes 8-11 bytes 12-15 Vendor remote button down |
437 | * VC_CEC_REMOTE_RELEASE bytes 0-3 bytes 4-7 bytes 8-11 bytes 12-15 Vendor remote button up |
438 | |
439 | * VC_CEC_LOGICAL_ADDR Log addr Phy addr - - Logical address allocated or failure |
440 | * VC_CEC_TOPOLOGY topology bit |
441 | * mask New topology is avaiable |
442 | * |
443 | *VC_CEC_LOGICAL_ADDR_LOST Last log addr Phy addr "Last log addr" is no longer available |
444 | * |
445 | * Notes: |
446 | * VC_CEC_BUTTON_RELEASE and VC_CEC_REMOTE_RELEASE (<User Control Release> and <Vendor Remote Button Up> messages respectively) |
447 | * returns the code from the most recent <User Control pressed> <Vendor Remote button up> respectively. |
448 | * The host application will need to find out the vendor ID of the initiator |
449 | * separately in the case if <Vendor Remote Button Up>/<Vendor Remote Button Down> commands were received. |
450 | * <User Control Pressed> will not be longer than 6 bytes (including header) |
451 | * |
452 | * VC_CEC_LOGICAL_ADDR returns 0xF in param1 whenever no logical address is in used. If physical address is 0xFFFF, |
453 | * this means CEC is being disabled. Otherwise physical address is the one read from EDID (and no suitable logical address |
454 | * is avaiable to be allocated). Host application should only attempt to send message if both param1 is not 0xF AND param2 |
455 | * is not 0xFFFF. |
456 | * |
457 | * VC_CEC_TOPOLOGY returns a 16-bit mask in param1 where bit n is set if logical address n is present. Host application |
458 | * must explicitly retrieve the entire topology if it wants to know how devices are connected. The bit mask includes our |
459 | * own logical address. |
460 | * |
461 | * If CEC is running in passive mode, the host will get a VC_CEC_LOGICAL_ADDR_LOST callback if the logical address is |
462 | * lost (e.g. HDMI mode change). In this case the host should try a new logical address. The physical address returned may |
463 | * also change, so the host should check this. |
464 | */ |
465 | |
466 | /** |
467 | * General callback function for notifications from CEC middleware (and CEC service) |
468 | * |
469 | * @param client_p is the callback context passed in by user |
470 | * |
471 | * @param reason is the notification nature (plus message lengths, return code, etc.) |
472 | * |
473 | * @param param1 is the first parameter of notification (see above) |
474 | * |
475 | * @param param2 is the second parameter of notification (see above) |
476 | * |
477 | * @param param3 is the third parameter of notification (see above) |
478 | * |
479 | * @param param4 is the fourth parameter of notification (see above) |
480 | * |
481 | * @return void |
482 | */ |
483 | typedef void (*CEC_CALLBACK_T)(void *client_p, uint32_t reason, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4); |
484 | |
485 | /** |
486 | * Some macros to get some fields from the callback parameters in CEC callback |
487 | */ |
488 | //Marcos operating on reason |
489 | #define CEC_CB_REASON(x) ((x) & 0xFFFF) /** Get callback reason */ |
490 | #define CEC_CB_MSG_LENGTH(x) (((x) >> 16) & 0xFF) /** Get callback parameter length (this includes the header byte) */ |
491 | #define CEC_CB_RC(x) (((x) >> 24) & 0xFF) /** Get return value (only for TX callbacks for the moment) */ |
492 | |
493 | //Macros operating on param1 |
494 | #define CEC_CB_INITIATOR(x) (((x) >> 4) & 0xF) /** Get the initiator from first parameter */ |
495 | #define CEC_CB_FOLLOWER(x) ((x) & 0xF) /** Get the follower from first parameter */ |
496 | #define CEC_CB_OPCODE(x) (((x) >> 8) & 0xFF) /** Get the opcode from first parameter */ |
497 | #define CEC_CB_OPERAND1(x) (((x) >> 16) & 0xFF) /** Get the button code from <User Control Pressed> or the first operand of the opcode */ |
498 | #define CEC_CB_OPERAND2(x) (((x) >> 24) & 0xFF) /** Get the second operand of opcode */ |
499 | |
500 | //CEC service return code |
501 | typedef enum { |
502 | VC_CEC_SUCCESS = 0, /** OK */ |
503 | VC_CEC_ERROR_NO_ACK = 1, /** No acknowledgement */ |
504 | VC_CEC_ERROR_SHUTDOWN = 2, /** In the process of shutting down */ |
505 | VC_CEC_ERROR_BUSY = 3, /** block is busy */ |
506 | VC_CEC_ERROR_NO_LA = 4, /** No logical address */ |
507 | VC_CEC_ERROR_NO_PA = 5, /** No physical address */ |
508 | VC_CEC_ERROR_NO_TOPO = 6, /** No topology */ |
509 | VC_CEC_ERROR_INVALID_FOLLOWER = 7, /** Invalid follower */ |
510 | VC_CEC_ERROR_INVALID_ARGUMENT = 8 /** Invalid arguments */ |
511 | } VC_CEC_ERROR_T; |
512 | |
513 | #endif |
514 | |