comparison src/video/ps3/SDL_ps3video.c @ 3145:7828eed2f31a gsoc2009_ps3

Initialise 720p and 1080p display modes in VideoInit(). Added setting display mode.
author Martin Lowinski <martin@goldtopf.org>
date Sat, 13 Jun 2009 05:20:57 +0000
parents 0d8d1f870964
children 9e902f423497
comparison
equal deleted inserted replaced
3144:0d8d1f870964 3145:7828eed2f31a
47 #define PS3VID_DRIVER_NAME "ps3" 47 #define PS3VID_DRIVER_NAME "ps3"
48 48
49 /* Initialization/Query functions */ 49 /* Initialization/Query functions */
50 static int PS3_VideoInit(_THIS); 50 static int PS3_VideoInit(_THIS);
51 static int PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode); 51 static int PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
52 void PS3_InitModes(_THIS);
53 void PS3_GetDisplayModes(_THIS);
52 static void PS3_VideoQuit(_THIS); 54 static void PS3_VideoQuit(_THIS);
53 55
54 /* Stores the SPE executable name of fb_writer_spu */ 56 /* Stores the SPE executable name of fb_writer_spu */
55 extern spe_program_handle_t fb_writer_spu; 57 extern spe_program_handle_t fb_writer_spu;
56 58
102 104
103 /* Set the function pointers */ 105 /* Set the function pointers */
104 device->VideoInit = PS3_VideoInit; 106 device->VideoInit = PS3_VideoInit;
105 device->VideoQuit = PS3_VideoQuit; 107 device->VideoQuit = PS3_VideoQuit;
106 device->SetDisplayMode = PS3_SetDisplayMode; 108 device->SetDisplayMode = PS3_SetDisplayMode;
109 device->GetDisplayModes = PS3_GetDisplayModes;
107 device->PumpEvents = PS3_PumpEvents; 110 device->PumpEvents = PS3_PumpEvents;
108 111
109 device->free = PS3_DeleteDevice; 112 device->free = PS3_DeleteDevice;
110 113
111 return device; 114 return device;
123 deprintf(1, "PS3_VideoInit()\n"); 126 deprintf(1, "PS3_VideoInit()\n");
124 127
125 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 128 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
126 SDL_DisplayMode mode; 129 SDL_DisplayMode mode;
127 130
131 #if 0
128 /* Use a fake 32-bpp desktop mode */ 132 /* Use a fake 32-bpp desktop mode */
129 mode.format = SDL_PIXELFORMAT_RGB888; 133 mode.format = SDL_PIXELFORMAT_RGB888;
130 //mode.w = 1024;
131 //mode.h = 768;
132 mode.w = 1920; 134 mode.w = 1920;
133 mode.h = 1080; 135 mode.h = 1080;
134 mode.refresh_rate = 0; 136 mode.refresh_rate = 0;
135 mode.driverdata = NULL; 137 mode.driverdata = NULL;
136 SDL_AddBasicVideoDisplay(&mode); 138 SDL_AddBasicVideoDisplay(&mode);
137 SDL_AddRenderDriver(0, &SDL_PS3_RenderDriver); 139 SDL_AddRenderDriver(0, &SDL_PS3_RenderDriver);
138 140
139 SDL_zero(mode); 141 //SDL_zero(mode);
140 SDL_AddDisplayMode(0, &mode); 142 SDL_AddDisplayMode(0, &mode);
143 display.desktop_mode = mode;
144 display.current_mode = mode;
145 #endif
141 146
142 /* 147 /*
143 *PS3 stuff 148 *PS3 stuff
144 */ 149 */
145 150
192 } 197 }
193 198
194 /* Blank screen */ 199 /* Blank screen */
195 memset(data->frame_buffer, 0x00, fb_finfo.smem_len); 200 memset(data->frame_buffer, 0x00, fb_finfo.smem_len);
196 201
202 PS3_InitModes(_this);
203
204 SDL_AddRenderDriver(0, &SDL_PS3_RenderDriver);
205
197 /* We're done! */ 206 /* We're done! */
198 return 0; 207 return 0;
199 } 208 }
200 209
201 static int 210 static int
202 PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode) 211 PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
203 { 212 {
204 deprintf(1, "PS3_SetDisplayMode()\n"); 213 deprintf(1, "PS3_SetDisplayMode()\n");
214 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
215 SDL_DisplayData *dispdata = (SDL_DisplayData *) mode->driverdata;
216
217 if (ioctl(data->fbdev, PS3FB_IOCTL_SETMODE, (unsigned long)&dispdata->mode)) {
218 SDL_SetError("Could not set videomode");
219 return -1;
220 }
205 return 0; 221 return 0;
222 }
223
224 void PS3_GetDisplayModes(_THIS) {
225 deprintf(1, "PS3_GetDisplayModes()\n");
226 }
227
228 void
229 PS3_InitModes(_THIS)
230 {
231 deprintf(1, "PS3_InitModes()\n");
232 SDL_VideoDisplay display;
233 SDL_DisplayMode mode, mode1080p;
234 SDL_DisplayData *displaydata;
235 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
236
237 displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
238 if (!displaydata) {
239 return;
240 }
241
242 struct ps3fb_ioctl_res res;
243 if (ioctl(data->fbdev, PS3FB_IOCTL_SCREENINFO, &res)) {
244 SDL_SetError("Can't get PS3FB_IOCTL_SCREENINFO");
245 }
246 mode.format = SDL_PIXELFORMAT_RGB888;
247 mode.refresh_rate = 0;
248 mode.w = res.xres;
249 mode.h = res.yres;
250
251 int vid = 0;
252 if (ioctl(data->fbdev, PS3FB_IOCTL_GETMODE, (unsigned long)&vid)) {
253 SDL_SetError("Can't get PS3FB_IOCTL_GETMODE");
254 }
255 printf("PS3FB_IOCTL_GETMODE = %u\n", vid);
256
257 displaydata->mode = vid;
258 mode.driverdata = displaydata;
259
260 SDL_zero(display);
261 display.desktop_mode = mode;
262 display.current_mode = mode;
263
264 SDL_AddVideoDisplay(&display);
265 SDL_AddDisplayMode(_this->current_display, &mode);
266
267 mode1080p.format = SDL_PIXELFORMAT_RGB888;
268 mode1080p.refresh_rate = 0;
269 mode1080p.w = 1920;
270 mode1080p.h = 1080;
271
272 displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
273 if (!displaydata) {
274 return;
275 }
276
277 displaydata->mode = 133;
278 mode1080p.driverdata = displaydata;
279 SDL_AddDisplayMode(_this->current_display, &mode1080p);
206 } 280 }
207 281
208 void 282 void
209 PS3_VideoQuit(_THIS) 283 PS3_VideoQuit(_THIS)
210 { 284 {