changeset 3157:cce01ba54174 gsoc2009_ps3

Added comments, clean up.
author Martin Lowinski <martin@goldtopf.org>
date Thu, 27 Aug 2009 11:33:56 +0000
parents 4ead4cef6b7b
children 30f3b987fec3
files src/video/ps3/SDL_ps3modes.c src/video/ps3/SDL_ps3render.c src/video/ps3/SDL_ps3spe.c src/video/ps3/SDL_ps3spe_c.h src/video/ps3/SDL_ps3video.c src/video/ps3/spulibs/yuv2rgb.c
diffstat 6 files changed, 37 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/ps3/SDL_ps3modes.c	Fri Aug 14 15:49:44 2009 +0000
+++ b/src/video/ps3/SDL_ps3modes.c	Thu Aug 27 11:33:56 2009 +0000
@@ -38,7 +38,7 @@
         return;
     }
 
-    /* Setting up the DisplayMode */
+    /* Setting up the DisplayMode based on current settings */
     struct ps3fb_ioctl_res res;
     if (ioctl(data->fbdev, PS3FB_IOCTL_SCREENINFO, &res)) {
         SDL_SetError("Can't get PS3FB_IOCTL_SCREENINFO");
@@ -48,7 +48,8 @@
     mode.w = res.xres;
     mode.h = res.yres;
 
-    /* Setting up driver specific mode data */
+    /* Setting up driver specific mode data,
+     * Get the current ps3 specific videmode number */
     if (ioctl(data->fbdev, PS3FB_IOCTL_GETMODE, (unsigned long)&vid)) {
         SDL_SetError("Can't get PS3FB_IOCTL_GETMODE");
     }
@@ -56,6 +57,7 @@
     modedata->mode = vid;
     mode.driverdata = modedata;
 
+    /* Set display's videomode and add it */
     SDL_zero(display);
     display.desktop_mode = mode;
     display.current_mode = mode;
@@ -64,6 +66,7 @@
     deprintf(1, "-PS3_InitModes()\n");
 }
 
+/* DisplayModes available on the PS3 */
 static SDL_DisplayMode ps3fb_modedb[] = {
     /* VESA */
     {SDL_PIXELFORMAT_RGB888, 1280, 768, 0, NULL}, // WXGA
@@ -75,6 +78,7 @@
     {SDL_PIXELFORMAT_RGB888, 1920, 1080, 0, NULL} // 1080p
 };
 
+/* PS3 videomode number according to ps3fb_modedb */
 static PS3_DisplayModeData ps3fb_data[] = {
     {11}, {12}, {13}, {130}, {131}, {133}, 
 };
--- a/src/video/ps3/SDL_ps3render.c	Fri Aug 14 15:49:44 2009 +0000
+++ b/src/video/ps3/SDL_ps3render.c	Thu Aug 27 11:33:56 2009 +0000
@@ -43,7 +43,6 @@
 extern spe_program_handle_t bilin_scaler_spu;
 
 /* SDL surface based renderer implementation */
-
 static SDL_Renderer *SDL_PS3_CreateRenderer(SDL_Window * window,
                                               Uint32 flags);
 static int SDL_PS3_DisplayModeChanged(SDL_Renderer * renderer);
@@ -107,7 +106,8 @@
     /* size of a screen line: width * bpp/8 */
     unsigned int line_length;
 
-    /* Use two buffers in fb? res < 720p */
+    /* Is the kernels fb size bigger than ~12MB
+     * double buffering will work for 1080p */
     unsigned int double_buffering;
 
     /* SPE threading stuff */
@@ -232,7 +232,7 @@
         return NULL;
     }
 
