2 * (C) GraÅžvydas "notaz" Ignotas, 2010
4 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
5 * See the COPYING file in the top-level directory.
10 #include "../SDL_sysvideo.h"
11 #include "../SDL_pixels_c.h"
12 #include "../../events/SDL_events_c.h"
16 static int omap_available(void)
22 static void omap_free(SDL_VideoDevice *device)
28 static int omap_VideoInit(SDL_VideoDevice *this, SDL_PixelFormat *vformat)
33 vformat->BitsPerPixel = 16;
41 static void omap_VideoQuit(SDL_VideoDevice *this)
45 osdl_video_finish(this->hidden);
46 this->screen->pixels = NULL;
47 omapsdl_input_finish();
50 static SDL_Rect **omap_ListModes(SDL_VideoDevice *this, SDL_PixelFormat *format, Uint32 flags)
52 static SDL_Rect omap_mode_list[] = {
53 // XXX: we are not really restricted to fixed modes
54 // FIXME: should really check the display for max supported
72 // broken API needs this
73 static SDL_Rect *omap_modes[] = {
86 if (format->BitsPerPixel <= 8)
87 // not (yet?) supported
93 static SDL_Surface *omap_SetVideoMode(SDL_VideoDevice *this, SDL_Surface *current, int width,
94 int height, int bpp, Uint32 flags)
96 trace("%d, %d, %d, %08x", width, height, bpp, flags);
98 if (osdl_video_set_mode(this->hidden, width, height, bpp) < 0)
101 if (!SDL_ReallocFormat(current, 16, 0xf800, 0x07e0, 0x001f, 0))
104 current->flags = SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE;
107 current->pitch = SDL_CalculatePitch(current);
109 current->pixels = osdl_video_flip(this->hidden);
114 static int omap_LockHWSurface(SDL_VideoDevice *this, SDL_Surface *surface)
116 trace("%p", surface);
121 static void omap_UnlockHWSurface(SDL_VideoDevice *this, SDL_Surface *surface)
123 trace("%p", surface);
126 static int omap_FlipHWSurface(SDL_VideoDevice *this, SDL_Surface *surface)
128 trace("%p", surface);
130 surface->pixels = osdl_video_flip(this->hidden);
135 /* we can't do hw surfaces (besides screen one) yet */
136 static int omap_AllocHWSurface(SDL_VideoDevice *this, SDL_Surface *surface)
138 trace("%p", surface);
142 static void omap_FreeHWSurface(SDL_VideoDevice *this, SDL_Surface *surface)
144 trace("%p", surface);
147 static int omap_SetColors(SDL_VideoDevice *this, int firstcolor, int ncolors, SDL_Color *colors)
149 trace("%d, %d, %p", firstcolor, ncolors, colors);
153 static void omap_UpdateRects(SDL_VideoDevice *this, int nrects, SDL_Rect *rects)
155 trace("%d, %p", nrects, rects);
157 if (nrects != 1 || rects->x != 0 || rects->y != 0 ||
158 rects->w != this->screen->w || rects->h != this->screen->h) {
159 static int warned = 0;
166 this->screen->pixels = osdl_video_flip(this->hidden);
169 static void omap_InitOSKeymap(SDL_VideoDevice *this)
174 static int key_event_cb(void *cb_arg, int sdl_kc, int is_pressed)
176 SDL_keysym keysym = { 0, };
179 SDL_PrivateKeyboard(is_pressed, &keysym);
182 static int ts_event_cb(void *cb_arg, int x, int y, unsigned int pressure)
184 static int was_pressed;
186 SDL_PrivateMouseMotion(0, 0, x, y);
188 pressure = !!pressure;
189 if (pressure != was_pressed) {
190 SDL_PrivateMouseButton(pressure ? SDL_PRESSED : SDL_RELEASED, 1, 0, 0);
191 was_pressed = pressure;
195 static void omap_PumpEvents(SDL_VideoDevice *this)
199 omapsdl_input_get_events(0, key_event_cb, ts_event_cb, NULL);
202 static SDL_VideoDevice *omap_create(int devindex)
204 SDL_VideoDevice *this;
206 this = calloc(1, sizeof(*this) + sizeof(*this->hidden));
211 this->hidden = (void *)(this + 1);
212 this->VideoInit = omap_VideoInit;
213 this->ListModes = omap_ListModes;
214 this->SetVideoMode = omap_SetVideoMode;
215 this->LockHWSurface = omap_LockHWSurface;
216 this->UnlockHWSurface = omap_UnlockHWSurface;
217 this->FlipHWSurface = omap_FlipHWSurface;
218 this->AllocHWSurface = omap_AllocHWSurface;
219 this->FreeHWSurface = omap_FreeHWSurface;
220 this->SetColors = omap_SetColors;
221 this->UpdateRects = omap_UpdateRects;
222 this->VideoQuit = omap_VideoQuit;
223 this->InitOSKeymap = omap_InitOSKeymap;
224 this->PumpEvents = omap_PumpEvents;
225 this->free = omap_free;
230 VideoBootStrap omapdss_bootstrap = {
231 "omapdss", "OMAP DSS2 Framebuffer Driver",
232 omap_available, omap_create