RDK Documentation (Open Sourced RDK Components)
Host.hpp
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 /**
22 * @defgroup hdmicec
23 * @{
24 * @defgroup ccec
25 * @{
26 **/
27 
28 
29 #ifndef HDMI_CCECHOST_HPP_
30 #define HDMI_CCECHOST_HPP_
31 
32 #include <stddef.h>
33 #include <stdint.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * Host Plugin must implement the following.
41  */
42 
43 typedef enum {
44  CECHost_ERR_GENERAL = -1,
45  CECHost_ERR_NONE,
46  CECHost_ERR_INVALID,
47  CECHost_ERR_SYMBOL,
48  CECHost_ERR_HOST,
49  CECHost_ERR_STATE,
50 } CECHost_Err_t;
51 
52 #define CECHost_HDMI_CONNECTED 0
53 #define CECHost_HDMI_DISCONNECTED 1
54 
55 #define CECHost_POWERSTATE_ON 0
56 #define CECHost_POWERSTATE_STANDBY 1
57 
58 typedef struct _CECHost_Policy_t {
59  int32_t turnOffTv;
60  int32_t turnOffSTB;
62 
63 typedef enum _CECHost_DeviceStatusType_t{
64  CECHost_POWER_STATUS = 1,
65  CECHost_OSD_NAME = 2,
66  CECHost_CONNECTED_STATUS =3
67 }CECHost_DeviceStatusType_t;
68 
70 {
71  CECHost_DeviceStatusType_t statusType;
72  union{
73  int powerState;
74  int isConnected;
75  char osdName[14+1];
76  }data;
78 
79 /*
80  * The following are a set of callbacks that the host module
81  * use to notify CEC about its state change.
82  */
83 
84 typedef CECHost_Err_t (*CECHost_HdmiHotplugCallback_t) (int32_t connect);
85 typedef CECHost_Err_t (*CECHost_PowerStateCallback_t) (int32_t curState, int32_t newState);
86 typedef CECHost_Err_t (*CECHost_DevMgrStatusCallback_t) (bool ipStatus,bool* opStatus);
87 /*
88  * Description: Notify CEC of the latest OSD name.
89  *
90  * The 'name' need not be null terminated. if it is, the 'len' does
91  * not include the 'null' termintator.
92  *
93  * @param name: the ASCII bytes of the OSD name.
94  * @param len: the number of ASCII bytes.
95  */
96 typedef CECHost_Err_t (*CECHost_OSDNameCallback_t) (uint8_t *name, size_t len);
97 typedef CECHost_Err_t (*CECHost_PolicyCallback_t) (CECHost_Policy_t policy);
98 
99 /*
100  * A Set of callback to notify CEC that the host state has changed.
101  */
102 typedef struct _CECHost_Callback_t {
103  CECHost_HdmiHotplugCallback_t hotplugCb;
104  CECHost_PowerStateCallback_t pwrStateCb;
105  CECHost_DevMgrStatusCallback_t devMgrStatusCb;
106  CECHost_OSDNameCallback_t osdCb;
107  CECHost_PolicyCallback_t policyCb;
109 
110 CECHost_Err_t CECHost_Init(const char *name);
111 CECHost_Err_t CECHost_Term(void);
112 
113 CECHost_Err_t CECHost_SetCallback(CECHost_Callback_t cb);
114 
115 /* HDMI */
116 CECHost_Err_t CECHost_GetHdmiOuputPhysicalAddress(uint8_t *byte0, uint8_t *byte1, uint8_t *byte2, uint8_t *byte3);
117 CECHost_Err_t CECHost_IsHdmiOutputConnected(int32_t *connect);
118 
119 /* Power */
120 CECHost_Err_t CECHost_GetPowerState(int32_t *state);
121 CECHost_Err_t CECHost_SetPowerState(int32_t state);
122 
123 /* Device Status */
124 CECHost_Err_t CECHost_SetDeviceStatus(int logicalAddress, CECHost_DeviceStatus_t *deviceStatus);
125 
126 /* CEC Control */
127 
128 /*
129  * Description: Get the OSD name from Host module.
130  *
131  * The 'name' need not be null terminated. if it is, the 'len' does
132  * not include the 'null' termintator.
133  *
134  * @param name: the ASCII bytes of the OSD name.
135  * @param len: the number of ASCII bytes.
136  */
137 
138 CECHost_Err_t CECHost_GetOSDName(uint8_t *name, size_t *len);
139 CECHost_Err_t CECHost_GetPolicy(CECHost_Policy_t *policy);
140 
141 
142 /*
143  * If box is an active source is different from its power state.
144  * I.e. a PowerOn STB in lightsleep may not claim to be an
145  * active source.
146  *
147  * STANDBY implies Inactive
148  * ON does not imply Active
149  * Active imples ON
150  * Inactive does not imply STANDBY
151  *
152  */
153 CECHost_Err_t CECHost_IsActive(int32_t *active);
154 
155 
156 /*
157  * Host Plugin Need not implement these two APIs.
158  */
159 CECHost_Err_t CECHost_LoadPlugin(void);
160 CECHost_Err_t CECHost_UnloadPlugin(void);
161 
162 
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif
169 
170 
171 /** @} */
172 /** @} */
CECHost_GetPowerState
CECHost_Err_t CECHost_GetPowerState(int32_t *state)
This function is used to get the state of power whether it is ON or in STANDBY state.
Definition: Host.cpp:174
CECHost_IsActive
CECHost_Err_t CECHost_IsActive(int32_t *active)
This function is used to check whether host device is active or not.
Definition: Host.cpp:231
CECHost_IsHdmiOutputConnected
CECHost_Err_t CECHost_IsHdmiOutputConnected(int32_t *connect)
This function is used to check whether the HDMI output is connected or not.
Definition: Host.cpp:159
CECHost_SetDeviceStatus
CECHost_Err_t CECHost_SetDeviceStatus(int logicalAddress, CECHost_DeviceStatus_t *deviceStatus)
This function is used to set and update the device status like power status, logical address,...
Definition: Host.cpp:188
CECHost_GetHdmiOuputPhysicalAddress
CECHost_Err_t CECHost_GetHdmiOuputPhysicalAddress(uint8_t *byte0, uint8_t *byte1, uint8_t *byte2, uint8_t *byte3)
This function is used to get the physical address of the HDMI output port byte by byte.
Definition: Host.cpp:144
CECHost_Term
CECHost_Err_t CECHost_Term(void)
This function is used to de-initialize CEC host device, disconnects and terminates the CEC connection...
Definition: Host.cpp:116
CECHost_SetCallback
CECHost_Err_t CECHost_SetCallback(CECHost_Callback_t cb)
This function is used to set the callback function. It is called by Device Manager application to set...
Definition: Host.cpp:130
CECHost_GetOSDName
CECHost_Err_t CECHost_GetOSDName(uint8_t *name, size_t *len)
This function is used to get OSD name of Host module. Here 'buf' need not to be null terminated....
Definition: Host.cpp:216
CECHost_Init
CECHost_Err_t CECHost_Init(const char *name)
This function is used to initialize CEC host device by registering event handlers and calls like stat...
Definition: Host.cpp:101
CECHost_SetPowerState
CECHost_Err_t CECHost_SetPowerState(int32_t state)
This function is used to set the device power state to be ON or STANDBY.
Definition: Host.cpp:201
_CECHost_Callback_t
Definition: Host.hpp:102
_CECHost_Policy_t
Definition: Host.hpp:58
_CECHost_DeviceStatus_t
Definition: Host.hpp:69