X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fgp2x%2Fgp2x.c;h=6db1d41f95f07baf6d2329029ee943b6571f05d6;hb=2d2247c26080ed9009b3d8c650cfc647fd1fb162;hp=3b5d125e2368cf9b5010302940e2ced102779d93;hpb=a12e01162349cd970e9b6fe5674497760631279b;p=picodrive.git diff --git a/platform/gp2x/gp2x.c b/platform/gp2x/gp2x.c index 3b5d125..6db1d41 100644 --- a/platform/gp2x/gp2x.c +++ b/platform/gp2x/gp2x.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -34,7 +35,7 @@ #include "gp2x.h" #include "usbjoy.h" -#include "asmutils.h" +#include "../common/arm_utils.h" volatile unsigned short *gp2x_memregs; //static @@ -231,8 +232,8 @@ void gp2x_start_sound(int rate, int bits, int stereo) if (sounddev == -1) printf("open(\"/dev/dsp\") failed with %i\n", errno); - ioctl(sounddev, SNDCTL_DSP_SPEED, &rate); ioctl(sounddev, SNDCTL_DSP_SETFMT, &bits); + ioctl(sounddev, SNDCTL_DSP_SPEED, &rate); ioctl(sounddev, SNDCTL_DSP_STEREO, &stereo); // calculate buffer size buffers = 16; @@ -241,11 +242,12 @@ void gp2x_start_sound(int rate, int bits, int stereo) while ((bsize>>=1)) frag++; frag |= buffers<<16; // 16 buffers ioctl(sounddev, SNDCTL_DSP_SETFRAGMENT, &frag); + usleep(192*1024); + printf("gp2x_set_sound: %i/%ibit/%s, %i buffers of %i bytes\n", rate, bits, stereo?"stereo":"mono", frag>>16, 1<<(frag&0xffff)); s_oldrate = rate; s_oldbits = bits; s_oldstereo = stereo; - usleep(100000); } @@ -282,6 +284,31 @@ void Reset940(int yes, int bank) gp2x_memregs[0x3B48>>1] = ((yes&1) << 7) | (bank & 0x03); } +static void proc_set(const char *path, const char *val) +{ + FILE *f; + char tmp[16]; + + f = fopen(path, "w"); + if (f == NULL) { + printf("failed to open: %s\n", path); + return; + } + + fprintf(f, "0\n"); + fclose(f); + + printf("\"%s\" is set to: ", path); + f = fopen(path, "r"); + if (f == NULL) { + printf("(open failed)\n"); + return; + } + + fgets(tmp, sizeof(tmp), f); + printf("%s", tmp); + fclose(f); +} /* common */ @@ -335,6 +362,10 @@ void gp2x_init(void) /* init usb joys -GnoStiC */ gp2x_usbjoy_init(); + /* disable Linux read-ahead */ + proc_set("/proc/sys/vm/max-readahead", "0\n"); + proc_set("/proc/sys/vm/min-readahead", "0\n"); + printf("exitting init()\n"); fflush(stdout); } @@ -375,4 +406,13 @@ void gp2x_deinit(void) } } +/* lprintf */ +void lprintf(const char *fmt, ...) +{ + va_list vl; + + va_start(vl, fmt); + vprintf(fmt, vl); + va_end(vl); +}