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