Mercurial > mplayer.hg
annotate libvo/vo_fbdev.c @ 7190:5137e9fb57e7
All RealVideo codecs liste on one line - less wasted space.
author | diego |
---|---|
date | Sat, 31 Aug 2002 13:05:33 +0000 |
parents | eca7dbad0166 |
children | f740737c54ce |
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 | |
7 */ | |
8 | |
393 | 9 #define FBDEV "fbdev: " |
10 | |
225 | 11 #include <stdio.h> |
12 #include <stdlib.h> | |
13 #include <string.h> | |
14 #include <fcntl.h> | |
15 #include <unistd.h> | |
16 #include <errno.h> | |
359 | 17 #include <ctype.h> |
18 #include <assert.h> | |
225 | 19 |
20 #include <sys/mman.h> | |
21 #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
|
22 #include <sys/kd.h> |
225 | 23 #include <linux/fb.h> |
24 | |
25 #include "config.h" | |
26 #include "video_out.h" | |
27 #include "video_out_internal.h" | |
658 | 28 #include "fastmemcpy.h" |
633 | 29 #include "sub.h" |
2556 | 30 #include "../postproc/rgb2rgb.h" |
4089 | 31 #ifdef CONFIG_VIDIX |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
32 #include "vosub_vidix.h" |
4089 | 33 #endif |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
34 #include "aspect.h" |
225 | 35 |
4756 | 36 #ifdef HAVE_PNG |
37 extern vo_functions_t video_out_png; | |
38 #endif | |
39 | |
225 | 40 LIBVO_EXTERN(fbdev) |
41 | |
42 static vo_info_t vo_info = { | |
43 "Framebuffer Device", | |
44 "fbdev", | |
45 "Szabolcs Berecz <szabi@inf.elte.hu>", | |
46 "" | |
47 }; | |
48 | |
379 | 49 extern int verbose; |
50 | |
4089 | 51 #ifdef CONFIG_VIDIX |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
52 /* Name of VIDIX driver */ |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
53 static const char *vidix_name = NULL; |
4386 | 54 #endif |
6164
aee9c32349a9
applied 64bit patch from Ulrich Hecht <uli at suse dot de>
alex
parents:
4756
diff
changeset
|
55 static signed int pre_init_err = -2; |
359 | 56 /****************************** |
393 | 57 * fb.modes support * |
359 | 58 ******************************/ |
59 | |
7069 | 60 extern char *monitor_hfreq_str; |
61 extern char *monitor_vfreq_str; | |
62 extern char *monitor_dotclock_str; | |
63 | |
64 static range_t *monitor_hfreq = NULL; | |
65 static range_t *monitor_vfreq = NULL; | |
66 static range_t *monitor_dotclock = NULL; | |
67 | |
359 | 68 typedef struct { |
69 char *name; | |
70 uint32_t xres, yres, vxres, vyres, depth; | |
71 uint32_t pixclock, left, right, upper, lower, hslen, vslen; | |
72 uint32_t sync; | |
73 uint32_t vmode; | |
74 } fb_mode_t; | |
75 | |
76 #define PRINT_LINENUM printf(" at line %d\n", line_num) | |
77 | |
78 #define MAX_NR_TOKEN 16 | |
79 | |
80 #define MAX_LINE_LEN 1000 | |
81 | |
82 #define RET_EOF -1 | |
83 #define RET_EOL -2 | |
84 | |
85 static int validate_mode(fb_mode_t *m) | |
86 { | |
87 if (!m->xres) { | |
88 printf("needs geometry "); | |
89 return 0; | |
90 } | |
91 if (!m->pixclock) { | |
92 printf("needs timings "); | |
93 return 0; | |
94 } | |
95 return 1; | |
96 } | |
97 | |
98 static FILE *fp; | |
99 static int line_num = 0; | |
100 static char *line; | |
101 static char *token[MAX_NR_TOKEN]; | |
4756 | 102 static uint32_t dstFourcc; |
359 | 103 |
104 static int get_token(int num) | |
105 { | |
106 static int read_nextline = 1; | |
107 static int line_pos; | |
108 int i; | |
109 char c; | |
110 | |
111 if (num >= MAX_NR_TOKEN) { | |
112 printf("get_token(): max >= MAX_NR_TOKEN!"); | |
113 goto out_eof; | |
114 } | |
115 | |
116 if (read_nextline) { | |
117 if (!fgets(line, MAX_LINE_LEN, fp)) | |
118 goto out_eof; | |
119 line_pos = 0; | |
120 ++line_num; | |
121 read_nextline = 0; | |
122 } | |
123 for (i = 0; i < num; i++) { | |
124 while (isspace(line[line_pos])) | |
125 ++line_pos; | |
126 if (line[line_pos] == '\0' || line[line_pos] == '#') { | |
127 read_nextline = 1; | |
128 goto out_eol; | |
129 } | |
130 token[i] = line + line_pos; | |
131 c = line[line_pos]; | |
132 if (c == '"' || c == '\'') { | |
133 token[i]++; | |
134 while (line[++line_pos] != c && line[line_pos]) | |
135 /* NOTHING */; | |
950 | 136 if (!line[line_pos]) |
137 goto out_eol; | |
138 line[line_pos] = ' '; | |
359 | 139 } else { |
140 for (/* NOTHING */; !isspace(line[line_pos]) && | |
141 line[line_pos]; line_pos++) | |
142 /* NOTHING */; | |
143 } | |
144 if (!line[line_pos]) { | |
145 read_nextline = 1; | |
146 if (i == num - 1) | |
147 goto out_ok; | |
148 goto out_eol; | |
149 } | |
950 | 150 line[line_pos++] = '\0'; |
359 | 151 } |
152 out_ok: | |
153 return i; | |
154 out_eof: | |
155 return RET_EOF; | |
156 out_eol: | |
157 return RET_EOL; | |
158 } | |
159 | |
160 static fb_mode_t *fb_modes = NULL; | |
161 static int nr_modes = 0; | |
162 | |
163 static int parse_fbmode_cfg(char *cfgfile) | |
164 { | |
977 | 165 #define CHECK_IN_MODE_DEF\ |
166 do {\ | |
167 if (!in_mode_def) {\ | |
168 printf("'needs 'mode' first");\ | |
169 goto err_out_print_linenum;\ | |
170 }\ | |
171 } while (0) | |
172 | |
359 | 173 fb_mode_t *mode = NULL; |
174 char *endptr; // strtoul()... | |
977 | 175 int in_mode_def = 0; |
359 | 176 int tmp, i; |
177 | |
950 | 178 if (verbose > 0) |
179 printf("Reading %s: ", cfgfile); | |
359 | 180 |
181 if ((fp = fopen(cfgfile, "r")) == NULL) { | |
182 printf("can't open '%s': %s\n", cfgfile, strerror(errno)); | |
183 return -1; | |
184 } | |
185 | |
186 if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) { | |
187 printf("can't get memory for 'line': %s\n", strerror(errno)); | |
188 return -2; | |
189 } | |
190 | |
191 /* | |
192 * check if the cfgfile starts with 'mode' | |
193 */ | |
194 while ((tmp = get_token(1)) == RET_EOL) | |
195 /* NOTHING */; | |
196 if (tmp == RET_EOF) | |
197 goto out; | |
198 if (!strcmp(token[0], "mode")) | |
199 goto loop_enter; | |
200 goto err_out_parse_error; | |
201 | |
202 while ((tmp = get_token(1)) != RET_EOF) { | |
203 if (tmp == RET_EOL) | |
204 continue; | |
205 if (!strcmp(token[0], "mode")) { | |
977 | 206 if (in_mode_def) { |
207 printf("'endmode' required"); | |
208 goto err_out_print_linenum; | |
209 } | |
359 | 210 if (!validate_mode(mode)) |
211 goto err_out_not_valid; | |
212 loop_enter: | |
213 if (!(fb_modes = (fb_mode_t *) realloc(fb_modes, | |
214 sizeof(fb_mode_t) * (nr_modes + 1)))) { | |
950 | 215 printf("can't realloc 'fb_modes' (nr_modes = %d):" |
216 " %s\n", nr_modes, strerror(errno)); | |
359 | 217 goto err_out; |
218 } | |
219 mode=fb_modes + nr_modes; | |
220 ++nr_modes; | |
221 memset(mode,0,sizeof(fb_mode_t)); | |
225 | 222 |
359 | 223 if (get_token(1) < 0) |
224 goto err_out_parse_error; | |
225 for (i = 0; i < nr_modes - 1; i++) { | |
226 if (!strcmp(token[0], fb_modes[i].name)) { | |
227 printf("mode name '%s' isn't unique", token[0]); | |
228 goto err_out_print_linenum; | |
229 } | |
230 } | |
231 if (!(mode->name = strdup(token[0]))) { | |
232 printf("can't strdup -> 'name': %s\n", strerror(errno)); | |
233 goto err_out; | |
234 } | |
977 | 235 in_mode_def = 1; |
359 | 236 } else if (!strcmp(token[0], "geometry")) { |
977 | 237 CHECK_IN_MODE_DEF; |
359 | 238 if (get_token(5) < 0) |
239 goto err_out_parse_error; | |
240 mode->xres = strtoul(token[0], &endptr, 0); | |
241 if (*endptr) | |
242 goto err_out_parse_error; | |
243 mode->yres = strtoul(token[1], &endptr, 0); | |
244 if (*endptr) | |
245 goto err_out_parse_error; | |
246 mode->vxres = strtoul(token[2], &endptr, 0); | |
247 if (*endptr) | |
248 goto err_out_parse_error; | |
249 mode->vyres = strtoul(token[3], &endptr, 0); | |
250 if (*endptr) | |
251 goto err_out_parse_error; | |
252 mode->depth = strtoul(token[4], &endptr, 0); | |
253 if (*endptr) | |
254 goto err_out_parse_error; | |
255 } else if (!strcmp(token[0], "timings")) { | |
977 | 256 CHECK_IN_MODE_DEF; |
359 | 257 if (get_token(7) < 0) |
258 goto err_out_parse_error; | |
259 mode->pixclock = strtoul(token[0], &endptr, 0); | |
260 if (*endptr) | |
261 goto err_out_parse_error; | |
262 mode->left = strtoul(token[1], &endptr, 0); | |
263 if (*endptr) | |
264 goto err_out_parse_error; | |
265 mode->right = strtoul(token[2], &endptr, 0); | |
266 if (*endptr) | |
267 goto err_out_parse_error; | |
268 mode->upper = strtoul(token[3], &endptr, 0); | |
269 if (*endptr) | |
270 goto err_out_parse_error; | |
271 mode->lower = strtoul(token[4], &endptr, 0); | |
272 if (*endptr) | |
273 goto err_out_parse_error; | |
274 mode->hslen = strtoul(token[5], &endptr, 0); | |
275 if (*endptr) | |
276 goto err_out_parse_error; | |
277 mode->vslen = strtoul(token[6], &endptr, 0); | |
278 if (*endptr) | |
279 goto err_out_parse_error; | |
280 } else if (!strcmp(token[0], "endmode")) { | |
977 | 281 CHECK_IN_MODE_DEF; |
282 in_mode_def = 0; | |
383 | 283 } else if (!strcmp(token[0], "accel")) { |
977 | 284 CHECK_IN_MODE_DEF; |
383 | 285 if (get_token(1) < 0) |
286 goto err_out_parse_error; | |
393 | 287 /* |
288 * it's only used for text acceleration | |
289 * so we just ignore it. | |
290 */ | |
359 | 291 } else if (!strcmp(token[0], "hsync")) { |
977 | 292 CHECK_IN_MODE_DEF; |
359 | 293 if (get_token(1) < 0) |
294 goto err_out_parse_error; | |
295 if (!strcmp(token[0], "low")) | |
296 mode->sync &= ~FB_SYNC_HOR_HIGH_ACT; | |
297 else if(!strcmp(token[0], "high")) | |
298 mode->sync |= FB_SYNC_HOR_HIGH_ACT; | |
299 else | |
300 goto err_out_parse_error; | |
301 } else if (!strcmp(token[0], "vsync")) { | |
977 | 302 CHECK_IN_MODE_DEF; |
359 | 303 if (get_token(1) < 0) |
304 goto err_out_parse_error; | |
305 if (!strcmp(token[0], "low")) | |
306 mode->sync &= ~FB_SYNC_VERT_HIGH_ACT; | |
307 else if(!strcmp(token[0], "high")) | |
308 mode->sync |= FB_SYNC_VERT_HIGH_ACT; | |
309 else | |
310 goto err_out_parse_error; | |
311 } else if (!strcmp(token[0], "csync")) { | |
977 | 312 CHECK_IN_MODE_DEF; |
359 | 313 if (get_token(1) < 0) |
314 goto err_out_parse_error; | |
315 if (!strcmp(token[0], "low")) | |
316 mode->sync &= ~FB_SYNC_COMP_HIGH_ACT; | |
317 else if(!strcmp(token[0], "high")) | |
318 mode->sync |= FB_SYNC_COMP_HIGH_ACT; | |
319 else | |
320 goto err_out_parse_error; | |
321 } else if (!strcmp(token[0], "extsync")) { | |
977 | 322 CHECK_IN_MODE_DEF; |
359 | 323 if (get_token(1) < 0) |
324 goto err_out_parse_error; | |
325 if (!strcmp(token[0], "false")) | |
326 mode->sync &= ~FB_SYNC_EXT; | |
327 else if(!strcmp(token[0], "true")) | |
328 mode->sync |= FB_SYNC_EXT; | |
329 else | |
330 goto err_out_parse_error; | |
331 } else if (!strcmp(token[0], "laced")) { | |
977 | 332 CHECK_IN_MODE_DEF; |
359 | 333 if (get_token(1) < 0) |
334 goto err_out_parse_error; | |
335 if (!strcmp(token[0], "false")) | |
336 mode->vmode = FB_VMODE_NONINTERLACED; | |
337 else if (!strcmp(token[0], "true")) | |
338 mode->vmode = FB_VMODE_INTERLACED; | |
339 else | |
340 goto err_out_parse_error; | |
479 | 341 } else if (!strcmp(token[0], "double")) { |
977 | 342 CHECK_IN_MODE_DEF; |
359 | 343 if (get_token(1) < 0) |
344 goto err_out_parse_error; | |
345 if (!strcmp(token[0], "false")) | |
346 ; | |
347 else if (!strcmp(token[0], "true")) | |
348 mode->vmode = FB_VMODE_DOUBLE; | |
349 else | |
350 goto err_out_parse_error; | |
351 } else | |
352 goto err_out_parse_error; | |
353 } | |
354 if (!validate_mode(mode)) | |
355 goto err_out_not_valid; | |
356 out: | |
950 | 357 if (verbose > 0) |
358 printf("%d modes\n", nr_modes); | |
359 | 359 free(line); |
360 fclose(fp); | |
361 return nr_modes; | |
362 err_out_parse_error: | |
363 printf("parse error"); | |
364 err_out_print_linenum: | |
365 PRINT_LINENUM; | |
366 err_out: | |
393 | 367 if (fb_modes) { |
359 | 368 free(fb_modes); |
393 | 369 fb_modes = NULL; |
370 } | |
371 nr_modes = 0; | |
359 | 372 free(line); |
373 free(fp); | |
374 return -2; | |
375 err_out_not_valid: | |
950 | 376 printf("previous mode is not correct"); |
359 | 377 goto err_out_print_linenum; |
378 } | |
379 | |
380 static fb_mode_t *find_mode_by_name(char *name) | |
381 { | |
382 int i; | |
383 | |
658 | 384 for (i = 0; i < nr_modes; i++) |
359 | 385 if (!strcmp(name, fb_modes[i].name)) |
386 return fb_modes + i; | |
387 return NULL; | |
388 } | |
389 | |
393 | 390 static float dcf(fb_mode_t *m) //driving clock frequency |
391 { | |
519 | 392 return 1e12f / m->pixclock; |
393 | 393 } |
394 | |
395 static float hsf(fb_mode_t *m) //horizontal scan frequency | |
396 { | |
397 int htotal = m->left + m->xres + m->right + m->hslen; | |
398 return dcf(m) / htotal; | |
399 } | |
400 | |
401 static float vsf(fb_mode_t *m) //vertical scan frequency | |
402 { | |
403 int vtotal = m->upper + m->yres + m->lower + m->vslen; | |
404 return hsf(m) / vtotal; | |
405 } | |
406 | |
407 | |
1561 | 408 static int mode_works(fb_mode_t *m, range_t *hfreq, range_t *vfreq, |
409 range_t *dotclock) | |
410 { | |
411 float h = hsf(m); | |
412 float v = vsf(m); | |
413 float d = dcf(m); | |
414 int ret = 1; | |
415 | |
416 if (verbose > 1) | |
417 printf(FBDEV "mode %dx%d:", m->xres, m->yres); | |
418 if (!in_range(hfreq, h)) { | |
419 ret = 0; | |
420 if (verbose > 1) | |
421 printf(" hsync out of range."); | |
422 } | |
423 if (!in_range(vfreq, v)) { | |
424 ret = 0; | |
425 if (verbose > 1) | |
426 printf(" vsync out of range."); | |
427 } | |
428 if (!in_range(dotclock, d)) { | |
429 ret = 0; | |
430 if (verbose > 1) | |
431 printf(" dotclock out of range."); | |
432 } | |
433 if (verbose > 1) { | |
434 if (ret) | |
435 printf(" hsync, vsync, dotclock ok.\n"); | |
436 else | |
437 printf("\n"); | |
438 } | |
439 | |
440 return ret; | |
441 } | |
442 | |
418 | 443 static fb_mode_t *find_best_mode(int xres, int yres, range_t *hfreq, |
444 range_t *vfreq, range_t *dotclock) | |
393 | 445 { |
446 int i; | |
447 fb_mode_t *best = fb_modes; | |
519 | 448 fb_mode_t *curr; |
449 | |
1561 | 450 if (verbose > 1) |
451 printf(FBDEV "Searching for first working mode\n"); | |
452 | |
950 | 453 for (i = 0; i < nr_modes; i++, best++) |
1561 | 454 if (mode_works(best, hfreq, vfreq, dotclock)) |
519 | 455 break; |
456 | |
950 | 457 if (i == nr_modes) |
519 | 458 return NULL; |
950 | 459 if (i == nr_modes - 1) |
519 | 460 return best; |
393 | 461 |
1561 | 462 if (verbose > 1) { |
463 printf(FBDEV "First working mode: %dx%d\n", best->xres, best->yres); | |
464 printf(FBDEV "Searching for better modes\n"); | |
465 } | |
950 | 466 |
1561 | 467 for (curr = best + 1; i < nr_modes - 1; i++, curr++) { |
468 if (!mode_works(curr, hfreq, vfreq, dotclock)) | |
519 | 469 continue; |
1561 | 470 |
519 | 471 if (verbose > 1) |
1561 | 472 printf(FBDEV); |
473 | |
474 if (best->xres < xres || best->yres < yres) { | |
475 if (curr->xres > best->xres || curr->yres > best->yres) { | |
519 | 476 if (verbose > 1) |
1561 | 477 printf("better than %dx%d, which is too small.\n", |
519 | 478 best->xres, best->yres); |
393 | 479 best = curr; |
519 | 480 } else if (verbose > 1) |
1561 | 481 printf("too small.\n"); |
482 } else if (curr->xres == best->xres && curr->yres == best->yres && | |
483 vsf(curr) > vsf(best)) { | |
484 if (verbose > 1) | |
485 printf("faster screen refresh.\n"); | |
486 best = curr; | |
487 } else if ((curr->xres <= best->xres && curr->yres <= best->yres) && | |
488 (curr->xres >= xres && curr->yres >= yres)) { | |
489 if (verbose > 1) | |
490 printf("better than %dx%d, which is too large.\n", | |
491 best->xres, best->yres); | |
492 best = curr; | |
493 } else if (verbose > 1) { | |
494 if (curr->xres < xres || curr->yres < yres) | |
495 printf("too small.\n"); | |
496 else if (curr->xres > best->xres || curr->yres > best->yres) | |
497 printf("too large.\n"); | |
498 else printf("it's worse, don't know why.\n"); | |
499 } | |
393 | 500 } |
1561 | 501 |
393 | 502 return best; |
503 } | |
504 | |
418 | 505 static void set_bpp(struct fb_var_screeninfo *p, int bpp) |
506 { | |
476 | 507 p->bits_per_pixel = (bpp + 1) & ~1; |
1087 | 508 p->red.msb_right = p->green.msb_right = p->blue.msb_right = p->transp.msb_right = 0; |
563 | 509 p->transp.offset = p->transp.length = 0; |
950 | 510 p->blue.offset = 0; |
418 | 511 switch (bpp) { |
512 case 32: | |
563 | 513 p->transp.offset = 24; |
514 p->transp.length = 8; | |
418 | 515 case 24: |
516 p->red.offset = 16; | |
517 p->red.length = 8; | |
518 p->green.offset = 8; | |
519 p->green.length = 8; | |
550 | 520 p->blue.length = 8; |
418 | 521 break; |
522 case 16: | |
523 p->red.offset = 11; | |
550 | 524 p->green.length = 6; |
418 | 525 p->red.length = 5; |
526 p->green.offset = 5; | |
550 | 527 p->blue.length = 5; |
418 | 528 break; |
529 case 15: | |
530 p->red.offset = 10; | |
550 | 531 p->green.length = 5; |
418 | 532 p->red.length = 5; |
533 p->green.offset = 5; | |
550 | 534 p->blue.length = 5; |
418 | 535 break; |
536 } | |
537 } | |
538 | |
539 static void fb_mode2fb_vinfo(fb_mode_t *m, struct fb_var_screeninfo *v) | |
540 { | |
541 v->xres = m->xres; | |
542 v->yres = m->yres; | |
543 v->xres_virtual = m->vxres; | |
544 v->yres_virtual = m->vyres; | |
545 set_bpp(v, m->depth); | |
546 v->pixclock = m->pixclock; | |
547 v->left_margin = m->left; | |
548 v->right_margin = m->right; | |
549 v->upper_margin = m->upper; | |
550 v->lower_margin = m->lower; | |
551 v->hsync_len = m->hslen; | |
552 v->vsync_len = m->vslen; | |
553 v->sync = m->sync; | |
554 v->vmode = m->vmode; | |
555 } | |
556 | |
557 | |
359 | 558 /****************************** |
559 * vo_fbdev * | |
560 ******************************/ | |
561 | |
658 | 562 /* command line/config file options */ |
393 | 563 char *fb_dev_name = NULL; |
564 char *fb_mode_cfgfile = "/etc/fb.modes"; | |
565 char *fb_mode_name = NULL; | |
418 | 566 |
658 | 567 static fb_mode_t *fb_mode = NULL; |
393 | 568 |
950 | 569 /* vt related variables */ |
1087 | 570 static int vt_fd; |
571 static FILE *vt_fp; | |
572 static int vt_doit = 1; | |
950 | 573 |
658 | 574 /* vo_fbdev related variables */ |
225 | 575 static int fb_dev_fd; |
2354
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
576 static int fb_tty_fd; |
225 | 577 static size_t fb_size; |
578 static uint8_t *frame_buffer; | |
658 | 579 static uint8_t *L123123875; /* thx .so :) */ |
359 | 580 static struct fb_fix_screeninfo fb_finfo; |
581 static struct fb_var_screeninfo fb_orig_vinfo; | |
582 static struct fb_var_screeninfo fb_vinfo; | |
481 | 583 static struct fb_cmap fb_oldcmap; |
584 static int fb_cmap_changed = 0; | |
359 | 585 static int fb_pixel_size; // 32: 4 24: 3 16: 2 15: 2 |
586 static int fb_real_bpp; // 32: 24 24: 24 16: 16 15: 15 | |
587 static int fb_bpp; // 32: 32 24: 24 16: 16 15: 15 | |
393 | 588 static int fb_bpp_we_want; // 32: 32 24: 24 16: 16 15: 15 |
950 | 589 static int fb_line_len; |
590 static int fb_xres; | |
591 static int fb_yres; | |
658 | 592 static void (*draw_alpha_p)(int w, int h, unsigned char *src, |
593 unsigned char *srca, int stride, unsigned char *dst, | |
594 int dstride); | |
359 | 595 |
596 static uint8_t *next_frame; | |
225 | 597 static int in_width; |
598 static int in_height; | |
599 static int out_width; | |
600 static int out_height; | |
950 | 601 static int first_row; |
602 static int last_row; | |
225 | 603 static uint32_t pixel_format; |
804 | 604 static int fs; |
605 static int flip; | |
225 | 606 |
305 | 607 /* |
608 * Note: this function is completely cut'n'pasted from | |
609 * Chris Lawrence's code. | |
311 | 610 * (modified a bit to fit in my code...) |
305 | 611 */ |
612 struct fb_cmap *make_directcolor_cmap(struct fb_var_screeninfo *var) | |
613 { | |
614 /* Hopefully any DIRECTCOLOR device will have a big enough palette | |
615 * to handle mapping the full color depth. | |
616 * e.g. 8 bpp -> 256 entry palette | |
617 * | |
618 * We could handle some sort of gamma here | |
619 */ | |
620 int i, cols, rcols, gcols, bcols; | |
621 uint16_t *red, *green, *blue; | |
622 struct fb_cmap *cmap; | |
623 | |
624 rcols = 1 << var->red.length; | |
625 gcols = 1 << var->green.length; | |
626 bcols = 1 << var->blue.length; | |
627 | |
628 /* Make our palette the length of the deepest color */ | |
629 cols = (rcols > gcols ? rcols : gcols); | |
630 cols = (cols > bcols ? cols : bcols); | |
631 | |
632 red = malloc(cols * sizeof(red[0])); | |
633 if(!red) { | |
634 printf("Can't allocate red palette with %d entries.\n", cols); | |
635 return NULL; | |
636 } | |
637 for(i=0; i< rcols; i++) | |
638 red[i] = (65535/(rcols-1)) * i; | |
639 | |
640 green = malloc(cols * sizeof(green[0])); | |
641 if(!green) { | |
642 printf("Can't allocate green palette with %d entries.\n", cols); | |
643 free(red); | |
644 return NULL; | |
645 } | |
646 for(i=0; i< gcols; i++) | |
647 green[i] = (65535/(gcols-1)) * i; | |
648 | |
649 blue = malloc(cols * sizeof(blue[0])); | |
650 if(!blue) { | |
651 printf("Can't allocate blue palette with %d entries.\n", cols); | |
652 free(red); | |
653 free(green); | |
654 return NULL; | |
655 } | |
656 for(i=0; i< bcols; i++) | |
657 blue[i] = (65535/(bcols-1)) * i; | |
658 | |
659 cmap = malloc(sizeof(struct fb_cmap)); | |
660 if(!cmap) { | |
661 printf("Can't allocate color map\n"); | |
662 free(red); | |
663 free(green); | |
664 free(blue); | |
665 return NULL; | |
666 } | |
667 cmap->start = 0; | |
668 cmap->transp = 0; | |
669 cmap->len = cols; | |
670 cmap->red = red; | |
671 cmap->blue = blue; | |
672 cmap->green = green; | |
673 cmap->transp = NULL; | |
674 | |
675 return cmap; | |
676 } | |
225 | 677 |
4089 | 678 #ifdef CONFIG_VIDIX |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
679 static uint32_t parseSubDevice(const char *sd) |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
680 { |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
681 if(memcmp(sd,"vidix",5) == 0) vidix_name = &sd[5]; /* vidix_name will be valid within init() */ |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
682 else { printf(FBDEV "Unknown subdevice: '%s'\n", sd); return -1; } |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
683 return 0; |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
684 } |
4089 | 685 #endif |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
686 |
393 | 687 static int fb_preinit(void) |
225 | 688 { |
950 | 689 static int fb_preinit_done = 0; |
690 static int fb_works = 0; | |
691 | |
692 if (fb_preinit_done) | |
693 return fb_works; | |
694 | |
393 | 695 if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER"))) |
696 fb_dev_name = "/dev/fb0"; | |
697 if (verbose > 0) | |
698 printf(FBDEV "using %s\n", fb_dev_name); | |
225 | 699 |
393 | 700 if ((fb_dev_fd = open(fb_dev_name, O_RDWR)) == -1) { |
701 printf(FBDEV "Can't open %s: %s\n", fb_dev_name, strerror(errno)); | |
702 goto err_out; | |
703 } | |
704 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) { | |
705 printf(FBDEV "Can't get VSCREENINFO: %s\n", strerror(errno)); | |
706 goto err_out_fd; | |
707 } | |
418 | 708 fb_orig_vinfo = fb_vinfo; |
393 | 709 |
2354
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
710 if ((fb_tty_fd = open("/dev/tty", O_RDWR)) < 0) { |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
711 if (verbose > 0) |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
712 printf(FBDEV "notice: Can't open /dev/tty: %s\n", strerror(errno)); |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
713 } |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
714 |
663 | 715 fb_bpp = fb_vinfo.bits_per_pixel; |
716 | |
1076 | 717 if (fb_bpp == 8 && !vo_dbpp) { |
718 printf(FBDEV "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
|
719 goto err_out_tty_fd; |
1076 | 720 } |
721 | |
1561 | 722 /* 16 and 15 bpp is reported as 16 bpp */ |
663 | 723 if (fb_bpp == 16) |
724 fb_bpp = fb_vinfo.red.length + fb_vinfo.green.length + | |
725 fb_vinfo.blue.length; | |
726 | |
418 | 727 if (vo_dbpp) { |
728 if (vo_dbpp != 15 && vo_dbpp != 16 && vo_dbpp != 24 && | |
729 vo_dbpp != 32) { | |
730 printf(FBDEV "can't switch to %d bpp\n", vo_dbpp); | |
1076 | 731 goto err_out_fd; |
359 | 732 } |
418 | 733 fb_bpp = vo_dbpp; |
359 | 734 } |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
735 |
393 | 736 fb_preinit_done = 1; |
737 fb_works = 1; | |
950 | 738 return 1; |
2354
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
739 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
|
740 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
|
741 fb_tty_fd = -1; |
393 | 742 err_out_fd: |
743 close(fb_dev_fd); | |
744 fb_dev_fd = -1; | |
745 err_out: | |
746 fb_preinit_done = 1; | |
950 | 747 fb_works = 0; |
748 return 0; | |
393 | 749 } |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
750 |
633 | 751 static void lots_of_printf(void) |
752 { | |
753 if (verbose > 0) { | |
754 printf(FBDEV "var info:\n"); | |
755 printf(FBDEV "xres: %u\n", fb_vinfo.xres); | |
756 printf(FBDEV "yres: %u\n", fb_vinfo.yres); | |
757 printf(FBDEV "xres_virtual: %u\n", fb_vinfo.xres_virtual); | |
758 printf(FBDEV "yres_virtual: %u\n", fb_vinfo.yres_virtual); | |
759 printf(FBDEV "xoffset: %u\n", fb_vinfo.xoffset); | |
760 printf(FBDEV "yoffset: %u\n", fb_vinfo.yoffset); | |
761 printf(FBDEV "bits_per_pixel: %u\n", fb_vinfo.bits_per_pixel); | |
762 printf(FBDEV "grayscale: %u\n", fb_vinfo.grayscale); | |
763 printf(FBDEV "red: %lu %lu %lu\n", | |
764 (unsigned long) fb_vinfo.red.offset, | |
765 (unsigned long) fb_vinfo.red.length, | |
766 (unsigned long) fb_vinfo.red.msb_right); | |
767 printf(FBDEV "green: %lu %lu %lu\n", | |
768 (unsigned long) fb_vinfo.green.offset, | |
769 (unsigned long) fb_vinfo.green.length, | |
770 (unsigned long) fb_vinfo.green.msb_right); | |
771 printf(FBDEV "blue: %lu %lu %lu\n", | |
772 (unsigned long) fb_vinfo.blue.offset, | |
773 (unsigned long) fb_vinfo.blue.length, | |
774 (unsigned long) fb_vinfo.blue.msb_right); | |
775 printf(FBDEV "transp: %lu %lu %lu\n", | |
776 (unsigned long) fb_vinfo.transp.offset, | |
777 (unsigned long) fb_vinfo.transp.length, | |
778 (unsigned long) fb_vinfo.transp.msb_right); | |
779 printf(FBDEV "nonstd: %u\n", fb_vinfo.nonstd); | |
780 if (verbose > 1) { | |
781 printf(FBDEV "activate: %u\n", fb_vinfo.activate); | |
782 printf(FBDEV "height: %u\n", fb_vinfo.height); | |
783 printf(FBDEV "width: %u\n", fb_vinfo.width); | |
784 printf(FBDEV "accel_flags: %u\n", fb_vinfo.accel_flags); | |
785 printf(FBDEV "timing:\n"); | |
786 printf(FBDEV "pixclock: %u\n", fb_vinfo.pixclock); | |
787 printf(FBDEV "left_margin: %u\n", fb_vinfo.left_margin); | |
788 printf(FBDEV "right_margin: %u\n", fb_vinfo.right_margin); | |
789 printf(FBDEV "upper_margin: %u\n", fb_vinfo.upper_margin); | |
790 printf(FBDEV "lower_margin: %u\n", fb_vinfo.lower_margin); | |
791 printf(FBDEV "hsync_len: %u\n", fb_vinfo.hsync_len); | |
792 printf(FBDEV "vsync_len: %u\n", fb_vinfo.vsync_len); | |
793 printf(FBDEV "sync: %u\n", fb_vinfo.sync); | |
794 printf(FBDEV "vmode: %u\n", fb_vinfo.vmode); | |
795 } | |
796 printf(FBDEV "fix info:\n"); | |
797 printf(FBDEV "framebuffer size: %d bytes\n", fb_finfo.smem_len); | |
798 printf(FBDEV "type: %lu\n", (unsigned long) fb_finfo.type); | |
799 printf(FBDEV "type_aux: %lu\n", (unsigned long) fb_finfo.type_aux); | |
800 printf(FBDEV "visual: %lu\n", (unsigned long) fb_finfo.visual); | |
801 printf(FBDEV "line_length: %lu bytes\n", (unsigned long) fb_finfo.line_length); | |
802 if (verbose > 1) { | |
803 printf(FBDEV "id: %.16s\n", fb_finfo.id); | |
804 printf(FBDEV "smem_start: %p\n", (void *) fb_finfo.smem_start); | |
805 printf(FBDEV "xpanstep: %u\n", fb_finfo.xpanstep); | |
806 printf(FBDEV "ypanstep: %u\n", fb_finfo.ypanstep); | |
807 printf(FBDEV "ywrapstep: %u\n", fb_finfo.ywrapstep); | |
808 printf(FBDEV "mmio_start: %p\n", (void *) fb_finfo.mmio_start); | |
809 printf(FBDEV "mmio_len: %u bytes\n", fb_finfo.mmio_len); | |
810 printf(FBDEV "accel: %u\n", fb_finfo.accel); | |
811 } | |
950 | 812 printf(FBDEV "fb_bpp: %d\n", fb_bpp); |
813 printf(FBDEV "fb_real_bpp: %d\n", fb_real_bpp); | |
814 printf(FBDEV "fb_pixel_size: %d bytes\n", fb_pixel_size); | |
815 printf(FBDEV "other:\n"); | |
816 printf(FBDEV "in_width: %d\n", in_width); | |
817 printf(FBDEV "in_height: %d\n", in_height); | |
818 printf(FBDEV "out_width: %d\n", out_width); | |
819 printf(FBDEV "out_height: %d\n", out_height); | |
820 printf(FBDEV "first_row: %d\n", first_row); | |
821 printf(FBDEV "last_row: %d\n", last_row); | |
822 if (verbose > 1) | |
823 printf(FBDEV "draw_alpha_p:%dbpp = %p\n", fb_bpp, draw_alpha_p); | |
633 | 824 } |
825 } | |
658 | 826 |
950 | 827 static void vt_set_textarea(int u, int l) |
828 { | |
829 /* how can I determine the font height? | |
830 * just use 16 for now | |
831 */ | |
832 int urow = ((u + 15) / 16) + 1; | |
833 int lrow = l / 16; | |
834 | |
835 if (verbose > 1) | |
836 printf(FBDEV "vt_set_textarea(%d,%d): %d,%d\n", u, l, urow, lrow); | |
837 fprintf(vt_fp, "\33[%d;%dr\33[%d;%dH", urow, lrow, lrow, 0); | |
838 fflush(vt_fp); | |
839 } | |
840 | |
4433 | 841 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, |
6851 | 842 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
|
843 uint32_t format) |
393 | 844 { |
950 | 845 struct fb_cmap *cmap; |
6851 | 846 int vm = flags & 0x02; |
847 int zoom = flags & 0x04; | |
418 | 848 |
6851 | 849 fs = flags & 0x01; |
850 flip = flags & 0x08; | |
393 | 851 |
6164
aee9c32349a9
applied 64bit patch from Ulrich Hecht <uli at suse dot de>
alex
parents:
4756
diff
changeset
|
852 if(pre_init_err == -2) |
4380 | 853 { |
854 printf(FBDEV "Internal fatal error: init() was called before preinit()\n"); | |
855 return -1; | |
856 } | |
857 | |
858 if (pre_init_err) return 1; | |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
859 |
4089 | 860 if (zoom |
861 #ifdef CONFIG_VIDIX | |
862 && !vidix_name | |
863 #endif | |
864 ) { | |
418 | 865 printf(FBDEV "-zoom is not supported\n"); |
866 return 1; | |
867 } | |
950 | 868 if (fb_mode_name && !vm) { |
869 printf(FBDEV "-fbmode can only be used with -vm\n"); | |
418 | 870 return 1; |
871 } | |
950 | 872 if (vm && (parse_fbmode_cfg(fb_mode_cfgfile) < 0)) |
418 | 873 return 1; |
950 | 874 if (d_width && (fs || vm)) { |
418 | 875 out_width = d_width; |
876 out_height = d_height; | |
877 } else { | |
878 out_width = width; | |
879 out_height = height; | |
880 } | |
881 in_width = width; | |
882 in_height = height; | |
883 pixel_format = format; | |
884 | |
393 | 885 if (fb_mode_name) { |
418 | 886 if (!(fb_mode = find_mode_by_name(fb_mode_name))) { |
887 printf(FBDEV "can't find requested video mode\n"); | |
888 return 1; | |
889 } | |
890 fb_mode2fb_vinfo(fb_mode, &fb_vinfo); | |
950 | 891 } else if (vm) { |
418 | 892 monitor_hfreq = str2range(monitor_hfreq_str); |
893 monitor_vfreq = str2range(monitor_vfreq_str); | |
894 monitor_dotclock = str2range(monitor_dotclock_str); | |
895 if (!monitor_hfreq || !monitor_vfreq || !monitor_dotclock) { | |
896 printf(FBDEV "you have to specify the capabilities of" | |
897 " the monitor.\n"); | |
898 return 1; | |
899 } | |
900 if (!(fb_mode = find_best_mode(out_width, out_height, | |
901 monitor_hfreq, monitor_vfreq, | |
902 monitor_dotclock))) { | |
903 printf(FBDEV "can't find best video mode\n"); | |
904 return 1; | |
905 } | |
519 | 906 printf(FBDEV "using mode %dx%d @ %.1fHz\n", fb_mode->xres, |
907 fb_mode->yres, vsf(fb_mode)); | |
418 | 908 fb_mode2fb_vinfo(fb_mode, &fb_vinfo); |
359 | 909 } |
418 | 910 fb_bpp_we_want = fb_bpp; |
911 set_bpp(&fb_vinfo, fb_bpp); | |
359 | 912 fb_vinfo.xres_virtual = fb_vinfo.xres; |
913 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
|
914 |
2354
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
915 if (fb_tty_fd >= 0 && ioctl(fb_tty_fd, KDSETMODE, KD_GRAPHICS) < 0) { |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
916 if (verbose > 0) |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
917 printf(FBDEV "Can't set graphics mode: %s\n", strerror(errno)); |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
918 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
|
919 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
|
920 } |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
921 |
359 | 922 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) { |
393 | 923 printf(FBDEV "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
|
924 if (fb_tty_fd >= 0 && ioctl(fb_tty_fd, KDSETMODE, KD_TEXT) < 0) { |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
925 printf(FBDEV "Can't restore text mode: %s\n", strerror(errno)); |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
926 } |
393 | 927 return 1; |
928 } | |
950 | 929 |
930 fb_pixel_size = fb_vinfo.bits_per_pixel / 8; | |
931 fb_real_bpp = fb_vinfo.red.length + fb_vinfo.green.length + | |
932 fb_vinfo.blue.length; | |
933 fb_bpp = (fb_pixel_size == 4) ? 32 : fb_real_bpp; | |
934 if (fb_bpp_we_want != fb_bpp) | |
1076 | 935 printf(FBDEV "requested %d bpp, got %d bpp!!!\n", |
950 | 936 fb_bpp_we_want, fb_bpp); |
937 | |
938 switch (fb_bpp) { | |
939 case 32: | |
940 draw_alpha_p = vo_draw_alpha_rgb32; | |
4756 | 941 dstFourcc = IMGFMT_BGR32; |
950 | 942 break; |
943 case 24: | |
944 draw_alpha_p = vo_draw_alpha_rgb24; | |
4756 | 945 dstFourcc = IMGFMT_BGR24; |
950 | 946 break; |
4756 | 947 default: |
950 | 948 case 16: |
949 draw_alpha_p = vo_draw_alpha_rgb16; | |
4756 | 950 dstFourcc = IMGFMT_BGR16; |
950 | 951 break; |
952 case 15: | |
953 draw_alpha_p = vo_draw_alpha_rgb15; | |
4756 | 954 dstFourcc = IMGFMT_BGR15; |
950 | 955 break; |
956 } | |
957 | |
958 if (flip & ((((pixel_format & 0xff) + 7) / 8) != fb_pixel_size)) { | |
959 printf(FBDEV "Flipped output with depth conversion is not " | |
960 "supported\n"); | |
961 return 1; | |
962 } | |
963 | |
964 fb_xres = fb_vinfo.xres; | |
965 fb_yres = fb_vinfo.yres; | |
966 | |
967 if (vm || fs) { | |
968 out_width = fb_xres; | |
969 out_height = fb_yres; | |
970 } | |
971 if (out_width < in_width || out_height < in_height) { | |
972 printf(FBDEV "screensize is smaller than video size\n"); | |
973 return 1; | |
974 } | |
975 | |
976 first_row = (out_height - in_height) / 2; | |
977 last_row = (out_height + in_height) / 2; | |
978 | |
618 | 979 if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo)) { |
980 printf(FBDEV "Can't get FSCREENINFO: %s\n", strerror(errno)); | |
981 return 1; | |
982 } | |
633 | 983 |
984 lots_of_printf(); | |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
985 |
633 | 986 if (fb_finfo.type != FB_TYPE_PACKED_PIXELS) { |
987 printf(FBDEV "type %d not supported\n", fb_finfo.type); | |
988 return 1; | |
305 | 989 } |
618 | 990 |
379 | 991 switch (fb_finfo.visual) { |
393 | 992 case FB_VISUAL_TRUECOLOR: |
993 break; | |
994 case FB_VISUAL_DIRECTCOLOR: | |
995 if (verbose > 0) | |
996 printf(FBDEV "creating cmap for directcolor\n"); | |
481 | 997 if (ioctl(fb_dev_fd, FBIOGETCMAP, &fb_oldcmap)) { |
393 | 998 printf(FBDEV "can't get cmap: %s\n", |
999 strerror(errno)); | |
1000 return 1; | |
1001 } | |
1002 if (!(cmap = make_directcolor_cmap(&fb_vinfo))) | |
1003 return 1; | |
1004 if (ioctl(fb_dev_fd, FBIOPUTCMAP, cmap)) { | |
1005 printf(FBDEV "can't put cmap: %s\n", | |
1006 strerror(errno)); | |
1007 return 1; | |
1008 } | |
481 | 1009 fb_cmap_changed = 1; |
393 | 1010 free(cmap->red); |
1011 free(cmap->green); | |
1012 free(cmap->blue); | |
1013 free(cmap); | |
1014 break; | |
1015 default: | |
1016 printf(FBDEV "visual: %d not yet supported\n", | |
1017 fb_finfo.visual); | |
1018 return 1; | |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
1019 } |
618 | 1020 |
950 | 1021 fb_line_len = fb_finfo.line_length; |
359 | 1022 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
|
1023 frame_buffer = NULL; |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1024 next_frame = NULL; |
4089 | 1025 #ifdef CONFIG_VIDIX |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1026 if(vidix_name) |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1027 { |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1028 unsigned image_width,image_height,x_offset,y_offset; |
6851 | 1029 if(zoom || fs){ |
1030 aspect_save_orig(width,height); | |
1031 aspect_save_prescale(d_width,d_height); | |
1032 aspect_save_screenres(fb_xres,fb_yres); | |
1033 aspect(&image_width,&image_height,fs ? A_ZOOM : A_NOZOOM); | |
1034 } else { | |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1035 image_width=width; |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1036 image_height=height; |
6851 | 1037 } |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1038 if(fb_xres > image_width) |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1039 x_offset = (fb_xres - image_width) / 2; |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1040 else x_offset = 0; |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1041 if(fb_yres > image_height) |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1042 y_offset = (fb_yres - image_height) / 2; |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1043 else y_offset = 0; |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1044 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
|
1045 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
|
1046 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
|
1047 { |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1048 printf(FBDEV "Can't initialize VIDIX driver\n"); |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1049 vidix_name = NULL; |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1050 vidix_term(); |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1051 return -1; |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1052 } |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1053 else printf(FBDEV "Using VIDIX\n"); |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4089
diff
changeset
|
1054 vidix_start(); |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1055 } |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1056 else |
4089 | 1057 #endif |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1058 { |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1059 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
|
1060 MAP_SHARED, fb_dev_fd, 0)) == (uint8_t *) -1) { |
393 | 1061 printf(FBDEV "Can't mmap %s: %s\n", fb_dev_name, strerror(errno)); |
1062 return 1; | |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1063 } |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1064 L123123875 = frame_buffer + (out_width - in_width) * fb_pixel_size / |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1065 2 + (out_height - in_height) * fb_line_len / 2; |
229 | 1066 |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1067 if (verbose > 0) { |
519 | 1068 if (verbose > 1) { |
393 | 1069 printf(FBDEV "frame_buffer @ %p\n", frame_buffer); |
519 | 1070 printf(FBDEV "L123123875 @ %p\n", L123123875); |
1071 } | |
950 | 1072 printf(FBDEV "pixel per line: %d\n", fb_line_len / fb_pixel_size); |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1073 } |
225 | 1074 |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1075 if (!(next_frame = (uint8_t *) malloc(in_width * in_height * fb_pixel_size))) { |
393 | 1076 printf(FBDEV "Can't malloc next_frame: %s\n", strerror(errno)); |
225 | 1077 return 1; |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1078 } |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1079 if (fs || vm) |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1080 memset(frame_buffer, '\0', fb_line_len * fb_yres); |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1081 |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1082 if (format == IMGFMT_YV12) |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1083 yuv2rgb_init(fb_bpp, MODE_RGB); |
225 | 1084 } |
950 | 1085 if (vt_doit && (vt_fd = open("/dev/tty", O_WRONLY)) == -1) { |
1086 printf(FBDEV "can't open /dev/tty: %s\n", strerror(errno)); | |
1087 vt_doit = 0; | |
1088 } | |
1089 if (vt_doit && !(vt_fp = fdopen(vt_fd, "w"))) { | |
1090 printf(FBDEV "can't fdopen /dev/tty: %s\n", strerror(errno)); | |
1091 vt_doit = 0; | |
804 | 1092 } |
950 | 1093 |
1094 if (vt_doit) | |
1095 vt_set_textarea(last_row, fb_yres); | |
1096 | |
225 | 1097 return 0; |
1098 } | |
1099 | |
1100 static uint32_t query_format(uint32_t format) | |
1101 { | |
6212 | 1102 int ret = VFCAP_OSD|VFCAP_CSP_SUPPORTED; /* osd/sub is supported on every bpp */ |
519 | 1103 |
950 | 1104 if (!fb_preinit()) |
305 | 1105 return 0; |
6851 | 1106 #ifdef CONFIG_VIDIX |
1107 if(vidix_name) | |
1108 return (vidix_query_fourcc(format)); | |
1109 #endif | |
311 | 1110 if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR) { |
1111 int bpp = format & 0xff; | |
519 | 1112 |
359 | 1113 if (bpp == fb_bpp) |
6212 | 1114 return ret|VFCAP_CSP_SUPPORTED_BY_HW; |
359 | 1115 else if (bpp == 15 && fb_bpp == 16) |
6212 | 1116 return ret; |
359 | 1117 else if (bpp == 24 && fb_bpp == 32) |
6212 | 1118 return ret; |
311 | 1119 } |
1120 if (format == IMGFMT_YV12) | |
6212 | 1121 return ret; |
311 | 1122 return 0; |
225 | 1123 } |
1124 | |
1125 static const vo_info_t *get_info(void) | |
1126 { | |
1127 return &vo_info; | |
1128 } | |
1129 | |
1130 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, | |
1131 unsigned char *srca, int stride) | |
1132 { | |
4210
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1133 unsigned char *dst; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1134 int dstride; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1135 |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1136 #ifdef USE_CONVERT2FB |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1137 if (pixel_format == IMGFMT_YV12) { |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1138 dst = L123123875 + (fb_xres * y0 + x0) * fb_pixel_size; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1139 dstride = fb_xres * fb_pixel_size; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1140 } |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1141 else |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1142 #endif |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1143 { |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1144 dst = next_frame + (in_width * y0 + x0) * fb_pixel_size; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1145 dstride = in_width * fb_pixel_size; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1146 } |
359 | 1147 |
658 | 1148 (*draw_alpha_p)(w, h, src, srca, stride, dst, dstride); |
225 | 1149 } |
1150 | |
1151 static uint32_t draw_frame(uint8_t *src[]) | |
1152 { | |
1153 if (pixel_format == IMGFMT_YV12) { | |
4210
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1154 #ifdef USE_CONVERT2FB |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1155 yuv2rgb(L123123875, src[0], src[1], src[2], fb_xres, |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1156 fb_yres, fb_xres * fb_pixel_size, |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1157 in_width, in_width / 2); |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1158 #else |
225 | 1159 yuv2rgb(next_frame, src[0], src[1], src[2], in_width, |
278 | 1160 in_height, in_width * fb_pixel_size, |
225 | 1161 in_width, in_width / 2); |
4210
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1162 #endif |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1163 |
804 | 1164 } else if (flip) { |
1165 int h = in_height; | |
1166 int len = in_width * fb_pixel_size; | |
1167 char *d = next_frame + (in_height - 1) * len; | |
1168 char *s = src[0]; | |
1169 while (h--) { | |
1170 memcpy(d, s, len); | |
1171 s += len; | |
1172 d -= len; | |
1173 } | |
311 | 1174 } else { |
1175 int sbpp = ((pixel_format & 0xff) + 7) / 8; | |
1176 char *d = next_frame; | |
1177 char *s = src[0]; | |
1178 if (sbpp == fb_pixel_size) { | |
2556 | 1179 if (fb_real_bpp == 16 && pixel_format == (IMGFMT_BGR|15)) |
1180 rgb15to16(s, d, 2 * in_width * in_height); | |
1181 else | |
1182 memcpy(d, s, sbpp * in_width * in_height); | |
311 | 1183 } |
1184 } | |
225 | 1185 return 0; |
1186 } | |
1187 | |
1188 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, | |
1189 int y) | |
1190 { | |
1191 uint8_t *dest; | |
1192 | |
4210
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1193 #ifdef USE_CONVERT2FB |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1194 if (pixel_format == IMGFMT_YV12) { |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1195 if(x < fb_xres && y < fb_yres) { |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1196 if(x+w > fb_xres) w= fb_xres-x; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1197 if(y+h > fb_yres) h= fb_yres-y; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1198 |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1199 dest = L123123875 + (fb_xres * y + x) * fb_pixel_size; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1200 yuv2rgb(dest, src[0], src[1], src[2], w, h, fb_xres * fb_pixel_size, |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1201 stride[0], stride[1]); |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1202 } |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1203 |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1204 return 0; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1205 } |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1206 #endif |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1207 |
278 | 1208 dest = next_frame + (in_width * y + x) * fb_pixel_size; |
1209 yuv2rgb(dest, src[0], src[1], src[2], w, h, in_width * fb_pixel_size, | |
225 | 1210 stride[0], stride[1]); |
1211 return 0; | |
1212 } | |
1213 | |
1214 static void check_events(void) | |
1215 { | |
1216 } | |
1217 | |
519 | 1218 static void put_frame(void) |
225 | 1219 { |
1220 int i, out_offset = 0, in_offset = 0; | |
1221 | |
4210
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1222 #ifdef USE_CONVERT2FB |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1223 if(pixel_format == IMGFMT_YV12) |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1224 return; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1225 #endif |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1226 |
225 | 1227 for (i = 0; i < in_height; i++) { |
519 | 1228 memcpy(L123123875 + out_offset, next_frame + in_offset, |
423 | 1229 in_width * fb_pixel_size); |
950 | 1230 out_offset += fb_line_len; |
278 | 1231 in_offset += in_width * fb_pixel_size; |
225 | 1232 } |
1233 } | |
1234 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1087
diff
changeset
|
1235 static void draw_osd(void) |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1087
diff
changeset
|
1236 { |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1087
diff
changeset
|
1237 vo_draw_text(in_width, in_height, draw_alpha); |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1087
diff
changeset
|
1238 } |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1087
diff
changeset
|
1239 |
246 | 1240 static void flip_page(void) |
1241 { | |
519 | 1242 put_frame(); |
246 | 1243 } |
1244 | |
225 | 1245 static void uninit(void) |
1246 { | |
379 | 1247 if (verbose > 0) |
393 | 1248 printf(FBDEV "uninit\n"); |
481 | 1249 if (fb_cmap_changed) { |
1250 if (ioctl(fb_dev_fd, FBIOPUTCMAP, &fb_oldcmap)) | |
393 | 1251 printf(FBDEV "Can't restore original cmap\n"); |
481 | 1252 fb_cmap_changed = 0; |
306 | 1253 } |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1254 if(next_frame) free(next_frame); |
503 | 1255 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) |
1256 printf(FBDEV "ioctl FBIOGET_VSCREENINFO: %s\n", strerror(errno)); | |
1257 fb_orig_vinfo.xoffset = fb_vinfo.xoffset; | |
1258 fb_orig_vinfo.yoffset = fb_vinfo.yoffset; | |
379 | 1259 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_orig_vinfo)) |
503 | 1260 printf(FBDEV "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
|
1261 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
|
1262 if (ioctl(fb_tty_fd, KDSETMODE, KD_TEXT) < 0) |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
1263 printf(FBDEV "Can't restore text mode: %s\n", strerror(errno)); |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
1264 } |
950 | 1265 if (vt_doit) |
1266 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
|
1267 close(fb_tty_fd); |
359 | 1268 close(fb_dev_fd); |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1269 if(frame_buffer) munmap(frame_buffer, fb_size); |
4089 | 1270 #ifdef CONFIG_VIDIX |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1271 if(vidix_name) vidix_term(); |
4089 | 1272 #endif |
225 | 1273 } |
2354
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
1274 |
4352 | 1275 static uint32_t preinit(const char *arg) |
1276 { | |
4380 | 1277 pre_init_err = 0; |
1278 #ifdef CONFIG_VIDIX | |
1279 if(vo_subdevice) parseSubDevice(vo_subdevice); | |
1280 if(vidix_name) pre_init_err = vidix_preinit(vidix_name,&video_out_fbdev); | |
1281 if(verbose > 2) | |
1282 printf("vo_subdevice: initialization returns: %i\n",pre_init_err); | |
1283 #endif | |
1284 if(!pre_init_err) return (pre_init_err=(fb_preinit()?0:-1)); | |
6164
aee9c32349a9
applied 64bit patch from Ulrich Hecht <uli at suse dot de>
alex
parents:
4756
diff
changeset
|
1285 return(-1); |
4352 | 1286 } |
1287 | |
4596 | 1288 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 1289 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4434
diff
changeset
|
1290 switch (request) { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4434
diff
changeset
|
1291 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4434
diff
changeset
|
1292 return query_format(*((uint32_t*)data)); |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4434
diff
changeset
|
1293 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4434
diff
changeset
|
1294 return VO_NOTIMPL; |
4352 | 1295 } |