/* Copyright (c) 2012, Broadcom Europe Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * CEC related constants - shared by both host and vc. */ #ifndef _VC_CEC_H_ #define _VC_CEC_H_ #ifndef STRINGIFY #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) #endif //Broadcast address and TV logical address #define CEC_BROADCAST_ADDR 0x0F #define CEC_TV_ADDRESS 0x00 //Maximum transmit length excluding the header byte */ #define CEC_MAX_XMIT_LENGTH 15 /* +1 for CEC Header Length */ //Invalid physical address #define CEC_CLEAR_ADDR 0xFFFF /* packed 16 bits of F.F.F.F */ /* ---------------------------------------------------------------------- * general CEC defines * -------------------------------------------------------------------- */ //Maximum transmission length and invalid physical address are now in vc_cec.h #define CEC_VERSION 0x04 /* HDMI 1.3a */ //This OUI ID is registered at the current HQ address in Irvine #define CEC_VENDOR_ID_BROADCOM (0x18C086L) // 24 bit OUI company id from IEEE. = Broadcom //These three OUI IDs are registered with the old address of Irvine office in case you need them //#define CEC_VENDOR_ID_BROADCOM (0x000AF7L) //#define CEC_VENDOR_ID_BROADCOM (0x001018L) //#define CEC_VENDOR_ID_BROADCOM (0x001BE9L) #define CEC_VENDOR_ID_ONKYO (0x0009B0L) #define CEC_VENDOR_ID_PANASONIC_EUROPE (0x000F12L) //If we want to "pretend" to be somebody else use a different company id #define CEC_VENDOR_ID (0x000000L) //We should set the vendor id #define CEC_BLOCKING 1 #define CEC_NONBLOCKING 0 /** * These are the logical addresses for all possible attached devices */ typedef enum CEC_AllDevices { CEC_AllDevices_eTV = 0, /** */ typedef enum CEC_DeviceTypes{ CEC_DeviceType_TV = 0, /** */ typedef enum { CEC_Abort_Reason_Unrecognised_Opcode = 0, CEC_Abort_Reason_Wrong_Mode = 1, CEC_Abort_Reason_Cannot_Provide_Source = 2, CEC_Abort_Reason_Invalid_Operand = 3, CEC_Abort_Reason_Refused = 4, CEC_Abort_Reason_Undetermined = 5 } CEC_ABORT_REASON_T; /** * Display control parameter for */ typedef enum { CEC_DISPLAY_CONTROL_DEFAULT_TIME = 0, CEC_DISPLAY_CONTROL_UNTIL_CLEARED = (1<<6), CEC_DISPLAY_CONTROL_CLEAR_PREV_MSG = (1<<7) } CEC_DISPLAY_CONTROL_T; /** * Power status parameter for */ typedef enum { CEC_POWER_STATUS_ON = 0, CEC_POWER_STATUS_STANDBY = 1, CEC_POWER_STATUS_ON_PENDING = 2, CEC_POWER_STATUS_STANDBY_PENDING = 3 } CEC_POWER_STATUS_T; /** * Menu state parameter for */ typedef enum { CEC_MENU_STATE_ACTIVATED = 0, CEC_MENU_STATE_DEACTIVATED = 1, CEC_MENU_STATE_QUERY = 2 } CEC_MENU_STATE_T; /** * Deck status parameter for */ typedef enum { CEC_DECK_INFO_PLAY = 0x11, CEC_DECK_INFO_RECORD = 0x12, CEC_DECK_INFO_PLAY_REVERSE = 0x13, CEC_DECK_INFO_STILL = 0x14, CEC_DECK_INFO_SLOW = 0x15, CEC_DECK_INFO_SLOW_REVERSE = 0x16, CEC_DECK_INFO_SEARCH_FORWARD = 0x17, CEC_DECK_INFO_SEARCH_REVERSE = 0x18, CEC_DECK_INFO_NO_MEDIA = 0x19, CEC_DECK_INFO_STOP = 0x1A, CEC_DECK_INFO_WIND = 0x1B, CEC_DECK_INFO_REWIND = 0x1C, CEC_DECK_IDX_SEARCH_FORWARD = 0x1D, CEC_DECK_IDX_SEARCH_REVERSE = 0x1E, CEC_DECK_OTHER_STATUS = 0x1F } CEC_DECK_INFO_T; /** * Deck control mode for */ typedef enum { CEC_DECK_CTRL_FORWARD = 1, CEC_DECK_CTRL_BACKWARD = 2, CEC_DECK_CTRL_STOP = 3, CEC_DECK_CTRL_EJECT = 4 } CEC_DECK_CTRL_MODE_T; /** * Play mode for */ typedef enum { CEC_PLAY_FORWARD = 0x24, CEC_PLAY_REVERSE = 0x20, CEC_PLAY_STILL = 0x25, CEC_PLAY_SCAN_FORWARD_MIN_SPEED = 0x05, CEC_PLAY_SCAN_FORWARD_MED_SPEED = 0x06, CEC_PLAY_SCAN_FORWARD_MAX_SPEED = 0x07, CEC_PLAY_SCAN_REVERSE_MIN_SPEED = 0x09, CEC_PLAY_SCAN_REVERSE_MED_SPEED = 0x0A, CEC_PLAY_SCAN_REVERSE_MAX_SPEED = 0x0B, CEC_PLAY_SLOW_FORWARD_MIN_SPEED = 0x15, CEC_PLAY_SLOW_FORWARD_MED_SPEED = 0x16, CEC_PLAY_SLOW_FORWARD_MAX_SPEED = 0x17, CEC_PLAY_SLOW_REVERSE_MIN_SPEED = 0x19, CEC_PLAY_SLOW_REVERSE_MED_SPEED = 0x1A, CEC_PLAY_SLOW_REVERSE_MAX_SPEED = 0x1B } CEC_PLAY_MODE_T; /** * Status request for */ typedef enum { CEC_DECK_STATUS_ON = 1, CEC_DECK_STATUS_OFF = 2, CEC_DECK_STATUS_ONCE = 3 } CEC_DECK_STATUS_REQUEST_T; /** * Button code for */ typedef enum { CEC_User_Control_Select = 0x00, CEC_User_Control_Up = 0x01, CEC_User_Control_Down = 0x02, CEC_User_Control_Left = 0x03, CEC_User_Control_Right = 0x04, CEC_User_Control_RightUp = 0x05, CEC_User_Control_RightDown = 0x06, CEC_User_Control_LeftUp = 0x07, CEC_User_Control_LeftDown = 0x08, CEC_User_Control_RootMenu = 0x09, CEC_User_Control_SetupMenu = 0x0A, CEC_User_Control_ContentsMenu = 0x0B, CEC_User_Control_FavoriteMenu = 0x0C, CEC_User_Control_Exit = 0x0D, CEC_User_Control_Number0 = 0x20, CEC_User_Control_Number1 = 0x21, CEC_User_Control_Number2 = 0x22, CEC_User_Control_Number3 = 0x23, CEC_User_Control_Number4 = 0x24, CEC_User_Control_Number5 = 0x25, CEC_User_Control_Number6 = 0x26, CEC_User_Control_Number7 = 0x27, CEC_User_Control_Number8 = 0x28, CEC_User_Control_Number9 = 0x29, CEC_User_Control_Dot = 0x2A, CEC_User_Control_Enter = 0x2B, CEC_User_Control_Clear = 0x2C, CEC_User_Control_ChannelUp = 0x30, CEC_User_Control_ChannelDown = 0x31, CEC_User_Control_PreviousChannel = 0x32, CEC_User_Control_SoundSelect = 0x33, CEC_User_Control_InputSelect = 0x34, CEC_User_Control_DisplayInformation = 0x35, CEC_User_Control_Help = 0x36, CEC_User_Control_PageUp = 0x37, CEC_User_Control_PageDown = 0x38, CEC_User_Control_Power = 0x40, CEC_User_Control_VolumeUp = 0x41, CEC_User_Control_VolumeDown = 0x42, CEC_User_Control_Mute = 0x43, CEC_User_Control_Play = 0x44, CEC_User_Control_Stop = 0x45, CEC_User_Control_Pause = 0x46, CEC_User_Control_Record = 0x47, CEC_User_Control_Rewind = 0x48, CEC_User_Control_FastForward = 0x49, CEC_User_Control_Eject = 0x4A, CEC_User_Control_Forward = 0x4B, CEC_User_Control_Backward = 0x4C, CEC_User_Control_Angle = 0x50, CEC_User_Control_Subpicture = 0x51, CEC_User_Control_VideoOnDemand = 0x52, CEC_User_Control_EPG = 0x53, CEC_User_Control_TimerProgramming = 0x54, CEC_User_Control_InitialConfig = 0x55, CEC_User_Control_PlayFunction = 0x60, CEC_User_Control_PausePlayFunction = 0x61, CEC_User_Control_RecordFunction = 0x62, CEC_User_Control_PauseRecordFunction = 0x63, CEC_User_Control_StopFunction = 0x64, CEC_User_Control_MuteFunction = 0x65, CEC_User_Control_RestoreVolumeFunction = 0x66, CEC_User_Control_TuneFunction = 0x67, CEC_User_Control_SelectDiskFunction = 0x68, CEC_User_Control_SelectAVInputFunction = 0x69, CEC_User_Control_SelectAudioInputFunction = 0x6A, CEC_User_Control_F1Blue = 0x71, CEC_User_Control_F2Red = 0x72, CEC_User_Control_F3Green = 0x73, CEC_User_Control_F4Yellow = 0x74, CEC_User_Control_F5 = 0x75 } CEC_USER_CONTROL_T; /** *CEC topology struct * * Meaning of device_attr is as follows (one per active logical device) * bit 3-0 logical address (see CEC_AllDevices_T above) * bit 7-4 device type (see CEC_DEVICE_TYPE_T above) * bit 11-8 index to upstream device * bit 15-12 number of downstream device * bit 31-16 index of first 4 downstream devices * * To keep life simple we only show the first 4 connected downstream devices * */ typedef struct { uint16_t active_mask; /** */ VC_CEC_BUTTON_RELEASE = (1 << 3), /**< */ VC_CEC_REMOTE_PRESSED = (1 << 4), /**< */ VC_CEC_REMOTE_RELEASE = (1 << 5), /**< */ VC_CEC_LOGICAL_ADDR = (1 << 6), /** and messages respectively) * returns the code from the most recent respectively. * The host application will need to find out the vendor ID of the initiator * separately in the case if / commands were received. * will not be longer than 6 bytes (including header) * * VC_CEC_LOGICAL_ADDR returns 0xF in param1 whenever no logical address is in used. If physical address is 0xFFFF, * this means CEC is being disabled. Otherwise physical address is the one read from EDID (and no suitable logical address * is avaiable to be allocated). Host application should only attempt to send message if both param1 is not 0xF AND param2 * is not 0xFFFF. * * VC_CEC_TOPOLOGY returns a 16-bit mask in param1 where bit n is set if logical address n is present. Host application * must explicitly retrieve the entire topology if it wants to know how devices are connected. The bit mask includes our * own logical address. * * If CEC is running in passive mode, the host will get a VC_CEC_LOGICAL_ADDR_LOST callback if the logical address is * lost (e.g. HDMI mode change). In this case the host should try a new logical address. The physical address returned may * also change, so the host should check this. */ /** * General callback function for notifications from CEC middleware (and CEC service) * * @param client_p is the callback context passed in by user * * @param reason is the notification nature (plus message lengths, return code, etc.) * * @param param1 is the first parameter of notification (see above) * * @param param2 is the second parameter of notification (see above) * * @param param3 is the third parameter of notification (see above) * * @param param4 is the fourth parameter of notification (see above) * * @return void */ typedef void (*CEC_CALLBACK_T)(void *client_p, uint32_t reason, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4); /** * Some macros to get some fields from the callback parameters in CEC callback */ //Marcos operating on reason #define CEC_CB_REASON(x) ((x) & 0xFFFF) /** Get callback reason */ #define CEC_CB_MSG_LENGTH(x) (((x) >> 16) & 0xFF) /** Get callback parameter length (this includes the header byte) */ #define CEC_CB_RC(x) (((x) >> 24) & 0xFF) /** Get return value (only for TX callbacks for the moment) */ //Macros operating on param1 #define CEC_CB_INITIATOR(x) (((x) >> 4) & 0xF) /** Get the initiator from first parameter */ #define CEC_CB_FOLLOWER(x) ((x) & 0xF) /** Get the follower from first parameter */ #define CEC_CB_OPCODE(x) (((x) >> 8) & 0xFF) /** Get the opcode from first parameter */ #define CEC_CB_OPERAND1(x) (((x) >> 16) & 0xFF) /** Get the button code from or the first operand of the opcode */ #define CEC_CB_OPERAND2(x) (((x) >> 24) & 0xFF) /** Get the second operand of opcode */ //CEC service return code typedef enum { VC_CEC_SUCCESS = 0, /** OK */ VC_CEC_ERROR_NO_ACK = 1, /** No acknowledgement */ VC_CEC_ERROR_SHUTDOWN = 2, /** In the process of shutting down */ VC_CEC_ERROR_BUSY = 3, /** block is busy */ VC_CEC_ERROR_NO_LA = 4, /** No logical address */ VC_CEC_ERROR_NO_PA = 5, /** No physical address */ VC_CEC_ERROR_NO_TOPO = 6, /** No topology */ VC_CEC_ERROR_INVALID_FOLLOWER = 7, /** Invalid follower */ VC_CEC_ERROR_INVALID_ARGUMENT = 8 /** Invalid arguments */ } VC_CEC_ERROR_T; #endif