-    /* Set up the SPEs */
+    /* Set up the SPE threading data */
     data->converter_thread_data = (spu_data_t *) malloc(sizeof(spu_data_t));
     data->scaler_thread_data = (spu_data_t *) malloc(sizeof(spu_data_t));
     if (data->converter_thread_data == NULL || data->scaler_thread_data == NULL) {
@@ -377,6 +377,7 @@
         dst = (Uint8 *) dstpixels + rect->y * data->pitch + rect->x
                         * SDL_BYTESPERPIXEL(texture->format);
         length = rect->w * SDL_BYTESPERPIXEL(texture->format);
+        /* Update the texture */
         for (row = 0; row < rect->h; ++row) {
             SDL_memcpy(dst, src, length);
             src += pitch;
@@ -520,18 +521,6 @@
     PS3_TextureData *txdata = (PS3_TextureData *) texture->driverdata;
     SDL_VideoData *devdata = display->device->driverdata;
 
-    /* Debug info */
-    deprintf(1, "srcrect->w = %u\n", srcrect->w);
-    deprintf(1, "srcrect->h = %u\n", srcrect->h);
-    deprintf(1, "srcrect->x = %u\n", srcrect->x);
-    deprintf(1, "srcrect->y = %u\n", srcrect->y);
-    deprintf(1, "dstrect->w = %u\n", dstrect->w);
-    deprintf(1, "dstrect->h = %u\n", dstrect->h);
-    deprintf(1, "dstrect->x = %u\n", dstrect->x);
-    deprintf(1, "dstrect->y = %u\n", dstrect->y);
-    deprintf(1, "texture->w = %u\n", texture->w);
-    deprintf(1, "texture->h = %u\n", texture->h);
-
     if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
         deprintf(1, "Texture is in a FOURCC format\n");
         if ((texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV)
--- a/src/video/ps3/SDL_ps3spe.c	Fri Aug 14 15:49:44 2009 +0000
+++ b/src/video/ps3/SDL_ps3spe.c	Thu Aug 27 11:33:56 2009 +0000
@@ -27,31 +27,6 @@
 #include "SDL_ps3video.h"
 #include "SDL_ps3render_c.h"
 
-
-/* This SPE API basically provides 3 ways to run and control a program
- * on the SPE:
- * - Start and stop the program (keepalive=0).
- *   SPE_Start() will implicitly boot up the program, create a thread and run
- *   the context.
- *   SPE_Stop() will join the (terminated) thread (may block) and return.
- * - Boot the program and run it (keepalive=0).
- *   SPE_Boot() will create a context and load the program and finally start
- *   the context with SPE_Start().
- *   SPE_Stop() will savely end the program.
- * - Boot, Run and send messages to the program (keepalive=1).
- *   Start the program by using one of the methods described above. When
- *   received the READY-message the program is in its infinite loop waiting
- *   for new messages.
- *   Every time you run the program, send SPU_START and the address of the
- *   according struct using SPE_SendMsg().
- *   SPE_WaitForMsg() will than wait for SPU_FIN and is blocking.
- *   SPE_Shutdown() sends SPU_EXIT and finally stops the program.
- *
- * Therefor the SPE program
- * - either runs once and returns
- * - or runs in an infinite loop and is controlled by messages.
- */
-
 /* Start the SPE thread */
 int SPE_Start(spu_data_t * spe_data)
 {
--- a/src/video/ps3/SDL_ps3spe_c.h	Fri Aug 14 15:49:44 2009 +0000
+++ b/src/video/ps3/SDL_ps3spe_c.h	Thu Aug 27 11:33:56 2009 +0000
@@ -19,6 +19,31 @@
     Sam Lantinga
     slouken@libsdl.org
 */
+
+/* This SPE API basically provides 3 ways to run and control a program
+ * on the SPE:
+ * - Start and stop the program (keepalive=0).
+ *   SPE_Start() will implicitly boot up the program, create a thread and run
+ *   the context.
+ *   SPE_Stop() will join the (terminated) thread (may block) and return.
+ * - Boot the program and run it (keepalive=0).
+ *   SPE_Boot() will create a context and load the program and finally start
+ *   the context with SPE_Start().
+ *   SPE_Stop() will savely end the program.
+ * - Boot, Run and send messages to the program (keepalive=1).
+ *   Start the program by using one of the methods described above. When
+ *   received the READY-message the program is in its infinite loop waiting
+ *   for new messages.
+ *   Every time you run the program, send SPU_START and the address of the
+ *   according struct using SPE_SendMsg().
+ *   SPE_WaitForMsg() will than wait for SPU_FIN and is blocking.
+ *   SPE_Shutdown() sends SPU_EXIT and finally stops the program.
+ *
+ * Therefor the SPE program
+ * - either runs once and returns
+ * - or runs in an infinite loop and is controlled by messages.
+ */
+
 #include "SDL_config.h"
 
 #include "spulibs/spu_common.h"
--- a/src/video/ps3/SDL_ps3video.c	Fri Aug 14 15:49:44 2009 +0000
+++ b/src/video/ps3/SDL_ps3video.c	Thu Aug 27 11:33:56 2009 +0000
@@ -129,26 +129,6 @@
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
     SDL_DisplayMode mode;
 
-#if 0
-    /* Use a fake 32-bpp desktop mode */
-    mode.format = SDL_PIXELFORMAT_RGB888;
-    mode.w = 1920;
-    mode.h = 1080;
-    mode.refresh_rate = 0;
-    mode.driverdata = NULL;
-    SDL_AddBasicVideoDisplay(&mode);
-    SDL_AddRenderDriver(0, &SDL_PS3_RenderDriver);
-
-    //SDL_zero(mode);
-    SDL_AddDisplayMode(0, &mode);
-    //display.desktop_mode = mode;
-    //display.current_mode = mode;
-#endif
-
-    /*
-     *PS3 stuff
-     */
-
     /* Create SPU fb_parms and thread structure */
     data->fb_parms = (struct fb_writer_parms_t *)
         memalign(16, sizeof(struct fb_writer_parms_t));
@@ -200,11 +180,8 @@
     /* Blank screen */
     memset(data->frame_buffer, 0x00, fb_finfo.smem_len);
 
-#if 1
     PS3_InitModes(_this);
-
     SDL_AddRenderDriver(0, &SDL_PS3_RenderDriver);
-#endif
 
     /* We're done! */
     return 0;
--- a/src/video/ps3/spulibs/yuv2rgb.c	Fri Aug 14 15:49:44 2009 +0000
+++ b/src/video/ps3/spulibs/yuv2rgb.c	Thu Aug 27 11:33:56 2009 +0000
@@ -31,10 +31,10 @@
 #include <spu_mfcio.h>
 
 // Debugging
-#define DEBUG
+//#define DEBUG
 
 // Test environment for /2 resolutions
-#define TESTING
+//#define TESTING
 
 #ifdef DEBUG
 #define deprintf(fmt, args... ) \