Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2ea07f1

Browse files
committedApr 2, 2009
Hello.
This patch provides basic support for video on the Sony PS3 Linux framebuffer. Scaling, format-conversion, and drawing is done from the SPEs, so there is little performance impact to PPE applications. This is by no means production quality code, but it is a very good start and a good example of how to use the PS3's hardware capabilities to accelerate video playback on the box. The driver has been verified to work with ffplay, mplayer and xine. This piece of software has been developed at the IBM R&D Lab in Boeblingen, Germany and is now returned to the community. Enjoy ! Signed-off-by: D.Herrendoerfer < d.herrendoerfer [at] de [dot] ibm [dot] com >
1 parent 12c22be commit 2ea07f1

16 files changed

+4382
-0
lines changed
 

‎README.PS3

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
SDL on Sony Playstation3
3+
------------------------
4+
5+
Installation:
6+
First, you have to install the Cell SDK
7+
- Download the Cell SDK installer RPM and ISO images to
8+
a temporary directory such as /tmp/cellsdk.
9+
- Mount the image: mount -o loop CellSDK-Devel-Fedora_3.1.0.0.0.iso /tmp/cellsdk
10+
- Install the SDK installer: rpm -ivh cell-install-3.1.0-0.0.noarch.rpm
11+
- Install the SDK: cd /opt/cell && ./cellsdk --iso /tmp/cellsdkiso install
12+
13+
You need to install the SPU-libs before installing SDL
14+
- Go to SDL-1.2/src/video/ps3/spulibs/
15+
- Run make && make install
16+
17+
Finally, install SDL
18+
- Go to SDL-1.2/ and build SDL like any other GNU style package.
19+
e.g.
20+
- Build the configure-script with ./autogen.sh
21+
- Configure SDL for your needs: ./configure --enable-video-ps3 ...
22+
- Build and install it: make && make install
23+
24+
25+
Todo:
26+
- mouse/keyboard/controller support
27+
28+
Have fun!
29+
Dirk Herrendoerfer <d.herrendoerfer [at] de [dot ibm [dot] com>

‎configure.in

+28
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,33 @@ AC_HELP_STRING([--enable-video-ps2gs], [use PlayStation 2 GS video driver [[defa
12871287
fi
12881288
}
12891289

1290+
dnl See if we're running on PlayStation 3 Cell hardware
1291+
CheckPS3()
1292+
{
1293+
AC_ARG_ENABLE(video-ps3,
1294+
AC_HELP_STRING([--enable-video-ps3], [use PlayStation 3 Cell driver [[default=yes]]]),
1295+
, enable_video_ps3=yes)
1296+
if test x$enable_video = xyes -a x$enable_video_ps3 = xyes; then
1297+
AC_MSG_CHECKING(for PlayStation 3 Cell support)
1298+
video_ps3=no
1299+
AC_TRY_COMPILE([
1300+
#include <linux/fb.h>
1301+
#include <asm/ps3fb.h>
1302+
],[
1303+
],[
1304+
video_ps3=yes
1305+
])
1306+
AC_MSG_RESULT($video_ps3)
1307+
if test x$video_ps3 = xyes; then
1308+
AC_DEFINE(SDL_VIDEO_DRIVER_PS3)
1309+
SOURCES="$SOURCES $srcdir/src/video/ps3/*.c"
1310+
EXTRA_CFLAGS="$EXTRA_CFLAGS -I/opt/cell/sdk/usr/include"
1311+
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lbilin_scaler_spu -lfb_writer_spu -lyuv2rgb_spu -L/opt/cell/sdk/usr/lib -lspe2"
1312+
have_video=yes
1313+
fi
1314+
fi
1315+
}
1316+
12901317
dnl Find the GGI includes
12911318
CheckGGI()
12921319
{
@@ -2251,6 +2278,7 @@ case "$host" in
22512278
CheckFBCON
22522279
CheckDirectFB
22532280
CheckPS2GS
2281+
CheckPS3
22542282
CheckGGI
22552283
CheckSVGA
22562284
CheckVGL

‎include/SDL_config.h.in

+1
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@
269269
#undef SDL_VIDEO_DRIVER_PHOTON
270270
#undef SDL_VIDEO_DRIVER_PICOGUI
271271
#undef SDL_VIDEO_DRIVER_PS2GS
272+
#undef SDL_VIDEO_DRIVER_PS3
272273
#undef SDL_VIDEO_DRIVER_QTOPIA
273274
#undef SDL_VIDEO_DRIVER_QUARTZ
274275
#undef SDL_VIDEO_DRIVER_RISCOS

‎src/video/SDL_sysvideo.h

+3
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ extern VideoBootStrap DirectFB_bootstrap;
347347
#if SDL_VIDEO_DRIVER_PS2GS
348348
extern VideoBootStrap PS2GS_bootstrap;
349349
#endif
350+
#if SDL_VIDEO_DRIVER_PS3
351+
extern VideoBootStrap PS3_bootstrap;
352+
#endif
350353
#if SDL_VIDEO_DRIVER_GGI
351354
extern VideoBootStrap GGI_bootstrap;
352355
#endif

‎src/video/SDL_video.c

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ static VideoBootStrap *bootstrap[] = {
6363
#if SDL_VIDEO_DRIVER_PS2GS
6464
&PS2GS_bootstrap,
6565
#endif
66+
#if SDL_VIDEO_DRIVER_PS3
67+
&PS3_bootstrap,
68+
#endif
6669
#if SDL_VIDEO_DRIVER_GGI
6770
&GGI_bootstrap,
6871
#endif

‎src/video/ps3/SDL_ps3events.c

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* SDL - Simple DirectMedia Layer
3+
* CELL BE Support for PS3 Framebuffer
4+
* Copyright (C) 2008, 2009 International Business Machines Corporation
5+
*
6+
* This library is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as published
8+
* by the Free Software Foundation; either version 2.1 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This library is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this library; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19+
* USA
20+
*
21+
* Martin Lowinski <lowinski [at] de [dot] ibm [ibm] com>
22+
* Dirk Herrendoerfer <d.herrendoerfer [at] de [dot] ibm [dot] com>
23+
* SPE code based on research by:
24+
* Rene Becker
25+
* Thimo Emmerich
26+
*/
27+
28+
#include "SDL_config.h"
29+
30+
#include "../../events/SDL_sysevents.h"
31+
#include "../../events/SDL_events_c.h"
32+
#include "SDL_ps3video.h"
33+
#include "SDL_ps3events_c.h"
34+
35+
void PS3_PumpEvents(_THIS)
36+
{
37+
return;
38+
}
39+
40+
void PS3_InitOSKeymap(_THIS)
41+
{
42+
return;
43+
}
44+

‎src/video/ps3/SDL_ps3events_c.h

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* SDL - Simple DirectMedia Layer
3+
* CELL BE Support for PS3 Framebuffer
4+
* Copyright (C) 2008, 2009 International Business Machines Corporation
5+
*
6+
* This library is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as published
8+
* by the Free Software Foundation; either version 2.1 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This library is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this library; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19+
* USA
20+
*
21+
* Martin Lowinski <lowinski [at] de [dot] ibm [ibm] com>
22+
* Dirk Herrendoerfer <d.herrendoerfer [at] de [dot] ibm [dot] com>
23+
* SPE code based on research by:
24+
* Rene Becker
25+
* Thimo Emmerich
26+
*/
27+
28+
#include "SDL_config.h"
29+
30+
#ifndef _SDL_ps3events_h
31+
#define _SDL_ps3events_h
32+
33+
#include "SDL_ps3video.h"
34+
35+
extern void PS3_InitOSKeymap(_THIS);
36+
extern void PS3_PumpEvents(_THIS);
37+
38+
extern void enable_cursor(int enable);
39+
40+
#endif /* _SDL_ps3events_h */
41+

‎src/video/ps3/SDL_ps3video.c

+621
Large diffs are not rendered by default.

‎src/video/ps3/SDL_ps3video.h

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
/*
2+
* SDL - Simple DirectMedia Layer
3+
* CELL BE Support for PS3 Framebuffer
4+
* Copyright (C) 2008, 2009 International Business Machines Corporation
5+
*
6+
* This library is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as published
8+
* by the Free Software Foundation; either version 2.1 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This library is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this library; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19+
* USA
20+
*
21+
* Martin Lowinski <lowinski [at] de [dot] ibm [ibm] com>
22+
* Dirk Herrendoerfer <d.herrendoerfer [at] de [dot] ibm [dot] com>
23+
* SPE code based on research by:
24+
* Rene Becker
25+
* Thimo Emmerich
26+
*/
27+
28+
#include "SDL_config.h"
29+
#include "../SDL_sysvideo.h"
30+
#include "SDL_mouse.h"
31+
#include "SDL_mutex.h"
32+
#include "spulibs/spu_common.h"
33+
34+
#include <libspe2.h>
35+
#include <pthread.h>
36+
#include <linux/types.h>
37+
#include <linux/fb.h>
38+
#include <asm/ps3fb.h>
39+
#include <linux/vt.h>
40+
#include <termios.h>
41+
42+
#ifndef _SDL_ps3video_h
43+
#define _SDL_ps3video_h
44+
45+
/* Debugging
46+
* 0: No debug messages
47+
* 1: Video debug messages
48+
* 2: SPE debug messages
49+
* 3: Memory adresses
50+
*/
51+
#define DEBUG_LEVEL 0
52+
53+
#ifdef DEBUG_LEVEL
54+
#define deprintf( level, fmt, args... ) \
55+
do \
56+
{ \
57+
if ( (unsigned)(level) <= DEBUG_LEVEL ) \
58+
{ \
59+
fprintf( stdout, fmt, ##args ); \
60+
fflush( stdout ); \
61+
} \
62+
} while ( 0 )
63+
#else
64+
#define deprintf( level, fmt, args... )
65+
#endif
66+
67+
/* Framebuffer device */
68+
#define PS3_DEV_FB "/dev/fb0"
69+
70+
/* Hidden "this" pointer for the video functions */
71+
#define _THIS SDL_VideoDevice * this
72+
73+
/* SPU thread data */
74+
typedef struct spu_data {
75+
spe_context_ptr_t ctx;
76+
pthread_t thread;
77+
spe_program_handle_t program;
78+
char * program_name;
79+
unsigned int booted;
80+
unsigned int keepalive;
81+
unsigned int entry;
82+
int error_code;
83+
void * argp;
84+
} spu_data_t;
85+
86+
/* Private video driver data needed for Cell support */
87+
struct SDL_PrivateVideoData
88+
{
89+
const char * const fb_dev_name; /* FB-device name */
90+
int fb_dev_fd; /* Descriptor-handle for fb_dev_name */
91+
uint8_t * frame_buffer; /* mmap'd access to fbdev */
92+
93+
/* SPE threading stuff */
94+
spu_data_t * fb_thread_data;
95+
spu_data_t * scaler_thread_data;
96+
spu_data_t * converter_thread_data;
97+
98+
/* screeninfo (from linux/fb.h) */
99+
struct fb_fix_screeninfo fb_finfo;
100+
struct fb_var_screeninfo fb_vinfo;
101+
struct fb_var_screeninfo fb_orig_vinfo;
102+
103+
/* screeninfo (from asm/ps3fb.h) */
104+
struct ps3fb_ioctl_res res;
105+
106+
unsigned int double_buffering;
107+
uint32_t real_width; // real width of screen
108+
uint32_t real_height; // real height of screen
109+
110+
uint32_t s_fb_pixel_size; // 32: 4 24: 3 16: 2 15: 2
111+
uint32_t fb_bits_per_pixel; // 32: 32 24: 24 16: 16 15: 15
112+
113+
uint32_t config_count;
114+
115+
uint32_t s_input_line_length; // precalculated: input_width * fb_pixel_size
116+
uint32_t s_bounded_input_width; // width of input (bounded by writeable width)
117+
uint32_t s_bounded_input_height;// height of input (bounded by writeable height)
118+
uint32_t s_bounded_input_width_offset; // offset from the left side (used for centering)
119+
uint32_t s_bounded_input_height_offset; // offset from the upper side (used for centering)
120+
uint32_t s_writeable_width; // width of screen which is writeable
121+
uint32_t s_writeable_height; // height of screen which is writeable
122+
123+
uint8_t * s_center[2]; // where to begin writing our image (centered?)
124+
uint32_t s_center_index;
125+
126+
volatile void * s_pixels __attribute__((aligned(128)));
127+
128+
/* Framebuffer data */
129+
volatile struct fb_writer_parms_t * fb_parms __attribute__((aligned(128)));
130+
};
131+
132+
#define fb_dev_name (this->hidden->fb_dev_name)
133+
#define fb_dev_fd (this->hidden->fb_dev_fd)
134+
#define frame_buffer (this->hidden->frame_buffer)
135+
#define fb_thread_data (this->hidden->fb_thread_data)
136+
#define scaler_thread_data (this->hidden->scaler_thread_data)
137+
#define converter_thread_data (this->hidden->converter_thread_data)
138+
#define fb_parms (this->hidden->fb_parms)
139+
#define SDL_nummodes (this->hidden->SDL_nummodes)
140+
#define SDL_modelist (this->hidden->SDL_modelist)
141+
#define SDL_videomode (this->hidden->SDL_videomode)
142+
#define fb_finfo (this->hidden->fb_finfo)
143+
#define fb_vinfo (this->hidden->fb_vinfo)
144+
#define fb_orig_vinfo (this->hidden->fb_orig_vinfo)
145+
#define res (this->hidden->res)
146+
#define double_buffering (this->hidden->double_buffering)
147+
#define real_width (this->hidden->real_width)
148+
#define real_height (this->hidden->real_height)
149+
#define s_fb_pixel_size (this->hidden->s_fb_pixel_size)
150+
#define fb_bits_per_pixel (this->hidden->fb_bits_per_pixel)
151+
#define config_count (this->hidden->config_count)
152+
#define s_input_line_length (this->hidden->s_input_line_length)
153+
#define s_bounded_input_width (this->hidden->s_bounded_input_width)
154+
#define s_bounded_input_height (this->hidden->s_bounded_input_height)
155+
#define s_bounded_input_width_offset (this->hidden->s_bounded_input_width_offset)
156+
#define s_bounded_input_height_offset (this->hidden->s_bounded_input_height_offset)
157+
#define s_writeable_width (this->hidden->s_writeable_width)
158+
#define s_writeable_height (this->hidden->s_writeable_height)
159+
#define s_center (this->hidden->s_center)
160+
#define s_center_index (this->hidden->s_center_index)
161+
#define s_pixels (this->hidden->s_pixels)
162+
163+
#endif /* _SDL_ps3video_h */
164+
165+

‎src/video/ps3/SDL_ps3yuv.c

+340
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,340 @@
1+
/*
2+
* SDL - Simple DirectMedia Layer
3+
* CELL BE Support for PS3 Framebuffer
4+
* Copyright (C) 2008, 2009 International Business Machines Corporation
5+
*
6+
* This library is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as published
8+
* by the Free Software Foundation; either version 2.1 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This library is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this library; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19+
* USA
20+
*
21+
* Martin Lowinski <lowinski [at] de [dot] ibm [ibm] com>
22+
* Dirk Herrendoerfer <d.herrendoerfer [at] de [dot] ibm [dot] com>
23+
* SPE code based on research by:
24+
* Rene Becker
25+
* Thimo Emmerich
26+
*/
27+
28+
#include "SDL_config.h"
29+
30+
#include "SDL_video.h"
31+
#include "SDL_ps3video.h"
32+
#include "SDL_ps3yuv_c.h"
33+
#include "../SDL_yuvfuncs.h"
34+
#include "spulibs/spu_common.h"
35+
36+
/* Stores the executable name */
37+
extern spe_program_handle_t yuv2rgb_spu;
38+
extern spe_program_handle_t bilin_scaler_spu;
39+
40+
int SPE_Start(_THIS, spu_data_t * spe_data);
41+
int SPE_Stop(_THIS, spu_data_t * spe_data);
42+
int SPE_Boot(_THIS, spu_data_t * spe_data);
43+
int SPE_Shutdown(_THIS, spu_data_t * spe_data);
44+
int SPE_SendMsg(_THIS, spu_data_t * spe_data, unsigned int msg);
45+
int SPE_WaitForMsg(_THIS, spu_data_t * spe_data, unsigned int msg);
46+
void SPE_RunContext(void *thread_argp);
47+
48+
49+
/* The functions used to manipulate software video overlays */
50+
static struct private_yuvhwfuncs ps3_yuvfuncs = {
51+
PS3_LockYUVOverlay,
52+
PS3_UnlockYUVOverlay,
53+
PS3_DisplayYUVOverlay,
54+
PS3_FreeYUVOverlay
55+
};
56+
57+
58+
struct private_yuvhwdata {
59+
SDL_Surface *display;
60+
SDL_Surface *stretch;
61+
volatile void * pixels __attribute__((aligned(128)));
62+
63+
/* These are just so we don't have to allocate them separately */
64+
Uint16 pitches[3];
65+
Uint8 * planes[3];
66+
67+
unsigned int scale;
68+
69+
/* Scaled YUV picture */
70+
Uint8 * scaler_out __attribute__((aligned(128)));
71+
72+
/* YUV2RGB converter data */
73+
volatile struct yuv2rgb_parms_t * converter_parms __attribute__((aligned(128)));
74+
75+
/* Scaler data */
76+
volatile struct scale_parms_t * scaler_parms __attribute__((aligned(128)));
77+
78+
Uint8 locked;
79+
};
80+
81+
82+
SDL_Overlay *PS3_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display) {
83+
/* Only RGB packed pixel conversion supported */
84+
if ((display->format->BytesPerPixel != 2) &&
85+
(display->format->BytesPerPixel != 3) &&
86+
(display->format->BytesPerPixel != 4))
87+
{
88+
SDL_SetError ("Can't use YUV data on non 16/24/32 bit surfaces");
89+
return NULL;
90+
}
91+
92+
/* Double-check the requested format. We'll only support YV12 */
93+
switch (format) {
94+
case SDL_IYUV_OVERLAY:
95+
case SDL_YV12_OVERLAY:
96+
/* Supported YUV format */
97+
break;
98+
default:
99+
SDL_SetError("Unsupported YUV format");
100+
return NULL;
101+
}
102+
103+
SDL_Overlay* overlay;
104+
struct private_yuvhwdata* hwdata;
105+
106+
/* Create the overlay structure */
107+
overlay = (SDL_Overlay *) SDL_calloc(1, sizeof(SDL_Overlay));
108+
if (overlay == NULL) {
109+
SDL_OutOfMemory();
110+
return NULL;
111+
}
112+
SDL_memset(overlay, 0, (sizeof *overlay));
113+
114+
/* Set the basic attributes */
115+
overlay->format = format;
116+
overlay->w = width;
117+
overlay->h = height;
118+
overlay->hwdata = NULL;
119+
120+
/* Set up the PS3 YUV surface function structure */
121+
overlay->hwfuncs = &ps3_yuvfuncs;
122+
123+
/* Create the pixel data and lookup tables */
124+
hwdata = (struct private_yuvhwdata *) SDL_calloc(1, sizeof(struct private_yuvhwdata));
125+
if (hwdata == NULL) {
126+
SDL_OutOfMemory();
127+
SDL_FreeYUVOverlay(overlay);
128+
return NULL;
129+
}
130+
overlay->hwdata = hwdata;
131+
132+
hwdata->stretch = NULL;
133+
hwdata->display = display;
134+
135+
/* Create SPU parms structure */
136+
hwdata->converter_parms = (struct yuv2rgb_parms_t *) memalign(16, sizeof(struct yuv2rgb_parms_t));
137+
hwdata->scaler_parms = (struct scale_parms_t *) memalign(16, sizeof(struct scale_parms_t));
138+
if (hwdata->converter_parms == NULL || hwdata->scaler_parms == NULL) {
139+
SDL_FreeYUVOverlay(overlay);
140+
SDL_OutOfMemory();
141+
return(NULL);
142+
}
143+
144+
/* Set up the SPEs */
145+
scaler_thread_data = (spu_data_t *) malloc(sizeof(spu_data_t));
146+
converter_thread_data = (spu_data_t *) malloc(sizeof(spu_data_t));
147+
if (converter_thread_data == NULL || scaler_thread_data == NULL) {
148+
SDL_FreeYUVOverlay(overlay);
149+
SDL_OutOfMemory();
150+
return(NULL);
151+
}
152+
153+
scaler_thread_data->program = bilin_scaler_spu;
154+
scaler_thread_data->program_name = "bilin_scaler_spu";
155+
scaler_thread_data->keepalive = 0;
156+
scaler_thread_data->booted = 0;
157+
158+
converter_thread_data->program = yuv2rgb_spu;
159+
converter_thread_data->program_name = "yuv2rgb_spu";
160+
converter_thread_data->keepalive = 1;
161+
converter_thread_data->booted = 0;
162+
163+
SPE_Start(this, converter_thread_data);
164+
165+
hwdata->pixels = (Uint8 *) memalign(16, width * height + ((width * height) >> 1));
166+
if (hwdata->pixels == NULL) {
167+
SDL_FreeYUVOverlay(overlay);
168+
SDL_OutOfMemory();
169+
return(NULL);
170+
}
171+
172+
/* Find the pitch and offset values for the overlay */
173+
overlay->pitches = hwdata->pitches;
174+
overlay->pixels = hwdata->planes;
175+
switch (format) {
176+
case SDL_YV12_OVERLAY:
177+
case SDL_IYUV_OVERLAY:
178+
overlay->pitches[0] = overlay->w;
179+
overlay->pitches[1] = overlay->pitches[0] / 2;
180+
overlay->pitches[2] = overlay->pitches[0] / 2;
181+
overlay->pixels[0] = (Uint8 *)hwdata->pixels;
182+
overlay->pixels[1] = overlay->pixels[0] +
183+
overlay->pitches[0] * overlay->h;
184+
overlay->pixels[2] = overlay->pixels[1] +
185+
overlay->pitches[1] * overlay->h / 2;
186+
overlay->planes = 3;
187+
break;
188+
default:
189+
/* We should never get here (caught above) */
190+
break;
191+
}
192+
193+
/* We're all done.. */
194+
return overlay;
195+
}
196+
197+
198+
int PS3_LockYUVOverlay(_THIS, SDL_Overlay *overlay) {
199+
if (overlay == NULL) {
200+
return -1;
201+
}
202+
overlay->hwdata->locked = 1;
203+
204+
return 0;
205+
}
206+
207+
208+
void PS3_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay) {
209+
if (overlay == NULL) {
210+
return;
211+
}
212+
overlay->hwdata->locked = 0;
213+
214+
return;
215+
}
216+
217+
218+
int PS3_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst) {
219+
if ((overlay == NULL) || (overlay->hwdata == NULL)) {
220+
return -1;
221+
}
222+
223+
Uint8 *lum, *Cr, *Cb;
224+
struct private_yuvhwdata *hwdata;
225+
SDL_Surface *display;
226+
227+
hwdata = overlay->hwdata;
228+
display = hwdata->display;
229+
230+
/* Do we have to scale? */
231+
if ((src->w != dst->w) || (src->h != dst->h) ) {
232+
hwdata->scale = 1;
233+
deprintf(1, "[PS3] We need to scale\n");
234+
} else {
235+
hwdata->scale = 0;
236+
deprintf(1, "[PS3] No scaling\n");
237+
}
238+
239+
/* Find out where the various portions of the image are */
240+
switch (overlay->format) {
241+
case SDL_YV12_OVERLAY:
242+
lum = (Uint8 *)overlay->pixels[0];
243+
Cr = (Uint8 *)overlay->pixels[1];
244+
Cb = (Uint8 *)overlay->pixels[2];
245+
break;
246+
case SDL_IYUV_OVERLAY:
247+
lum = (Uint8 *)overlay->pixels[0];
248+
Cr = (Uint8 *)overlay->pixels[2];
249+
Cb = (Uint8 *)overlay->pixels[1];
250+
break;
251+
default:
252+
SDL_SetError("Unsupported YUV format in blit");
253+
return -1;
254+
}
255+
256+
if (hwdata->scale) {
257+
/* Alloc mem for scaled YUV picture */
258+
hwdata->scaler_out = (Uint8 *) memalign(16, dst->w * dst->h + ((dst->w * dst->h) >> 1));
259+
if (hwdata->scaler_out == NULL) {
260+
SDL_FreeYUVOverlay(overlay);
261+
SDL_OutOfMemory();
262+
return -1;
263+
}
264+
265+
/* Set parms for scaling */
266+
hwdata->scaler_parms->src_pixel_width = src->w;
267+
hwdata->scaler_parms->src_pixel_height = src->h;
268+
hwdata->scaler_parms->dst_pixel_width = dst->w;
269+
hwdata->scaler_parms->dst_pixel_height = dst->h;
270+
hwdata->scaler_parms->y_plane = lum;
271+
hwdata->scaler_parms->v_plane = Cr;
272+
hwdata->scaler_parms->u_plane = Cb;
273+
hwdata->scaler_parms->dstBuffer = hwdata->scaler_out;
274+
scaler_thread_data->argp = (void *)hwdata->scaler_parms;
275+
276+
/* Scale the YUV overlay to given size */
277+
SPE_Start(this, scaler_thread_data);
278+
SPE_Stop(this, scaler_thread_data);
279+
280+
/* Set parms for converting after scaling */
281+
hwdata->converter_parms->y_plane = hwdata->scaler_out;
282+
hwdata->converter_parms->v_plane = hwdata->scaler_out + dst->w * dst->h;
283+
hwdata->converter_parms->u_plane = hwdata->scaler_out + dst->w * dst->h + ((dst->w * dst->h) >> 2);
284+
} else {
285+
/* Set parms for converting */
286+
hwdata->converter_parms->y_plane = lum;
287+
hwdata->converter_parms->v_plane = Cr;
288+
hwdata->converter_parms->u_plane = Cb;
289+
}
290+
291+
hwdata->converter_parms->src_pixel_width = dst->w;
292+
hwdata->converter_parms->src_pixel_height = dst->h;
293+
hwdata->converter_parms->dstBuffer = (Uint8 *) s_pixels;
294+
converter_thread_data->argp = (void *)hwdata->converter_parms;
295+
296+
/* Convert YUV overlay to RGB */
297+
SPE_SendMsg(this, converter_thread_data, SPU_START);
298+
SPE_SendMsg(this, converter_thread_data, (unsigned int)converter_thread_data->argp);
299+
300+
/* Centering */
301+
s_bounded_input_width = dst->w;
302+
s_bounded_input_height = dst->h;
303+
304+
/* UpdateRects() will do the rest.. */
305+
SDL_UpdateRects(display, 1, dst);
306+
307+
if (hwdata->scale)
308+
SDL_free((void *)hwdata->scaler_out);
309+
310+
return 0;
311+
}
312+
313+
314+
void PS3_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) {
315+
if (overlay == NULL) {
316+
return;
317+
}
318+
319+
if (overlay->hwdata == NULL) {
320+
return;
321+
}
322+
323+
struct private_yuvhwdata * hwdata;
324+
hwdata = overlay->hwdata;
325+
326+
if (scaler_thread_data)
327+
SDL_free(scaler_thread_data);
328+
if (converter_thread_data) {
329+
SPE_Shutdown(this, converter_thread_data);
330+
SDL_free(converter_thread_data);
331+
}
332+
333+
if (hwdata) {
334+
if (hwdata->pixels)
335+
SDL_free((void *)hwdata->pixels);
336+
SDL_free(hwdata);
337+
}
338+
return;
339+
}
340+

‎src/video/ps3/SDL_ps3yuv_c.h

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* SDL - Simple DirectMedia Layer
3+
* CELL BE Support for PS3 Framebuffer
4+
* Copyright (C) 2008, 2009 International Business Machines Corporation
5+
*
6+
* This library is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as published
8+
* by the Free Software Foundation; either version 2.1 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This library is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this library; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19+
* USA
20+
*
21+
* Martin Lowinski <lowinski [at] de [dot] ibm [ibm] com>
22+
* Dirk Herrendoerfer <d.herrendoerfer [at] de [dot] ibm [dot] com>
23+
* SPE code based on research by:
24+
* Rene Becker
25+
* Thimo Emmerich
26+
*/
27+
28+
#include "SDL_config.h"
29+
30+
#ifndef _SDL_ps3yuv_h
31+
#define _SDL_ps3yuv_h
32+
33+
/* This is the PS3 implementation of YUV video overlays */
34+
35+
#include "SDL_video.h"
36+
37+
extern SDL_Overlay *PS3_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display);
38+
extern int PS3_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst);
39+
extern int PS3_LockYUVOverlay(_THIS, SDL_Overlay *overlay);
40+
extern void PS3_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay);
41+
extern void PS3_FreeYUVOverlay(_THIS, SDL_Overlay *overlay);
42+
43+
#endif /* _SDL_ps3yuv_h */
44+

