4 * This work is licensed under the terms of the GNU GPLv2 or later.
5 * See the COPYING file in the top-level directory.
11 #include <sys/types.h>
14 #include <sys/ioctl.h>
16 #include <linux/input.h>
20 #include "common/input.h"
21 #include "linux/in_evdev.h"
22 #include "plugin_lib.h"
24 #include "plat_omap.h"
28 static const char * const pandora_gpio_keys[KEY_MAX + 1] = {
29 [0 ... KEY_MAX] = NULL,
32 [KEY_RIGHT] = "Right",
35 [KEY_PAGEDOWN] = "(X)",
38 [KEY_RIGHTSHIFT]= "(L)",
39 [KEY_RIGHTCTRL] = "(R)",
40 [KEY_LEFTALT] = "Start",
41 [KEY_LEFTCTRL] = "Select",
42 [KEY_MENU] = "Pandora",
45 static const struct in_default_bind in_evdev_defbinds[] = {
46 { KEY_UP, IN_BINDTYPE_PLAYER12, DKEY_UP },
47 { KEY_DOWN, IN_BINDTYPE_PLAYER12, DKEY_DOWN },
48 { KEY_LEFT, IN_BINDTYPE_PLAYER12, DKEY_LEFT },
49 { KEY_RIGHT, IN_BINDTYPE_PLAYER12, DKEY_RIGHT },
50 { KEY_PAGEUP, IN_BINDTYPE_PLAYER12, DKEY_TRIANGLE },
51 { KEY_PAGEDOWN, IN_BINDTYPE_PLAYER12, DKEY_CROSS },
52 { KEY_END, IN_BINDTYPE_PLAYER12, DKEY_CIRCLE },
53 { KEY_HOME, IN_BINDTYPE_PLAYER12, DKEY_SQUARE },
54 { KEY_LEFTALT, IN_BINDTYPE_PLAYER12, DKEY_START },
55 { KEY_LEFTCTRL, IN_BINDTYPE_PLAYER12, DKEY_SELECT },
56 { KEY_RIGHTSHIFT,IN_BINDTYPE_PLAYER12, DKEY_L1 },
57 { KEY_RIGHTCTRL, IN_BINDTYPE_PLAYER12, DKEY_R1 },
58 { KEY_Q, IN_BINDTYPE_PLAYER12, DKEY_L2 },
59 { KEY_P, IN_BINDTYPE_PLAYER12, DKEY_R2 },
60 { KEY_MENU, IN_BINDTYPE_EMU, SACTION_MINIMIZE },
61 { KEY_SPACE, IN_BINDTYPE_EMU, SACTION_ENTER_MENU },
62 { KEY_1, IN_BINDTYPE_EMU, SACTION_SAVE_STATE },
63 { KEY_2, IN_BINDTYPE_EMU, SACTION_LOAD_STATE },
64 { KEY_3, IN_BINDTYPE_EMU, SACTION_PREV_SSLOT },
65 { KEY_4, IN_BINDTYPE_EMU, SACTION_NEXT_SSLOT },
66 { KEY_5, IN_BINDTYPE_EMU, SACTION_TOGGLE_FSKIP },
67 { KEY_6, IN_BINDTYPE_EMU, SACTION_SCREENSHOT },
68 { KEY_7, IN_BINDTYPE_EMU, SACTION_TOGGLE_RENDERER },
72 static const char pnd_script_base[] = "sudo -n /usr/pandora/scripts";
73 static char **pnd_filter_list;
75 static void scan_for_filters(void)
83 dir = opendir("/etc/pandora/conf/dss_fir");
85 perror("filter opendir");
98 if (ent->d_type != DT_REG && ent->d_type != DT_LNK)
107 mfilters = calloc(count + 1, sizeof(mfilters[0]));
108 if (mfilters == NULL)
112 for (i = 0; (ent = readdir(dir)); ) {
115 if (ent->d_type != DT_REG && ent->d_type != DT_LNK)
118 len = strlen(ent->d_name);
120 // skip pre-HF5 extra files
121 if (len >= 3 && strcmp(ent->d_name + len - 3, "_v3") == 0)
123 if (len >= 3 && strcmp(ent->d_name + len - 3, "_v5") == 0)
126 // have to cut "_up_h" for pre-HF5
127 if (len > 5 && strcmp(ent->d_name + len - 5, "_up_h") == 0)
130 if (len > sizeof(buff) - 1)
133 strncpy(buff, ent->d_name, len);
135 mfilters[i] = strdup(buff);
136 if (mfilters[i] != NULL)
141 pnd_filter_list = mfilters;
142 menu_set_filter_list((void *)mfilters);
151 in_evdev_init(in_evdev_defbinds);
153 gpiokeys_id = in_name_to_id("evdev:gpio-keys");
154 in_set_config(gpiokeys_id, IN_CFG_KEY_NAMES,
155 pandora_gpio_keys, sizeof(pandora_gpio_keys));
156 in_set_config(gpiokeys_id, IN_CFG_DEFAULT_DEV, NULL, 0);
157 in_adev[0] = in_name_to_id("evdev:nub0");
158 in_adev[1] = in_name_to_id("evdev:nub1");
165 void plat_finish(void)
170 static void apply_lcdrate(int pal)
174 snprintf(buf, sizeof(buf), "%s/op_lcdrate.sh %d",
175 pnd_script_base, pal ? 50 : 60);
179 static void apply_filter(int which)
184 if (pnd_filter_list == NULL)
187 for (i = 0; i < which; i++)
188 if (pnd_filter_list[i] == NULL)
191 if (pnd_filter_list[i] == NULL)
194 snprintf(buf, sizeof(buf), "%s/op_videofir.sh %s",
195 pnd_script_base, pnd_filter_list[i]);
199 void plat_gvideo_open(int is_pal)
201 static int old_pal = -1, old_filter = -1;
203 if (is_pal != old_pal) {
204 apply_lcdrate(is_pal);
207 if (filter != old_filter) {
208 apply_filter(filter);
212 plat_omap_gvideo_open();
215 int plat_cpu_clock_get(void)
219 f = fopen("/proc/pandora/cpu_mhz_max", "r");
221 fscanf(f, "%d", &ret);
227 int plat_cpu_clock_apply(int cpu_clock)
231 if (cpu_clock != 0 && cpu_clock != plat_cpu_clock_get()) {
232 snprintf(buf, sizeof(buf), "unset DISPLAY; echo y | %s/op_cpuspeed.sh %d",
233 pnd_script_base, cpu_clock);
239 int plat_get_bat_capacity(void)
243 f = fopen("/sys/class/power_supply/bq27500-0/capacity", "r");
245 fscanf(f, "%d", &ret);
251 void plat_step_volume(int is_up)
255 void plat_trigger_vibrate(int is_strong)