annotate src/video/ps3/SDL_ps3video.c @ 3473:7bdc10624cba

This is terrible, but the OpenGL standard says that lines are half open, which means that one endpoint is not covered so adjoining lines don't overlap. It also doesn't define which end is open, and indeed Mac OS X and Linux differ. Mac OS X seems to leave the second endpoint open, but Linux uses the right-most endpoint for x major lines and the bottom-most endpoint for y major lines.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 21 Nov 2009 07:14:21 +0000
parents 94fb40a4a9a7
children 83518f8fcd61
rev   line source
3257
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 /* SDL PS3 video driver implementation based on dummy video driver
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 *
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 * of this was cut-and-pasted from Stephane Peter's work in the AAlib
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 * SDL video driver. Renamed to "DUMMY" by Sam Lantinga.
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include "SDL_video.h"
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #include "SDL_mouse.h"
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 #include "../SDL_sysvideo.h"
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 #include "../SDL_pixels_c.h"
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 #include "../../events/SDL_events_c.h"
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 #include "SDL_ps3video.h"
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 #include "SDL_ps3spe_c.h"
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #include "SDL_ps3events_c.h"
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 #include "SDL_ps3render_c.h"
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 #include "SDL_ps3modes_c.h"
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 #include <fcntl.h>
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 #include <linux/fb.h>
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 #include <asm/ps3fb.h>
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 #include <sys/mman.h>
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 #define PS3VID_DRIVER_NAME "ps3"
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 /* Initialization/Query functions */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 static int PS3_VideoInit(_THIS);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 static void PS3_VideoQuit(_THIS);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 /* Stores the SPE executable name of fb_writer_spu */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 extern spe_program_handle_t fb_writer_spu;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 /* PS3 driver bootstrap functions */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 static int
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 PS3_Available(void)
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 deprintf(1, "+PS3_Available()\n");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 const char *envr = SDL_getenv("SDL_VIDEODRIVER");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 if ((envr) && (SDL_strcmp(envr, PS3VID_DRIVER_NAME) == 0)) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 return (1);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 deprintf(1, "-PS3_Available()\n");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 return (0);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 static void
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 PS3_DeleteDevice(SDL_VideoDevice * device)
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 deprintf(1, "+PS3_DeleteDevice()\n");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 SDL_free(device->driverdata);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 SDL_free(device);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 deprintf(1, "-PS3_DeleteDevice()\n");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 static SDL_VideoDevice *
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 PS3_CreateDevice(int devindex)
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 deprintf(1, "+PS3_CreateDevice()\n");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 SDL_VideoDevice *device;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 SDL_VideoData *data;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 /* Initialize all variables that we clean on shutdown */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 if (!device) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 SDL_OutOfMemory();
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 if (device) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 SDL_free(device);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 return (0);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 if (!data) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 SDL_OutOfMemory();
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 SDL_free(device);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 return (0);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 device->driverdata = data;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 /* Set the function pointers */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 device->VideoInit = PS3_VideoInit;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 device->VideoQuit = PS3_VideoQuit;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 device->SetDisplayMode = PS3_SetDisplayMode;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 device->GetDisplayModes = PS3_GetDisplayModes;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 device->PumpEvents = PS3_PumpEvents;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 device->free = PS3_DeleteDevice;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 deprintf(1, "-PS3_CreateDevice()\n");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 return device;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 VideoBootStrap PS3_bootstrap = {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 PS3VID_DRIVER_NAME, "SDL PS3 Cell video driver",
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 PS3_Available, PS3_CreateDevice
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 };
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 int
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 PS3_VideoInit(_THIS)
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 deprintf(1, "PS3_VideoInit()\n");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 SDL_DisplayMode mode;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 /* Create SPU fb_parms and thread structure */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 data->fb_parms = (struct fb_writer_parms_t *)
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 memalign(16, sizeof(struct fb_writer_parms_t));
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 data->fb_thread_data = (spu_data_t *) malloc(sizeof(spu_data_t));
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 if (data->fb_parms == NULL || data->fb_thread_data == NULL) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 SDL_OutOfMemory();
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 return -1;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 data->fb_thread_data->program = fb_writer_spu;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 data->fb_thread_data->program_name = "fb_writer_spu";
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 data->fb_thread_data->argp = (void *)data->fb_parms;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 data->fb_thread_data->keepalive = 1;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 data->fb_thread_data->booted = 0;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 SPE_Start(data->fb_thread_data);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 /* Open the device */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 data->fbdev = open(PS3DEV, O_RDWR);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 if (data->fbdev < 0) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 SDL_SetError("[PS3] Unable to open device %s", PS3DEV);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 return -1;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 /* Take control of frame buffer from kernel, for details see
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 * http://felter.org/wesley/files/ps3/linux-20061110-docs/ApplicationProgrammingEnvironment.html
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 * kernel will no longer flip the screen itself
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 ioctl(data->fbdev, PS3FB_IOCTL_ON, 0);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 /* Unblank screen */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 ioctl(data->fbdev, FBIOBLANK, 0);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 struct fb_fix_screeninfo fb_finfo;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 if (ioctl(data->fbdev, FBIOGET_FSCREENINFO, &fb_finfo)) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 SDL_SetError("[PS3] Can't get fixed screeninfo");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 return (0);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 /* Note: on PS3, fb_finfo.smem_len is enough for double buffering */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 if ((data->frame_buffer = (uint8_t *)mmap(0, fb_finfo.smem_len,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 PROT_READ | PROT_WRITE, MAP_SHARED,
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 data->fbdev, 0)) == (uint8_t *) - 1) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 SDL_SetError("[PS3] Can't mmap for %s", PS3DEV);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 return (0);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 } else {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 /* Enable double buffering */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 /* Blank screen */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 memset(data->frame_buffer, 0x00, fb_finfo.smem_len);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 PS3_InitModes(_this);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 SDL_AddRenderDriver(0, &SDL_PS3_RenderDriver);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 /* We're done! */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 return 0;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 void
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 PS3_VideoQuit(_THIS)
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 deprintf(1, "PS3_VideoQuit()\n");
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 PS3_QuitModes(_this);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 /* Unmap framebuffer */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 if (data->frame_buffer) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 struct fb_fix_screeninfo fb_finfo;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 if (ioctl(data->fbdev, FBIOGET_FSCREENINFO, &fb_finfo) != -1) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 munmap(data->frame_buffer, fb_finfo.smem_len);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 data->frame_buffer = 0;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 /* Shutdown SPE and related resources */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 if (data->fb_parms)
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 free((void *)data->fb_parms);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 if (data->fb_thread_data) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 SPE_Shutdown(data->fb_thread_data);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 free((void *)data->fb_thread_data);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 /* Close device */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 if (data->fbdev) {
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 /* Give control of frame buffer back to kernel */
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 ioctl(data->fbdev, PS3FB_IOCTL_OFF, 0);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 close(data->fbdev);
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 data->fbdev = -1;
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 }
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223
94fb40a4a9a7 Merged Martin's code changes from Google Summer of Code 2009
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 /* vi: set ts=4 sw=4 expandtab: */