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