‎src/video/ps3/spulibs/Makefile

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# This Makefile is for building the CELL BE SPU libs
2+
# libfb_writer_spu.so, libyuv2rgb_spu.so, libbilin_scaler_spu.so
3+
4+
# Toolchain
5+
SPU_GCC=/usr/bin/spu-gcc
6+
PPU_GCC=/usr/bin/gcc
7+
PPU_EMBEDSPU=/usr/bin/embedspu
8+
PPU_AR=/usr/bin/ar
9+
PPU_LD=/usr/bin/ld
10+
INSTALL=/usr/bin/install
11+
12+
SPU_CFLAGS=-W -Wall -Winline -Wno-main -I. -I /usr/spu/include -I /opt/cell/sdk/usr/spu/include -finline-limit=10000 -Winline -ftree-vectorize -funroll-loops -fmodulo-sched -ffast-math -fPIC -O2
13+
14+
# Usually /usr/lib, depending on your distribution
15+
PREFIX=/usr/lib
16+
17+
18+
all: libfb_writer_spu.a libfb_writer_spu.so \
19+
libyuv2rgb_spu.so libyuv2rgb_spu.a \
20+
libbilin_scaler_spu.so libbilin_scaler_spu.a
21+
22+
23+
# fb_writer
24+
fb_writer_spu-embed.o: fb_writer.c spu_common.h
25+
$(SPU_GCC) $(SPU_CFLAGS) -o fb_writer_spu fb_writer.c -lm
26+
$(PPU_EMBEDSPU) -m32 fb_writer_spu fb_writer_spu fb_writer_spu-embed.o
27+
28+
libfb_writer_spu.so: fb_writer_spu-embed.o
29+
$(PPU_LD) -o libfb_writer_spu.so -shared -soname=libfb_writer_spu.so fb_writer_spu-embed.o
30+
31+
libfb_writer_spu.a: fb_writer_spu-embed.o
32+
$(PPU_AR) -qcs libfb_writer_spu.a fb_writer_spu-embed.o
33+
34+
35+
# yuv2rgb_converter
36+
yuv2rgb_spu-embed.o: yuv2rgb_converter.c spu_common.h
37+
$(SPU_GCC) $(SPU_CFLAGS) -o yuv2rgb_spu yuv2rgb_converter.c -lm
38+
$(PPU_EMBEDSPU) -m32 yuv2rgb_spu yuv2rgb_spu yuv2rgb_spu-embed.o
39+
40+
libyuv2rgb_spu.a: yuv2rgb_spu-embed.o
41+
$(PPU_AR) -qcs libyuv2rgb_spu.a yuv2rgb_spu-embed.o
42+
43+
libyuv2rgb_spu.so: yuv2rgb_spu-embed.o
44+
$(PPU_LD) -o libyuv2rgb_spu.so -shared -soname=libyuv2rgb_spu.so yuv2rgb_spu-embed.o
45+
46+
47+
# bilin_scaler
48+
bilin_scaler_spu-embed.o: bilin_scaler.c spu_common.h
49+
$(SPU_GCC) $(SPU_CFLAGS) -o bilin_scaler_spu bilin_scaler.c -lm
50+
$(PPU_EMBEDSPU) -m32 bilin_scaler_spu bilin_scaler_spu bilin_scaler_spu-embed.o
51+
52+
libbilin_scaler_spu.a: bilin_scaler_spu-embed.o
53+
$(PPU_AR) -qcs libbilin_scaler_spu.a bilin_scaler_spu-embed.o
54+
55+
libbilin_scaler_spu.so: bilin_scaler_spu-embed.o
56+
$(PPU_LD) -o libbilin_scaler_spu.so -shared -soname=libbilin_scaler_spu.so bilin_scaler_spu-embed.o
57+
58+
install: libfb_writer_spu.a libfb_writer_spu.so \
59+
libyuv2rgb_spu.so libyuv2rgb_spu.a \
60+
libbilin_scaler_spu.so libbilin_scaler_spu.a
61+
$(INSTALL) -c -m 0755 libfb_writer_spu.so $(PREFIX)/.
62+
$(INSTALL) -c -m 0655 libfb_writer_spu.a $(PREFIX)/.
63+
$(INSTALL) -c -m 0755 libyuv2rgb_spu.so $(PREFIX)/.
64+
$(INSTALL) -c -m 0655 libyuv2rgb_spu.a $(PREFIX)/.
65+
$(INSTALL) -c -m 0755 libbilin_scaler_spu.so $(PREFIX)/.
66+
$(INSTALL) -c -m 0655 libbilin_scaler_spu.a $(PREFIX)/.
67+
68+
69+
uninstall: $(PREFIX)/libfb_writer_spu.so $(PREFIX)/libfb_writer_spu.a \
70+
$(PREFIX)/libyuv2rgb_spu.so $(PREFIX)/libyuv2rgb_spu.a \
71+
$(PREFIX)/libbilin_scaler_spu.so $(PREFIX)/libbilin_scaler_spu.a
72+
rm -f $(PREFIX)/libfb_writer_spu.a
73+
rm -f $(PREFIX)/libfb_writer_spu.so
74+
rm -f $(PREFIX)/libyuv2rgb_spu.so
75+
rm -f $(PREFIX)/libyuv2rgb_spu.a
76+
rm -f $(PREFIX)/libbilin_scaler_spu.so
77+
rm -f $(PREFIX)/libbilin_scaler_spu.a
78+
79+
80+
clean:
81+
rm -f bilin_scaler_spu-embed.o libbilin_scaler_spu.so libbilin_scaler_spu.a bilin_scaler_spu
82+
rm -f yuv2rgb_spu-embed.o libyuv2rgb_spu.so libyuv2rgb_spu.a yuv2rgb_spu
83+
rm -f fb_writer_spu-embed.o libfb_writer_spu.so libfb_writer_spu.a fb_writer_spu

