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