static const int gp2x_screenaddrs[4] = { FRAMEBUFF_ADDR0, FRAMEBUFF_ADDR1, FRAMEBUFF_ADDR2, FRAMEBUFF_ADDR3 };
static int gp2x_screenaddrs_use[4];
+
+static char gamma_was_changed = 0;
+static char cpuclk_was_changed = 0;
static unsigned short gp2x_screenaddr_old[4];
+static unsigned short memtimex_old[2];
+static unsigned short reg0910;
/* video stuff */
for (i = 0; i < 10000; i++)
if (!(gp2x_memregs[0x902>>1] & 1))
break;
+
+ cpuclk_was_changed = 1;
}
/* RAM timings */
-static unsigned short memtimex[2];
-
#define TIMING_CHECK(t, adj, mask) \
t += adj; \
if (t & ~mask) \
static void unset_ram_timings_(void)
{
- gp2x_memregs[0x3802>>1] = memtimex[0];
- gp2x_memregs[0x3804>>1] = memtimex[1] | 0x8000;
+ gp2x_memregs[0x3802>>1] = memtimex_old[0];
+ gp2x_memregs[0x3804>>1] = memtimex_old[1] | 0x8000;
printf("RAM timings reset to startup values.\n");
}
gp2x_memregs[0x295E>>1]= s;
gp2x_memregs[0x295E>>1]= g;
}
+
+ gamma_was_changed = 1;
}
memcpy(gp2x_screenaddrs_use, gp2x_screenaddrs, sizeof(gp2x_screenaddrs));
- /* default LCD refresh */
+ /* save startup values: LCD refresh */
get_reg_setting(lcd_rate_defaults);
- /* RAM timings */
- memtimex[0] = gp2x_memregs[0x3802>>1];
- memtimex[1] = gp2x_memregs[0x3804>>1];
+ /* CPU and RAM timings */
+ reg0910 = gp2x_memregs[0x0910>>1];
+ memtimex_old[0] = gp2x_memregs[0x3802>>1];
+ memtimex_old[1] = gp2x_memregs[0x3804>>1];
/* touchscreen */
touchdev = open("/dev/touchscreen/wm97xx", O_RDONLY);
pause940(1);
sharedmem940_finish();
+ gp2x_video_RGB_setscaling_(0, 320, 240);
+ gp2x_video_changemode_ll_(16);
+
gp2x_memregs[0x290E>>1] = gp2x_screenaddr_old[0];
gp2x_memregs[0x2910>>1] = gp2x_screenaddr_old[1];
gp2x_memregs[0x2912>>1] = gp2x_screenaddr_old[2];
gp2x_memregs[0x2914>>1] = gp2x_screenaddr_old[3];
- unset_ram_timings_();
unset_lcd_custom_rate_();
+ if (gamma_was_changed)
+ set_lcd_gamma_(100, 0);
+ unset_ram_timings_();
+ if (cpuclk_was_changed)
+ gp2x_memregs[0x910>>1] = reg0910;
munmap(gp2x_screens[0], FRAMEBUFF_WHOLESIZE);
munmap((void *)gp2x_memregs, 0x10000);
static int fb_work_buf;
static int fbdev = -1;
+static char cpuclk_was_changed = 0;
+static unsigned short memtimex_old[2];
+static unsigned int pllsetreg0;
+
/* video stuff */
static void pollux_video_flip(int buf_count)
char buff[24];
snprintf(buff, sizeof(buff), "cpuclk=%u", mhz);
pollux_set(memregs, buff);
+
+ cpuclk_was_changed = 1;
}
/* misc */
}
/* RAM timings */
-static unsigned short memtimex[2];
-
static void set_ram_timings_(void)
{
pollux_set_fromenv("POLLUX_RAM_TIMINGS");
{
int i;
- memregs[0x14802>>1] = memtimex[0];
- memregs[0x14804>>1] = memtimex[1] | 0x8000;
+ memregs[0x14802>>1] = memtimex_old[0];
+ memregs[0x14804>>1] = memtimex_old[1] | 0x8000;
for (i = 0; i < 0x100000; i++)
if (!(memregs[0x14804>>1] & 0x8000))
fb_work_buf = 0;
g_screen_ptr = gp2x_screens[0];
- memtimex[0] = memregs[0x14802>>1];
- memtimex[1] = memregs[0x14804>>1];
+ pllsetreg0 = memregl[0xf004];
+ memtimex_old[0] = memregs[0x14802>>1];
+ memtimex_old[1] = memregs[0x14804>>1];
gp2x_video_flip = gp2x_video_flip_;
gp2x_video_flip2 = gp2x_video_flip2_;
// wiz_lcd_set_portrait(0);
close(fbdev);
+ gp2x_video_changemode_ll_(16);
+ unset_ram_timings_();
+ if (cpuclk_was_changed) {
+ memregl[0xf004>>2] = pllsetreg0;
+ memregl[0xf07c>>2] |= 0x8000;
+ }
+
munmap((void *)memregs, 0x20000);
close(memdev);
}