X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Fsoc.c;h=3d4ad0415b89e11da001048038e73aad5849e90c;hb=a1b30e1a4a93f8104a1119e4387fa83ba777c712;hp=d34077dbce2cbd4f0218fa95175bc3884505ff87;hpb=d572cbad9886a04f8c51edb825dc6aaec9b02e23;p=libpicofe.git diff --git a/gp2x/soc.c b/gp2x/soc.c index d34077d..3d4ad04 100644 --- a/gp2x/soc.c +++ b/gp2x/soc.c @@ -1,3 +1,14 @@ +/* + * (C) Gražvydas "notaz" Ignotas, 2009-2010 + * + * This work is licensed under the terms of any of these licenses + * (at your option): + * - GNU GPL, version 2 or later. + * - GNU LGPL, version 2.1 or later. + * - MAME license. + * See the COPYING file in the top-level directory. + */ + #include #include #include @@ -7,24 +18,47 @@ #include #include "soc.h" -#include "../common/emu.h" -gp2x_soc_t gp2x_soc = -1; +void (*gp2x_video_flip)(void); +void (*gp2x_video_flip2)(void); +void (*gp2x_video_changemode_ll)(int bpp); +void (*gp2x_video_setpalette)(int *pal, int len); +void (*gp2x_video_RGB_setscaling)(int ln_offs, int W, int H); +void (*gp2x_video_wait_vsync)(void); + +void (*gp2x_set_cpuclk)(unsigned int mhz); + +void (*set_lcd_custom_rate)(int is_pal); +void (*unset_lcd_custom_rate)(void); +void (*set_lcd_gamma)(int g100, int A_SNs_curve); + +void (*set_ram_timings)(void); +void (*unset_ram_timings)(void); +int (*gp2x_read_battery)(void); + +unsigned int (*gp2x_get_ticks_ms)(void); +unsigned int (*gp2x_get_ticks_us)(void); + gp2x_soc_t soc_detect(void) { volatile unsigned short *memregs; volatile unsigned int *memregl; + static gp2x_soc_t ret = -2; int pollux_chipname[0x30/4 + 1]; char *pollux_chipname_c = (char *)pollux_chipname; - gp2x_soc_t ret = -1; int memdev; int i; + if ((int)ret != -2) + /* already detected */ + return ret; + memdev = open("/dev/mem", O_RDONLY); if (memdev == -1) { perror("open(/dev/mem)"); + ret = -1; return -1; } @@ -33,6 +67,7 @@ gp2x_soc_t soc_detect(void) { perror("mmap(memregs)"); close(memdev); + ret = -1; return -1; } memregl = (volatile void *)memregs; @@ -72,7 +107,6 @@ not_pollux_like: out: munmap((void *)memregs, 0x20000); close(memdev); - gp2x_soc = ret; return ret; }