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>
19 #include "common/input.h"
20 #include "linux/in_evdev.h"
21 #include "plugin_lib.h"
25 static const char * const pandora_gpio_keys[KEY_MAX + 1] = {
26 [0 ... KEY_MAX] = NULL,
29 [KEY_RIGHT] = "Right",
32 [KEY_PAGEDOWN] = "(X)",
35 [KEY_RIGHTSHIFT]= "(L)",
36 [KEY_RIGHTCTRL] = "(R)",
37 [KEY_LEFTALT] = "Start",
38 [KEY_LEFTCTRL] = "Select",
39 [KEY_MENU] = "Pandora",
42 static const struct in_default_bind in_evdev_defbinds[] = {
43 { KEY_UP, IN_BINDTYPE_PLAYER12, DKEY_UP },
44 { KEY_DOWN, IN_BINDTYPE_PLAYER12, DKEY_DOWN },
45 { KEY_LEFT, IN_BINDTYPE_PLAYER12, DKEY_LEFT },
46 { KEY_RIGHT, IN_BINDTYPE_PLAYER12, DKEY_RIGHT },
47 { KEY_PAGEUP, IN_BINDTYPE_PLAYER12, DKEY_TRIANGLE },
48 { KEY_PAGEDOWN, IN_BINDTYPE_PLAYER12, DKEY_CROSS },
49 { KEY_END, IN_BINDTYPE_PLAYER12, DKEY_CIRCLE },
50 { KEY_HOME, IN_BINDTYPE_PLAYER12, DKEY_SQUARE },
51 { KEY_LEFTALT, IN_BINDTYPE_PLAYER12, DKEY_START },
52 { KEY_LEFTCTRL, IN_BINDTYPE_PLAYER12, DKEY_SELECT },
53 { KEY_RIGHTSHIFT,IN_BINDTYPE_PLAYER12, DKEY_L1 },
54 { KEY_RIGHTCTRL, IN_BINDTYPE_PLAYER12, DKEY_R1 },
55 { KEY_Q, IN_BINDTYPE_PLAYER12, DKEY_L2 },
56 { KEY_P, IN_BINDTYPE_PLAYER12, DKEY_R2 },
57 { KEY_TAB, IN_BINDTYPE_EMU, SACTION_MINIMIZE },
58 { KEY_SPACE, IN_BINDTYPE_EMU, SACTION_ENTER_MENU },
59 { KEY_1, IN_BINDTYPE_EMU, SACTION_SAVE_STATE },
60 { KEY_2, IN_BINDTYPE_EMU, SACTION_LOAD_STATE },
61 { KEY_3, IN_BINDTYPE_EMU, SACTION_PREV_SSLOT },
62 { KEY_4, IN_BINDTYPE_EMU, SACTION_NEXT_SSLOT },
63 { KEY_5, IN_BINDTYPE_EMU, SACTION_TOGGLE_FSKIP },
64 { KEY_6, IN_BINDTYPE_EMU, SACTION_SCREENSHOT },
68 int plat_pandora_init(void)
72 in_evdev_init(in_evdev_defbinds);
74 gpiokeys_id = in_name_to_id("evdev:gpio-keys");
75 in_set_config(gpiokeys_id, IN_CFG_KEY_NAMES,
76 pandora_gpio_keys, sizeof(pandora_gpio_keys));
77 in_set_config(gpiokeys_id, IN_CFG_DEFAULT_DEV, NULL, 0);
78 in_adev[0] = in_name_to_id("evdev:nub0");
79 in_adev[1] = in_name_to_id("evdev:nub1");
84 static const char pnd_script_base[] = "sudo -n /usr/pandora/scripts";
86 int plat_cpu_clock_get(void)
90 f = fopen("/proc/pandora/cpu_mhz_max", "r");
92 fscanf(f, "%d", &ret);
98 int plat_cpu_clock_apply(int cpu_clock)
102 if (cpu_clock != 0 && cpu_clock != plat_cpu_clock_get()) {
103 snprintf(buf, sizeof(buf), "unset DISPLAY; echo y | %s/op_cpuspeed.sh %d",
104 pnd_script_base, cpu_clock);
110 int plat_get_bat_capacity(void)
114 f = fopen("/sys/class/power_supply/bq27500-0/capacity", "r");
116 fscanf(f, "%d", &ret);