2 * Copyright © 2010-2011 Intel Corporation
3 * Copyright © 2008-2011 Kristian Høgsberg
4 * Copyright © 2013 TOYOTA MOTOR CORPORATION.
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of the copyright holders not be used in
11 * advertising or publicity pertaining to distribution of the software
12 * without specific, written prior permission. The copyright holders make
13 * no representations about the suitability of this software for any
14 * purpose. It is provided "as is" without express or implied warranty.
16 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
21 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 * @brief Weston(Wayland) Plugin: IVI Common Functions.
39 #include <weston/compositor.h>
40 #include "ico_ivi_common.h"
42 /* IVI Plugin Common Table */
43 struct ico_ivi_common {
44 int32_t myNodeId; /* (HostId << 16) | DisplayNo */
45 int (*usurf_2_node)(const int surfaceid);
46 /* Function address of nodeId from surfaceId*/
47 int (*send_to_mgr)(const int event, const int surfaceid, const char *appid,
48 const int param1, const int param2, const int param3,
49 const int param4, const int param5, const int param6);
50 /* Function address of send to manager */
51 int (*send_surface_change)(struct weston_surface *surface,
52 const int x, const int y, const int width, const int height);
53 /* Function address of send configure to manager*/
56 /* This function is called from the ico_plugin-loader and initializes this module.*/
57 int module_init(struct weston_compositor *ec);
59 /* Static area for control ico_ivi_common */
60 static struct ico_ivi_common *_ico_ivi_common = NULL;
63 static int _ico_option_flag = 0;
66 static int _ico_ivi_debug = 3;
68 static const struct config_key debug_config_keys[] = {
69 { "option_flag", CONFIG_KEY_INTEGER, &_ico_option_flag },
70 { "ivi_debug", CONFIG_KEY_INTEGER, &_ico_ivi_debug },
73 static const struct config_section conf_debug[] = {
74 { "debug", debug_config_keys, ARRAY_LENGTH(debug_config_keys) },
77 /*--------------------------------------------------------------------------*/
79 * @brief ico_special_option: Answer special option flag
82 * @return Special option flag
84 /*--------------------------------------------------------------------------*/
88 return _ico_option_flag;
91 /*--------------------------------------------------------------------------*/
93 * @brief ico_ivi_debuglevel: Answer debug output level.
96 * @return Debug output level
97 * @retval 0 No debug output
98 * @retval 1 Only error output
99 * @retval 2 Error and information output
100 * @retval 3 All output with debug write
102 /*--------------------------------------------------------------------------*/
104 ico_ivi_debuglevel(void)
106 return _ico_ivi_debug;
109 /*--------------------------------------------------------------------------*/
111 * @brief ico_ivi_get_mynode: Get my NodeId
114 * @return NodeId of my node
116 /*--------------------------------------------------------------------------*/
118 ico_ivi_get_mynode(void)
120 /* Reference Platform 0.50 only support 1 ECU */
124 /*--------------------------------------------------------------------------*/
126 * @brief ico_ivi_set_usurf_2_node: Regist function of convert surfaceId to NodeId
128 * @param[in] usurf_2_node Function address of usurf_2_node
131 /*--------------------------------------------------------------------------*/
133 ico_ivi_set_usurf_2_node(int (*usurf_2_node)(const int surfaceid))
135 _ico_ivi_common->usurf_2_node = usurf_2_node;
138 /*--------------------------------------------------------------------------*/
140 * @brief ico_ivi_usurf_2_node: Convert surfaceId to NodeId
142 * @param[in] surfaceid ivi-shell surfaceId
144 * @retval >= 0 NodeId
145 * @retval < 0 Surface dose not exist
147 /*--------------------------------------------------------------------------*/
149 ico_ivi_usurf_2_node(const int surfaceid)
153 if (_ico_ivi_common->usurf_2_node) {
154 /* If declared convert function, call function */
155 nodeId = (*_ico_ivi_common->usurf_2_node) (surfaceid);
161 /* If NOT declare convert function, convert from surfaceId */
162 return ICO_IVI_SURFACEID_2_NODEID(surfaceid);
165 /*--------------------------------------------------------------------------*/
167 * @brief ico_ivi_set_send_to_mgr: Regist function of send to manager
169 * @param[in] send_to_mgr Function address of send to manager
172 /*--------------------------------------------------------------------------*/
174 ico_ivi_set_send_to_mgr(int (*send_to_mgr)(const int event,
175 const int surfaceid, const char *appid,
176 const int param1, const int param2, const int param3,
177 const int param4, const int param5, const int param6))
179 _ico_ivi_common->send_to_mgr = send_to_mgr;
182 /*--------------------------------------------------------------------------*/
184 * @brief ico_ivi_send_to_mgr: Send event to manager
186 * @param[in] event Event code
187 * @param[in] client_resource Client resource
188 * @param[in] surfaceid SurfaceId (depend of event code)
189 * @param[in] appid ApplicationId (depend of event code)
190 * @param[in] param1 Parameter.1 (depend of event code)
191 * @param[in] param2 Parameter.2 (depend of event code)
193 * @param[in] param6 Parameter.6 (depend of event code)
194 * @return number of managers
195 * @retval > 0 number of managers
196 * @retval 0 manager not exist
197 * @retval -1 Multi Input Manager not exist
199 /*--------------------------------------------------------------------------*/
201 ico_ivi_send_to_mgr(const int event, struct wl_resource *client_resource,
202 const int surfaceid, const char *appid,
203 const int param1, const int param2, const int param3,
204 const int param4, const int param5, const int param6)
206 if (_ico_ivi_common->send_to_mgr) {
207 return (*_ico_ivi_common->send_to_mgr)(event, surfaceid, appid,
208 param1, param2, param3,
209 param4, param5, param6);
214 /*--------------------------------------------------------------------------*/
216 * @brief ico_ivi_set_send_surface_change: Regist function of surface change
218 * @param[in] send_surface_change Function address of surface change
221 /*--------------------------------------------------------------------------*/
223 ico_ivi_set_send_surface_change(int (*send_surface_change)(struct weston_surface *surface,
224 const int x, const int y,
228 _ico_ivi_common->send_surface_change = send_surface_change;
231 /*--------------------------------------------------------------------------*/
233 * @brief ico_ivi_send_surface_change: Send surface change event to manager
235 * @param[in] surface Weston surface
236 * @return number of managers
237 * @retval > 0 number of managers
238 * @retval 0 manager not exist
239 * @retval -1 Multi Input Manager not exist
241 /*--------------------------------------------------------------------------*/
243 ico_ivi_send_surface_change(struct weston_surface *surface,
244 const int x, const int y, const int width, const int height)
246 if (_ico_ivi_common->send_surface_change) {
247 return (*_ico_ivi_common->send_surface_change)(surface, x, y, width, height);
252 /*--------------------------------------------------------------------------*/
254 * @brief ico_ivi_nodename_2_node: Convert node name to hostId
256 * @param[in] nodename Node name(same as host name)
258 * @retval >= 0 HostId
260 /*--------------------------------------------------------------------------*/
262 ico_ivi_nodename_2_node(const char *nodename)
264 if (nodename == NULL) {
265 uifw_trace("ico_ivi_nodename_2_node: NULL => %d",
266 ICO_IVI_NODEID_2_HOSTID(_ico_ivi_common->myNodeId));
267 return ICO_IVI_NODEID_2_HOSTID(_ico_ivi_common->myNodeId);
270 /* Reference Platform 0.50 only support 1 ECU */
271 uifw_trace("ico_ivi_nodename_2_node: %s => None", nodename );
275 /*--------------------------------------------------------------------------*/
277 * @brief ico_ivi_dispname_2_node: Convert display name to nodeId
279 * @param[in] dispname Node name(same as display name)
281 * @retval >= 0 NodeId
283 /*--------------------------------------------------------------------------*/
285 ico_ivi_dispname_2_node(const char *dispname)
287 if (dispname == NULL) {
288 uifw_trace("ico_ivi_dispname_2_node: NULL => %x", _ico_ivi_common->myNodeId);
289 return _ico_ivi_common->myNodeId;
292 /* Reference Platform 0.50 only support 1 ECU */
293 uifw_trace("ico_ivi_dispname_2_node: %s => None", dispname);
297 /*--------------------------------------------------------------------------*/
299 * @brief IVI Common: Initialize function of ico_ivi_common.
301 * @param[in] ec Weston compositor. (from Weston)
303 * @retval 0 Normal end
306 /*--------------------------------------------------------------------------*/
308 module_init(struct weston_compositor *ec)
312 uifw_info("ico_ivi_common: Enter(module_init)");
314 /* Get debug level from config file */
315 config_fd = open_config_file(ICO_IVI_PLUGIN_CONFIG);
316 parse_config_file(config_fd, conf_debug, ARRAY_LENGTH(conf_debug), NULL);
319 uifw_info("ico_ivi_common: option flag=0x%08x debug=%d",
320 ico_option_flag(), ico_ivi_debuglevel());
322 /* Allocate static area */
323 _ico_ivi_common = (struct ico_ivi_common *) malloc(sizeof(struct ico_ivi_common));
324 if (! _ico_ivi_common) {
325 uifw_error("ico_ivi_common: Leave(No Memory)");
328 memset(_ico_ivi_common, 0, sizeof(struct ico_ivi_common));
330 uifw_info("ico_ivi_common: Leave(module_init)");