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