Changeset d900699 in mainline for uspace/srv/hid
- Timestamp:
- 2011-06-17T16:48:53Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f3a605be
- Parents:
- df8110d3 (diff), 98caf49 (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:
-
- 7 added
- 2 deleted
- 11 edited
- 29 moved
-
adb_mouse/adb_dev.c (modified) (3 diffs)
-
adb_mouse/adb_mouse.c (modified) (2 diffs)
-
char_mouse/char_mouse.c (modified) (1 diff)
-
char_mouse/chardev.c (modified) (3 diffs)
-
console/console.c (modified) (17 diffs)
-
console/gcons.c (modified) (1 diff)
-
fb/ega.c (modified) (1 diff)
-
fb/fb.c (modified) (1 diff)
-
fb/serial_console.c (modified) (1 diff)
-
fb/serial_console.h (modified) (1 diff)
-
input/Makefile (added)
-
input/ctl/apple.c (moved) (moved from uspace/srv/hid/kbd/ctl/apple.c ) (4 diffs)
-
input/ctl/gxe_fb.c (moved) (moved from uspace/srv/hid/kbd/ctl/gxe_fb.c ) (7 diffs)
-
input/ctl/kbdev.c (added)
-
input/ctl/pc.c (moved) (moved from uspace/srv/hid/kbd/ctl/pc.c ) (7 diffs)
-
input/ctl/stty.c (moved) (moved from uspace/srv/hid/kbd/ctl/stty.c ) (7 diffs)
-
input/ctl/sun.c (moved) (moved from uspace/srv/hid/kbd/ctl/sun.c ) (5 diffs)
-
input/generic/gsp.c (moved) (moved from uspace/srv/hid/kbd/genarch/gsp.c ) (1 diff)
-
input/generic/input.c (added)
-
input/generic/layout.c (added)
-
input/generic/mouse.c (added)
-
input/generic/stroke.c (moved) (moved from uspace/srv/hid/kbd/genarch/stroke.c ) (6 diffs)
-
input/include/gsp.h (moved) (moved from uspace/srv/hid/kbd/include/gsp.h ) (1 diff)
-
input/include/input.h (moved) (moved from uspace/srv/hid/kbd/include/kbd.h ) (3 diffs)
-
input/include/kbd.h (added)
-
input/include/kbd_ctl.h (moved) (moved from uspace/drv/usbhid/layout.h ) (3 diffs)
-
input/include/kbd_port.h (added)
-
input/include/layout.h (moved) (moved from uspace/srv/hid/kbd/include/layout.h ) (2 diffs)
-
input/include/mouse.h (moved) (moved from uspace/srv/hid/kbd/include/kbd_port.h ) (3 diffs)
-
input/include/stroke.h (moved) (moved from uspace/srv/hid/kbd/include/stroke.h ) (3 diffs)
-
input/include/sun.h (moved) (moved from uspace/srv/hid/kbd/include/sun.h )
-
input/layout/cz.c (moved) (moved from uspace/srv/hid/kbd/layout/cz.c ) (9 diffs)
-
input/layout/us_dvorak.c (moved) (moved from uspace/srv/hid/kbd/layout/us_dvorak.c ) (4 diffs)
-
input/layout/us_qwerty.c (moved) (moved from uspace/srv/hid/kbd/layout/us_qwerty.c ) (4 diffs)
-
input/port/adb.c (moved) (moved from uspace/srv/hid/kbd/port/adb.c ) (6 diffs)
-
input/port/chardev.c (moved) (moved from uspace/srv/hid/kbd/port/chardev.c ) (7 diffs)
-
input/port/dummy.c (moved) (moved from uspace/srv/hid/kbd/port/dummy.c )
-
input/port/gxemul.c (moved) (moved from uspace/srv/hid/kbd/port/gxemul.c ) (5 diffs)
-
input/port/msim.c (moved) (moved from uspace/srv/hid/kbd/port/msim.c ) (6 diffs)
-
input/port/niagara.c (moved) (moved from uspace/srv/hid/kbd/port/niagara.c ) (6 diffs)
-
input/port/ns16550.c (moved) (moved from uspace/srv/hid/kbd/port/ns16550.c ) (4 diffs)
-
input/port/pl050.c (moved) (moved from uspace/srv/hid/kbd/port/pl050.c ) (5 diffs)
-
input/port/sgcn.c (moved) (moved from uspace/srv/hid/kbd/port/sgcn.c ) (5 diffs)
-
input/port/ski.c (moved) (moved from uspace/srv/hid/kbd/port/ski.c ) (7 diffs)
-
input/port/sun.c (moved) (moved from uspace/srv/hid/kbd/port/sun.c )
-
input/port/z8530.c (moved) (moved from uspace/srv/hid/kbd/port/z8530.c ) (5 diffs)
-
kbd/Makefile (deleted)
-
kbd/generic/kbd.c (deleted)
-
s3c24xx_ts/s3c24xx_ts.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/adb_mouse/adb_dev.c
rdf8110d3 rd900699 48 48 #include "adb_dev.h" 49 49 50 static void adb_dev_events(ipc_callid_t iid, ipc_call_t *icall );50 static void adb_dev_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); 51 51 52 52 int adb_dev_init(void) … … 68 68 69 69 /* NB: The callback connection is slotted for removal */ 70 if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, adb_dev_events) != 0) { 70 if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, adb_dev_events, 71 NULL) != 0) { 71 72 printf(NAME ": Failed to create callback from device\n"); 72 73 return false; … … 76 77 } 77 78 78 static void adb_dev_events(ipc_callid_t iid, ipc_call_t *icall )79 static void adb_dev_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 79 80 { 80 81 /* Ignore parameters, the connection is already opened */ -
uspace/srv/hid/adb_mouse/adb_mouse.c
rdf8110d3 rd900699 52 52 #include <kernel/ipc/ipc_methods.h> 53 53 54 static void client_connection(ipc_callid_t iid, ipc_call_t *icall );54 static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg); 55 55 static void mouse_ev_btn(int button, int press); 56 56 static void mouse_ev_move(int dx, int dy); … … 94 94 } 95 95 96 static void client_connection(ipc_callid_t iid, ipc_call_t *icall )96 static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 97 97 { 98 98 ipc_callid_t callid; -
uspace/srv/hid/char_mouse/char_mouse.c
rdf8110d3 rd900699 79 79 } 80 80 81 static void client_connection(ipc_callid_t iid, ipc_call_t *icall )81 static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 82 82 { 83 83 ipc_callid_t callid; -
uspace/srv/hid/char_mouse/chardev.c
rdf8110d3 rd900699 45 45 #include <mouse_port.h> 46 46 47 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall );47 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); 48 48 49 49 static int dev_phone; … … 69 69 70 70 /* NB: The callback connection is slotted for removal */ 71 if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, chardev_events) != 0) { 71 if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, chardev_events, 72 NULL) != 0) { 72 73 printf(NAME ": Failed to create callback from device\n"); 73 74 return false; … … 90 91 } 91 92 92 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall )93 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 93 94 { 94 95 /* Ignore parameters, the connection is already opened */ -
uspace/srv/hid/console/console.c
rdf8110d3 rd900699 1 1 /* 2 2 * Copyright (c) 2006 Josef Cejka 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 34 35 35 36 #include <libc.h> 36 #include <ipc/ kbd.h>37 #include <ipc/input.h> 37 38 #include <io/keycode.h> 38 #include <ipc/mouse.h>39 39 #include <ipc/fb.h> 40 40 #include <ipc/services.h> … … 60 60 #include <io/style.h> 61 61 #include <io/screenbuffer.h> 62 #include <inttypes.h>63 62 64 63 #include "console.h" … … 66 65 #include "keybuffer.h" 67 66 68 // FIXME: remove this header69 #include <kernel/ipc/ipc_methods.h>70 71 67 #define NAME "console" 72 68 #define NAMESPACE "term" 73 69 74 /** Interval for checking for new keyboard (1/4s). */ 75 #define HOTPLUG_WATCH_INTERVAL (1000 * 250) 76 77 /* Kernel defines 32 but does not export it. */ 78 #define MAX_IPC_OUTGOING_PHONES 128 79 80 /** To allow proper phone closing. */ 81 static ipc_callid_t driver_phones[MAX_IPC_OUTGOING_PHONES] = { 0 }; 82 83 /** Phone to the keyboard driver. */ 84 static int kbd_phone; 85 86 /** Phone to the mouse driver. */ 87 static int mouse_phone; 70 /** Phone to the input server. */ 71 static int input_phone; 88 72 89 73 /** Information about framebuffer */ … … 155 139 } 156 140 157 static void kbd_yield(void)158 { 159 async_obsolete_req_0_0( kbd_phone, KBD_YIELD);160 } 161 162 static void kbd_reclaim(void)163 { 164 async_obsolete_req_0_0( kbd_phone, KBD_RECLAIM);141 static void input_yield(void) 142 { 143 async_obsolete_req_0_0(input_phone, INPUT_YIELD); 144 } 145 146 static void input_reclaim(void) 147 { 148 async_obsolete_req_0_0(input_phone, INPUT_RECLAIM); 165 149 } 166 150 … … 343 327 gcons_in_kernel(); 344 328 screen_yield(); 345 kbd_yield();329 input_yield(); 346 330 async_obsolete_serialize_end(); 347 331 … … 358 342 if (active_console == kernel_console) { 359 343 screen_reclaim(); 360 kbd_reclaim();344 input_reclaim(); 361 345 gcons_redraw_console(); 362 346 } … … 413 397 } 414 398 415 static void close_driver_phone(ipc_callid_t hash) 416 { 417 int i; 418 for (i = 0; i < MAX_IPC_OUTGOING_PHONES; i++) { 419 if (driver_phones[i] == hash) { 420 printf("Device %" PRIxn " gone.\n", hash); 421 driver_phones[i] = 0; 422 async_obsolete_hangup(i); 423 return; 424 } 425 } 426 } 427 428 /** Handler for keyboard */ 429 static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall) 399 /** Handler for input events */ 400 static void input_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 430 401 { 431 402 /* Ignore parameters, the connection is already opened */ … … 439 410 if (!IPC_GET_IMETHOD(call)) { 440 411 /* TODO: Handle hangup */ 441 close_driver_phone(iid);412 async_obsolete_hangup(input_phone); 442 413 return; 443 414 } 444 415 445 416 switch (IPC_GET_IMETHOD(call)) { 446 case KBD_EVENT:447 /* Got event from keyboard driver.*/417 case INPUT_EVENT_KEY: 418 /* Got key press/release event */ 448 419 retval = 0; 449 420 ev.type = IPC_GET_ARG1(call); … … 466 437 fibril_mutex_unlock(&input_mutex); 467 438 break; 468 default: 469 retval = ENOENT; 470 } 471 async_answer_0(callid, retval); 472 } 473 } 474 475 /** Handler for mouse events */ 476 static void mouse_events(ipc_callid_t iid, ipc_call_t *icall) 477 { 478 /* Ignore parameters, the connection is already opened */ 479 while (true) { 480 ipc_call_t call; 481 ipc_callid_t callid = async_get_call(&call); 482 483 int retval; 484 485 if (!IPC_GET_IMETHOD(call)) { 486 /* TODO: Handle hangup */ 487 close_driver_phone(iid); 488 return; 489 } 490 491 switch (IPC_GET_IMETHOD(call)) { 492 case MEVENT_BUTTON: 439 case INPUT_EVENT_MOVE: 440 /* Got pointer move event */ 441 gcons_mouse_move((int) IPC_GET_ARG1(call), 442 (int) IPC_GET_ARG2(call)); 443 retval = 0; 444 break; 445 case INPUT_EVENT_BUTTON: 446 /* Got pointer button press/release event */ 493 447 if (IPC_GET_ARG1(call) == 1) { 494 448 int newcon = gcons_mouse_btn((bool) IPC_GET_ARG2(call)); … … 498 452 retval = 0; 499 453 break; 500 case MEVENT_MOVE:501 gcons_mouse_move((int) IPC_GET_ARG1(call),502 (int) IPC_GET_ARG2(call));503 retval = 0;504 break;505 454 default: 506 455 retval = ENOENT; 507 456 } 508 509 457 async_answer_0(callid, retval); 510 458 } … … 597 545 598 546 /** Default thread for new connections */ 599 static void client_connection(ipc_callid_t iid, ipc_call_t *icall )547 static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 600 548 { 601 549 console_t *cons = NULL; … … 747 695 } 748 696 749 static int async_connect_to_me_hack(int phone, sysarg_t arg1, sysarg_t arg2, 750 sysarg_t arg3, async_client_conn_t client_receiver, ipc_callid_t *hash) 751 { 752 sysarg_t task_hash; 753 sysarg_t phone_hash; 754 int rc = async_obsolete_req_3_5(phone, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3, 755 NULL, NULL, NULL, &task_hash, &phone_hash); 756 if (rc != EOK) 757 return rc; 758 759 if (client_receiver != NULL) 760 async_new_connection(task_hash, phone_hash, phone_hash, NULL, 761 client_receiver); 762 763 if (hash != NULL) 764 *hash = phone_hash; 765 766 return EOK; 767 } 768 769 static int connect_keyboard_or_mouse(const char *devname, 770 async_client_conn_t handler, const char *dev) 697 static int connect_input(const char *dev_path) 771 698 { 772 699 int phone; 773 700 devmap_handle_t handle; 774 701 775 int rc = devmap_device_get_handle(dev , &handle, 0);702 int rc = devmap_device_get_handle(dev_path, &handle, 0); 776 703 if (rc == EOK) { 777 704 phone = devmap_obsolete_device_connect(handle, 0); … … 780 707 return phone; 781 708 } 782 } else 709 } else { 783 710 return rc; 711 } 784 712 785 713 /* NB: The callback connection is slotted for removal */ 786 ipc_callid_t hash;787 rc = async_connect_to_me_hack(phone, SERVICE_CONSOLE, 0, phone,788 handler, &hash); 714 rc = async_obsolete_connect_to_me(phone, SERVICE_CONSOLE, 0, 0, 715 input_events, NULL); 716 789 717 if (rc != EOK) { 790 718 async_obsolete_hangup(phone); … … 794 722 } 795 723 796 driver_phones[phone] = hash;797 printf("%s: found %s \"%s\" (%" PRIxn ").\n", NAME, devname, dev, hash);798 724 return phone; 799 725 } 800 726 801 static int connect_keyboard(const char *dev) 802 { 803 return connect_keyboard_or_mouse("keyboard", keyboard_events, dev); 804 } 805 806 static int connect_mouse(const char *dev) 807 { 808 return connect_keyboard_or_mouse("mouse", mouse_events, dev); 809 } 810 811 struct hid_class_info { 812 char *classname; 813 int (*connection_func)(const char *); 814 }; 815 816 /** Periodically check for new keyboards in /dev/class/. 817 * 818 * @param arg Class name. 819 * 820 * @return This function should never exit. 821 * 822 */ 823 static int check_new_device_fibril(void *arg) 824 { 825 struct hid_class_info *dev_info = (struct hid_class_info *) arg; 826 827 size_t index = 1; 828 829 while (true) { 830 async_usleep(HOTPLUG_WATCH_INTERVAL); 831 832 char *dev; 833 int rc = asprintf(&dev, "class/%s\\%zu", 834 dev_info->classname, index); 835 if (rc < 0) 836 continue; 837 838 rc = dev_info->connection_func(dev); 839 if (rc > 0) { 840 /* We do not allow unplug. */ 841 index++; 842 } 843 844 free(dev); 845 } 846 847 return EOK; 848 } 849 850 /** Start a fibril monitoring hot-plugged keyboards. 851 */ 852 static void check_new_devices_in_background(int (*connection_func)(const char *), 853 const char *classname) 854 { 855 struct hid_class_info *dev_info = malloc(sizeof(struct hid_class_info)); 856 if (dev_info == NULL) { 857 printf("%s: Out of memory, no hot-plug support.\n", NAME); 858 return; 859 } 860 861 int rc = asprintf(&dev_info->classname, "%s", classname); 862 if (rc < 0) { 863 printf("%s: Failed to format classname: %s.\n", NAME, 864 str_error(rc)); 865 return; 866 } 867 868 dev_info->connection_func = connection_func; 869 870 fid_t fid = fibril_create(check_new_device_fibril, (void *) dev_info); 871 if (!fid) { 872 printf("%s: Failed to create hot-plug fibril for %s.\n", NAME, 873 classname); 874 return; 875 } 876 877 fibril_add_ready(fid); 878 } 879 880 static bool console_srv_init(char *kdev) 881 { 882 /* Connect to input device */ 883 kbd_phone = connect_keyboard(kdev); 884 if (kbd_phone < 0) 727 static bool console_srv_init(char *input_dev) 728 { 729 /* Connect to input server */ 730 input_phone = connect_input(input_dev); 731 if (input_phone < 0) 885 732 return false; 886 887 mouse_phone = connect_mouse("hid_in/mouse");888 if (mouse_phone < 0) {889 printf("%s: Failed to connect to mouse device %s\n", NAME,890 str_error(mouse_phone));891 }892 733 893 734 /* Connect to framebuffer driver */ … … 972 813 printf("%s: Error registering kconsole notifications\n", NAME); 973 814 974 /* Start fibril for checking on hot-plugged keyboards. */975 check_new_devices_in_background(connect_keyboard, "keyboard");976 check_new_devices_in_background(connect_mouse, "mouse");977 978 815 return true; 979 816 } … … 981 818 static void usage(void) 982 819 { 983 printf("Usage: console <input >\n");820 printf("Usage: console <input_dev>\n"); 984 821 } 985 822 -
uspace/srv/hid/console/gcons.c
rdf8110d3 rd900699 168 168 void gcons_change_console(size_t index) 169 169 { 170 if (!use_gcons) 171 return; 170 if (!use_gcons) { 171 active_console = index; 172 return; 173 } 172 174 173 175 if (active_console == KERNEL_CONSOLE) { -
uspace/srv/hid/fb/ega.c
rdf8110d3 rd900699 256 256 } 257 257 258 static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) 258 static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall, 259 void *arg) 259 260 { 260 261 size_t intersize = 0; -
uspace/srv/hid/fb/fb.c
rdf8110d3 rd900699 1576 1576 * 1577 1577 */ 1578 static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall) 1578 static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall, 1579 void *arg) 1579 1580 { 1580 1581 unsigned int vp = 0; -
uspace/srv/hid/fb/serial_console.c
rdf8110d3 rd900699 315 315 * Main function of the thread serving client connections. 316 316 */ 317 void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall )317 void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 318 318 { 319 319 keyfield_t *interbuf = NULL; -
uspace/srv/hid/fb/serial_console.h
rdf8110d3 rd900699 52 52 extern void serial_set_scroll_region(sysarg_t); 53 53 extern void serial_console_init(putc_function_t, sysarg_t, sysarg_t); 54 extern void serial_client_connection(ipc_callid_t, ipc_call_t * );54 extern void serial_client_connection(ipc_callid_t, ipc_call_t *, void *arg); 55 55 56 56 #endif -
uspace/srv/hid/input/ctl/apple.c
rdf8110d3 rd900699 1 1 /* 2 * Copyright (c) 201 0Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 28 28 29 29 /** @addtogroup kbd_ctl 30 * @ingroup kbd30 * @ingroup input 31 31 * @{ 32 32 */ … … 40 40 #include <io/keycode.h> 41 41 #include <kbd_ctl.h> 42 #include <kbd_port.h> 43 44 static void apple_ctl_parse_scancode(int); 45 static int apple_ctl_init(kbd_dev_t *); 46 static void apple_ctl_set_ind(kbd_dev_t *, unsigned); 47 48 kbd_ctl_ops_t apple_ctl = { 49 .parse_scancode = apple_ctl_parse_scancode, 50 .init = apple_ctl_init, 51 .set_ind = apple_ctl_set_ind 52 }; 42 53 43 54 #define KBD_KEY_RELEASE 0x80 44 55 56 static kbd_dev_t *kbd_dev; 57 45 58 static int scanmap[]; 46 59 47 int kbd_ctl_init(void)60 static int apple_ctl_init(kbd_dev_t *kdev) 48 61 { 62 kbd_dev = kdev; 49 63 return 0; 50 64 } 51 65 52 void kbd_ctl_parse_scancode(int scancode)66 static void apple_ctl_parse_scancode(int scancode) 53 67 { 54 68 kbd_event_type_t type; … … 67 81 key = scanmap[scancode]; 68 82 if (key != 0) 69 kbd_push_ev( type, key);83 kbd_push_ev(kbd_dev, type, key); 70 84 } 71 85 72 void kbd_ctl_set_ind(unsigned mods)86 static void apple_ctl_set_ind(kbd_dev_t *kdev, unsigned mods) 73 87 { 74 88 (void) mods; -
uspace/srv/hid/input/ctl/gxe_fb.c
rdf8110d3 rd900699 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 28 28 29 29 /** @addtogroup kbd_ctl 30 * @ingroup kbd30 * @ingroup input 31 31 * @{ 32 32 */ … … 40 40 #include <io/keycode.h> 41 41 #include <kbd_ctl.h> 42 #include <kbd_port.h> 42 43 #include <gsp.h> 43 44 #include <stroke.h> 44 45 46 static void gxe_fb_ctl_parse_scancode(int); 47 static int gxe_fb_ctl_init(kbd_dev_t *); 48 static void gxe_fb_ctl_set_ind(kbd_dev_t *, unsigned); 49 50 kbd_ctl_ops_t gxe_fb_ctl = { 51 .parse_scancode = gxe_fb_ctl_parse_scancode, 52 .init = gxe_fb_ctl_init, 53 .set_ind = gxe_fb_ctl_set_ind 54 }; 55 56 static kbd_dev_t *kbd_dev; 57 45 58 /** Scancode parser */ 46 59 static gsp_t sp; … … 51 64 #include <stdio.h> 52 65 53 int seq_defs[] = {66 static int seq_defs[] = { 54 67 /* Not shifted */ 55 68 … … 207 220 }; 208 221 209 int kbd_ctl_init(void)222 static int gxe_fb_ctl_init(kbd_dev_t *kdev) 210 223 { 224 kbd_dev = kdev; 211 225 ds = 0; 212 226 … … 215 229 } 216 230 217 void kbd_ctl_parse_scancode(int scancode)231 static void gxe_fb_ctl_parse_scancode(int scancode) 218 232 { 219 233 unsigned mods, key; … … 221 235 ds = gsp_step(&sp, ds, scancode, &mods, &key); 222 236 if (key != 0) { 223 stroke_sim( mods, key);237 stroke_sim(kbd_dev, mods, key); 224 238 } 225 239 } 226 240 227 void kbd_ctl_set_ind(unsigned mods)241 static void gxe_fb_ctl_set_ind(kbd_dev_t *kdev, unsigned mods) 228 242 { 229 243 (void) mods; -
uspace/srv/hid/input/ctl/pc.c
rdf8110d3 rd900699 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 28 28 29 29 /** @addtogroup kbd_ctl 30 * @ingroup kbd30 * @ingroup input 31 31 * @{ 32 32 */ … … 43 43 #include <gsp.h> 44 44 45 static void pc_ctl_parse_scancode(int); 46 static int pc_ctl_init(kbd_dev_t *); 47 static void pc_ctl_set_ind(kbd_dev_t *, unsigned); 48 49 kbd_ctl_ops_t pc_ctl = { 50 .parse_scancode = pc_ctl_parse_scancode, 51 .init = pc_ctl_init, 52 .set_ind = pc_ctl_set_ind 53 }; 54 45 55 enum dec_state { 46 56 ds_s, … … 64 74 65 75 static enum dec_state ds; 76 static kbd_dev_t *kbd_dev; 66 77 67 78 static int scanmap_simple[] = { … … 197 208 }; 198 209 199 int kbd_ctl_init(void)210 static int pc_ctl_init(kbd_dev_t *kdev) 200 211 { 212 kbd_dev = kdev; 201 213 ds = ds_s; 202 214 return 0; 203 215 } 204 216 205 void kbd_ctl_parse_scancode(int scancode)217 static void pc_ctl_parse_scancode(int scancode) 206 218 { 207 219 kbd_event_type_t type; … … 250 262 key = map[scancode]; 251 263 if (key != 0) 252 kbd_push_ev( type, key);264 kbd_push_ev(kbd_dev, type, key); 253 265 } 254 266 255 void kbd_ctl_set_ind(unsigned mods)267 static void pc_ctl_set_ind(kbd_dev_t *kdev, unsigned mods) 256 268 { 257 269 uint8_t b; … … 265 277 b = b | LI_SCROLL; 266 278 267 kbd_port_write(KBD_CMD_SET_LEDS);268 kbd_port_write(b);279 (*kbd_dev->port_ops->write)(KBD_CMD_SET_LEDS); 280 (*kbd_dev->port_ops->write)(b); 269 281 } 270 282 -
uspace/srv/hid/input/ctl/stty.c
rdf8110d3 rd900699 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 28 28 29 29 /** @addtogroup kbd_ctl 30 * @ingroup kbd30 * @ingroup input 31 31 * @{ 32 32 */ … … 39 39 #include <io/keycode.h> 40 40 #include <kbd_ctl.h> 41 #include <kbd_port.h> 41 42 #include <gsp.h> 42 43 #include <stroke.h> 43 44 45 static void stty_ctl_parse_scancode(int); 46 static int stty_ctl_init(kbd_dev_t *); 47 static void stty_ctl_set_ind(kbd_dev_t *, unsigned); 48 49 kbd_ctl_ops_t stty_ctl = { 50 .parse_scancode = stty_ctl_parse_scancode, 51 .init = stty_ctl_init, 52 .set_ind = stty_ctl_set_ind 53 }; 54 55 static kbd_dev_t *kbd_dev; 56 44 57 /** Scancode parser */ 45 58 static gsp_t sp; … … 50 63 #include <stdio.h> 51 64 52 int seq_defs[] = {65 static int seq_defs[] = { 53 66 /* Not shifted */ 54 67 … … 206 219 }; 207 220 208 int kbd_ctl_init(void)221 static int stty_ctl_init(kbd_dev_t *kdev) 209 222 { 223 kbd_dev = kdev; 210 224 ds = 0; 211 225 … … 214 228 } 215 229 216 void kbd_ctl_parse_scancode(int scancode)230 static void stty_ctl_parse_scancode(int scancode) 217 231 { 218 232 unsigned mods, key; … … 220 234 ds = gsp_step(&sp, ds, scancode, &mods, &key); 221 235 if (key != 0) { 222 stroke_sim( mods, key);236 stroke_sim(kbd_dev, mods, key); 223 237 } 224 238 } 225 239 226 void kbd_ctl_set_ind(unsigned mods)240 static void stty_ctl_set_ind(kbd_dev_t *kdev, unsigned mods) 227 241 { 228 242 (void) mods; -
uspace/srv/hid/input/ctl/sun.c
rdf8110d3 rd900699 1 1 /* 2 2 * Copyright (c) 2006 Jakub Jermar 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 28 29 29 30 /** @addtogroup kbd_ctl 30 * @ingroup kbd31 * @ingroup input 31 32 * @{ 32 33 */ … … 40 41 #include <io/keycode.h> 41 42 #include <kbd_ctl.h> 43 #include <kbd_port.h> 44 45 static void sun_ctl_parse_scancode(int); 46 static int sun_ctl_init(kbd_dev_t *); 47 static void sun_ctl_set_ind(kbd_dev_t *, unsigned); 48 49 kbd_ctl_ops_t sun_ctl = { 50 .parse_scancode = sun_ctl_parse_scancode, 51 .init = sun_ctl_init, 52 .set_ind = sun_ctl_set_ind 53 }; 54 55 static kbd_dev_t *kbd_dev; 42 56 43 57 #define KBD_KEY_RELEASE 0x80 … … 46 60 static int scanmap_simple[]; 47 61 48 int kbd_ctl_init(void)62 static int sun_ctl_init(kbd_dev_t *kdev) 49 63 { 64 kbd_dev = kdev; 50 65 return 0; 51 66 } 52 67 53 void kbd_ctl_parse_scancode(int scancode)68 static void sun_ctl_parse_scancode(int scancode) 54 69 { 55 70 kbd_event_type_t type; … … 71 86 key = scanmap_simple[scancode]; 72 87 if (key != 0) 73 kbd_push_ev( type, key);88 kbd_push_ev(kbd_dev, type, key); 74 89 } 75 90 76 void kbd_ctl_set_ind(unsigned mods)91 static void sun_ctl_set_ind(kbd_dev_t *kdev, unsigned mods) 77 92 { 78 93 (void) mods; -
uspace/srv/hid/input/generic/gsp.c
rdf8110d3 rd900699 29 29 /** 30 30 * @addtogroup kbdgen generic 31 * @ingroup kbd31 * @ingroup input 32 32 * @{ 33 33 */ -
uspace/srv/hid/input/generic/stroke.c
rdf8110d3 rd900699 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kbd29 /** @addtogroup input 30 30 * @{ 31 31 */ … … 52 52 53 53 /** Simulate keystroke using sequences of key presses and releases. */ 54 void stroke_sim( unsigned mod, unsigned key)54 void stroke_sim(kbd_dev_t *kdev, unsigned mod, unsigned key) 55 55 { 56 56 int i; … … 60 60 while (mods_keys[i][0] != 0) { 61 61 if (mod & mods_keys[i][0]) { 62 kbd_push_ev( KEY_PRESS, mods_keys[i][1]);62 kbd_push_ev(kdev, KEY_PRESS, mods_keys[i][1]); 63 63 } 64 64 ++i; … … 67 67 /* Simulate key press and release. */ 68 68 if (key != 0) { 69 kbd_push_ev( KEY_PRESS, key);70 kbd_push_ev( KEY_RELEASE, key);69 kbd_push_ev(kdev, KEY_PRESS, key); 70 kbd_push_ev(kdev, KEY_RELEASE, key); 71 71 } 72 72 … … 75 75 while (mods_keys[i][0] != 0) { 76 76 if (mod & mods_keys[i][0]) { 77 kbd_push_ev( KEY_RELEASE, mods_keys[i][1]);77 kbd_push_ev(kdev, KEY_RELEASE, mods_keys[i][1]); 78 78 } 79 79 ++i; -
uspace/srv/hid/input/include/gsp.h
rdf8110d3 rd900699 27 27 */ 28 28 29 /** @addtogroup kbdgen generic29 /** @addtogroup inputgen generic 30 30 * @brief Generic scancode parser. 31 * @ingroup kbd31 * @ingroup input 32 32 * @{ 33 */ 33 */ 34 34 /** @file 35 35 */ -
uspace/srv/hid/input/include/input.h
rdf8110d3 rd900699 1 1 /* 2 2 * Copyright (c) 2006 Josef Cejka 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 27 28 */ 28 29 29 /** @addtogroup kbdgen generic30 * @brief HelenOS generic uspace keyboard handler.31 * @ingroup kbd30 /** @addtogroup inputgen generic 31 * @brief HelenOS input server. 32 * @ingroup input 32 33 * @{ 33 34 */ … … 35 36 */ 36 37 37 #ifndef KBD_KBD_H_38 #define KBD_KBD_H_38 #ifndef INPUT_H_ 39 #define INPUT_H_ 39 40 40 41 #include <bool.h> 42 43 #define NAME "input" 44 #define NAMESPACE "hid_in" 41 45 42 46 extern bool irc_service; 43 47 extern int irc_phone; 44 48 45 extern void kbd_push_scancode(int); 46 extern void kbd_push_ev(int, unsigned int); 49 extern link_t mouse_devs; 50 51 void input_event_move(int, int); 52 void input_event_button(int bnum, int press); 47 53 48 54 #endif -
uspace/srv/hid/input/include/kbd_ctl.h
rdf8110d3 rd900699 1 1 /* 2 * Copyright (c) 2009 Jiri Svoboda 3 * Copyright (c) 2011 Lubos Slovak 4 * (copied from /uspace/srv/hid/kbd/include/layout.h) 2 * Copyright (c) 2011 Jiri Svoboda 5 3 * All rights reserved. 6 4 * … … 29 27 */ 30 28 31 /** @addtogroup drvusbhid 29 /** @addtogroup inputgen generic 30 * @brief Keyboard controller driver interface. 31 * @ingroup input 32 32 * @{ 33 33 */ 34 34 /** @file 35 * Keyboard layout.36 35 */ 37 36 38 #ifndef USB_HID_LAYOUT_H_39 #define USB_HID_LAYOUT_H_37 #ifndef KBD_CTL_H_ 38 #define KBD_CTL_H_ 40 39 41 #include <sys/types.h> 42 #include <io/console.h> 40 #include <kbd_port.h> 43 41 44 typedef struct { 45 void (*reset)(void); 46 wchar_t (*parse_ev)(kbd_event_t *); 47 } layout_op_t; 42 struct kbd_dev; 48 43 49 extern layout_op_t us_qwerty_op; 50 extern layout_op_t us_dvorak_op; 51 extern layout_op_t cz_op; 44 typedef struct kbd_ctl_ops { 45 void (*parse_scancode)(int); 46 int (*init)(struct kbd_dev *); 47 void (*set_ind)(struct kbd_dev *, unsigned); 48 } kbd_ctl_ops_t; 49 50 extern kbd_ctl_ops_t apple_ctl; 51 extern kbd_ctl_ops_t gxe_fb_ctl; 52 extern kbd_ctl_ops_t kbdev_ctl; 53 extern kbd_ctl_ops_t pc_ctl; 54 extern kbd_ctl_ops_t stty_ctl; 55 extern kbd_ctl_ops_t sun_ctl; 52 56 53 57 #endif … … 55 59 /** 56 60 * @} 57 */ 61 */ 62 -
uspace/srv/hid/input/include/layout.h
rdf8110d3 rd900699 27 27 */ 28 28 29 /** @addtogroup kbdgen generic30 * @brief HelenOS generic uspace keyboard handler.31 * @ingroup kbd29 /** @addtogroup inputgen generic 30 * @brief Keyboard layout interface. 31 * @ingroup input 32 32 * @{ 33 33 */ … … 41 41 #include <io/console.h> 42 42 43 typedef struct { 44 void (*reset)(void); 45 wchar_t (*parse_ev)(kbd_event_t *);46 } layout_op_t;43 /** Layout instance state */ 44 typedef struct layout { 45 /** Ops structure */ 46 struct layout_ops *ops; 47 47 48 extern layout_op_t us_qwerty_op; 49 extern layout_op_t us_dvorak_op; 50 extern layout_op_t cz_op; 48 /* Layout-private data */ 49 void *layout_priv; 50 } layout_t; 51 52 /** Layout ops */ 53 typedef struct layout_ops { 54 int (*create)(layout_t *); 55 void (*destroy)(layout_t *); 56 wchar_t (*parse_ev)(layout_t *, kbd_event_t *); 57 } layout_ops_t; 58 59 extern layout_ops_t us_qwerty_ops; 60 extern layout_ops_t us_dvorak_ops; 61 extern layout_ops_t cz_ops; 62 63 extern layout_t *layout_create(layout_ops_t *); 64 extern void layout_destroy(layout_t *); 65 extern wchar_t layout_parse_ev(layout_t *, kbd_event_t *); 51 66 52 67 #endif -
uspace/srv/hid/input/include/mouse.h
rdf8110d3 rd900699 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kbdgen generic30 * @brief HelenOS generic uspace keyboard handler.31 * @ingroup kbd29 /** @addtogroup inputgen generic 30 * @brief Mouse device handling. 31 * @ingroup input 32 32 * @{ 33 */ 33 */ 34 34 /** @file 35 35 */ 36 36 37 #ifndef KBD_PORT_H_38 #define KBD_PORT_H_37 #ifndef MOUSE_H_ 38 #define MOUSE_H_ 39 39 40 #include < sys/types.h>40 #include <adt/list.h> 41 41 42 extern int kbd_port_init(void); 43 extern void kbd_port_yield(void); 44 extern void kbd_port_reclaim(void); 45 extern void kbd_port_write(uint8_t); 42 typedef struct mouse_dev { 43 /** Link to mouse_devs list */ 44 link_t mouse_devs; 45 46 /** Path to the device */ 47 const char *dev_path; 48 } mouse_dev_t; 49 50 int mouse_add_dev(const char *dev_path); 46 51 47 52 #endif … … 49 54 /** 50 55 * @} 51 */ 52 56 */ -
uspace/srv/hid/input/include/stroke.h
rdf8110d3 rd900699 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kbdgen generic29 /** @addtogroup inputgen generic 30 30 * @brief Generic scancode parser. 31 * @ingroup kbd31 * @ingroup input 32 32 * @{ 33 33 */ … … 38 38 #define KBD_STROKE_H_ 39 39 40 extern void stroke_sim(unsigned, unsigned); 40 #include <kbd.h> 41 42 extern void stroke_sim(kbd_dev_t *, unsigned, unsigned); 41 43 42 44 #endif -
uspace/srv/hid/input/layout/cz.c
rdf8110d3 rd900699 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kbd29 /** @addtogroup input 30 30 * @brief Czech QWERTZ layout. 31 31 * @{ 32 32 */ 33 33 34 #include <kbd.h> 34 #include <errno.h> 35 #include <input.h> 35 36 #include <io/console.h> 36 37 #include <io/keycode.h> 37 38 #include <bool.h> 38 39 #include <layout.h> 39 40 static void layout_reset(void); 41 static wchar_t layout_parse_ev(kbd_event_t *ev); 40 #include <stdlib.h> 41 42 static int cz_create(layout_t *); 43 static void cz_destroy(layout_t *); 44 static wchar_t cz_parse_ev(layout_t *, kbd_event_t *ev); 42 45 43 46 enum m_state { … … 47 50 }; 48 51 49 static enum m_state mstate; 50 51 layout_op_t cz_op = { 52 layout_reset, 53 layout_parse_ev 52 typedef struct { 53 enum m_state mstate; 54 } layout_cz_t; 55 56 layout_ops_t cz_ops = { 57 .create = cz_create, 58 .destroy = cz_destroy, 59 .parse_ev = cz_parse_ev 54 60 }; 55 61 … … 273 279 } 274 280 275 static wchar_t parse_ms_hacek( kbd_event_t *ev)281 static wchar_t parse_ms_hacek(layout_cz_t *cz_state, kbd_event_t *ev) 276 282 { 277 283 wchar_t c; 278 284 279 mstate = ms_start;285 cz_state->mstate = ms_start; 280 286 281 287 /* Produce no characters when Ctrl or Alt is pressed. */ … … 291 297 } 292 298 293 static wchar_t parse_ms_carka( kbd_event_t *ev)299 static wchar_t parse_ms_carka(layout_cz_t *cz_state, kbd_event_t *ev) 294 300 { 295 301 wchar_t c; 296 302 297 mstate = ms_start;303 cz_state->mstate = ms_start; 298 304 299 305 /* Produce no characters when Ctrl or Alt is pressed. */ … … 309 315 } 310 316 311 static wchar_t parse_ms_start( kbd_event_t *ev)317 static wchar_t parse_ms_start(layout_cz_t *cz_state, kbd_event_t *ev) 312 318 { 313 319 wchar_t c; … … 319 325 if (ev->key == KC_EQUALS) { 320 326 if ((ev->mods & KM_SHIFT) != 0) 321 mstate = ms_hacek;327 cz_state->mstate = ms_hacek; 322 328 else 323 mstate = ms_carka;329 cz_state->mstate = ms_carka; 324 330 325 331 return 0; … … 379 385 } 380 386 381 static void layout_reset(void) 382 { 383 mstate = ms_start; 384 } 385 386 static wchar_t layout_parse_ev(kbd_event_t *ev) 387 { 387 static int cz_create(layout_t *state) 388 { 389 layout_cz_t *cz_state; 390 391 cz_state = malloc(sizeof(layout_cz_t)); 392 if (cz_state == NULL) { 393 printf(NAME ": Out of memory.\n"); 394 return ENOMEM; 395 } 396 397 cz_state->mstate = ms_start; 398 state->layout_priv = (void *) cz_state; 399 400 return EOK; 401 } 402 403 static void cz_destroy(layout_t *state) 404 { 405 free(state->layout_priv); 406 } 407 408 static wchar_t cz_parse_ev(layout_t *state, kbd_event_t *ev) 409 { 410 layout_cz_t *cz_state = (layout_cz_t *) state->layout_priv; 411 388 412 if (ev->type != KEY_PRESS) 389 413 return 0; … … 392 416 return 0; 393 417 394 switch ( mstate) {418 switch (cz_state->mstate) { 395 419 case ms_start: 396 return parse_ms_start( ev);420 return parse_ms_start(cz_state, ev); 397 421 case ms_hacek: 398 return parse_ms_hacek( ev);422 return parse_ms_hacek(cz_state, ev); 399 423 case ms_carka: 400 return parse_ms_carka( ev);424 return parse_ms_carka(cz_state, ev); 401 425 } 402 426 -
uspace/srv/hid/input/layout/us_dvorak.c
rdf8110d3 rd900699 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kbd29 /** @addtogroup input 30 30 * @brief US Dvorak Simplified Keyboard layout. 31 31 * @{ 32 32 */ 33 33 34 #include <errno.h> 34 35 #include <kbd.h> 35 36 #include <io/console.h> … … 37 38 #include <layout.h> 38 39 39 static void layout_reset(void); 40 static wchar_t layout_parse_ev(kbd_event_t *ev); 41 42 layout_op_t us_dvorak_op = { 43 layout_reset, 44 layout_parse_ev 40 static int us_dvorak_create(layout_t *); 41 static void us_dvorak_destroy(layout_t *); 42 static wchar_t us_dvorak_parse_ev(layout_t *, kbd_event_t *ev); 43 44 layout_ops_t us_dvorak_ops = { 45 .create = us_dvorak_create, 46 .destroy = us_dvorak_destroy, 47 .parse_ev = us_dvorak_parse_ev 45 48 }; 46 49 … … 206 209 } 207 210 208 static void layout_reset(void) 209 { 210 } 211 212 static wchar_t layout_parse_ev(kbd_event_t *ev) 211 static int us_dvorak_create(layout_t *state) 212 { 213 return EOK; 214 } 215 216 static void us_dvorak_destroy(layout_t *state) 217 { 218 } 219 220 static wchar_t us_dvorak_parse_ev(layout_t *state, kbd_event_t *ev) 213 221 { 214 222 wchar_t c; -
uspace/srv/hid/input/layout/us_qwerty.c
rdf8110d3 rd900699 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kbd29 /** @addtogroup input 30 30 * @brief US QWERTY layout. 31 31 * @{ 32 */ 33 32 */ 33 34 #include <errno.h> 34 35 #include <kbd.h> 35 36 #include <io/console.h> … … 37 38 #include <layout.h> 38 39 39 static void layout_reset(void); 40 static wchar_t layout_parse_ev(kbd_event_t *ev); 41 42 layout_op_t us_qwerty_op = { 43 layout_reset, 44 layout_parse_ev 40 static int us_qwerty_create(layout_t *); 41 static void us_qwerty_destroy(layout_t *); 42 static wchar_t us_qwerty_parse_ev(layout_t *, kbd_event_t *ev); 43 44 layout_ops_t us_qwerty_ops = { 45 .create = us_qwerty_create, 46 .destroy = us_qwerty_destroy, 47 .parse_ev = us_qwerty_parse_ev 45 48 }; 46 49 … … 200 203 } 201 204 202 static void layout_reset(void) 203 { 204 } 205 206 static wchar_t layout_parse_ev(kbd_event_t *ev) 205 static int us_qwerty_create(layout_t *state) 206 { 207 return EOK; 208 } 209 210 static void us_qwerty_destroy(layout_t *state) 211 { 212 } 213 214 static wchar_t us_qwerty_parse_ev(layout_t *state, kbd_event_t *ev) 207 215 { 208 216 wchar_t c; -
uspace/srv/hid/input/port/adb.c
rdf8110d3 rd900699 1 1 /* 2 * Copyright (c) 201 0Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 38 38 #include <async.h> 39 39 #include <async_obsolete.h> 40 #include <input.h> 40 41 #include <kbd_port.h> 41 42 #include <kbd.h> … … 46 47 #include <devmap_obsolete.h> 47 48 48 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall );49 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); 49 50 static void adb_kbd_reg0_data(uint16_t data); 50 51 52 static int adb_port_init(kbd_dev_t *); 53 static void adb_port_yield(void); 54 static void adb_port_reclaim(void); 55 static void adb_port_write(uint8_t data); 56 57 kbd_port_ops_t adb_port = { 58 .init = adb_port_init, 59 .yield = adb_port_yield, 60 .reclaim = adb_port_reclaim, 61 .write = adb_port_write 62 }; 63 64 static kbd_dev_t *kbd_dev; 51 65 static int dev_phone; 52 66 53 #define NAME "kbd" 54 55 int kbd_port_init(void) 67 static int adb_port_init(kbd_dev_t *kdev) 56 68 { 57 69 const char *dev = "adb/kbd"; 58 70 devmap_handle_t handle; 71 72 kbd_dev = kdev; 59 73 60 74 int rc = devmap_device_get_handle(dev, &handle, 0); … … 69 83 70 84 /* NB: The callback connection is slotted for removal */ 71 rc = async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events); 85 rc = async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events, 86 NULL); 72 87 if (rc != EOK) { 73 88 printf(NAME ": Failed to create callback from device\n"); … … 78 93 } 79 94 80 void kbd_port_yield(void)95 static void adb_port_yield(void) 81 96 { 82 97 } 83 98 84 void kbd_port_reclaim(void)99 static void adb_port_reclaim(void) 85 100 { 86 101 } 87 102 88 void kbd_port_write(uint8_t data)103 static void adb_port_write(uint8_t data) 89 104 { 90 105 /*async_msg_1(dev_phone, CHAR_WRITE_BYTE, data);*/ 91 106 } 92 107 93 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall )108 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 94 109 { 95 110 /* Ignore parameters, the connection is already opened */ … … 125 140 126 141 if (b0 != 0xff) 127 kbd_push_scancode( b0);142 kbd_push_scancode(kbd_dev, b0); 128 143 if (b1 != 0xff) 129 kbd_push_scancode( b1);144 kbd_push_scancode(kbd_dev, b1); 130 145 } 131 146 -
uspace/srv/hid/input/port/chardev.c
rdf8110d3 rd900699 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 38 38 #include <async.h> 39 39 #include <async_obsolete.h> 40 #include <input.h> 40 41 #include <kbd_port.h> 41 42 #include <kbd.h> … … 45 46 #include <stdio.h> 46 47 47 #define NAME "kbd/chardev" 48 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); 48 49 49 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall); 50 static int chardev_port_init(kbd_dev_t *); 51 static void chardev_port_yield(void); 52 static void chardev_port_reclaim(void); 53 static void chardev_port_write(uint8_t data); 50 54 55 kbd_port_ops_t chardev_port = { 56 .init = chardev_port_init, 57 .yield = chardev_port_yield, 58 .reclaim = chardev_port_reclaim, 59 .write = chardev_port_write 60 }; 61 62 static kbd_dev_t *kbd_dev; 51 63 static int dev_phone; 52 64 … … 59 71 static const unsigned int num_devs = sizeof(in_devs) / sizeof(in_devs[0]); 60 72 61 int kbd_port_init(void)73 static int chardev_port_init(kbd_dev_t *kdev) 62 74 { 63 75 devmap_handle_t handle; 64 76 unsigned int i; 65 77 int rc; 78 79 kbd_dev = kdev; 66 80 67 81 for (i = 0; i < num_devs; i++) { … … 83 97 84 98 /* NB: The callback connection is slotted for removal */ 85 if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) { 99 if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events, 100 NULL) != 0) { 86 101 printf(NAME ": Failed to create callback from device\n"); 87 102 return -1; … … 91 106 } 92 107 93 void kbd_port_yield(void)108 static void chardev_port_yield(void) 94 109 { 95 110 } 96 111 97 void kbd_port_reclaim(void)112 static void chardev_port_reclaim(void) 98 113 { 99 114 } 100 115 101 void kbd_port_write(uint8_t data)116 static void chardev_port_write(uint8_t data) 102 117 { 103 118 async_obsolete_msg_1(dev_phone, CHAR_WRITE_BYTE, data); 104 119 } 105 120 106 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall )121 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 107 122 { 108 123 /* Ignore parameters, the connection is already opened */ … … 121 136 switch (IPC_GET_IMETHOD(call)) { 122 137 case CHAR_NOTIF_BYTE: 123 kbd_push_scancode( IPC_GET_ARG1(call));138 kbd_push_scancode(kbd_dev, IPC_GET_ARG1(call)); 124 139 break; 125 140 default: -
uspace/srv/hid/input/port/gxemul.c
rdf8110d3 rd900699 1 1 /* 2 2 * Copyright (c) 2007 Michal Kebrt 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 42 43 #include <errno.h> 43 44 45 static int gxemul_port_init(kbd_dev_t *); 46 static void gxemul_port_yield(void); 47 static void gxemul_port_reclaim(void); 48 static void gxemul_port_write(uint8_t data); 49 50 kbd_port_ops_t gxemul_port = { 51 .init = gxemul_port_init, 52 .yield = gxemul_port_yield, 53 .reclaim = gxemul_port_reclaim, 54 .write = gxemul_port_write 55 }; 56 57 static kbd_dev_t *kbd_dev; 58 44 59 static irq_cmd_t gxemul_cmds[] = { 45 60 { … … 61 76 62 77 /** Initializes keyboard handler. */ 63 int kbd_port_init(void)78 static int gxemul_port_init(kbd_dev_t *kdev) 64 79 { 80 kbd_dev = kdev; 81 65 82 sysarg_t addr; 66 83 if (sysinfo_get_value("kbd.address.virtual", &addr) != EOK) … … 77 94 } 78 95 79 void kbd_port_yield(void)96 static void gxemul_port_yield(void) 80 97 { 81 98 } 82 99 83 void kbd_port_reclaim(void)100 static void gxemul_port_reclaim(void) 84 101 { 85 102 } 86 103 87 void kbd_port_write(uint8_t data)104 static void gxemul_port_write(uint8_t data) 88 105 { 89 106 (void) data; … … 101 118 int scan_code = IPC_GET_ARG2(*call); 102 119 103 kbd_push_scancode( scan_code);120 kbd_push_scancode(kbd_dev, scan_code); 104 121 } 105 122 -
uspace/srv/hid/input/port/msim.c
rdf8110d3 rd900699 1 1 /* 2 2 * Copyright (c) 2006 Josef Cejka 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 42 43 #include <errno.h> 43 44 44 irq_cmd_t msim_cmds[] = { 45 static int msim_port_init(kbd_dev_t *); 46 static void msim_port_yield(void); 47 static void msim_port_reclaim(void); 48 static void msim_port_write(uint8_t data); 49 50 kbd_port_ops_t msim_port = { 51 .init = msim_port_init, 52 .yield = msim_port_yield, 53 .reclaim = msim_port_reclaim, 54 .write = msim_port_write 55 }; 56 57 static kbd_dev_t *kbd_dev; 58 59 static irq_cmd_t msim_cmds[] = { 45 60 { 46 61 .cmd = CMD_PIO_READ_8, … … 51 66 .cmd = CMD_ACCEPT 52 67 } 53 54 68 }; 55 69 56 irq_code_t msim_kbd = {70 static irq_code_t msim_kbd = { 57 71 sizeof(msim_cmds) / sizeof(irq_cmd_t), 58 72 msim_cmds … … 61 75 static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call); 62 76 63 int kbd_port_init(void)77 static int msim_port_init(kbd_dev_t *kdev) 64 78 { 79 kbd_dev = kdev; 80 65 81 sysarg_t vaddr; 66 82 if (sysinfo_get_value("kbd.address.virtual", &vaddr) != EOK) … … 78 94 } 79 95 80 void kbd_port_yield(void)96 static void msim_port_yield(void) 81 97 { 82 98 } 83 99 84 void kbd_port_reclaim(void)100 static void msim_port_reclaim(void) 85 101 { 86 102 } 87 103 88 void kbd_port_write(uint8_t data)104 static void msim_port_write(uint8_t data) 89 105 { 90 106 (void) data; … … 94 110 { 95 111 int scan_code = IPC_GET_ARG2(*call); 96 kbd_push_scancode( scan_code);112 kbd_push_scancode(kbd_dev, scan_code); 97 113 } 98 114 -
uspace/srv/hid/input/port/niagara.c
rdf8110d3 rd900699 1 1 /* 2 2 * Copyright (c) 2008 Pavel Rimsky 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 46 47 #include <errno.h> 47 48 49 static int niagara_port_init(kbd_dev_t *); 50 static void niagara_port_yield(void); 51 static void niagara_port_reclaim(void); 52 static void niagara_port_write(uint8_t data); 53 54 kbd_port_ops_t niagara_port = { 55 .init = niagara_port_init, 56 .yield = niagara_port_yield, 57 .reclaim = niagara_port_reclaim, 58 .write = niagara_port_write 59 }; 60 61 static kbd_dev_t *kbd_dev; 62 48 63 #define POLL_INTERVAL 10000 49 64 … … 70 85 71 86 /* virtual address of the shared buffer */ 72 input_buffer_t input_buffer;87 static input_buffer_t input_buffer; 73 88 74 89 static volatile bool polling_disabled = false; … … 79 94 * Maps the shared buffer and creates the polling thread. 80 95 */ 81 int kbd_port_init(void)96 static int niagara_port_init(kbd_dev_t *kdev) 82 97 { 98 kbd_dev = kdev; 99 83 100 sysarg_t paddr; 84 101 if (sysinfo_get_value("niagara.inbuf.address", &paddr) != EOK) … … 105 122 } 106 123 107 void kbd_port_yield(void)124 static void niagara_port_yield(void) 108 125 { 109 126 polling_disabled = true; 110 127 } 111 128 112 void kbd_port_reclaim(void)129 static void niagara_port_reclaim(void) 113 130 { 114 131 polling_disabled = false; 115 132 } 116 133 117 void kbd_port_write(uint8_t data)134 static void niagara_port_write(uint8_t data) 118 135 { 119 136 (void) data; … … 132 149 input_buffer->read_ptr = 133 150 ((input_buffer->read_ptr) + 1) % INPUT_BUFFER_SIZE; 134 kbd_push_scancode( c);151 kbd_push_scancode(kbd_dev, c); 135 152 } 136 153 } -
uspace/srv/hid/input/port/ns16550.c
rdf8110d3 rd900699 1 1 /* 2 2 * Copyright (c) 2006 Josef Cejka 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 39 40 #include <async_obsolete.h> 40 41 #include <sysinfo.h> 42 #include <input.h> 41 43 #include <kbd.h> 42 44 #include <kbd_port.h> 43 #include <sun.h>44 45 #include <ddi.h> 45 46 #include <errno.h> 47 48 static int ns16550_port_init(kbd_dev_t *); 49 static void ns16550_port_yield(void); 50 static void ns16550_port_reclaim(void); 51 static void ns16550_port_write(uint8_t data); 52 53 kbd_port_ops_t ns16550_port = { 54 .init = ns16550_port_init, 55 .yield = ns16550_port_yield, 56 .reclaim = ns16550_port_reclaim, 57 .write = ns16550_port_write 58 }; 59 60 static kbd_dev_t *kbd_dev; 46 61 47 62 /* NS16550 registers */ … … 91 106 92 107 static uintptr_t ns16550_physical; 93 static uintptr_t ns16550_kernel; 108 static uintptr_t ns16550_kernel; 94 109 95 int ns16550_port_init(void) 110 static kbd_dev_t *kbd_dev; 111 112 static int ns16550_port_init(kbd_dev_t *kdev) 96 113 { 97 114 void *vaddr; 98 115 116 kbd_dev = kdev; 117 118 sysarg_t ns16550; 119 if (sysinfo_get_value("kbd.type.ns16550", &ns16550) != EOK) 120 return -1; 121 if (!ns16550) 122 return -1; 123 99 124 if (sysinfo_get_value("kbd.address.physical", &ns16550_physical) != EOK) 100 125 return -1; … … 116 141 } 117 142 143 static void ns16550_port_yield(void) 144 { 145 } 146 147 static void ns16550_port_reclaim(void) 148 { 149 } 150 151 static void ns16550_port_write(uint8_t data) 152 { 153 (void) data; 154 } 155 118 156 static void ns16550_irq_handler(ipc_callid_t iid, ipc_call_t *call) 119 157 { 120 158 int scan_code = IPC_GET_ARG2(*call); 121 kbd_push_scancode( scan_code);159 kbd_push_scancode(kbd_dev, scan_code); 122 160 123 161 if (irc_service) -
uspace/srv/hid/input/port/pl050.c
rdf8110d3 rd900699 1 1 /* 2 2 * Copyright (c) 2009 Vineeth Pillai 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 46 47 #include <errno.h> 47 48 49 static int pl050_port_init(kbd_dev_t *); 50 static void pl050_port_yield(void); 51 static void pl050_port_reclaim(void); 52 static void pl050_port_write(uint8_t data); 53 54 kbd_port_ops_t pl050_port = { 55 .init = pl050_port_init, 56 .yield = pl050_port_yield, 57 .reclaim = pl050_port_reclaim, 58 .write = pl050_port_write 59 }; 60 61 static kbd_dev_t *kbd_dev; 62 48 63 #define PL050_STAT_RXFULL (1 << 4) 49 64 … … 82 97 static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call); 83 98 84 int kbd_port_init(void)99 static int pl050_port_init(kbd_dev_t *kdev) 85 100 { 101 kbd_dev = kdev; 102 86 103 sysarg_t addr; 87 104 if (sysinfo_get_value("kbd.address.status", &addr) != EOK) … … 105 122 } 106 123 107 void kbd_port_yield(void)124 static void pl050_port_yield(void) 108 125 { 109 126 } 110 127 111 void kbd_port_reclaim(void)128 static void pl050_port_reclaim(void) 112 129 { 113 130 } 114 131 115 void kbd_port_write(uint8_t data)132 static void pl050_port_write(uint8_t data) 116 133 { 117 134 (void) data; … … 122 139 int scan_code = IPC_GET_ARG2(*call); 123 140 124 kbd_push_scancode( scan_code);141 kbd_push_scancode(kbd_dev, scan_code); 125 142 return; 126 143 } -
uspace/srv/hid/input/port/sgcn.c
rdf8110d3 rd900699 1 1 /* 2 2 * Copyright (c) 2008 Pavel Rimsky 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 46 47 #include <errno.h> 47 48 49 static int sgcn_port_init(kbd_dev_t *); 50 static void sgcn_port_yield(void); 51 static void sgcn_port_reclaim(void); 52 static void sgcn_port_write(uint8_t data); 53 54 kbd_port_ops_t sgcn_port = { 55 .init = sgcn_port_init, 56 .yield = sgcn_port_yield, 57 .reclaim = sgcn_port_reclaim, 58 .write = sgcn_port_write 59 }; 60 61 static kbd_dev_t *kbd_dev; 62 48 63 #define POLL_INTERVAL 10000 49 64 … … 101 116 * Maps the physical memory (SRAM) and creates the polling thread. 102 117 */ 103 int kbd_port_init(void) 104 { 118 static int sgcn_port_init(kbd_dev_t *kdev) 119 { 120 kbd_dev = kdev; 121 105 122 sysarg_t sram_paddr; 106 123 if (sysinfo_get_value("sram.address.physical", &sram_paddr) != EOK) … … 130 147 } 131 148 132 void kbd_port_yield(void)149 static void sgcn_port_yield(void) 133 150 { 134 151 polling_disabled = true; 135 152 } 136 153 137 void kbd_port_reclaim(void)154 static void sgcn_port_reclaim(void) 138 155 { 139 156 polling_disabled = false; 140 157 } 141 158 142 void kbd_port_write(uint8_t data)159 static void sgcn_port_write(uint8_t data) 143 160 { 144 161 (void) data; … … 167 184 buf_ptr = (volatile char *) 168 185 SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); 169 kbd_push_scancode( c);186 kbd_push_scancode(kbd_dev, c); 170 187 } 171 188 } -
uspace/srv/hid/input/port/ski.c
rdf8110d3 rd900699 1 1 /* 2 2 * Copyright (c) 2005 Jakub Jermar 3 * Copyright (c) 20 09Jiri Svoboda3 * Copyright (c) 2011 Jiri Svoboda 4 4 * All rights reserved. 5 5 * … … 45 45 #include <bool.h> 46 46 47 static int ski_port_init(kbd_dev_t *); 48 static void ski_port_yield(void); 49 static void ski_port_reclaim(void); 50 static void ski_port_write(uint8_t data); 51 52 kbd_port_ops_t ski_port = { 53 .init = ski_port_init, 54 .yield = ski_port_yield, 55 .reclaim = ski_port_reclaim, 56 .write = ski_port_write 57 }; 58 59 static kbd_dev_t *kbd_dev; 60 47 61 #define SKI_GETCHAR 21 48 62 … … 55 69 56 70 /** Initialize Ski port driver. */ 57 int kbd_port_init(void)71 static int ski_port_init(kbd_dev_t *kdev) 58 72 { 59 73 thread_id_t tid; 60 74 int rc; 75 76 kbd_dev = kdev; 61 77 62 78 rc = thread_create(ski_thread_impl, NULL, "kbd_poll", &tid); … … 68 84 } 69 85 70 void kbd_port_yield(void)86 static void ski_port_yield(void) 71 87 { 72 88 polling_disabled = true; 73 89 } 74 90 75 void kbd_port_reclaim(void)91 static void ski_port_reclaim(void) 76 92 { 77 93 polling_disabled = false; 78 94 } 79 95 80 void kbd_port_write(uint8_t data)96 static void ski_port_write(uint8_t data) 81 97 { 82 98 (void) data; … … 94 110 if (c == 0) 95 111 break; 96 kbd_push_scancode( c);112 kbd_push_scancode(kbd_dev, c); 97 113 } 98 114 … … 112 128 uint64_t ch; 113 129 130 #ifdef UARCH_ia64 114 131 asm volatile ( 115 132 "mov r15 = %1\n" … … 121 138 : "r15", "r8" 122 139 ); 123 140 #else 141 ch = 0; 142 #endif 124 143 return (int32_t) ch; 125 144 } -
uspace/srv/hid/input/port/z8530.c
rdf8110d3 rd900699 1 1 /* 2 2 * Copyright (c) 2006 Martin Decky 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 39 40 #include <async_obsolete.h> 40 41 #include <sysinfo.h> 42 #include <input.h> 41 43 #include <kbd.h> 42 44 #include <kbd_port.h> 43 #include <sun.h>44 45 #include <sys/types.h> 45 46 #include <ddi.h> 46 47 #include <errno.h> 48 49 static int z8530_port_init(kbd_dev_t *); 50 static void z8530_port_yield(void); 51 static void z8530_port_reclaim(void); 52 static void z8530_port_write(uint8_t data); 53 54 kbd_port_ops_t z8530_port = { 55 .init = z8530_port_init, 56 .yield = z8530_port_yield, 57 .reclaim = z8530_port_reclaim, 58 .write = z8530_port_write 59 }; 60 61 static kbd_dev_t *kbd_dev; 47 62 48 63 #define CHAN_A_STATUS 4 … … 77 92 } 78 93 }; 79 80 irq_code_t z8530_kbd = {94 95 static irq_code_t z8530_kbd = { 81 96 sizeof(z8530_cmds) / sizeof(irq_cmd_t), 82 97 z8530_cmds … … 85 100 static void z8530_irq_handler(ipc_callid_t iid, ipc_call_t *call); 86 101 87 int z8530_port_init(void)102 static int z8530_port_init(kbd_dev_t *kdev) 88 103 { 104 kbd_dev = kdev; 105 106 sysarg_t z8530; 107 if (sysinfo_get_value("kbd.type.z8530", &z8530) != EOK) 108 return -1; 109 if (!z8530) 110 return -1; 111 89 112 sysarg_t kaddr; 90 113 if (sysinfo_get_value("kbd.address.kernel", &kaddr) != EOK) … … 104 127 } 105 128 129 static void z8530_port_yield(void) 130 { 131 } 132 133 static void z8530_port_reclaim(void) 134 { 135 } 136 137 static void z8530_port_write(uint8_t data) 138 { 139 (void) data; 140 } 141 106 142 static void z8530_irq_handler(ipc_callid_t iid, ipc_call_t *call) 107 143 { 108 144 int scan_code = IPC_GET_ARG2(*call); 109 kbd_push_scancode( scan_code);145 kbd_push_scancode(kbd_dev, scan_code); 110 146 111 147 if (irc_service) -
uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
rdf8110d3 rd900699 73 73 static s3c24xx_ts_t *ts; 74 74 75 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall); 75 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall, 76 void *arg); 76 77 static void s3c24xx_ts_irq_handler(ipc_callid_t iid, ipc_call_t *call); 77 78 static void s3c24xx_ts_pen_down(s3c24xx_ts_t *ts); … … 373 374 374 375 /** Handle mouse client connection. */ 375 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall) 376 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall, 377 void *arg) 376 378 { 377 379 ipc_callid_t callid;
Note:
See TracChangeset
for help on using the changeset viewer.
