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_TAB, 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 },
71 static const char pnd_script_base[] = "sudo -n /usr/pandora/scripts";
72 static char **pnd_filter_list;
74 static void scan_for_filters(void)
82 dir = opendir("/etc/pandora/conf/dss_fir");
84 perror("filter opendir");
97 if (ent->d_type != DT_REG && ent->d_type != DT_LNK)
106 mfilters = calloc(count + 1, sizeof(mfilters[0]));
107 if (mfilters == NULL)
111 for (i = 0; (ent = readdir(dir)); ) {
114 if (ent->d_type != DT_REG && ent->d_type != DT_LNK)
117 len = strlen(ent->d_name);
119 // skip pre-HF5 extra files
120 if (len >= 3 && strcmp(ent->d_name + len - 3, "_v3") == 0)
122 if (len >= 3 && strcmp(ent->d_name + len - 3, "_v5") == 0)
125 // have to cut "_up_h" for pre-HF5
126 if (len > 5 && strcmp(ent->d_name + len - 5, "_up_h") == 0)
129 if (len > sizeof(buff) - 1)
132 strncpy(buff, ent->d_name, len);
134 mfilters[i] = strdup(buff);
135 if (mfilters[i] != NULL)
140 pnd_filter_list = mfilters;
141 menu_set_filter_list((void *)mfilters);
150 in_evdev_init(in_evdev_defbinds);
152 gpiokeys_id = in_name_to_id("evdev:gpio-keys");
153 in_set_config(gpiokeys_id, IN_CFG_KEY_NAMES,
154 pandora_gpio_keys, sizeof(pandora_gpio_keys));
155 in_set_config(gpiokeys_id, IN_CFG_DEFAULT_DEV, NULL, 0);
156 in_adev[0] = in_name_to_id("evdev:nub0");
157 in_adev[1] = in_name_to_id("evdev:nub1");
164 void plat_finish(void)
169 static void apply_lcdrate(int pal)
173 snprintf(buf, sizeof(buf), "%s/op_lcdrate.sh %d",
174 pnd_script_base, pal ? 50 : 60);
178 static void apply_filter(int which)
183 if (pnd_filter_list == NULL)
186 for (i = 0; i < which; i++)
187 if (pnd_filter_list[i] == NULL)
190 if (pnd_filter_list[i] == NULL)
193 snprintf(buf, sizeof(buf), "%s/op_videofir.sh %s",
194 pnd_script_base, pnd_filter_list[i]);
198 void plat_gvideo_open(int is_pal)
200 static int old_pal = -1, old_filter = -1;
202 if (is_pal != old_pal) {
203 apply_lcdrate(is_pal);
206 if (filter != old_filter) {
207 apply_filter(filter);
211 plat_omap_gvideo_open();
214 int plat_cpu_clock_get(void)
218 f = fopen("/proc/pandora/cpu_mhz_max", "r");
220 fscanf(f, "%d", &ret);
226 int plat_cpu_clock_apply(int cpu_clock)
230 if (cpu_clock != 0 && cpu_clock != plat_cpu_clock_get()) {
231 snprintf(buf, sizeof(buf), "unset DISPLAY; echo y | %s/op_cpuspeed.sh %d",
232 pnd_script_base, cpu_clock);
238 int plat_get_bat_capacity(void)
242 f = fopen("/sys/class/power_supply/bq27500-0/capacity", "r");
244 fscanf(f, "%d", &ret);
250 void plat_step_volume(int is_up)
254 void plat_trigger_vibrate(int is_strong)