Changeset ddb844e in mainline for uspace/drv
- Timestamp:
- 2020-07-03T23:00:34Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e79a025
- Parents:
- edb57bc6 (diff), 1a1c75e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/drv/fb
- Files:
-
- 8 edited
-
amdm37x_dispc/amdm37x_dispc.c (modified) (8 diffs)
-
amdm37x_dispc/amdm37x_dispc.h (modified) (4 diffs)
-
amdm37x_dispc/main.c (modified) (6 diffs)
-
amdm37x_dispc/meson.build (modified) (1 diff)
-
kfb/kfb.c (modified) (1 diff)
-
kfb/kfb.h (modified) (1 diff)
-
kfb/meson.build (modified) (1 diff)
-
kfb/port.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.c
redb57bc6 rddb844e 1 1 /* 2 * Copyright (c) 2020 Jiri Svoboda 2 3 * Copyright (c) 2013 Jan Vesely 3 4 * All rights reserved. … … 35 36 36 37 #include <align.h> 38 #include <as.h> 37 39 #include <assert.h> 38 40 #include <errno.h> 41 #include <ddev_srv.h> 42 #include <ddev/info.h> 43 #include <ddf/driver.h> 39 44 #include <ddf/log.h> 40 45 #include <ddi.h> 41 #include <as.h> 46 #include <gfx/color.h> 47 #include <io/pixelmap.h> 42 48 43 49 #include "amdm37x_dispc.h" … … 55 61 #endif 56 62 57 static errno_t change_mode(visualizer_t *vis, vslmode_t mode); 58 static errno_t handle_damage(visualizer_t *vs, 59 sysarg_t x0, sysarg_t y0, sysarg_t width, sysarg_t height, 60 sysarg_t x_offset, sysarg_t y_offset); 61 static errno_t dummy(visualizer_t *vs) 62 { 63 return EOK; 64 } 65 66 static const visualizer_ops_t amdm37x_dispc_vis_ops = { 67 .change_mode = change_mode, 68 .handle_damage = handle_damage, 69 .claim = dummy, 70 .yield = dummy, 71 .suspend = dummy, 72 .wakeup = dummy, 63 static errno_t amdm37x_change_mode(amdm37x_dispc_t *, unsigned, unsigned, 64 visual_t); 65 66 static errno_t amdm37x_ddev_get_gc(void *, sysarg_t *, sysarg_t *); 67 static errno_t amdm37x_ddev_get_info(void *, ddev_info_t *); 68 69 static errno_t amdm37x_gc_set_color(void *, gfx_color_t *); 70 static errno_t amdm37x_gc_fill_rect(void *, gfx_rect_t *); 71 static errno_t amdm37x_gc_bitmap_create(void *, gfx_bitmap_params_t *, 72 gfx_bitmap_alloc_t *, void **); 73 static errno_t amdm37x_gc_bitmap_destroy(void *); 74 static errno_t amdm37x_gc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *); 75 static errno_t amdm37x_gc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *); 76 77 ddev_ops_t amdm37x_ddev_ops = { 78 .get_gc = amdm37x_ddev_get_gc, 79 .get_info = amdm37x_ddev_get_info 80 }; 81 82 gfx_context_ops_t amdm37x_gc_ops = { 83 .set_color = amdm37x_gc_set_color, 84 .fill_rect = amdm37x_gc_fill_rect, 85 .bitmap_create = amdm37x_gc_bitmap_create, 86 .bitmap_destroy = amdm37x_gc_bitmap_destroy, 87 .bitmap_render = amdm37x_gc_bitmap_render, 88 .bitmap_get_alloc = amdm37x_gc_bitmap_get_alloc 73 89 }; 74 90 … … 94 110 }; 95 111 96 static void mode_init(vslmode_list_element_t *mode, 97 unsigned width, unsigned height, visual_t visual) 98 { 99 mode->mode.index = 0; 100 mode->mode.version = 0; 101 mode->mode.refresh_rate = 0; 102 mode->mode.screen_aspect.width = width; 103 mode->mode.screen_aspect.height = height; 104 mode->mode.screen_width = width; 105 mode->mode.screen_height = height; 106 mode->mode.cell_aspect.width = 1; 107 mode->mode.cell_aspect.height = 1; 108 mode->mode.cell_visual.pixel_visual = visual; 109 110 link_initialize(&mode->link); 111 112 } 113 114 errno_t amdm37x_dispc_init(amdm37x_dispc_t *instance, visualizer_t *vis) 115 { 116 assert(instance); 117 assert(vis); 118 112 errno_t amdm37x_dispc_init(amdm37x_dispc_t *instance, ddf_fun_t *fun) 113 { 114 instance->fun = fun; 119 115 instance->fb_data = NULL; 120 116 instance->size = 0; … … 145 141 } 146 142 147 mode_init(&instance->modes[0], 148 CONFIG_BFB_WIDTH, CONFIG_BFB_HEIGHT, visual); 149 150 /* Handle vis stuff */ 151 vis->dev_ctx = instance; 152 vis->def_mode_idx = 0; 153 vis->ops = amdm37x_dispc_vis_ops; 154 list_append(&instance->modes[0].link, &vis->modes); 143 ret = amdm37x_change_mode(instance, CONFIG_BFB_WIDTH, 144 CONFIG_BFB_HEIGHT, visual); 145 if (ret != EOK) 146 return EIO; 155 147 156 148 return EOK; … … 269 261 } 270 262 271 static errno_t change_mode(visualizer_t *vis, vslmode_t mode) 272 { 273 assert(vis); 274 assert(vis->dev_ctx); 275 276 amdm37x_dispc_t *dispc = vis->dev_ctx; 277 const visual_t visual = mode.cell_visual.pixel_visual; 263 static errno_t amdm37x_change_mode(amdm37x_dispc_t *dispc, unsigned x, 264 unsigned y, visual_t visual) 265 { 278 266 assert((size_t)visual < sizeof(pixel2visual_table) / sizeof(pixel2visual_table[0])); 279 267 const unsigned bpp = pixel2visual_table[visual].bpp; 280 268 pixel2visual_t p2v = pixel2visual_table[visual].func; 281 const unsigned x = mode.screen_width;282 const unsigned y = mode.screen_height;283 269 ddf_log_note("Setting mode: %ux%ux%u\n", x, y, bpp * 8); 284 270 const size_t size = ALIGN_UP(x * y * bpp, PAGE_SIZE); … … 296 282 dispc->fb_data = buffer; 297 283 amdm37x_dispc_setup_fb(dispc->regs, x, y, bpp * 8, (uint32_t)pa); 298 dispc->active_fb.idx = mode.index;299 284 dispc->active_fb.width = x; 300 285 dispc->active_fb.height = y; … … 302 287 dispc->active_fb.bpp = bpp; 303 288 dispc->active_fb.pixel2visual = p2v; 289 dispc->rect.p0.x = 0; 290 dispc->rect.p0.y = 0; 291 dispc->rect.p1.x = x; 292 dispc->rect.p1.y = y; 304 293 dispc->size = size; 305 assert(mode.index < 1); 306 307 return EOK; 308 } 309 310 static errno_t handle_damage(visualizer_t *vs, 311 sysarg_t x0, sysarg_t y0, sysarg_t width, sysarg_t height, 312 sysarg_t x_offset, sysarg_t y_offset) 313 { 314 assert(vs); 315 assert(vs->dev_ctx); 316 amdm37x_dispc_t *dispc = vs->dev_ctx; 317 pixelmap_t *map = &vs->cells; 318 319 #define FB_POS(x, y) \ 320 (((y) * (dispc->active_fb.width + dispc->active_fb.pitch) + (x)) \ 321 * dispc->active_fb.bpp) 322 if (x_offset == 0 && y_offset == 0) { 323 /* Faster damage routine ignoring offsets. */ 324 for (sysarg_t y = y0; y < height + y0; ++y) { 325 pixel_t *pixel = pixelmap_pixel_at(map, x0, y); 326 for (sysarg_t x = x0; x < width + x0; ++x) { 327 dispc->active_fb.pixel2visual( 328 dispc->fb_data + FB_POS(x, y), *pixel++); 329 } 294 295 return EOK; 296 } 297 298 #define FB_POS(d, x, y) \ 299 (((y) * ((d)->active_fb.width + (d)->active_fb.pitch) + (x)) \ 300 * (d)->active_fb.bpp) 301 302 static errno_t amdm37x_ddev_get_gc(void *arg, sysarg_t *arg2, sysarg_t *arg3) 303 { 304 amdm37x_dispc_t *dispc = (amdm37x_dispc_t *) arg; 305 306 *arg2 = ddf_fun_get_handle(dispc->fun); 307 *arg3 = 42; 308 return EOK; 309 } 310 311 static errno_t amdm37x_ddev_get_info(void *arg, ddev_info_t *info) 312 { 313 amdm37x_dispc_t *dispc = (amdm37x_dispc_t *) arg; 314 315 ddev_info_init(info); 316 info->rect.p0.x = 0; 317 info->rect.p0.y = 0; 318 info->rect.p1.x = dispc->active_fb.width; 319 info->rect.p1.y = dispc->active_fb.height; 320 return EOK; 321 } 322 323 /** Set color on AMDM37x display controller. 324 * 325 * Set drawing color on AMDM37x GC. 326 * 327 * @param arg AMDM37x display controller 328 * @param color Color 329 * 330 * @return EOK on success or an error code 331 */ 332 static errno_t amdm37x_gc_set_color(void *arg, gfx_color_t *color) 333 { 334 amdm37x_dispc_t *dispc = (amdm37x_dispc_t *) arg; 335 uint16_t r, g, b; 336 337 gfx_color_get_rgb_i16(color, &r, &g, &b); 338 dispc->color = PIXEL(0, r >> 8, g >> 8, b >> 8); 339 return EOK; 340 } 341 342 /** Fill rectangle on AMDM37x display controller. 343 * 344 * @param arg AMDM37x display controller 345 * @param rect Rectangle 346 * 347 * @return EOK on success or an error code 348 */ 349 static errno_t amdm37x_gc_fill_rect(void *arg, gfx_rect_t *rect) 350 { 351 amdm37x_dispc_t *dispc = (amdm37x_dispc_t *) arg; 352 gfx_rect_t crect; 353 gfx_coord_t x, y; 354 355 /* Make sure we have a sorted, clipped rectangle */ 356 gfx_rect_clip(rect, &dispc->rect, &crect); 357 358 for (y = crect.p0.y; y < crect.p1.y; y++) { 359 for (x = crect.p0.x; x < crect.p1.x; x++) { 360 dispc->active_fb.pixel2visual(dispc->fb_data + 361 FB_POS(dispc, x, y), dispc->color); 362 } 363 } 364 365 return EOK; 366 } 367 368 /** Create bitmap in AMDM37x GC. 369 * 370 * @param arg AMDM37x display controller 371 * @param params Bitmap params 372 * @param alloc Bitmap allocation info or @c NULL 373 * @param rbm Place to store pointer to new bitmap 374 * @return EOK on success or an error code 375 */ 376 errno_t amdm37x_gc_bitmap_create(void *arg, gfx_bitmap_params_t *params, 377 gfx_bitmap_alloc_t *alloc, void **rbm) 378 { 379 amdm37x_dispc_t *dispc = (amdm37x_dispc_t *) arg; 380 amdm37x_bitmap_t *dcbm = NULL; 381 gfx_coord2_t dim; 382 errno_t rc; 383 384 /* Check that we support all required flags */ 385 if ((params->flags & ~bmpf_color_key) != 0) 386 return ENOTSUP; 387 388 dcbm = calloc(1, sizeof(amdm37x_bitmap_t)); 389 if (dcbm == NULL) 390 return ENOMEM; 391 392 gfx_coord2_subtract(¶ms->rect.p1, ¶ms->rect.p0, &dim); 393 dcbm->rect = params->rect; 394 395 if (alloc == NULL) { 396 dcbm->alloc.pitch = dim.x * sizeof(uint32_t); 397 dcbm->alloc.off0 = 0; 398 dcbm->alloc.pixels = malloc(dcbm->alloc.pitch * dim.y); 399 dcbm->myalloc = true; 400 401 if (dcbm->alloc.pixels == NULL) { 402 rc = ENOMEM; 403 goto error; 330 404 } 331 405 } else { 332 for (sysarg_t y = y0; y < height + y0; ++y) { 333 for (sysarg_t x = x0; x < width + x0; ++x) { 334 dispc->active_fb.pixel2visual( 335 dispc->fb_data + FB_POS(x, y), 336 *pixelmap_pixel_at(map, 337 (x + x_offset) % map->width, 338 (y + y_offset) % map->height)); 339 } 406 dcbm->alloc = *alloc; 407 } 408 409 dcbm->dispc = dispc; 410 *rbm = (void *)dcbm; 411 return EOK; 412 error: 413 if (rbm != NULL) 414 free(dcbm); 415 return rc; 416 } 417 418 /** Destroy bitmap in AMDM37x GC. 419 * 420 * @param bm Bitmap 421 * @return EOK on success or an error code 422 */ 423 static errno_t amdm37x_gc_bitmap_destroy(void *bm) 424 { 425 amdm37x_bitmap_t *dcbm = (amdm37x_bitmap_t *)bm; 426 if (dcbm->myalloc) 427 free(dcbm->alloc.pixels); 428 free(dcbm); 429 return EOK; 430 } 431 432 /** Render bitmap in AMDM37x GC. 433 * 434 * @param bm Bitmap 435 * @param srect0 Source rectangle or @c NULL 436 * @param offs0 Offset or @c NULL 437 * @return EOK on success or an error code 438 */ 439 static errno_t amdm37x_gc_bitmap_render(void *bm, gfx_rect_t *srect0, 440 gfx_coord2_t *offs0) 441 { 442 amdm37x_bitmap_t *dcbm = (amdm37x_bitmap_t *)bm; 443 amdm37x_dispc_t *dispc = dcbm->dispc; 444 gfx_rect_t srect; 445 gfx_rect_t drect; 446 gfx_rect_t skfbrect; 447 gfx_rect_t crect; 448 gfx_coord2_t offs; 449 gfx_coord2_t bmdim; 450 gfx_coord2_t dim; 451 gfx_coord2_t sp; 452 gfx_coord2_t dp; 453 gfx_coord2_t pos; 454 pixelmap_t pbm; 455 pixel_t color; 456 457 /* Clip source rectangle to bitmap bounds */ 458 459 if (srect0 != NULL) 460 gfx_rect_clip(srect0, &dcbm->rect, &srect); 461 else 462 srect = dcbm->rect; 463 464 if (offs0 != NULL) { 465 offs = *offs0; 466 } else { 467 offs.x = 0; 468 offs.y = 0; 469 } 470 471 /* Destination rectangle */ 472 gfx_rect_translate(&offs, &srect, &drect); 473 gfx_coord2_subtract(&drect.p1, &drect.p0, &dim); 474 gfx_coord2_subtract(&dcbm->rect.p1, &dcbm->rect.p0, &bmdim); 475 476 pbm.width = bmdim.x; 477 pbm.height = bmdim.y; 478 pbm.data = dcbm->alloc.pixels; 479 480 /* Transform AMDM37x bounding rectangle back to bitmap coordinate system */ 481 gfx_rect_rtranslate(&offs, &dispc->rect, &skfbrect); 482 483 /* 484 * Make sure we have a sorted source rectangle, clipped so that 485 * destination lies within AMDM37x bounding rectangle 486 */ 487 gfx_rect_clip(&srect, &skfbrect, &crect); 488 489 // XXX bmpf_color_key 490 for (pos.y = crect.p0.y; pos.y < crect.p1.y; pos.y++) { 491 for (pos.x = crect.p0.x; pos.x < crect.p1.x; pos.x++) { 492 gfx_coord2_subtract(&pos, &dcbm->rect.p0, &sp); 493 gfx_coord2_add(&pos, &offs, &dp); 494 495 color = pixelmap_get_pixel(&pbm, sp.x, sp.y); 496 dispc->active_fb.pixel2visual(dispc->fb_data + 497 FB_POS(dispc, dp.x, dp.y), color); 340 498 } 341 499 } 342 500 501 return EOK; 502 } 503 504 /** Get allocation info for bitmap in AMDM37x GC. 505 * 506 * @param bm Bitmap 507 * @param alloc Place to store allocation info 508 * @return EOK on success or an error code 509 */ 510 static errno_t amdm37x_gc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc) 511 { 512 amdm37x_bitmap_t *dcbm = (amdm37x_bitmap_t *)bm; 513 *alloc = dcbm->alloc; 343 514 return EOK; 344 515 } -
uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.h
redb57bc6 rddb844e 1 1 /* 2 * Copyright (c) 2020 Jiri Svoboda 2 3 * Copyright (c) 2013 Jan Vesely 3 4 * All rights reserved. … … 37 38 #define AMDM37X_DISPC_H_ 38 39 39 #include <graph.h>40 40 #include <abi/fb/visuals.h> 41 #include <ddev_srv.h> 42 #include <ddf/driver.h> 43 #include <gfx/context.h> 44 #include <gfx/coord.h> 45 #include <io/pixel.h> 41 46 #include <pixconv.h> 42 47 #include <ddi.h> … … 45 50 46 51 typedef struct { 52 ddf_fun_t *fun; 47 53 amdm37x_dispc_regs_t *regs; 48 54 … … 53 59 unsigned pitch; 54 60 unsigned bpp; 55 unsigned idx;56 61 } active_fb; 57 62 63 pixel_t color; 64 gfx_rect_t rect; 58 65 size_t size; 59 66 void *fb_data; 60 61 vslmode_list_element_t modes[1];62 67 } amdm37x_dispc_t; 63 68 64 errno_t amdm37x_dispc_init(amdm37x_dispc_t *instance, visualizer_t *vis); 65 errno_t amdm37x_dispc_fini(amdm37x_dispc_t *instance); 69 typedef struct { 70 amdm37x_dispc_t *dispc; 71 gfx_bitmap_alloc_t alloc; 72 gfx_rect_t rect; 73 bool myalloc; 74 } amdm37x_bitmap_t; 75 76 extern ddev_ops_t amdm37x_ddev_ops; 77 extern gfx_context_ops_t amdm37x_gc_ops; 78 79 extern errno_t amdm37x_dispc_init(amdm37x_dispc_t *, ddf_fun_t *); 80 extern errno_t amdm37x_dispc_fini(amdm37x_dispc_t *); 66 81 67 82 #endif -
uspace/drv/fb/amdm37x_dispc/main.c
redb57bc6 rddb844e 1 1 /* 2 * Copyright (c) 2020 Jiri Svoboda 2 3 * Copyright (c) 2013 Jan Vesely 3 4 * Copyright (c) 2011 Petr Koupy … … 35 36 */ 36 37 38 #include <ddev_srv.h> 37 39 #include <ddf/driver.h> 38 40 #include <ddf/log.h> 39 41 #include <errno.h> 42 #include <ipcgfx/server.h> 40 43 #include <str_error.h> 41 44 #include <stdio.h> 42 #include <graph.h>43 45 44 46 #include "amdm37x_dispc.h" … … 46 48 #define NAME "amdm37x_dispc" 47 49 48 static void graph_vsl_connection(ipc_call_t *icall, void *arg)50 static void amdm37x_client_conn(ipc_call_t *icall, void *arg) 49 51 { 50 visualizer_t *vsl; 52 amdm37x_dispc_t *dispc; 53 ddev_srv_t srv; 54 sysarg_t gc_id; 55 gfx_context_t *gc; 56 errno_t rc; 51 57 52 vsl = (visualizer_t *) ddf_fun_data_get((ddf_fun_t *)arg); 53 graph_visualizer_connection(vsl, icall, NULL); 58 dispc = (amdm37x_dispc_t *) ddf_dev_data_get( 59 ddf_fun_get_dev((ddf_fun_t *) arg)); 60 61 gc_id = ipc_get_arg3(icall); 62 63 if (gc_id == 0) { 64 /* Set up protocol structure */ 65 ddev_srv_initialize(&srv); 66 srv.ops = &amdm37x_ddev_ops; 67 srv.arg = dispc; 68 69 /* Handle connection */ 70 ddev_conn(icall, &srv); 71 } else { 72 assert(gc_id == 42); 73 74 rc = gfx_context_new(&amdm37x_gc_ops, dispc, &gc); 75 if (rc != EOK) 76 goto error; 77 78 /* GC connection */ 79 gc_conn(icall, gc); 80 } 81 82 return; 83 error: 84 async_answer_0(icall, rc); 54 85 } 55 86 … … 57 88 { 58 89 assert(dev); 59 /* Visualizer part */ 60 ddf_fun_t *fun = ddf_fun_create(dev, fun_exposed, " viz");90 91 ddf_fun_t *fun = ddf_fun_create(dev, fun_exposed, "a"); 61 92 if (!fun) { 62 ddf_log_error("Failed to create visualizerfunction.");93 ddf_log_error("Failed to create display device function."); 63 94 return ENOMEM; 64 95 } 65 96 66 visualizer_t *vis = ddf_fun_data_alloc(fun, sizeof(visualizer_t)); 67 if (!vis) { 68 ddf_log_error("Failed to allocate visualizer structure."); 69 ddf_fun_destroy(fun); 70 return ENOMEM; 71 } 97 ddf_fun_set_conn_handler(fun, &amdm37x_client_conn); 72 98 73 graph_init_visualizer(vis);74 vis->reg_svc_handle = ddf_fun_get_handle(fun);75 76 ddf_fun_set_conn_handler(fun, graph_vsl_connection);77 99 /* Hw part */ 78 100 amdm37x_dispc_t *dispc = … … 84 106 } 85 107 86 errno_t rc = amdm37x_dispc_init(dispc, vis);108 errno_t rc = amdm37x_dispc_init(dispc, fun); 87 109 if (rc != EOK) { 88 110 ddf_log_error("Failed to init dispc: %s.", str_error(rc)); … … 100 122 } 101 123 102 rc = ddf_fun_add_to_category(fun, " visualizer");124 rc = ddf_fun_add_to_category(fun, "display-device"); 103 125 if (rc != EOK) { 104 ddf_log_error("Failed to add function: %s to visualizer"126 ddf_log_error("Failed to add function: %s to display device " 105 127 "category.", str_error(rc)); 106 128 amdm37x_dispc_fini(dispc); -
uspace/drv/fb/amdm37x_dispc/meson.build
redb57bc6 rddb844e 29 29 # 30 30 31 deps = [ 'g raph', 'softrend' ]31 deps = [ 'gfx', 'ipcgfx', 'ddev', 'softrend' ] 32 32 src = files('amdm37x_dispc.c', 'main.c') -
uspace/drv/fb/kfb/kfb.c
redb57bc6 rddb844e 36 36 #include <errno.h> 37 37 #include <stdio.h> 38 #include <graph.h>39 38 #include "port.h" 40 39 #include "kfb.h" -
uspace/drv/fb/kfb/kfb.h
redb57bc6 rddb844e 41 41 #define NAME "kfb" 42 42 43 extern ddf_dev_ops_t graph_vsl_device_ops;44 extern ddf_dev_ops_t graph_rnd_device_ops;45 46 43 #endif 47 44 -
uspace/drv/fb/kfb/meson.build
redb57bc6 rddb844e 29 29 # 30 30 31 deps = [ 'g raph', 'softrend' ]31 deps = [ 'gfx', 'ipcgfx', 'ddev', 'softrend' ] 32 32 src = files('port.c', 'kfb.c') -
uspace/drv/fb/kfb/port.c
redb57bc6 rddb844e 1 1 /* 2 * Copyright (c) 2019 Jiri Svoboda 2 3 * Copyright (c) 2006 Jakub Vana 3 4 * Copyright (c) 2006 Ondrej Palkovsky … … 38 39 39 40 #include <abi/fb/visuals.h> 41 #include <adt/list.h> 42 #include <align.h> 43 #include <as.h> 44 #include <ddev_srv.h> 45 #include <ddev/info.h> 46 #include <ddi.h> 47 #include <ddf/log.h> 48 #include <errno.h> 49 #include <gfx/bitmap.h> 50 #include <gfx/color.h> 51 #include <gfx/coord.h> 52 #include <io/mode.h> 53 #include <io/pixelmap.h> 54 #include <ipcgfx/server.h> 55 #include <mem.h> 56 #include <pixconv.h> 40 57 #include <stddef.h> 41 58 #include <stdint.h> 42 #include <errno.h>43 44 59 #include <stdlib.h> 45 #include <mem.h>46 #include <as.h>47 #include <align.h>48 49 60 #include <sysinfo.h> 50 #include <ddi.h>51 52 #include <adt/list.h>53 54 #include <io/mode.h>55 #include <io/pixelmap.h>56 #include <io/chargrid.h>57 58 #include <pixconv.h>59 60 #include <graph.h>61 61 62 62 #include "kfb.h" 63 63 #include "port.h" 64 64 65 #define FB_POS( x, y) ((y) * kfb.scanline + (x) * kfb.pixel_bytes)65 #define FB_POS(fb, x, y) ((y) * (fb)->scanline + (x) * (fb)->pixel_bytes) 66 66 67 67 typedef struct { 68 ddf_fun_t *fun; 69 68 70 sysarg_t paddr; 69 sysarg_t width; 70 sysarg_t height; 71 gfx_rect_t rect; 71 72 size_t offset; 72 73 size_t scanline; … … 80 81 size_t size; 81 82 uint8_t *addr; 83 84 /** Current drawing color */ 85 pixel_t color; 82 86 } kfb_t; 83 87 84 static kfb_t kfb; 85 86 static vslmode_list_element_t pixel_mode; 87 88 static errno_t kfb_claim(visualizer_t *vs) 89 { 90 return physmem_map(kfb.paddr + kfb.offset, 91 ALIGN_UP(kfb.size, PAGE_SIZE) >> PAGE_WIDTH, 92 AS_AREA_READ | AS_AREA_WRITE, (void *) &kfb.addr); 93 } 94 95 static errno_t kfb_yield(visualizer_t *vs) 96 { 88 typedef struct { 89 kfb_t *kfb; 90 gfx_bitmap_alloc_t alloc; 91 gfx_rect_t rect; 92 gfx_bitmap_flags_t flags; 93 pixel_t key_color; 94 bool myalloc; 95 } kfb_bitmap_t; 96 97 static errno_t kfb_ddev_get_gc(void *, sysarg_t *, sysarg_t *); 98 static errno_t kfb_ddev_get_info(void *, ddev_info_t *); 99 100 static errno_t kfb_gc_set_color(void *, gfx_color_t *); 101 static errno_t kfb_gc_fill_rect(void *, gfx_rect_t *); 102 static errno_t kfb_gc_bitmap_create(void *, gfx_bitmap_params_t *, 103 gfx_bitmap_alloc_t *, void **); 104 static errno_t kfb_gc_bitmap_destroy(void *); 105 static errno_t kfb_gc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *); 106 static errno_t kfb_gc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *); 107 108 static ddev_ops_t kfb_ddev_ops = { 109 .get_gc = kfb_ddev_get_gc, 110 .get_info = kfb_ddev_get_info 111 }; 112 113 static gfx_context_ops_t kfb_gc_ops = { 114 .set_color = kfb_gc_set_color, 115 .fill_rect = kfb_gc_fill_rect, 116 .bitmap_create = kfb_gc_bitmap_create, 117 .bitmap_destroy = kfb_gc_bitmap_destroy, 118 .bitmap_render = kfb_gc_bitmap_render, 119 .bitmap_get_alloc = kfb_gc_bitmap_get_alloc 120 }; 121 122 static errno_t kfb_ddev_get_gc(void *arg, sysarg_t *arg2, sysarg_t *arg3) 123 { 124 kfb_t *kfb = (kfb_t *) arg; 125 126 *arg2 = ddf_fun_get_handle(kfb->fun); 127 *arg3 = 42; 128 return EOK; 129 } 130 131 static errno_t kfb_ddev_get_info(void *arg, ddev_info_t *info) 132 { 133 kfb_t *kfb = (kfb_t *) arg; 134 135 ddev_info_init(info); 136 info->rect = kfb->rect; 137 return EOK; 138 } 139 140 /** Set color on KFB. 141 * 142 * Set drawing color on KFB GC. 143 * 144 * @param arg KFB 145 * @param color Color 146 * 147 * @return EOK on success or an error code 148 */ 149 static errno_t kfb_gc_set_color(void *arg, gfx_color_t *color) 150 { 151 kfb_t *kfb = (kfb_t *) arg; 152 uint16_t r, g, b; 153 154 gfx_color_get_rgb_i16(color, &r, &g, &b); 155 kfb->color = PIXEL(0, r >> 8, g >> 8, b >> 8); 156 return EOK; 157 } 158 159 /** Fill rectangle on KFB. 160 * 161 * @param arg KFB 162 * @param rect Rectangle 163 * 164 * @return EOK on success or an error code 165 */ 166 static errno_t kfb_gc_fill_rect(void *arg, gfx_rect_t *rect) 167 { 168 kfb_t *kfb = (kfb_t *) arg; 169 gfx_rect_t crect; 170 gfx_coord_t x, y; 171 172 /* Make sure we have a sorted, clipped rectangle */ 173 gfx_rect_clip(rect, &kfb->rect, &crect); 174 175 for (y = crect.p0.y; y < crect.p1.y; y++) { 176 for (x = crect.p0.x; x < crect.p1.x; x++) { 177 kfb->pixel2visual(kfb->addr + FB_POS(kfb, x, y), 178 kfb->color); 179 } 180 } 181 182 return EOK; 183 } 184 185 /** Create bitmap in KFB GC. 186 * 187 * @param arg KFB 188 * @param params Bitmap params 189 * @param alloc Bitmap allocation info or @c NULL 190 * @param rbm Place to store pointer to new bitmap 191 * @return EOK on success or an error code 192 */ 193 errno_t kfb_gc_bitmap_create(void *arg, gfx_bitmap_params_t *params, 194 gfx_bitmap_alloc_t *alloc, void **rbm) 195 { 196 kfb_t *kfb = (kfb_t *) arg; 197 kfb_bitmap_t *kfbbm = NULL; 198 gfx_coord2_t dim; 97 199 errno_t rc; 98 200 99 if (vs->mode_set) { 100 vs->ops.handle_damage = NULL; 101 } 102 103 rc = physmem_unmap(kfb.addr); 104 if (rc != EOK) 105 return rc; 106 107 kfb.addr = NULL; 108 return EOK; 109 } 110 111 static errno_t kfb_handle_damage_pixels(visualizer_t *vs, 112 sysarg_t x0, sysarg_t y0, sysarg_t width, sysarg_t height, 113 sysarg_t x_offset, sysarg_t y_offset) 114 { 115 pixelmap_t *map = &vs->cells; 116 117 if (x_offset == 0 && y_offset == 0) { 118 /* Faster damage routine ignoring offsets. */ 119 for (sysarg_t y = y0; y < height + y0; ++y) { 120 pixel_t *pixel = pixelmap_pixel_at(map, x0, y); 121 for (sysarg_t x = x0; x < width + x0; ++x) { 122 kfb.pixel2visual(kfb.addr + FB_POS(x, y), *pixel++); 201 /* Check that we support all required flags */ 202 if ((params->flags & ~bmpf_color_key) != 0) 203 return ENOTSUP; 204 205 kfbbm = calloc(1, sizeof(kfb_bitmap_t)); 206 if (kfbbm == NULL) 207 return ENOMEM; 208 209 gfx_coord2_subtract(¶ms->rect.p1, ¶ms->rect.p0, &dim); 210 kfbbm->rect = params->rect; 211 kfbbm->flags = params->flags; 212 kfbbm->key_color = params->key_color; 213 214 if (alloc == NULL) { 215 kfbbm->alloc.pitch = dim.x * sizeof(uint32_t); 216 kfbbm->alloc.off0 = 0; 217 kfbbm->alloc.pixels = malloc(kfbbm->alloc.pitch * dim.y); 218 kfbbm->myalloc = true; 219 220 if (kfbbm->alloc.pixels == NULL) { 221 rc = ENOMEM; 222 goto error; 223 } 224 } else { 225 kfbbm->alloc = *alloc; 226 } 227 228 kfbbm->kfb = kfb; 229 *rbm = (void *)kfbbm; 230 return EOK; 231 error: 232 if (rbm != NULL) 233 free(kfbbm); 234 return rc; 235 } 236 237 /** Destroy bitmap in KFB GC. 238 * 239 * @param bm Bitmap 240 * @return EOK on success or an error code 241 */ 242 static errno_t kfb_gc_bitmap_destroy(void *bm) 243 { 244 kfb_bitmap_t *kfbbm = (kfb_bitmap_t *)bm; 245 if (kfbbm->myalloc) 246 free(kfbbm->alloc.pixels); 247 free(kfbbm); 248 return EOK; 249 } 250 251 /** Render bitmap in KFB GC. 252 * 253 * @param bm Bitmap 254 * @param srect0 Source rectangle or @c NULL 255 * @param offs0 Offset or @c NULL 256 * @return EOK on success or an error code 257 */ 258 static errno_t kfb_gc_bitmap_render(void *bm, gfx_rect_t *srect0, 259 gfx_coord2_t *offs0) 260 { 261 kfb_bitmap_t *kfbbm = (kfb_bitmap_t *)bm; 262 kfb_t *kfb = kfbbm->kfb; 263 gfx_rect_t srect; 264 gfx_rect_t drect; 265 gfx_rect_t skfbrect; 266 gfx_rect_t crect; 267 gfx_coord2_t offs; 268 gfx_coord2_t bmdim; 269 gfx_coord2_t dim; 270 gfx_coord2_t sp; 271 gfx_coord2_t dp; 272 gfx_coord2_t pos; 273 pixelmap_t pbm; 274 pixel_t color; 275 276 /* Clip source rectangle to bitmap bounds */ 277 278 if (srect0 != NULL) 279 gfx_rect_clip(srect0, &kfbbm->rect, &srect); 280 else 281 srect = kfbbm->rect; 282 283 if (offs0 != NULL) { 284 offs = *offs0; 285 } else { 286 offs.x = 0; 287 offs.y = 0; 288 } 289 290 /* Destination rectangle */ 291 gfx_rect_translate(&offs, &srect, &drect); 292 gfx_coord2_subtract(&drect.p1, &drect.p0, &dim); 293 gfx_coord2_subtract(&kfbbm->rect.p1, &kfbbm->rect.p0, &bmdim); 294 295 pbm.width = bmdim.x; 296 pbm.height = bmdim.y; 297 pbm.data = kfbbm->alloc.pixels; 298 299 /* Transform KFB bounding rectangle back to bitmap coordinate system */ 300 gfx_rect_rtranslate(&offs, &kfb->rect, &skfbrect); 301 302 /* 303 * Make sure we have a sorted source rectangle, clipped so that 304 * destination lies within KFB bounding rectangle 305 */ 306 gfx_rect_clip(&srect, &skfbrect, &crect); 307 308 if ((kfbbm->flags & bmpf_color_key) != 0) { 309 for (pos.y = crect.p0.y; pos.y < crect.p1.y; pos.y++) { 310 for (pos.x = crect.p0.x; pos.x < crect.p1.x; pos.x++) { 311 gfx_coord2_subtract(&pos, &kfbbm->rect.p0, &sp); 312 gfx_coord2_add(&pos, &offs, &dp); 313 314 color = pixelmap_get_pixel(&pbm, sp.x, sp.y); 315 if (color != kfbbm->key_color) { 316 kfb->pixel2visual(kfb->addr + 317 FB_POS(kfb, dp.x, dp.y), color); 318 } 123 319 } 124 320 } 125 321 } else { 126 for (sysarg_t y = y0; y < height + y0; ++y) { 127 for (sysarg_t x = x0; x < width + x0; ++x) { 128 kfb.pixel2visual(kfb.addr + FB_POS(x, y), 129 *pixelmap_pixel_at(map, 130 (x + x_offset) % map->width, 131 (y + y_offset) % map->height)); 322 for (pos.y = crect.p0.y; pos.y < crect.p1.y; pos.y++) { 323 for (pos.x = crect.p0.x; pos.x < crect.p1.x; pos.x++) { 324 gfx_coord2_subtract(&pos, &kfbbm->rect.p0, &sp); 325 gfx_coord2_add(&pos, &offs, &dp); 326 327 color = pixelmap_get_pixel(&pbm, sp.x, sp.y); 328 kfb->pixel2visual(kfb->addr + 329 FB_POS(kfb, dp.x, dp.y), color); 132 330 } 133 331 } … … 137 335 } 138 336 139 static errno_t kfb_change_mode(visualizer_t *vs, vslmode_t new_mode) 140 { 141 vs->ops.handle_damage = kfb_handle_damage_pixels; 142 return EOK; 143 } 144 145 static errno_t kfb_suspend(visualizer_t *vs) 146 { 147 return EOK; 148 } 149 150 static errno_t kfb_wakeup(visualizer_t *vs) 151 { 152 return EOK; 153 } 154 155 static visualizer_ops_t kfb_ops = { 156 .claim = kfb_claim, 157 .yield = kfb_yield, 158 .change_mode = kfb_change_mode, 159 .handle_damage = NULL, 160 .suspend = kfb_suspend, 161 .wakeup = kfb_wakeup 162 }; 163 164 static void graph_vsl_connection(ipc_call_t *icall, void *arg) 165 { 166 visualizer_t *vsl; 337 /** Get allocation info for bitmap in KFB GC. 338 * 339 * @param bm Bitmap 340 * @param alloc Place to store allocation info 341 * @return EOK on success or an error code 342 */ 343 static errno_t kfb_gc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc) 344 { 345 kfb_bitmap_t *kfbbm = (kfb_bitmap_t *)bm; 346 *alloc = kfbbm->alloc; 347 return EOK; 348 } 349 350 #include <stdio.h> 351 static void kfb_client_conn(ipc_call_t *icall, void *arg) 352 { 353 kfb_t *kfb; 354 ddev_srv_t srv; 355 sysarg_t gc_id; 356 gfx_context_t *gc; 167 357 errno_t rc; 168 358 169 vsl = (visualizer_t *) ddf_fun_data_get((ddf_fun_t *)arg); 170 graph_visualizer_connection(vsl, icall, NULL); 171 172 if (kfb.addr != NULL) { 173 rc = physmem_unmap(kfb.addr); 359 kfb = (kfb_t *) ddf_fun_data_get((ddf_fun_t *) arg); 360 361 printf("kfb_client_conn arg2=%lu arg3=%lu arg4=%lu\n", 362 (unsigned long) ipc_get_arg2(icall), 363 (unsigned long) ipc_get_arg3(icall), 364 (unsigned long) ipc_get_arg4(icall)); 365 366 gc_id = ipc_get_arg3(icall); 367 368 if (gc_id == 0) { 369 /* Set up protocol structure */ 370 ddev_srv_initialize(&srv); 371 srv.ops = &kfb_ddev_ops; 372 srv.arg = kfb; 373 374 /* Handle connection */ 375 ddev_conn(icall, &srv); 376 } else { 377 assert(gc_id == 42); 378 379 if (kfb->addr != AS_AREA_ANY) { 380 /* This means there already is a GC connection */ 381 async_answer_0(icall, EBUSY); 382 return; 383 } 384 385 rc = physmem_map(kfb->paddr + kfb->offset, 386 ALIGN_UP(kfb->size, PAGE_SIZE) >> PAGE_WIDTH, 387 AS_AREA_READ | AS_AREA_WRITE, (void *) &kfb->addr); 388 if (rc != EOK) 389 goto error; 390 391 rc = gfx_context_new(&kfb_gc_ops, kfb, &gc); 392 if (rc != EOK) 393 goto error; 394 395 /* GC connection */ 396 gc_conn(icall, gc); 397 398 rc = physmem_unmap(kfb->addr); 174 399 if (rc == EOK) 175 kfb.addr = NULL; 176 } 400 kfb->addr = AS_AREA_ANY; 401 } 402 403 return; 404 error: 405 if (kfb->addr != AS_AREA_ANY) { 406 if (physmem_unmap(kfb->addr) == EOK) 407 kfb->addr = AS_AREA_ANY; 408 } 409 410 async_answer_0(icall, rc); 177 411 } 178 412 179 413 errno_t port_init(ddf_dev_t *dev) 180 414 { 415 ddf_fun_t *fun = NULL; 416 kfb_t *kfb = NULL; 417 errno_t rc; 418 419 fun = ddf_fun_create(dev, fun_exposed, "kfb"); 420 if (fun == NULL) { 421 rc = ENOMEM; 422 goto error; 423 } 424 425 ddf_fun_set_conn_handler(fun, &kfb_client_conn); 426 427 kfb = ddf_fun_data_alloc(fun, sizeof(kfb_t)); 428 if (kfb == NULL) { 429 rc = ENOMEM; 430 goto error; 431 } 432 181 433 sysarg_t present; 182 errno_trc = sysinfo_get_value("fb", &present);434 rc = sysinfo_get_value("fb", &present); 183 435 if (rc != EOK) 184 436 present = false; 185 437 186 if (!present) 187 return ENOENT; 438 if (!present) { 439 ddf_fun_destroy(fun); 440 rc = ENOENT; 441 goto error; 442 } 188 443 189 444 sysarg_t kind; … … 192 447 kind = (sysarg_t) -1; 193 448 194 if (kind != 1) 195 return EINVAL; 449 if (kind != 1) { 450 rc = EINVAL; 451 goto error; 452 } 196 453 197 454 sysarg_t paddr; 198 455 rc = sysinfo_get_value("fb.address.physical", &paddr); 199 456 if (rc != EOK) 200 return rc;457 goto error; 201 458 202 459 sysarg_t offset; … … 208 465 rc = sysinfo_get_value("fb.width", &width); 209 466 if (rc != EOK) 210 return rc;467 goto error; 211 468 212 469 sysarg_t height; 213 470 rc = sysinfo_get_value("fb.height", &height); 214 471 if (rc != EOK) 215 return rc;472 goto error; 216 473 217 474 sysarg_t scanline; 218 475 rc = sysinfo_get_value("fb.scanline", &scanline); 219 476 if (rc != EOK) 220 return rc;477 goto error; 221 478 222 479 sysarg_t visual; 223 480 rc = sysinfo_get_value("fb.visual", &visual); 224 481 if (rc != EOK) 225 return rc; 226 227 kfb.width = width; 228 kfb.height = height; 229 kfb.paddr = paddr; 230 kfb.offset = offset; 231 kfb.scanline = scanline; 232 kfb.visual = visual; 482 goto error; 483 484 kfb->fun = fun; 485 486 kfb->rect.p0.x = 0; 487 kfb->rect.p0.y = 0; 488 kfb->rect.p1.x = width; 489 kfb->rect.p1.y = height; 490 491 kfb->paddr = paddr; 492 kfb->offset = offset; 493 kfb->scanline = scanline; 494 kfb->visual = visual; 233 495 234 496 switch (visual) { 235 497 case VISUAL_INDIRECT_8: 236 kfb .pixel2visual = pixel2bgr_323;237 kfb .visual2pixel = bgr_323_2pixel;238 kfb .visual_mask = visual_mask_323;239 kfb .pixel_bytes = 1;498 kfb->pixel2visual = pixel2bgr_323; 499 kfb->visual2pixel = bgr_323_2pixel; 500 kfb->visual_mask = visual_mask_323; 501 kfb->pixel_bytes = 1; 240 502 break; 241 503 case VISUAL_RGB_5_5_5_LE: 242 kfb .pixel2visual = pixel2rgb_555_le;243 kfb .visual2pixel = rgb_555_le_2pixel;244 kfb .visual_mask = visual_mask_555;245 kfb .pixel_bytes = 2;504 kfb->pixel2visual = pixel2rgb_555_le; 505 kfb->visual2pixel = rgb_555_le_2pixel; 506 kfb->visual_mask = visual_mask_555; 507 kfb->pixel_bytes = 2; 246 508 break; 247 509 case VISUAL_RGB_5_5_5_BE: 248 kfb .pixel2visual = pixel2rgb_555_be;249 kfb .visual2pixel = rgb_555_be_2pixel;250 kfb .visual_mask = visual_mask_555;251 kfb .pixel_bytes = 2;510 kfb->pixel2visual = pixel2rgb_555_be; 511 kfb->visual2pixel = rgb_555_be_2pixel; 512 kfb->visual_mask = visual_mask_555; 513 kfb->pixel_bytes = 2; 252 514 break; 253 515 case VISUAL_RGB_5_6_5_LE: 254 kfb .pixel2visual = pixel2rgb_565_le;255 kfb .visual2pixel = rgb_565_le_2pixel;256 kfb .visual_mask = visual_mask_565;257 kfb .pixel_bytes = 2;516 kfb->pixel2visual = pixel2rgb_565_le; 517 kfb->visual2pixel = rgb_565_le_2pixel; 518 kfb->visual_mask = visual_mask_565; 519 kfb->pixel_bytes = 2; 258 520 break; 259 521 case VISUAL_RGB_5_6_5_BE: 260 kfb .pixel2visual = pixel2rgb_565_be;261 kfb .visual2pixel = rgb_565_be_2pixel;262 kfb .visual_mask = visual_mask_565;263 kfb .pixel_bytes = 2;522 kfb->pixel2visual = pixel2rgb_565_be; 523 kfb->visual2pixel = rgb_565_be_2pixel; 524 kfb->visual_mask = visual_mask_565; 525 kfb->pixel_bytes = 2; 264 526 break; 265 527 case VISUAL_RGB_8_8_8: 266 kfb .pixel2visual = pixel2rgb_888;267 kfb .visual2pixel = rgb_888_2pixel;268 kfb .visual_mask = visual_mask_888;269 kfb .pixel_bytes = 3;528 kfb->pixel2visual = pixel2rgb_888; 529 kfb->visual2pixel = rgb_888_2pixel; 530 kfb->visual_mask = visual_mask_888; 531 kfb->pixel_bytes = 3; 270 532 break; 271 533 case VISUAL_BGR_8_8_8: 272 kfb .pixel2visual = pixel2bgr_888;273 kfb .visual2pixel = bgr_888_2pixel;274 kfb .visual_mask = visual_mask_888;275 kfb .pixel_bytes = 3;534 kfb->pixel2visual = pixel2bgr_888; 535 kfb->visual2pixel = bgr_888_2pixel; 536 kfb->visual_mask = visual_mask_888; 537 kfb->pixel_bytes = 3; 276 538 break; 277 539 case VISUAL_RGB_8_8_8_0: 278 kfb .pixel2visual = pixel2rgb_8880;279 kfb .visual2pixel = rgb_8880_2pixel;280 kfb .visual_mask = visual_mask_8880;281 kfb .pixel_bytes = 4;540 kfb->pixel2visual = pixel2rgb_8880; 541 kfb->visual2pixel = rgb_8880_2pixel; 542 kfb->visual_mask = visual_mask_8880; 543 kfb->pixel_bytes = 4; 282 544 break; 283 545 case VISUAL_RGB_0_8_8_8: 284 kfb .pixel2visual = pixel2rgb_0888;285 kfb .visual2pixel = rgb_0888_2pixel;286 kfb .visual_mask = visual_mask_0888;287 kfb .pixel_bytes = 4;546 kfb->pixel2visual = pixel2rgb_0888; 547 kfb->visual2pixel = rgb_0888_2pixel; 548 kfb->visual_mask = visual_mask_0888; 549 kfb->pixel_bytes = 4; 288 550 break; 289 551 case VISUAL_BGR_0_8_8_8: 290 kfb .pixel2visual = pixel2bgr_0888;291 kfb .visual2pixel = bgr_0888_2pixel;292 kfb .visual_mask = visual_mask_0888;293 kfb .pixel_bytes = 4;552 kfb->pixel2visual = pixel2bgr_0888; 553 kfb->visual2pixel = bgr_0888_2pixel; 554 kfb->visual_mask = visual_mask_0888; 555 kfb->pixel_bytes = 4; 294 556 break; 295 557 case VISUAL_BGR_8_8_8_0: 296 kfb .pixel2visual = pixel2bgr_8880;297 kfb .visual2pixel = bgr_8880_2pixel;298 kfb .visual_mask = visual_mask_8880;299 kfb .pixel_bytes = 4;558 kfb->pixel2visual = pixel2bgr_8880; 559 kfb->visual2pixel = bgr_8880_2pixel; 560 kfb->visual_mask = visual_mask_8880; 561 kfb->pixel_bytes = 4; 300 562 break; 301 563 default: … … 303 565 } 304 566 305 kfb.size = scanline * height; 306 kfb.addr = AS_AREA_ANY; 307 308 ddf_fun_t *fun_vs = ddf_fun_create(dev, fun_exposed, "vsl0"); 309 if (fun_vs == NULL) { 310 as_area_destroy(kfb.addr); 311 return ENOMEM; 312 } 313 ddf_fun_set_conn_handler(fun_vs, &graph_vsl_connection); 314 315 visualizer_t *vs = ddf_fun_data_alloc(fun_vs, sizeof(visualizer_t)); 316 if (vs == NULL) { 317 as_area_destroy(kfb.addr); 318 return ENOMEM; 319 } 320 graph_init_visualizer(vs); 321 322 pixel_mode.mode.index = 0; 323 pixel_mode.mode.version = 0; 324 pixel_mode.mode.refresh_rate = 0; 325 pixel_mode.mode.screen_aspect.width = width; 326 pixel_mode.mode.screen_aspect.height = height; 327 pixel_mode.mode.screen_width = width; 328 pixel_mode.mode.screen_height = height; 329 pixel_mode.mode.cell_aspect.width = 1; 330 pixel_mode.mode.cell_aspect.height = 1; 331 pixel_mode.mode.cell_visual.pixel_visual = visual; 332 333 link_initialize(&pixel_mode.link); 334 list_append(&pixel_mode.link, &vs->modes); 335 336 vs->def_mode_idx = 0; 337 338 vs->ops = kfb_ops; 339 vs->dev_ctx = NULL; 340 341 rc = ddf_fun_bind(fun_vs); 567 kfb->size = scanline * height; 568 kfb->addr = AS_AREA_ANY; 569 570 rc = ddf_fun_bind(fun); 571 if (rc != EOK) 572 goto error; 573 574 rc = ddf_fun_add_to_category(fun, "display-device"); 342 575 if (rc != EOK) { 343 list_remove(&pixel_mode.link); 344 ddf_fun_destroy(fun_vs); 345 as_area_destroy(kfb.addr); 346 return rc; 347 } 348 349 vs->reg_svc_handle = ddf_fun_get_handle(fun_vs); 350 rc = ddf_fun_add_to_category(fun_vs, "visualizer"); 351 if (rc != EOK) { 352 list_remove(&pixel_mode.link); 353 ddf_fun_unbind(fun_vs); 354 ddf_fun_destroy(fun_vs); 355 as_area_destroy(kfb.addr); 356 return rc; 357 } 358 359 return EOK; 576 ddf_fun_unbind(fun); 577 goto error; 578 } 579 580 return EOK; 581 error: 582 if (fun != NULL) 583 ddf_fun_destroy(fun); 584 return rc; 360 585 } 361 586
Note:
See TracChangeset
for help on using the changeset viewer.
