annotate src/video/ipod/SDL_ipodvideo.c @ 1895:c121d94672cb

SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 10 Jul 2006 21:04:37 +0000
parents 8d9bb0cf2c2a
children e27bdcc80744 204be4fc2726
rev   line source
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
1 /*
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
2 SDL - Simple DirectMedia Layer
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
4
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
5 This library is free software; you can redistribute it and/or
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
6 modify it under the terms of the GNU Lesser General Public
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
7 License as published by the Free Software Foundation; either
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
9
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
10 This library is distributed in the hope that it will be useful,
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
13 Lesser General Public License for more details.
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
14
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
15 You should have received a copy of the GNU Lesser General Public
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
16 License along with this library; if not, write to the Free Software
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
18
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
19 Sam Lantinga
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
20 slouken@libsdl.org
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
21 */
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
22 #include "SDL_config.h"
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
23
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
24 #include <sys/types.h>
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
25 #include <sys/ioctl.h>
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
26
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
27 #include <unistd.h>
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
28 #include <fcntl.h>
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
29 #include <string.h>
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
30 #include <termios.h>
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
31 #include <ctype.h>
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
32
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
33 #include <linux/vt.h>
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
34 #include <linux/kd.h>
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35 #include <linux/keyboard.h>
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
36 #include <linux/fb.h>
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
37
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
38 #include "SDL_video.h"
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
39 #include "SDL_mouse.h"
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
40 #include "../SDL_sysvideo.h"
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
41 #include "../SDL_pixels_c.h"
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
42 #include "../../events/SDL_events_c.h"
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
43 #include "SDL_sysevents.h"
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
44 #include "SDL_ipodvideo.h"
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
45
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
46 #define _THIS SDL_VideoDevice *this
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
47
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
48 static int iPod_VideoInit(_THIS, SDL_PixelFormat * vformat);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
49 static SDL_Rect **iPod_ListModes(_THIS, SDL_PixelFormat * format,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
50 Uint32 flags);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
51 static SDL_Surface *iPod_SetVideoMode(_THIS, SDL_Surface * current,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
52 int width, int height, int bpp,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
53 Uint32 flags);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
54 static int iPod_SetColors(_THIS, int firstcolor, int ncolors,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
55 SDL_Color * colors);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
56 static void iPod_UpdateRects(_THIS, int nrects, SDL_Rect * rects);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
57 static void iPod_VideoQuit(_THIS);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
58 static void iPod_PumpEvents(_THIS);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
59
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
60 static long iPod_GetGeneration();
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
61
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
62 static int initd = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
63 static int kbfd = -1;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
64 static int fbfd = -1;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
65 static int oldvt = -1;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
66 static int curvt = -1;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
67 static int old_kbmode = -1;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
68 static long generation = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
69 static struct termios old_termios, cur_termios;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
70
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
71 FILE *dbgout;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
72
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
73 #define LCD_DATA 0x10
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
74 #define LCD_CMD 0x08
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
75 #define IPOD_OLD_LCD_BASE 0xc0001000
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
76 #define IPOD_OLD_LCD_RTC 0xcf001110
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
77 #define IPOD_NEW_LCD_BASE 0x70003000
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
78 #define IPOD_NEW_LCD_RTC 0x60005010
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
79
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
80 static unsigned long lcd_base, lcd_rtc, lcd_width, lcd_height;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
81
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
82 static long
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
83 iPod_GetGeneration()
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
84 {
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
85 int i;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
86 char cpuinfo[256];
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
87 char *ptr;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
88 FILE *file;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
89
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
90 if ((file = fopen("/proc/cpuinfo", "r")) != NULL) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
91 while (fgets(cpuinfo, sizeof(cpuinfo), file) != NULL)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
92 if (SDL_strncmp(cpuinfo, "Revision", 8) == 0)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
93 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
94 fclose(file);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
95 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
96 for (i = 0; !isspace(cpuinfo[i]); i++);
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
97 for (; isspace(cpuinfo[i]); i++);
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
98 ptr = cpuinfo + i + 2;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
99
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1140
diff changeset
100 return SDL_strtol(ptr, NULL, 10);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
101 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
102
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
103 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
104 iPod_Available()
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
105 {
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
106 return 1;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
107 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
108
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
109 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
110 iPod_DeleteDevice(SDL_VideoDevice * device)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
111 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
112 free(device->hidden);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
113 free(device);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
114 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
115
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
116 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
117 iPod_InitOSKeymap(_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
118 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
119 }
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
120
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
121 static SDL_VideoDevice *
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
122 iPod_CreateDevice(int devindex)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
123 {
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
124 SDL_VideoDevice *this;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
125
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
126 this = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
127 if (this) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
128 memset(this, 0, sizeof *this);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
129 this->hidden = (struct SDL_PrivateVideoData *)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
130 SDL_malloc(sizeof(struct SDL_PrivateVideoData));
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
131 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
132 if (!this || !this->hidden) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
133 SDL_OutOfMemory();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
134 if (this)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
135 SDL_free(this);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
136 return 0;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
137 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
138 memset(this->hidden, 0, sizeof(struct SDL_PrivateVideoData));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
139
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
140 generation = iPod_GetGeneration();
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
141
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
142 this->VideoInit = iPod_VideoInit;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
143 this->ListModes = iPod_ListModes;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
144 this->SetVideoMode = iPod_SetVideoMode;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
145 this->SetColors = iPod_SetColors;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
146 this->UpdateRects = iPod_UpdateRects;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
147 this->VideoQuit = iPod_VideoQuit;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
148 this->AllocHWSurface = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
149 this->CheckHWBlit = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
150 this->FillHWRect = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
151 this->SetHWColorKey = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
152 this->SetHWAlpha = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
153 this->LockHWSurface = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
154 this->UnlockHWSurface = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
155 this->FlipHWSurface = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
156 this->FreeHWSurface = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
157 this->SetCaption = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
158 this->SetIcon = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
159 this->IconifyWindow = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
160 this->GrabInput = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
161 this->GetWMInfo = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
162 this->InitOSKeymap = iPod_InitOSKeymap;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
163 this->PumpEvents = iPod_PumpEvents;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
164 this->free = iPod_DeleteDevice;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
165
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
166 return this;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
167 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
168
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
169 VideoBootStrap iPod_bootstrap = {
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
170 "ipod", "iPod Framebuffer Driver",
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
171 iPod_Available, iPod_CreateDevice
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
172 };
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
173
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
174 //--//
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
175
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
176 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
177 iPod_VideoInit(_THIS, SDL_PixelFormat * vformat)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
178 {
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
179 if (!initd) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
180 /*** Code adapted/copied from SDL fbcon driver. ***/
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
181
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
182 static const char *const tty0[] = { "/dev/tty0", "/dev/vc/0", 0 };
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
183 static const char *const vcs[] = { "/dev/vc/%d", "/dev/tty%d", 0 };
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
184 int i, tty0_fd;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
185
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
186 dbgout =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
187 fdopen(open("/etc/sdlpod.log", O_WRONLY | O_SYNC | O_APPEND),
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
188 "a");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
189 if (dbgout) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
190 setbuf(dbgout, 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
191 fprintf(dbgout, "--> Started SDL <--\n");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
192 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
193 // Try to query for a free VT
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
194 tty0_fd = -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
195 for (i = 0; tty0[i] && (tty0_fd < 0); ++i) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
196 tty0_fd = open(tty0[i], O_WRONLY, 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
197 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
198 if (tty0_fd < 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
199 tty0_fd = dup(0); /* Maybe stdin is a VT? */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
200 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
201 ioctl(tty0_fd, VT_OPENQRY, &curvt);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
202 close(tty0_fd);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
203
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
204 tty0_fd = open("/dev/tty", O_RDWR, 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
205 if (tty0_fd >= 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
206 ioctl(tty0_fd, TIOCNOTTY, 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
207 close(tty0_fd);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
208 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
209
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
210 if ((geteuid() == 0) && (curvt > 0)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
211 for (i = 0; vcs[i] && (kbfd < 0); ++i) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
212 char vtpath[12];
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
213
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
214 SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], curvt);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
215 kbfd = open(vtpath, O_RDWR);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
216 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
217 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
218 if (kbfd < 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
219 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
220 fprintf(dbgout, "Couldn't open any VC\n");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
221 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
222 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
223 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
224 fprintf(stderr, "Current VT: %d\n", curvt);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
225
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
226 if (kbfd >= 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
227 /* Switch to the correct virtual terminal */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
228 if (curvt > 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
229 struct vt_stat vtstate;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
230
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
231 if (ioctl(kbfd, VT_GETSTATE, &vtstate) == 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
232 oldvt = vtstate.v_active;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
233 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
234 if (ioctl(kbfd, VT_ACTIVATE, curvt) == 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
235 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
236 fprintf(dbgout, "Waiting for switch to this VT... ");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
237 ioctl(kbfd, VT_WAITACTIVE, curvt);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
238 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
239 fprintf(dbgout, "done!\n");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
240 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
241 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
242 // Set terminal input mode
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
243 if (tcgetattr(kbfd, &old_termios) < 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
244 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
245 fprintf(dbgout, "Can't get termios\n");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
246 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
247 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
248 cur_termios = old_termios;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
249 // cur_termios.c_iflag &= ~(ICRNL | INPCK | ISTRIP | IXON);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
250 // cur_termios.c_iflag |= (BRKINT);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
251 // cur_termios.c_lflag &= ~(ICANON | ECHO | ISIG | IEXTEN);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
252 // cur_termios.c_oflag &= ~(OPOST);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
253 // cur_termios.c_oflag |= (ONOCR | ONLRET);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
254 cur_termios.c_lflag &= ~(ICANON | ECHO | ISIG);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
255 cur_termios.c_iflag &=
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
256 ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
257 cur_termios.c_cc[VMIN] = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
258 cur_termios.c_cc[VTIME] = 0;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
259
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
260 if (tcsetattr(kbfd, TCSAFLUSH, &cur_termios) < 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
261 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
262 fprintf(dbgout, "Can't set termios\n");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
263 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
264 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
265 if (ioctl(kbfd, KDSKBMODE, K_MEDIUMRAW) < 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
266 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
267 fprintf(dbgout, "Can't set medium-raw mode\n");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
268 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
269 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
270 if (ioctl(kbfd, KDSETMODE, KD_GRAPHICS) < 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
271 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
272 fprintf(dbgout, "Can't set graphics\n");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
273 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
274 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
275 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
276 // Open the framebuffer
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
277 if ((fbfd = open("/dev/fb0", O_RDWR)) < 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
278 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
279 fprintf(dbgout, "Can't open framebuffer\n");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
280 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
281 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
282 struct fb_var_screeninfo vinfo;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
283
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
284 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
285 fprintf(dbgout, "Generation: %ld\n", generation);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
286
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
287 if (generation >= 40000) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
288 lcd_base = IPOD_NEW_LCD_BASE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
289 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
290 lcd_base = IPOD_OLD_LCD_BASE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
291 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
292
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
293 ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
294 close(fbfd);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
295
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
296 if (lcd_base == IPOD_OLD_LCD_BASE)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
297 lcd_rtc = IPOD_OLD_LCD_RTC;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
298 else if (lcd_base == IPOD_NEW_LCD_BASE)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
299 lcd_rtc = IPOD_NEW_LCD_RTC;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
300 else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
301 SDL_SetError("Unknown iPod version");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
302 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
303 }
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
304
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
305 lcd_width = vinfo.xres;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
306 lcd_height = vinfo.yres;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
307
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
308 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
309 fprintf(dbgout, "LCD is %dx%d\n", lcd_width, lcd_height);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
310 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
311
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
312 fcntl(kbfd, F_SETFL, O_RDWR | O_NONBLOCK);
1545
8d9bb0cf2c2a Added current_w and current_h to the SDL_VideoInfo structure, which is set to the desktop resolution during video intialization, and then set to the current resolution when a video mode is set.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
313
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
314 /* Determine the current screen size */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
315 this->info.current_w = lcd_width;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
316 this->info.current_h = lcd_height;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
317
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
318 if ((generation >= 60000) && (generation < 70000)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
319 vformat->BitsPerPixel = 16;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
320 vformat->Rmask = 0xF800;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
321 vformat->Gmask = 0x07E0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
322 vformat->Bmask = 0x001F;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
323 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
324 vformat->BitsPerPixel = 8;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
325 vformat->Rmask = vformat->Gmask = vformat->Bmask = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
326 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
327
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
328 initd = 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
329 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
330 fprintf(dbgout, "Initialized.\n\n");
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
331 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
332 return 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
333 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
334
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
335 static SDL_Rect **
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
336 iPod_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
337 {
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
338 int width, height, fd;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
339 static SDL_Rect r;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
340 static SDL_Rect *rs[2] = { &r, 0 };
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
341
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
342 if ((fd = open("/dev/fb0", O_RDWR)) < 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
343 return 0;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
344 } else {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
345 struct fb_var_screeninfo vinfo;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
346
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
347 ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
348 close(fbfd);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
349
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
350 width = vinfo.xres;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
351 height = vinfo.yres;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
352 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
353 r.x = r.y = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
354 r.w = width;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
355 r.h = height;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
356 return rs;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
357 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
358
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
359
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
360 static SDL_Surface *
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
361 iPod_SetVideoMode(_THIS, SDL_Surface * current, int width, int height,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
362 int bpp, Uint32 flags)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
363 {
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
364 Uint32 Rmask, Gmask, Bmask;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
365 if (bpp > 8) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
366 Rmask = 0xF800;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
367 Gmask = 0x07E0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
368 Bmask = 0x001F;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
369 } else {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
370 Rmask = Gmask = Bmask = 0;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
371 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
372
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
373 if (this->hidden->buffer)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
374 SDL_free(this->hidden->buffer);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
375 this->hidden->buffer = SDL_malloc(width * height * (bpp / 8));
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
376 if (!this->hidden->buffer) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
377 SDL_SetError("Couldn't allocate buffer for requested mode");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
378 return 0;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
379 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
380
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
381 memset(this->hidden->buffer, 0, width * height * (bpp / 8));
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
382
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
383 if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
384 SDL_SetError("Couldn't allocate new pixel format");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
385 SDL_free(this->hidden->buffer);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
386 this->hidden->buffer = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
387 return 0;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
388 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
389
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
390 if (bpp <= 8) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
391 int i, j;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
392 for (i = 0; i < 256; i += 4) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
393 for (j = 0; j < 4; j++) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
394 current->format->palette->colors[i + j].r = 85 * j;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
395 current->format->palette->colors[i + j].g = 85 * j;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
396 current->format->palette->colors[i + j].b = 85 * j;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
397 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
398 }
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
399 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
400
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
401 current->flags = flags & SDL_FULLSCREEN;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
402 this->hidden->w = current->w = width;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
403 this->hidden->h = current->h = height;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
404 current->pitch = current->w * (bpp / 8);
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
405 current->pixels = this->hidden->buffer;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
406
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
407 return current;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
408 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
409
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
410 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
411 iPod_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
412 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
413 if (SDL_VideoSurface && SDL_VideoSurface->format
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
414 && SDL_VideoSurface->format->palette) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
415 int i, j;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
416 for (i = 0; i < 256; i += 4) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
417 for (j = 0; j < 4; j++) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
418 SDL_VideoSurface->format->palette->colors[i + j].r = 85 * j;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
419 SDL_VideoSurface->format->palette->colors[i + j].g = 85 * j;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
420 SDL_VideoSurface->format->palette->colors[i + j].b = 85 * j;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
421 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
422 }
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
423 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
424 return 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
425 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
426
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
427 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
428 iPod_VideoQuit(_THIS)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
429 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
430 ioctl(kbfd, KDSETMODE, KD_TEXT);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
431 tcsetattr(kbfd, TCSAFLUSH, &old_termios);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
432 old_kbmode = -1;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
433
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
434 if (oldvt > 0)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
435 ioctl(kbfd, VT_ACTIVATE, oldvt);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
436
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
437 if (kbfd > 0)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
438 close(kbfd);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
439
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
440 if (dbgout) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
441 fprintf(dbgout, "<-- Ended SDL -->\n");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
442 fclose(dbgout);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
443 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
444
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
445 kbfd = -1;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
446 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
447
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
448 static char iPod_SC_keymap[] = {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
449 0, /* 0 - no key */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
450 '[' - 0x40, /* ESC (Ctrl+[) */
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
451 '1', '2', '3', '4', '5', '6', '7', '8', '9',
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
452 '-', '=',
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
453 '\b', '\t', /* Backspace, Tab (Ctrl+H,Ctrl+I) */
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
454 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']',
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
455 '\n', 0, /* Enter, Left CTRL */
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
456 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`',
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
457 0, '\\', /* left shift, backslash */
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
458 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/',
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
459 0, '*', 0, ' ', 0, /* right shift, KP mul, left alt, space, capslock */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
460 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* F1-10 */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
461 0, 0, /* numlock, scrollock */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
462 '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', /* numeric keypad */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
463 0, 0, /* padding */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
464 0, 0, 0, /* "less" (?), F11, F12 */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
465 0, 0, 0, 0, 0, 0, 0, /* padding */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
466 '\n', 0, '/', 0, 0, /* KP enter, Rctrl, Ctrl, KP div, PrtSc, RAlt */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
467 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Break, Home, Up, PgUp, Left, Right, End, Down, PgDn */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
468 0, 0, /* Ins, Del */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
469 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* padding */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
470 0, 0, /* RWin, LWin */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
471 0 /* no key */
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
472 };
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
473
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
474
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
475 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
476 iPod_keyboard()
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
477 {
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
478 unsigned char keybuf[128];
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
479 int i, nread;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
480 SDL_keysym keysym;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
481 SDL_Event ev;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
482
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
483 keysym.mod = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
484 keysym.scancode = 0xff;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
485 memset(&ev, 0, sizeof(SDL_Event));
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
486
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
487 nread = read(kbfd, keybuf, 128);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
488 for (i = 0; i < nread; i++) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
489 char ascii = iPod_SC_keymap[keybuf[i] & 0x7f];
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
490
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
491 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
492 fprintf(dbgout, "Key! %02x is %c %s", keybuf[i], ascii,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
493 (keybuf[i] & 0x80) ? "up" : "down");
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
494
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
495 keysym.sym = keysym.unicode = ascii;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
496 ev.type = (keybuf[i] & 0x80) ? SDL_KEYUP : SDL_KEYDOWN;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
497 ev.key.state = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
498 ev.key.keysym = keysym;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
499 SDL_PushEvent(&ev);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
500 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
501 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
502
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
503 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
504 iPod_PumpEvents(_THIS)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
505 {
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
506 fd_set fdset;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
507 int max_fd = 0;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
508 static struct timeval zero;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
509 int posted;
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
510
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
511 do {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
512 posted = 0;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
513
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
514 FD_ZERO(&fdset);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
515 if (kbfd >= 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
516 FD_SET(kbfd, &fdset);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
517 max_fd = kbfd;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
518 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
519 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
520 fprintf(dbgout, "Selecting");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
521 if (select(max_fd + 1, &fdset, 0, 0, &zero) > 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
522 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
523 fprintf(dbgout, " -> match!\n");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
524 iPod_keyboard();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
525 posted++;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
526 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
527 if (dbgout)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
528 fprintf(dbgout, "\n");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
529 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
530 while (posted);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
531 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
532
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
533 // enough space for 160x128x2
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
534 static char ipod_scr[160 * (128 / 4)];
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
535
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
536 #define outl(datum,addr) (*(volatile unsigned long *)(addr) = (datum))
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
537 #define inl(addr) (*(volatile unsigned long *)(addr))
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
538
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
539 /*** The following LCD code is taken from Linux kernel uclinux-2.4.24-uc0-ipod2,
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
540 file arch/armnommu/mach-ipod/fb.c. A few modifications have been made. ***/
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
541
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
542 /* get current usec counter */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
543 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
544 M_timer_get_current(void)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
545 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
546 return inl(lcd_rtc);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
547 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
548
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
549 /* check if number of useconds has past */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
550 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
551 M_timer_check(int clock_start, int usecs)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
552 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
553 unsigned long clock;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
554 clock = inl(lcd_rtc);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
555
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
556 if ((clock - clock_start) >= usecs) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
557 return 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
558 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
559 return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
560 }
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
561 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
562
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
563 /* wait for LCD with timeout */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
564 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
565 M_lcd_wait_write(void)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
566 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
567 if ((inl(lcd_base) & 0x8000) != 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
568 int start = M_timer_get_current();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
569
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
570 do {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
571 if ((inl(lcd_base) & (unsigned int) 0x8000) == 0)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
572 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
573 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
574 while (M_timer_check(start, 1000) == 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
575 }
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
576 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
577
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
578
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
579 /* send LCD data */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
580 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
581 M_lcd_send_data(int data_lo, int data_hi)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
582 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
583 M_lcd_wait_write();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
584
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
585 outl(data_lo, lcd_base + LCD_DATA);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
586
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
587 M_lcd_wait_write();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
588
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
589 outl(data_hi, lcd_base + LCD_DATA);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
590
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
591 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
592
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
593 /* send LCD command */
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
594 static void
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
595 M_lcd_prepare_cmd(int cmd)
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
596 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
597 M_lcd_wait_write();
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
598
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
599 outl(0x0, lcd_base + LCD_CMD);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
600
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
601 M_lcd_wait_write();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
602
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
603 outl(cmd, lcd_base + LCD_CMD);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
604
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
605 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
606
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
607 /* send LCD command and data */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
608 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
609 M_lcd_cmd_and_data(int cmd, int data_lo, int data_hi)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
610 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
611 M_lcd_prepare_cmd(cmd);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
612
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
613 M_lcd_send_data(data_lo, data_hi);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
614 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
615
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
616 // Copied from uW
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
617 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
618 M_update_display(int sx, int sy, int mx, int my)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
619 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
620 int y;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
621 unsigned short cursor_pos;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
622
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
623 sx >>= 3;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
624 mx >>= 3;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
625
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
626 cursor_pos = sx + (sy << 5);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
627
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
628 for (y = sy; y <= my; y++) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
629 unsigned char *img_data;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
630 int x;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
631
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
632 /* move the cursor */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
633 M_lcd_cmd_and_data(0x11, cursor_pos >> 8, cursor_pos & 0xff);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
634
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
635 /* setup for printing */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
636 M_lcd_prepare_cmd(0x12);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
637
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
638 img_data = ipod_scr + (sx << 1) + (y * (lcd_width / 4));
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
639
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
640 /* loops up to 160 times */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
641 for (x = sx; x <= mx; x++) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
642 /* display eight pixels */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
643 M_lcd_send_data(*(img_data + 1), *img_data);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
644
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
645 img_data += 2;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
646 }
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
647
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
648 /* update cursor pos counter */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
649 cursor_pos += 0x20;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
650 }
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
651 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
652
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
653 /* get current usec counter */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
654 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
655 C_timer_get_current(void)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
656 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
657 return inl(0x60005010);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
658 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
659
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
660 /* check if number of useconds has past */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
661 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
662 C_timer_check(int clock_start, int usecs)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
663 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
664 unsigned long clock;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
665 clock = inl(0x60005010);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
666
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
667 if ((clock - clock_start) >= usecs) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
668 return 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
669 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
670 return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
671 }
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
672 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
673
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
674 /* wait for LCD with timeout */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
675 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
676 C_lcd_wait_write(void)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
677 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
678 if ((inl(0x70008A0C) & 0x80000000) != 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
679 int start = C_timer_get_current();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
680
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
681 do {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
682 if ((inl(0x70008A0C) & 0x80000000) == 0)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
683 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
684 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
685 while (C_timer_check(start, 1000) == 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
686 }
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
687 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
688 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
689 C_lcd_cmd_data(int cmd, int data)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
690 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
691 C_lcd_wait_write();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
692 outl(cmd | 0x80000000, 0x70008A0C);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
693
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
694 C_lcd_wait_write();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
695 outl(data | 0x80000000, 0x70008A0C);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
696 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
697
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
698 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
699 C_update_display(int sx, int sy, int mx, int my)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
700 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
701 int height = (my - sy) + 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
702 int width = (mx - sx) + 1;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
703
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
704 char *addr = SDL_VideoSurface->pixels;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
705
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
706 if (width & 1)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
707 width++;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
708
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
709 /* start X and Y */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
710 C_lcd_cmd_data(0x12, (sy & 0xff));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
711 C_lcd_cmd_data(0x13, (((SDL_VideoSurface->w - 1) - sx) & 0xff));
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
712
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
713 /* max X and Y */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
714 C_lcd_cmd_data(0x15, (((sy + height) - 1) & 0xff));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
715 C_lcd_cmd_data(0x16,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
716 (((((SDL_VideoSurface->w - 1) - sx) - width) + 1) & 0xff));
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
717
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
718 addr += sx + sy * SDL_VideoSurface->pitch;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
719
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
720 while (height > 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
721 int h, x, y, pixels_to_write;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
722
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
723 pixels_to_write = (width * height) * 2;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
724
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
725 /* calculate how much we can do in one go */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
726 h = height;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
727 if (pixels_to_write > 64000) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
728 h = (64000 / 2) / width;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
729 pixels_to_write = (width * h) * 2;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
730 }
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
731
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
732 outl(0x10000080, 0x70008A20);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
733 outl((pixels_to_write - 1) | 0xC0010000, 0x70008A24);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
734 outl(0x34000000, 0x70008A20);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
735
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
736 /* for each row */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
737 for (x = 0; x < h; x++) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
738 /* for each column */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
739 for (y = 0; y < width; y += 2) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
740 unsigned two_pixels;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
741
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
742 two_pixels = addr[0] | (addr[1] << 16);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
743 addr += 2;
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
744
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
745 while ((inl(0x70008A20) & 0x1000000) == 0);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
746
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
747 /* output 2 pixels */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
748 outl(two_pixels, 0x70008B00);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
749 }
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
750
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
751 addr += SDL_VideoSurface->w - width;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
752 }
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
753
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
754 while ((inl(0x70008A20) & 0x4000000) == 0);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
755
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
756 outl(0x0, 0x70008A24);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
757
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
758 height = height - h;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
759 }
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
760 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
761
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
762 // Should work with photo. However, I don't have one, so I'm not sure.
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
763 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
764 iPod_UpdateRects(_THIS, int nrects, SDL_Rect * rects)
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
765 {
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
766 if (SDL_VideoSurface->format->BitsPerPixel == 16) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
767 C_update_display(0, 0, lcd_width, lcd_height);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
768 } else {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
769 int i, y, x;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
770 for (i = 0; i < nrects; i++) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
771 SDL_Rect *r = rects + i;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
772 if (!r) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
773 continue;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
774 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
775
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
776 for (y = r->y; (y < r->y + r->h) && y < lcd_height; y++) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
777 for (x = r->x; (x < r->x + r->w) && x < lcd_width; x++) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
778 ipod_scr[y * (lcd_width / 4) + x / 4] &=
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
779 ~(3 << (2 * (x % 4)));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
780 ipod_scr[y * (lcd_width / 4) + x / 4] |=
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
781 (((Uint8 *) (SDL_VideoSurface->pixels))[y *
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
782 SDL_VideoSurface->
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
783 pitch
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
784 +
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
785 x] &
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
786 3) << (2 * (x % 4));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
787 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
788 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
789 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
790
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
791 M_update_display(0, 0, lcd_width, lcd_height);
1140
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
792 }
af8b0f9ac2f4 iPod Linux framebuffer support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
793 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
794
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1545
diff changeset
795 /* vi: set ts=4 sw=4 expandtab: */