aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornotaz2012-07-06 00:24:41 +0300
committernotaz2012-07-09 02:35:58 +0300
commitab423939f0af46542bb23000e77a30976c8c2335 (patch)
tree73d9e91d696994f0520347c4b9ad2126366eac9d
parent239f3754d8e0480f1e32bf414e49dec6e2ea019d (diff)
downloadpcsx_rearmed-ab423939f0af46542bb23000e77a30976c8c2335.tar.gz
pcsx_rearmed-ab423939f0af46542bb23000e77a30976c8c2335.tar.bz2
pcsx_rearmed-ab423939f0af46542bb23000e77a30976c8c2335.zip
frontend: move some leftover pandora parts out of common code
-rw-r--r--frontend/menu.c146
-rw-r--r--frontend/menu.h2
-rw-r--r--frontend/plat.h5
-rw-r--r--frontend/plat_dummy.c2
-rw-r--r--frontend/plat_omap.c17
-rw-r--r--frontend/plat_omap.h5
-rw-r--r--frontend/plat_pandora.c141
-rw-r--r--frontend/plat_pollux.c2
-rw-r--r--frontend/plat_sdl.c2
-rw-r--r--frontend/plugin_lib.c8
10 files changed, 179 insertions, 151 deletions
diff --git a/frontend/menu.c b/frontend/menu.c
index 65f7b98..7cdfe39 100644
--- a/frontend/menu.c
+++ b/frontend/menu.c
@@ -84,7 +84,7 @@ enum {
};
static int last_psx_w, last_psx_h, last_psx_bpp;
-static int scaling, filter, cpu_clock, cpu_clock_st, volume_boost, frameskip;
+static int scaling, cpu_clock, cpu_clock_st, volume_boost, frameskip;
static char rom_fname_reload[MAXPATHLEN];
static char last_selected_fname[MAXPATHLEN];
static int warned_about_bios, region, in_type_sel1, in_type_sel2;
@@ -92,6 +92,7 @@ static int psx_clock;
static int memcard1_sel, memcard2_sel;
int g_opts;
int soft_scaling, analog_deadzone; // for Caanoo
+int filter;
#ifdef __ARM_ARCH_7A__
#define DEFAULT_PSX_CLOCK 57
@@ -621,126 +622,6 @@ out:
free(gpu);
}
-// ---------- XXX: pandora specific -----------
-
-static const char pnd_script_base[] = "sudo -n /usr/pandora/scripts";
-static char **pnd_filter_list;
-
-static void apply_filter(int which)
-{
- static int old = -1;
- char buf[128];
- int i;
-
- if (pnd_filter_list == NULL || which == old)
- return;
-
- for (i = 0; i < which; i++)
- if (pnd_filter_list[i] == NULL)
- return;
-
- if (pnd_filter_list[i] == NULL)
- return;
-
- snprintf(buf, sizeof(buf), "%s/op_videofir.sh %s", pnd_script_base, pnd_filter_list[i]);
- system(buf);
- old = which;
-}
-
-static void apply_lcdrate(int pal)
-{
- static int old = -1;
- char buf[128];
-
- if (pal == old)
- return;
-
- snprintf(buf, sizeof(buf), "%s/op_lcdrate.sh %d",
- pnd_script_base, pal ? 50 : 60);
- system(buf);
- old = pal;
-}
-
-static menu_entry e_menu_gfx_options[];
-
-static void pnd_menu_init(void)
-{
- struct dirent *ent;
- int i, count = 0;
- char **mfilters;
- char buff[64];
- DIR *dir;
-
- cpu_clock_st = cpu_clock = plat_cpu_clock_get();
-
- dir = opendir("/etc/pandora/conf/dss_fir");
- if (dir == NULL) {
- perror("filter opendir");
- return;
- }
-
- while (1) {
- errno = 0;
- ent = readdir(dir);
- if (ent == NULL) {
- if (errno != 0)
- perror("readdir");
- break;
- }
-
- if (ent->d_type != DT_REG && ent->d_type != DT_LNK)
- continue;
-
- count++;
- }
-
- if (count == 0)
- return;
-
- mfilters = calloc(count + 1, sizeof(mfilters[0]));
- if (mfilters == NULL)
- return;
-
- rewinddir(dir);
- for (i = 0; (ent = readdir(dir)); ) {
- size_t len;
-
- if (ent->d_type != DT_REG && ent->d_type != DT_LNK)
- continue;
-
- len = strlen(ent->d_name);
-
- // skip pre-HF5 extra files
- if (len >= 3 && strcmp(ent->d_name + len - 3, "_v3") == 0)
- continue;
- if (len >= 3 && strcmp(ent->d_name + len - 3, "_v5") == 0)
- continue;
-
- // have to cut "_up_h" for pre-HF5
- if (len > 5 && strcmp(ent->d_name + len - 5, "_up_h") == 0)
- len -= 5;
-
- if (len > sizeof(buff) - 1)
- continue;
-
- strncpy(buff, ent->d_name, len);
- buff[len] = 0;
- mfilters[i] = strdup(buff);
- if (mfilters[i] != NULL)
- i++;
- }
- closedir(dir);
-
- i = me_id2offset(e_menu_gfx_options, MA_OPT_FILTERING);
- e_menu_gfx_options[i].data = (void *)mfilters;
- pnd_filter_list = mfilters;
-}
-
-void menu_finish(void)
-{
- plat_cpu_clock_apply(cpu_clock_st);
-}
-
// -------------- key config --------------
me_bind_action me_ctrl_actions[] =
@@ -1150,7 +1031,7 @@ static int menu_loop_cscaler(int id, int keys)
scaling = SCALE_CUSTOM;
- plat_gvideo_open();
+ plat_gvideo_open(Config.PsxType);
for (;;)
{
@@ -1186,7 +1067,7 @@ static int menu_loop_cscaler(int id, int keys)
if (g_layer_y + g_layer_h > 480)
g_layer_h = 480 - g_layer_y;
// resize the layer
- plat_gvideo_open();
+ plat_gvideo_open(Config.PsxType);
}
}
@@ -1214,6 +1095,16 @@ static int menu_loop_gfx_options(int id, int keys)
return 0;
}
+// XXX
+void menu_set_filter_list(void *filters)
+{
+ int i;
+
+ i = me_id2offset(e_menu_gfx_options, MA_OPT_FILTERING);
+ e_menu_gfx_options[i].data = filters;
+ me_enable(e_menu_gfx_options, MA_OPT_FILTERING, filters != NULL);
+}
+
// ------------ bios/plugins ------------
#ifdef __ARM_NEON__
@@ -2245,8 +2136,9 @@ void menu_init(void)
strcpy(last_selected_fname, "/media");
+ cpu_clock_st = cpu_clock = plat_cpu_clock_get();
+
scan_bios_plugins();
- pnd_menu_init();
menu_init_common();
menu_set_defconfig();
@@ -2387,8 +2279,6 @@ void menu_prepare_emu(void)
CDR_stop();
menu_sync_config();
- apply_lcdrate(Config.PsxType);
- apply_filter(filter);
if (cpu_clock > 0)
plat_cpu_clock_apply(cpu_clock);
@@ -2413,3 +2303,7 @@ void me_update_msg(const char *msg)
lprintf("msg: %s\n", menu_error_msg);
}
+void menu_finish(void)
+{
+ plat_cpu_clock_apply(cpu_clock_st);
+}
diff --git a/frontend/menu.h b/frontend/menu.h
index 7f366df..17163ec 100644
--- a/frontend/menu.h
+++ b/frontend/menu.h
@@ -4,6 +4,7 @@ void menu_loop(void);
void menu_finish(void);
void menu_notify_mode_change(int w, int h, int bpp);
+void menu_set_filter_list(void *filters);
enum opts {
OPT_SHOWFPS = 1 << 0,
@@ -15,3 +16,4 @@ enum opts {
extern int g_opts;
extern int soft_scaling, analog_deadzone;
+extern int filter;
diff --git a/frontend/plat.h b/frontend/plat.h
index 9076cd5..db66c57 100644
--- a/frontend/plat.h
+++ b/frontend/plat.h
@@ -6,10 +6,7 @@ int plat_cpu_clock_apply(int cpu_clock);
int plat_get_bat_capacity(void);
// indirectly called from GPU plugin
-void plat_gvideo_open(void);
+void plat_gvideo_open(int is_pal);
void *plat_gvideo_set_mode(int *w, int *h, int *bpp);
void *plat_gvideo_flip(void);
void plat_gvideo_close(void);
-
-// XXX
-int plat_pandora_init(void);
diff --git a/frontend/plat_dummy.c b/frontend/plat_dummy.c
index 26cd3a2..5b0adf1 100644
--- a/frontend/plat_dummy.c
+++ b/frontend/plat_dummy.c
@@ -23,7 +23,7 @@ void plat_video_menu_leave(void)
{
}
-void plat_gvideo_open(void)
+void plat_gvideo_open(int is_pal)
{
}
diff --git a/frontend/plat_omap.c b/frontend/plat_omap.c
index d3ba5c9..d5c10b9 100644
--- a/frontend/plat_omap.c
+++ b/frontend/plat_omap.c
@@ -20,6 +20,7 @@
#include "plugin_lib.h"
#include "pl_gun_ts.h"
#include "plat.h"
+#include "plat_omap.h"
#include "menu.h"
static struct vout_fbdev *main_fb, *layer_fb;
@@ -83,7 +84,7 @@ static int omap_enable_layer(int enabled)
g_layer_x, g_layer_y, g_layer_w, g_layer_h);
}
-void plat_gvideo_open(void)
+void plat_omap_gvideo_open(void)
{
omap_enable_layer(1);
@@ -150,20 +151,12 @@ void plat_minimize(void)
omap_enable_layer(1);
}
-void plat_step_volume(int is_up)
-{
-}
-
-void plat_trigger_vibrate(int is_strong)
-{
-}
-
void *plat_prepare_screenshot(int *w, int *h, int *bpp)
{
return NULL;
}
-void plat_init(void)
+void plat_omap_init(void)
{
const char *main_fb_name, *layer_fb_name;
int fd, ret, w, h;
@@ -217,8 +210,6 @@ void plat_init(void)
goto fail0;
}
- plat_pandora_init(); // XXX
-
return;
fail0:
@@ -226,7 +217,7 @@ fail0:
exit(1);
}
-void plat_finish(void)
+void plat_omap_finish(void)
{
omap_enable_layer(0);
vout_fbdev_finish(layer_fb);
diff --git a/frontend/plat_omap.h b/frontend/plat_omap.h
new file mode 100644
index 0000000..e47410a
--- /dev/null
+++ b/frontend/plat_omap.h
@@ -0,0 +1,5 @@
+
+void plat_omap_init(void);
+void plat_omap_finish(void);
+void plat_omap_gvideo_open(void);
+
diff --git a/frontend/plat_pandora.c b/frontend/plat_pandora.c
index 20abd68..fb33056 100644
--- a/frontend/plat_pandora.c
+++ b/frontend/plat_pandora.c
@@ -14,13 +14,16 @@
#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/input.h>
+#include <dirent.h>
#include <errno.h>
#include "common/input.h"
#include "linux/in_evdev.h"
#include "plugin_lib.h"
#include "plat.h"
+#include "plat_omap.h"
#include "main.h"
+#include "menu.h"
static const char * const pandora_gpio_keys[KEY_MAX + 1] = {
[0 ... KEY_MAX] = NULL,
@@ -65,10 +68,85 @@ static const struct in_default_bind in_evdev_defbinds[] = {
{ 0, 0, 0 }
};
-int plat_pandora_init(void)
+static const char pnd_script_base[] = "sudo -n /usr/pandora/scripts";
+static char **pnd_filter_list;
+
+static void scan_for_filters(void)
+{
+ struct dirent *ent;
+ int i, count = 0;
+ char **mfilters;
+ char buff[64];
+ DIR *dir;
+
+ dir = opendir("/etc/pandora/conf/dss_fir");
+ if (dir == NULL) {
+ perror("filter opendir");
+ return;
+ }
+
+ while (1) {
+ errno = 0;
+ ent = readdir(dir);
+ if (ent == NULL) {
+ if (errno != 0)
+ perror("readdir");
+ break;
+ }
+
+ if (ent->d_type != DT_REG && ent->d_type != DT_LNK)
+ continue;
+
+ count++;
+ }
+
+ if (count == 0)
+ return;
+
+ mfilters = calloc(count + 1, sizeof(mfilters[0]));
+ if (mfilters == NULL)
+ return;
+
+ rewinddir(dir);
+ for (i = 0; (ent = readdir(dir)); ) {
+ size_t len;
+
+ if (ent->d_type != DT_REG && ent->d_type != DT_LNK)
+ continue;
+
+ len = strlen(ent->d_name);
+
+ // skip pre-HF5 extra files
+ if (len >= 3 && strcmp(ent->d_name + len - 3, "_v3") == 0)
+ continue;
+ if (len >= 3 && strcmp(ent->d_name + len - 3, "_v5") == 0)
+ continue;
+
+ // have to cut "_up_h" for pre-HF5
+ if (len > 5 && strcmp(ent->d_name + len - 5, "_up_h") == 0)
+ len -= 5;
+
+ if (len > sizeof(buff) - 1)
+ continue;
+
+ strncpy(buff, ent->d_name, len);
+ buff[len] = 0;
+ mfilters[i] = strdup(buff);
+ if (mfilters[i] != NULL)
+ i++;
+ }
+ closedir(dir);
+
+ pnd_filter_list = mfilters;
+ menu_set_filter_list((void *)mfilters);
+}
+
+int plat_init(void)
{
int gpiokeys_id;
+ plat_omap_init();
+
in_evdev_init(in_evdev_defbinds);
in_probe();
gpiokeys_id = in_name_to_id("evdev:gpio-keys");
@@ -78,10 +156,60 @@ int plat_pandora_init(void)
in_adev[0] = in_name_to_id("evdev:nub0");
in_adev[1] = in_name_to_id("evdev:nub1");
+ scan_for_filters();
+
return 0;
}
-static const char pnd_script_base[] = "sudo -n /usr/pandora/scripts";
+void plat_finish(void)
+{
+ plat_omap_finish();
+}
+
+static void apply_lcdrate(int pal)
+{
+ char buf[128];
+
+ snprintf(buf, sizeof(buf), "%s/op_lcdrate.sh %d",
+ pnd_script_base, pal ? 50 : 60);
+ system(buf);
+}
+
+static void apply_filter(int which)
+{
+ char buf[128];
+ int i;
+
+ if (pnd_filter_list == NULL)
+ return;
+
+ for (i = 0; i < which; i++)
+ if (pnd_filter_list[i] == NULL)
+ return;
+
+ if (pnd_filter_list[i] == NULL)
+ return;
+
+ snprintf(buf, sizeof(buf), "%s/op_videofir.sh %s",
+ pnd_script_base, pnd_filter_list[i]);
+ system(buf);
+}
+
+void plat_gvideo_open(int is_pal)
+{
+ static int old_pal = -1, old_filter = -1;
+
+ if (is_pal != old_pal) {
+ apply_lcdrate(is_pal);
+ old_pal = is_pal;
+ }
+ if (filter != old_filter) {
+ apply_filter(filter);
+ old_filter = filter;
+ }
+
+ plat_omap_gvideo_open();
+}
int plat_cpu_clock_get(void)
{
@@ -118,3 +246,12 @@ int plat_get_bat_capacity(void)
}
return ret;
}
+
+void plat_step_volume(int is_up)
+{
+}
+
+void plat_trigger_vibrate(int is_strong)
+{
+}
+
diff --git a/frontend/plat_pollux.c b/frontend/plat_pollux.c
index 80e7a1b..8395e54 100644
--- a/frontend/plat_pollux.c
+++ b/frontend/plat_pollux.c
@@ -463,7 +463,7 @@ void *plat_gvideo_set_mode(int *w_, int *h_, int *bpp_)
}
/* not really used, we do raw_flip */
-void plat_gvideo_open(void)
+void plat_gvideo_open(int is_pal)
{
}
diff --git a/frontend/plat_sdl.c b/frontend/plat_sdl.c
index 9be12a5..08afd70 100644
--- a/frontend/plat_sdl.c
+++ b/frontend/plat_sdl.c
@@ -100,7 +100,7 @@ void plat_finish(void)
SDL_Quit();
}
-void plat_gvideo_open(void)
+void plat_gvideo_open(int is_pal)
{
}
diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c
index dbfdb36..2e954aa 100644
--- a/frontend/plugin_lib.c
+++ b/frontend/plugin_lib.c
@@ -39,7 +39,8 @@ void *pl_vout_buf;
int g_layer_x, g_layer_y, g_layer_w, g_layer_h;
static int pl_vout_w, pl_vout_h, pl_vout_bpp;
static int vsync_cnt;
-static int frame_interval, frame_interval1024, vsync_usec_time;
+static int is_pal, frame_interval, frame_interval1024;
+static int vsync_usec_time;
static __attribute__((noinline)) int get_cpu_ticks(void)
@@ -174,7 +175,7 @@ static int pl_vout_open(void)
pl_vout_h--;
pl_vout_buf = pl_vout_set_mode(pl_vout_w, h, pl_vout_bpp);
- plat_gvideo_open();
+ plat_gvideo_open(is_pal);
gettimeofday(&now, 0);
vsync_usec_time = now.tv_usec;
@@ -364,12 +365,13 @@ void pl_frame_limit(void)
pcnt_start(PCNT_ALL);
}
-void pl_timing_prepare(int is_pal)
+void pl_timing_prepare(int is_pal_)
{
pl_rearmed_cbs.fskip_advice = 0;
pl_rearmed_cbs.flips_per_sec = 0;
pl_rearmed_cbs.cpu_usage = 0;
+ is_pal = is_pal_;
frame_interval = is_pal ? 20000 : 16667;
frame_interval1024 = is_pal ? 20000*1024 : 17066667;