changeset 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
files src/video/ps3/SDL_ps3modes.c src/video/ps3/SDL_ps3modes_c.h src/video/ps3/SDL_ps3video.c src/video/ps3/SDL_ps3video.h
diffstat 4 files changed, 134 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/ps3/SDL_ps3modes.c	Tue Jul 21 05:33:11 2009 +0000
@@ -0,0 +1,96 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2009 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_ps3video.h"
+
+void
+PS3_InitModes(_THIS)
+{
+    deprintf(1, "+PS3_InitModes()\n");
+    SDL_VideoDisplay display;
+    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
+    SDL_DisplayMode mode;
+    PS3_DisplayModeData *modedata;
+    unsigned long vid = 0;
+
+    modedata = (PS3_DisplayModeData *) SDL_malloc(sizeof(*modedata));
+    if (!displaydata) {
+        return;
+    }
+
+    /* Setting up the DisplayMode */
+    struct ps3fb_ioctl_res res;
+    if (ioctl(data->fbdev, PS3FB_IOCTL_SCREENINFO, &res)) {
+        SDL_SetError("Can't get PS3FB_IOCTL_SCREENINFO");
+    }
+    mode.format = SDL_PIXELFORMAT_RGB888;
+    mode.refresh_rate = 0;
+    mode.w = res.xres;
+    mode.h = res.yres;
+
+    /* Setting up driver specific mode data */
+    if (ioctl(data->fbdev, PS3FB_IOCTL_GETMODE, (unsigned long)&vid)) {
+        SDL_SetError("Can't get PS3FB_IOCTL_GETMODE");
+    }
+    deprintf(2, "PS3FB_IOCTL_GETMODE = %u\n", vid);
+    modedata->mode = vid;
+    mode.driverdata = modedata;
+
+    SDL_zero(display);
+    display.desktop_mode = mode;
+    display.current_mode = mode;
+
+    SDL_AddVideoDisplay(&display);
+    deprintf(1, "-PS3_InitModes()\n");
+}
+
+void
+PS3_GetDisplayModes(_THIS) {
+    deprintf(1, "+PS3_GetDisplayModes()\n");
+    deprintf(1, "-PS3_GetDisplayModes()\n");
+}
+
+static int
+PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
+{
+    deprintf(1, "+PS3_SetDisplayMode()\n");
+    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
+    SDL_DisplayData *dispdata = (SDL_DisplayData *) mode->driverdata;
+
+    /* We don't care about the current DisplayMode for now */
+    if (ioctl(data->fbdev, PS3FB_IOCTL_SETMODE, (unsigned long)&dispdata->mode)) {
+        SDL_SetError("Could not set videomode\n");
+        return -1;
+    }
+
+    deprintf(1, "-PS3_SetDisplayMode()\n");
+    return 0;
+}
+
+void
+PS3_QuitModes(_THIS) {
+    deprintf(1, "+PS3_QuitModes()\n");
+    deprintf(1, "-PS3_QuitModes()\n");
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/ps3/SDL_ps3modes_c.h	Tue Jul 21 05:33:11 2009 +0000
@@ -0,0 +1,34 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2009 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifndef _SDL_ps3modes_h
+#define _SDL_ps3modes_h
+
+extern void PS3_InitModes(_THIS);
+extern void PS3_GetDisplayModes(_THIS);
+extern int PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
+extern void PS3_QuitModes(_THIS);
+
+#endif /* SDL_ps3modes_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/ps3/SDL_ps3video.c	Sun Jul 19 11:31:47 2009 +0000
+++ b/src/video/ps3/SDL_ps3video.c	Tue Jul 21 05:33:11 2009 +0000
@@ -38,6 +38,7 @@
 #include "SDL_ps3spe_c.h"
 #include "SDL_ps3events_c.h"
 #include "SDL_ps3render_c.h"
+#include "SDL_ps3modes_c.h"
 
 #include <fcntl.h>
 #include <linux/fb.h>
@@ -48,9 +49,6 @@
 
 /* Initialization/Query functions */
 static int PS3_VideoInit(_THIS);
-static int PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
-void PS3_InitModes(_THIS);
-void PS3_GetDisplayModes(_THIS);
 static void PS3_VideoQuit(_THIS);
 
 /* Stores the SPE executable name of fb_writer_spu */
@@ -128,7 +126,7 @@
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
     SDL_DisplayMode mode;
 
-#if 1
+#if 0
     /* Use a fake 32-bpp desktop mode */
     mode.format = SDL_PIXELFORMAT_RGB888;
     mode.w = 1920;
@@ -199,7 +197,7 @@
     /* Blank screen */
     memset(data->frame_buffer, 0x00, fb_finfo.smem_len);
 
-#if 0
+#if 1
     PS3_InitModes(_this);
 
     SDL_AddRenderDriver(0, &SDL_PS3_RenderDriver);
@@ -209,78 +207,6 @@
     return 0;
 }
 
