|
14 | 14 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | 15 | */ |
16 | 16 | #include <linux/fs.h> |
17 | | -#include <linux/kobject.h> |
18 | 17 | #include <linux/cdev.h> |
19 | 18 | #include <linux/init.h> |
20 | 19 | #include <linux/device.h> |
21 | 20 | #include <linux/module.h> |
22 | | -#include <linux/delay.h> |
23 | 21 | #include <linux/timer.h> |
24 | 22 | #include <linux/gpio.h> |
25 | 23 | #include <linux/input.h> |
26 | 24 | #include <linux/kernel.h> |
27 | | -#include <linux/slab.h> |
28 | 25 | #include <linux/backlight.h> |
29 | | -#include <asm/irq.h> |
30 | 26 | #include <asm/io.h> |
31 | | -#include <asm/io.h> |
32 | | -#include <asm/arch-suniv/cpu.h> |
33 | | -#include <asm/arch-suniv/gpio.h> |
34 | 27 | #include <linux/uaccess.h> |
35 | | -#include <linux/unistd.h> |
| 28 | +#include <linux/kallsyms.h> |
| 29 | +#include <linux/module.h> |
| 30 | + |
| 31 | +static void (*miyoo_increase_volume)(void) = NULL; |
| 32 | +static void (*miyoo_decrease_volume)(void) = NULL; |
| 33 | +extern void MIYOO_INCREASE_VOLUME(void); |
| 34 | +extern void MIYOO_DECREASE_VOLUME(void); |
36 | 35 |
|
37 | 36 | //Hotkeys |
38 | 37 | #define KILL_HK "/bin/sh", "-c", "/bin/kill -9 $(/bin/ps -al | /bin/grep \"/mnt/\")" |
@@ -165,6 +164,12 @@ bool non_hotkey_menu=false; |
165 | 164 | module_param(miyoo_ver,uint,0660); |
166 | 165 | module_param(miyoo_layout,uint,0660); |
167 | 166 |
|
| 167 | +bool is_module_loaded(const char *mod_name) |
| 168 | +{ |
| 169 | + struct module *mod = find_module(mod_name); |
| 170 | + return mod != NULL; |
| 171 | +} |
| 172 | + |
168 | 173 | static int do_input_request(uint32_t pin, const char*name) |
169 | 174 | { |
170 | 175 | if(gpio_request(pin, name) < 0){ |
@@ -235,8 +240,6 @@ static void scan_handler(struct timer_list *timer) |
235 | 240 | static uint32_t pre=0; |
236 | 241 | uint32_t scan=0, val=0, debounce=0; |
237 | 242 | static uint32_t touchRead=0, touchReadPrev=0; |
238 | | - extern void MIYOO_INCREASE_VOLUME(void); |
239 | | - extern void MIYOO_DECREASE_VOLUME(void); |
240 | 243 | static char * kill_argv[] = {KILL_HK, NULL}; |
241 | 244 | static char * kill_soft_argv[] = {KILL_SOFT_HK, NULL}; |
242 | 245 | static char * shutdown_argv[] = {SHUTDOWN_HK, NULL}; |
@@ -785,19 +788,27 @@ static void scan_handler(struct timer_list *timer) |
785 | 788 | } |
786 | 789 | } |
787 | 790 | else if((val & MY_R) && (val & MY_UP)){ |
788 | | - if(!hotkey_down && !hotkey_custom) { |
789 | | - MIYOO_INCREASE_VOLUME(); |
790 | | - hotkey_down = true; |
791 | | - } |
| 791 | + if (!hotkey_down && !hotkey_custom) { |
| 792 | + if (!miyoo_increase_volume && is_module_loaded("miyoo") ) { |
| 793 | + miyoo_increase_volume = symbol_get(MIYOO_INCREASE_VOLUME); |
| 794 | + } |
| 795 | + if (miyoo_increase_volume) |
| 796 | + miyoo_increase_volume(); |
| 797 | + hotkey_down = true; |
| 798 | + } |
792 | 799 | hotkey_actioned = true; |
793 | 800 | if (hotkey_custom) |
794 | 801 | hotkey = hotkey == 0 ? 5 : hotkey; |
795 | 802 | } |
796 | 803 | else if((val & MY_R) && (val & MY_DOWN)){ |
797 | | - if(!hotkey_down && !hotkey_custom) { |
798 | | - MIYOO_DECREASE_VOLUME(); |
799 | | - hotkey_down = true; |
800 | | - } |
| 804 | + if (!hotkey_down && !hotkey_custom) { |
| 805 | + if (!miyoo_decrease_volume && is_module_loaded("miyoo") ) { |
| 806 | + miyoo_decrease_volume = symbol_get(MIYOO_DECREASE_VOLUME); |
| 807 | + } |
| 808 | + if (miyoo_decrease_volume) |
| 809 | + miyoo_decrease_volume(); |
| 810 | + hotkey_down = true; |
| 811 | + } |
801 | 812 | hotkey_actioned = true; |
802 | 813 | if (hotkey_custom) |
803 | 814 | hotkey = hotkey == 0 ? 6 : hotkey; |
@@ -1113,7 +1124,10 @@ static void __exit kbd_exit(void) |
1113 | 1124 | { |
1114 | 1125 | input_unregister_device(mydev); |
1115 | 1126 | del_timer(&mytimer); |
1116 | | - |
| 1127 | + if (miyoo_increase_volume) |
| 1128 | + symbol_put(MIYOO_INCREASE_VOLUME); |
| 1129 | + if (miyoo_decrease_volume) |
| 1130 | + symbol_put(MIYOO_DECREASE_VOLUME); |
1117 | 1131 | device_destroy(myclass, major); |
1118 | 1132 | cdev_del(&mycdev); |
1119 | 1133 | class_destroy(myclass); |
|
0 commit comments