11 void (*gp2x_video_flip)(void);
12 void (*gp2x_video_flip2)(void);
13 void (*gp2x_video_changemode_ll)(int bpp);
14 void (*gp2x_video_setpalette)(int *pal, int len);
15 void (*gp2x_video_RGB_setscaling)(int ln_offs, int W, int H);
16 void (*gp2x_video_wait_vsync)(void);
18 void (*gp2x_set_cpuclk)(unsigned int mhz);
20 void (*set_lcd_custom_rate)(int is_pal);
21 void (*unset_lcd_custom_rate)(void);
22 void (*set_lcd_gamma)(int g100, int A_SNs_curve);
24 void (*set_ram_timings)(void);
25 void (*unset_ram_timings)(void);
26 int (*gp2x_read_battery)(void);
28 unsigned int (*gp2x_get_ticks_ms)(void);
29 unsigned int (*gp2x_get_ticks_us)(void);
32 gp2x_soc_t soc_detect(void)
34 volatile unsigned short *memregs;
35 volatile unsigned int *memregl;
36 static gp2x_soc_t ret = -2;
37 int pollux_chipname[0x30/4 + 1];
38 char *pollux_chipname_c = (char *)pollux_chipname;
43 /* already detected */
46 memdev = open("/dev/mem", O_RDONLY);
49 perror("open(/dev/mem)");
54 memregs = mmap(0, 0x20000, PROT_READ, MAP_SHARED, memdev, 0xc0000000);
55 if (memregs == MAP_FAILED)
57 perror("mmap(memregs)");
62 memregl = (volatile void *)memregs;
64 if (memregs[0x1836>>1] == 0x2330)
66 printf("looks like this is MMSP2\n");
71 /* perform word reads. Byte reads might also work,
72 * but we don't want to play with that. */
73 for (i = 0; i < 0x30; i += 4)
75 pollux_chipname[i >> 2] = memregl[(0x1f810 + i) >> 2];
77 pollux_chipname_c[0x30] = 0;
79 for (i = 0; i < 0x30; i++)
81 unsigned char c = pollux_chipname_c[i];
82 if (c < 0x20 || c > 0x7f)
86 printf("found pollux-like id: \"%s\"\n", pollux_chipname_c);
88 if (strncmp(pollux_chipname_c, "MAGICEYES-LEAPFROG-LF1000", 25) ||
89 strncmp(pollux_chipname_c, "MAGICEYES-POLLUX", 16))
97 munmap((void *)memregs, 0x20000);