X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=frontend%2Fplat_pollux.c;h=52a09b14674fd9d4975df61c100dc558f38146c5;hp=c03173ea4f098a401f60e344a907afc9f4c2c043;hb=fa56d36096cd4ab2b227ce2aa61c8404b8874689;hpb=3a40ff141abca7d9c5a1e3f47e41c26d9bc3b3ff diff --git a/frontend/plat_pollux.c b/frontend/plat_pollux.c index c03173ea..52a09b14 100644 --- a/frontend/plat_pollux.c +++ b/frontend/plat_pollux.c @@ -16,9 +16,11 @@ #include #include #include +#include #include "common/input.h" #include "gp2x/in_gp2x.h" +#include "linux/in_evdev.h" #include "common/menu.h" #include "warm/warm.h" #include "plugin_lib.h" @@ -49,19 +51,26 @@ static int psx_step, psx_width, psx_height, psx_bpp; static int psx_offset_x, psx_offset_y, psx_src_width, psx_src_height; static int fb_offset_x, fb_offset_y; -// TODO: get rid of this -struct vout_fbdev; -struct vout_fbdev *layer_fb; -int g_layer_x, g_layer_y, g_layer_w, g_layer_h; - -int omap_enable_layer(int enabled) -{ - return 0; -} - static void caanoo_init(void); -static void *pl_vout_set_mode(int w, int h, int bpp); +static void wiz_init(void); + +static const struct in_default_bind in_evdev_defbinds[] = { + { KEY_UP, IN_BINDTYPE_PLAYER12, DKEY_UP }, + { KEY_DOWN, IN_BINDTYPE_PLAYER12, DKEY_DOWN }, + { KEY_LEFT, IN_BINDTYPE_PLAYER12, DKEY_LEFT }, + { KEY_RIGHT, IN_BINDTYPE_PLAYER12, DKEY_RIGHT }, + { BTN_TOP, IN_BINDTYPE_PLAYER12, DKEY_TRIANGLE }, + { BTN_THUMB, IN_BINDTYPE_PLAYER12, DKEY_CROSS }, + { BTN_THUMB2, IN_BINDTYPE_PLAYER12, DKEY_CIRCLE }, + { BTN_TRIGGER, IN_BINDTYPE_PLAYER12, DKEY_SQUARE }, + { BTN_BASE3, IN_BINDTYPE_PLAYER12, DKEY_START }, + { BTN_BASE4, IN_BINDTYPE_PLAYER12, DKEY_SELECT }, + { BTN_TOP2, IN_BINDTYPE_PLAYER12, DKEY_L1 }, + { BTN_PINKIE, IN_BINDTYPE_PLAYER12, DKEY_R1 }, + { BTN_BASE, IN_BINDTYPE_EMU, SACTION_ENTER_MENU }, + { 0, 0, 0 }, +}; static void *fb_flip(void) { @@ -249,7 +258,7 @@ void plat_video_menu_leave(void) memset(g_menuscreen_ptr, 0, 320*240 * psx_bpp/8); g_menuscreen_ptr = fb_flip(); - pl_vout_set_mode(psx_width, psx_height, psx_bpp); + memset(g_menuscreen_ptr, 0, 320*240 * psx_bpp/8); } void *plat_prepare_screenshot(int *w, int *h, int *bpp) @@ -296,12 +305,13 @@ static void spend_cycles(int loops) #define DMA_REG(x) memregl[(DMA_BASE6 + x) >> 2] /* this takes ~1.5ms, while ldm/stm ~1.95ms */ -static void raw_flip_dma(int x, int y) +static void raw_flip_dma(const void *vram, int stride, int bgr24, int w, int h) { + unsigned int pixel_offset = psx_vram - (unsigned short *)vram; unsigned int dst = fb_paddrs[fb_work_buf] + (fb_offset_y * 320 + fb_offset_x) * psx_bpp / 8; - int spsx_line = y + psx_offset_y; - int spsx_offset = (x + psx_offset_x) & 0x3f8; + int spsx_line = pixel_offset / 1024 + psx_offset_y; + int spsx_offset = (pixel_offset + psx_offset_x) & 0x3f8; int dst_stride = 320 * psx_bpp / 8; int len = psx_src_width * psx_bpp / 8; int i; @@ -335,7 +345,7 @@ static void raw_flip_dma(int x, int y) if (psx_bpp == 16) { pl_vout_buf = g_menuscreen_ptr; - pl_print_hud(320, fb_offset_y + psx_src_height, fb_offset_x); + pl_print_hud(w, h, fb_offset_x); } g_menuscreen_ptr = fb_flip(); @@ -345,26 +355,24 @@ static void raw_flip_dma(int x, int y) } #define make_flip_func(name, blitfunc) \ -static void name(int x, int y) \ +static void name(const void *vram_, int stride, int bgr24, int w, int h) \ { \ - unsigned short *vram = psx_vram; \ + const unsigned short *vram = vram_; \ unsigned char *dst = (unsigned char *)g_menuscreen_ptr + \ (fb_offset_y * 320 + fb_offset_x) * psx_bpp / 8; \ - unsigned int src = (y + psx_offset_y) * 1024 + x + psx_offset_x; \ int dst_stride = 320 * psx_bpp / 8; \ int len = psx_src_width * psx_bpp / 8; \ int i; \ \ pcnt_start(PCNT_BLIT); \ \ - for (i = psx_src_height; i > 0; i--, src += psx_step * 1024, dst += dst_stride) { \ - src &= 1024*512-1; \ - blitfunc(dst, vram + src, len); \ - } \ + vram += psx_offset_y * 1024 + psx_offset_x; \ + for (i = psx_src_height; i > 0; i--, vram += psx_step * 1024, dst += dst_stride)\ + blitfunc(dst, vram, len); \ \ if (psx_bpp == 16) { \ pl_vout_buf = g_menuscreen_ptr; \ - pl_print_hud(320, fb_offset_y + psx_src_height, fb_offset_x); \ + pl_print_hud(w, h, fb_offset_x); \ } \ \ g_menuscreen_ptr = fb_flip(); \ @@ -378,9 +386,10 @@ make_flip_func(raw_flip_soft_368, blit320_368) make_flip_func(raw_flip_soft_512, blit320_512) make_flip_func(raw_flip_soft_640, blit320_640) -static void *pl_vout_set_mode(int w, int h, int bpp) +void *plat_gvideo_set_mode(int *w_, int *h_, int *bpp_) { int poff_w, poff_h, w_max; + int w = *w_, h = *h_, bpp = *bpp_; if (!w || !h || !bpp) return NULL; @@ -392,20 +401,20 @@ static void *pl_vout_set_mode(int w, int h, int bpp) switch (w + (bpp != 16) + !soft_scaling) { case 640: - pl_rearmed_cbs.pl_vout_raw_flip = raw_flip_soft_640; + pl_rearmed_cbs.pl_vout_flip = raw_flip_soft_640; w_max = 640; break; case 512: - pl_rearmed_cbs.pl_vout_raw_flip = raw_flip_soft_512; + pl_rearmed_cbs.pl_vout_flip = raw_flip_soft_512; w_max = 512; break; case 384: case 368: - pl_rearmed_cbs.pl_vout_raw_flip = raw_flip_soft_368; + pl_rearmed_cbs.pl_vout_flip = raw_flip_soft_368; w_max = 368; break; default: - pl_rearmed_cbs.pl_vout_raw_flip = have_warm ? raw_flip_dma : raw_flip_soft; + pl_rearmed_cbs.pl_vout_flip = have_warm ? raw_flip_dma : raw_flip_soft; w_max = 320; break; } @@ -430,7 +439,7 @@ static void *pl_vout_set_mode(int w, int h, int bpp) } fb_offset_y = 240/2 - h / 2; - psx_offset_x = poff_w; + psx_offset_x = poff_w * psx_bpp/8 / 2; psx_offset_y = poff_h; psx_src_width = w; psx_src_height = h; @@ -446,14 +455,27 @@ static void *pl_vout_set_mode(int w, int h, int bpp) pl_set_gun_rect(fb_offset_x, fb_offset_y, w > 320 ? 320 : w, h); + // adjust for hud + *w_ = 320; + *h_ = fb_offset_y + psx_src_height; + return NULL; } -static void *pl_vout_flip(void) +/* not really used, we do raw_flip */ +void plat_gvideo_open(int is_pal) +{ +} + +void *plat_gvideo_flip(void) { return NULL; } +void plat_gvideo_close(void) +{ +} + static void save_multiple_regs(unsigned int *dest, int base, int count) { const volatile unsigned int *regs = memregl + base / 4; @@ -527,12 +549,6 @@ void plat_init(void) g_menuscreen_h = 240; g_menuscreen_ptr = fb_flip(); - g_menubg_ptr = calloc(320*240*2, 1); - if (g_menubg_ptr == NULL) { - fprintf(stderr, "OOM\n"); - exit(1); - } - warm_ret = warm_init(); have_warm = warm_ret == 0; warm_change_cb_upper(WCB_B_BIT, 1); @@ -591,21 +607,20 @@ void plat_init(void) else { printf("detected Wiz\n"); gp2x_dev_id = GP2X_DEV_WIZ; - in_gp2x_init(); } in_tsbutton_init(); - in_probe(); + in_evdev_init(in_evdev_defbinds); if (gp2x_dev_id == GP2X_DEV_CAANOO) caanoo_init(); + else + wiz_init(); mixerdev = open("/dev/mixer", O_RDWR); if (mixerdev == -1) perror("open(/dev/mixer)"); - pl_rearmed_cbs.pl_vout_flip = pl_vout_flip; - pl_rearmed_cbs.pl_vout_raw_flip = have_warm ? raw_flip_dma : raw_flip_soft; - pl_rearmed_cbs.pl_vout_set_mode = pl_vout_set_mode; + pl_rearmed_cbs.pl_vout_flip = have_warm ? raw_flip_dma : raw_flip_soft; pl_rearmed_cbs.pl_vout_set_raw_vram = pl_vout_set_raw_vram; psx_src_width = 320; @@ -637,26 +652,23 @@ void plat_finish(void) close(memdev); } -/* Caanoo stuff, perhaps move later */ -#include +/* WIZ RAM lack workaround */ +void *memtab_mmap(void *addr, size_t size) +{ + void *ret; -struct in_default_bind in_evdev_defbinds[] = { - { KEY_UP, IN_BINDTYPE_PLAYER12, DKEY_UP }, - { KEY_DOWN, IN_BINDTYPE_PLAYER12, DKEY_DOWN }, - { KEY_LEFT, IN_BINDTYPE_PLAYER12, DKEY_LEFT }, - { KEY_RIGHT, IN_BINDTYPE_PLAYER12, DKEY_RIGHT }, - { BTN_TOP, IN_BINDTYPE_PLAYER12, DKEY_TRIANGLE }, - { BTN_THUMB, IN_BINDTYPE_PLAYER12, DKEY_CROSS }, - { BTN_THUMB2, IN_BINDTYPE_PLAYER12, DKEY_CIRCLE }, - { BTN_TRIGGER, IN_BINDTYPE_PLAYER12, DKEY_SQUARE }, - { BTN_BASE3, IN_BINDTYPE_PLAYER12, DKEY_START }, - { BTN_BASE4, IN_BINDTYPE_PLAYER12, DKEY_SELECT }, - { BTN_TOP2, IN_BINDTYPE_PLAYER12, DKEY_L1 }, - { BTN_PINKIE, IN_BINDTYPE_PLAYER12, DKEY_R1 }, - { BTN_BASE, IN_BINDTYPE_EMU, SACTION_ENTER_MENU }, - { 0, 0, 0 }, -}; + if (gp2x_dev_id != GP2X_DEV_WIZ) + return mmap(addr, size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); + + ret = mmap(addr, size, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_FIXED, memdev, 0x03000000); + if (ret != MAP_FAILED) + warm_change_cb_range(WCB_C_BIT | WCB_B_BIT, 1, ret, size); + return ret; +} +/* Caanoo stuff, perhaps move later */ static const char * const caanoo_keys[KEY_MAX + 1] = { [0 ... KEY_MAX] = NULL, [KEY_UP] = "Up", @@ -699,7 +711,7 @@ static int haptic_read(const char *fname, struct haptic_data *data) f = fopen(fname, "r"); if (f == NULL) { - fprintf("fopen(%s)", fname); + fprintf(stderr, "fopen(%s)", fname); perror(""); return -1; } @@ -782,8 +794,15 @@ void plat_trigger_vibrate(int is_strong) ioctl(hapticdev, HAPTIC_PLAY_PATTERN, &haptic_seq[!!is_strong]); } +static void caanoo_init(void) +{ + in_probe(); + in_set_config(in_name_to_id("evdev:pollux-analog"), IN_CFG_KEY_NAMES, + caanoo_keys, sizeof(caanoo_keys)); +} + /* Wiz stuff */ -struct in_default_bind in_gp2x_defbinds[] = +static const struct in_default_bind in_gp2x_defbinds[] = { /* MXYZ SACB RLDU */ { GP2X_BTN_UP, IN_BINDTYPE_PLAYER12, DKEY_UP }, @@ -830,8 +849,8 @@ void plat_step_volume(int is_up) // unused dummy for in_gp2x volatile unsigned short *gp2x_memregs; -static void caanoo_init(void) +static void wiz_init(void) { - in_set_config(in_name_to_id("evdev:pollux-analog"), IN_CFG_KEY_NAMES, - caanoo_keys, sizeof(caanoo_keys)); + in_gp2x_init(in_gp2x_defbinds); + in_probe(); }