Changeset a33f0a6 in mainline for uspace/srv/hid/input/port/adb.c
- Timestamp:
- 2011-08-03T17:34:57Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1940326
- Parents:
- 52a79081 (diff), 3fab770 (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
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 201 0Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 30 30 * @ingroup kbd 31 31 * @{ 32 */ 32 */ 33 33 /** @file 34 34 * @brief ADB keyboard port driver. … … 37 37 #include <ipc/adb.h> 38 38 #include <async.h> 39 #include <input.h> 39 40 #include <kbd_port.h> 40 41 #include <kbd.h> … … 42 43 #include <fcntl.h> 43 44 #include <errno.h> 45 #include <devmap.h> 44 46 45 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); 46 48 static void adb_kbd_reg0_data(uint16_t data); 47 49 48 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); 49 54 50 #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 }; 51 61 52 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) 53 66 { 54 const char *input = "/dev/adb/kbd"; 55 int input_fd; 56 57 printf(NAME ": open %s\n", input); 58 59 input_fd = open(input, O_RDONLY); 60 if (input_fd < 0) { 61 printf(NAME ": Failed opening %s (%d)\n", input, input_fd); 62 return false; 67 const char *dev = "adb/kbd"; 68 devmap_handle_t handle; 69 async_exch_t *exch; 70 int rc; 71 72 kbd_dev = kdev; 73 74 rc = devmap_device_get_handle(dev, &handle, 0); 75 if (rc != EOK) 76 return rc; 77 78 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0); 79 if (dev_sess == NULL) { 80 printf("%s: Failed to connect to device\n", NAME); 81 return ENOENT; 63 82 } 64 65 dev_phone = fd_phone(input_fd); 66 if (dev_phone < 0) { 67 printf(NAME ": Failed to connect to device\n"); 68 return false; 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; 69 89 } 70 90 71 91 /* NB: The callback connection is slotted for removal */ 72 if (async_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) { 73 printf(NAME ": Failed to create callback from device\n"); 74 return false; 92 rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL); 93 async_exchange_end(exch); 94 if (rc != EOK) { 95 printf("%s: Failed to create callback from device\n", NAME); 96 async_hangup(dev_sess); 97 return rc; 75 98 } 76 77 return 0;99 100 return EOK; 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 */ … … 100 123 101 124 int retval; 102 103 switch (IPC_GET_IMETHOD(call)) { 104 case IPC_M_PHONE_HUNGUP: 125 126 if (!IPC_GET_IMETHOD(call)) { 105 127 /* TODO: Handle hangup */ 106 128 return; 129 } 130 131 switch (IPC_GET_IMETHOD(call)) { 107 132 case ADB_REG_NOTIF: 108 133 adb_kbd_reg0_data(IPC_GET_ARG1(call)); … … 117 142 static void adb_kbd_reg0_data(uint16_t data) 118 143 { 119 uint8_t b0, b1; 120 121 b0 = (data >> 8) & 0xff; 122 b1 = data & 0xff; 123 144 uint8_t b0 = (data >> 8) & 0xff; 145 uint8_t b1 = data & 0xff; 146 124 147 if (b0 != 0xff) 125 kbd_push_scancode(b0); 148 kbd_push_data(kbd_dev, b0); 149 126 150 if (b1 != 0xff) 127 kbd_push_ scancode(b1);151 kbd_push_data(kbd_dev, b1); 128 152 } 129 153
Note:
See TracChangeset
for help on using the changeset viewer.