2 * (C) GraÅžvydas "notaz" Ignotas, 2011,2012
4 * This work is licensed under the terms of any of these licenses
6 * - GNU GPL, version 2 or later.
7 * - GNU LGPL, version 2.1 or later.
9 * See the COPYING file in the top-level directory.
15 #include <sys/types.h>
17 #include <linux/input.h>
23 static const char * const pandora_gpio_keys[KEY_MAX + 1] = {
24 [0 ... KEY_MAX] = NULL,
27 [KEY_RIGHT] = "Right",
30 [KEY_PAGEDOWN] = "(X)",
33 [KEY_RIGHTSHIFT]= "(L)",
34 [KEY_RIGHTCTRL] = "(R)",
35 [KEY_LEFTALT] = "Start",
36 [KEY_LEFTCTRL] = "Select",
37 [KEY_MENU] = "Pandora",
40 static const char pnd_script_base[] = "sudo -n /usr/pandora/scripts";
42 static void scan_for_filters(void)
50 dir = opendir("/etc/pandora/conf/dss_fir");
52 perror("filter opendir");
65 if (ent->d_type != DT_REG && ent->d_type != DT_LNK)
74 mfilters = calloc(count + 1, sizeof(mfilters[0]));
79 for (i = 0; (ent = readdir(dir)); ) {
82 if (ent->d_type != DT_REG && ent->d_type != DT_LNK)
85 len = strlen(ent->d_name);
87 // skip pre-HF5 extra files
88 if (len >= 3 && strcmp(ent->d_name + len - 3, "_v3") == 0)
90 if (len >= 3 && strcmp(ent->d_name + len - 3, "_v5") == 0)
93 // have to cut "_up_h" for pre-HF5
94 if (len > 5 && strcmp(ent->d_name + len - 5, "_up_h") == 0)
97 if (len > sizeof(buff) - 1)
100 strncpy(buff, ent->d_name, len);
102 mfilters[i] = strdup(buff);
103 if (mfilters[i] != NULL)
108 plat_target.filters = mfilters;
111 static void set_lcdrate(int is_pal)
113 static int old_pal = -1;
116 if (is_pal == old_pal)
119 snprintf(buf, sizeof(buf), "%s/op_lcdrate.sh %d",
120 pnd_script_base, is_pal ? 50 : 60);
125 static void set_filter(int which)
127 static int old_filter = -1;
131 if (plat_target.filters == NULL || which == old_filter)
134 for (i = 0; i < which; i++)
135 if (plat_target.filters[i] == NULL)
138 if (plat_target.filters[i] == NULL)
141 snprintf(buf, sizeof(buf), "%s/op_videofir.sh %s",
142 pnd_script_base, plat_target.filters[i]);
147 static int cpu_clock_get(void)
151 f = fopen("/proc/pandora/cpu_mhz_max", "r");
153 fscanf(f, "%d", &ret);
159 static int cpu_clock_set(int cpu_clock)
163 if (cpu_clock != 0 && cpu_clock != cpu_clock_get()) {
164 snprintf(buf, sizeof(buf), "unset DISPLAY; echo y | %s/op_cpuspeed.sh %d",
165 pnd_script_base, cpu_clock);
171 static int get_bat_capacity(void)
175 f = fopen("/sys/class/power_supply/bq27500-0/capacity", "r");
177 fscanf(f, "%d", &ret);
183 struct plat_target plat_target = {
192 int plat_target_init(void)
199 /* to be called after in_probe */
200 void plat_target_setup_input(void)
204 gpiokeys_id = in_name_to_id("evdev:gpio-keys");
205 in_set_config(gpiokeys_id, IN_CFG_KEY_NAMES,
206 pandora_gpio_keys, sizeof(pandora_gpio_keys));
207 in_set_config(gpiokeys_id, IN_CFG_DEFAULT_DEV, NULL, 0);
210 void plat_target_finish(void)