]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/input/lib/src/proxy.c
Inital import
[l4.git] / l4 / pkg / input / lib / src / proxy.c
1 /*
2  * (c) 2009 Technische Universität Dresden
3  * This file is part of TUD:OS and distributed under the terms of the
4  * GNU General Public License 2.
5  * Please see the COPYING-GPL-2 file for details.
6  */
7 #include <linux/kernel.h>
8 #include <linux/module.h>
9 #include <linux/init.h>
10 #include <linux/input.h>
11
12 #include <l4/sys/ipc.h>
13 #include <l4/sys/utcb.h>
14 #include <pthread.h>
15
16 #include "internal.h"
17
18 MODULE_AUTHOR("Alexander Warg");
19 MODULE_DESCRIPTION("L4 Proxy input injector");
20 MODULE_LICENSE("GPL");
21
22 static char proxy_name[] = "L4 input event injector";
23 static char proxy_phys[] = "l4/sys";
24
25 static struct input_dev l4proxy_dev;
26
27 static pthread_t irq_tid;
28
29 static void *irq_handler(void *dummy)
30 {
31         //l4thread_started(NULL);
32         printk("%s: IRQ handler up\n", proxy_name);
33         l4_umword_t input_server;
34         l4_umword_t d0 = 0, d1 = 0;
35
36         /* FIXME protocol hard-coded here */
37         while (1)
38           {
39             /*l4_msgtag_t res = */l4_ipc_wait(l4_utcb(), &input_server, L4_IPC_NEVER);
40             enter_kdebug("IMPLEMENT ME!");
41             input_event(&l4proxy_dev,
42                         d0 & (unsigned short)0xffff,
43                         (d0 >> 16) & (unsigned short)0xffff,
44                         d1);
45           }
46         return NULL;
47 }
48
49 //static int __init proxy_init(int prio)
50 int l4input_internal_proxy_init(int prio)
51 {
52         init_input_dev(&l4proxy_dev);
53         l4proxy_dev.name = proxy_name;
54         l4proxy_dev.phys = proxy_phys;
55         l4proxy_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS) | BIT(EV_MSC);
56
57         int i;
58         for (i = 0; i < NBITS(KEY_MAX); i++) l4proxy_dev.keybit[i] = ~0UL;
59         for (i = 0; i < NBITS(REL_MAX); i++) l4proxy_dev.relbit[i] = ~0UL;
60         for (i = 0; i < NBITS(ABS_MAX); i++) l4proxy_dev.absbit[i] = ~0UL;
61         for (i = 0; i < NBITS(MSC_MAX); i++) l4proxy_dev.mscbit[i] = ~0UL;
62
63         /* XXX this is no touchpad */
64         clear_bit(BTN_TOOL_FINGER, l4proxy_dev.keybit);
65
66         input_register_device(&l4proxy_dev);
67
68         printk(KERN_INFO "input: %s\n", proxy_name);
69
70         /* FIXME name hard-coded here */
71 #if 0
72         irq_tid = l4thread_create_named((l4thread_fn_t) irq_handler,
73                                        "l4i_proxy", 0,
74                                        L4THREAD_CREATE_SYNC);
75
76         if (L4THREAD_IS_ERR(irq_tid)) {
77 #endif
78         if (pthread_create(&irq_tid, NULL, irq_handler, NULL)) {
79                 printf("Error creating IRQ thread!");
80                 return 1;
81         }
82
83         return 0;
84 }