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