-static int
-PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
-{
-    deprintf(1, "PS3_SetDisplayMode()\n");
-    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    SDL_DisplayData *dispdata = (SDL_DisplayData *) mode->driverdata;
-
-    if (ioctl(data->fbdev, PS3FB_IOCTL_SETMODE, (unsigned long)&dispdata->mode)) {
-        SDL_SetError("Could not set videomode");
-        return -1;
-    }
-    return 0;
-}
-
-void PS3_GetDisplayModes(_THIS) {
-    deprintf(1, "PS3_GetDisplayModes()\n");
-}
-
-void
-PS3_InitModes(_THIS)
-{
-    deprintf(1, "PS3_InitModes()\n");
-    SDL_VideoDisplay display;
-    SDL_DisplayMode mode, mode1080p;
-    SDL_DisplayData *displaydata;
-    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-
-    displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
-    if (!displaydata) {
-        return;
-    }
-
-    struct ps3fb_ioctl_res res;
-    if (ioctl(data->fbdev, PS3FB_IOCTL_SCREENINFO, &res)) {
-        SDL_SetError("Can't get PS3FB_IOCTL_SCREENINFO");
-    }
-    mode.format = SDL_PIXELFORMAT_RGB888;
-    mode.refresh_rate = 0;
-    mode.w = res.xres;
-    mode.h = res.yres;
-
-    int vid = 0;
-    if (ioctl(data->fbdev, PS3FB_IOCTL_GETMODE, (unsigned long)&vid)) {
-        SDL_SetError("Can't get PS3FB_IOCTL_GETMODE");
-    }
-    printf("PS3FB_IOCTL_GETMODE = %u\n", vid);
-
-    displaydata->mode = vid;
-    mode.driverdata = displaydata;
-
-    SDL_zero(display);
-    display.desktop_mode = mode;
-    display.current_mode = mode;
-
-    SDL_AddVideoDisplay(&display);
-    SDL_AddDisplayMode(_this->current_display, &mode);
-
-    mode1080p.format = SDL_PIXELFORMAT_RGB888;
-    mode1080p.refresh_rate = 0;
-    mode1080p.w = 1920;
-    mode1080p.h = 1080;
-
-    displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
-    if (!displaydata) {
-        return;
-    }
-
-    displaydata->mode = 133;
-    mode1080p.driverdata = displaydata;
-    SDL_AddDisplayMode(_this->current_display, &mode1080p);
-}
-
 void
 PS3_VideoQuit(_THIS)
 {
--- a/src/video/ps3/SDL_ps3video.h	Sun Jul 19 11:31:47 2009 +0000
+++ b/src/video/ps3/SDL_ps3video.h	Tue Jul 21 05:33:11 2009 +0000
@@ -72,7 +72,7 @@
 {
     unsigned long mode;
     struct ps3fb_ioctl_res res;
-} SDL_DisplayData;
+} PS3_DisplayModeData;
 
 #endif /* _SDL_ps3video_h */