Changeset f1fae414 in mainline for uspace/srv/hid/input/port/chardev.c
- Timestamp:
- 2011-06-22T01:34:53Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8d7e82c1, cac458f
- Parents:
- 72ec8cc (diff), bf172825 (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 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/port/chardev.c
r72ec8cc rf1fae414 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 37 37 #include <ipc/char.h> 38 38 #include <async.h> 39 #include < async_obsolete.h>39 #include <input.h> 40 40 #include <kbd_port.h> 41 41 #include <kbd.h> 42 42 #include <devmap.h> 43 #include <devmap_obsolete.h>44 43 #include <errno.h> 45 44 #include <stdio.h> 46 45 47 #define NAME "kbd/chardev" 46 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); 48 47 49 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall); 48 static int chardev_port_init(kbd_dev_t *); 49 static void chardev_port_yield(void); 50 static void chardev_port_reclaim(void); 51 static void chardev_port_write(uint8_t data); 50 52 51 static int dev_phone; 53 kbd_port_ops_t chardev_port = { 54 .init = chardev_port_init, 55 .yield = chardev_port_yield, 56 .reclaim = chardev_port_reclaim, 57 .write = chardev_port_write 58 }; 59 60 static kbd_dev_t *kbd_dev; 61 static async_sess_t *dev_sess; 52 62 53 63 /** List of devices to try connecting to. */ … … 59 69 static const unsigned int num_devs = sizeof(in_devs) / sizeof(in_devs[0]); 60 70 61 int kbd_port_init(void)71 static int chardev_port_init(kbd_dev_t *kdev) 62 72 { 63 73 devmap_handle_t handle; 74 async_exch_t *exch; 64 75 unsigned int i; 65 76 int rc; 77 78 kbd_dev = kdev; 66 79 67 80 for (i = 0; i < num_devs; i++) { … … 76 89 } 77 90 78 dev_phone = devmap_obsolete_device_connect(handle, IPC_FLAG_BLOCKING); 79 if (dev_phone < 0) { 91 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 92 IPC_FLAG_BLOCKING); 93 if (dev_sess == NULL) { 80 94 printf("%s: Failed connecting to device\n", NAME); 81 95 return ENOENT; 82 96 } 83 97 98 exch = async_exchange_begin(dev_sess); 99 if (exch == NULL) { 100 printf("%s: Failed starting exchange with device\n", NAME); 101 async_hangup(dev_sess); 102 return ENOMEM; 103 } 104 84 105 /* NB: The callback connection is slotted for removal */ 85 if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) { 86 printf(NAME ": Failed to create callback from device\n"); 106 rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL); 107 async_exchange_end(exch); 108 109 if (rc != 0) { 110 printf("%s: Failed to create callback from device\n", NAME); 111 async_hangup(dev_sess); 87 112 return -1; 88 113 } 89 114 90 115 return 0; 91 116 } 92 117 93 void kbd_port_yield(void)118 static void chardev_port_yield(void) 94 119 { 95 120 } 96 121 97 void kbd_port_reclaim(void)122 static void chardev_port_reclaim(void) 98 123 { 99 124 } 100 125 101 void kbd_port_write(uint8_t data)126 static void chardev_port_write(uint8_t data) 102 127 { 103 async_obsolete_msg_1(dev_phone, CHAR_WRITE_BYTE, data); 128 async_exch_t *exch = async_exchange_begin(dev_sess); 129 if (exch == NULL) { 130 printf("%s: Failed starting exchange with device\n", NAME); 131 return; 132 } 133 134 async_msg_1(exch, CHAR_WRITE_BYTE, data); 135 async_exchange_end(exch); 104 136 } 105 137 106 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall )138 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 107 139 { 108 140 /* Ignore parameters, the connection is already opened */ … … 121 153 switch (IPC_GET_IMETHOD(call)) { 122 154 case CHAR_NOTIF_BYTE: 123 kbd_push_ scancode(IPC_GET_ARG1(call));155 kbd_push_data(kbd_dev, IPC_GET_ARG1(call)); 124 156 break; 125 157 default:
Note:
See TracChangeset
for help on using the changeset viewer.