Merge branch 'org.openembedded.dev' of git@git.openembedded.net:openembedded into...
[openembedded.git] / recipes / linux / opensimpad / simpad-switches-input.patch
1
2 #
3 # Patch managed by http://www.holgerschurig.de/patcher.html
4 #
5
6 --- linux-2.4.27/drivers/misc/switches.h~simpad-switches-input
7 +++ linux-2.4.27/drivers/misc/switches.h
8 @@ -25,4 +25,14 @@
9  extern int  switches_ucb1x00_init(void);
10  extern void switches_ucb1x00_exit(void);
11  
12 +#ifdef CONFIG_SA1100_SIMPAD    
13 +#define SIMPAD_KEY_SUSPEND     0x0002
14 +#define SIMPAD_KEY_WWW         0x0008
15 +#define SIMPAD_KEY_ENTER       0x0010
16 +#define SIMPAD_KEY_UP          0x0020
17 +#define SIMPAD_KEY_DOWN                0x0040
18 +#define SIMPAD_KEY_LEFT                0x0080
19 +#define SIMPAD_KEY_RIGHT       0x0100
20 +#endif
21 +
22  #endif  /* !defined(_SWITCHES_H) */
23 --- linux-2.4.27/drivers/misc/switches-core.c~simpad-switches-input
24 +++ linux-2.4.27/drivers/misc/switches-core.c
25 @@ -16,6 +16,9 @@
26   *  11 September 2001 - UCB1200 driver framework support added.
27   *
28   *  19 December 2001 - separated out SA-1100 and UCB1x00 code.
29 + *
30 + *  3 July 2004 - Added generating of keyboard events. 
31 + *                Florian Boor <florian@handhelds.org>
32   */
33  
34  #include <linux/config.h>
35 @@ -30,7 +33,11 @@
36  #include <linux/slab.h>
37  #include <linux/wait.h>
38  
39 +#include <linux/input.h>
40 +
41  #include <asm/uaccess.h>
42 +#include <asm/hardware.h>
43 +#include <asm/keyboard.h>
44  
45  #include "switches.h"
46  
47 @@ -53,6 +60,19 @@
48  DECLARE_WAIT_QUEUE_HEAD(switches_wait);
49  LIST_HEAD(switches_event_queue);
50  
51 +#ifdef CONFIG_INPUT
52 +static struct input_dev idev;
53 +       
54 +int 
55 +dummy_k_translate(unsigned char scancode, unsigned char *keycode, char raw_mode)
56 +{
57 +       *keycode = scancode;
58 +       return 1;
59 +}
60 +
61 +extern int (*k_translate)(unsigned char, unsigned char *, char);
62 +
63 +#endif
64  
65  static ssize_t switches_read(struct file *file, char *buffer,
66                              size_t count, loff_t *pos)
67 @@ -148,6 +168,31 @@
68  {
69         struct switches_action *action;
70  
71 +#ifdef CONFIG_INPUT
72 +       /* create input events, the events to send depends on the platform */
73 +#ifdef CONFIG_SA1100_SIMPAD    
74 +       if (machine_is_simpad()) {
75 +               if (SWITCHES_COUNT(mask) > 0)
76 +               {
77 +                       if (mask->events[0] & SIMPAD_KEY_SUSPEND)
78 +                               input_report_key(&idev, KEY_POWER, (mask->states[0] & SIMPAD_KEY_SUSPEND) ? 0 : 1);
79 +                       if (mask->events[0] & SIMPAD_KEY_ENTER)
80 +                               input_report_key(&idev, KEY_ENTER, (mask->states[0] & SIMPAD_KEY_ENTER) ? 1 : 0);
81 +                       if (mask->events[0] & SIMPAD_KEY_UP)
82 +                               input_report_key(&idev, KEY_UP, (mask->states[0] & SIMPAD_KEY_UP) ? 1 : 0);
83 +                       if (mask->events[0] & SIMPAD_KEY_DOWN)
84 +                               input_report_key(&idev, KEY_DOWN, (mask->states[0] & SIMPAD_KEY_DOWN) ? 1 : 0);
85 +                       if (mask->events[0] & SIMPAD_KEY_LEFT)
86 +                               input_report_key(&idev, KEY_LEFT, (mask->states[0] & SIMPAD_KEY_LEFT) ? 1 : 0);
87 +                       if (mask->events[0] & SIMPAD_KEY_RIGHT)
88 +                               input_report_key(&idev, KEY_RIGHT, (mask->states[0] & SIMPAD_KEY_RIGHT) ? 1 : 0);
89 +                       if (mask->events[0] & SIMPAD_KEY_WWW)
90 +                               input_report_key(&idev, KEY_F10, (mask->states[0] & SIMPAD_KEY_WWW) ? 1 : 0);
91 +               }
92 +       }
93 +#endif
94 +#endif
95 +       /* take care of switches device */
96         if ((switches_users > 0) && (SWITCHES_COUNT(mask) > 0)) {
97  
98                 if ((action = (struct switches_action *)
99 @@ -197,6 +242,21 @@
100                 return -EIO;
101         }
102  
103 +#ifdef CONFIG_INPUT
104 +       /* init input driver stuff */
105 +       k_translate = dummy_k_translate;
106 +       idev.evbit[0] = BIT(EV_KEY); /* handle key events */
107 +
108 +       idev.keybit[LONG(KEY_POWER)] |= BIT(KEY_POWER);
109 +       idev.keybit[LONG(KEY_UP)] |= BIT(KEY_UP);
110 +       idev.keybit[LONG(KEY_DOWN)] |= BIT(KEY_DOWN);
111 +       idev.keybit[LONG(KEY_LEFT)] |= BIT(KEY_LEFT);
112 +       idev.keybit[LONG(KEY_RIGHT)] |= BIT(KEY_RIGHT);
113 +       idev.keybit[LONG(KEY_ENTER)] |= BIT(KEY_ENTER);
114 +       idev.keybit[LONG(KEY_F10)] |= BIT(KEY_F10);
115 +
116 +       input_register_device(&idev);
117 +#endif 
118         printk("Console switches initialized\n");
119  
120         return 0;
121 @@ -214,6 +274,10 @@
122         switches_ucb1x00_exit();
123  #endif
124  
125 +#ifdef CONFIG_INPUT
126 +       input_unregister_device(&idev);
127 +#endif
128 +       
129         if (misc_deregister(&switches_misc) < 0)
130                 printk(KERN_ERR "%s: unable to deregister misc device\n",
131                        SWITCHES_NAME);