29
29
/** @addtogroup kbd_port
34
34
* @brief ADB keyboard port driver.
37
37
#include <ipc/adb.h>
39
40
#include <kbd_port.h>
41
42
#include <vfs/vfs.h>
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);
52
int kbd_port_init(void)
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);
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
62
static kbd_dev_t *kbd_dev;
63
static async_sess_t *dev_sess;
65
static int adb_port_init(kbd_dev_t *kdev)
54
const char *input = "/dev/adb/kbd";
57
printf(NAME ": open %s\n", input);
59
input_fd = open(input, O_RDONLY);
61
printf(NAME ": Failed opening %s (%d)\n", input, input_fd);
65
dev_phone = fd_phone(input_fd);
67
printf(NAME ": Failed to connect to device\n");
67
const char *dev = "adb/kbd";
68
service_id_t service_id;
74
rc = loc_service_get_id(dev, &service_id, 0);
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);
84
exch = async_exchange_begin(dev_sess);
86
printf("%s: Failed starting exchange with device\n", NAME);
87
async_hangup(dev_sess);
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");
92
rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL);
93
async_exchange_end(exch);
95
printf("%s: Failed to create callback from device\n", NAME);
96
async_hangup(dev_sess);
80
void kbd_port_yield(void)
84
void kbd_port_reclaim(void)
88
void kbd_port_write(uint8_t data)
103
static void adb_port_yield(void)
107
static void adb_port_reclaim(void)
111
static void adb_port_write(uint8_t data)
90
113
/*async_msg_1(dev_phone, CHAR_WRITE_BYTE, data);*/
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)
95
118
/* Ignore parameters, the connection is already opened */