Changeset 41811af in mainline for uspace/srv/hid/kbd/port/chardev.c
- Timestamp:
- 2011-06-10T10:14:26Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ab547063
- Parents:
- 9536e6e (diff), 390d80d (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/kbd/port/chardev.c
r9536e6e r41811af 30 30 * @ingroup kbd 31 31 * @{ 32 */ 32 */ 33 33 /** @file 34 34 * @brief Chardev keyboard port driver. … … 37 37 #include <ipc/char.h> 38 38 #include <async.h> 39 #include <async_obsolete.h> 39 40 #include <kbd_port.h> 40 41 #include <kbd.h> 41 #include <vfs/vfs.h> 42 #include <sys/stat.h> 43 #include <fcntl.h> 42 #include <devmap.h> 43 #include <devmap_obsolete.h> 44 44 #include <errno.h> 45 #include <stdio.h> 46 47 #define NAME "kbd/chardev" 45 48 46 49 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall); … … 48 51 static int dev_phone; 49 52 50 #define NAME "kbd"51 52 53 /** List of devices to try connecting to. */ 53 54 static const char *in_devs[] = { 54 " /dev/char/ps2a",55 " /dev/char/s3c24ser"55 "char/ps2a", 56 "char/s3c24ser" 56 57 }; 57 58 58 static const int num_devs = sizeof(in_devs) / sizeof(in_devs[0]);59 static const unsigned int num_devs = sizeof(in_devs) / sizeof(in_devs[0]); 59 60 60 61 int kbd_port_init(void) 61 62 { 62 int input_fd;63 int i;64 65 input_fd = -1;63 devmap_handle_t handle; 64 unsigned int i; 65 int rc; 66 66 67 for (i = 0; i < num_devs; i++) { 67 struct stat s; 68 69 if (stat(in_devs[i], &s) == EOK) 68 rc = devmap_device_get_handle(in_devs[i], &handle, 0); 69 if (rc == EOK) 70 70 break; 71 71 } 72 72 73 73 if (i >= num_devs) { 74 printf( NAME ": Could not find any suitable input device.\n");74 printf("%s: Could not find any suitable input device\n", NAME); 75 75 return -1; 76 76 } 77 78 input_fd = open(in_devs[i], O_RDONLY); 79 if (input_fd < 0) { 80 printf(NAME ": failed opening device %s (%d).\n", in_devs[i], 81 input_fd); 82 return -1; 77 78 dev_phone = devmap_obsolete_device_connect(handle, IPC_FLAG_BLOCKING); 79 if (dev_phone < 0) { 80 printf("%s: Failed connecting to device\n", NAME); 81 return ENOENT; 83 82 } 84 85 dev_phone = fd_phone(input_fd); 86 if (dev_phone < 0) { 87 printf(NAME ": Failed connecting to device\n"); 88 return -1; 89 } 90 83 91 84 /* NB: The callback connection is slotted for removal */ 92 if (async_ connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) {85 if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) { 93 86 printf(NAME ": Failed to create callback from device\n"); 94 87 return -1; … … 108 101 void kbd_port_write(uint8_t data) 109 102 { 110 async_ msg_1(dev_phone, CHAR_WRITE_BYTE, data);103 async_obsolete_msg_1(dev_phone, CHAR_WRITE_BYTE, data); 111 104 } 112 105 … … 118 111 ipc_call_t call; 119 112 ipc_callid_t callid = async_get_call(&call); 113 114 if (!IPC_GET_IMETHOD(call)) { 115 /* TODO: Handle hangup */ 116 return; 117 } 120 118 121 119 int retval; 122 120 123 121 switch (IPC_GET_IMETHOD(call)) { 124 case IPC_M_PHONE_HUNGUP:125 /* TODO: Handle hangup */126 return;127 122 case CHAR_NOTIF_BYTE: 128 123 kbd_push_scancode(IPC_GET_ARG1(call));
Note:
See TracChangeset
for help on using the changeset viewer.