Changeset 1d2a1a9 in mainline for uspace/srv/hid
- Timestamp:
- 2011-08-17T20:44:32Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0cc32f2
- Parents:
- bb285b4 (diff), c53a705 (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/srv/hid
- Files:
-
- 10 added
- 11 deleted
- 19 edited
-
console/Makefile (modified) (1 diff)
-
console/console.c (modified) (6 diffs)
-
console/gcons.c (modified) (14 diffs)
-
console/gfx/anim_1.ppm (deleted)
-
console/gfx/anim_1.tga (added)
-
console/gfx/anim_2.ppm (deleted)
-
console/gfx/anim_2.tga (added)
-
console/gfx/anim_3.ppm (deleted)
-
console/gfx/anim_3.tga (added)
-
console/gfx/anim_4.ppm (deleted)
-
console/gfx/anim_4.tga (added)
-
console/gfx/cons_has_data.ppm (deleted)
-
console/gfx/cons_has_data.tga (added)
-
console/gfx/cons_idle.ppm (deleted)
-
console/gfx/cons_idle.tga (added)
-
console/gfx/cons_kernel.ppm (deleted)
-
console/gfx/cons_kernel.tga (added)
-
console/gfx/cons_selected.ppm (deleted)
-
console/gfx/cons_selected.tga (added)
-
console/gfx/helenos.ppm (deleted)
-
console/gfx/helenos.tga (added)
-
console/gfx/nameic.ppm (deleted)
-
console/gfx/nameic.tga (added)
-
fb/Makefile (modified) (2 diffs)
-
fb/ega.c (modified) (2 diffs)
-
fb/fb.c (modified) (30 diffs)
-
fb/fb.h (modified) (1 diff)
-
fb/ppm.c (deleted)
-
fb/serial_console.c (modified) (1 diff)
-
input/ctl/kbdev.c (modified) (7 diffs)
-
input/generic/input.c (modified) (15 diffs)
-
input/include/kbd.h (modified) (2 diffs)
-
input/include/mouse.h (modified) (2 diffs)
-
input/port/adb.c (modified) (3 diffs)
-
input/port/adb_mouse.c (modified) (2 diffs)
-
input/port/chardev.c (modified) (4 diffs)
-
input/port/chardev_mouse.c (modified) (4 diffs)
-
input/proto/mousedev.c (modified) (7 diffs)
-
s3c24xx_ts/s3c24xx_ts.c (modified) (4 diffs)
-
s3c24xx_ts/s3c24xx_ts.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/Makefile
rbb285b4 r1d2a1a9 29 29 30 30 USPACE_PREFIX = ../../.. 31 LIBS = $(LIBIMGMAP_PREFIX)/libimgmap.a 32 EXTRA_CFLAGS += -I$(LIBIMGMAP_PREFIX) 31 33 BINARY = console 32 34 33 GENERIC_SOURCES = \35 SOURCES = \ 34 36 console.c \ 35 37 keybuffer.c \ 38 images.c \ 36 39 gcons.c 37 40 38 41 IMAGES = \ 39 gfx/helenos. ppm\40 gfx/nameic. ppm\41 gfx/cons_selected. ppm\42 gfx/cons_idle. ppm\43 gfx/cons_has_data. ppm\44 gfx/cons_kernel. ppm\45 gfx/anim_1. ppm\46 gfx/anim_2. ppm\47 gfx/anim_3. ppm\48 gfx/anim_4. ppm42 gfx/helenos.tga \ 43 gfx/nameic.tga \ 44 gfx/cons_selected.tga \ 45 gfx/cons_idle.tga \ 46 gfx/cons_has_data.tga \ 47 gfx/cons_kernel.tga \ 48 gfx/anim_1.tga \ 49 gfx/anim_2.tga \ 50 gfx/anim_3.tga \ 51 gfx/anim_4.tga 49 52 50 SOURCES = \ 51 $(GENERIC_SOURCES) \ 52 $(IMAGES) 53 PRE_DEPEND = images.c images.h 54 EXTRA_CLEAN = images.c images.h 53 55 54 56 include $(USPACE_PREFIX)/Makefile.common 55 57 56 %.o: %.ppm 57 $( OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) $< $@58 images.c images.h: $(IMAGES) 59 $(ROOT_PATH)/tools/mkarray.py images CONSOLE_IMAGES $^ -
uspace/srv/hid/console/console.c
rbb285b4 r1d2a1a9 53 53 #include <sysinfo.h> 54 54 #include <event.h> 55 #include < devmap.h>55 #include <loc.h> 56 56 #include <fcntl.h> 57 57 #include <vfs/vfs.h> … … 81 81 size_t index; /**< Console index */ 82 82 size_t refcount; /**< Connection reference count */ 83 devmap_handle_t devmap_handle; /**< Device handle*/83 service_id_t service_id; /**< Service ID */ 84 84 keybuffer_t keybuffer; /**< Buffer for incoming keys. */ 85 85 screenbuffer_t scr; /**< Screenbuffer for saving screen … … 582 582 continue; 583 583 584 if (consoles[i]. devmap_handle == (devmap_handle_t) IPC_GET_ARG1(*icall)) {584 if (consoles[i].service_id == (service_id_t) IPC_GET_ARG1(*icall)) { 585 585 cons = &consoles[i]; 586 586 break; … … 721 721 } 722 722 723 static async_sess_t *connect_input(const char * dev_path)723 static async_sess_t *connect_input(const char *svc_path) 724 724 { 725 725 async_sess_t *sess; 726 726 async_exch_t *exch; 727 devmap_handle_t handle;728 729 int rc = devmap_device_get_handle(dev_path, &handle, 0);727 service_id_t service_id; 728 729 int rc = loc_service_get_id(svc_path, &service_id, 0); 730 730 if (rc == EOK) { 731 sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);731 sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0); 732 732 if (sess == NULL) { 733 733 printf("%s: Failed to connect to input server\n", NAME); … … 773 773 } 774 774 775 /* Register driver */776 int rc = devmap_driver_register(NAME, client_connection);775 /* Register server */ 776 int rc = loc_server_register(NAME, client_connection); 777 777 if (rc < 0) { 778 printf("%s: Unable to register driver (%d)\n", NAME, rc);778 printf("%s: Unable to register server (%d)\n", NAME, rc); 779 779 return false; 780 780 } … … 820 820 consoles[i].refcount = 0; 821 821 822 char vc[ DEVMAP_NAME_MAXLEN + 1];823 snprintf(vc, DEVMAP_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);822 char vc[LOC_NAME_MAXLEN + 1]; 823 snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i); 824 824 825 if ( devmap_device_register(vc, &consoles[i].devmap_handle) != EOK) {826 printf("%s: Unable to register device %s\n", NAME, vc);825 if (loc_service_register(vc, &consoles[i].service_id) != EOK) { 826 printf("%s: Unable to register service %s\n", NAME, vc); 827 827 return false; 828 828 } -
uspace/srv/hid/console/gcons.c
rbb285b4 r1d2a1a9 41 41 #include <align.h> 42 42 #include <bool.h> 43 #include <imgmap.h> 43 44 44 45 #include "console.h" 45 46 #include "gcons.h" 47 #include "images.h" 46 48 47 49 #define CONSOLE_TOP 66 … … 58 60 #define COLOR_BACKGROUND 0xffffff 59 61 60 extern char _binary_gfx_helenos_ppm_start[0];61 extern int _binary_gfx_helenos_ppm_size;62 extern char _binary_gfx_nameic_ppm_start[0];63 extern int _binary_gfx_nameic_ppm_size;64 65 extern char _binary_gfx_anim_1_ppm_start[0];66 extern int _binary_gfx_anim_1_ppm_size;67 extern char _binary_gfx_anim_2_ppm_start[0];68 extern int _binary_gfx_anim_2_ppm_size;69 extern char _binary_gfx_anim_3_ppm_start[0];70 extern int _binary_gfx_anim_3_ppm_size;71 extern char _binary_gfx_anim_4_ppm_start[0];72 extern int _binary_gfx_anim_4_ppm_size;73 74 extern char _binary_gfx_cons_selected_ppm_start[0];75 extern int _binary_gfx_cons_selected_ppm_size;76 extern char _binary_gfx_cons_idle_ppm_start[0];77 extern int _binary_gfx_cons_idle_ppm_size;78 extern char _binary_gfx_cons_has_data_ppm_start[0];79 extern int _binary_gfx_cons_has_data_ppm_size;80 extern char _binary_gfx_cons_kernel_ppm_start[0];81 extern int _binary_gfx_cons_kernel_ppm_size;82 83 62 static bool use_gcons = false; 84 63 static sysarg_t xres; 85 64 static sysarg_t yres; 65 66 static imgmap_t *helenos_img; 67 static imgmap_t *nameic_img; 68 69 static imgmap_t *anim_1_img; 70 static imgmap_t *anim_2_img; 71 static imgmap_t *anim_3_img; 72 static imgmap_t *anim_4_img; 73 74 static imgmap_t *cons_has_data_img; 75 static imgmap_t *cons_idle_img; 76 static imgmap_t *cons_kernel_img; 77 static imgmap_t *cons_selected_img; 86 78 87 79 enum butstate { … … 101 93 static int fbphone; 102 94 103 /** List of pixmaps identifying these icons */104 static int ic_ pixmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};95 /** List of image maps identifying these icons */ 96 static int ic_imgmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1}; 105 97 static int animation = -1; 106 98 … … 149 141 enum butstate state = console_state[index]; 150 142 151 if (ic_ pixmaps[state] != -1)152 async_obsolete_msg_2(fbphone, FB_VP_DRAW_ PIXMAP, cstatus_vp[index],153 ic_ pixmaps[state]);143 if (ic_imgmaps[state] != -1) 144 async_obsolete_msg_2(fbphone, FB_VP_DRAW_IMGMAP, cstatus_vp[index], 145 ic_imgmaps[state]); 154 146 155 147 if ((state != CONS_DISCONNECTED) && (state != CONS_KERNEL) … … 358 350 } 359 351 360 /** Draw a PPM pixmap to framebuffer 361 * 362 * @param logo Pointer to PPM data 363 * @param size Size of PPM data 364 * @param x Coordinate of upper left corner 365 * @param y Coordinate of upper left corner 366 * 367 */ 368 static void draw_pixmap(char *logo, size_t size, sysarg_t x, sysarg_t y) 369 { 352 /** Draw an image map to framebuffer 353 * 354 * @param img Image map 355 * @param x Coordinate of upper left corner 356 * @param y Coordinate of upper left corner 357 * 358 */ 359 static void draw_imgmap(imgmap_t *img, sysarg_t x, sysarg_t y) 360 { 361 if (img == NULL) 362 return; 363 370 364 /* Create area */ 371 char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |365 char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE, MAP_SHARED | 372 366 MAP_ANONYMOUS, 0, 0); 373 367 if (shm == MAP_FAILED) 374 368 return; 375 369 376 memcpy(shm, logo,size);370 memcpy(shm, img, img->size); 377 371 378 372 /* Send area */ … … 386 380 387 381 /* Draw logo */ 388 async_obsolete_msg_2(fbphone, FB_DRAW_ PPM, x, y);382 async_obsolete_msg_2(fbphone, FB_DRAW_IMGMAP, x, y); 389 383 390 384 drop: … … 394 388 exit: 395 389 /* Remove area */ 396 munmap(shm, size);390 munmap(shm, img->size); 397 391 } 398 392 … … 406 400 set_rgb_color(COLOR_MAIN, COLOR_MAIN); 407 401 clear(); 408 draw_pixmap(_binary_gfx_helenos_ppm_start, 409 (size_t) &_binary_gfx_helenos_ppm_size, xres - 66, 2); 410 draw_pixmap(_binary_gfx_nameic_ppm_start, 411 (size_t) &_binary_gfx_nameic_ppm_size, 5, 17); 402 draw_imgmap(helenos_img, xres - 66, 2); 403 draw_imgmap(nameic_img, 5, 17); 412 404 413 405 unsigned int i; … … 418 410 } 419 411 420 /** Creates a pixmap on framebuffer 421 * 422 * @param data PPM data 423 * @param size PPM data size 424 * 425 * @return Pixmap identification 426 * 427 */ 428 static int make_pixmap(char *data, size_t size) 429 { 412 /** Create an image map on framebuffer 413 * 414 * @param img Image map. 415 * 416 * @return Image map identification 417 * 418 */ 419 static int make_imgmap(imgmap_t *img) 420 { 421 if (img == NULL) 422 return -1; 423 430 424 /* Create area */ 431 char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |432 MAP_ ANONYMOUS, 0, 0);425 char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE, 426 MAP_SHARED | MAP_ANONYMOUS, 0, 0); 433 427 if (shm == MAP_FAILED) 434 428 return -1; 435 429 436 memcpy(shm, data,size);437 438 int pxid = -1;430 memcpy(shm, img, img->size); 431 432 int id = -1; 439 433 440 434 /* Send area */ … … 447 441 goto drop; 448 442 449 /* Obtain pixmap*/450 rc = async_obsolete_req_0_0(fbphone, FB_SHM2 PIXMAP);443 /* Obtain image map identifier */ 444 rc = async_obsolete_req_0_0(fbphone, FB_SHM2IMGMAP); 451 445 if (rc < 0) 452 446 goto drop; 453 447 454 pxid = rc;448 id = rc; 455 449 456 450 drop: … … 460 454 exit: 461 455 /* Remove area */ 462 munmap(shm, size);463 464 return pxid;456 munmap(shm, img->size); 457 458 return id; 465 459 } 466 460 … … 472 466 return; 473 467 474 int pm = make_pixmap(_binary_gfx_anim_1_ppm_start, 475 (size_t) &_binary_gfx_anim_1_ppm_size); 476 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 477 478 pm = make_pixmap(_binary_gfx_anim_2_ppm_start, 479 (size_t) &_binary_gfx_anim_2_ppm_size); 480 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 481 482 pm = make_pixmap(_binary_gfx_anim_3_ppm_start, 483 (size_t) &_binary_gfx_anim_3_ppm_size); 484 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 485 486 pm = make_pixmap(_binary_gfx_anim_4_ppm_start, 487 (size_t) &_binary_gfx_anim_4_ppm_size); 488 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 468 int pm = make_imgmap(anim_1_img); 469 async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm); 470 471 pm = make_imgmap(anim_2_img); 472 async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm); 473 474 pm = make_imgmap(anim_3_img); 475 async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm); 476 477 pm = make_imgmap(anim_4_img); 478 async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm); 489 479 490 480 async_obsolete_msg_1(fbphone, FB_ANIM_START, an); … … 504 494 if ((xres < 800) || (yres < 600)) 505 495 return; 496 497 /* Create image maps */ 498 helenos_img = imgmap_decode_tga((void *) helenos_tga, 499 helenos_tga_size); 500 nameic_img = imgmap_decode_tga((void *) nameic_tga, 501 nameic_tga_size); 502 503 anim_1_img = imgmap_decode_tga((void *) anim_1_tga, 504 anim_1_tga_size); 505 anim_2_img = imgmap_decode_tga((void *) anim_2_tga, 506 anim_2_tga_size); 507 anim_3_img = imgmap_decode_tga((void *) anim_3_tga, 508 anim_3_tga_size); 509 anim_4_img = imgmap_decode_tga((void *) anim_4_tga, 510 anim_4_tga_size); 511 512 cons_has_data_img = imgmap_decode_tga((void *) cons_has_data_tga, 513 cons_has_data_tga_size); 514 cons_idle_img = imgmap_decode_tga((void *) cons_idle_tga, 515 cons_idle_tga_size); 516 cons_kernel_img = imgmap_decode_tga((void *) cons_kernel_tga, 517 cons_kernel_tga_size); 518 cons_selected_img = imgmap_decode_tga((void *) cons_selected_tga, 519 cons_selected_tga_size); 506 520 507 521 /* Create console viewport */ … … 531 545 532 546 /* Initialize icons */ 533 ic_pixmaps[CONS_SELECTED] = 534 make_pixmap(_binary_gfx_cons_selected_ppm_start, 535 (size_t) &_binary_gfx_cons_selected_ppm_size); 536 ic_pixmaps[CONS_IDLE] = 537 make_pixmap(_binary_gfx_cons_idle_ppm_start, 538 (size_t) &_binary_gfx_cons_idle_ppm_size); 539 ic_pixmaps[CONS_HAS_DATA] = 540 make_pixmap(_binary_gfx_cons_has_data_ppm_start, 541 (size_t) &_binary_gfx_cons_has_data_ppm_size); 542 ic_pixmaps[CONS_DISCONNECTED] = 543 make_pixmap(_binary_gfx_cons_idle_ppm_start, 544 (size_t) &_binary_gfx_cons_idle_ppm_size); 545 ic_pixmaps[CONS_KERNEL] = 546 make_pixmap(_binary_gfx_cons_kernel_ppm_start, 547 (size_t) &_binary_gfx_cons_kernel_ppm_size); 548 ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; 547 ic_imgmaps[CONS_SELECTED] = make_imgmap(cons_selected_img); 548 ic_imgmaps[CONS_IDLE] = make_imgmap(cons_idle_img); 549 ic_imgmaps[CONS_HAS_DATA] = make_imgmap(cons_has_data_img); 550 ic_imgmaps[CONS_DISCONNECTED] = make_imgmap(cons_idle_img); 551 ic_imgmaps[CONS_KERNEL] = make_imgmap(cons_kernel_img); 552 ic_imgmaps[CONS_DISCONNECTED_SEL] = ic_imgmaps[CONS_SELECTED]; 549 553 550 554 make_anim(); -
uspace/srv/hid/fb/Makefile
rbb285b4 r1d2a1a9 40 40 41 41 SOURCES = \ 42 main.c \ 43 ppm.c 42 main.c 44 43 45 44 ifneq ($(UARCH),ia64) … … 86 85 endif 87 86 88 EXTRA_CFLAGS += -D$(UARCH) 87 LIBS = $(LIBIMGMAP_PREFIX)/libimgmap.a 88 EXTRA_CFLAGS += -I$(LIBIMGMAP_PREFIX) -D$(UARCH) 89 89 90 90 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/hid/fb/ega.c
rbb285b4 r1d2a1a9 56 56 57 57 // FIXME: remove this header 58 #include < kernel/ipc/ipc_methods.h>58 #include <abi/ipc/methods.h> 59 59 60 60 #define MAX_SAVED_SCREENS 256 … … 414 414 retval = 0; 415 415 break; 416 case FB_VP_DRAW_ PIXMAP:416 case FB_VP_DRAW_IMGMAP: 417 417 scr = IPC_GET_ARG2(call); 418 418 retval = print_screen(scr); 419 419 break; 420 case FB_VP2 PIXMAP:420 case FB_VP2IMGMAP: 421 421 retval = save_screen(); 422 422 break; 423 case FB_DROP_ PIXMAP:423 case FB_DROP_IMGMAP: 424 424 scr = IPC_GET_ARG1(call); 425 425 -
uspace/srv/hid/fb/fb.c
rbb285b4 r1d2a1a9 49 49 #include <ipc/ns.h> 50 50 #include <ipc/services.h> 51 #include < kernel/errno.h>52 #include < kernel/genarch/fb/visuals.h>51 #include <errno.h> 52 #include <abi/fb/visuals.h> 53 53 #include <io/color.h> 54 54 #include <io/style.h> … … 59 59 #include <byteorder.h> 60 60 #include <io/screenbuffer.h> 61 #include <imgmap.h> 61 62 #include "font-8x16.h" 62 63 #include "fb.h" 63 64 #include "main.h" 64 #include "ppm.h"65 65 #include "pointer.xbm" 66 66 #include "pointer_mask.xbm" 67 67 68 68 // FIXME: remove this header 69 #include < kernel/ipc/ipc_methods.h>69 #include <abi/ipc/methods.h> 70 70 71 71 #define DEFAULT_BGCOLOR 0xf0f0f0 … … 76 76 #define MAX_ANIM_LEN 8 77 77 #define MAX_ANIMATIONS 4 78 #define MAX_ PIXMAPS 256 /**< Maximum number of saved pixmaps */78 #define MAX_IMGMAPS 256 /**< Maximum number of saved image maps */ 79 79 #define MAX_VIEWPORTS 128 /**< Viewport is a rectangular area on the screen */ 80 80 … … 160 160 unsigned int pos; 161 161 unsigned int animlen; 162 unsigned int pixmaps[MAX_ANIM_LEN];162 unsigned int imgmaps[MAX_ANIM_LEN]; 163 163 } animation_t; 164 164 … … 166 166 static bool anims_enabled; 167 167 168 typedef struct { 169 unsigned int width; 170 unsigned int height; 171 uint8_t *data; 172 } pixmap_t; 173 174 static pixmap_t pixmaps[MAX_PIXMAPS]; 168 static imgmap_t *imgmaps[MAX_IMGMAPS]; 175 169 static viewport_t viewports[128]; 176 170 … … 212 206 static void draw_vp_glyph(viewport_t *vport, bool cursor, unsigned int col, 213 207 unsigned int row); 214 215 208 216 209 #define RED(x, bits) (((x) >> (8 + 8 + 8 - (bits))) & ((1 << (bits)) - 1)) … … 875 868 } 876 869 877 878 870 /** Show cursor if cursor showing is enabled 879 871 * … … 888 880 } 889 881 890 891 882 /** Invert cursor, if it is enabled 892 883 * … … 899 890 cursor_show(vport); 900 891 } 901 902 892 903 893 /** Draw character at given position relative to viewport … … 981 971 } 982 972 983 984 static void putpixel_pixmap(void *data, unsigned int x, unsigned int y, uint32_t color) 985 { 986 int pm = *((int *) data); 987 pixmap_t *pmap = &pixmaps[pm]; 988 unsigned int pos = (y * pmap->width + x) * screen.pixelbytes; 989 990 screen.rgb_conv(&pmap->data[pos], color); 991 } 992 993 994 static void putpixel(void *data, unsigned int x, unsigned int y, uint32_t color) 995 { 996 viewport_t *vport = (viewport_t *) data; 973 static void putpixel(viewport_t *vport, unsigned int x, unsigned int y, 974 uint32_t color) 975 { 997 976 unsigned int dx = vport->x + x; 998 977 unsigned int dy = vport->y + y; … … 1001 980 } 1002 981 1003 1004 /** Return first free pixmap 1005 * 1006 */ 1007 static int find_free_pixmap(void) 982 /** Draw image map 983 * 984 * @param[in] img Image map. 985 * @param[in] sx Coordinate of upper left corner. 986 * @param[in] sy Coordinate of upper left corner. 987 * @param[in] maxwidth Maximum allowed width for picture. 988 * @param[in] maxheight Maximum allowed height for picture. 989 * @param[in] vport Viewport. 990 * 991 * @return EOK on success. 992 * 993 */ 994 static int imgmap_draw(imgmap_t *img, unsigned int sx, unsigned int sy, 995 unsigned int maxwidth, unsigned int maxheight, void *vport) 996 { 997 if (img->visual != VISUAL_BGR_8_8_8) 998 return EINVAL; 999 1000 uint8_t *data = (uint8_t *) img->data; 1001 1002 for (sysarg_t y = 0; y < img->height; y++) { 1003 for (sysarg_t x = 0; x < img->width; x++) { 1004 if ((x > maxwidth) || (y > maxheight)) { 1005 data += 3; 1006 continue; 1007 } 1008 1009 uint32_t color = (data[2] << 16) + (data[1] << 8) + data[0]; 1010 1011 putpixel(vport, sx + x, sy + y, color); 1012 data += 3; 1013 } 1014 } 1015 1016 return EOK; 1017 } 1018 1019 /** Return first free image map 1020 * 1021 */ 1022 static int find_free_imgmap(void) 1008 1023 { 1009 1024 unsigned int i; 1010 1025 1011 for (i = 0; i < MAX_ PIXMAPS; i++)1012 if (! pixmaps[i].data)1026 for (i = 0; i < MAX_IMGMAPS; i++) 1027 if (!imgmaps[i]) 1013 1028 return i; 1014 1029 … … 1016 1031 } 1017 1032 1018 1019 /** Create a new pixmap and return appropriate ID 1020 * 1021 */ 1022 static int shm2pixmap(unsigned char *shm, size_t size) 1023 { 1024 int pm; 1025 pixmap_t *pmap; 1026 1027 pm = find_free_pixmap(); 1028 if (pm == -1) 1033 /** Create a new image map and return appropriate ID 1034 * 1035 */ 1036 static int shm2imgmap(imgmap_t *shm, size_t size) 1037 { 1038 int im = find_free_imgmap(); 1039 if (im == -1) 1029 1040 return ELIMIT; 1030 1041 1031 pmap = &pixmaps[pm]; 1032 1033 if (ppm_get_data(shm, size, &pmap->width, &pmap->height)) 1034 return EINVAL; 1035 1036 pmap->data = malloc(pmap->width * pmap->height * screen.pixelbytes); 1037 if (!pmap->data) 1042 imgmap_t *imap = malloc(size); 1043 if (!imap) 1038 1044 return ENOMEM; 1039 1045 1040 ppm_draw(shm, size, 0, 0, pmap->width, pmap->height, putpixel_pixmap, (void *) &pm); 1041 1042 return pm; 1043 } 1044 1046 memcpy(imap, shm, size); 1047 imgmaps[im] = imap; 1048 return im; 1049 } 1045 1050 1046 1051 /** Handle shared memory communication calls 1047 1052 * 1048 * Protocol for drawing pixmaps:1053 * Protocol for drawing image maps: 1049 1054 * - FB_PREPARE_SHM(client shm identification) 1050 1055 * - IPC_M_AS_AREA_SEND 1051 * - FB_DRAW_ PPM(startx, starty)1056 * - FB_DRAW_IMGMAP(startx, starty) 1052 1057 * - FB_DROP_SHM 1053 1058 * … … 1071 1076 static size_t intersize = 0; 1072 1077 1073 static unsigned char*shm = NULL;1078 static imgmap_t *shm = NULL; 1074 1079 static sysarg_t shm_id = 0; 1075 1080 static size_t shm_size; … … 1093 1098 return false; 1094 1099 } 1100 1095 1101 shm = dest; 1096 1097 if (shm[0] != 'P')1098 return false;1099 1100 1102 return true; 1101 1103 } else { … … 1107 1109 if (shm_id) 1108 1110 retval = EBUSY; 1109 else 1111 else 1110 1112 shm_id = IPC_GET_ARG1(*call); 1111 1113 break; 1112 1113 1114 case FB_DROP_SHM: 1114 1115 if (shm) { … … 1118 1119 shm_id = 0; 1119 1120 break; 1120 1121 case FB_SHM2PIXMAP: 1121 case FB_SHM2IMGMAP: 1122 1122 if (!shm) { 1123 1123 retval = EINVAL; 1124 1124 break; 1125 1125 } 1126 retval = shm2 pixmap(shm, shm_size);1127 break; 1128 case FB_DRAW_ PPM:1126 retval = shm2imgmap(shm, shm_size); 1127 break; 1128 case FB_DRAW_IMGMAP: 1129 1129 if (!shm) { 1130 1130 retval = EINVAL; 1131 1131 break; 1132 1132 } 1133 1133 1134 x = IPC_GET_ARG1(*call); 1134 1135 y = IPC_GET_ARG2(*call); … … 1139 1140 } 1140 1141 1141 ppm_draw(shm, shm_size, IPC_GET_ARG1(*call),1142 IPC_GET_ARG2(*call), vport->width - x, vport->height - y, putpixel, (void *)vport);1142 imgmap_draw(shm, IPC_GET_ARG1(*call), IPC_GET_ARG2(*call), 1143 vport->width - x, vport->height - y, vport); 1143 1144 break; 1144 1145 case FB_DRAW_TEXT_DATA: … … 1167 1168 if (handled) 1168 1169 async_answer_0(callid, retval); 1170 1169 1171 return handled; 1170 1172 } 1171 1173 1172 1173 static void copy_vp_to_pixmap(viewport_t *vport, pixmap_t *pmap) 1174 static void copy_vp_to_imgmap(viewport_t *vport, imgmap_t *imap) 1174 1175 { 1175 1176 unsigned int width = vport->width; … … 1178 1179 if (width + vport->x > screen.xres) 1179 1180 width = screen.xres - vport->x; 1181 1180 1182 if (height + vport->y > screen.yres) 1181 1183 height = screen.yres - vport->y; 1182 1184 1183 unsigned int realwidth = pmap->width <= width ? pmap->width : width;1184 unsigned int realheight = pmap->height <= height ? pmap->height : height;1185 unsigned int realwidth = imap->width <= width ? imap->width : width; 1186 unsigned int realheight = imap->height <= height ? imap->height : height; 1185 1187 1186 1188 unsigned int srcrowsize = vport->width * screen.pixelbytes; … … 1190 1192 for (y = 0; y < realheight; y++) { 1191 1193 unsigned int tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes; 1192 memcpy(pmap->data + srcrowsize * y, screen.fb_addr + tmp, realrowsize); 1193 } 1194 } 1195 1196 1197 /** Save viewport to pixmap 1198 * 1199 */ 1200 static int save_vp_to_pixmap(viewport_t *vport) 1201 { 1202 int pm; 1203 pixmap_t *pmap; 1204 1205 pm = find_free_pixmap(); 1206 if (pm == -1) 1194 memcpy(imap->data + srcrowsize * y, screen.fb_addr + tmp, realrowsize); 1195 } 1196 } 1197 1198 /** Save viewport to image map 1199 * 1200 */ 1201 static int save_vp_to_imgmap(viewport_t *vport) 1202 { 1203 int im = find_free_imgmap(); 1204 if (im == -1) 1207 1205 return ELIMIT; 1208 1206 1209 pmap = &pixmaps[pm];1210 pmap->data = malloc(screen.pixelbytes * vport->width * vport->height);1211 if (! pmap->data)1207 size_t size = screen.pixelbytes * vport->width * vport->height; 1208 imgmap_t *imap = malloc(sizeof(imgmap_t) + size); 1209 if (!imap) 1212 1210 return ENOMEM; 1213 1211 1214 pmap->width = vport->width; 1215 pmap->height = vport->height; 1216 1217 copy_vp_to_pixmap(vport, pmap); 1218 1219 return pm; 1220 } 1221 1222 1223 /** Draw pixmap on screen 1224 * 1225 * @param vp Viewport to draw on 1226 * @param pm Pixmap identifier 1227 * 1228 */ 1229 static int draw_pixmap(int vp, int pm) 1230 { 1231 pixmap_t *pmap = &pixmaps[pm]; 1212 imap->size = sizeof(imgmap_t) + size; 1213 imap->width = vport->width; 1214 imap->height = vport->height; 1215 imap->visual = (visual_t) -1; 1216 1217 copy_vp_to_imgmap(vport, imap); 1218 imgmaps[im] = imap; 1219 return im; 1220 } 1221 1222 /** Draw image map to screen 1223 * 1224 * @param vp Viewport to draw to 1225 * @param im Image map identifier 1226 * 1227 */ 1228 static int draw_imgmap(int vp, int im) 1229 { 1230 imgmap_t *imap = imgmaps[im]; 1231 if (!imap) 1232 return EINVAL; 1233 1232 1234 viewport_t *vport = &viewports[vp]; 1233 1235 … … 1237 1239 if (width + vport->x > screen.xres) 1238 1240 width = screen.xres - vport->x; 1241 1239 1242 if (height + vport->y > screen.yres) 1240 1243 height = screen.yres - vport->y; 1241 1244 1242 if (!pmap->data)1243 return EINVAL;1244 1245 unsigned int realwidth = pmap->width <= width ? pmap->width : width;1246 unsigned int realheight = pmap->height <= height ? pmap->height : height;1247 1248 unsigned int srcrowsize = vport->width * screen.pixelbytes;1249 unsigned int realrowsize = realwidth * screen.pixelbytes;1250 1251 unsigned int y;1252 for (y = 0; y < realheight; y++) {1253 unsigned int tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes;1254 memcpy(screen.fb_addr + tmp, pmap->data + y * srcrowsize, realrowsize);1255 }1245 unsigned int realwidth = imap->width <= width ? imap->width : width; 1246 unsigned int realheight = imap->height <= height ? imap->height : height; 1247 1248 if (imap->visual == (visual_t) -1) { 1249 unsigned int srcrowsize = vport->width * screen.pixelbytes; 1250 unsigned int realrowsize = realwidth * screen.pixelbytes; 1251 1252 unsigned int y; 1253 for (y = 0; y < realheight; y++) { 1254 unsigned int tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes; 1255 memcpy(screen.fb_addr + tmp, imap->data + y * srcrowsize, realrowsize); 1256 } 1257 } else 1258 imgmap_draw(imap, 0, 0, realwidth, realheight, vport); 1256 1259 1257 1260 return EOK; 1258 1261 } 1259 1260 1262 1261 1263 /** Tick animation one step forward … … 1277 1279 continue; 1278 1280 1279 draw_ pixmap(animations[i].vp, animations[i].pixmaps[animations[i].pos]);1281 draw_imgmap(animations[i].vp, animations[i].imgmaps[animations[i].pos]); 1280 1282 animations[i].pos = (animations[i].pos + 1) % animations[i].animlen; 1281 1283 } … … 1287 1289 static bool pointer_shown, pointer_enabled; 1288 1290 static int pointer_vport = -1; 1289 static int pointer_ pixmap = -1;1291 static int pointer_imgmap = -1; 1290 1292 1291 1293 … … 1310 1312 } 1311 1313 1312 if (pointer_ pixmap == -1)1313 pointer_ pixmap = save_vp_to_pixmap(&viewports[pointer_vport]);1314 if (pointer_imgmap == -1) 1315 pointer_imgmap = save_vp_to_imgmap(&viewports[pointer_vport]); 1314 1316 else 1315 copy_vp_to_ pixmap(&viewports[pointer_vport], &pixmaps[pointer_pixmap]);1317 copy_vp_to_imgmap(&viewports[pointer_vport], imgmaps[pointer_imgmap]); 1316 1318 1317 1319 /* Draw mouse pointer. */ … … 1338 1340 /* Restore image under the pointer. */ 1339 1341 if (pointer_shown) { 1340 draw_ pixmap(pointer_vport, pointer_pixmap);1342 draw_imgmap(pointer_vport, pointer_imgmap); 1341 1343 pointer_shown = 0; 1342 1344 } … … 1393 1395 animations[i].initialized = 0; 1394 1396 break; 1395 case FB_ANIM_ADD PIXMAP:1397 case FB_ANIM_ADDIMGMAP: 1396 1398 i = IPC_GET_ARG1(*call); 1397 1399 if (i >= MAX_ANIMATIONS || i < 0 || … … 1405 1407 } 1406 1408 newval = IPC_GET_ARG2(*call); 1407 if (newval < 0 || newval > MAX_ PIXMAPS ||1408 ! pixmaps[newval].data) {1409 if (newval < 0 || newval > MAX_IMGMAPS || 1410 !imgmaps[newval]) { 1409 1411 retval = EINVAL; 1410 1412 break; 1411 1413 } 1412 animations[i]. pixmaps[animations[i].animlen++] = newval;1414 animations[i].imgmaps[animations[i].animlen++] = newval; 1413 1415 break; 1414 1416 case FB_ANIM_CHGVP: … … 1449 1451 } 1450 1452 1451 1452 /** Handler for messages concerning pixmap handling 1453 * 1454 */ 1455 static int pixmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp) 1453 /** Handler for messages concerning image map handling 1454 * 1455 */ 1456 static int imgmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp) 1456 1457 { 1457 1458 bool handled = true; … … 1460 1461 1461 1462 switch (IPC_GET_IMETHOD(*call)) { 1462 case FB_VP_DRAW_ PIXMAP:1463 case FB_VP_DRAW_IMGMAP: 1463 1464 nvp = IPC_GET_ARG1(*call); 1464 1465 if (nvp == -1) 1465 1466 nvp = vp; 1467 1466 1468 if (nvp < 0 || nvp >= MAX_VIEWPORTS || 1467 !viewports[nvp].initialized) {1469 !viewports[nvp].initialized) { 1468 1470 retval = EINVAL; 1469 1471 break; 1470 1472 } 1473 1471 1474 i = IPC_GET_ARG2(*call); 1472 retval = draw_ pixmap(nvp, i);1473 break; 1474 case FB_VP2 PIXMAP:1475 retval = draw_imgmap(nvp, i); 1476 break; 1477 case FB_VP2IMGMAP: 1475 1478 nvp = IPC_GET_ARG1(*call); 1476 1479 if (nvp == -1) 1477 1480 nvp = vp; 1481 1478 1482 if (nvp < 0 || nvp >= MAX_VIEWPORTS || 1479 !viewports[nvp].initialized)1483 !viewports[nvp].initialized) { 1480 1484 retval = EINVAL; 1481 else 1482 retval = save_vp_to_pixmap(&viewports[nvp]); 1483 break; 1484 case FB_DROP_PIXMAP: 1485 break; 1486 } 1487 1488 retval = save_vp_to_imgmap(&viewports[nvp]); 1489 break; 1490 case FB_DROP_IMGMAP: 1485 1491 i = IPC_GET_ARG1(*call); 1486 if (i >= MAX_ PIXMAPS) {1492 if (i >= MAX_IMGMAPS) { 1487 1493 retval = EINVAL; 1488 1494 break; 1489 1495 } 1490 if (pixmaps[i].data) { 1491 free(pixmaps[i].data); 1492 pixmaps[i].data = NULL; 1493 } 1496 1497 if (imgmaps[i]) { 1498 free(imgmaps[i]); 1499 imgmaps[i] = NULL; 1500 } 1501 1494 1502 break; 1495 1503 default: … … 1616 1624 continue; 1617 1625 1618 if ( pixmap_handle(callid, &call, vp))1626 if (imgmap_handle(callid, &call, vp)) 1619 1627 continue; 1620 1628 -
uspace/srv/hid/fb/fb.h
rbb285b4 r1d2a1a9 39 39 #include <stdint.h> 40 40 41 typedef void (* putpixel_cb_t)(void *, unsigned int, unsigned int, uint32_t);42 43 41 extern int fb_init(void); 44 42 -
uspace/srv/hid/fb/serial_console.c
rbb285b4 r1d2a1a9 53 53 54 54 // FIXME: remove this header 55 #include < kernel/ipc/ipc_methods.h>55 #include <abi/ipc/methods.h> 56 56 57 57 #define MAX_CONTROL 20 -
uspace/srv/hid/input/ctl/kbdev.c
rbb285b4 r1d2a1a9 48 48 #include <kbd_ctl.h> 49 49 #include <kbd_port.h> 50 #include <loc.h> 50 51 #include <stdlib.h> 51 52 #include <vfs/vfs_sess.h> 52 53 #include <sys/typefmt.h> 53 54 54 55 static int kbdev_ctl_init(kbd_dev_t *); … … 70 71 /** Session with kbdev device */ 71 72 async_sess_t *sess; 72 73 /** File descriptor of open kbdev device */74 int fd;75 73 } kbdev_t; 76 74 … … 84 82 85 83 kbdev->kbd_dev = kdev; 86 kbdev->fd = -1;87 84 88 85 return kbdev; … … 93 90 if (kbdev->sess != NULL) 94 91 async_hangup(kbdev->sess); 95 if (kbdev->fd >= 0)96 close(kbdev->fd);97 92 free(kbdev); 98 93 } … … 100 95 static int kbdev_ctl_init(kbd_dev_t *kdev) 101 96 { 102 const char *pathname;103 97 async_sess_t *sess; 104 98 async_exch_t *exch; 105 99 kbdev_t *kbdev; 106 int fd;107 100 int rc; 108 101 109 pathname = kdev->dev_path; 110 111 fd = open(pathname, O_RDWR); 112 if (fd < 0) { 113 return -1; 114 } 115 116 sess = fd_session(EXCHANGE_SERIALIZE, fd); 102 sess = loc_service_connect(EXCHANGE_SERIALIZE, kdev->svc_id, 0); 117 103 if (sess == NULL) { 118 printf("%s: Failed starting session with '%s '\n", NAME, pathname);119 close(fd);104 printf("%s: Failed starting session with '%s.'\n", NAME, 105 kdev->svc_name); 120 106 return -1; 121 107 } … … 124 110 if (kbdev == NULL) { 125 111 printf("%s: Failed allocating device structure for '%s'.\n", 126 NAME, pathname);112 NAME, kdev->svc_name); 127 113 return -1; 128 114 } 129 115 130 kbdev->fd = fd;131 116 kbdev->sess = sess; 132 117 133 118 exch = async_exchange_begin(sess); 134 119 if (exch == NULL) { 135 printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname); 120 printf("%s: Failed starting exchange with '%s'.\n", NAME, 121 kdev->svc_name); 136 122 kbdev_destroy(kbdev); 137 123 return -1; … … 141 127 if (rc != EOK) { 142 128 printf("%s: Failed creating callback connection from '%s'.\n", 143 NAME, pathname);129 NAME, kdev->svc_name); 144 130 async_exchange_end(exch); 145 131 kbdev_destroy(kbdev); -
uspace/srv/hid/input/generic/input.c
rbb285b4 r1d2a1a9 38 38 39 39 #include <adt/list.h> 40 #include <bool.h> 40 41 #include <ipc/services.h> 41 42 #include <ipc/input.h> … … 53 54 #include <io/console.h> 54 55 #include <io/keycode.h> 55 #include < devmap.h>56 #include <loc.h> 56 57 #include <input.h> 57 58 #include <kbd.h> … … 63 64 64 65 // FIXME: remove this header 65 #include < kernel/ipc/ipc_methods.h>66 #include <abi/ipc/methods.h> 66 67 67 68 /* In microseconds */ … … 275 276 kdev->port_ops = port; 276 277 kdev->ctl_ops = ctl; 277 kdev-> dev_path = NULL;278 kdev->svc_id = 0; 278 279 279 280 /* Initialize port driver. */ … … 303 304 mdev->port_ops = port; 304 305 mdev->proto_ops = proto; 305 mdev-> dev_path = NULL;306 mdev->svc_id = 0; 306 307 307 308 /* Initialize port driver. */ … … 324 325 /** Add new kbdev device. 325 326 * 326 * @param dev_path Filesystem path to the device (/dev/class/...)327 * @param service_id Service ID of the keyboard device 327 328 * 328 329 */ 329 static int kbd_add_kbdev( const char *dev_path)330 static int kbd_add_kbdev(service_id_t service_id, kbd_dev_t **kdevp) 330 331 { 331 332 kbd_dev_t *kdev = kbd_dev_new(); … … 333 334 return -1; 334 335 335 kdev-> dev_path = dev_path;336 kdev->svc_id = service_id; 336 337 kdev->port_ops = NULL; 337 338 kdev->ctl_ops = &kbdev_ctl; 338 339 340 int rc = loc_service_get_name(service_id, &kdev->svc_name); 341 if (rc != EOK) { 342 kdev->svc_name = NULL; 343 goto fail; 344 } 345 339 346 /* Initialize controller driver. */ 340 347 if ((*kdev->ctl_ops->init)(kdev) != 0) { … … 343 350 344 351 list_append(&kdev->kbd_devs, &kbd_devs); 352 *kdevp = kdev; 345 353 return EOK; 346 354 347 355 fail: 356 if (kdev->svc_name != NULL) 357 free(kdev->svc_name); 348 358 free(kdev); 349 359 return -1; … … 352 362 /** Add new mousedev device. 353 363 * 354 * @param dev_path Filesystem path to the device (/dev/class/...)364 * @param service_id Service ID of the mouse device 355 365 * 356 366 */ 357 static int mouse_add_mousedev( const char *dev_path)367 static int mouse_add_mousedev(service_id_t service_id, mouse_dev_t **mdevp) 358 368 { 359 369 mouse_dev_t *mdev = mouse_dev_new(); … … 361 371 return -1; 362 372 363 mdev-> dev_path = dev_path;373 mdev->svc_id = service_id; 364 374 mdev->port_ops = NULL; 365 375 mdev->proto_ops = &mousedev_proto; 366 376 377 int rc = loc_service_get_name(service_id, &mdev->svc_name); 378 if (rc != EOK) { 379 mdev->svc_name = NULL; 380 goto fail; 381 } 382 367 383 /* Initialize controller driver. */ 368 384 if ((*mdev->proto_ops->init)(mdev) != 0) { … … 371 387 372 388 list_append(&mdev->mouse_devs, &mouse_devs); 389 *mdevp = mdev; 373 390 return EOK; 374 391 … … 482 499 /** Periodically check for new input devices. 483 500 * 484 * Looks under / dev/class/keyboard and /dev/class/mouse.501 * Looks under /loc/class/keyboard and /loc/class/mouse. 485 502 * 486 503 * @param arg Ignored … … 489 506 static int dev_discovery_fibril(void *arg) 490 507 { 491 char *dev_path; 492 size_t kbd_id = 1; 493 size_t mouse_id = 1; 508 category_id_t keyboard_cat, mouse_cat; 509 service_id_t *svcs; 510 size_t count, i; 511 bool already_known; 494 512 int rc; 513 514 rc = loc_category_get_id("keyboard", &keyboard_cat, IPC_FLAG_BLOCKING); 515 if (rc != EOK) { 516 printf("%s: Failed resolving category 'keyboard'.\n", NAME); 517 return ENOENT; 518 } 519 520 rc = loc_category_get_id("mouse", &mouse_cat, IPC_FLAG_BLOCKING); 521 if (rc != EOK) { 522 printf("%s: Failed resolving category 'mouse'.\n", NAME); 523 return ENOENT; 524 } 495 525 496 526 while (true) { … … 498 528 499 529 /* 500 * Check for new keyboard device 530 * Check for new keyboard devices 501 531 */ 502 rc = asprintf(&dev_path, "/dev/class/keyboard\\%zu", kbd_id); 503 if (rc < 0) 532 rc = loc_category_get_svcs(keyboard_cat, &svcs, &count); 533 if (rc != EOK) { 534 printf("%s: Failed getting list of keyboard devices.\n", 535 NAME); 504 536 continue; 505 506 if (kbd_add_kbdev(dev_path) == EOK) { 507 printf("%s: Connected keyboard device '%s'\n",508 NAME, dev_path);537 } 538 539 for (i = 0; i < count; i++) { 540 already_known = false; 509 541 510 /* XXX Handle device removal */ 511 ++kbd_id; 542 /* Determine whether we already know this device. */ 543 list_foreach(kbd_devs, kdev_link) { 544 kbd_dev_t *kdev = list_get_instance(kdev_link, 545 kbd_dev_t, kbd_devs); 546 if (kdev->svc_id == svcs[i]) { 547 already_known = true; 548 break; 549 } 550 } 551 552 if (!already_known) { 553 kbd_dev_t *kdev; 554 if (kbd_add_kbdev(svcs[i], &kdev) == EOK) { 555 printf("%s: Connected keyboard device '%s'\n", 556 NAME, kdev->svc_name); 557 } 558 } 512 559 } 513 560 514 free(dev_path);561 /* XXX Handle device removal */ 515 562 516 563 /* 517 * Check for new mouse device 564 * Check for new mouse devices 518 565 */ 519 rc = asprintf(&dev_path, "/dev/class/mouse\\%zu", mouse_id); 520 if (rc < 0) 566 rc = loc_category_get_svcs(mouse_cat, &svcs, &count); 567 if (rc != EOK) { 568 printf("%s: Failed getting list of mouse devices.\n", 569 NAME); 521 570 continue; 522 523 if (mouse_add_mousedev(dev_path) == EOK) { 524 printf("%s: Connected mouse device '%s'\n",525 NAME, dev_path);571 } 572 573 for (i = 0; i < count; i++) { 574 already_known = false; 526 575 527 /* XXX Handle device removal */ 528 ++mouse_id; 576 /* Determine whether we already know this device. */ 577 list_foreach(mouse_devs, mdev_link) { 578 mouse_dev_t *mdev = list_get_instance(mdev_link, 579 mouse_dev_t, mouse_devs); 580 if (mdev->svc_id == svcs[i]) { 581 already_known = true; 582 break; 583 } 584 } 585 586 if (!already_known) { 587 mouse_dev_t *mdev; 588 if (mouse_add_mousedev(svcs[i], &mdev) == EOK) { 589 printf("%s: Connected mouse device '%s'\n", 590 NAME, mdev->svc_name); 591 } 592 } 529 593 } 530 594 531 free(dev_path);595 /* XXX Handle device removal */ 532 596 } 533 597 … … 572 636 573 637 /* Register driver */ 574 int rc = devmap_driver_register(NAME, client_connection);638 int rc = loc_server_register(NAME, client_connection); 575 639 if (rc < 0) { 576 printf("%s: Unable to register driver (%d)\n", NAME, rc);640 printf("%s: Unable to register server (%d)\n", NAME, rc); 577 641 return -1; 578 642 } 579 643 580 char kbd[ DEVMAP_NAME_MAXLEN + 1];581 snprintf(kbd, DEVMAP_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME);582 583 devmap_handle_t devmap_handle;584 if ( devmap_device_register(kbd, &devmap_handle) != EOK) {585 printf("%s: Unable to register device %s\n", NAME, kbd);644 char kbd[LOC_NAME_MAXLEN + 1]; 645 snprintf(kbd, LOC_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME); 646 647 service_id_t service_id; 648 if (loc_service_register(kbd, &service_id) != EOK) { 649 printf("%s: Unable to register service %s\n", NAME, kbd); 586 650 return -1; 587 651 } -
uspace/srv/hid/input/include/kbd.h
rbb285b4 r1d2a1a9 40 40 41 41 #include <adt/list.h> 42 #include <ipc/loc.h> 42 43 43 44 struct kbd_port_ops; … … 49 50 link_t kbd_devs; 50 51 51 /** Path to the device (only for kbdev devices) */ 52 const char *dev_path; 52 /** Service ID (only for kbdev devices) */ 53 service_id_t svc_id; 54 55 /** Device service name (only for kbdev devices) */ 56 char *svc_name; 53 57 54 58 /** Port ops */ -
uspace/srv/hid/input/include/mouse.h
rbb285b4 r1d2a1a9 39 39 40 40 #include <adt/list.h> 41 #include <ipc/loc.h> 41 42 42 43 struct mouse_port_ops; … … 47 48 link_t mouse_devs; 48 49 49 /** Path to the device (only for mouseev devices) */ 50 const char *dev_path; 50 /** Service ID (only for mousedev devices) */ 51 service_id_t svc_id; 52 53 /** Device service name (only for mousedev devices) */ 54 char *svc_name; 51 55 52 56 /** Port ops */ -
uspace/srv/hid/input/port/adb.c
rbb285b4 r1d2a1a9 43 43 #include <fcntl.h> 44 44 #include <errno.h> 45 #include < devmap.h>45 #include <loc.h> 46 46 47 47 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); … … 66 66 { 67 67 const char *dev = "adb/kbd"; 68 devmap_handle_t handle;68 service_id_t service_id; 69 69 async_exch_t *exch; 70 70 int rc; … … 72 72 kbd_dev = kdev; 73 73 74 rc = devmap_device_get_handle(dev, &handle, 0);74 rc = loc_service_get_id(dev, &service_id, 0); 75 75 if (rc != EOK) 76 76 return rc; 77 77 78 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);78 dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0); 79 79 if (dev_sess == NULL) { 80 80 printf("%s: Failed to connect to device\n", NAME); -
uspace/srv/hid/input/port/adb_mouse.c
rbb285b4 r1d2a1a9 41 41 #include <mouse.h> 42 42 #include <errno.h> 43 #include < devmap.h>43 #include <loc.h> 44 44 45 45 static mouse_dev_t *mouse_dev; … … 78 78 mouse_dev = mdev; 79 79 80 devmap_handle_t handle;81 int rc = devmap_device_get_handle(dev, &handle, 0);80 service_id_t service_id; 81 int rc = loc_service_get_id(dev, &service_id, 0); 82 82 if (rc != EOK) 83 83 return rc; 84 84 85 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);85 dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0); 86 86 if (dev_sess == NULL) { 87 87 printf("%s: Failed to connect to device\n", NAME); -
uspace/srv/hid/input/port/chardev.c
rbb285b4 r1d2a1a9 40 40 #include <kbd_port.h> 41 41 #include <kbd.h> 42 #include < devmap.h>42 #include <loc.h> 43 43 #include <errno.h> 44 44 #include <stdio.h> … … 71 71 static int chardev_port_init(kbd_dev_t *kdev) 72 72 { 73 devmap_handle_t handle;73 service_id_t service_id; 74 74 async_exch_t *exch; 75 75 unsigned int i; … … 79 79 80 80 for (i = 0; i < num_devs; i++) { 81 rc = devmap_device_get_handle(in_devs[i], &handle, 0);81 rc = loc_service_get_id(in_devs[i], &service_id, 0); 82 82 if (rc == EOK) 83 83 break; … … 89 89 } 90 90 91 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle,91 dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 92 92 IPC_FLAG_BLOCKING); 93 93 if (dev_sess == NULL) { -
uspace/srv/hid/input/port/chardev_mouse.c
rbb285b4 r1d2a1a9 39 39 #include <async.h> 40 40 #include <errno.h> 41 #include < devmap.h>41 #include <loc.h> 42 42 #include <input.h> 43 43 #include <mouse_port.h> … … 82 82 static int chardev_port_init(mouse_dev_t *mdev) 83 83 { 84 devmap_handle_t handle;84 service_id_t service_id; 85 85 unsigned int i; 86 86 int rc; … … 89 89 90 90 for (i = 0; i < num_devs; i++) { 91 rc = devmap_device_get_handle(in_devs[i], &handle, 0);91 rc = loc_service_get_id(in_devs[i], &service_id, 0); 92 92 if (rc == EOK) 93 93 break; … … 99 99 } 100 100 101 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle,101 dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 102 102 IPC_FLAG_BLOCKING); 103 103 if (dev_sess == NULL) { -
uspace/srv/hid/input/proto/mousedev.c
rbb285b4 r1d2a1a9 44 44 #include <ipc/mouseev.h> 45 45 #include <input.h> 46 #include <loc.h> 46 47 #include <mouse.h> 47 48 #include <mouse_port.h> 48 49 #include <mouse_proto.h> 50 #include <sys/typefmt.h> 49 51 50 52 /** Mousedev softstate */ … … 55 57 /** Session to mouse device */ 56 58 async_sess_t *sess; 57 58 /** File descriptor of open mousedev device */59 int fd;60 59 } mousedev_t; 61 60 … … 67 66 68 67 mousedev->mouse_dev = mdev; 69 mousedev->fd = -1;70 68 71 69 return mousedev; … … 76 74 if (mousedev->sess != NULL) 77 75 async_hangup(mousedev->sess); 78 79 if (mousedev->fd >= 0)80 close(mousedev->fd);81 76 82 77 free(mousedev); … … 122 117 static int mousedev_proto_init(mouse_dev_t *mdev) 123 118 { 124 const char *pathname = mdev->dev_path; 125 126 int fd = open(pathname, O_RDWR); 127 if (fd < 0) 128 return -1; 129 130 async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd); 119 async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, 120 mdev->svc_id, 0); 131 121 if (sess == NULL) { 132 printf("%s: Failed starting session with '%s'\n", NAME, pathname);133 close(fd);122 printf("%s: Failed starting session with '%s'\n", NAME, 123 mdev->svc_name); 134 124 return -1; 135 125 } … … 138 128 if (mousedev == NULL) { 139 129 printf("%s: Failed allocating device structure for '%s'.\n", 140 NAME, pathname);130 NAME, mdev->svc_name); 141 131 return -1; 142 132 } 143 133 144 mousedev->fd = fd;145 134 mousedev->sess = sess; 146 135 147 136 async_exch_t *exch = async_exchange_begin(sess); 148 137 if (exch == NULL) { 149 printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname); 138 printf("%s: Failed starting exchange with '%s'.\n", NAME, 139 mdev->svc_name); 150 140 mousedev_destroy(mousedev); 151 141 return -1; … … 157 147 if (rc != EOK) { 158 148 printf("%s: Failed creating callback connection from '%s'.\n", 159 NAME, pathname);149 NAME, mdev->svc_name); 160 150 mousedev_destroy(mousedev); 161 151 return -1; -
uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
rbb285b4 r1d2a1a9 39 39 #include <ddi.h> 40 40 #include <libarch/ddi.h> 41 #include < devmap.h>41 #include <loc.h> 42 42 #include <io/console.h> 43 43 #include <vfs/vfs.h> … … 54 54 55 55 // FIXME: remove this header 56 #include < kernel/ipc/ipc_methods.h>56 #include <abi/ipc/methods.h> 57 57 58 58 #define NAME "s3c24ser" … … 90 90 printf(NAME ": S3C24xx touchscreen driver\n"); 91 91 92 rc = devmap_driver_register(NAME, s3c24xx_ts_connection);92 rc = loc_server_register(NAME, s3c24xx_ts_connection); 93 93 if (rc < 0) { 94 94 printf(NAME ": Unable to register driver.\n"); … … 103 103 return -1; 104 104 105 rc = devmap_device_register(NAMESPACE "/mouse", &ts->devmap_handle);105 rc = loc_service_register(NAMESPACE "/mouse", &ts->service_id); 106 106 if (rc != EOK) { 107 107 printf(NAME ": Unable to register device %s.\n", -
uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.h
rbb285b4 r1d2a1a9 124 124 int client_phone; 125 125 126 /** Device handle*/127 devmap_handle_t devmap_handle;126 /** Service ID */ 127 service_id_t service_id; 128 128 129 129 /** Device/driver state */
Note:
See TracChangeset
for help on using the changeset viewer.
