Mercurial > mplayer.hg
annotate libvo/vo_fbdev.c @ 36494:60d86116a5bc
Simplify: use memcpy_pic.
author | reimar |
---|---|
date | Sat, 18 Jan 2014 11:41:27 +0000 |
parents | edd8273dc025 |
children | 5d3f93051de9 |
rev | line source |
---|---|
305 | 1 /* |
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
2 * video driver for framebuffer device |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
3 * copyright (C) 2001 Szabolcs Berecz <szabi@inf.elte.hu> |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
4 * |
305 | 5 * Some idea and code borrowed from Chris Lawrence's ppmtofb-0.27 |
10576 | 6 * Some fixes and small improvements by Joey Parrish <joey@nicewarrior.org> |
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
7 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
8 * This file is part of MPlayer. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
9 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
10 * MPlayer is free software; you can redistribute it and/or modify |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
13 * (at your option) any later version. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
14 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
15 * MPlayer is distributed in the hope that it will be useful, |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
18 * GNU General Public License for more details. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
19 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
20 * You should have received a copy of the GNU General Public License along |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
21 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
27983
diff
changeset
|
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
305 | 23 */ |
24 | |
225 | 25 #include <stdio.h> |
26 #include <stdlib.h> | |
27 #include <string.h> | |
28 #include <fcntl.h> | |
29 #include <unistd.h> | |
30 #include <errno.h> | |
11412 | 31 #include <ctype.h> |
225 | 32 |
33 #include <sys/mman.h> | |
34 #include <sys/ioctl.h> | |
35884 | 35 #ifdef __ANDROID__ |
36 #include <linux/kd.h> | |
37 #else | |
2354
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
38 #include <sys/kd.h> |
35884 | 39 #endif |
225 | 40 #include <linux/fb.h> |
41 | |
42 #include "config.h" | |
43 #include "video_out.h" | |
44 #include "video_out_internal.h" | |
658 | 45 #include "fastmemcpy.h" |
32467 | 46 #include "sub/sub.h" |
27443 | 47 #include "geometry.h" |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
48 #include "vosub_vidix.h" |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
49 #include "aspect.h" |
10576 | 50 #include "mp_msg.h" |
29354 | 51 #include "libavutil/common.h" |
31379
82fce4fb5049
Add header file for externally used variables from vo_fbdev.c.
diego
parents:
31082
diff
changeset
|
52 #include "vo_fbdev.h" |
4756 | 53 |
25216 | 54 static const vo_info_t info = { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
55 "Framebuffer Device", |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
56 "fbdev", |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
57 "Szabolcs Berecz <szabi@inf.elte.hu>", |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
58 "" |
225 | 59 }; |
60 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7980
diff
changeset
|
61 LIBVO_EXTERN(fbdev) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7980
diff
changeset
|
62 |
4089 | 63 #ifdef CONFIG_VIDIX |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
64 /* Name of VIDIX driver */ |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
65 static const char *vidix_name = NULL; |
11158
85f4534d1edb
Colorkeying can be disabled. Fbdev, svga and vesa vidix colorkeying support
alex
parents:
11055
diff
changeset
|
66 static vidix_grkey_t gr_key; |
4386 | 67 #endif |
6164
aee9c32349a9
applied 64bit patch from Ulrich Hecht <uli at suse dot de>
alex
parents:
4756
diff
changeset
|
68 static signed int pre_init_err = -2; |
359 | 69 /****************************** |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
70 * fb.modes support * |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
71 ******************************/ |
359 | 72 |
7069 | 73 static range_t *monitor_hfreq = NULL; |
74 static range_t *monitor_vfreq = NULL; | |
75 static range_t *monitor_dotclock = NULL; | |
76 | |
359 | 77 typedef struct { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
78 char *name; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
79 uint32_t xres, yres, vxres, vyres, depth; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
80 uint32_t pixclock, left, right, upper, lower, hslen, vslen; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
81 uint32_t sync; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
82 uint32_t vmode; |
359 | 83 } fb_mode_t; |
84 | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
85 #define MAX_NR_TOKEN 16 |
359 | 86 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
87 #define MAX_LINE_LEN 1000 |
359 | 88 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
89 #define RET_EOF -1 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
90 #define RET_EOL -2 |
359 | 91 |
92 static int validate_mode(fb_mode_t *m) | |
93 { | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
94 if (!m->xres) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
95 mp_msg(MSGT_VO, MSGL_V, "needs geometry "); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
96 return 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
97 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
98 if (!m->pixclock) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
99 mp_msg(MSGT_VO, MSGL_V, "needs timings "); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
100 return 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
101 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
102 return 1; |
359 | 103 } |
104 | |
105 static FILE *fp; | |
106 static int line_num = 0; | |
107 static char *line; | |
108 static char *token[MAX_NR_TOKEN]; | |
109 | |
110 static int get_token(int num) | |
111 { | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
112 static int read_nextline = 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
113 static int line_pos; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
114 int i; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
115 char c; |
359 | 116 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
117 if (num >= MAX_NR_TOKEN) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
118 mp_msg(MSGT_VO, MSGL_V, "get_token(): max >= MAX_NR_TOKEN!\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
119 goto out_eof; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
120 } |
359 | 121 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
122 if (read_nextline) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
123 if (!fgets(line, MAX_LINE_LEN, fp)) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
124 goto out_eof; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
125 line_pos = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
126 ++line_num; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
127 read_nextline = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
128 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
129 for (i = 0; i < num; i++) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
130 while (isspace(line[line_pos])) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
131 ++line_pos; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
132 if (line[line_pos] == '\0' || line[line_pos] == '#') { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
133 read_nextline = 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
134 goto out_eol; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
135 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
136 token[i] = line + line_pos; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
137 c = line[line_pos]; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
138 if (c == '"' || c == '\'') { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
139 token[i]++; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
140 while (line[++line_pos] != c && line[line_pos]) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
141 /* NOTHING */; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
142 if (!line[line_pos]) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
143 goto out_eol; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
144 line[line_pos] = ' '; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
145 } else { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
146 for (/* NOTHING */; !isspace(line[line_pos]) && |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
147 line[line_pos]; line_pos++) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
148 /* NOTHING */; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
149 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
150 if (!line[line_pos]) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
151 read_nextline = 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
152 if (i == num - 1) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
153 goto out_ok; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
154 goto out_eol; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
155 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
156 line[line_pos++] = '\0'; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
157 } |
359 | 158 out_ok: |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
159 return i; |
359 | 160 out_eof: |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
161 return RET_EOF; |
359 | 162 out_eol: |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
163 return RET_EOL; |
359 | 164 } |
165 | |
166 static fb_mode_t *fb_modes = NULL; | |
167 static int nr_modes = 0; | |
168 | |
169 static int parse_fbmode_cfg(char *cfgfile) | |
170 { | |
977 | 171 #define CHECK_IN_MODE_DEF\ |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
172 if (!in_mode_def) {\ |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
173 mp_msg(MSGT_VO, MSGL_V, "'needs 'mode' first");\ |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
174 goto err_out_print_linenum;\ |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
175 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
176 fb_mode_t *mode = NULL; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
177 char *endptr; // strtoul()... |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
178 int in_mode_def = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
179 int tmp, i; |
359 | 180 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
181 /* If called more than once, reuse parsed data */ |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
182 if (nr_modes) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
183 return nr_modes; |
17900
5075cd9bb631
Don't try to parse fb.modes more than once. Fixes playback of multiple files
pacman
parents:
17728
diff
changeset
|
184 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
185 mp_msg(MSGT_VO, MSGL_V, "Reading %s: ", cfgfile); |
359 | 186 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
187 if ((fp = fopen(cfgfile, "r")) == NULL) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
188 mp_msg(MSGT_VO, MSGL_V, "can't open '%s': %s\n", cfgfile, strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
189 return -1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
190 } |
359 | 191 |
29353 | 192 if ((line = malloc(MAX_LINE_LEN + 1)) == NULL) { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
193 mp_msg(MSGT_VO, MSGL_V, "can't get memory for 'line': %s\n", strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
194 return -2; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
195 } |
359 | 196 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
197 /* |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
198 * check if the cfgfile starts with 'mode' |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
199 */ |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
200 while ((tmp = get_token(1)) == RET_EOL) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
201 /* NOTHING */; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
202 if (tmp == RET_EOF) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
203 goto out; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
204 if (!strcmp(token[0], "mode")) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
205 goto loop_enter; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
206 goto err_out_parse_error; |
359 | 207 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
208 while ((tmp = get_token(1)) != RET_EOF) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
209 if (tmp == RET_EOL) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
210 continue; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
211 if (!strcmp(token[0], "mode")) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
212 if (in_mode_def) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
213 mp_msg(MSGT_VO, MSGL_V, "'endmode' required"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
214 goto err_out_print_linenum; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
215 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
216 if (!validate_mode(mode)) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
217 goto err_out_not_valid; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
218 loop_enter: |
29353 | 219 if (!(fb_modes = |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
220 realloc(fb_modes, sizeof(fb_mode_t) * (nr_modes + 1)))) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
221 mp_msg(MSGT_VO, MSGL_V, "can't realloc 'fb_modes' (nr_modes = %d):" |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
222 " %s\n", nr_modes, strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
223 goto err_out; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
224 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
225 mode = fb_modes + nr_modes; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
226 ++nr_modes; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
227 memset(mode, 0, sizeof(fb_mode_t)); |
225 | 228 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
229 if (get_token(1) < 0) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
230 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
231 for (i = 0; i < nr_modes - 1; i++) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
232 if (!strcmp(token[0], fb_modes[i].name)) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
233 mp_msg(MSGT_VO, MSGL_V, "mode name '%s' isn't unique", token[0]); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
234 goto err_out_print_linenum; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
235 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
236 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
237 if (!(mode->name = strdup(token[0]))) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
238 mp_msg(MSGT_VO, MSGL_V, "can't strdup -> 'name': %s\n", strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
239 goto err_out; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
240 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
241 in_mode_def = 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
242 } else if (!strcmp(token[0], "geometry")) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
243 CHECK_IN_MODE_DEF; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
244 if (get_token(5) < 0) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
245 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
246 mode->xres = strtoul(token[0], &endptr, 0); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
247 if (*endptr) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
248 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
249 mode->yres = strtoul(token[1], &endptr, 0); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
250 if (*endptr) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
251 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
252 mode->vxres = strtoul(token[2], &endptr, 0); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
253 if (*endptr) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
254 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
255 mode->vyres = strtoul(token[3], &endptr, 0); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
256 if (*endptr) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
257 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
258 mode->depth = strtoul(token[4], &endptr, 0); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
259 if (*endptr) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
260 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
261 } else if (!strcmp(token[0], "timings")) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
262 CHECK_IN_MODE_DEF; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
263 if (get_token(7) < 0) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
264 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
265 mode->pixclock = strtoul(token[0], &endptr, 0); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
266 if (*endptr) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
267 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
268 mode->left = strtoul(token[1], &endptr, 0); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
269 if (*endptr) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
270 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
271 mode->right = strtoul(token[2], &endptr, 0); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
272 if (*endptr) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
273 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
274 mode->upper = strtoul(token[3], &endptr, 0); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
275 if (*endptr) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
276 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
277 mode->lower = strtoul(token[4], &endptr, 0); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
278 if (*endptr) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
279 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
280 mode->hslen = strtoul(token[5], &endptr, 0); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
281 if (*endptr) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
282 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
283 mode->vslen = strtoul(token[6], &endptr, 0); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
284 if (*endptr) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
285 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
286 } else if (!strcmp(token[0], "endmode")) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
287 CHECK_IN_MODE_DEF; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
288 in_mode_def = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
289 } else if (!strcmp(token[0], "accel")) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
290 CHECK_IN_MODE_DEF; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
291 if (get_token(1) < 0) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
292 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
293 /* |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
294 * it's only used for text acceleration |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
295 * so we just ignore it. |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
296 */ |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
297 } else if (!strcmp(token[0], "hsync")) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
298 CHECK_IN_MODE_DEF; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
299 if (get_token(1) < 0) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
300 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
301 if (!strcmp(token[0], "low")) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
302 mode->sync &= ~FB_SYNC_HOR_HIGH_ACT; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
303 else if (!strcmp(token[0], "high")) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
304 mode->sync |= FB_SYNC_HOR_HIGH_ACT; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
305 else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
306 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
307 } else if (!strcmp(token[0], "vsync")) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
308 CHECK_IN_MODE_DEF; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
309 if (get_token(1) < 0) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
310 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
311 if (!strcmp(token[0], "low")) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
312 mode->sync &= ~FB_SYNC_VERT_HIGH_ACT; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
313 else if (!strcmp(token[0], "high")) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
314 mode->sync |= FB_SYNC_VERT_HIGH_ACT; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
315 else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
316 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
317 } else if (!strcmp(token[0], "csync")) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
318 CHECK_IN_MODE_DEF; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
319 if (get_token(1) < 0) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
320 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
321 if (!strcmp(token[0], "low")) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
322 mode->sync &= ~FB_SYNC_COMP_HIGH_ACT; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
323 else if (!strcmp(token[0], "high")) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
324 mode->sync |= FB_SYNC_COMP_HIGH_ACT; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
325 else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
326 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
327 } else if (!strcmp(token[0], "extsync")) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
328 CHECK_IN_MODE_DEF; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
329 if (get_token(1) < 0) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
330 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
331 if (!strcmp(token[0], "false")) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
332 mode->sync &= ~FB_SYNC_EXT; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
333 else if (!strcmp(token[0], "true")) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
334 mode->sync |= FB_SYNC_EXT; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
335 else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
336 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
337 } else if (!strcmp(token[0], "laced")) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
338 CHECK_IN_MODE_DEF; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
339 if (get_token(1) < 0) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
340 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
341 if (!strcmp(token[0], "false")) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
342 mode->vmode = FB_VMODE_NONINTERLACED; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
343 else if (!strcmp(token[0], "true")) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
344 mode->vmode = FB_VMODE_INTERLACED; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
345 else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
346 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
347 } else if (!strcmp(token[0], "double")) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
348 CHECK_IN_MODE_DEF; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
349 if (get_token(1) < 0) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
350 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
351 if (!strcmp(token[0], "false")) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
352 ; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
353 else if (!strcmp(token[0], "true")) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
354 mode->vmode = FB_VMODE_DOUBLE; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
355 else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
356 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
357 } else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
358 goto err_out_parse_error; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
359 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
360 if (!validate_mode(mode)) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
361 goto err_out_not_valid; |
359 | 362 out: |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
363 mp_msg(MSGT_VO, MSGL_V, "%d modes\n", nr_modes); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
364 free(line); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
365 fclose(fp); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
366 return nr_modes; |
359 | 367 err_out_parse_error: |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
368 mp_msg(MSGT_VO, MSGL_V, "parse error"); |
359 | 369 err_out_print_linenum: |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
370 mp_msg(MSGT_VO, MSGL_V, " at line %d\n", line_num); |
359 | 371 err_out: |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32467
diff
changeset
|
372 free(fb_modes); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32467
diff
changeset
|
373 fb_modes = NULL; |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
374 nr_modes = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
375 free(line); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
376 free(fp); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
377 return -2; |
359 | 378 err_out_not_valid: |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
379 mp_msg(MSGT_VO, MSGL_V, "previous mode is not correct"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
380 goto err_out_print_linenum; |
359 | 381 } |
382 | |
383 static fb_mode_t *find_mode_by_name(char *name) | |
384 { | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
385 int i; |
359 | 386 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
387 for (i = 0; i < nr_modes; i++) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
388 if (!strcmp(name, fb_modes[i].name)) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
389 return fb_modes + i; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
390 return NULL; |
359 | 391 } |
392 | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
393 static float dcf(fb_mode_t *m) //driving clock frequency |
393 | 394 { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
395 return 1e12f / m->pixclock; |
393 | 396 } |
397 | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
398 static float hsf(fb_mode_t *m) //horizontal scan frequency |
393 | 399 { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
400 int htotal = m->left + m->xres + m->right + m->hslen; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
401 return dcf(m) / htotal; |
393 | 402 } |
403 | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
404 static float vsf(fb_mode_t *m) //vertical scan frequency |
393 | 405 { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
406 int vtotal = m->upper + m->yres + m->lower + m->vslen; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
407 return hsf(m) / vtotal; |
393 | 408 } |
409 | |
410 | |
1561 | 411 static int mode_works(fb_mode_t *m, range_t *hfreq, range_t *vfreq, |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
412 range_t *dotclock) |
1561 | 413 { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
414 float h = hsf(m); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
415 float v = vsf(m); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
416 float d = dcf(m); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
417 int ret = 1; |
1561 | 418 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
419 mp_msg(MSGT_VO, MSGL_DBG2, "mode %dx%d:", m->xres, m->yres); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
420 if (!in_range(hfreq, h)) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
421 ret = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
422 mp_msg(MSGT_VO, MSGL_DBG2, " hsync out of range."); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
423 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
424 if (!in_range(vfreq, v)) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
425 ret = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
426 mp_msg(MSGT_VO, MSGL_DBG2, " vsync out of range."); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
427 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
428 if (!in_range(dotclock, d)) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
429 ret = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
430 mp_msg(MSGT_VO, MSGL_DBG2, " dotclock out of range."); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
431 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
432 if (ret) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
433 mp_msg(MSGT_VO, MSGL_DBG2, " hsync, vsync, dotclock ok.\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
434 else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
435 mp_msg(MSGT_VO, MSGL_DBG2, "\n"); |
1561 | 436 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
437 return ret; |
1561 | 438 } |
439 | |
418 | 440 static fb_mode_t *find_best_mode(int xres, int yres, range_t *hfreq, |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
441 range_t *vfreq, range_t *dotclock) |
393 | 442 { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
443 int i; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
444 fb_mode_t *best = fb_modes; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
445 fb_mode_t *curr; |
519 | 446 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
447 mp_msg(MSGT_VO, MSGL_DBG2, "Searching for first working mode\n"); |
1561 | 448 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
449 for (i = 0; i < nr_modes; i++, best++) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
450 if (mode_works(best, hfreq, vfreq, dotclock)) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
451 break; |
519 | 452 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
453 if (i == nr_modes) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
454 return NULL; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
455 if (i == nr_modes - 1) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
456 return best; |
393 | 457 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
458 mp_msg(MSGT_VO, MSGL_DBG2, "First working mode: %dx%d\n", best->xres, best->yres); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
459 mp_msg(MSGT_VO, MSGL_DBG2, "Searching for better modes\n"); |
950 | 460 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
461 for (curr = best + 1; i < nr_modes - 1; i++, curr++) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
462 if (!mode_works(curr, hfreq, vfreq, dotclock)) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
463 continue; |
1561 | 464 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
465 if (best->xres < xres || best->yres < yres) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
466 if (curr->xres > best->xres || curr->yres > best->yres) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
467 mp_msg(MSGT_VO, MSGL_DBG2, "better than %dx%d, which is too small.\n", |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
468 best->xres, best->yres); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
469 best = curr; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
470 } else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
471 mp_msg(MSGT_VO, MSGL_DBG2, "too small.\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
472 } else if (curr->xres == best->xres && curr->yres == best->yres && |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
473 vsf(curr) > vsf(best)) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
474 mp_msg(MSGT_VO, MSGL_DBG2, "faster screen refresh.\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
475 best = curr; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
476 } else if ((curr->xres <= best->xres && curr->yres <= best->yres) && |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
477 (curr->xres >= xres && curr->yres >= yres)) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
478 mp_msg(MSGT_VO, MSGL_DBG2, "better than %dx%d, which is too large.\n", |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
479 best->xres, best->yres); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
480 best = curr; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
481 } else { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
482 if (curr->xres < xres || curr->yres < yres) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
483 mp_msg(MSGT_VO, MSGL_DBG2, "too small.\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
484 else if (curr->xres > best->xres || curr->yres > best->yres) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
485 mp_msg(MSGT_VO, MSGL_DBG2, "too large.\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
486 else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
487 mp_msg(MSGT_VO, MSGL_DBG2, "it's worse, don't know why.\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
488 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
489 } |
1561 | 490 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
491 return best; |
393 | 492 } |
493 | |
33202 | 494 static void set_bpp(struct fb_var_screeninfo *p, int bpp, int rgb) |
418 | 495 { |
29354 | 496 p->bits_per_pixel = FFALIGN(bpp, 2); |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
497 p->red.msb_right = p->green.msb_right = p->blue.msb_right = p->transp.msb_right = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
498 p->transp.offset = p->transp.length = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
499 p->blue.offset = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
500 switch (bpp) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
501 case 32: |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
502 p->transp.offset = 24; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
503 p->transp.length = 8; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
504 case 24: |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
505 p->red.offset = 16; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
506 p->red.length = 8; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
507 p->green.offset = 8; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
508 p->green.length = 8; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
509 p->blue.length = 8; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
510 break; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
511 case 16: |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
512 p->red.offset = 11; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
513 p->green.length = 6; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
514 p->red.length = 5; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
515 p->green.offset = 5; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
516 p->blue.length = 5; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
517 break; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
518 case 15: |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
519 p->red.offset = 10; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
520 p->green.length = 5; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
521 p->red.length = 5; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
522 p->green.offset = 5; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
523 p->blue.length = 5; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
524 break; |
31082
92f88bb315c5
Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents:
30817
diff
changeset
|
525 case 12: |
92f88bb315c5
Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents:
30817
diff
changeset
|
526 p->red.offset = 8; |
92f88bb315c5
Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents:
30817
diff
changeset
|
527 p->green.length = 4; |
92f88bb315c5
Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents:
30817
diff
changeset
|
528 p->red.length = 4; |
92f88bb315c5
Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents:
30817
diff
changeset
|
529 p->green.offset = 4; |
92f88bb315c5
Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents:
30817
diff
changeset
|
530 p->blue.length = 4; |
92f88bb315c5
Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents:
30817
diff
changeset
|
531 break; |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
532 } |
33202 | 533 if (rgb) { |
534 p->blue.offset = p->red.offset; | |
535 p->red.offset = 0; | |
536 } | |
418 | 537 } |
538 | |
33202 | 539 static void fb_mode2fb_vinfo(fb_mode_t *m, struct fb_var_screeninfo *v, int rgb) |
418 | 540 { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
541 v->xres = m->xres; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
542 v->yres = m->yres; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
543 v->xres_virtual = m->vxres; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
544 v->yres_virtual = m->vyres; |
33202 | 545 set_bpp(v, m->depth, rgb); |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
546 v->pixclock = m->pixclock; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
547 v->left_margin = m->left; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
548 v->right_margin = m->right; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
549 v->upper_margin = m->upper; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
550 v->lower_margin = m->lower; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
551 v->hsync_len = m->hslen; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
552 v->vsync_len = m->vslen; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
553 v->sync = m->sync; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
554 v->vmode = m->vmode; |
418 | 555 } |
556 | |
557 | |
359 | 558 /****************************** |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
559 * vo_fbdev * |
359 | 560 ******************************/ |
561 | |
658 | 562 /* command line/config file options */ |
27965 | 563 static char *fb_dev_name = NULL; |
10618
7901f7d6e0eb
4x10l fix. Vars used by the config layer must be malloc'd (strdup) as they will be freed at exit.
alex
parents:
10578
diff
changeset
|
564 char *fb_mode_cfgfile = NULL; |
393 | 565 char *fb_mode_name = NULL; |
418 | 566 |
658 | 567 static fb_mode_t *fb_mode = NULL; |
393 | 568 |
658 | 569 /* vo_fbdev related variables */ |
225 | 570 static int fb_dev_fd; |
10576 | 571 static int fb_tty_fd = -1; |
35055 | 572 static int fb_omap; |
225 | 573 static size_t fb_size; |
574 static uint8_t *frame_buffer; | |
27955 | 575 static uint8_t *center; |
359 | 576 static struct fb_fix_screeninfo fb_finfo; |
577 static struct fb_var_screeninfo fb_orig_vinfo; | |
578 static struct fb_var_screeninfo fb_vinfo; | |
17637
479b64764d9e
Fix colormap save/restore for directcolor fb devices
pacman
parents:
16171
diff
changeset
|
579 static unsigned short fb_ored[256], fb_ogreen[256], fb_oblue[256]; |
479b64764d9e
Fix colormap save/restore for directcolor fb devices
pacman
parents:
16171
diff
changeset
|
580 static struct fb_cmap fb_oldcmap = { 0, 256, fb_ored, fb_ogreen, fb_oblue }; |
481 | 581 static int fb_cmap_changed = 0; |
33202 | 582 static int fb_rgb; |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
583 static int fb_pixel_size; // 32: 4 24: 3 16: 2 15: 2 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
584 static int fb_bpp; // 32: 32 24: 24 16: 16 15: 15 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
585 static int fb_bpp_we_want; // 32: 32 24: 24 16: 16 15: 15 |
950 | 586 static int fb_line_len; |
587 static int fb_xres; | |
588 static int fb_yres; | |
30816 | 589 static int fb_page; |
658 | 590 static void (*draw_alpha_p)(int w, int h, unsigned char *src, |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
591 unsigned char *srca, int stride, |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
592 unsigned char *dst, int dstride); |
359 | 593 |
225 | 594 static int in_width; |
595 static int in_height; | |
596 static int out_width; | |
597 static int out_height; | |
950 | 598 static int first_row; |
599 static int last_row; | |
225 | 600 static uint32_t pixel_format; |
804 | 601 static int fs; |
225 | 602 |
305 | 603 /* |
604 * Note: this function is completely cut'n'pasted from | |
605 * Chris Lawrence's code. | |
311 | 606 * (modified a bit to fit in my code...) |
305 | 607 */ |
10426
c3345a8fbc57
removed yv12 support, but left some swscaler support for fast 15 vs 16bpp conversion
alex
parents:
9941
diff
changeset
|
608 static struct fb_cmap *make_directcolor_cmap(struct fb_var_screeninfo *var) |
305 | 609 { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
610 /* Hopefully any DIRECTCOLOR device will have a big enough palette |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
611 * to handle mapping the full color depth. |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
612 * e.g. 8 bpp -> 256 entry palette |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
613 * |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
614 * We could handle some sort of gamma here |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
615 */ |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
616 int i, cols, rcols, gcols, bcols; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
617 uint16_t *red, *green, *blue; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
618 struct fb_cmap *cmap; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
619 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
620 rcols = 1 << var->red.length; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
621 gcols = 1 << var->green.length; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
622 bcols = 1 << var->blue.length; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
623 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
624 /* Make our palette the length of the deepest color */ |
29354 | 625 cols = FFMAX3(rcols, gcols, bcols); |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
626 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
627 red = malloc(cols * sizeof(red[0])); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
628 if (!red) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
629 mp_msg(MSGT_VO, MSGL_V, "Can't allocate red palette with %d entries.\n", cols); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
630 return NULL; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
631 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
632 for (i = 0; i < rcols; i++) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
633 red[i] = (65535 / (rcols - 1)) * i; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
634 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
635 green = malloc(cols * sizeof(green[0])); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
636 if (!green) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
637 mp_msg(MSGT_VO, MSGL_V, "Can't allocate green palette with %d entries.\n", cols); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
638 free(red); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
639 return NULL; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
640 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
641 for (i = 0; i < gcols; i++) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
642 green[i] = (65535 / (gcols - 1)) * i; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
643 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
644 blue = malloc(cols * sizeof(blue[0])); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
645 if (!blue) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
646 mp_msg(MSGT_VO, MSGL_V, "Can't allocate blue palette with %d entries.\n", cols); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
647 free(red); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
648 free(green); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
649 return NULL; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
650 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
651 for (i = 0; i < bcols; i++) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
652 blue[i] = (65535 / (bcols - 1)) * i; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
653 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
654 cmap = malloc(sizeof(struct fb_cmap)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
655 if (!cmap) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
656 mp_msg(MSGT_VO, MSGL_V, "Can't allocate color map\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
657 free(red); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
658 free(green); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
659 free(blue); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
660 return NULL; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
661 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
662 cmap->start = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
663 cmap->transp = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
664 cmap->len = cols; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
665 cmap->red = red; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
666 cmap->blue = blue; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
667 cmap->green = green; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
668 cmap->transp = NULL; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
669 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
670 return cmap; |
305 | 671 } |
225 | 672 |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
673 |
10426
c3345a8fbc57
removed yv12 support, but left some swscaler support for fast 15 vs 16bpp conversion
alex
parents:
9941
diff
changeset
|
674 static int fb_preinit(int reset) |
225 | 675 { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
676 static int fb_preinit_done = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
677 static int fb_works = 0; |
950 | 678 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
679 if (reset) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
680 fb_preinit_done = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
681 return 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
682 } |
10426
c3345a8fbc57
removed yv12 support, but left some swscaler support for fast 15 vs 16bpp conversion
alex
parents:
9941
diff
changeset
|
683 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
684 if (fb_preinit_done) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
685 return fb_works; |
950 | 686 |
29355
288044ae1f9a
Use a single err_out in fb_preinit, also fixes a leak when vo_dbpp has an
reimar
parents:
29354
diff
changeset
|
687 fb_dev_fd = fb_tty_fd = -1; |
288044ae1f9a
Use a single err_out in fb_preinit, also fixes a leak when vo_dbpp has an
reimar
parents:
29354
diff
changeset
|
688 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
689 if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER"))) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
690 fb_dev_name = strdup("/dev/fb0"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
691 mp_msg(MSGT_VO, MSGL_V, "using %s\n", fb_dev_name); |
225 | 692 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
693 if ((fb_dev_fd = open(fb_dev_name, O_RDWR)) == -1) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
694 mp_msg(MSGT_VO, MSGL_ERR, "Can't open %s: %s\n", fb_dev_name, strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
695 goto err_out; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
696 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
697 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
698 mp_msg(MSGT_VO, MSGL_ERR, "Can't get VSCREENINFO: %s\n", strerror(errno)); |
29355
288044ae1f9a
Use a single err_out in fb_preinit, also fixes a leak when vo_dbpp has an
reimar
parents:
29354
diff
changeset
|
699 goto err_out; |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
700 } |
35055 | 701 // random ioctl to check if we seem to run on OMAPFB |
702 #define OMAPFB_SYNC_GFX (('O' << 8) | 37) | |
703 fb_omap = ioctl(fb_dev_fd, OMAPFB_SYNC_GFX) == 0; | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
704 fb_orig_vinfo = fb_vinfo; |
393 | 705 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
706 if ((fb_tty_fd = open("/dev/tty", O_RDWR)) < 0) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
707 mp_msg(MSGT_VO, MSGL_ERR, "notice: Can't open /dev/tty: %s\n", strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
708 } |
2354
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
709 |
33202 | 710 fb_rgb = !fb_vinfo.red.offset; |
30206 | 711 fb_bpp = fb_vinfo.bits_per_pixel; |
712 if (fb_bpp == 16) | |
713 fb_bpp = fb_vinfo.red.length + fb_vinfo.green.length + fb_vinfo.blue.length; | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
714 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
715 if (fb_bpp == 8 && !vo_dbpp) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
716 mp_msg(MSGT_VO, MSGL_ERR, "8 bpp output is not supported.\n"); |
29355
288044ae1f9a
Use a single err_out in fb_preinit, also fixes a leak when vo_dbpp has an
reimar
parents:
29354
diff
changeset
|
717 goto err_out; |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
718 } |
663 | 719 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
720 if (vo_dbpp) { |
31082
92f88bb315c5
Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents:
30817
diff
changeset
|
721 if (vo_dbpp != 12 && vo_dbpp != 15 && vo_dbpp != 16 |
92f88bb315c5
Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents:
30817
diff
changeset
|
722 && vo_dbpp != 24 && vo_dbpp != 32) { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
723 mp_msg(MSGT_VO, MSGL_ERR, "can't switch to %d bpp\n", vo_dbpp); |
29355
288044ae1f9a
Use a single err_out in fb_preinit, also fixes a leak when vo_dbpp has an
reimar
parents:
29354
diff
changeset
|
724 goto err_out; |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
725 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
726 fb_bpp = vo_dbpp; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
727 } |
1076 | 728 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
729 if (!fb_mode_cfgfile) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
730 fb_mode_cfgfile = strdup("/etc/fb.modes"); |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
731 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
732 fb_preinit_done = 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
733 fb_works = 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
734 return 1; |
29355
288044ae1f9a
Use a single err_out in fb_preinit, also fixes a leak when vo_dbpp has an
reimar
parents:
29354
diff
changeset
|
735 err_out: |
288044ae1f9a
Use a single err_out in fb_preinit, also fixes a leak when vo_dbpp has an
reimar
parents:
29354
diff
changeset
|
736 if (fb_tty_fd != -1) |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
737 close(fb_tty_fd); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
738 fb_tty_fd = -1; |
29355
288044ae1f9a
Use a single err_out in fb_preinit, also fixes a leak when vo_dbpp has an
reimar
parents:
29354
diff
changeset
|
739 if (fb_dev_fd != -1) |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
740 close(fb_dev_fd); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
741 fb_dev_fd = -1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
742 fb_preinit_done = 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
743 fb_works = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
744 return 0; |
393 | 745 } |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
746 |
950 | 747 static void vt_set_textarea(int u, int l) |
748 { | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
749 /* how can I determine the font height? |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
750 * just use 16 for now |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
751 */ |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
752 int urow = ((u + 15) / 16) + 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
753 int lrow = l / 16; |
950 | 754 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
755 mp_msg(MSGT_VO, MSGL_DBG2, "vt_set_textarea(%d,%d): %d,%d\n", u, l, urow, lrow); |
30804 | 756 if (fb_tty_fd >= 0) { |
757 char modestring[100]; | |
758 snprintf(modestring, sizeof(modestring), "\33[%d;%dr\33[%d;%dH", urow, lrow, lrow, 0); | |
759 write(fb_tty_fd, modestring, strlen(modestring)); | |
760 fsync(fb_tty_fd); | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
761 } |
950 | 762 } |
763 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
764 static int config(uint32_t width, uint32_t height, uint32_t d_width, |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
765 uint32_t d_height, uint32_t flags, char *title, |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
766 uint32_t format) |
393 | 767 { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
768 struct fb_cmap *cmap; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
769 int vm = flags & VOFLAG_MODESWITCHING; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
770 int zoom = flags & VOFLAG_SWSCALE; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
771 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
772 fs = flags & VOFLAG_FULLSCREEN; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
773 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
774 if (pre_init_err == -2) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
775 mp_msg(MSGT_VO, MSGL_ERR, "Internal fatal error: config() was called before preinit()\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
776 return -1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
777 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
778 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
779 if (pre_init_err) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
780 return 1; |
418 | 781 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
782 if (fb_mode_name && !vm) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
783 mp_msg(MSGT_VO, MSGL_ERR, "-fbmode can only be used with -vm\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
784 return 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
785 } |
29352 | 786 if (vm && parse_fbmode_cfg(fb_mode_cfgfile) < 0) |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
787 return 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
788 if (d_width && (fs || vm)) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
789 out_width = d_width; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
790 out_height = d_height; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
791 } else { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
792 out_width = width; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
793 out_height = height; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
794 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
795 in_width = width; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
796 in_height = height; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
797 pixel_format = format; |
4380 | 798 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
799 if (fb_mode_name) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
800 if (!(fb_mode = find_mode_by_name(fb_mode_name))) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
801 mp_msg(MSGT_VO, MSGL_ERR, "can't find requested video mode\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
802 return 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
803 } |
33202 | 804 fb_mode2fb_vinfo(fb_mode, &fb_vinfo, fb_rgb); |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
805 } else if (vm) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
806 monitor_hfreq = str2range(monitor_hfreq_str); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
807 monitor_vfreq = str2range(monitor_vfreq_str); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
808 monitor_dotclock = str2range(monitor_dotclock_str); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
809 if (!monitor_hfreq || !monitor_vfreq || !monitor_dotclock) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
810 mp_msg(MSGT_VO, MSGL_ERR, "you have to specify the capabilities of" |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
811 " the monitor.\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
812 return 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
813 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
814 if (!(fb_mode = find_best_mode(out_width, out_height, monitor_hfreq, |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
815 monitor_vfreq, monitor_dotclock))) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
816 mp_msg(MSGT_VO, MSGL_ERR, "can't find best video mode\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
817 return 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
818 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
819 mp_msg(MSGT_VO, MSGL_V, "using mode %dx%d @ %.1fHz\n", fb_mode->xres, |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
820 fb_mode->yres, vsf(fb_mode)); |
33202 | 821 fb_mode2fb_vinfo(fb_mode, &fb_vinfo, fb_rgb); |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
822 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
823 fb_bpp_we_want = fb_bpp; |
33202 | 824 set_bpp(&fb_vinfo, fb_bpp, fb_rgb); |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
825 fb_vinfo.xres_virtual = fb_vinfo.xres; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
826 fb_vinfo.yres_virtual = fb_vinfo.yres; |
30816 | 827 fb_page = 0; |
828 if (vo_doublebuffering) { | |
829 fb_vinfo.yres_virtual <<= 1; | |
830 fb_vinfo.yoffset = 0; | |
831 fb_page = 1; // start writing into the page we don't display | |
832 } | |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
833 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
834 if (fb_tty_fd >= 0 && ioctl(fb_tty_fd, KDSETMODE, KD_GRAPHICS) < 0) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
835 mp_msg(MSGT_VO, MSGL_V, "Can't set graphics mode: %s\n", strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
836 close(fb_tty_fd); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
837 fb_tty_fd = -1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
838 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
839 |
30206 | 840 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) |
841 // Intel drivers fail if we request a transparency channel | |
842 fb_vinfo.transp.length = fb_vinfo.transp.offset = 0; | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
843 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
844 mp_msg(MSGT_VO, MSGL_ERR, "Can't put VSCREENINFO: %s\n", strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
845 if (fb_tty_fd >= 0 && ioctl(fb_tty_fd, KDSETMODE, KD_TEXT) < 0) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
846 mp_msg(MSGT_VO, MSGL_ERR, "Can't restore text mode: %s\n", strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
847 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
848 return 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
849 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
850 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
851 fb_pixel_size = fb_vinfo.bits_per_pixel / 8; |
30206 | 852 fb_bpp = fb_vinfo.bits_per_pixel; |
853 if (fb_bpp == 16) | |
854 fb_bpp = fb_vinfo.red.length + fb_vinfo.green.length + fb_vinfo.blue.length; | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
855 if (fb_bpp_we_want != fb_bpp) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
856 mp_msg(MSGT_VO, MSGL_WARN, "requested %d bpp, got %d bpp!!!\n", |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
857 fb_bpp_we_want, fb_bpp); |
418 | 858 |
35050
b291f44d864a
Avoid some code duplication related to drawing the OSD.
reimar
parents:
33305
diff
changeset
|
859 draw_alpha_p = vo_get_draw_alpha(format); |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
860 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
861 fb_xres = fb_vinfo.xres; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
862 fb_yres = fb_vinfo.yres; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
863 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
864 if (vm || fs) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
865 out_width = fb_xres; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
866 out_height = fb_yres; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
867 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
868 if (out_width < in_width || out_height < in_height) { |
35117
91a3927fd02e
More helpful error message when video does not fit into frame buffer.
reimar
parents:
35055
diff
changeset
|
869 mp_msg(MSGT_VO, MSGL_ERR, "screensize %ix%i is smaller than video size %ix%i\n", |
91a3927fd02e
More helpful error message when video does not fit into frame buffer.
reimar
parents:
35055
diff
changeset
|
870 out_width, out_height, in_width, in_height); |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
871 return 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
872 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
873 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
874 first_row = (out_height - in_height) / 2; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
875 last_row = (out_height + in_height) / 2; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
876 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
877 if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo)) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
878 mp_msg(MSGT_VO, MSGL_ERR, "Can't get FSCREENINFO: %s\n", strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
879 return 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
880 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
881 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
882 if (fb_finfo.type != FB_TYPE_PACKED_PIXELS) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
883 mp_msg(MSGT_VO, MSGL_ERR, "type %d not supported\n", fb_finfo.type); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
884 return 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
885 } |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
886 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
887 switch (fb_finfo.visual) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
888 case FB_VISUAL_TRUECOLOR: |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
889 break; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
890 case FB_VISUAL_DIRECTCOLOR: |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
891 mp_msg(MSGT_VO, MSGL_V, "creating cmap for directcolor\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
892 if (ioctl(fb_dev_fd, FBIOGETCMAP, &fb_oldcmap)) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
893 mp_msg(MSGT_VO, MSGL_ERR, "can't get cmap: %s\n", |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
894 strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
895 return 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
896 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
897 if (!(cmap = make_directcolor_cmap(&fb_vinfo))) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
898 return 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
899 if (ioctl(fb_dev_fd, FBIOPUTCMAP, cmap)) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
900 mp_msg(MSGT_VO, MSGL_ERR, "can't put cmap: %s\n", |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
901 strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
902 return 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
903 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
904 fb_cmap_changed = 1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
905 free(cmap->red); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
906 free(cmap->green); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
907 free(cmap->blue); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
908 free(cmap); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
909 break; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
910 default: |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
911 mp_msg(MSGT_VO, MSGL_ERR, "visual: %d not yet supported\n", |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
912 fb_finfo.visual); |
35055 | 913 break; |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
914 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
915 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
916 fb_line_len = fb_finfo.line_length; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
917 fb_size = fb_finfo.smem_len; |
30816 | 918 if (vo_doublebuffering && fb_size < 2 * fb_yres * fb_line_len) |
919 { | |
920 mp_msg(MSGT_VO, MSGL_WARN, "framebuffer too small for double-buffering, disabling\n"); | |
921 vo_doublebuffering = 0; | |
922 fb_page = 0; | |
923 } | |
27983
9d1894ccd09f
Remove useless setting of frame_buffer to NULL as suggested by Reimar.
diego
parents:
27982
diff
changeset
|
924 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
925 #ifdef CONFIG_VIDIX |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
926 if (vidix_name) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
927 unsigned image_width, image_height, x_offset, y_offset; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
928 if (zoom || fs) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
929 aspect_save_orig(width, height); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
930 aspect_save_prescale(d_width, d_height); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
931 aspect_save_screenres(fb_xres, fb_yres); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
932 aspect(&image_width, &image_height, fs ? A_ZOOM : A_NOZOOM); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
933 } else { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
934 image_width = width; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
935 image_height = height; |
2354
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
936 } |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
937 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
938 if (fb_xres > image_width) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
939 x_offset = (fb_xres - image_width) / 2; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
940 else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
941 x_offset = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
942 if (fb_yres > image_height) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
943 y_offset = (fb_yres - image_height) / 2; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
944 else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
945 y_offset = 0; |
618 | 946 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
947 if (vidix_init(width, height, x_offset, y_offset, image_width, |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
948 image_height, format, fb_bpp, fb_xres, fb_yres) != 0) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
949 mp_msg(MSGT_VO, MSGL_ERR, "Can't initialize VIDIX driver\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
950 vidix_name = NULL; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
951 vidix_term(); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
952 return -1; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
953 } else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
954 mp_msg(MSGT_VO, MSGL_V, "Using VIDIX\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
955 vidix_start(); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
956 if (vidix_grkey_support()) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
957 vidix_grkey_get(&gr_key); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
958 gr_key.key_op = KEYS_PUT; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
959 if (!(vo_colorkey & 0xff000000)) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
960 gr_key.ckey.op = CKEY_TRUE; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
961 gr_key.ckey.red = (vo_colorkey & 0x00ff0000) >> 16; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
962 gr_key.ckey.green = (vo_colorkey & 0x0000ff00) >> 8; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
963 gr_key.ckey.blue = vo_colorkey & 0x000000ff; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
964 } else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
965 gr_key.ckey.op = CKEY_FALSE; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
966 vidix_grkey_set(&gr_key); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
967 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
968 } else |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
969 #endif |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
970 { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
971 int x_offset = 0, y_offset = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
972 geometry(&x_offset, &y_offset, &out_width, &out_height, fb_xres, fb_yres); |
27981
53912f852a86
Move setting of frame_buffer variable out of 'if', as preferred by Reimar.
diego
parents:
27965
diff
changeset
|
973 |
29353 | 974 frame_buffer = mmap(0, fb_size, PROT_READ | PROT_WRITE, |
975 MAP_SHARED, fb_dev_fd, 0); | |
27981
53912f852a86
Move setting of frame_buffer variable out of 'if', as preferred by Reimar.
diego
parents:
27965
diff
changeset
|
976 if (frame_buffer == (uint8_t *) -1) { |
27982 | 977 mp_msg(MSGT_VO, MSGL_ERR, "Can't mmap %s: %s\n", fb_dev_name, strerror(errno)); |
978 return 1; | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
979 } |
9517 | 980 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
981 center = frame_buffer + |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
982 ( (out_width - in_width) / 2 ) * fb_pixel_size + |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
983 ( (out_height - in_height) / 2 ) * fb_line_len + |
30816 | 984 x_offset * fb_pixel_size + y_offset * fb_line_len + |
985 fb_page * fb_yres * fb_line_len; | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
986 |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
987 mp_msg(MSGT_VO, MSGL_DBG2, "frame_buffer @ %p\n", frame_buffer); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
988 mp_msg(MSGT_VO, MSGL_DBG2, "center @ %p\n", center); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
989 mp_msg(MSGT_VO, MSGL_V, "pixel per line: %d\n", fb_line_len / fb_pixel_size); |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
7863
diff
changeset
|
990 |
30816 | 991 if (fs || vm) { |
992 int clear_size = fb_line_len * fb_yres; | |
35055 | 993 int i; |
30816 | 994 if (vo_doublebuffering) |
995 clear_size <<= 1; | |
35055 | 996 switch (format) { |
997 case IMGFMT_YUY2: | |
998 for (i = 0; i < clear_size - 3;) { | |
999 frame_buffer[i++] = 0; | |
1000 frame_buffer[i++] = 0x80; | |
1001 frame_buffer[i++] = 0; | |
1002 frame_buffer[i++] = 0x80; | |
1003 } | |
1004 break; | |
1005 case IMGFMT_UYVY: | |
1006 for (i = 0; i < clear_size - 3;) { | |
1007 frame_buffer[i++] = 0x80; | |
1008 frame_buffer[i++] = 0; | |
1009 frame_buffer[i++] = 0x80; | |
1010 frame_buffer[i++] = 0; | |
1011 } | |
1012 break; | |
1013 default: | |
1014 memset(frame_buffer, 0, clear_size); | |
1015 } | |
30816 | 1016 } |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1017 } |
225 | 1018 |
29358 | 1019 vt_set_textarea(last_row, fb_yres); |
950 | 1020 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1021 return 0; |
225 | 1022 } |
1023 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
1024 static int query_format(uint32_t format) |
225 | 1025 { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1026 if (!fb_preinit(0)) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1027 return 0; |
6851 | 1028 #ifdef CONFIG_VIDIX |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1029 if (vidix_name) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1030 return vidix_query_fourcc(format); |
6851 | 1031 #endif |
35055 | 1032 if (fb_omap && fb_vinfo.nonstd) { |
1033 if ((fb_vinfo.nonstd == 1 && format == IMGFMT_UYVY) || | |
1034 (fb_vinfo.nonstd == 8 && format == IMGFMT_YUY2)) | |
1035 return VFCAP_ACCEPT_STRIDE | VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; | |
1036 return 0; | |
1037 } | |
33202 | 1038 if ((format & IMGFMT_BGR_MASK) == (fb_rgb ? IMGFMT_RGB : IMGFMT_BGR)) { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1039 int bpp = format & 0xff; |
519 | 1040 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1041 if (bpp == fb_bpp) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1042 return VFCAP_ACCEPT_STRIDE | VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1043 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1044 return 0; |
225 | 1045 } |
1046 | |
1047 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1048 unsigned char *srca, int stride) |
225 | 1049 { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1050 unsigned char *dst; |
4210
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1051 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1052 dst = center + fb_line_len * y0 + fb_pixel_size * x0; |
359 | 1053 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1054 (*draw_alpha_p)(w, h, src, srca, stride, dst, fb_line_len); |
225 | 1055 } |
1056 | |
27954 | 1057 static int draw_frame(uint8_t *src[]) |
1058 { | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1059 return 1; |
27954 | 1060 } |
225 | 1061 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1062 static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) |
225 | 1063 { |
29360 | 1064 uint8_t *d; |
10576 | 1065 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1066 d = center + fb_line_len * y + fb_pixel_size * x; |
10576 | 1067 |
29360 | 1068 memcpy_pic2(d, src[0], w * fb_pixel_size, h, fb_line_len, stride[0], 1); |
10576 | 1069 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1070 return 0; |
225 | 1071 } |
1072 | |
1073 static void check_events(void) | |
1074 { | |
1075 } | |
1076 | |
246 | 1077 static void flip_page(void) |
1078 { | |
30816 | 1079 int next_page = !fb_page; |
1080 int page_delta = next_page - fb_page; | |
1081 #ifdef CONFIG_VIDIX | |
1082 if (vidix_name) | |
1083 return; | |
1084 #endif | |
1085 if (!vo_doublebuffering) | |
1086 return; | |
1087 | |
1088 fb_vinfo.yoffset = fb_page * fb_yres; | |
30817
e2285e7da27a
Use FBIOPAN_DISPLAY for switching between pages, seems to work for more
reimar
parents:
30816
diff
changeset
|
1089 ioctl(fb_dev_fd, FBIOPAN_DISPLAY, &fb_vinfo); |
30816 | 1090 |
1091 center += page_delta * fb_yres * fb_line_len; | |
1092 fb_page = next_page; | |
246 | 1093 } |
1094 | |
10576 | 1095 static void draw_osd(void) |
1096 { | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1097 vo_draw_text(in_width, in_height, draw_alpha); |
10576 | 1098 } |
1099 | |
225 | 1100 static void uninit(void) |
1101 { | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1102 if (fb_cmap_changed) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1103 if (ioctl(fb_dev_fd, FBIOPUTCMAP, &fb_oldcmap)) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1104 mp_msg(MSGT_VO, MSGL_WARN, "Can't restore original cmap\n"); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1105 fb_cmap_changed = 0; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1106 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1107 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1108 mp_msg(MSGT_VO, MSGL_WARN, "ioctl FBIOGET_VSCREENINFO: %s\n", strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1109 fb_orig_vinfo.xoffset = fb_vinfo.xoffset; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1110 fb_orig_vinfo.yoffset = fb_vinfo.yoffset; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1111 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_orig_vinfo)) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1112 mp_msg(MSGT_VO, MSGL_WARN, "Can't reset original fb_var_screeninfo: %s\n", strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1113 if (fb_tty_fd >= 0) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1114 if (ioctl(fb_tty_fd, KDSETMODE, KD_TEXT) < 0) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1115 mp_msg(MSGT_VO, MSGL_WARN, "Can't restore text mode: %s\n", strerror(errno)); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1116 } |
29358 | 1117 vt_set_textarea(0, fb_orig_vinfo.yres); |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1118 close(fb_tty_fd); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1119 close(fb_dev_fd); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1120 if (frame_buffer) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1121 munmap(frame_buffer, fb_size); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1122 frame_buffer = NULL; |
4089 | 1123 #ifdef CONFIG_VIDIX |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1124 if (vidix_name) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1125 vidix_term(); |
4089 | 1126 #endif |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1127 fb_preinit(1); |
225 | 1128 } |
2354
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
1129 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
1130 static int preinit(const char *vo_subdevice) |
4352 | 1131 { |
4380 | 1132 pre_init_err = 0; |
11055
497104408c30
correct handling of subdevice, -fb device is obsoleted
alex
parents:
11036
diff
changeset
|
1133 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1134 if (vo_subdevice) { |
4380 | 1135 #ifdef CONFIG_VIDIX |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1136 if (memcmp(vo_subdevice, "vidix", 5) == 0) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1137 vidix_name = &vo_subdevice[5]; |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1138 if (vidix_name) |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1139 pre_init_err = vidix_preinit(vidix_name, &video_out_fbdev); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1140 else |
4380 | 1141 #endif |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1142 { |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32467
diff
changeset
|
1143 free(fb_dev_name); |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1144 fb_dev_name = strdup(vo_subdevice); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1145 } |
11055
497104408c30
correct handling of subdevice, -fb device is obsoleted
alex
parents:
11036
diff
changeset
|
1146 } |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1147 if (!pre_init_err) |
29352 | 1148 return pre_init_err = fb_preinit(0) ? 0 : -1; |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
25216
diff
changeset
|
1149 return -1; |
4352 | 1150 } |
1151 | |
10576 | 1152 static uint32_t get_image(mp_image_t *mpi) |
1153 { | |
27954 | 1154 if (!IMGFMT_IS_BGR(mpi->imgfmt) || |
29352 | 1155 IMGFMT_BGR_DEPTH(mpi->imgfmt) != fb_bpp || |
1156 (mpi->type != MP_IMGTYPE_STATIC && mpi->type != MP_IMGTYPE_TEMP) || | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1157 (mpi->flags & MP_IMGFLAG_PLANAR) || |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1158 (mpi->flags & MP_IMGFLAG_YUV) || |
29352 | 1159 mpi->width != in_width || |
1160 mpi->height != in_height | |
10576 | 1161 ) |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1162 return VO_FALSE; |
10576 | 1163 |
1164 mpi->planes[0] = center; | |
1165 mpi->stride[0] = fb_line_len; | |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1166 mpi->flags |= MP_IMGFLAG_DIRECT; |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
25216
diff
changeset
|
1167 return VO_TRUE; |
10576 | 1168 } |
1169 | |
33305
ddb45e9443ec
Remove the variable arguments from the libvo control() functions.
iive
parents:
33301
diff
changeset
|
1170 static int control(uint32_t request, void *data) |
4352 | 1171 { |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1172 switch (request) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1173 case VOCTRL_GET_IMAGE: |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1174 return get_image(data); |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1175 case VOCTRL_QUERY_FORMAT: |
29352 | 1176 return query_format(*(uint32_t*)data); |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1177 } |
11036
8e55228b6102
vidix equalizer support by Jake Page <jake@CS.Stanford.EDU>
alex
parents:
10618
diff
changeset
|
1178 |
8e55228b6102
vidix equalizer support by Jake Page <jake@CS.Stanford.EDU>
alex
parents:
10618
diff
changeset
|
1179 #ifdef CONFIG_VIDIX |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1180 if (vidix_name) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1181 switch (request) { |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1182 case VOCTRL_SET_EQUALIZER: |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1183 case VOCTRL_GET_EQUALIZER: |
33301
899d817e56fc
Implement control() VOCTRL_SET/GET_EQUALIZER using a vf_equalize struct,
iive
parents:
33202
diff
changeset
|
1184 return vidix_control(request, data); |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1185 } |
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1186 } |
11036
8e55228b6102
vidix equalizer support by Jake Page <jake@CS.Stanford.EDU>
alex
parents:
10618
diff
changeset
|
1187 #endif |
8e55228b6102
vidix equalizer support by Jake Page <jake@CS.Stanford.EDU>
alex
parents:
10618
diff
changeset
|
1188 |
27956
95d14fb247a8
cosmetics: complete reformatting, tabs to spaces, etc.
diego
parents:
27955
diff
changeset
|
1189 return VO_NOTIMPL; |
4352 | 1190 } |