Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Initialise 720p and 1080p display modes in VideoInit().
Browse files Browse the repository at this point in the history
Added setting display mode.
  • Loading branch information
martinlowinski committed Jun 13, 2009
1 parent 678294e commit e6ced19
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 3 deletions.
80 changes: 77 additions & 3 deletions src/video/ps3/SDL_ps3video.c
Expand Up @@ -49,6 +49,8 @@
/* 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 */
Expand Down Expand Up @@ -104,6 +106,7 @@ PS3_CreateDevice(int devindex)
device->VideoInit = PS3_VideoInit;
device->VideoQuit = PS3_VideoQuit;
device->SetDisplayMode = PS3_SetDisplayMode;
device->GetDisplayModes = PS3_GetDisplayModes;
device->PumpEvents = PS3_PumpEvents;

device->free = PS3_DeleteDevice;
Expand All @@ -125,19 +128,21 @@ PS3_VideoInit(_THIS)
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 = 1024;
//mode.h = 768;
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_zero(mode);
SDL_AddDisplayMode(0, &mode);
display.desktop_mode = mode;
display.current_mode = mode;
#endif

/*
*PS3 stuff
Expand Down Expand Up @@ -194,6 +199,10 @@ PS3_VideoInit(_THIS)
/* Blank screen */
memset(data->frame_buffer, 0x00, fb_finfo.smem_len);

PS3_InitModes(_this);

SDL_AddRenderDriver(0, &SDL_PS3_RenderDriver);

/* We're done! */
return 0;
}
Expand All @@ -202,9 +211,74 @@ 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)
{
Expand Down
9 changes: 9 additions & 0 deletions src/video/ps3/SDL_ps3video.h
Expand Up @@ -27,6 +27,9 @@
#include "../SDL_sysvideo.h"
#include "SDL_ps3spe_c.h"

#include <linux/fb.h>
#include <asm/ps3fb.h>

/* Debugging
* 0: No debug messages
* 1: Video debug messages
Expand Down Expand Up @@ -65,6 +68,12 @@ typedef struct SDL_VideoData
volatile struct fb_writer_parms_t * fb_parms __attribute__((aligned(128)));
} SDL_VideoData;

typedef struct
{
unsigned long mode;
struct ps3fb_ioctl_res res;
} SDL_DisplayData;

#endif /* _SDL_ps3video_h */

/* vi: set ts=4 sw=4 expandtab: */

0 comments on commit e6ced19

Please sign in to comment.