Merge pull request #127 from retro-wertz/fix_rtps_rtpt
[pcsx_rearmed.git] / frontend / pandora / picorestore.c
... / ...
CommitLineData
1/*
2 * picorestore - clean up after an omapfb program crash
3 *
4 * Copyright (c) GraÅžvydas "notaz" Ignotas, 2010
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the organization nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <stdio.h>
30#include <sys/types.h>
31#include <sys/stat.h>
32#include <fcntl.h>
33#include <unistd.h>
34#include <sys/ioctl.h>
35#include <linux/fb.h>
36#include <linux/omapfb.h>
37#include <linux/kd.h>
38
39int main()
40{
41 struct fb_var_screeninfo fbvar;
42 struct omapfb_plane_info pi;
43 struct omapfb_mem_info mi;
44 int ret, fbdev, kbdfd;
45
46 fbdev = open("/dev/fb0", O_RDWR);
47 if (fbdev == -1) {
48 perror("open fb0");
49 goto end_fb0;
50 }
51
52 ret = ioctl(fbdev, FBIOGET_VSCREENINFO, &fbvar);
53 if (ret == -1) {
54 perror("FBIOGET_VSCREENINFO ioctl");
55 goto end_fb0;
56 }
57
58 if (fbvar.yoffset != 0) {
59 printf("fixing yoffset.. ");
60 fbvar.yoffset = 0;
61 ret = ioctl(fbdev, FBIOPAN_DISPLAY, &fbvar);
62 if (ret < 0)
63 perror("ioctl FBIOPAN_DISPLAY");
64 else
65 printf("ok\n");
66 }
67
68end_fb0:
69 if (fbdev >= 0)
70 close(fbdev);
71
72 fbdev = open("/dev/fb1", O_RDWR);
73 if (fbdev == -1) {
74 perror("open fb1");
75 goto end_fb1;
76 }
77
78 ret = ioctl(fbdev, OMAPFB_QUERY_PLANE, &pi);
79 ret |= ioctl(fbdev, OMAPFB_QUERY_MEM, &mi);
80 if (ret != 0)
81 perror("QUERY_*");
82
83 pi.enabled = 0;
84 ret = ioctl(fbdev, OMAPFB_SETUP_PLANE, &pi);
85 if (ret != 0)
86 perror("SETUP_PLANE");
87
88 mi.size = 0;
89 ret = ioctl(fbdev, OMAPFB_SETUP_MEM, &mi);
90 if (ret != 0)
91 perror("SETUP_MEM");
92
93end_fb1:
94 if (fbdev >= 0)
95 close(fbdev);
96
97 kbdfd = open("/dev/tty", O_RDWR);
98 if (kbdfd == -1) {
99 perror("open /dev/tty");
100 return 1;
101 }
102
103 if (ioctl(kbdfd, KDSETMODE, KD_TEXT) == -1)
104 perror("KDSETMODE KD_TEXT");
105
106 close(kbdfd);
107
108 return 0;
109}