RDK Documentation (Open Sourced RDK Components)
irMgr.h
Go to the documentation of this file.
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 * @file irMgr.h
22 *
23 * @brief IARM-Bus IR Manager API.
24 *
25  * This API defines the structures and functions for the
26  * IARM-Bus IR Manager interface.
27 *
28 * @par Document
29 * Document reference.is
30 *
31 * @par Open Issues (in no particular order)
32 * -# None
33 *
34 * @par Assumptions
35 * -# None
36 *
37 * @par Abbreviations
38 * - BE: ig-Endian.
39 * - cb: allback function (suffix).
40 * - DS: Device Settings.
41 * - FPD: Front-Panel Display.
42 * - HAL: Hardware Abstraction Layer.
43 * - LE: Little-Endian.
44 * - LS: Least Significant.
45 * - MBZ: Must be zero.
46 * - MS: Most Significant.
47 * - RDK: Reference Design Kit.
48 * - _t: Type (suffix).
49 *
50 * @par Implementation Notes
51 * -# None
52 *
53 */
54 
55 /**
56  * @defgroup IARM_MGR IARM Manager
57  * IARM (Inter Application Resource Management) is a mechanism for interprocess communication
58  * among different RDK applications. Its a platform agnostic inter process
59  * communication (IPC) mechanism for the other RDK components. The inter communication is
60  * possible between IARM application using events and RPC method.
61  *
62  * @image html iarm.png
63  *
64  * Basically there are three IARM entities involved for development
65  * <ol>
66  * <li> IARM Bus
67  * <li> IARM Application (Consumers/Listeners)
68  * <li> IARM Manager (Publishers)
69  * </ol>
70  *
71  * @par IARM Bus
72  * - Invoke methods in other processes via Remote Procedure Call.
73  * - Send inter-process messages.
74  * - Manage shared and exclusive access to resources.
75  * - Register for event notification.
76  * - Publish Event notification to registered listener.
77  * - There are two ways for application to use IARM Bus is 'Subscribe for system events' and 'Invoke RPC Methods'
78  *
79  * @par IARM Application
80  * - IARM Application utilize the IARM utilities and it register for event notification.
81  * - For example, IR Application registering for the events and the same event appears
82  * in the IARM Bus. So that the notification of the IARM Bus event shall be transfer
83  * to the IARM Bus application.
84  * - IARM application can also invoke the RPC method which has been registered by the other IARM process.
85  *
86  * @par IARM Manager
87  * - IARM Manager is an IARM Application that runs as Linux daemon process.
88  * - The IARM Bus Daemon is a Manager Component with Special privileges to manage resources.
89  * - The Other IARM Manager components include Power Manager, IR Manager, Disk Manager, Sys Manager, DS Manager, etc
90  *
91  * @par IARM Publisher and Listeners Concept
92  * @image html iarm-publisher.png
93  *
94  * @defgroup IARM_MGR_RPC Events and Remote Procedure Calls
95  * IARM-Bus is a platform agnostic Inter-process communication (IPC) interface. It allows
96  * applications to communicate with each other by sending Events or invoking Remote
97  * Procedure Calls. The common programming APIs offered by the RDK IARM-Bus interface is
98  * independent of the operating system or the underlying IPC mechanism.
99  *
100  * Two applications connected to the same instance of IARM-Bus are able to exchange events
101  * or RPC calls. On a typical system, only one instance of IARM-Bus instance is needed. If
102  * desired, it is possible to have multiple IARM-Bus instances. However, applications
103  * connected to different buses will not be able to communicate with each other.
104  * @ingroup IARM_MGR
105  */
106 
107 /**
108  * @defgroup IARMBUS_IR_MGR IR Manager
109  * @ingroup IARM_MGR_RPC
110  *
111  * IR Manager is an application that publishes Remote Key events to other applications.
112  * This manager receives IR signals from driver and dispatch it to all registered listeners on IARM Bus.
113  * IR manager sends these IR events to other applications.
114  *
115  * @par IR Manager: Events
116  *
117  * - @b IARM_BUS_IRMGR_EVENT_IRKEY
118  * @n The Event Data contains Key Code and Key Type of the pressed IR key.
119  * This enum is used to notify IR Key events.
120  * @n Example:
121  * @code
122  * IARM_Bus_IRMgr_EventData_t eventData;
123  * eventData.data.irkey.keyType = KET_KEYUP;
124  * eventData.data.irkey.keyCode = prevEventData.data.irkey.keyCode;
125  * IARM_Bus_BroadcastEvent(IARM_BUS_IRMGR_NAME, (IARM_EventId_t)IARM_BUS_IRMGR_EVENT_IRKEY,
126  * (void *)&eventData, sizeof(eventData));
127  * @endcode
128  * @n
129  * - @b IARM_BUS_RF4CEMGR_EVENT_KEY
130  * @n The RF4CE fetches the user key and that will pass to UEI's quickset application, that will then fetch the
131  * requested TV's IR codeset. UEI's fetch mechanism can be local or non local (Cloud based). Once the requested
132  * TV IR codeset has been retrieved , it will then be programmed into the remote via API calls.
133  * Ultimately, this will allow the XR device to control the following keys on a given TV. It support for the various
134  * keys such as OK, TV input, Volume UP, Volume Down, Mute Toggle power, Discrete Power ON, Discrete Power OFF, and so on.
135  * @code
136  * IARM_Bus_RegisterEventHandler(IARM_BUS_RF4CEMGR_NAME, IARM_BUS_RF4CEMGR_EVENT_KEY, _rf4ceEventHandler); //Register Callback func
137  * void _rf4ceEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len); //Function prototype
138  * @endcode
139  *
140  * @par IR Manager: RPC Methods
141  *
142  * IR manager publishes two RPC Methods such as <b>SetRepeatKeyInterval</b> and <b>GetRepeatKeyInterval</b>.
143  * Other application can invoke these methods to determine how often a repeat key is sent when the IR key is
144  * held own by the user.
145  * @n @n
146  * - @b IARM_BUS_IRMGR_API_SetRepeatInterval
147  * @n This API is used to set the repeat key event interval.
148  * @n Example:
149  * @code
150  * IARM_Bus_IRMgr_SetRepeatInterval_Param_t param;
151  * param. timeout = 200; //200 milisec
152  * IARM_Bus_Call(IARM_BUS_IRMGR_NAME, IARM_BUS_IRMGR_API_SetRepeatInterval,
153  * (void *)&param, siizeof(param));
154  * @endcode
155  * @n @n
156  * - @b IARM_BUS_IRMGR_API_GetRepeatInterval
157  * @n This is used to retrieves the current key repeat interval.
158  * @n Example:
159  * @code
160  * IARM_Bus_IRMgr_SetRepeatInterval_Param_t param;
161  * IARM_Bus_Call (IARM_BUS_IRMGR_NAME, IARM_BUS_IRMGR_API_GetRepeatInterval, \
162  * (void *)&param, sizeof(param));
163  * @endcode
164  *
165  * @par How to register callback function with HAL to receive the IR keys
166  * This function must initialize all the IR specific user input device modules.
167  * @code
168  * PLAT_API_RegisterIRKeyCallback(PLAT_IrKeyCallback_t func);
169  * @endcode
170  *
171  * @par Callback prototype
172  * The event data contains Key type and Key code of the pressed IR Key.
173  * @code
174  * typedef void (*PLAT_IrKeyCallback_t)(int keyType, int keyCode);
175  * @endcode
176  *
177  */
178 
179 
180 /**
181 * @defgroup iarmmgrs
182 * @{
183 * @defgroup ir
184 * @{
185 **/
186 
187 /** @addtogroup IARM_BUS_IRMGR_API IARM-Bus IR Manager API.
188  * @ingroup IARM_BUS
189  *
190  * Described herein are the IARM-Bus types and functions that are part of the IR
191  * Manager application. The IR Manager application manages user input.
192  *
193  * @{
194  */
195 
196 
197 
198 
199 /**
200 * @defgroup iarmmgrs
201 * @{
202 * @defgroup ir
203 * @{
204 **/
205 
206 
207 #ifndef _IARM_BUS_IRMGR_H
208 #define _IARM_BUS_IRMGR_H
209 
210 #include "libIARM.h"
211 
212 #ifdef __cplusplus
213 extern "C"
214 {
215 #endif
216 #define IARM_BUS_IRMGR_NAME "IRMgr" /*!< IR Manager IARM -bus name */
217 
218 /*! Events published from IR Mananger */
219 typedef enum _IRMgr_EventId_t {
220  IARM_BUS_IRMGR_EVENT_IRKEY, /*!< Key Event */
221  IARM_BUS_IRMGR_EVENT_CONTROL,
222  IARM_BUS_IRMGR_EVENT_MAX, /*!< Maximum event id*/
224 
225 
226 /*! Possible IR Manager Key Source */
227 typedef enum _IRMgr_KeySrc_t {
228  IARM_BUS_IRMGR_KEYSRC_FP, /*!< Key Source FP */
229  IARM_BUS_IRMGR_KEYSRC_IR, /*!< Key Source IR */
230  IARM_BUS_IRMGR_KEYSRC_RF, /*!< Key Source RF */
232 
233 
234 /*! Key Event Data */
235 typedef struct _IRMgr_EventData_t {
236  union {
237  struct _IRKEY_DATA{
238  /* Declare Event Data structure for IRMGR_EVENT_DUMMY0 */
239  int keyType; /*!< Key type (UP/DOWN/REPEAT) */
240  int keyCode; /*!< Key code */
241  int keyTag; /*!< key tag (identifies which remote) */
242  int keyOwner; /*!< key owner (normal or pairing op) */
243  int isFP; /*!< Key Source -- Remote/FP - TBD - Need to be removed after changing MPEOS*/
244  IARM_Bus_IRMgr_KeySrc_t keySrc; /*!< Key Source -- FP,IR,Remote */
245  unsigned int keySourceId;
246  } irkey, fpkey;
247  } data;
249 
250 /*
251  * Declare RPC API names and their arguments
252  */
253 #define IARM_BUS_IRMGR_API_SetRepeatInterval "SetRepeatInterval" /*!< Set the repeat key event interval*/
254 
255 /*! Declare Argument Data structure for SetRepeatInterval */
257 
258  unsigned int timeout; /*!< Repeat key interval timeout*/
260 
261 #define IARM_BUS_IRMGR_API_GetRepeatInterval "GetRepeatInterval" /*!< Retrives the current repeat interval*/
262 
263 /*! Declare Argument Data structure for GetRepeatInterval */
265  unsigned int timeout; /*!< Repeat key interval timeout value retrived*/
267 
268 #ifdef __cplusplus
269 }
270 #endif
271 #endif
272 
273 /* End of IARM_BUS_IRMGR_API doxygen group */
274 /**
275  * @}
276  */
277 
278 
279 /** @} */
280 /** @} */
IARM_Bus_IRMgr_KeySrc_t
enum _IRMgr_KeySrc_t IARM_Bus_IRMgr_KeySrc_t
IARM_BUS_IRMGR_EVENT_IRKEY
@ IARM_BUS_IRMGR_EVENT_IRKEY
Definition: irMgr.h:220
IARM_BUS_IRMGR_KEYSRC_RF
@ IARM_BUS_IRMGR_KEYSRC_RF
Definition: irMgr.h:230
_IARM_Bus_IRMgr_GetRepeatInterval_Param_t
Definition: irMgr.h:264
IARM_BUS_IRMGR_EVENT_MAX
@ IARM_BUS_IRMGR_EVENT_MAX
Definition: irMgr.h:222
IARM_BUS_IRMGR_KEYSRC_FP
@ IARM_BUS_IRMGR_KEYSRC_FP
Definition: irMgr.h:228
_IARM_Bus_IRMgr_SetRepeatInterval_Param_t
Definition: irMgr.h:256
_IRMgr_EventId_t
_IRMgr_EventId_t
Definition: irMgr.h:219
_IRMgr_EventData_t::@3::_IRKEY_DATA::keyTag
int keyTag
Definition: irMgr.h:241
_IRMgr_EventData_t::@3::_IRKEY_DATA::keyType
int keyType
Definition: irMgr.h:239
_IARM_Bus_IRMgr_GetRepeatInterval_Param_t::timeout
unsigned int timeout
Definition: irMgr.h:265
_IRMgr_EventData_t::@3::_IRKEY_DATA::keySrc
IARM_Bus_IRMgr_KeySrc_t keySrc
Definition: irMgr.h:244
_IARM_Bus_IRMgr_SetRepeatInterval_Param_t::timeout
unsigned int timeout
Definition: irMgr.h:258
IARM_BUS_IRMGR_KEYSRC_IR
@ IARM_BUS_IRMGR_KEYSRC_IR
Definition: irMgr.h:229
_IRMgr_EventData_t::@3::_IRKEY_DATA::keyOwner
int keyOwner
Definition: irMgr.h:242
_IRMgr_KeySrc_t
_IRMgr_KeySrc_t
Definition: irMgr.h:227
IARM_Bus_IRMgr_SetRepeatInterval_Param_t
struct _IARM_Bus_IRMgr_SetRepeatInterval_Param_t IARM_Bus_IRMgr_SetRepeatInterval_Param_t
_IRMgr_EventData_t
Definition: irMgr.h:235
_IRMgr_EventData_t::@3::_IRKEY_DATA::isFP
int isFP
Definition: irMgr.h:243
IARM_Bus_IRMgr_EventData_t
struct _IRMgr_EventData_t IARM_Bus_IRMgr_EventData_t
IARM_Bus_IRMgr_EventId_t
enum _IRMgr_EventId_t IARM_Bus_IRMgr_EventId_t
IARM_Bus_IRMgr_GetRepeatInterval_Param_t
struct _IARM_Bus_IRMgr_GetRepeatInterval_Param_t IARM_Bus_IRMgr_GetRepeatInterval_Param_t
_IRMgr_EventData_t::@3::_IRKEY_DATA::keyCode
int keyCode
Definition: irMgr.h:240