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/usbjoy.h"
\r
16 #include "../linux/sndout_oss.h"
\r
17 #include "../common/arm_linux.h"
\r
19 static volatile unsigned int *memregs = MAP_FAILED;
\r
22 static int fbdev = -1;
\r
24 #define SCREEN_MAP_SIZE (800*480*2)
\r
25 static void *screen = MAP_FAILED;
\r
30 void gp2x_video_flip(void)
\r
34 /* doulblebuffered flip */
\r
35 void gp2x_video_flip2(void)
\r
40 void gp2x_video_changemode2(int bpp)
\r
45 void gp2x_video_changemode(int bpp)
\r
50 void gp2x_video_setpalette(int *pal, int len)
\r
55 void gp2x_video_RGB_setscaling(int ln_offs, int W, int H)
\r
60 void gp2x_video_wait_vsync(void)
\r
64 void gp2x_video_flush_cache(void)
\r
66 // cache_flush_d_inval_i(gp2x_screen, (char *)gp2x_screen + 320*240*2, 0);
\r
69 void gp2x_memcpy_buffers(int buffers, void *data, int offset, int len)
\r
74 void gp2x_memcpy_all_buffers(void *data, int offset, int len)
\r
79 void gp2x_memset_all_buffers(int offset, int byte, int len)
\r
81 memset((char *)gp2x_screen + offset, byte, len);
\r
85 void gp2x_pd_clone_buffer2(void)
\r
87 memset(gp2x_screen, 0, 800*480*2);
\r
91 unsigned long gp2x_joystick_read(int allow_usb_joy)
\r
93 unsigned long value = 0;
\r
96 if (allow_usb_joy && num_of_joys > 0) {
\r
97 // check the usb joy as well..
\r
99 for (i = 0; i < num_of_joys; i++)
\r
100 value |= usbjoy_check(i);
\r
108 static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };
\r
110 typedef struct ucb1x00_ts_event
\r
112 unsigned short pressure;
\r
115 unsigned short pad;
\r
116 struct timeval stamp;
\r
117 } UCB1X00_TS_EVENT;
\r
119 int gp2x_touchpad_read(int *x, int *y)
\r
121 UCB1X00_TS_EVENT event;
\r
122 static int zero_seen = 0;
\r
125 if (touchdev < 0) return -1;
\r
127 retval = read(touchdev, &event, sizeof(event));
\r
129 printf("touch read failed %i %i\n", retval, errno);
\r
132 // this is to ignore the messed-up 4.1.x driver
\r
133 if (event.pressure == 0) zero_seen = 1;
\r
135 if (x) *x = (event.x * touchcal[0] + touchcal[2]) >> 16;
\r
136 if (y) *y = (event.y * touchcal[4] + touchcal[5]) >> 16;
\r
137 // printf("read %i %i %i\n", event.pressure, *x, *y);
\r
139 return zero_seen ? event.pressure : 0;
\r
142 int gp2x_touchpad_read(int *x, int *y) { return -1; }
\r
146 void gp2x_init(void)
\r
148 printf("entering init()\n"); fflush(stdout);
\r
150 memdev = open("/dev/mem", O_RDWR);
\r
153 perror("open(\"/dev/mem\")");
\r
157 memregs = mmap(0, 0x01000000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x48000000);
\r
158 if (memregs == MAP_FAILED)
\r
160 printf("mmap(memregs) failed with %i\n", errno);
\r
164 fbdev = open("/dev/fb0", O_RDWR);
\r
167 perror("open(\"/dev/fb0\")");
\r
171 screen = mmap(0, SCREEN_MAP_SIZE, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev, 0);
\r
172 if (screen == MAP_FAILED)
\r
174 perror("mmap(fbptr)");
\r
177 printf("fbptr %p\n", screen);
\r
178 gp2x_screen = screen;
\r
183 /* init usb joys -GnoStiC */
\r
186 printf("exitting init()\n"); fflush(stdout);
\r
189 void gp2x_deinit(void)
\r
191 if (screen != MAP_FAILED)
\r
192 munmap(screen, SCREEN_MAP_SIZE);
\r
193 if (memregs != MAP_FAILED)
\r
194 munmap((void *)memregs, 0x10000);
\r
196 if (fbdev >= 0) close(fbdev);
\r
201 printf("all done");
\r
205 void lprintf(const char *fmt, ...)
\r
216 int crashed_940 = 0;
\r
218 void set_gamma(int g100, int A_SNs_curve) {}
\r
219 void set_FCLK(unsigned MHZ) {}
\r
220 void set_LCD_custom_rate(int rate) {}
\r
221 void unset_LCD_custom_rate(void) {}
\r
222 void Pause940(int yes) {}
\r
223 void Reset940(int yes, int bank) {}
\r