‎src/video/ps3/spulibs/bilin_scaler.c

+2,050
Large diffs are not rendered by default.

‎src/video/ps3/spulibs/fb_writer.c

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
/*
2+
* SDL - Simple DirectMedia Layer
3+
* CELL BE Support for PS3 Framebuffer
4+
* Copyright (C) 2008, 2009 International Business Machines Corporation
5+
*
6+
* This library is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as published
8+
* by the Free Software Foundation; either version 2.1 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This library is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this library; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19+
* USA
20+
*
21+
* Martin Lowinski <lowinski [at] de [dot] ibm [ibm] com>
22+
* Dirk Herrendoerfer <d.herrendoerfer [at] de [dot] ibm [dot] com>
23+
* SPE code based on research by:
24+
* Rene Becker
25+
* Thimo Emmerich
26+
*/
27+
28+
#include "spu_common.h"
29+
30+
#include <spu_intrinsics.h>
31+
#include <spu_mfcio.h>
32+
#include <stdio.h>
33+
#include <string.h>
34+
35+
// Debugging
36+
//#define DEBUG
37+
38+
#ifdef DEBUG
39+
#define deprintf(fmt, args... ) \
40+
fprintf( stdout, fmt, ##args ); \
41+
fflush( stdout );
42+
#else
43+
#define deprintf( fmt, args... )
44+
#endif
45+
46+
void cpy_to_fb(unsigned int);
47+
48+
/* fb_writer_spu parms */
49+
static volatile struct fb_writer_parms_t parms __attribute__ ((aligned(128)));
50+
51+
/* Code running on SPU */
52+
int main(unsigned long long spe_id __attribute__ ((unused)), unsigned long long argp __attribute__ ((unused)))
53+
{
54+
deprintf("[SPU] fb_writer_spu is up... (on SPE #%llu)\n", spe_id);
55+
uint32_t ea_mfc, mbox;
56+
// send ready message
57+
spu_write_out_mbox(SPU_READY);
58+
59+
while (1) {
60+
/* Check mailbox */
61+
mbox = spu_read_in_mbox();
62+
deprintf("[SPU] Message is %u\n", mbox);
63+
switch (mbox) {
64+
case SPU_EXIT:
65+
deprintf("[SPU] fb_writer goes down...\n");
66+
return 0;
67+
case SPU_START:
68+
break;
69+
default:
70+
deprintf("[SPU] Cannot handle message\n");
71+
continue;
72+
}
73+
74+
/* Tag Manager setup */
75+
unsigned int tags;
76+
tags = mfc_multi_tag_reserve(5);
77+
if (tags == MFC_TAG_INVALID) {
78+
deprintf("[SPU] Failed to reserve mfc tags on fb_writer\n");
79+
return 0;
80+
}
81+
82+
/* Framebuffer parms */
83+
ea_mfc = spu_read_in_mbox();
84+
deprintf("[SPU] Message on fb_writer is %u\n", ea_mfc);
85+
spu_mfcdma32(&parms, (unsigned int)ea_mfc,
86+
sizeof(struct fb_writer_parms_t), tags,
87+
MFC_GET_CMD);
88+
deprintf("[SPU] argp = %u\n", (unsigned int)argp);
89+
DMA_WAIT_TAG(tags);
90+
91+
/* Copy parms->data to framebuffer */
92+
deprintf("[SPU] Copying to framebuffer started\n");
93+
cpy_to_fb(tags);
94+
deprintf("[SPU] Copying to framebuffer done!\n");
95+
96+
mfc_multi_tag_release(tags, 5);
97+
deprintf("[SPU] fb_writer_spu... done!\n");
98+
/* Send FIN msg */
99+
spu_write_out_mbox(SPU_FIN);
100+
}
101+
102+
return 0;
103+
}
104+
105+
void cpy_to_fb(unsigned int tag_id_base)
106+
{
107+
unsigned int i;
108+
unsigned char current_buf;
109+
uint8_t *in = parms.data;
110+
111+
/* Align fb pointer which was centered before */
112+
uint8_t *fb =
113+
(unsigned char *)((unsigned int)parms.center & 0xFFFFFFF0);
114+
115+
uint32_t bounded_input_height = parms.bounded_input_height;
116+
uint32_t bounded_input_width = parms.bounded_input_width;
117+
uint32_t fb_pixel_size = parms.fb_pixel_size;
118+
119+
uint32_t out_line_stride = parms.out_line_stride;
120+
uint32_t in_line_stride = parms.in_line_stride;
121+
uint32_t in_line_size = bounded_input_width * fb_pixel_size;
122+
123+
current_buf = 0;
124+
125+
/* Local store buffer */
126+
static volatile uint8_t buf[4][BUFFER_SIZE]
127+
__attribute__ ((aligned(128)));
128+
/* do 4-times multibuffering using DMA list, process in two steps */
129+
for (i = 0; i < bounded_input_height >> 2; i++) {
130+
/* first buffer */
131+
DMA_WAIT_TAG(tag_id_base + 1);
132+
// retrieve buffer
133+
spu_mfcdma32(buf[0], (unsigned int)in, in_line_size,
134+
tag_id_base + 1, MFC_GETB_CMD);
135+
DMA_WAIT_TAG(tag_id_base + 1);
136+
// store buffer
137+
spu_mfcdma32(buf[0], (unsigned int)fb, in_line_size,
138+
tag_id_base + 1, MFC_PUTB_CMD);
139+
in += in_line_stride;
140+
fb += out_line_stride;
141+
deprintf("[SPU] 1st buffer copied in=0x%x, fb=0x%x\n", in,
142+
fb);
143+
144+
/* second buffer */
145+
DMA_WAIT_TAG(tag_id_base + 2);
146+
// retrieve buffer
147+
spu_mfcdma32(buf[1], (unsigned int)in, in_line_size,
148+
tag_id_base + 2, MFC_GETB_CMD);
149+
DMA_WAIT_TAG(tag_id_base + 2);
150+
// store buffer
151+
spu_mfcdma32(buf[1], (unsigned int)fb, in_line_size,
152+
tag_id_base + 2, MFC_PUTB_CMD);
153+
in += in_line_stride;
154+
fb += out_line_stride;
155+
deprintf("[SPU] 2nd buffer copied in=0x%x, fb=0x%x\n", in,
156+
fb);
157+
158+
/* third buffer */
159+
DMA_WAIT_TAG(tag_id_base + 3);
160+
// retrieve buffer
161+
spu_mfcdma32(buf[2], (unsigned int)in, in_line_size,
162+
tag_id_base + 3, MFC_GETB_CMD);
163+
DMA_WAIT_TAG(tag_id_base + 3);
164+
// store buffer
165+
spu_mfcdma32(buf[2], (unsigned int)fb, in_line_size,
166+
tag_id_base + 3, MFC_PUTB_CMD);
167+
in += in_line_stride;
168+
fb += out_line_stride;
169+
deprintf("[SPU] 3rd buffer copied in=0x%x, fb=0x%x\n", in,
170+
fb);
171+
172+
/* fourth buffer */
173+
DMA_WAIT_TAG(tag_id_base + 4);
174+
// retrieve buffer
175+
spu_mfcdma32(buf[3], (unsigned int)in, in_line_size,
176+
tag_id_base + 4, MFC_GETB_CMD);
177+
DMA_WAIT_TAG(tag_id_base + 4);
178+
// store buffer
179+
spu_mfcdma32(buf[3], (unsigned int)fb, in_line_size,
180+
tag_id_base + 4, MFC_PUTB_CMD);
181+
in += in_line_stride;
182+
fb += out_line_stride;
183+
deprintf("[SPU] 4th buffer copied in=0x%x, fb=0x%x\n", in,
184+
fb);
185+
deprintf("[SPU] Loop #%i, bounded_input_height=%i\n", i,
186+
bounded_input_height >> 2);
187+
}
188+
DMA_WAIT_TAG(tag_id_base + 2);
189+
DMA_WAIT_TAG(tag_id_base + 3);
190+
DMA_WAIT_TAG(tag_id_base + 4);
191+
}
192+
193+

‎src/video/ps3/spulibs/spu_common.h

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* SDL - Simple DirectMedia Layer
3+
* CELL BE Support for PS3 Framebuffer
4+
* Copyright (C) 2008, 2009 International Business Machines Corporation
5+
*
6+
* This library is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as published
8+
* by the Free Software Foundation; either version 2.1 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This library is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this library; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19+
* USA
20+
*
21+
* Martin Lowinski <lowinski [at] de [dot] ibm [ibm] com>
22+
* Dirk Herrendoerfer <d.herrendoerfer [at] de [dot] ibm [dot] com>
23+
* SPE code based on research by:
24+
* Rene Becker
25+
* Thimo Emmerich
26+
*/
27+
28+
/* Common definitions/makros for SPUs */
29+
30+
#ifndef _SPU_COMMON_H
31+
#define _SPU_COMMON_H
32+
33+
#include <stdio.h>
34+
#include <stdint.h>
35+
#include <string.h>
36+
37+
/* Tag management */
38+
#define DMA_WAIT_TAG(_tag) \
39+
mfc_write_tag_mask(1<<(_tag)); \
40+
mfc_read_tag_status_all();
41+
42+
/* SPU mailbox messages */
43+
#define SPU_READY 0
44+
#define SPU_START 1
45+
#define SPU_FIN 2
46+
#define SPU_EXIT 3
47+
48+
/* Tags */
49+
#define RETR_BUF 0
50+
#define STR_BUF 1
51+
#define TAG_INIT 2
52+
53+
/* Buffersizes */
54+
#define MAX_HDTV_WIDTH 1920
55+
#define MAX_HDTV_HEIGHT 1080
56+
/* One stride of HDTV */
57+
#define BUFFER_SIZE 7680
58+
59+
/* fb_writer ppu/spu exchange parms */
60+
struct fb_writer_parms_t {
61+
uint8_t *data;
62+
uint8_t *center;
63+
uint32_t out_line_stride;
64+
uint32_t in_line_stride;
65+
uint32_t bounded_input_height;
66+
uint32_t bounded_input_width;
67+
uint32_t fb_pixel_size;
68+
69+
/* This padding is to fulfill the need for 16 byte alignment. On parm change, update! */
70+
char padding[4];
71+
} __attribute__((aligned(128)));
72+
73+
/* yuv2rgb ppu/spu exchange parms */
74+
struct yuv2rgb_parms_t {
75+
uint8_t* y_plane;
76+
uint8_t* v_plane;
77+
uint8_t* u_plane;
78+
79+
uint8_t* dstBuffer;
80+
81+
unsigned int src_pixel_width;
82+
unsigned int src_pixel_height;
83+
84+
/* This padding is to fulfill the need for 16 byte alignment. On parm change, update! */
85+
char padding[128 - ((4 * sizeof(uint8_t *) + 2 * sizeof(unsigned int)) & 0x7F)];
86+
} __attribute__((aligned(128)));
87+
88+
/* bilin_scaler ppu/spu exchange parms */
89+
struct scale_parms_t {
90+
uint8_t* y_plane;
91+
uint8_t* v_plane;
92+
uint8_t* u_plane;
93+
94+
uint8_t* dstBuffer;
95+
96+
unsigned int src_pixel_width;
97+
unsigned int src_pixel_height;
98+
99+
unsigned int dst_pixel_width;
100+
unsigned int dst_pixel_height;
101+
102+
/* This padding is to fulfill the need for 16 byte alignment. On parm change, update! */
103+
char padding[128 - ((4 * sizeof(uint8_t *) + 4 * sizeof(unsigned int)) & 0x7F)];
104+
} __attribute__((aligned(128)));
105+
106+
#endif /* _SPU_COMMON_H */
107+
108+

‎src/video/ps3/spulibs/yuv2rgb_converter.c

+629
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.