X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=ginge.git;a=blobdiff_plain;f=loader%2Femu.c;h=4de04e5c94fa7dc27cbc581cf46e884eee892bd8;hp=3a2bd651814d4bc6f9fef469d9f6a8b6a93569b3;hb=8cb68a18cc36ab8e47b8834723f3a65ea360974f;hpb=890c1dc54f2d12febbf4238c73ccd145a6724771 diff --git a/loader/emu.c b/loader/emu.c index 3a2bd65..4de04e5 100644 --- a/loader/emu.c +++ b/loader/emu.c @@ -79,6 +79,7 @@ static int fb_sync_thread_paused; static int fb_sync_thread_futex; static int emu_is_dl; +static int emu_force_snd_frag; static struct { u32 dstctrl; @@ -430,11 +431,17 @@ static void fb_thread_resume(void) static u32 xread32_io_cmn(u32 a, u32 *handled) { + struct timespec ts; u32 d = 0; *handled = 1; switch (a) { // Wiz stuff + case 0x1980: // TIMER3 TMRCOUNT + // assume the timer is set up for microsec time + g_clock_gettime_raw(CLOCK_REALTIME, &ts); + d = ts.tv_sec * 1000000 + ((u64)(u32)ts.tv_nsec * 4294968 >> 32); + break; case 0x402c: // MLCVSTRIDE0 case 0x4060: // MLCVSTRIDE1 d = pollux.v.stride; @@ -1011,6 +1018,7 @@ void emu_init(void *map_bottom[2], int is_dl) .sa_sigaction = segv_sigaction, .sa_flags = SA_SIGINFO, }; + const char *var; void *pret; int i, ret; @@ -1024,6 +1032,14 @@ void emu_init(void *map_bottom[2], int is_dl) emu_is_dl = is_dl; +#ifdef PND + // set default buffer size to 8 * 1K + emu_force_snd_frag = (8<<16) | 10; +#endif + var = getenv("GINGE_SETFRAGMENT"); + if (var != NULL) + emu_force_snd_frag = strtol(var, NULL, 0); + for (i = 0; i < 2; i++) { if (map_bottom[i] == NULL) continue; @@ -1157,15 +1173,13 @@ long emu_do_munmap(void *addr, unsigned int length) static void emu_sound_open(int fd) { -#ifdef PND - int ret, frag; + int ret; - // set default buffer size to 16 * 1K - frag = (16<<16) | 10; // 16K - ret = g_ioctl_raw(fd, SNDCTL_DSP_SETFRAGMENT, &frag); - if (ret != 0) - err("snd ioctl SETFRAGMENT %08x: %d\n", frag, ret); -#endif + if (emu_force_snd_frag != 0) { + ret = g_ioctl_raw(fd, SNDCTL_DSP_SETFRAGMENT, &emu_force_snd_frag); + if (ret != 0) + err("snd ioctl SETFRAGMENT %08x: %d\n", emu_force_snd_frag, ret); + } } static long emu_sound_ioctl(int fd, int request, void *argp) @@ -1193,7 +1207,7 @@ static long emu_sound_ioctl(int fd, int request, void *argp) frag = *arg & 0xffff; frag_cnt = *arg >> 16; bsize = frag_cnt << frag; - if (frag < 10 || bsize < 4096*4 || bsize > 4096*4*2) { + if (frag < 8 || bsize < 4096*4 || bsize > 4096*4*2) { /* * ~4ms. gpSP wants small buffers or else it stutters * because of it's audio thread sync stuff @@ -1207,7 +1221,7 @@ static long emu_sound_ioctl(int fd, int request, void *argp) for (frag = 0; bsize; bsize >>= 1, frag++) ; - frag_cnt = 16; + frag_cnt = 8; } frag |= frag_cnt << 16; @@ -1285,6 +1299,7 @@ long emu_do_ioctl(int fd, int request, void *argp) } /* *********************** */ + case FAKEDEV_TTY: case FAKEDEV_TTY0: // fake tty0 to make GPH SDL happy if (request == 0x4b46) // KDGKBENT