annotate libvo/vo_wii.c @ 27443:ff52998e24e8

-geometry support for -vo fbdev. Patch by Sander (thrill12 gmx net)
author reimar
date Fri, 22 Aug 2008 17:26:16 +0000
parents 80d93ca55238
children 31837cfbb63c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27375
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
1 /*
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
2 * Video driver for Nintendo Wii/GameCube Framebuffer device
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
3 *
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
4 * Copyright (C) 2008 Jing Liu <fatersh-1@yahoo.com>
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
5 *
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
6 * Maintainer: Benjamin Zores <ben@geexbox.org>
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
7 *
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
8 * This file is part of MPlayer.
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
9 *
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
10 * MPlayer is free software; you can redistribute it and/or modify
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
13 * (at your option) any later version.
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
14 *
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
15 * MPlayer is distributed in the hope that it will be useful,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
18 * GNU General Public License for more details.
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
19 *
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License along
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
21 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
23 */
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
24
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
25 /*
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
26 * This driver handles dedicated ATI GPU, which can be found in:
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
27 * - Nintendo GameCube (ATI LSI Flipper @ 162 MHz)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
28 * - Nintendo Wii (ATI Hollywood @ 243 MHz)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
29 *
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
30 * Flipper and Hollywood chipsets are pretty similar, except from clock speed:
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
31 * - Embedded framebuffer is 2MB.
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
32 * - Texture cache is 1MB.
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
33 * - Vertex cache is 0.1 MB.
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
34 * - Framebuffer is YUY2, not RGB.
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
35 * - Best resolution is 480p (854x480)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
36 */
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
37
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
38 #include <stdio.h>
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
39 #include <stdlib.h>
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
40 #include <string.h>
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
41 #include <fcntl.h>
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
42 #include <unistd.h>
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
43 #include <errno.h>
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
44 #include <ctype.h>
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
45
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
46 #include <sys/mman.h>
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
47 #include <sys/ioctl.h>
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
48 #include <sys/kd.h>
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
49 #include <linux/fb.h>
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
50
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
51 #include "config.h"
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
52 #include "video_out.h"
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
53 #include "video_out_internal.h"
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
54 #include "sub.h"
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
55 #include "mp_msg.h"
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
56
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
57 #define WII_DEV_NAME "/dev/fb0"
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
58 #define TTY_DEV_NAME "/dev/tty"
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
59 #define FB_PIXEL_SIZE 2
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
60
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
61 static const vo_info_t info = {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
62 "Nintendo Wii/GameCube Framebuffer Device",
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
63 "wii",
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
64 "Jing Liu <fartersh-1@yahoo.com>",
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
65 ""
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
66 };
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
67
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
68 LIBVO_EXTERN(wii)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
69
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
70 static signed int pre_init_err = -2;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
71
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
72 static FILE *vt_fp = NULL;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
73 static int vt_doit = 1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
74 static int fb_dev_fd = -1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
75 static int fb_tty_fd = -1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
76
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
77 static uint8_t *frame_buffer;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
78 static uint8_t *center;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
79
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
80 static struct fb_var_screeninfo fb_orig_vinfo;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
81 static struct fb_var_screeninfo fb_vinfo;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
82 static int fb_line_len;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
83 static size_t fb_size;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
84
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
85 static int in_width, out_width;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
86 static int in_height, out_height;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
87 static int fs;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
88
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
89 static int
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
90 fb_preinit (int reset)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
91 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
92 static int fb_preinit_done = 0;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
93 static int fb_works = 0;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
94
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
95 if (reset)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
96 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
97 fb_preinit_done = 0;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
98 return 0;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
99 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
100
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
101 if (fb_preinit_done)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
102 return fb_works;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
103
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
104 if ((fb_dev_fd = open (WII_DEV_NAME, O_RDWR)) == -1)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
105 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
106 mp_msg (MSGT_VO, MSGL_ERR,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
107 "Can't open %s: %s\n", WII_DEV_NAME, strerror (errno));
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
108 goto err_out;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
109 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
110
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
111 if (ioctl (fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo))
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
112 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
113 mp_msg (MSGT_VO, MSGL_ERR,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
114 "Can't get VSCREENINFO: %s\n", strerror (errno));
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
115 goto err_out_fd;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
116 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
117
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
118 fb_orig_vinfo = fb_vinfo;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
119
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
120 if ((fb_tty_fd = open (TTY_DEV_NAME, O_RDWR)) < 0)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
121 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
122 mp_msg (MSGT_VO, MSGL_ERR,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
123 "Notice: Can't open %s: %s\n", TTY_DEV_NAME, strerror (errno));
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
124 goto err_out_fd;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
125 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
126
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
127 fb_preinit_done = 1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
128 fb_works = 1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
129 return 1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
130
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
131 err_out_fd:
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
132 close (fb_dev_fd);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
133 fb_dev_fd = -1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
134 err_out:
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
135 fb_preinit_done = 1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
136 fb_works = 0;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
137
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
138 return 0;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
139 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
140
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
141 static void
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
142 vt_set_textarea (int u, int l)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
143 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
144 /* how can I determine the font height?
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
145 * just use 16 for now
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
146 */
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
147 int urow = ((u + 15) / 16) + 1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
148 int lrow = l / 16;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
149
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
150 mp_msg (MSGT_VO, MSGL_DBG2,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
151 "vt_set_textarea (%d, %d): %d,%d\n", u, l, urow, lrow);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
152
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
153 if (vt_fp)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
154 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
155 fprintf (vt_fp, "\33[%d;%dr\33[%d;%dH", urow, lrow, lrow, 0);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
156 fflush (vt_fp);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
157 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
158 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
159
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
160 static int
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
161 config (uint32_t width, uint32_t height, uint32_t d_width,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
162 uint32_t d_height, uint32_t flags, char *title, uint32_t format)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
163 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
164 struct fb_fix_screeninfo fb_finfo;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
165 uint32_t black = 0x00800080;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
166 long temp;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
167 int vt_fd;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
168
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
169 fs = flags & VOFLAG_FULLSCREEN;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
170
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
171 if (pre_init_err == -2)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
172 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
173 mp_msg (MSGT_VO, MSGL_ERR,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
174 "Internal fatal error: config() was called before preinit()\n");
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
175 return -1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
176 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
177
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
178 if (pre_init_err)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
179 return 1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
180
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
181 in_width = width;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
182 in_height = height;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
183
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
184 out_width = (d_width && fs) ? d_width : width;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
185 out_height = (d_width && fs) ? d_height : height;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
186
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
187 fb_vinfo.xres_virtual = fb_vinfo.xres;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
188 fb_vinfo.yres_virtual = fb_vinfo.yres;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
189
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
190 if (fb_tty_fd >= 0 && ioctl (fb_tty_fd, KDSETMODE, KD_GRAPHICS) < 0)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
191 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
192 mp_msg (MSGT_VO, MSGL_V,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
193 "Can't set graphics mode: %s\n", strerror (errno));
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
194 close (fb_tty_fd);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
195 fb_tty_fd = -1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
196 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
197
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
198 if (ioctl (fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo))
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
199 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
200 mp_msg (MSGT_VO, MSGL_ERR,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
201 "Can't put VSCREENINFO: %s\n", strerror (errno));
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
202 if (fb_tty_fd >= 0 && ioctl (fb_tty_fd, KDSETMODE, KD_TEXT) < 0)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
203 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
204 mp_msg (MSGT_VO, MSGL_ERR,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
205 "Can't restore text mode: %s\n", strerror (errno));
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
206 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
207 return 1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
208 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
209
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
210 if (fs)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
211 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
212 out_width = fb_vinfo.xres;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
213 out_height = fb_vinfo.yres;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
214 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
215
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
216 if (out_width < in_width || out_height < in_height)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
217 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
218 mp_msg (MSGT_VO, MSGL_ERR, "Screensize is smaller than video size\n");
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
219 return 1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
220 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
221
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
222 if (ioctl (fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo))
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
223 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
224 mp_msg (MSGT_VO, MSGL_ERR,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
225 "Can't get FSCREENINFO: %s\n", strerror (errno));
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
226 return 1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
227 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
228
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
229 if (fb_finfo.type != FB_TYPE_PACKED_PIXELS)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
230 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
231 mp_msg (MSGT_VO, MSGL_ERR, "Type %d not supported\n", fb_finfo.type);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
232 return 1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
233 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
234
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
235 fb_line_len = fb_finfo.line_length;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
236 fb_size = fb_finfo.smem_len;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
237 frame_buffer = NULL;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
238
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
239 frame_buffer = (uint8_t *) mmap (0, fb_size, PROT_READ | PROT_WRITE,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
240 MAP_SHARED, fb_dev_fd, 0);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
241 if (frame_buffer == (uint8_t *) -1)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
242 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
243 mp_msg (MSGT_VO, MSGL_ERR,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
244 "Can't mmap %s: %s\n", WII_DEV_NAME, strerror (errno));
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
245 return 1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
246 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
247
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
248 center = frame_buffer +
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
249 ((out_width - in_width) / 2) * FB_PIXEL_SIZE +
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
250 ((out_height - in_height) / 2) * fb_line_len;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
251
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
252 mp_msg (MSGT_VO, MSGL_DBG2, "Frame_buffer @ %p\n", frame_buffer);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
253 mp_msg (MSGT_VO, MSGL_DBG2, "Center @ %p\n", center);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
254 mp_msg (MSGT_VO, MSGL_V,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
255 "Pixel per line: %d\n", fb_line_len / FB_PIXEL_SIZE);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
256
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
257 /* blanking screen */
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
258 for (temp = 0; temp < fb_size; temp += 4)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
259 memcpy (frame_buffer + temp, (void *) &black, 4);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
260
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
261 vt_fd = open (TTY_DEV_NAME, O_WRONLY);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
262 if (vt_doit && vt_fd == -1)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
263 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
264 mp_msg (MSGT_VO, MSGL_ERR,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
265 "Can't open %s: %s\n", TTY_DEV_NAME, strerror (errno));
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
266 vt_doit = 0;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
267 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
268
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
269 vt_fp = fdopen (vt_fd, "w");
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
270 if (vt_doit && !vt_fp)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
271 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
272 mp_msg (MSGT_VO, MSGL_ERR,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
273 "Can't fdopen %s: %s\n", TTY_DEV_NAME, strerror (errno));
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
274 vt_doit = 0;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
275 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
276
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
277 if (vt_doit)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
278 vt_set_textarea ((out_height + in_height) / 2, fb_vinfo.yres);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
279
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
280 return 0;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
281 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
282
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
283 static int
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
284 query_format (uint32_t format)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
285 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
286 if (!fb_preinit (0))
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
287 return 0;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
288
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
289 if (format != IMGFMT_YUY2)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
290 return 0;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
291
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
292 return VFCAP_ACCEPT_STRIDE | VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
293 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
294
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
295 static void
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
296 draw_alpha (int x0, int y0, int w, int h,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
297 unsigned char *src, unsigned char *srca, int stride)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
298 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
299 unsigned char *dst;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
300
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
301 dst = center + fb_line_len * y0 + FB_PIXEL_SIZE * x0;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
302 vo_draw_alpha_yuy2 (w, h, src, srca, stride, dst, fb_line_len);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
303 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
304
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
305 static int
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
306 draw_frame (uint8_t *src[])
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
307 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
308 return 1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
309 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
310
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
311 static int
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
312 draw_slice (uint8_t *src[], int stride[], int w, int h, int x, int y)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
313 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
314 uint8_t *d, *s;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
315
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
316 d = center + fb_line_len * y + FB_PIXEL_SIZE * x;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
317 s = src[0];
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
318
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
319 while (h)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
320 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
321 memcpy (d, s, w * FB_PIXEL_SIZE);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
322 d += fb_line_len;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
323 s += stride[0];
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
324 h--;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
325 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
326
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
327 return 0;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
328 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
329
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
330 static void
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
331 check_events(void)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
332 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
333 /* unused */
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
334 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
335
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
336 static void
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
337 flip_page (void)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
338 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
339 /* unused */
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
340 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
341
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
342 static void
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
343 draw_osd (void)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
344 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
345 vo_draw_text (in_width, in_height, draw_alpha);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
346 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
347
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
348 static void
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
349 uninit (void)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
350 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
351 if (ioctl (fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo))
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
352 mp_msg (MSGT_VO, MSGL_WARN,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
353 "ioctl FBIOGET_VSCREENINFO: %s\n", strerror (errno));
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
354
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
355 fb_orig_vinfo.xoffset = fb_vinfo.xoffset;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
356 fb_orig_vinfo.yoffset = fb_vinfo.yoffset;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
357
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
358 if (ioctl (fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_orig_vinfo))
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
359 mp_msg (MSGT_VO, MSGL_WARN,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
360 "Can't reset original fb_var_screeninfo: %s\n", strerror (errno));
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
361
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
362 if (fb_tty_fd >= 0)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
363 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
364 if (ioctl (fb_tty_fd, KDSETMODE, KD_TEXT) < 0)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
365 mp_msg (MSGT_VO, MSGL_WARN,
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
366 "Can't restore text mode: %s\n", strerror (errno));
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
367 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
368
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
369 if (vt_doit)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
370 vt_set_textarea (0, fb_orig_vinfo.yres);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
371
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
372 close (fb_tty_fd);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
373 close (fb_dev_fd);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
374
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
375 if (frame_buffer)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
376 munmap (frame_buffer, fb_size);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
377
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
378 frame_buffer = NULL;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
379 fb_preinit (1);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
380 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
381
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
382 static int
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
383 preinit (const char *vo_subdevice)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
384 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
385 pre_init_err = 0;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
386
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
387 if (!pre_init_err)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
388 return pre_init_err = (fb_preinit (0) ? 0 : -1);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
389
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
390 return -1;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
391 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
392
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
393 static uint32_t
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
394 get_image(mp_image_t *mpi)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
395 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
396 if (((mpi->type != MP_IMGTYPE_STATIC) && (mpi->type != MP_IMGTYPE_TEMP)) ||
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
397 (mpi->flags & MP_IMGFLAG_PLANAR) ||
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
398 (mpi->flags & MP_IMGFLAG_YUV) ||
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
399 (mpi->width != in_width) ||
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
400 (mpi->height != in_height))
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
401 return VO_FALSE;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
402
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
403 mpi->planes[0] = center;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
404 mpi->stride[0] = fb_line_len;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
405 mpi->flags |= MP_IMGFLAG_DIRECT;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
406
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
407 return VO_TRUE;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
408 }
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
409
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
410 static int
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
411 control (uint32_t request, void *data, ...)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
412 {
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
413 if (request == VOCTRL_GET_IMAGE)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
414 return get_image (data);
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
415 else if (request == VOCTRL_QUERY_FORMAT)
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
416 return query_format (*((uint32_t*) data));
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
417
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
418 return VO_NOTIMPL;
80d93ca55238 Add video driver for Nintendo Wii/GameCube.
ben
parents:
diff changeset
419 }