Changeset 8ff0bd2 in mainline for uspace/srv/hid/input/port/adb.c
- Timestamp:
- 2011-09-04T11:30:58Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 03bc76a
- Parents:
- d2c67e7 (diff), deac215e (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/adb.c
rd2c67e7 r8ff0bd2 1 1 /* 2 * Copyright (c) 201 0Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 37 37 #include <ipc/adb.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> … … 43 43 #include <fcntl.h> 44 44 #include <errno.h> 45 #include <devmap.h> 46 #include <devmap_obsolete.h> 45 #include <loc.h> 47 46 48 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall );47 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); 49 48 static void adb_kbd_reg0_data(uint16_t data); 50 49 51 static int dev_phone; 50 static int adb_port_init(kbd_dev_t *); 51 static void adb_port_yield(void); 52 static void adb_port_reclaim(void); 53 static void adb_port_write(uint8_t data); 52 54 53 #define NAME "kbd" 55 kbd_port_ops_t adb_port = { 56 .init = adb_port_init, 57 .yield = adb_port_yield, 58 .reclaim = adb_port_reclaim, 59 .write = adb_port_write 60 }; 54 61 55 int kbd_port_init(void) 62 static kbd_dev_t *kbd_dev; 63 static async_sess_t *dev_sess; 64 65 static int adb_port_init(kbd_dev_t *kdev) 56 66 { 57 67 const char *dev = "adb/kbd"; 58 devmap_handle_t handle; 68 service_id_t service_id; 69 async_exch_t *exch; 70 int rc; 59 71 60 int rc = devmap_device_get_handle(dev, &handle, 0); 61 if (rc == EOK) { 62 dev_phone = devmap_obsolete_device_connect(handle, 0); 63 if (dev_phone < 0) { 64 printf("%s: Failed to connect to device\n", NAME); 65 return dev_phone; 66 } 67 } else 72 kbd_dev = kdev; 73 74 rc = loc_service_get_id(dev, &service_id, 0); 75 if (rc != EOK) 68 76 return rc; 69 77 78 dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0); 79 if (dev_sess == NULL) { 80 printf("%s: Failed to connect to device\n", NAME); 81 return ENOENT; 82 } 83 84 exch = async_exchange_begin(dev_sess); 85 if (exch == NULL) { 86 printf("%s: Failed starting exchange with device\n", NAME); 87 async_hangup(dev_sess); 88 return ENOMEM; 89 } 90 70 91 /* NB: The callback connection is slotted for removal */ 71 rc = async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events); 92 rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL); 93 async_exchange_end(exch); 72 94 if (rc != EOK) { 73 printf(NAME ": Failed to create callback from device\n"); 95 printf("%s: Failed to create callback from device\n", NAME); 96 async_hangup(dev_sess); 74 97 return rc; 75 98 } … … 78 101 } 79 102 80 void kbd_port_yield(void)103 static void adb_port_yield(void) 81 104 { 82 105 } 83 106 84 void kbd_port_reclaim(void)107 static void adb_port_reclaim(void) 85 108 { 86 109 } 87 110 88 void kbd_port_write(uint8_t data)111 static void adb_port_write(uint8_t data) 89 112 { 90 113 /*async_msg_1(dev_phone, CHAR_WRITE_BYTE, data);*/ 91 114 } 92 115 93 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall )116 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 94 117 { 95 118 /* Ignore parameters, the connection is already opened */ … … 119 142 static void adb_kbd_reg0_data(uint16_t data) 120 143 { 121 uint8_t b0, b1; 122 123 b0 = (data >> 8) & 0xff; 124 b1 = data & 0xff; 125 144 uint8_t b0 = (data >> 8) & 0xff; 145 uint8_t b1 = data & 0xff; 146 126 147 if (b0 != 0xff) 127 kbd_push_scancode(b0); 148 kbd_push_data(kbd_dev, b0); 149 128 150 if (b1 != 0xff) 129 kbd_push_ scancode(b1);151 kbd_push_data(kbd_dev, b1); 130 152 } 131 153
Note:
See TracChangeset
for help on using the changeset viewer.