annotate src/video/ipod/SDL_ipodvideo.c @ 1358:c71e05b4dc2e

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