Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
1815 lines (1657 loc) · 55.9 KB

SDL_fbvideo.c

File metadata and controls

1815 lines (1657 loc) · 55.9 KB
 
Apr 26, 2001
Apr 26, 2001
1
/*
Feb 1, 2006
Feb 1, 2006
2
SDL - Simple DirectMedia Layer
Dec 8, 2008
Dec 8, 2008
3
Copyright (C) 1997-2009 Sam Lantinga
Apr 26, 2001
Apr 26, 2001
4
Feb 1, 2006
Feb 1, 2006
5
6
7
8
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
Apr 26, 2001
Apr 26, 2001
9
Feb 1, 2006
Feb 1, 2006
10
11
12
13
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
Apr 26, 2001
Apr 26, 2001
14
Feb 1, 2006
Feb 1, 2006
15
16
17
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Apr 26, 2001
Apr 26, 2001
18
Feb 1, 2006
Feb 1, 2006
19
20
Sam Lantinga
slouken@libsdl.org
Apr 26, 2001
Apr 26, 2001
21
*/
Feb 21, 2006
Feb 21, 2006
22
#include "SDL_config.h"
Apr 26, 2001
Apr 26, 2001
23
24
25
26
27
28
29
30
31
/* Framebuffer console based SDL video driver implementation.
*/
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
Mar 14, 2007
Mar 14, 2007
32
33
#ifndef HAVE_GETPAGESIZE
Jul 10, 2006
Jul 10, 2006
34
#include <asm/page.h> /* For definition of PAGE_SIZE */
Mar 14, 2007
Mar 14, 2007
35
36
#endif
Mar 22, 2006
Mar 22, 2006
37
#include <linux/vt.h>
Apr 26, 2001
Apr 26, 2001
38
39
40
#include "SDL_video.h"
#include "SDL_mouse.h"
Feb 16, 2006
Feb 16, 2006
41
42
43
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
Apr 26, 2001
Apr 26, 2001
44
45
46
47
48
#include "SDL_fbvideo.h"
#include "SDL_fbmouse_c.h"
#include "SDL_fbevents_c.h"
#include "SDL_fb3dfx.h"
#include "SDL_fbmatrox.h"
Jul 31, 2001
Jul 31, 2001
49
50
#include "SDL_fbriva.h"
Jan 2, 2006
Jan 2, 2006
51
/*#define FBCON_DEBUG*/
Apr 26, 2001
Apr 26, 2001
52
53
54
#if defined(i386) && defined(FB_TYPE_VGA_PLANES)
#define VGA16_FBCON_SUPPORT
Jul 10, 2006
Jul 10, 2006
55
#include <sys/io.h> /* For ioperm() */
Apr 26, 2001
Apr 26, 2001
56
57
58
#ifndef FB_AUX_VGA_PLANES_VGA4
#define FB_AUX_VGA_PLANES_VGA4 0
#endif
Feb 7, 2006
Feb 7, 2006
59
/*
Apr 26, 2001
Apr 26, 2001
60
61
62
63
static inline void outb (unsigned char value, unsigned short port)
{
__asm__ __volatile__ ("outb %b0,%w1"::"a" (value), "Nd" (port));
}
Feb 7, 2006
Feb 7, 2006
64
*/
Apr 26, 2001
Apr 26, 2001
65
66
67
#endif /* FB_TYPE_VGA_PLANES */
/* A list of video resolutions that we query for (sorted largest to smallest) */
Jul 7, 2001
Jul 7, 2001
68
static const SDL_Rect checkres[] = {
Jul 10, 2006
Jul 10, 2006
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{0, 0, 1600, 1200}, /* 16 bpp: 0x11E, or 286 */
{0, 0, 1408, 1056}, /* 16 bpp: 0x19A, or 410 */
{0, 0, 1280, 1024}, /* 16 bpp: 0x11A, or 282 */
{0, 0, 1152, 864}, /* 16 bpp: 0x192, or 402 */
{0, 0, 1024, 768}, /* 16 bpp: 0x117, or 279 */
{0, 0, 960, 720}, /* 16 bpp: 0x18A, or 394 */
{0, 0, 800, 600}, /* 16 bpp: 0x114, or 276 */
{0, 0, 768, 576}, /* 16 bpp: 0x182, or 386 */
{0, 0, 720, 576}, /* PAL */
{0, 0, 720, 480}, /* NTSC */
{0, 0, 640, 480}, /* 16 bpp: 0x111, or 273 */
{0, 0, 640, 400}, /* 8 bpp: 0x100, or 256 */
{0, 0, 512, 384},
{0, 0, 320, 240},
{0, 0, 320, 200}
Apr 26, 2001
Apr 26, 2001
84
};
Aug 27, 2008
Aug 27, 2008
85
Jul 10, 2006
Jul 10, 2006
86
87
88
89
90
91
92
93
94
95
96
97
98
static const struct
{
int xres;
int yres;
int pixclock;
int left;
int right;
int upper;
int lower;
int hslen;
int vslen;
int sync;
int vmode;
Apr 26, 2001
Apr 26, 2001
99
} vesa_timings[] = {
Jul 10, 2006
Jul 10, 2006
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifdef USE_VESA_TIMINGS /* Only tested on Matrox Millenium I */
{
640, 400, 39771, 48, 16, 39, 8, 96, 2, 2, 0}, /* 70 Hz */
{
640, 480, 39683, 48, 16, 33, 10, 96, 2, 0, 0}, /* 60 Hz */
{
768, 576, 26101, 144, 16, 28, 6, 112, 4, 0, 0}, /* 60 Hz */
{
800, 600, 24038, 144, 24, 28, 8, 112, 6, 0, 0}, /* 60 Hz */
{
960, 720, 17686, 144, 24, 28, 8, 112, 4, 0, 0}, /* 60 Hz */
{
1024, 768, 15386, 160, 32, 30, 4, 128, 4, 0, 0}, /* 60 Hz */
{
1152, 864, 12286, 192, 32, 30, 4, 128, 4, 0, 0}, /* 60 Hz */
{
1280, 1024, 9369, 224, 32, 32, 4, 136, 4, 0, 0}, /* 60 Hz */
{
1408, 1056, 8214, 256, 40, 32, 5, 144, 5, 0, 0}, /* 60 Hz */
{
1600, 1200, /*? */ 0, 272, 48, 32, 5, 152, 5, 0, 0}, /* 60 Hz */
Apr 26, 2001
Apr 26, 2001
121
#else
Jul 10, 2006
Jul 10, 2006
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* You can generate these timings from your XF86Config file using
the 'modeline2fb' perl script included with the fbset package.
These timings were generated for Matrox Millenium I, 15" monitor.
*/
{
320, 200, 79440, 16, 16, 20, 4, 48, 1, 0, 2}, /* 70 Hz */
{
320, 240, 63492, 16, 16, 16, 4, 48, 2, 0, 2}, /* 72 Hz */
{
512, 384, 49603, 48, 16, 16, 1, 64, 3, 0, 0}, /* 78 Hz */
{
640, 400, 31746, 96, 32, 41, 1, 64, 3, 2, 0}, /* 85 Hz */
{
640, 480, 31746, 120, 16, 16, 1, 64, 3, 0, 0}, /* 75 Hz */
{
768, 576, 26101, 144, 16, 28, 6, 112, 4, 0, 0}, /* 60 Hz */
{
800, 600, 20000, 64, 56, 23, 37, 120, 6, 3, 0}, /* 72 Hz */
{
960, 720, 17686, 144, 24, 28, 8, 112, 4, 0, 0}, /* 60 Hz */
{
1024, 768, 13333, 144, 24, 29, 3, 136, 6, 0, 0}, /* 70 Hz */
{
1152, 864, 12286, 192, 32, 30, 4, 128, 4, 0, 0}, /* 60 Hz */
{
1280, 1024, 9369, 224, 32, 32, 4, 136, 4, 0, 0}, /* 60 Hz */
{
1408, 1056, 8214, 256, 40, 32, 5, 144, 5, 0, 0}, /* 60 Hz */
{
1600, 1200, /*? */ 0, 272, 48, 32, 5, 152, 5, 0, 0}, /* 60 Hz */
Apr 26, 2001
Apr 26, 2001
152
153
154
155
#endif
};
/* Initialization/Query functions */
Jul 10, 2006
Jul 10, 2006
156
157
158
159
static int FB_VideoInit(_THIS, SDL_PixelFormat * vformat);
static SDL_Rect **FB_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags);
static SDL_Surface *FB_SetVideoMode(_THIS, SDL_Surface * current, int width,
int height, int bpp, Uint32 flags);
Apr 26, 2001
Apr 26, 2001
160
#ifdef VGA16_FBCON_SUPPORT
Jul 10, 2006
Jul 10, 2006
161
162
static SDL_Surface *FB_SetVGA16Mode(_THIS, SDL_Surface * current, int width,
int height, int bpp, Uint32 flags);
Apr 26, 2001
Apr 26, 2001
163
#endif
Jul 10, 2006
Jul 10, 2006
164
165
static int FB_SetColors(_THIS, int firstcolor, int ncolors,
SDL_Color * colors);
Apr 26, 2001
Apr 26, 2001
166
167
168
static void FB_VideoQuit(_THIS);
/* Hardware surface functions */
Jul 10, 2006
Jul 10, 2006
169
170
static int FB_InitHWSurfaces(_THIS, SDL_Surface * screen, char *base,
int size);
Apr 26, 2001
Apr 26, 2001
171
static void FB_FreeHWSurfaces(_THIS);
Jul 10, 2006
Jul 10, 2006
172
173
174
175
static int FB_AllocHWSurface(_THIS, SDL_Surface * surface);
static int FB_LockHWSurface(_THIS, SDL_Surface * surface);
static void FB_UnlockHWSurface(_THIS, SDL_Surface * surface);
static void FB_FreeHWSurface(_THIS, SDL_Surface * surface);
Apr 26, 2001
Apr 26, 2001
176
static void FB_WaitVBL(_THIS);
Jul 13, 2001
Jul 13, 2001
177
static void FB_WaitIdle(_THIS);
Jul 10, 2006
Jul 10, 2006
178
static int FB_FlipHWSurface(_THIS, SDL_Surface * surface);
Apr 26, 2001
Apr 26, 2001
179
180
181
/* Internal palette functions */
static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo,
Jul 10, 2006
Jul 10, 2006
182
struct fb_var_screeninfo *vinfo);
Apr 26, 2001
Apr 26, 2001
183
184
static void FB_RestorePalette(_THIS);
Jun 14, 2007
Jun 14, 2007
185
186
static int
SDL_getpagesize(void)
Feb 15, 2007
Feb 15, 2007
187
188
189
190
191
192
193
{
#ifdef HAVE_GETPAGESIZE
return getpagesize();
#elif defined(PAGE_SIZE)
return PAGE_SIZE;
#else
#error Can not determine system page size.
Jun 14, 2007
Jun 14, 2007
194
195
/* this is what it USED to be in Linux... */
return 4096;
Feb 15, 2007
Feb 15, 2007
196
197
198
199
#endif
}
May 10, 2006
May 10, 2006
200
201
202
/* Small wrapper for mmap() so we can play nicely with no-mmu hosts
* (non-mmu hosts disallow the MAP_SHARED flag) */
Jul 10, 2006
Jul 10, 2006
203
204
static void *
do_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
May 10, 2006
May 10, 2006
205
{
Jul 10, 2006
Jul 10, 2006
206
207
208
209
210
211
212
void *ret;
ret = mmap(start, length, prot, flags, fd, offset);
if (ret == (char *) -1 && (flags & MAP_SHARED)) {
ret = mmap(start, length, prot,
(flags & ~MAP_SHARED) | MAP_PRIVATE, fd, offset);
}
return ret;
May 10, 2006
May 10, 2006
213
214
}
Apr 26, 2001
Apr 26, 2001
215
216
/* FB driver bootstrap functions */
Jul 10, 2006
Jul 10, 2006
217
218
static int
FB_Available(void)
Apr 26, 2001
Apr 26, 2001
219
{
Jul 10, 2006
Jul 10, 2006
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
int console = -1;
/* Added check for /fb/0 (devfs) */
/* but - use environment variable first... if it fails, still check defaults */
int idx = 0;
const char *SDL_fbdevs[4] = { NULL, "/dev/fb0", "/dev/fb/0", NULL };
SDL_fbdevs[0] = SDL_getenv("SDL_FBDEV");
if (!SDL_fbdevs[0])
idx++;
for (; SDL_fbdevs[idx]; idx++) {
console = open(SDL_fbdevs[idx], O_RDWR, 0);
if (console >= 0) {
close(console);
break;
}
}
return (console >= 0);
Apr 26, 2001
Apr 26, 2001
237
238
}
Jul 10, 2006
Jul 10, 2006
239
240
static void
FB_DeleteDevice(SDL_VideoDevice * device)
Apr 26, 2001
Apr 26, 2001
241
{
Jul 10, 2006
Jul 10, 2006
242
243
SDL_free(device->hidden);
SDL_free(device);
Apr 26, 2001
Apr 26, 2001
244
245
}
Jul 10, 2006
Jul 10, 2006
246
247
static SDL_VideoDevice *
FB_CreateDevice(int devindex)
Apr 26, 2001
Apr 26, 2001
248
{
Jul 10, 2006
Jul 10, 2006
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
SDL_VideoDevice *this;
/* Initialize all variables that we clean on shutdown */
this = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
if (this) {
SDL_memset(this, 0, (sizeof *this));
this->hidden = (struct SDL_PrivateVideoData *)
SDL_malloc((sizeof *this->hidden));
}
if ((this == NULL) || (this->hidden == NULL)) {
SDL_OutOfMemory();
if (this) {
SDL_free(this);
}
return (0);
}
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
wait_vbl = FB_WaitVBL;
wait_idle = FB_WaitIdle;
mouse_fd = -1;
keyboard_fd = -1;
/* Set the function pointers */
this->VideoInit = FB_VideoInit;
this->ListModes = FB_ListModes;
this->SetVideoMode = FB_SetVideoMode;
this->SetColors = FB_SetColors;
this->UpdateRects = NULL;
this->VideoQuit = FB_VideoQuit;
this->AllocHWSurface = FB_AllocHWSurface;
this->CheckHWBlit = NULL;
this->FillHWRect = NULL;
this->SetHWColorKey = NULL;
this->SetHWAlpha = NULL;
this->LockHWSurface = FB_LockHWSurface;
this->UnlockHWSurface = FB_UnlockHWSurface;
this->FlipHWSurface = FB_FlipHWSurface;
this->FreeHWSurface = FB_FreeHWSurface;
this->SetCaption = NULL;
this->SetIcon = NULL;
this->IconifyWindow = NULL;
this->GrabInput = NULL;
this->GetWMInfo = NULL;
this->InitOSKeymap = FB_InitOSKeymap;
this->PumpEvents = FB_PumpEvents;
this->free = FB_DeleteDevice;
return this;
Apr 26, 2001
Apr 26, 2001
298
299
300
}
VideoBootStrap FBCON_bootstrap = {
Jul 10, 2006
Jul 10, 2006
301
302
"fbcon", "Linux Framebuffer Console",
FB_Available, FB_CreateDevice
Apr 26, 2001
Apr 26, 2001
303
304
};
Jan 2, 2006
Jan 2, 2006
305
306
#define FB_MODES_DB "/etc/fb.modes"
Jul 10, 2006
Jul 10, 2006
307
308
static int
read_fbmodes_line(FILE * f, char *line, int length)
Jan 2, 2006
Jan 2, 2006
309
{
Jul 10, 2006
Jul 10, 2006
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
int blank;
char *c;
int i;
blank = 0;
/* find a relevant line */
do {
if (fgets(line, length, f) <= 0)
return 0;
c = line;
while (((*c == '\t') || (*c == ' ')) && (*c != 0))
c++;
if ((*c == '\n') || (*c == '#') || (*c == 0))
blank = 1;
else
blank = 0;
Aug 27, 2008
Aug 27, 2008
327
} while (blank);
Jul 10, 2006
Jul 10, 2006
328
329
330
331
332
/* remove whitespace at the begining of the string */
i = 0;
do {
line[i] = c[i];
i++;
Aug 27, 2008
Aug 27, 2008
333
} while (c[i] != 0);
Jul 10, 2006
Jul 10, 2006
334
return 1;
Jan 2, 2006
Jan 2, 2006
335
336
}
Jul 10, 2006
Jul 10, 2006
337
338
static int
read_fbmodes_mode(FILE * f, struct fb_var_screeninfo *vinfo)
Jan 2, 2006
Jan 2, 2006
339
{
Jul 10, 2006
Jul 10, 2006
340
341
342
343
344
345
346
347
348
char line[1024];
char option[256];
/* Find a "geometry" */
do {
if (read_fbmodes_line(f, line, sizeof(line)) == 0)
return 0;
if (SDL_strncmp(line, "geometry", 8) == 0)
break;
Aug 27, 2008
Aug 27, 2008
349
} while (1);
Jul 10, 2006
Jul 10, 2006
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
SDL_sscanf(line, "geometry %d %d %d %d %d", &vinfo->xres, &vinfo->yres,
&vinfo->xres_virtual, &vinfo->yres_virtual,
&vinfo->bits_per_pixel);
if (read_fbmodes_line(f, line, sizeof(line)) == 0)
return 0;
SDL_sscanf(line, "timings %d %d %d %d %d %d %d", &vinfo->pixclock,
&vinfo->left_margin, &vinfo->right_margin,
&vinfo->upper_margin, &vinfo->lower_margin, &vinfo->hsync_len,
&vinfo->vsync_len);
vinfo->sync = 0;
vinfo->vmode = FB_VMODE_NONINTERLACED;
/* Parse misc options */
do {
if (read_fbmodes_line(f, line, sizeof(line)) == 0)
return 0;
if (SDL_strncmp(line, "hsync", 5) == 0) {
SDL_sscanf(line, "hsync %s", option);
if (SDL_strncmp(option, "high", 4) == 0)
vinfo->sync |= FB_SYNC_HOR_HIGH_ACT;
} else if (SDL_strncmp(line, "vsync", 5) == 0) {
SDL_sscanf(line, "vsync %s", option);
if (SDL_strncmp(option, "high", 4) == 0)
vinfo->sync |= FB_SYNC_VERT_HIGH_ACT;
} else if (SDL_strncmp(line, "csync", 5) == 0) {
SDL_sscanf(line, "csync %s", option);
if (SDL_strncmp(option, "high", 4) == 0)
vinfo->sync |= FB_SYNC_COMP_HIGH_ACT;
} else if (SDL_strncmp(line, "extsync", 5) == 0) {
SDL_sscanf(line, "extsync %s", option);
if (SDL_strncmp(option, "true", 4) == 0)
vinfo->sync |= FB_SYNC_EXT;
} else if (SDL_strncmp(line, "laced", 5) == 0) {
SDL_sscanf(line, "laced %s", option);
if (SDL_strncmp(option, "true", 4) == 0)
vinfo->vmode |= FB_VMODE_INTERLACED;
} else if (SDL_strncmp(line, "double", 6) == 0) {
SDL_sscanf(line, "double %s", option);
if (SDL_strncmp(option, "true", 4) == 0)
vinfo->vmode |= FB_VMODE_DOUBLE;
}
Aug 27, 2008
Aug 27, 2008
395
} while (SDL_strncmp(line, "endmode", 7) != 0);
Jul 10, 2006
Jul 10, 2006
396
397
return 1;
Jan 2, 2006
Jan 2, 2006
398
399
}
Jul 10, 2006
Jul 10, 2006
400
401
402
static int
FB_CheckMode(_THIS, struct fb_var_screeninfo *vinfo,
int index, unsigned int *w, unsigned int *h)
Apr 26, 2001
Apr 26, 2001
403
{
Jul 10, 2006
Jul 10, 2006
404
405
406
407
408
409
410
411
412
413
int mode_okay;
mode_okay = 0;
vinfo->bits_per_pixel = (index + 1) * 8;
vinfo->xres = *w;
vinfo->xres_virtual = *w;
vinfo->yres = *h;
vinfo->yres_virtual = *h;
vinfo->activate = FB_ACTIVATE_TEST;
if (ioctl(console_fd, FBIOPUT_VSCREENINFO, vinfo) == 0) {
Apr 26, 2001
Apr 26, 2001
414
#ifdef FBCON_DEBUG
Jul 10, 2006
Jul 10, 2006
415
416
417
418
fprintf(stderr,
"Checked mode %dx%d at %d bpp, got mode %dx%d at %d bpp\n",
*w, *h, (index + 1) * 8, vinfo->xres, vinfo->yres,
vinfo->bits_per_pixel);
Apr 26, 2001
Apr 26, 2001
419
#endif
Jul 10, 2006
Jul 10, 2006
420
421
422
423
424
425
426
if ((((vinfo->bits_per_pixel + 7) / 8) - 1) == index) {
*w = vinfo->xres;
*h = vinfo->yres;
mode_okay = 1;
}
}
return mode_okay;
Apr 26, 2001
Apr 26, 2001
427
428
}
Jul 10, 2006
Jul 10, 2006
429
430
431
static int
FB_AddMode(_THIS, int index, unsigned int w, unsigned int h,
int check_timings)
Apr 26, 2001
Apr 26, 2001
432
{
Jul 10, 2006
Jul 10, 2006
433
434
435
436
437
438
439
440
SDL_Rect *mode;
int i;
int next_mode;
/* Check to see if we already have this mode */
if (SDL_nummodes[index] > 0) {
mode = SDL_modelist[index][SDL_nummodes[index] - 1];
if ((mode->w == w) && (mode->h == h)) {
Apr 26, 2001
Apr 26, 2001
441
#ifdef FBCON_DEBUG
Jul 10, 2006
Jul 10, 2006
442
443
444
fprintf(stderr,
"We already have mode %dx%d at %d bytes per pixel\n",
w, h, index + 1);
Apr 26, 2001
Apr 26, 2001
445
#endif
Jul 10, 2006
Jul 10, 2006
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
return (0);
}
}
/* Only allow a mode if we have a valid timing for it */
if (check_timings) {
int found_timing = 0;
for (i = 0; i < (sizeof(vesa_timings) / sizeof(vesa_timings[0])); ++i) {
if ((w == vesa_timings[i].xres) &&
(h == vesa_timings[i].yres) && vesa_timings[i].pixclock) {
found_timing = 1;
break;
}
}
if (!found_timing) {
Apr 26, 2001
Apr 26, 2001
461
#ifdef FBCON_DEBUG
Jul 10, 2006
Jul 10, 2006
462
fprintf(stderr, "No valid timing line for mode %dx%d\n", w, h);
Apr 26, 2001
Apr 26, 2001
463
#endif
Jul 10, 2006
Jul 10, 2006
464
465
466
467
468
469
470
471
472
473
474
475
476
477
return (0);
}
}
/* Set up the new video mode rectangle */
mode = (SDL_Rect *) SDL_malloc(sizeof *mode);
if (mode == NULL) {
SDL_OutOfMemory();
return (-1);
}
mode->x = 0;
mode->y = 0;
mode->w = w;
mode->h = h;
Apr 26, 2001
Apr 26, 2001
478
#ifdef FBCON_DEBUG
Jul 10, 2006
Jul 10, 2006
479
480
fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h,
index + 1);
Apr 26, 2001
Apr 26, 2001
481
482
#endif
Jul 10, 2006
Jul 10, 2006
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
/* Allocate the new list of modes, and fill in the new mode */
next_mode = SDL_nummodes[index];
SDL_modelist[index] = (SDL_Rect **)
SDL_realloc(SDL_modelist[index],
(1 + next_mode + 1) * sizeof(SDL_Rect *));
if (SDL_modelist[index] == NULL) {
SDL_OutOfMemory();
SDL_nummodes[index] = 0;
SDL_free(mode);
return (-1);
}
SDL_modelist[index][next_mode] = mode;
SDL_modelist[index][next_mode + 1] = NULL;
SDL_nummodes[index]++;
return (0);
Apr 26, 2001
Apr 26, 2001
499
500
}
Jul 10, 2006
Jul 10, 2006
501
502
static int
cmpmodes(const void *va, const void *vb)
Jan 2, 2006
Jan 2, 2006
503
{
Jul 10, 2006
Jul 10, 2006
504
505
506
const SDL_Rect *a = *(const SDL_Rect **) va;
const SDL_Rect *b = *(const SDL_Rect **) vb;
if (a->h == b->h)
Jan 2, 2006
Jan 2, 2006
507
508
509
510
511
return b->w - a->w;
else
return b->h - a->h;
}
Jul 10, 2006
Jul 10, 2006
512
513
static void
FB_SortModes(_THIS)
Jan 2, 2006
Jan 2, 2006
514
{
Jul 10, 2006
Jul 10, 2006
515
516
517
518
519
520
521
int i;
for (i = 0; i < NUM_MODELISTS; ++i) {
if (SDL_nummodes[i] > 0) {
SDL_qsort(SDL_modelist[i], SDL_nummodes[i],
sizeof *SDL_modelist[i], cmpmodes);
}
}
Jan 2, 2006
Jan 2, 2006
522
523
}
Jul 10, 2006
Jul 10, 2006
524
525
static int
FB_VideoInit(_THIS, SDL_PixelFormat * vformat)
Apr 26, 2001
Apr 26, 2001
526
{
Feb 15, 2007
Feb 15, 2007
527
const int pagesize = SDL_getpagesize();
Jul 10, 2006
Jul 10, 2006
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
struct fb_fix_screeninfo finfo;
struct fb_var_screeninfo vinfo;
int i, j;
int current_index;
unsigned int current_w;
unsigned int current_h;
const char *SDL_fbdev;
FILE *modesdb;
/* Initialize the library */
SDL_fbdev = SDL_getenv("SDL_FBDEV");
if (SDL_fbdev == NULL) {
SDL_fbdev = "/dev/fb0";
}
console_fd = open(SDL_fbdev, O_RDWR, 0);
if (console_fd < 0) {
SDL_SetError("Unable to open %s", SDL_fbdev);
return (-1);
}
Feb 16, 2006
Feb 16, 2006
547
#if !SDL_THREADS_DISABLED
Jul 10, 2006
Jul 10, 2006
548
549
550
551
552
553
554
/* Create the hardware surface lock mutex */
hw_lock = SDL_CreateMutex();
if (hw_lock == NULL) {
SDL_SetError("Unable to create lock mutex");
FB_VideoQuit(this);
return (-1);
}
Apr 26, 2001
Apr 26, 2001
555
556
#endif
Jul 10, 2006
Jul 10, 2006
557
558
559
560
561
562
563
564
565
566
/* Get the type of video hardware */
if (ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) {
SDL_SetError("Couldn't get console hardware info");
FB_VideoQuit(this);
return (-1);
}
switch (finfo.type) {
case FB_TYPE_PACKED_PIXELS:
/* Supported, no worries.. */
break;
Apr 26, 2001
Apr 26, 2001
567
#ifdef VGA16_FBCON_SUPPORT
Jul 10, 2006
Jul 10, 2006
568
569
570
571
572
573
574
575
576
577
578
579
case FB_TYPE_VGA_PLANES:
/* VGA16 is supported, but that's it */
if (finfo.type_aux == FB_AUX_VGA_PLANES_VGA4) {
if (ioperm(0x3b4, 0x3df - 0x3b4 + 1, 1) < 0) {
SDL_SetError("No I/O port permissions");
FB_VideoQuit(this);
return (-1);
}
this->SetVideoMode = FB_SetVGA16Mode;
break;
}
/* Fall through to unsupported case */
Apr 26, 2001
Apr 26, 2001
580
#endif /* VGA16_FBCON_SUPPORT */
Jul 10, 2006
Jul 10, 2006
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
default:
SDL_SetError("Unsupported console hardware");
FB_VideoQuit(this);
return (-1);
}
switch (finfo.visual) {
case FB_VISUAL_TRUECOLOR:
case FB_VISUAL_PSEUDOCOLOR:
case FB_VISUAL_STATIC_PSEUDOCOLOR:
case FB_VISUAL_DIRECTCOLOR:
break;
default:
SDL_SetError("Unsupported console hardware");
FB_VideoQuit(this);
return (-1);
}
/* Check if the user wants to disable hardware acceleration */
{
const char *fb_accel;
fb_accel = SDL_getenv("SDL_FBACCEL");
if (fb_accel) {
finfo.accel = SDL_atoi(fb_accel);
}
}
/* Memory map the device, compensating for buggy PPC mmap() */
mapped_offset = (((long) finfo.smem_start) -
Feb 15, 2007
Feb 15, 2007
609
(((long) finfo.smem_start) & ~(pagesize - 1)));
Jul 10, 2006
Jul 10, 2006
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
mapped_memlen = finfo.smem_len + mapped_offset;
mapped_mem = do_mmap(NULL, mapped_memlen,
PROT_READ | PROT_WRITE, MAP_SHARED, console_fd, 0);
if (mapped_mem == (char *) -1) {
SDL_SetError("Unable to memory map the video hardware");
mapped_mem = NULL;
FB_VideoQuit(this);
return (-1);
}
/* Determine the current screen depth */
if (ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) {
SDL_SetError("Couldn't get console pixel format");
FB_VideoQuit(this);
return (-1);
}
vformat->BitsPerPixel = vinfo.bits_per_pixel;
if (vformat->BitsPerPixel < 8) {
/* Assuming VGA16, we handle this via a shadow framebuffer */
vformat->BitsPerPixel = 8;
}
for (i = 0; i < vinfo.red.length; ++i) {
vformat->Rmask <<= 1;
vformat->Rmask |= (0x00000001 << vinfo.red.offset);
}
for (i = 0; i < vinfo.green.length; ++i) {
vformat->Gmask <<= 1;
vformat->Gmask |= (0x00000001 << vinfo.green.offset);
}
for (i = 0; i < vinfo.blue.length; ++i) {
vformat->Bmask <<= 1;
vformat->Bmask |= (0x00000001 << vinfo.blue.offset);
}
saved_vinfo = vinfo;
/* Save hardware palette, if needed */
FB_SavePalette(this, &finfo, &vinfo);
/* If the I/O registers are available, memory map them so we
can take advantage of any supported hardware acceleration.
*/
vinfo.accel_flags = 0; /* Temporarily reserve registers */
ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo);
if (finfo.accel && finfo.mmio_len) {
mapped_iolen = finfo.mmio_len;
mapped_io = do_mmap(NULL, mapped_iolen, PROT_READ | PROT_WRITE,
MAP_SHARED, console_fd, mapped_memlen);
if (mapped_io == (char *) -1) {
/* Hmm, failed to memory map I/O registers */
mapped_io = NULL;
}
}
/* Query for the list of available video modes */
current_w = vinfo.xres;
current_h = vinfo.yres;
current_index = ((vinfo.bits_per_pixel + 7) / 8) - 1;
modesdb = fopen(FB_MODES_DB, "r");
for (i = 0; i < NUM_MODELISTS; ++i) {
SDL_nummodes[i] = 0;
SDL_modelist[i] = NULL;
}
if (SDL_getenv("SDL_FB_BROKEN_MODES") != NULL) {
FB_AddMode(this, current_index, current_w, current_h, 0);
} else if (modesdb) {
while (read_fbmodes_mode(modesdb, &vinfo)) {
for (i = 0; i < NUM_MODELISTS; ++i) {
unsigned int w, h;
/* See if we are querying for the current mode */
w = vinfo.xres;
h = vinfo.yres;
if (i == current_index) {
if ((current_w > w) || (current_h > h)) {
/* Only check once */
FB_AddMode(this, i, current_w, current_h, 0);
current_index = -1;
}
}
if (FB_CheckMode(this, &vinfo, i, &w, &h)) {
FB_AddMode(this, i, w, h, 0);
}
}
}
fclose(modesdb);
FB_SortModes(this);
} else {
for (i = 0; i < NUM_MODELISTS; ++i) {
for (j = 0; j < (sizeof(checkres) / sizeof(checkres[0])); ++j) {
unsigned int w, h;
/* See if we are querying for the current mode */
w = checkres[j].w;
h = checkres[j].h;
if (i == current_index) {
if ((current_w > w) || (current_h > h)) {
/* Only check once */
FB_AddMode(this, i, current_w, current_h, 0);
current_index = -1;
}
}
if (FB_CheckMode(this, &vinfo, i, &w, &h)) {
FB_AddMode(this, i, w, h, 1);
}
}
}
}
/* Fill in our hardware acceleration capabilities */
this->info.current_w = current_w;
this->info.current_h = current_h;
this->info.wm_available = 0;
this->info.hw_available = 1;
this->info.video_mem = finfo.smem_len / 1024;
if (mapped_io) {
switch (finfo.accel) {
case FB_ACCEL_MATROX_MGA2064W:
case FB_ACCEL_MATROX_MGA1064SG:
case FB_ACCEL_MATROX_MGA2164W:
case FB_ACCEL_MATROX_MGA2164W_AGP:
case FB_ACCEL_MATROX_MGAG100:
/*case FB_ACCEL_MATROX_MGAG200: G200 acceleration broken! */
case FB_ACCEL_MATROX_MGAG400:
Apr 26, 2001
Apr 26, 2001
733
#ifdef FBACCEL_DEBUG
Jul 10, 2006
Jul 10, 2006
734
printf("Matrox hardware accelerator!\n");
Apr 26, 2001
Apr 26, 2001
735
#endif
Jul 10, 2006
Jul 10, 2006
736
737
738
FB_MatroxAccel(this, finfo.accel);
break;
case FB_ACCEL_3DFX_BANSHEE:
Apr 26, 2001
Apr 26, 2001
739
#ifdef FBACCEL_DEBUG
Jul 10, 2006
Jul 10, 2006
740
printf("3DFX hardware accelerator!\n");
Apr 26, 2001
Apr 26, 2001
741
#endif
Jul 10, 2006
Jul 10, 2006
742
743
744
745
FB_3DfxAccel(this, finfo.accel);
break;
case FB_ACCEL_NV3:
case FB_ACCEL_NV4:
Jul 31, 2001
Jul 31, 2001
746
#ifdef FBACCEL_DEBUG
Jul 10, 2006
Jul 10, 2006
747
printf("NVidia hardware accelerator!\n");
Jul 31, 2001
Jul 31, 2001
748
#endif
Jul 10, 2006
Jul 10, 2006
749
750
751
FB_RivaAccel(this, finfo.accel);
break;
default:
Apr 26, 2001
Apr 26, 2001
752
#ifdef FBACCEL_DEBUG
Jul 10, 2006
Jul 10, 2006
753
printf("Unknown hardware accelerator.\n");
Apr 26, 2001
Apr 26, 2001
754
#endif
Jul 10, 2006
Jul 10, 2006
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
break;
}
}
/* Enable mouse and keyboard support */
if (FB_OpenKeyboard(this) < 0) {
FB_VideoQuit(this);
return (-1);
}
if (FB_OpenMouse(this) < 0) {
const char *sdl_nomouse;
sdl_nomouse = SDL_getenv("SDL_NOMOUSE");
if (!sdl_nomouse) {
SDL_SetError("Unable to open mouse");
FB_VideoQuit(this);
return (-1);
}
}
/* We're done! */
return (0);
Apr 26, 2001
Apr 26, 2001
777
778
}
Jul 10, 2006
Jul 10, 2006
779
780
static SDL_Rect **
FB_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
Apr 26, 2001
Apr 26, 2001
781
{
Jul 10, 2006
Jul 10, 2006
782
return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]);
Apr 26, 2001
Apr 26, 2001
783
784
785
}
/* Various screen update functions available */
Jul 10, 2006
Jul 10, 2006
786
static void FB_DirectUpdate(_THIS, int numrects, SDL_Rect * rects);
Apr 26, 2001
Apr 26, 2001
787
#ifdef VGA16_FBCON_SUPPORT
Jul 10, 2006
Jul 10, 2006
788
static void FB_VGA16Update(_THIS, int numrects, SDL_Rect * rects);
Apr 26, 2001
Apr 26, 2001
789
790
791
#endif
#ifdef FBCON_DEBUG
Jul 10, 2006
Jul 10, 2006
792
793
static void
print_vinfo(struct fb_var_screeninfo *vinfo)
Apr 26, 2001
Apr 26, 2001
794
{
Jul 10, 2006
Jul 10, 2006
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
fprintf(stderr, "Printing vinfo:\n");
fprintf(stderr, "\txres: %d\n", vinfo->xres);
fprintf(stderr, "\tyres: %d\n", vinfo->yres);
fprintf(stderr, "\txres_virtual: %d\n", vinfo->xres_virtual);
fprintf(stderr, "\tyres_virtual: %d\n", vinfo->yres_virtual);
fprintf(stderr, "\txoffset: %d\n", vinfo->xoffset);
fprintf(stderr, "\tyoffset: %d\n", vinfo->yoffset);
fprintf(stderr, "\tbits_per_pixel: %d\n", vinfo->bits_per_pixel);
fprintf(stderr, "\tgrayscale: %d\n", vinfo->grayscale);
fprintf(stderr, "\tnonstd: %d\n", vinfo->nonstd);
fprintf(stderr, "\tactivate: %d\n", vinfo->activate);
fprintf(stderr, "\theight: %d\n", vinfo->height);
fprintf(stderr, "\twidth: %d\n", vinfo->width);
fprintf(stderr, "\taccel_flags: %d\n", vinfo->accel_flags);
fprintf(stderr, "\tpixclock: %d\n", vinfo->pixclock);
fprintf(stderr, "\tleft_margin: %d\n", vinfo->left_margin);
fprintf(stderr, "\tright_margin: %d\n", vinfo->right_margin);
fprintf(stderr, "\tupper_margin: %d\n", vinfo->upper_margin);
fprintf(stderr, "\tlower_margin: %d\n", vinfo->lower_margin);
fprintf(stderr, "\thsync_len: %d\n", vinfo->hsync_len);
fprintf(stderr, "\tvsync_len: %d\n", vinfo->vsync_len);
fprintf(stderr, "\tsync: %d\n", vinfo->sync);
fprintf(stderr, "\tvmode: %d\n", vinfo->vmode);
fprintf(stderr, "\tred: %d/%d\n", vinfo->red.length, vinfo->red.offset);
fprintf(stderr, "\tgreen: %d/%d\n", vinfo->green.length,
vinfo->green.offset);
fprintf(stderr, "\tblue: %d/%d\n", vinfo->blue.length,
vinfo->blue.offset);
fprintf(stderr, "\talpha: %d/%d\n", vinfo->transp.length,
vinfo->transp.offset);
Apr 26, 2001
Apr 26, 2001
825
}
Aug 27, 2008
Aug 27, 2008
826
Jul 10, 2006
Jul 10, 2006
827
828
static void
print_finfo(struct fb_fix_screeninfo *finfo)
Apr 26, 2001
Apr 26, 2001
829
{
Jul 10, 2006
Jul 10, 2006
830
831
832
833
834
835
836
837
838
839
840
841
842
fprintf(stderr, "Printing finfo:\n");
fprintf(stderr, "\tsmem_start = %p\n", (char *) finfo->smem_start);
fprintf(stderr, "\tsmem_len = %d\n", finfo->smem_len);
fprintf(stderr, "\ttype = %d\n", finfo->type);
fprintf(stderr, "\ttype_aux = %d\n", finfo->type_aux);
fprintf(stderr, "\tvisual = %d\n", finfo->visual);
fprintf(stderr, "\txpanstep = %d\n", finfo->xpanstep);
fprintf(stderr, "\typanstep = %d\n", finfo->ypanstep);
fprintf(stderr, "\tywrapstep = %d\n", finfo->ywrapstep);
fprintf(stderr, "\tline_length = %d\n", finfo->line_length);
fprintf(stderr, "\tmmio_start = %p\n", (char *) finfo->mmio_start);
fprintf(stderr, "\tmmio_len = %d\n", finfo->mmio_len);
fprintf(stderr, "\taccel = %d\n", finfo->accel);
Apr 26, 2001
Apr 26, 2001
843
844
845
}
#endif
Jul 10, 2006
Jul 10, 2006
846
847
static int
choose_fbmodes_mode(struct fb_var_screeninfo *vinfo)
Apr 26, 2001
Apr 26, 2001
848
{
Jul 10, 2006
Jul 10, 2006
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
int matched;
FILE *modesdb;
struct fb_var_screeninfo cinfo;
matched = 0;
modesdb = fopen(FB_MODES_DB, "r");
if (modesdb) {
/* Parse the mode definition file */
while (read_fbmodes_mode(modesdb, &cinfo)) {
if ((vinfo->xres == cinfo.xres && vinfo->yres == cinfo.yres)
&& (!matched
|| (vinfo->bits_per_pixel == cinfo.bits_per_pixel))) {
vinfo->pixclock = cinfo.pixclock;
vinfo->left_margin = cinfo.left_margin;
vinfo->right_margin = cinfo.right_margin;
vinfo->upper_margin = cinfo.upper_margin;
vinfo->lower_margin = cinfo.lower_margin;
vinfo->hsync_len = cinfo.hsync_len;
vinfo->vsync_len = cinfo.vsync_len;
if (matched) {
break;
}
matched = 1;
}
}
fclose(modesdb);
}
return (matched);
Apr 26, 2001
Apr 26, 2001
877
878
}
Jul 10, 2006
Jul 10, 2006
879
880
static int
choose_vesa_mode(struct fb_var_screeninfo *vinfo)
Apr 26, 2001
Apr 26, 2001
881
{
Jul 10, 2006
Jul 10, 2006
882
883
884
885
886
887
888
889
int matched;
int i;
/* Check for VESA timings */
matched = 0;
for (i = 0; i < (sizeof(vesa_timings) / sizeof(vesa_timings[0])); ++i) {
if ((vinfo->xres == vesa_timings[i].xres) &&
(vinfo->yres == vesa_timings[i].yres)) {
Apr 26, 2001
Apr 26, 2001
890
#ifdef FBCON_DEBUG
Jul 10, 2006
Jul 10, 2006
891
892
fprintf(stderr, "Using VESA timings for %dx%d\n",
vinfo->xres, vinfo->yres);
Apr 26, 2001
Apr 26, 2001
893
#endif
Jul 10, 2006
Jul 10, 2006
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
if (vesa_timings[i].pixclock) {
vinfo->pixclock = vesa_timings[i].pixclock;
}
vinfo->left_margin = vesa_timings[i].left;
vinfo->right_margin = vesa_timings[i].right;
vinfo->upper_margin = vesa_timings[i].upper;
vinfo->lower_margin = vesa_timings[i].lower;
vinfo->hsync_len = vesa_timings[i].hslen;
vinfo->vsync_len = vesa_timings[i].vslen;
vinfo->sync = vesa_timings[i].sync;
vinfo->vmode = vesa_timings[i].vmode;
matched = 1;
break;
}
}
return (matched);
Apr 26, 2001
Apr 26, 2001
910
911
912
}
#ifdef VGA16_FBCON_SUPPORT
Jul 10, 2006
Jul 10, 2006
913
914
915
static SDL_Surface *
FB_SetVGA16Mode(_THIS, SDL_Surface * current,
int width, int height, int bpp, Uint32 flags)
Apr 26, 2001
Apr 26, 2001
916
{
Jul 10, 2006
Jul 10, 2006
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
struct fb_fix_screeninfo finfo;
struct fb_var_screeninfo vinfo;
/* Set the terminal into graphics mode */
if (FB_EnterGraphicsMode(this) < 0) {
return (NULL);
}
/* Restore the original palette */
FB_RestorePalette(this);
/* Set the video mode and get the final screen format */
if (ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) {
SDL_SetError("Couldn't get console screen info");
return (NULL);
}
cache_vinfo = vinfo;
Apr 26, 2001
Apr 26, 2001
934
#ifdef FBCON_DEBUG
Jul 10, 2006
Jul 10, 2006
935
936
fprintf(stderr, "Printing actual vinfo:\n");
print_vinfo(&vinfo);
Apr 26, 2001
Apr 26, 2001
937
#endif
Jul 10, 2006
Jul 10, 2006
938
939
940
941
942
943
944
945
946
947
948
949
if (!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0)) {
return (NULL);
}
current->format->palette->ncolors = 16;
/* Get the fixed information about the console hardware.
This is necessary since finfo.line_length changes.
*/
if (ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) {
SDL_SetError("Couldn't get console hardware info");
return (NULL);
}
Apr 26, 2001
Apr 26, 2001
950
#ifdef FBCON_DEBUG
Jul 10, 2006
Jul 10, 2006
951
952
fprintf(stderr, "Printing actual finfo:\n");
print_finfo(&finfo);
Apr 26, 2001
Apr 26, 2001
953
954
#endif
Jul 10, 2006
Jul 10, 2006
955
956
/* Save hardware palette, if needed */
FB_SavePalette(this, &finfo, &vinfo);
Apr 26, 2001
Apr 26, 2001
957
Jul 10, 2006
Jul 10, 2006
958
959
960
961
962
963
/* Set up the new mode framebuffer */
current->flags = SDL_FULLSCREEN;
current->w = vinfo.xres;
current->h = vinfo.yres;
current->pitch = current->w;
current->pixels = SDL_malloc(current->h * current->pitch);
Apr 26, 2001
Apr 26, 2001
964
Jul 10, 2006
Jul 10, 2006
965
966
/* Set the update rectangle function */
this->UpdateRects = FB_VGA16Update;
Apr 26, 2001
Apr 26, 2001
967
Jul 10, 2006
Jul 10, 2006
968
969
/* We're done */
return (current);
Apr 26, 2001
Apr 26, 2001
970
971
972
}
#endif /* VGA16_FBCON_SUPPORT */
Jul 10, 2006
Jul 10, 2006
973
974
975
static SDL_Surface *
FB_SetVideoMode(_THIS, SDL_Surface * current,
int width, int height, int bpp, Uint32 flags)
Apr 26, 2001
Apr 26, 2001
976
{
Jul 10, 2006
Jul 10, 2006
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
struct fb_fix_screeninfo finfo;
struct fb_var_screeninfo vinfo;
int i;
Uint32 Rmask;
Uint32 Gmask;
Uint32 Bmask;
char *surfaces_mem;
int surfaces_len;
/* Set the terminal into graphics mode */
if (FB_EnterGraphicsMode(this) < 0) {
return (NULL);
}
/* Restore the original palette */
FB_RestorePalette(this);
/* Set the video mode and get the final screen format */
if (ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) {
SDL_SetError("Couldn't get console screen info");
return (NULL);
}
Apr 26, 2001
Apr 26, 2001
999
#ifdef FBCON_DEBUG
Jul 10, 2006
Jul 10, 2006
1000
fprintf(stderr, "Printing original vinfo:\n");