annotate src/video/ps3/SDL_ps3modes.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
children 7f3341cccf42
rev   line source
3151
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
1 /*
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
4
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
9
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
13 Lesser General Public License for more details.
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
14
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
18
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
19 Sam Lantinga
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
20 slouken@libsdl.org
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
21 */
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
22 #include "SDL_config.h"
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
23
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
24 #include "SDL_ps3video.h"
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
25
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
26 void
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
27 PS3_InitModes(_THIS)
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
28 {
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
29 deprintf(1, "+PS3_InitModes()\n");
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
30 SDL_VideoDisplay display;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
31 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
32 SDL_DisplayMode mode;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
33 PS3_DisplayModeData *modedata;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
34 unsigned long vid = 0;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
35
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
36 modedata = (PS3_DisplayModeData *) SDL_malloc(sizeof(*modedata));
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
37 if (!displaydata) {
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
38 return;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
39 }
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
40
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
41 /* Setting up the DisplayMode */
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
42 struct ps3fb_ioctl_res res;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
43 if (ioctl(data->fbdev, PS3FB_IOCTL_SCREENINFO, &res)) {
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
44 SDL_SetError("Can't get PS3FB_IOCTL_SCREENINFO");
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
45 }
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
46 mode.format = SDL_PIXELFORMAT_RGB888;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
47 mode.refresh_rate = 0;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
48 mode.w = res.xres;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
49 mode.h = res.yres;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
50
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
51 /* Setting up driver specific mode data */
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
52 if (ioctl(data->fbdev, PS3FB_IOCTL_GETMODE, (unsigned long)&vid)) {
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
53 SDL_SetError("Can't get PS3FB_IOCTL_GETMODE");
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
54 }
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
55 deprintf(2, "PS3FB_IOCTL_GETMODE = %u\n", vid);
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
56 modedata->mode = vid;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
57 mode.driverdata = modedata;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
58
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
59 SDL_zero(display);
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
60 display.desktop_mode = mode;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
61 display.current_mode = mode;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
62
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
63 SDL_AddVideoDisplay(&display);
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
64 deprintf(1, "-PS3_InitModes()\n");
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
65 }
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
66
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
67 void
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
68 PS3_GetDisplayModes(_THIS) {
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
69 deprintf(1, "+PS3_GetDisplayModes()\n");
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
70 deprintf(1, "-PS3_GetDisplayModes()\n");
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
71 }
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
72
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
73 static int
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
74 PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
75 {
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
76 deprintf(1, "+PS3_SetDisplayMode()\n");
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
77 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
78 SDL_DisplayData *dispdata = (SDL_DisplayData *) mode->driverdata;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
79
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
80 /* We don't care about the current DisplayMode for now */
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
81 if (ioctl(data->fbdev, PS3FB_IOCTL_SETMODE, (unsigned long)&dispdata->mode)) {
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
82 SDL_SetError("Could not set videomode\n");
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
83 return -1;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
84 }
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
85
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
86 deprintf(1, "-PS3_SetDisplayMode()\n");
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
87 return 0;
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
88 }
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
89
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
90 void
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
91 PS3_QuitModes(_THIS) {
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
92 deprintf(1, "+PS3_QuitModes()\n");
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
93 deprintf(1, "-PS3_QuitModes()\n");
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
94 }
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
95
4a88137385f9 Moved mode functions to SDL_ps3modes and fixed minor stuff.
Martin Lowinski <martin@goldtopf.org>
parents:
diff changeset
96 /* vi: set ts=4 sw=4 expandtab: */