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
63 // broken API needs this
64 static SDL_Rect *omap_modes[] = {
77 if (format->BitsPerPixel <= 8)
78 // not (yet?) supported
84 static SDL_Surface *omap_SetVideoMode(SDL_VideoDevice *this, SDL_Surface *current, int width,
85 int height, int bpp, Uint32 flags)
87 trace("%d, %d, %d, %08x", width, height, bpp, flags);
89 if (osdl_video_set_mode(this->hidden, width, height, bpp) < 0)
92 if (!SDL_ReallocFormat(current, 16, 0xf800, 0x07e0, 0x001f, 0))
95 current->flags = SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE;
98 current->pitch = SDL_CalculatePitch(current);
100 current->pixels = osdl_video_flip(this->hidden);
105 static int omap_LockHWSurface(SDL_VideoDevice *this, SDL_Surface *surface)
107 trace("%p", surface);
112 static void omap_UnlockHWSurface(SDL_VideoDevice *this, SDL_Surface *surface)
114 trace("%p", surface);
117 static int omap_FlipHWSurface(SDL_VideoDevice *this, SDL_Surface *surface)
119 trace("%p", surface);
121 surface->pixels = osdl_video_flip(this->hidden);
126 static int omap_SetColors(SDL_VideoDevice *this, int firstcolor, int ncolors, SDL_Color *colors)
128 trace("%d, %d, %p", firstcolor, ncolors, colors);
132 static void omap_UpdateRects(SDL_VideoDevice *this, int nrects, SDL_Rect *rects)
134 trace("%d, %p", nrects, rects);
136 if (nrects != 1 || rects->x != 0 || rects->y != 0 ||
137 rects->w != this->screen->w || rects->h != this->screen->h) {
138 static int warned = 0;
145 this->screen->pixels = osdl_video_flip(this->hidden);
148 static void omap_InitOSKeymap(SDL_VideoDevice *this)
153 static int key_event_cb(void *cb_arg, int sdl_kc, int is_pressed)
155 SDL_keysym keysym = { 0, };
158 SDL_PrivateKeyboard(is_pressed, &keysym);
161 static int ts_event_cb(void *cb_arg, int x, int y, unsigned int pressure)
163 static int was_pressed;
165 SDL_PrivateMouseMotion(0, 0, x, y);
167 pressure = !!pressure;
168 if (pressure != was_pressed) {
169 SDL_PrivateMouseButton(pressure ? SDL_PRESSED : SDL_RELEASED, 1, 0, 0);
170 was_pressed = pressure;
174 static void omap_PumpEvents(SDL_VideoDevice *this)
178 omapsdl_input_get_events(0, key_event_cb, ts_event_cb, NULL);
181 static SDL_VideoDevice *omap_create(int devindex)
183 SDL_VideoDevice *this;
185 this = calloc(1, sizeof(*this) + sizeof(*this->hidden));
190 this->hidden = (void *)(this + 1);
191 this->VideoInit = omap_VideoInit;
192 this->ListModes = omap_ListModes;
193 this->SetVideoMode = omap_SetVideoMode;
194 this->LockHWSurface = omap_LockHWSurface;
195 this->UnlockHWSurface = omap_UnlockHWSurface;
196 this->FlipHWSurface = omap_FlipHWSurface;
197 this->SetColors = omap_SetColors;
198 this->UpdateRects = omap_UpdateRects;
199 this->VideoQuit = omap_VideoQuit;
200 this->InitOSKeymap = omap_InitOSKeymap;
201 this->PumpEvents = omap_PumpEvents;
202 this->free = omap_free;
207 VideoBootStrap omapdss_bootstrap = {
208 "omapdss", "OMAP DSS2 Framebuffer Driver",
209 omap_available, omap_create