Changes in uspace/srv/hid/kbd/port/chardev.c [79ae36dd:ffa2c8ef] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/kbd/port/chardev.c
r79ae36dd rffa2c8ef 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>40 39 #include <kbd_port.h> 41 40 #include <kbd.h> 42 #include <devmap.h> 43 #include <devmap_obsolete.h> 41 #include <vfs/vfs.h> 42 #include <sys/stat.h> 43 #include <fcntl.h> 44 44 #include <errno.h> 45 #include <stdio.h>46 47 #define NAME "kbd/chardev"48 45 49 46 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall); … … 51 48 static int dev_phone; 52 49 50 #define NAME "kbd" 51 53 52 /** List of devices to try connecting to. */ 54 53 static const char *in_devs[] = { 55 " char/ps2a",56 " char/s3c24ser"54 "/dev/char/ps2a", 55 "/dev/char/s3c24ser" 57 56 }; 58 57 59 static const unsignedint num_devs = sizeof(in_devs) / sizeof(in_devs[0]);58 static const int num_devs = sizeof(in_devs) / sizeof(in_devs[0]); 60 59 61 60 int kbd_port_init(void) 62 61 { 63 devmap_handle_t handle;64 unsignedint i;65 int rc; 66 62 int input_fd; 63 int i; 64 65 input_fd = -1; 67 66 for (i = 0; i < num_devs; i++) { 68 rc = devmap_device_get_handle(in_devs[i], &handle, 0); 69 if (rc == EOK) 67 struct stat s; 68 69 if (stat(in_devs[i], &s) == EOK) 70 70 break; 71 71 } 72 72 73 73 if (i >= num_devs) { 74 printf( "%s: Could not find any suitable input device\n", NAME);74 printf(NAME ": Could not find any suitable input device.\n"); 75 75 return -1; 76 76 } 77 78 dev_phone = devmap_obsolete_device_connect(handle, IPC_FLAG_BLOCKING); 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; 83 } 84 85 dev_phone = fd_phone(input_fd); 79 86 if (dev_phone < 0) { 80 printf( "%s: Failed connecting to device\n", NAME);81 return ENOENT;87 printf(NAME ": Failed connecting to device\n"); 88 return -1; 82 89 } 83 90 84 91 /* NB: The callback connection is slotted for removal */ 85 if (async_ obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) {92 if (async_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) { 86 93 printf(NAME ": Failed to create callback from device\n"); 87 94 return -1; … … 101 108 void kbd_port_write(uint8_t data) 102 109 { 103 async_ obsolete_msg_1(dev_phone, CHAR_WRITE_BYTE, data);110 async_msg_1(dev_phone, CHAR_WRITE_BYTE, data); 104 111 } 105 112 … … 111 118 ipc_call_t call; 112 119 ipc_callid_t callid = async_get_call(&call); 113 114 if (!IPC_GET_IMETHOD(call)) {115 /* TODO: Handle hangup */116 return;117 }118 120 119 121 int retval; 120 122 121 123 switch (IPC_GET_IMETHOD(call)) { 124 case IPC_M_PHONE_HUNGUP: 125 /* TODO: Handle hangup */ 126 return; 122 127 case CHAR_NOTIF_BYTE: 123 128 kbd_push_scancode(IPC_GET_ARG1(call));
Note:
See TracChangeset
for help on using the changeset viewer.