X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Fgp2x.c;h=7706e41a2ec95c91fa382dfe11fbcef5f6b3ea98;hb=6e507f764b95d5f6088ea7f174586cfb0360a236;hp=3ed64fb35af18c4fc1ae72cf1c446139682d5b4d;hpb=6245d5a03dba96b93c7cc0a247d17ff3d9e08325;p=libpicofe.git diff --git a/gp2x/gp2x.c b/gp2x/gp2x.c index 3ed64fb..7706e41 100644 --- a/gp2x/gp2x.c +++ b/gp2x/gp2x.c @@ -201,12 +201,12 @@ void gp2x_pd_clone_buffer2(void) unsigned long gp2x_joystick_read(int allow_usb_joy) { int i; - unsigned long value=(gp2x_memregs[0x1198>>1] & 0x00FF); + unsigned long value=(gp2x_memregs[0x1198>>1] & 0x00FF); // GPIO M if(value==0xFD) value=0xFA; if(value==0xF7) value=0xEB; if(value==0xDF) value=0xAF; if(value==0x7F) value=0xBE; - value = ~((gp2x_memregs[0x1184>>1] & 0xFF00) | value | (gp2x_memregs[0x1186>>1] << 16)); + value = ~((gp2x_memregs[0x1184>>1] & 0xFF00) | value | (gp2x_memregs[0x1186>>1] << 16)); // C D if (allow_usb_joy && num_of_joys > 0) { // check the usb joy as well.. @@ -232,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; @@ -242,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); } @@ -283,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 */ @@ -306,6 +332,8 @@ void gp2x_init(void) } gp2x_memregl = (unsigned long *) gp2x_memregs; + gp2x_memregs[0x2880>>1] &= ~0x383; // disable cursor, subpict, osd, video layers + gp2x_screens[0] = mmap(0, FRAMEBUFF_WHOLESIZE, PROT_WRITE, MAP_SHARED, memdev, FRAMEBUFF_ADDR0); if(gp2x_screens[0] == MAP_FAILED) { @@ -336,6 +364,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); }