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