Changes in uspace/srv/hid/display/main.c [1762ceb:6fbd1f9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/main.c
r1762ceb r6fbd1f9 1 1 /* 2 * Copyright (c) 20 19Jiri Svoboda2 * Copyright (c) 2024 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 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; 92 134 errno_t rc; 93 135 … … 98 140 goto error; 99 141 100 rc = ds_seat_create(disp, &seat); 101 if (rc != EOK) 102 goto error; 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 } 103 152 104 153 rc = ds_output_create(&output); … … 111 160 goto error; 112 161 162 rc = ds_ievent_init(disp); 163 if (rc != EOK) 164 goto error; 165 113 166 rc = ds_input_open(disp); 114 167 if (rc != EOK) 115 168 goto error; 116 169 117 async_set_fallback_port_handler(display_client_conn, disp); 118 119 rc = loc_server_register(NAME); 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); 120 190 if (rc != EOK) { 121 191 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering server: %s.", str_error(rc)); … … 124 194 } 125 195 126 service_id_t sid; 127 rc = loc_service_register(SERVICE_NAME_DISPLAY, &sid); 196 rc = loc_service_register(srv, SERVICE_NAME_DISPLAY, &sid); 128 197 if (rc != EOK) { 129 198 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service: %s.", str_error(rc)); … … 135 204 return EOK; 136 205 error: 206 if (sid != 0) 207 loc_service_unregister(srv, sid); 208 if (srv != NULL) 209 loc_server_unregister(srv); 210 // XXX destroy disp_port 211 // XXX destroy gc_port 212 // XXX destroy wm_port 213 // XXX destroy dc_port 137 214 #if 0 138 215 if (disp->input != NULL) 139 216 ds_input_close(disp); 140 217 #endif 218 ds_ievent_fini(disp); 141 219 if (output != NULL) 142 220 ds_output_destroy(output); … … 154 232 { 155 233 display_srv_t srv; 156 sysarg_t wnd_id;157 234 sysarg_t svc_id; 158 235 ds_client_t *client = NULL; 159 ds_window_t *wnd;160 236 ds_display_t *disp = (ds_display_t *) arg; 161 gfx_context_t *gc;162 237 errno_t rc; 163 238 … … 166 241 ipc_get_arg4(icall)); 167 242 168 (void) icall;169 (void) arg;170 171 243 svc_id = ipc_get_arg2(icall); 172 wnd_id = ipc_get_arg3(icall);173 244 174 245 if (svc_id != 0) { 175 246 /* Create client object */ 247 ds_display_lock(disp); 176 248 rc = ds_client_create(disp, &display_client_cb, &srv, &client); 249 ds_display_unlock(disp); 177 250 if (rc != EOK) { 178 251 async_answer_0(icall, ENOMEM); … … 191 264 ds_client_destroy(client); 192 265 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 } 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); 209 357 } 210 358
Note:
See TracChangeset
for help on using the changeset viewer.