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