comparison src/video/ps3/SDL_ps3video.c @ 3151:4a88137385f9 gsoc2009_ps3

Moved mode functions to SDL_ps3modes and fixed minor stuff.
author Martin Lowinski <martin@goldtopf.org>
date Tue, 21 Jul 2009 05:33:11 +0000
parents 0cf7bff804ad
children 7f3341cccf42
comparison
equal deleted inserted replaced
3150:0cf7bff804ad 3151:4a88137385f9
36 36
37 #include "SDL_ps3video.h" 37 #include "SDL_ps3video.h"
38 #include "SDL_ps3spe_c.h" 38 #include "SDL_ps3spe_c.h"
39 #include "SDL_ps3events_c.h" 39 #include "SDL_ps3events_c.h"
40 #include "SDL_ps3render_c.h" 40 #include "SDL_ps3render_c.h"
41 #include "SDL_ps3modes_c.h"
41 42
42 #include <fcntl.h> 43 #include <fcntl.h>
43 #include <linux/fb.h> 44 #include <linux/fb.h>
44 #include <asm/ps3fb.h> 45 #include <asm/ps3fb.h>
45 #include <sys/mman.h> 46 #include <sys/mman.h>
46 47
47 #define PS3VID_DRIVER_NAME "ps3" 48 #define PS3VID_DRIVER_NAME "ps3"
48 49
49 /* Initialization/Query functions */ 50 /* Initialization/Query functions */
50 static int PS3_VideoInit(_THIS); 51 static int PS3_VideoInit(_THIS);
51 static int PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
52 void PS3_InitModes(_THIS);
53 void PS3_GetDisplayModes(_THIS);
54 static void PS3_VideoQuit(_THIS); 52 static void PS3_VideoQuit(_THIS);
55 53
56 /* Stores the SPE executable name of fb_writer_spu */ 54 /* Stores the SPE executable name of fb_writer_spu */
57 extern spe_program_handle_t fb_writer_spu; 55 extern spe_program_handle_t fb_writer_spu;
58 56
126 deprintf(1, "PS3_VideoInit()\n"); 124 deprintf(1, "PS3_VideoInit()\n");
127 125
128 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 126 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
129 SDL_DisplayMode mode; 127 SDL_DisplayMode mode;
130 128
131 #if 1 129 #if 0
132 /* Use a fake 32-bpp desktop mode */ 130 /* Use a fake 32-bpp desktop mode */
133 mode.format = SDL_PIXELFORMAT_RGB888; 131 mode.format = SDL_PIXELFORMAT_RGB888;
134 mode.w = 1920; 132 mode.w = 1920;
135 mode.h = 1080; 133 mode.h = 1080;
136 mode.refresh_rate = 0; 134 mode.refresh_rate = 0;
197 } 195 }
198 196
199 /* Blank screen */ 197 /* Blank screen */
200 memset(data->frame_buffer, 0x00, fb_finfo.smem_len); 198 memset(data->frame_buffer, 0x00, fb_finfo.smem_len);
201 199
202 #if 0 200 #if 1
203 PS3_InitModes(_this); 201 PS3_InitModes(_this);
204 202
205 SDL_AddRenderDriver(0, &SDL_PS3_RenderDriver); 203 SDL_AddRenderDriver(0, &SDL_PS3_RenderDriver);
206 #endif 204 #endif
207 205
208 /* We're done! */ 206 /* We're done! */
209 return 0; 207 return 0;
210 }
211
212 static int
213 PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
214 {
215 deprintf(1, "PS3_SetDisplayMode()\n");
216 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
217 SDL_DisplayData *dispdata = (SDL_DisplayData *) mode->driverdata;
218
219 if (ioctl(data->fbdev, PS3FB_IOCTL_SETMODE, (unsigned long)&dispdata->mode)) {
220 SDL_SetError("Could not set videomode");
221 return -1;
222 }
223 return 0;
224 }
225
226 void PS3_GetDisplayModes(_THIS) {
227 deprintf(1, "PS3_GetDisplayModes()\n");
228 }
229
230 void
231 PS3_InitModes(_THIS)
232 {
233 deprintf(1, "PS3_InitModes()\n");
234 SDL_VideoDisplay display;
235 SDL_DisplayMode mode, mode1080p;
236 SDL_DisplayData *displaydata;
237 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
238
239 displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
240 if (!displaydata) {
241 return;
242 }
243
244 struct ps3fb_ioctl_res res;
245 if (ioctl(data->fbdev, PS3FB_IOCTL_SCREENINFO, &res)) {
246 SDL_SetError("Can't get PS3FB_IOCTL_SCREENINFO");
247 }
248 mode.format = SDL_PIXELFORMAT_RGB888;
249 mode.refresh_rate = 0;
250 mode.w = res.xres;
251 mode.h = res.yres;
252
253 int vid = 0;
254 if (ioctl(data->fbdev, PS3FB_IOCTL_GETMODE, (unsigned long)&vid)) {
255 SDL_SetError("Can't get PS3FB_IOCTL_GETMODE");
256 }
257 printf("PS3FB_IOCTL_GETMODE = %u\n", vid);
258
259 displaydata->mode = vid;
260 mode.driverdata = displaydata;
261
262 SDL_zero(display);
263 display.desktop_mode = mode;
264 display.current_mode = mode;
265
266 SDL_AddVideoDisplay(&display);
267 SDL_AddDisplayMode(_this->current_display, &mode);
268
269 mode1080p.format = SDL_PIXELFORMAT_RGB888;
270 mode1080p.refresh_rate = 0;
271 mode1080p.w = 1920;
272 mode1080p.h = 1080;
273
274 displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
275 if (!displaydata) {
276 return;
277 }
278
279 displaydata->mode = 133;
280 mode1080p.driverdata = displaydata;
281 SDL_AddDisplayMode(_this->current_display, &mode1080p);
282 } 208 }
283 209
284 void 210 void
285 PS3_VideoQuit(_THIS) 211 PS3_VideoQuit(_THIS)
286 { 212 {