comparison src/video/fbcon/SDL_fbvideo.c @ 1585:980d2a0dc2a3

Date: Tue, 4 Mar 2003 15:05:31 -0800 From: "Jim" Subject: [SDL] Frame Buffer patches... Okay I'm new at patch generation - so please tell me if there's a better way I could have done this. Attached are two patch files generated with 'cvs diff -u' SDL-fb-open-lock.patch applies to SDL_fbvideo.c Modifies the open loop to check /dev/fb/0 found on devfs... Modifies the lock code to return failure if the current virtual terminal is not the one opened for frame buffer writing... Lock would hang forever if switched away (ctrl-alt-F1) ... SDL-fb-mousedrv-screensave.patch applies to SDL_fbevents.c Switches default mouse mode based on SDL_MOUSEDRV - currently only accepts PS2 - otherwise default is MS Mouse. When the screen is switched - exisiting code (wrapped in ifdef SAVE_SCREEN_COTENTS) would save the wrong bit of the screen.... ( I run frame buffer 1600x1200, the size I requested was 800x600 - the save would save the top 800 lines (non biased) and restore them... Adding screen->offset fixed that ) However, if that option is not set, then a call to SDL_UpdateRect (full screen) is made. (which may have had it's contents changed since the screen is not entirely locked because of lock-failure patch) Jim [patches slightly tweaked for SDL 1.2.10]
author Sam Lantinga <slouken@libsdl.org>
date Wed, 22 Mar 2006 07:48:22 +0000
parents 8d9bb0cf2c2a
children 14717b52abc0 7a36f01acf71
comparison
equal deleted inserted replaced
1584:b786d9c15e42 1585:980d2a0dc2a3
28 #include <fcntl.h> 28 #include <fcntl.h>
29 #include <unistd.h> 29 #include <unistd.h>
30 #include <sys/ioctl.h> 30 #include <sys/ioctl.h>
31 #include <sys/mman.h> 31 #include <sys/mman.h>
32 #include <asm/page.h> /* For definition of PAGE_SIZE */ 32 #include <asm/page.h> /* For definition of PAGE_SIZE */
33 #include <linux/vt.h>
33 34
34 #include "SDL_video.h" 35 #include "SDL_video.h"
35 #include "SDL_mouse.h" 36 #include "SDL_mouse.h"
36 #include "../SDL_sysvideo.h" 37 #include "../SDL_sysvideo.h"
37 #include "../SDL_pixels_c.h" 38 #include "../SDL_pixels_c.h"
151 /* FB driver bootstrap functions */ 152 /* FB driver bootstrap functions */
152 153
153 static int FB_Available(void) 154 static int FB_Available(void)
154 { 155 {
155 int console; 156 int console;
156 const char *SDL_fbdev; 157 /* Added check for /fb/0 (devfs) */
157 158 /* but - use environment variable first... if it fails, still check defaults */
158 SDL_fbdev = SDL_getenv("SDL_FBDEV"); 159 int idx = 0;
159 if ( SDL_fbdev == NULL ) { 160 const char *SDL_fbdevs[4] = { NULL, "/dev/fb0", "/dev/fb/0", NULL };
160 SDL_fbdev = "/dev/fb0"; 161
161 } 162 SDL_fbdevs[0] = SDL_getenv("SDL_FBDEV");
162 console = open(SDL_fbdev, O_RDWR, 0); 163 if( !SDL_fbdevs[0] )
163 if ( console >= 0 ) { 164 idx++;
164 close(console); 165 for( ; SDL_fbdevs[idx]; idx++ )
166 {
167 console = open(SDL_fbdevs[idx], O_RDWR, 0);
168 if ( console >= 0 ) {
169 close(console);
170 break;
171 }
165 } 172 }
166 return(console >= 0); 173 return(console >= 0);
167 } 174 }
168 175
169 static void FB_DeleteDevice(SDL_VideoDevice *device) 176 static void FB_DeleteDevice(SDL_VideoDevice *device)
1228 } 1235 }
1229 } 1236 }
1230 surface->pixels = NULL; 1237 surface->pixels = NULL;
1231 surface->hwdata = NULL; 1238 surface->hwdata = NULL;
1232 } 1239 }
1240
1241 /* Routine to check to see if the frame buffer virtual terminal */
1242 /* is the current(active) one. If it is not, result will cause */
1243 /* Lock to fail. (would have waited forever, since the fbevent */
1244 /* keyboard handler maintains a lock when switched away from */
1245 /* current) */
1246 static __inline__ int FB_IsFrameBufferActive(_THIS)
1247 {
1248 struct vt_stat vtstate;
1249 if ( (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) < 0) ||
1250 (current_vt != vtstate.v_active) ) {
1251 return 0;
1252 }
1253 return 1;
1254 }
1255
1256
1233 static int FB_LockHWSurface(_THIS, SDL_Surface *surface) 1257 static int FB_LockHWSurface(_THIS, SDL_Surface *surface)
1234 { 1258 {
1259 if ( !FB_IsFrameBufferActive(this) ) {
1260 return -1; /* fail locking. */
1261 }
1235 if ( surface == this->screen ) { 1262 if ( surface == this->screen ) {
1236 SDL_mutexP(hw_lock); 1263 SDL_mutexP(hw_lock);
1237 if ( FB_IsSurfaceBusy(surface) ) { 1264 if ( FB_IsSurfaceBusy(surface) ) {
1238 FB_WaitBusySurfaces(this); 1265 FB_WaitBusySurfaces(this);
1239 } 1266 }