Changeset cac458f in mainline for uspace/srv/hid/input/port/adb_mouse.c
- Timestamp:
- 2011-06-22T01:59:39Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 41e2118
- Parents:
- 79506d6 (diff), f1fae414 (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
-
uspace/srv/hid/input/port/adb_mouse.c (moved) (moved from uspace/srv/hid/char_mouse/chardev.c ) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/port/adb_mouse.c
r79506d6 rcac458f 1 1 /* 2 * Copyright (c) 20 09 Jiri Svoboda2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mouse 29 /** @addtogroup mouse_port 30 * @ingroup mouse 30 31 * @{ 31 */ 32 */ 32 33 /** @file 33 * @brief 34 * @brief ADB mouse port driver. 34 35 */ 35 36 36 #include <ipc/ char.h>37 #include <ipc/adb.h> 37 38 #include <async.h> 38 #include < async_obsolete.h>39 #include < vfs/vfs.h>40 #include < fcntl.h>39 #include <input.h> 40 #include <mouse_port.h> 41 #include <mouse.h> 41 42 #include <errno.h> 42 43 #include <devmap.h> 43 #include <devmap_obsolete.h>44 #include <char_mouse.h>45 #include <mouse_port.h>46 44 47 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); 45 static mouse_dev_t *mouse_dev; 46 static async_sess_t *dev_sess; 48 47 49 static int dev_phone; 50 51 #define NAME "char_mouse" 52 53 int mouse_port_init(void) 54 { 55 devmap_handle_t handle; 56 int rc = devmap_device_get_handle("char/ps2b", &handle, 57 IPC_FLAG_BLOCKING); 58 59 if (rc != EOK) { 60 printf("%s: Failed resolving PS/2\n", NAME); 61 return rc; 62 } 63 64 dev_phone = devmap_obsolete_device_connect(handle, IPC_FLAG_BLOCKING); 65 if (dev_phone < 0) { 66 printf("%s: Failed connecting to PS/2\n", NAME); 67 return ENOENT; 68 } 69 70 /* NB: The callback connection is slotted for removal */ 71 if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, chardev_events, 72 NULL) != 0) { 73 printf(NAME ": Failed to create callback from device\n"); 74 return false; 75 } 76 77 return 0; 78 } 79 80 void mouse_port_yield(void) 81 { 82 } 83 84 void mouse_port_reclaim(void) 85 { 86 } 87 88 void mouse_port_write(uint8_t data) 89 { 90 async_obsolete_msg_1(dev_phone, CHAR_WRITE_BYTE, data); 91 } 92 93 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 48 static void mouse_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 94 49 { 95 50 /* Ignore parameters, the connection is already opened */ 96 51 while (true) { 97 98 52 ipc_call_t call; 99 53 ipc_callid_t callid = async_get_call(&call); 100 54 101 55 int retval; 102 56 … … 105 59 return; 106 60 } 107 61 108 62 switch (IPC_GET_IMETHOD(call)) { 109 case IPC_FIRST_USER_METHOD:110 mouse_ handle_byte(IPC_GET_ARG1(call));63 case ADB_REG_NOTIF: 64 mouse_push_data(mouse_dev, IPC_GET_ARG1(call)); 111 65 break; 112 66 default: 113 67 retval = ENOENT; 114 68 } 69 115 70 async_answer_0(callid, retval); 116 71 } 117 72 } 118 73 74 static int adb_port_init(mouse_dev_t *mdev) 75 { 76 const char *dev = "adb/mouse"; 77 78 mouse_dev = mdev; 79 80 devmap_handle_t handle; 81 int rc = devmap_device_get_handle(dev, &handle, 0); 82 if (rc != EOK) 83 return rc; 84 85 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0); 86 if (dev_sess == NULL) { 87 printf("%s: Failed to connect to device\n", NAME); 88 return ENOENT; 89 } 90 91 async_exch_t *exch = async_exchange_begin(dev_sess); 92 if (exch == NULL) { 93 printf("%s: Failed starting exchange with device\n", NAME); 94 async_hangup(dev_sess); 95 return ENOMEM; 96 } 97 98 /* NB: The callback connection is slotted for removal */ 99 rc = async_connect_to_me(exch, 0, 0, 0, mouse_port_events, NULL); 100 async_exchange_end(exch); 101 if (rc != EOK) { 102 printf("%s: Failed to create callback from device\n", NAME); 103 async_hangup(dev_sess); 104 return rc; 105 } 106 107 return EOK; 108 } 109 110 static void adb_port_yield(void) 111 { 112 } 113 114 static void adb_port_reclaim(void) 115 { 116 } 117 118 static void adb_port_write(uint8_t data) 119 { 120 } 121 122 mouse_port_ops_t adb_mouse_port = { 123 .init = adb_port_init, 124 .yield = adb_port_yield, 125 .reclaim = adb_port_reclaim, 126 .write = adb_port_write 127 }; 128 119 129 /** 120 130 * @}
Note:
See TracChangeset
for help on using the changeset viewer.
