7 #include <sys/mman.h>
\r
8 #include <sys/types.h>
\r
9 #include <sys/stat.h>
\r
10 #include <linux/fb.h>
\r
14 #include "../gp2x/gp2x.h"
\r
15 #include "../linux/sndout_oss.h"
\r
16 #include "../common/arm_linux.h"
\r
18 static volatile unsigned int *memregs = MAP_FAILED;
\r
21 static int fbdev = -1;
\r
23 #define SCREEN_MAP_SIZE (800*480*2)
\r
24 static void *screen = MAP_FAILED;
\r
29 void gp2x_video_flip(void)
\r
33 /* doulblebuffered flip */
\r
34 void gp2x_video_flip2(void)
\r
39 void gp2x_video_changemode2(int bpp)
\r
44 void gp2x_video_changemode(int bpp)
\r
49 void gp2x_video_setpalette(int *pal, int len)
\r
54 void gp2x_video_RGB_setscaling(int ln_offs, int W, int H)
\r
59 void gp2x_video_wait_vsync(void)
\r
63 void gp2x_video_flush_cache(void)
\r
65 // cache_flush_d_inval_i(gp2x_screen, (char *)gp2x_screen + 320*240*2, 0);
\r
68 void gp2x_memcpy_buffers(int buffers, void *data, int offset, int len)
\r
73 void gp2x_memcpy_all_buffers(void *data, int offset, int len)
\r
78 void gp2x_memset_all_buffers(int offset, int byte, int len)
\r
80 memset((char *)gp2x_screen + offset, byte, len);
\r
84 void gp2x_pd_clone_buffer2(void)
\r
86 memset(gp2x_screen, 0, 800*480*2);
\r
91 static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };
\r
93 typedef struct ucb1x00_ts_event
\r
95 unsigned short pressure;
\r
99 struct timeval stamp;
\r
100 } UCB1X00_TS_EVENT;
\r
102 int gp2x_touchpad_read(int *x, int *y)
\r
104 UCB1X00_TS_EVENT event;
\r
105 static int zero_seen = 0;
\r
108 if (touchdev < 0) return -1;
\r
110 retval = read(touchdev, &event, sizeof(event));
\r
112 printf("touch read failed %i %i\n", retval, errno);
\r
115 // this is to ignore the messed-up 4.1.x driver
\r
116 if (event.pressure == 0) zero_seen = 1;
\r
118 if (x) *x = (event.x * touchcal[0] + touchcal[2]) >> 16;
\r
119 if (y) *y = (event.y * touchcal[4] + touchcal[5]) >> 16;
\r
120 // printf("read %i %i %i\n", event.pressure, *x, *y);
\r
122 return zero_seen ? event.pressure : 0;
\r
125 int gp2x_touchpad_read(int *x, int *y) { return -1; }
\r
129 void gp2x_init(void)
\r
131 printf("entering init()\n"); fflush(stdout);
\r
133 memdev = open("/dev/mem", O_RDWR);
\r
136 perror("open(\"/dev/mem\")");
\r
140 memregs = mmap(0, 0x01000000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x48000000);
\r
141 if (memregs == MAP_FAILED)
\r
143 printf("mmap(memregs) failed with %i\n", errno);
\r
147 fbdev = open("/dev/fb0", O_RDWR);
\r
150 perror("open(\"/dev/fb0\")");
\r
154 screen = mmap(0, SCREEN_MAP_SIZE, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev, 0);
\r
155 if (screen == MAP_FAILED)
\r
157 perror("mmap(fbptr)");
\r
160 printf("fbptr %p\n", screen);
\r
161 gp2x_screen = screen;
\r
166 printf("exitting init()\n"); fflush(stdout);
\r
169 void gp2x_deinit(void)
\r
171 if (screen != MAP_FAILED)
\r
172 munmap(screen, SCREEN_MAP_SIZE);
\r
173 if (memregs != MAP_FAILED)
\r
174 munmap((void *)memregs, 0x10000);
\r
176 if (fbdev >= 0) close(fbdev);
\r
180 printf("all done");
\r
184 void lprintf(const char *fmt, ...)
\r
195 int crashed_940 = 0;
\r
197 void set_gamma(int g100, int A_SNs_curve) {}
\r
198 void set_FCLK(unsigned MHZ) {}
\r
199 void set_LCD_custom_rate(int rate) {}
\r
200 void unset_LCD_custom_rate(void) {}
\r
201 void Pause940(int yes) {}
\r
202 void Reset940(int yes, int bank) {}
\r