| 1 | /*************************************************************************** |
|---|
| 2 | * (c)2007-2011 Broadcom Corporation |
|---|
| 3 | * |
|---|
| 4 | * This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | * and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | * conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | * no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | * Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | * |
|---|
| 14 | * Except as expressly set forth in the Authorized License, |
|---|
| 15 | * |
|---|
| 16 | * 1. This program, including its structure, sequence and organization, constitutes the valuable trade |
|---|
| 17 | * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, |
|---|
| 18 | * and to use this information only in connection with your use of Broadcom integrated circuit products. |
|---|
| 19 | * |
|---|
| 20 | * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
|---|
| 21 | * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
|---|
| 22 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO |
|---|
| 23 | * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES |
|---|
| 24 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, |
|---|
| 25 | * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION |
|---|
| 26 | * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF |
|---|
| 27 | * USE OR PERFORMANCE OF THE SOFTWARE. |
|---|
| 28 | * |
|---|
| 29 | * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS |
|---|
| 30 | * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR |
|---|
| 31 | * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR |
|---|
| 32 | * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF |
|---|
| 33 | * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT |
|---|
| 34 | * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE |
|---|
| 35 | * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF |
|---|
| 36 | * ANY LIMITED REMEDY. |
|---|
| 37 | * |
|---|
| 38 | * $brcm_Workfile: nexus_cec.h $ |
|---|
| 39 | * $brcm_Revision: SW7405-4781/1 $ |
|---|
| 40 | * $brcm_Date: 12/21/11 12:12p $ |
|---|
| 41 | * |
|---|
| 42 | * Module Description: |
|---|
| 43 | * |
|---|
| 44 | * Revision History: |
|---|
| 45 | * |
|---|
| 46 | * $brcm_Log: /nexus/modules/cec/7425/include/nexus_cec.h $ |
|---|
| 47 | * |
|---|
| 48 | * SW7405-4781/1 12/21/11 12:12p vle |
|---|
| 49 | * SW7405-4781: allow CEC device type to be configurable |
|---|
| 50 | * |
|---|
| 51 | * 1 12/15/11 4:27p vsilyaev |
|---|
| 52 | * SW7425-1140: Merge NEXUS_Cec module support into main-line |
|---|
| 53 | * |
|---|
| 54 | * SW7425-1140/1 12/9/11 4:40p vle |
|---|
| 55 | * SW7425-1140: Add NEXUS_Cec module support |
|---|
| 56 | * |
|---|
| 57 | ***************************************************************************/ |
|---|
| 58 | |
|---|
| 59 | #ifndef NEXUS_CEC_H__ |
|---|
| 60 | #define NEXUS_CEC_H__ |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | #ifdef __cplusplus |
|---|
| 64 | extern "C" { |
|---|
| 65 | #endif |
|---|
| 66 | |
|---|
| 67 | #define NEXUS_CEC_MESSAGE_DATA_SIZE 16 |
|---|
| 68 | |
|---|
| 69 | /** |
|---|
| 70 | Summary: |
|---|
| 71 | Handle for the CEC interface. |
|---|
| 72 | **/ |
|---|
| 73 | typedef struct NEXUS_Cec *NEXUS_CecHandle; |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | /** |
|---|
| 77 | Summary: |
|---|
| 78 | Enumeration indicate the device type |
|---|
| 79 | **/ |
|---|
| 80 | typedef enum NEXUS_CecDeviceType |
|---|
| 81 | { |
|---|
| 82 | NEXUS_CecDeviceType_eTv = 0, |
|---|
| 83 | NEXUS_CecDeviceType_eRecordingDevice, |
|---|
| 84 | NEXUS_CecDeviceType_eReserved, |
|---|
| 85 | NEXUS_CecDeviceType_eTuner, |
|---|
| 86 | NEXUS_CecDeviceType_ePlaybackDevice, |
|---|
| 87 | NEXUS_CecDeviceType_eAudioSystem, |
|---|
| 88 | NEXUS_CecDeviceType_ePureCecSwitch, |
|---|
| 89 | NEXUS_CecDeviceType_eVideoProcessor, |
|---|
| 90 | NEXUS_CecDeviceType_eMax |
|---|
| 91 | } NEXUS_CecDeviceType; |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | /** |
|---|
| 95 | Summary: |
|---|
| 96 | CEC settings |
|---|
| 97 | **/ |
|---|
| 98 | typedef struct NEXUS_CecSettings |
|---|
| 99 | { |
|---|
| 100 | bool enabled; /* enable the CEC core */ |
|---|
| 101 | NEXUS_CallbackDesc messageTransmittedCallback; |
|---|
| 102 | NEXUS_CallbackDesc messageReceivedCallback; |
|---|
| 103 | NEXUS_CallbackDesc logicalAddressAcquiredCallback; |
|---|
| 104 | uint8_t physicalAddress[2]; /* device physical address: read from attached EDID */ |
|---|
| 105 | NEXUS_CecDeviceType deviceType; |
|---|
| 106 | } NEXUS_CecSettings; |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | /** |
|---|
| 110 | Summary: |
|---|
| 111 | Get default CEC settings |
|---|
| 112 | **/ |
|---|
| 113 | void NEXUS_Cec_GetDefaultSettings( |
|---|
| 114 | NEXUS_CecSettings *pSettings /* [out] */ |
|---|
| 115 | ); |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | /** |
|---|
| 119 | Summary: |
|---|
| 120 | Open a CEC interface |
|---|
| 121 | **/ |
|---|
| 122 | NEXUS_CecHandle NEXUS_Cec_Open( /* attr{destructor=NEXUS_Cec_Close} */ |
|---|
| 123 | unsigned index, |
|---|
| 124 | const NEXUS_CecSettings *pSettings |
|---|
| 125 | ); |
|---|
| 126 | |
|---|
| 127 | /** |
|---|
| 128 | Summary: |
|---|
| 129 | Close the Cec interface |
|---|
| 130 | **/ |
|---|
| 131 | void NEXUS_Cec_Close( |
|---|
| 132 | NEXUS_CecHandle handle |
|---|
| 133 | ); |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | /** |
|---|
| 137 | Summary: |
|---|
| 138 | Get current CEC settings |
|---|
| 139 | **/ |
|---|
| 140 | void NEXUS_Cec_GetSettings( |
|---|
| 141 | NEXUS_CecHandle handle, |
|---|
| 142 | NEXUS_CecSettings *pSettings /* [out] */ |
|---|
| 143 | ); |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | /** |
|---|
| 147 | Summary: |
|---|
| 148 | Set new CEC settings |
|---|
| 149 | |
|---|
| 150 | Description: |
|---|
| 151 | This function is expected to call this with a new physicalAddress after a hotplug occurred on the HDMI interface. |
|---|
| 152 | CEC interface will then re-initialize after a hotplug. |
|---|
| 153 | |
|---|
| 154 | Consult the HDMI spec for more details. |
|---|
| 155 | **/ |
|---|
| 156 | NEXUS_Error NEXUS_Cec_SetSettings( |
|---|
| 157 | NEXUS_CecHandle handle, |
|---|
| 158 | const NEXUS_CecSettings *pSettings |
|---|
| 159 | ); |
|---|
| 160 | |
|---|
| 161 | |
|---|
| 162 | /** |
|---|
| 163 | Summary: |
|---|
| 164 | Status returned by NEXUS_Cec_GetStatus |
|---|
| 165 | **/ |
|---|
| 166 | typedef struct NEXUS_CecStatus |
|---|
| 167 | { |
|---|
| 168 | bool ready; /* device is ready */ |
|---|
| 169 | |
|---|
| 170 | uint8_t physicalAddress[2]; |
|---|
| 171 | uint8_t logicalAddress; /* Until logical address is obtained by Nexus, the CEC Send/Receive functions cannot be used. |
|---|
| 172 | 0xFF means no address. */ |
|---|
| 173 | NEXUS_CecDeviceType deviceType; |
|---|
| 174 | |
|---|
| 175 | bool messageReceived; /* If true, call NEXUS_Cec_ReceiveMessage to receive a message. */ |
|---|
| 176 | bool messageTransmitPending; /* If true, you must wait before calling NEXUS_Cec_TransmitMessage again. */ |
|---|
| 177 | |
|---|
| 178 | bool transmitMessageAcknowledged; /* status from last transmitted message */ |
|---|
| 179 | |
|---|
| 180 | } NEXUS_CecStatus; |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | /** |
|---|
| 184 | Summary: |
|---|
| 185 | Get CEC status |
|---|
| 186 | **/ |
|---|
| 187 | NEXUS_Error NEXUS_Cec_GetStatus( |
|---|
| 188 | NEXUS_CecHandle handle, |
|---|
| 189 | NEXUS_CecStatus *pStatus /* [out] */ |
|---|
| 190 | ); |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | /** |
|---|
| 194 | Summary: |
|---|
| 195 | Holds data of CEC message to be transmitted or received message |
|---|
| 196 | **/ |
|---|
| 197 | typedef struct NEXUS_CecMessage |
|---|
| 198 | { |
|---|
| 199 | uint8_t initiatorAddr; |
|---|
| 200 | uint8_t destinationAddr; |
|---|
| 201 | uint8_t buffer[NEXUS_CEC_MESSAGE_DATA_SIZE]; |
|---|
| 202 | unsigned length; |
|---|
| 203 | } NEXUS_CecMessage; |
|---|
| 204 | |
|---|
| 205 | |
|---|
| 206 | typedef struct NEXUS_CecReceivedMessage |
|---|
| 207 | { |
|---|
| 208 | struct { |
|---|
| 209 | bool receivedMessageAcknowledged; /* HW has acknowledged received message */ |
|---|
| 210 | bool endOfMessage; |
|---|
| 211 | } receivedStatus; |
|---|
| 212 | |
|---|
| 213 | NEXUS_CecMessage data; |
|---|
| 214 | } NEXUS_CecReceivedMessage; |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | /** |
|---|
| 218 | Summary: |
|---|
| 219 | Get a CEC message that was received |
|---|
| 220 | |
|---|
| 221 | Description: |
|---|
| 222 | You can only have one message pending at a time. |
|---|
| 223 | Fails if no message was received. |
|---|
| 224 | |
|---|
| 225 | Consult the HDMI spec for the contents of the CEC message. |
|---|
| 226 | |
|---|
| 227 | **/ |
|---|
| 228 | NEXUS_Error NEXUS_Cec_ReceiveMessage( |
|---|
| 229 | NEXUS_CecHandle handle, |
|---|
| 230 | NEXUS_CecReceivedMessage *pReceivedMessage /* [out] */ |
|---|
| 231 | ); |
|---|
| 232 | |
|---|
| 233 | |
|---|
| 234 | /** |
|---|
| 235 | Summary: |
|---|
| 236 | Get defaults for the structure before populating it for transmission |
|---|
| 237 | **/ |
|---|
| 238 | void NEXUS_Cec_GetDefaultMessageData( |
|---|
| 239 | NEXUS_CecMessage *pMessage /* [out] */ |
|---|
| 240 | ); |
|---|
| 241 | |
|---|
| 242 | |
|---|
| 243 | /** |
|---|
| 244 | Summary: |
|---|
| 245 | Transmit CEC message |
|---|
| 246 | |
|---|
| 247 | Description: |
|---|
| 248 | This function will fail if a previous NEXUS_Cec_TransmitMessage has not completed. |
|---|
| 249 | Wait for messageTransmitted callback and/or check NEXUS_CecStatus.messageTransmitPending. |
|---|
| 250 | |
|---|
| 251 | Consult the HDMI spec for the contents of the CEC message. |
|---|
| 252 | **/ |
|---|
| 253 | NEXUS_Error NEXUS_Cec_TransmitMessage( |
|---|
| 254 | NEXUS_CecHandle handle, |
|---|
| 255 | const NEXUS_CecMessage *pMessage |
|---|
| 256 | ); |
|---|
| 257 | |
|---|
| 258 | |
|---|
| 259 | #ifdef __cplusplus |
|---|
| 260 | } |
|---|
| 261 | #endif |
|---|
| 262 | |
|---|
| 263 | #endif |
|---|
| 264 | |
|---|
| 265 | |
|---|
| 266 | |
|---|