Changes in uspace/srv/hid/display/main.c [6fbd1f9:1762ceb] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/main.c
r6fbd1f9 r1762ceb 1 1 /* 2 * Copyright (c) 20 24Jiri Svoboda2 * Copyright (c) 2019 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 36 36 #include <async.h> 37 37 #include <disp_srv.h> 38 #include <dispcfg_srv.h>39 38 #include <errno.h> 40 39 #include <gfx/context.h> … … 48 47 #include <stdio.h> 49 48 #include <task.h> 50 #include <wndmgt_srv.h>51 #include "cfgclient.h"52 #include "cfgops.h"53 49 #include "client.h" 54 50 #include "display.h" 55 51 #include "dsops.h" 56 #include "ievent.h"57 52 #include "input.h" 58 53 #include "main.h" … … 60 55 #include "seat.h" 61 56 #include "window.h" 62 #include "wmclient.h"63 #include "wmops.h"64 65 const char *cfg_file_path = "/w/cfg/display.sif";66 57 67 58 static void display_client_conn(ipc_call_t *, void *); 68 59 static void display_client_ev_pending(void *); 69 static void display_wmclient_ev_pending(void *);70 static void display_cfgclient_ev_pending(void *);71 static void display_gc_conn(ipc_call_t *, void *);72 static void display_wndmgt_conn(ipc_call_t *, void *);73 static void display_dispcfg_conn(ipc_call_t *, void *);74 60 75 61 #ifdef CONFIG_DISP_DOUBLE_BUF … … 90 76 }; 91 77 92 static ds_wmclient_cb_t display_wmclient_cb = {93 .ev_pending = display_wmclient_ev_pending94 };95 96 static ds_cfgclient_cb_t display_cfgclient_cb = {97 .ev_pending = display_cfgclient_ev_pending98 };99 100 78 static void display_client_ev_pending(void *arg) 101 79 { … … 103 81 104 82 display_srv_ev_pending(srv); 105 }106 107 static void display_wmclient_ev_pending(void *arg)108 {109 wndmgt_srv_t *srv = (wndmgt_srv_t *) arg;110 111 wndmgt_srv_ev_pending(srv);112 }113 114 static void display_cfgclient_ev_pending(void *arg)115 {116 dispcfg_srv_t *srv = (dispcfg_srv_t *) arg;117 118 dispcfg_srv_ev_pending(srv);119 83 } 120 84 … … 126 90 ds_output_t *output = NULL; 127 91 gfx_context_t *gc = NULL; 128 port_id_t disp_port;129 port_id_t gc_port;130 port_id_t wm_port;131 port_id_t dc_port;132 loc_srv_t *srv = NULL;133 service_id_t sid = 0;134 92 errno_t rc; 135 93 … … 140 98 goto error; 141 99 142 rc = ds_display_load_cfg(disp, cfg_file_path); 143 if (rc != EOK) { 144 log_msg(LOG_DEFAULT, LVL_NOTE, 145 "Starting with fresh configuration."); 146 147 /* Create first seat */ 148 rc = ds_seat_create(disp, "Alice", &seat); 149 if (rc != EOK) 150 goto error; 151 } 100 rc = ds_seat_create(disp, &seat); 101 if (rc != EOK) 102 goto error; 152 103 153 104 rc = ds_output_create(&output); … … 160 111 goto error; 161 112 162 rc = ds_ievent_init(disp);163 if (rc != EOK)164 goto error;165 166 113 rc = ds_input_open(disp); 167 114 if (rc != EOK) 168 115 goto error; 169 116 170 rc = async_create_port(INTERFACE_DISPLAY, display_client_conn, disp, 171 &disp_port); 172 if (rc != EOK) 173 goto error; 174 175 rc = async_create_port(INTERFACE_GC, display_gc_conn, disp, &gc_port); 176 if (rc != EOK) 177 goto error; 178 179 rc = async_create_port(INTERFACE_WNDMGT, display_wndmgt_conn, disp, 180 &wm_port); 181 if (rc != EOK) 182 goto error; 183 184 rc = async_create_port(INTERFACE_DISPCFG, display_dispcfg_conn, disp, 185 &dc_port); 186 if (rc != EOK) 187 goto error; 188 189 rc = loc_server_register(NAME, &srv); 117 async_set_fallback_port_handler(display_client_conn, disp); 118 119 rc = loc_server_register(NAME); 190 120 if (rc != EOK) { 191 121 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering server: %s.", str_error(rc)); … … 194 124 } 195 125 196 rc = loc_service_register(srv, SERVICE_NAME_DISPLAY, &sid); 126 service_id_t sid; 127 rc = loc_service_register(SERVICE_NAME_DISPLAY, &sid); 197 128 if (rc != EOK) { 198 129 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service: %s.", str_error(rc)); … … 204 135 return EOK; 205 136 error: 206 if (sid != 0)207 loc_service_unregister(srv, sid);208 if (srv != NULL)209 loc_server_unregister(srv);210 // XXX destroy disp_port211 // XXX destroy gc_port212 // XXX destroy wm_port213 // XXX destroy dc_port214 137 #if 0 215 138 if (disp->input != NULL) 216 139 ds_input_close(disp); 217 140 #endif 218 ds_ievent_fini(disp);219 141 if (output != NULL) 220 142 ds_output_destroy(output); … … 232 154 { 233 155 display_srv_t srv; 156 sysarg_t wnd_id; 234 157 sysarg_t svc_id; 235 158 ds_client_t *client = NULL; 159 ds_window_t *wnd; 236 160 ds_display_t *disp = (ds_display_t *) arg; 161 gfx_context_t *gc; 237 162 errno_t rc; 238 163 … … 241 166 ipc_get_arg4(icall)); 242 167 168 (void) icall; 169 (void) arg; 170 243 171 svc_id = ipc_get_arg2(icall); 172 wnd_id = ipc_get_arg3(icall); 244 173 245 174 if (svc_id != 0) { 246 175 /* Create client object */ 247 ds_display_lock(disp);248 176 rc = ds_client_create(disp, &display_client_cb, &srv, &client); 249 ds_display_unlock(disp);250 177 if (rc != EOK) { 251 178 async_answer_0(icall, ENOMEM); … … 264 191 ds_client_destroy(client); 265 192 ds_display_unlock(disp); 266 } 267 } 268 269 /** Handle GC connection to display server */ 270 static void display_gc_conn(ipc_call_t *icall, void *arg) 271 { 272 sysarg_t wnd_id; 273 ds_window_t *wnd; 274 ds_display_t *disp = (ds_display_t *) arg; 275 gfx_context_t *gc; 276 277 log_msg(LOG_DEFAULT, LVL_DEBUG, "display_gc_conn arg1=%zu arg2=%zu arg3=%zu arg4=%zu.", 278 ipc_get_arg1(icall), ipc_get_arg2(icall), ipc_get_arg3(icall), 279 ipc_get_arg4(icall)); 280 281 wnd_id = ipc_get_arg3(icall); 282 283 /* Window GC connection */ 284 285 wnd = ds_display_find_window(disp, wnd_id); 286 if (wnd == NULL) { 287 async_answer_0(icall, ENOENT); 288 return; 289 } 290 291 /* 292 * XXX We need a way to make sure that the connection does 293 * not stay active after the window had been destroyed 294 */ 295 gc = ds_window_get_ctx(wnd); 296 gc_conn(icall, gc); 297 } 298 299 /** Handle window management connection to display server */ 300 static void display_wndmgt_conn(ipc_call_t *icall, void *arg) 301 { 302 ds_display_t *disp = (ds_display_t *) arg; 303 errno_t rc; 304 wndmgt_srv_t srv; 305 ds_wmclient_t *wmclient = NULL; 306 307 /* Create WM client object */ 308 ds_display_lock(disp); 309 rc = ds_wmclient_create(disp, &display_wmclient_cb, &srv, &wmclient); 310 ds_display_unlock(disp); 311 if (rc != EOK) { 312 async_answer_0(icall, ENOMEM); 313 return; 314 } 315 316 /* Set up protocol structure */ 317 wndmgt_srv_initialize(&srv); 318 srv.ops = &wndmgt_srv_ops; 319 srv.arg = wmclient; 320 321 /* Handle connection */ 322 wndmgt_conn(icall, &srv); 323 324 ds_display_lock(disp); 325 ds_wmclient_destroy(wmclient); 326 ds_display_unlock(disp); 327 } 328 329 /** Handle configuration connection to display server */ 330 static void display_dispcfg_conn(ipc_call_t *icall, void *arg) 331 { 332 ds_display_t *disp = (ds_display_t *) arg; 333 errno_t rc; 334 dispcfg_srv_t srv; 335 ds_cfgclient_t *cfgclient = NULL; 336 337 /* Create CFG client object */ 338 ds_display_lock(disp); 339 rc = ds_cfgclient_create(disp, &display_cfgclient_cb, &srv, &cfgclient); 340 ds_display_unlock(disp); 341 if (rc != EOK) { 342 async_answer_0(icall, ENOMEM); 343 return; 344 } 345 346 /* Set up protocol structure */ 347 dispcfg_srv_initialize(&srv); 348 srv.ops = &dispcfg_srv_ops; 349 srv.arg = cfgclient; 350 351 /* Handle connection */ 352 dispcfg_conn(icall, &srv); 353 354 ds_display_lock(disp); 355 ds_cfgclient_destroy(cfgclient); 356 ds_display_unlock(disp); 193 } else { 194 /* Window GC connection */ 195 196 wnd = ds_display_find_window(disp, wnd_id); 197 if (wnd == NULL) { 198 async_answer_0(icall, ENOENT); 199 return; 200 } 201 202 /* 203 * XXX We need a way to make sure that the connection does 204 * not stay active after the window had been destroyed 205 */ 206 gc = ds_window_get_ctx(wnd); 207 gc_conn(icall, gc); 208 } 357 209 } 358 210
Note:
See TracChangeset
for help on using the changeset viewer.