annotate src/video/fbcon-1.3/SDL_fbvideo.c @ 3158:30f3b987fec3 gsoc2009_ps3

created env (fbcon-1.3) and added basic files
author Martin Lowinski <martin@goldtopf.org>
date Sat, 07 Nov 2009 11:35:19 +0000
parents
children 2632b7453516
rev   line source
3158
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
1 /*
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
4
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
9
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
13 Lesser General Public License for more details.
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
14
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
18
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
19 Sam Lantinga
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
20 slouken@libsdl.org
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
21 */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
22
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
23 #include "SDL_config.h"
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
24
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
25 /* SDL fbcon video driver implementation based on dummy, ps3 video driver
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
26 * and sourcecode of the fbcon implementation in sdl-1.2
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
27 *
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
28 * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
29 * of this was cut-and-pasted from Stephane Peter's work in the AAlib
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
30 * SDL video driver. Renamed to "DUMMY" by Sam Lantinga.
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
31 */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
32
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
33 #include "SDL_video.h"
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
34 #include "../SDL_sysvideo.h"
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
35
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
36 #include "SDL_fbvideo.h"
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
37 #include "SDL_fbevents_c.h"
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
38 #include "SDL_fbrender_c.h"
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
39 #include "SDL_fbmodes_c.h"
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
40
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
41 #include <stdio.h>
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
42 #include <fcntl.h>
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
43 #include <unistd.h>
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
44 #include <sys/ioctl.h>
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
45 #include <sys/mman.h>
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
46
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
47 #ifndef HAVE_GETPAGESIZE
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
48 #include <asm/page.h> /* For definition of PAGE_SIZE */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
49 #endif
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
50
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
51 #include <linux/vt.h>
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
52
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
53 #define FBVID_DRIVER_NAME "fbcon"
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
54
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
55 /* Initialization/Query functions */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
56 static int FB_VideoInit(_THIS);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
57 static int FB_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
58 static void FB_VideoQuit(_THIS);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
59
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
60 /* bootstrap functions */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
61 static int
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
62 FB_Available(void)
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
63 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
64 deprintf(1, "+FB_Available()\n");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
65 const char *envr = SDL_getenv("SDL_VIDEODRIVER");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
66 if ((envr) && (SDL_strcmp(envr, FBVID_DRIVER_NAME) == 0)) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
67 return (1);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
68 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
69
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
70 int console = -1;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
71 /* Added check for /fb/0 (devfs) */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
72 /* but - use environment variable first... if it fails, still check defaults */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
73 int idx = 0;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
74 const char *SDL_fbdevs[4] = { NULL, "/dev/fb0", "/dev/fb/0", NULL };
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
75
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
76 SDL_fbdevs[0] = SDL_getenv("SDL_FBDEV");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
77 if (!SDL_fbdevs[0]) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
78 idx++;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
79 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
80 for (; SDL_fbdevs[idx]; idx++) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
81 console = open(SDL_fbdevs[idx], O_RDWR, 0);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
82 if (console >= 0) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
83 close(console);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
84 break;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
85 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
86 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
87 deprintf(1, "-FB_Available()\n");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
88 return (console >= 0);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
89 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
90
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
91 static void
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
92 FB_DeleteDevice(SDL_VideoDevice * device)
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
93 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
94 deprintf(1, "+FB_DeleteDevice()\n");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
95 SDL_free(device->driverdata);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
96 SDL_free(device);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
97 deprintf(1, "-FB_DeleteDevice()\n");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
98 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
99
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
100 static SDL_VideoDevice *
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
101 FB_CreateDevice(int devindex)
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
102 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
103 deprintf(1, "+FB_CreateDevice()\n");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
104 SDL_VideoDevice *device;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
105 SDL_VideoData *data;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
106
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
107 /* Initialize all variables that we clean on shutdown */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
108 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
109 if (!device) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
110 SDL_OutOfMemory();
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
111 if (device) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
112 SDL_free(device);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
113 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
114 return (0);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
115 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
116 data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
117 if (!data) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
118 SDL_OutOfMemory();
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
119 SDL_free(device);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
120 return (0);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
121 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
122 device->driverdata = data;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
123
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
124 /* Set the function pointers */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
125 device->VideoInit = FB_VideoInit;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
126 device->VideoQuit = FB_VideoQuit;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
127 device->SetDisplayMode = FB_SetDisplayMode;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
128 device->PumpEvents = FB_PumpEvents;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
129
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
130 device->free = FB_DeleteDevice;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
131
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
132 deprintf(1, "-FB_CreateDevice()\n");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
133 return device;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
134 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
135
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
136 VideoBootStrap FB_bootstrap = {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
137 FBVID_DRIVER_NAME, "Linux framebuffer video driver",
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
138 FB_Available, FB_CreateDevice
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
139 };
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
140
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
141 int
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
142 FB_VideoInit(_THIS)
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
143 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
144 deprintf(1, "+FB_VideoInit()\n");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
145 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
146 SDL_DisplayMode mode;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
147 struct fb_fix_screeninfo finfo;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
148 const char *SDL_fbdev;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
149
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
150 /* Initialize the library */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
151 SDL_fbdev = SDL_getenv("SDL_FBDEV");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
152 if (SDL_fbdev == NULL) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
153 SDL_fbdev = "/dev/fb0";
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
154 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
155 data->console_fd = open(SDL_fbdev, O_RDWR, 0);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
156 if (data->console_fd < 0) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
157 SDL_SetError("Unable to open %s", SDL_fbdev);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
158 return -1;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
159 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
160 #if !SDL_THREADS_DISABLED
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
161 /* Create the hardware surface lock mutex */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
162 data->hw_lock = SDL_CreateMutex();
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
163 if (data->hw_lock == NULL) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
164 SDL_SetError("Unable to create lock mutex");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
165 FB_VideoQuit(_this);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
166 return -1;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
167 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
168 #endif
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
169
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
170 /* Get the type of video hardware */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
171 if (ioctl(data->console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
172 SDL_SetError("Couldn't get console hardware info");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
173 FB_VideoQuit(_this);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
174 return -1;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
175 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
176
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
177 /* Use a fake 32-bpp desktop mode */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
178 mode.format = SDL_PIXELFORMAT_RGB888;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
179 mode.w = 1024;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
180 mode.h = 768;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
181 mode.refresh_rate = 0;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
182 mode.driverdata = NULL;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
183 SDL_AddBasicVideoDisplay(&mode);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
184 SDL_AddRenderDriver(0, &SDL_FB_RenderDriver);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
185
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
186 SDL_zero(mode);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
187 SDL_AddDisplayMode(0, &mode);
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
188
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
189 /* We're done! */
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
190 deprintf(1, "-FB_VideoInit()\n");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
191 return 0;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
192 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
193
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
194 static int
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
195 FB_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
196 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
197 deprintf(1, "+FB_SetDisplayMode()\n");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
198 deprintf(1, "-FB_SetDisplayMode()\n");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
199 return 0;
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
200 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
201
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
202 void
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
203 FB_VideoQuit(_THIS)
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
204 {
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
205 deprintf(1, "+FB_VideoQuit()\n");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
206 deprintf(1, "-FB_VideoQuit()\n");
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
207 }
30f3b987fec3 created env (fbcon-1.3) and added basic files
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
208