2 * (C) GraÅžvydas "notaz" Ignotas, 2009-2010
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.
14 #include <sys/types.h>
22 void (*gp2x_video_flip)(void);
23 void (*gp2x_video_flip2)(void);
24 void (*gp2x_video_changemode_ll)(int bpp);
25 void (*gp2x_video_setpalette)(int *pal, int len);
26 void (*gp2x_video_RGB_setscaling)(int ln_offs, int W, int H);
27 void (*gp2x_video_wait_vsync)(void);
29 void (*gp2x_set_cpuclk)(unsigned int mhz);
31 void (*set_lcd_custom_rate)(int is_pal);
32 void (*unset_lcd_custom_rate)(void);
33 void (*set_lcd_gamma)(int g100, int A_SNs_curve);
35 void (*set_ram_timings)(void);
36 void (*unset_ram_timings)(void);
37 int (*gp2x_read_battery)(void);
39 unsigned int (*gp2x_get_ticks_ms)(void);
40 unsigned int (*gp2x_get_ticks_us)(void);
43 gp2x_soc_t soc_detect(void)
45 volatile unsigned short *memregs;
46 volatile unsigned int *memregl;
47 static gp2x_soc_t ret = -2;
48 int pollux_chipname[0x30/4 + 1];
49 char *pollux_chipname_c = (char *)pollux_chipname;
54 /* already detected */
57 memdev = open("/dev/mem", O_RDONLY);
60 perror("open(/dev/mem)");
65 memregs = mmap(0, 0x20000, PROT_READ, MAP_SHARED, memdev, 0xc0000000);
66 if (memregs == MAP_FAILED)
68 perror("mmap(memregs)");
73 memregl = (volatile void *)memregs;
75 if (memregs[0x1836>>1] == 0x2330)
77 printf("looks like this is MMSP2\n");
82 /* perform word reads. Byte reads might also work,
83 * but we don't want to play with that. */
84 for (i = 0; i < 0x30; i += 4)
86 pollux_chipname[i >> 2] = memregl[(0x1f810 + i) >> 2];
88 pollux_chipname_c[0x30] = 0;
90 for (i = 0; i < 0x30; i++)
92 unsigned char c = pollux_chipname_c[i];
93 if (c < 0x20 || c > 0x7f)
97 printf("found pollux-like id: \"%s\"\n", pollux_chipname_c);
99 if (strncmp(pollux_chipname_c, "MAGICEYES-LEAPFROG-LF1000", 25) ||
100 strncmp(pollux_chipname_c, "MAGICEYES-POLLUX", 16))
108 munmap((void *)memregs, 0x20000);