comparison src/video/ps3/SDL_ps3modes.c @ 3152:7f3341cccf42 gsoc2009_ps3

Working 1080p, 720p, 480p videomodes and double buffering.
author Martin Lowinski <martin@goldtopf.org>
date Thu, 06 Aug 2009 12:24:47 +0000
parents 4a88137385f9
children cce01ba54174
comparison
equal deleted inserted replaced
3151:4a88137385f9 3152:7f3341cccf42
32 SDL_DisplayMode mode; 32 SDL_DisplayMode mode;
33 PS3_DisplayModeData *modedata; 33 PS3_DisplayModeData *modedata;
34 unsigned long vid = 0; 34 unsigned long vid = 0;
35 35
36 modedata = (PS3_DisplayModeData *) SDL_malloc(sizeof(*modedata)); 36 modedata = (PS3_DisplayModeData *) SDL_malloc(sizeof(*modedata));
37 if (!displaydata) { 37 if (!modedata) {
38 return; 38 return;
39 } 39 }
40 40
41 /* Setting up the DisplayMode */ 41 /* Setting up the DisplayMode */
42 struct ps3fb_ioctl_res res; 42 struct ps3fb_ioctl_res res;
62 62
63 SDL_AddVideoDisplay(&display); 63 SDL_AddVideoDisplay(&display);
64 deprintf(1, "-PS3_InitModes()\n"); 64 deprintf(1, "-PS3_InitModes()\n");
65 } 65 }
66 66
67 static SDL_DisplayMode ps3fb_modedb[] = {
68 /* VESA */
69 {SDL_PIXELFORMAT_RGB888, 1280, 768, 0, NULL}, // WXGA
70 {SDL_PIXELFORMAT_RGB888, 1280, 1024, 0, NULL}, // SXGA
71 {SDL_PIXELFORMAT_RGB888, 1920, 1200, 0, NULL}, // WUXGA
72 /* Native resolutions (progressive, "fullscreen") */
73 {SDL_PIXELFORMAT_RGB888, 720, 480, 0, NULL}, // 480p
74 {SDL_PIXELFORMAT_RGB888, 1280, 720, 0, NULL}, // 720p
75 {SDL_PIXELFORMAT_RGB888, 1920, 1080, 0, NULL} // 1080p
76 };
77
78 static PS3_DisplayModeData ps3fb_data[] = {
79 {11}, {12}, {13}, {130}, {131}, {133},
80 };
81
67 void 82 void
68 PS3_GetDisplayModes(_THIS) { 83 PS3_GetDisplayModes(_THIS) {
69 deprintf(1, "+PS3_GetDisplayModes()\n"); 84 deprintf(1, "+PS3_GetDisplayModes()\n");
85 SDL_DisplayMode mode;
86 unsigned int nummodes;
87
88 nummodes = sizeof(ps3fb_modedb) / sizeof(SDL_DisplayMode);
89
90 int n;
91 for (n=0; n<nummodes; ++n) {
92 /* Get driver specific mode data */
93 ps3fb_modedb[n].driverdata = &ps3fb_data[n];
94
95 /* Add DisplayMode to list */
96 deprintf(2, "Adding resolution %u x %u\n", ps3fb_modedb[n].w, ps3fb_modedb[n].h);
97 SDL_AddDisplayMode(_this->current_display, &ps3fb_modedb[n]);
98 }
70 deprintf(1, "-PS3_GetDisplayModes()\n"); 99 deprintf(1, "-PS3_GetDisplayModes()\n");
71 } 100 }
72 101
73 static int 102 int
74 PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode) 103 PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
75 { 104 {
76 deprintf(1, "+PS3_SetDisplayMode()\n"); 105 deprintf(1, "+PS3_SetDisplayMode()\n");
77 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 106 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
78 SDL_DisplayData *dispdata = (SDL_DisplayData *) mode->driverdata; 107 PS3_DisplayModeData *dispdata = (PS3_DisplayModeData *) mode->driverdata;
79 108
80 /* We don't care about the current DisplayMode for now */ 109 /* Set the new DisplayMode */
110 deprintf(2, "Setting PS3FB_MODE to %u\n", dispdata->mode);
81 if (ioctl(data->fbdev, PS3FB_IOCTL_SETMODE, (unsigned long)&dispdata->mode)) { 111 if (ioctl(data->fbdev, PS3FB_IOCTL_SETMODE, (unsigned long)&dispdata->mode)) {
82 SDL_SetError("Could not set videomode\n"); 112 deprintf(2, "Could not set PS3FB_MODE\n");
113 SDL_SetError("Could not set PS3FB_MODE\n");
83 return -1; 114 return -1;
84 } 115 }
85 116
86 deprintf(1, "-PS3_SetDisplayMode()\n"); 117 deprintf(1, "-PS3_SetDisplayMode()\n");
87 return 0; 118 return 0;
88 } 119 }
89 120
90 void 121 void
91 PS3_QuitModes(_THIS) { 122 PS3_QuitModes(_THIS) {
92 deprintf(1, "+PS3_QuitModes()\n"); 123 deprintf(1, "+PS3_QuitModes()\n");
124
125 /* There was no mem allocated for driverdata */
126 int i, j;
127 for (i = _this->num_displays; i--;) {
128 SDL_VideoDisplay *display = &_this->displays[i];
129 for (j = display->num_display_modes; j--;) {
130 display->display_modes[j].driverdata = NULL;
131 }
132 }
133
93 deprintf(1, "-PS3_QuitModes()\n"); 134 deprintf(1, "-PS3_QuitModes()\n");
94 } 135 }
95 136
96 /* vi: set ts=4 sw=4 expandtab: */ 137 /* vi: set ts=4 sw=4 expandtab: */