Mercurial > mplayer.hg
annotate libvo/vo_fbdev.c @ 9370:88bd19564b64
Motion-JPEG RTP streams can now be played. Some MPEG-4 ES video RTP
streams can also be played.
patch by Ross Finlayson <finlayson@live.com>
author | arpi |
---|---|
date | Sun, 09 Feb 2003 17:06:38 +0000 |
parents | 3168cfe4f7d1 |
children | d65ddafbc404 |
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 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7980
diff
changeset
|
40 static vo_info_t info = { |
225 | 41 "Framebuffer Device", |
42 "fbdev", | |
43 "Szabolcs Berecz <szabi@inf.elte.hu>", | |
44 "" | |
45 }; | |
46 | |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7980
diff
changeset
|
47 LIBVO_EXTERN(fbdev) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7980
diff
changeset
|
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); | |
7980 | 837 if(vt_fp) { |
838 fprintf(vt_fp, "\33[%d;%dr\33[%d;%dH", urow, lrow, lrow, 0); | |
839 fflush(vt_fp); | |
840 } | |
950 | 841 } |
842 | |
4433 | 843 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, |
6851 | 844 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
|
845 uint32_t format) |
393 | 846 { |
950 | 847 struct fb_cmap *cmap; |
6851 | 848 int vm = flags & 0x02; |
849 int zoom = flags & 0x04; | |
418 | 850 |
6851 | 851 fs = flags & 0x01; |
852 flip = flags & 0x08; | |
393 | 853 |
6164
aee9c32349a9
applied 64bit patch from Ulrich Hecht <uli at suse dot de>
alex
parents:
4756
diff
changeset
|
854 if(pre_init_err == -2) |
4380 | 855 { |
856 printf(FBDEV "Internal fatal error: init() was called before preinit()\n"); | |
857 return -1; | |
858 } | |
859 | |
860 if (pre_init_err) return 1; | |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
861 |
7427 | 862 #if 0 |
4089 | 863 if (zoom |
864 #ifdef CONFIG_VIDIX | |
865 && !vidix_name | |
866 #endif | |
867 ) { | |
418 | 868 printf(FBDEV "-zoom is not supported\n"); |
869 return 1; | |
870 } | |
7427 | 871 #endif |
950 | 872 if (fb_mode_name && !vm) { |
873 printf(FBDEV "-fbmode can only be used with -vm\n"); | |
418 | 874 return 1; |
875 } | |
950 | 876 if (vm && (parse_fbmode_cfg(fb_mode_cfgfile) < 0)) |
418 | 877 return 1; |
950 | 878 if (d_width && (fs || vm)) { |
418 | 879 out_width = d_width; |
880 out_height = d_height; | |
881 } else { | |
882 out_width = width; | |
883 out_height = height; | |
884 } | |
885 in_width = width; | |
886 in_height = height; | |
887 pixel_format = format; | |
888 | |
393 | 889 if (fb_mode_name) { |
418 | 890 if (!(fb_mode = find_mode_by_name(fb_mode_name))) { |
891 printf(FBDEV "can't find requested video mode\n"); | |
892 return 1; | |
893 } | |
894 fb_mode2fb_vinfo(fb_mode, &fb_vinfo); | |
950 | 895 } else if (vm) { |
418 | 896 monitor_hfreq = str2range(monitor_hfreq_str); |
897 monitor_vfreq = str2range(monitor_vfreq_str); | |
898 monitor_dotclock = str2range(monitor_dotclock_str); | |
899 if (!monitor_hfreq || !monitor_vfreq || !monitor_dotclock) { | |
900 printf(FBDEV "you have to specify the capabilities of" | |
901 " the monitor.\n"); | |
902 return 1; | |
903 } | |
904 if (!(fb_mode = find_best_mode(out_width, out_height, | |
905 monitor_hfreq, monitor_vfreq, | |
906 monitor_dotclock))) { | |
907 printf(FBDEV "can't find best video mode\n"); | |
908 return 1; | |
909 } | |
519 | 910 printf(FBDEV "using mode %dx%d @ %.1fHz\n", fb_mode->xres, |
911 fb_mode->yres, vsf(fb_mode)); | |
418 | 912 fb_mode2fb_vinfo(fb_mode, &fb_vinfo); |
359 | 913 } |
418 | 914 fb_bpp_we_want = fb_bpp; |
915 set_bpp(&fb_vinfo, fb_bpp); | |
359 | 916 fb_vinfo.xres_virtual = fb_vinfo.xres; |
917 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
|
918 |
2354
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
919 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
|
920 if (verbose > 0) |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
921 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
|
922 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
|
923 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
|
924 } |
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
925 |
359 | 926 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) { |
393 | 927 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
|
928 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
|
929 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
|
930 } |
393 | 931 return 1; |
932 } | |
950 | 933 |
934 fb_pixel_size = fb_vinfo.bits_per_pixel / 8; | |
935 fb_real_bpp = fb_vinfo.red.length + fb_vinfo.green.length + | |
936 fb_vinfo.blue.length; | |
937 fb_bpp = (fb_pixel_size == 4) ? 32 : fb_real_bpp; | |
938 if (fb_bpp_we_want != fb_bpp) | |
1076 | 939 printf(FBDEV "requested %d bpp, got %d bpp!!!\n", |
950 | 940 fb_bpp_we_want, fb_bpp); |
941 | |
942 switch (fb_bpp) { | |
943 case 32: | |
944 draw_alpha_p = vo_draw_alpha_rgb32; | |
4756 | 945 dstFourcc = IMGFMT_BGR32; |
950 | 946 break; |
947 case 24: | |
948 draw_alpha_p = vo_draw_alpha_rgb24; | |
4756 | 949 dstFourcc = IMGFMT_BGR24; |
950 | 950 break; |
4756 | 951 default: |
950 | 952 case 16: |
953 draw_alpha_p = vo_draw_alpha_rgb16; | |
4756 | 954 dstFourcc = IMGFMT_BGR16; |
950 | 955 break; |
956 case 15: | |
957 draw_alpha_p = vo_draw_alpha_rgb15; | |
4756 | 958 dstFourcc = IMGFMT_BGR15; |
950 | 959 break; |
960 } | |
961 | |
962 if (flip & ((((pixel_format & 0xff) + 7) / 8) != fb_pixel_size)) { | |
963 printf(FBDEV "Flipped output with depth conversion is not " | |
964 "supported\n"); | |
965 return 1; | |
966 } | |
967 | |
968 fb_xres = fb_vinfo.xres; | |
969 fb_yres = fb_vinfo.yres; | |
970 | |
971 if (vm || fs) { | |
972 out_width = fb_xres; | |
973 out_height = fb_yres; | |
974 } | |
975 if (out_width < in_width || out_height < in_height) { | |
976 printf(FBDEV "screensize is smaller than video size\n"); | |
977 return 1; | |
978 } | |
979 | |
980 first_row = (out_height - in_height) / 2; | |
981 last_row = (out_height + in_height) / 2; | |
982 | |
618 | 983 if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo)) { |
984 printf(FBDEV "Can't get FSCREENINFO: %s\n", strerror(errno)); | |
985 return 1; | |
986 } | |
633 | 987 |
988 lots_of_printf(); | |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
989 |
633 | 990 if (fb_finfo.type != FB_TYPE_PACKED_PIXELS) { |
991 printf(FBDEV "type %d not supported\n", fb_finfo.type); | |
992 return 1; | |
305 | 993 } |
618 | 994 |
379 | 995 switch (fb_finfo.visual) { |
393 | 996 case FB_VISUAL_TRUECOLOR: |
997 break; | |
998 case FB_VISUAL_DIRECTCOLOR: | |
999 if (verbose > 0) | |
1000 printf(FBDEV "creating cmap for directcolor\n"); | |
481 | 1001 if (ioctl(fb_dev_fd, FBIOGETCMAP, &fb_oldcmap)) { |
393 | 1002 printf(FBDEV "can't get cmap: %s\n", |
1003 strerror(errno)); | |
1004 return 1; | |
1005 } | |
1006 if (!(cmap = make_directcolor_cmap(&fb_vinfo))) | |
1007 return 1; | |
1008 if (ioctl(fb_dev_fd, FBIOPUTCMAP, cmap)) { | |
1009 printf(FBDEV "can't put cmap: %s\n", | |
1010 strerror(errno)); | |
1011 return 1; | |
1012 } | |
481 | 1013 fb_cmap_changed = 1; |
393 | 1014 free(cmap->red); |
1015 free(cmap->green); | |
1016 free(cmap->blue); | |
1017 free(cmap); | |
1018 break; | |
1019 default: | |
1020 printf(FBDEV "visual: %d not yet supported\n", | |
1021 fb_finfo.visual); | |
1022 return 1; | |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
1023 } |
618 | 1024 |
950 | 1025 fb_line_len = fb_finfo.line_length; |
359 | 1026 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
|
1027 frame_buffer = NULL; |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1028 next_frame = NULL; |
4089 | 1029 #ifdef CONFIG_VIDIX |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1030 if(vidix_name) |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1031 { |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1032 unsigned image_width,image_height,x_offset,y_offset; |
6851 | 1033 if(zoom || fs){ |
1034 aspect_save_orig(width,height); | |
1035 aspect_save_prescale(d_width,d_height); | |
1036 aspect_save_screenres(fb_xres,fb_yres); | |
1037 aspect(&image_width,&image_height,fs ? A_ZOOM : A_NOZOOM); | |
1038 } else { | |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1039 image_width=width; |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1040 image_height=height; |
6851 | 1041 } |
8918 | 1042 |
1043 if(fb_xres > image_width) | |
1044 x_offset = (fb_xres - image_width) / 2; | |
1045 else x_offset = 0; | |
1046 if(fb_yres > image_height) | |
1047 y_offset = (fb_yres - image_height) / 2; | |
1048 else y_offset = 0; | |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8148
diff
changeset
|
1049 geometry(&x_offset,&y_offset,fb_xres,fb_yres,image_width,image_height); |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
7863
diff
changeset
|
1050 |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1051 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
|
1052 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
|
1053 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
|
1054 { |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1055 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
|
1056 vidix_name = NULL; |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1057 vidix_term(); |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1058 return -1; |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1059 } |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1060 else printf(FBDEV "Using VIDIX\n"); |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4089
diff
changeset
|
1061 vidix_start(); |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1062 } |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1063 else |
4089 | 1064 #endif |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1065 { |
8918 | 1066 int x_offset=0,y_offset=0; |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1067 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
|
1068 MAP_SHARED, fb_dev_fd, 0)) == (uint8_t *) -1) { |
393 | 1069 printf(FBDEV "Can't mmap %s: %s\n", fb_dev_name, strerror(errno)); |
1070 return 1; | |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1071 } |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
7863
diff
changeset
|
1072 |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8148
diff
changeset
|
1073 geometry(&x_offset,&y_offset,fb_xres,fb_yres,out_width,out_height); |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
7863
diff
changeset
|
1074 |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1075 L123123875 = frame_buffer + (out_width - in_width) * fb_pixel_size / |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
7863
diff
changeset
|
1076 2 + ( (out_height - in_height) / 2 ) * fb_line_len + |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
7863
diff
changeset
|
1077 x_offset * fb_pixel_size + y_offset * fb_line_len; |
229 | 1078 |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1079 if (verbose > 0) { |
519 | 1080 if (verbose > 1) { |
393 | 1081 printf(FBDEV "frame_buffer @ %p\n", frame_buffer); |
519 | 1082 printf(FBDEV "L123123875 @ %p\n", L123123875); |
1083 } | |
950 | 1084 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
|
1085 } |
225 | 1086 |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1087 if (!(next_frame = (uint8_t *) malloc(in_width * in_height * fb_pixel_size))) { |
393 | 1088 printf(FBDEV "Can't malloc next_frame: %s\n", strerror(errno)); |
225 | 1089 return 1; |
4084
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 if (fs || vm) |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1092 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
|
1093 |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1094 if (format == IMGFMT_YV12) |
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1095 yuv2rgb_init(fb_bpp, MODE_RGB); |
225 | 1096 } |
950 | 1097 if (vt_doit && (vt_fd = open("/dev/tty", O_WRONLY)) == -1) { |
1098 printf(FBDEV "can't open /dev/tty: %s\n", strerror(errno)); | |
1099 vt_doit = 0; | |
1100 } | |
1101 if (vt_doit && !(vt_fp = fdopen(vt_fd, "w"))) { | |
1102 printf(FBDEV "can't fdopen /dev/tty: %s\n", strerror(errno)); | |
1103 vt_doit = 0; | |
804 | 1104 } |
950 | 1105 |
1106 if (vt_doit) | |
1107 vt_set_textarea(last_row, fb_yres); | |
1108 | |
225 | 1109 return 0; |
1110 } | |
1111 | |
1112 static uint32_t query_format(uint32_t format) | |
1113 { | |
6212 | 1114 int ret = VFCAP_OSD|VFCAP_CSP_SUPPORTED; /* osd/sub is supported on every bpp */ |
519 | 1115 |
950 | 1116 if (!fb_preinit()) |
305 | 1117 return 0; |
6851 | 1118 #ifdef CONFIG_VIDIX |
1119 if(vidix_name) | |
1120 return (vidix_query_fourcc(format)); | |
1121 #endif | |
311 | 1122 if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR) { |
1123 int bpp = format & 0xff; | |
519 | 1124 |
359 | 1125 if (bpp == fb_bpp) |
6212 | 1126 return ret|VFCAP_CSP_SUPPORTED_BY_HW; |
359 | 1127 else if (bpp == 15 && fb_bpp == 16) |
6212 | 1128 return ret; |
359 | 1129 else if (bpp == 24 && fb_bpp == 32) |
6212 | 1130 return ret; |
311 | 1131 } |
1132 if (format == IMGFMT_YV12) | |
6212 | 1133 return ret; |
311 | 1134 return 0; |
225 | 1135 } |
1136 | |
1137 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, | |
1138 unsigned char *srca, int stride) | |
1139 { | |
4210
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1140 unsigned char *dst; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1141 int dstride; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1142 |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1143 #ifdef USE_CONVERT2FB |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1144 if (pixel_format == IMGFMT_YV12) { |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1145 dst = L123123875 + (fb_xres * y0 + x0) * fb_pixel_size; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1146 dstride = fb_xres * fb_pixel_size; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1147 } |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1148 else |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1149 #endif |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1150 { |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1151 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
|
1152 dstride = in_width * fb_pixel_size; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1153 } |
359 | 1154 |
658 | 1155 (*draw_alpha_p)(w, h, src, srca, stride, dst, dstride); |
225 | 1156 } |
1157 | |
1158 static uint32_t draw_frame(uint8_t *src[]) | |
1159 { | |
1160 if (pixel_format == IMGFMT_YV12) { | |
4210
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1161 #ifdef USE_CONVERT2FB |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1162 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
|
1163 fb_yres, fb_xres * fb_pixel_size, |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1164 in_width, in_width / 2); |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1165 #else |
225 | 1166 yuv2rgb(next_frame, src[0], src[1], src[2], in_width, |
278 | 1167 in_height, in_width * fb_pixel_size, |
225 | 1168 in_width, in_width / 2); |
4210
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1169 #endif |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1170 |
804 | 1171 } else if (flip) { |
1172 int h = in_height; | |
1173 int len = in_width * fb_pixel_size; | |
1174 char *d = next_frame + (in_height - 1) * len; | |
1175 char *s = src[0]; | |
1176 while (h--) { | |
1177 memcpy(d, s, len); | |
1178 s += len; | |
1179 d -= len; | |
1180 } | |
311 | 1181 } else { |
1182 int sbpp = ((pixel_format & 0xff) + 7) / 8; | |
1183 char *d = next_frame; | |
1184 char *s = src[0]; | |
1185 if (sbpp == fb_pixel_size) { | |
2556 | 1186 if (fb_real_bpp == 16 && pixel_format == (IMGFMT_BGR|15)) |
1187 rgb15to16(s, d, 2 * in_width * in_height); | |
1188 else | |
1189 memcpy(d, s, sbpp * in_width * in_height); | |
311 | 1190 } |
1191 } | |
225 | 1192 return 0; |
1193 } | |
1194 | |
1195 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, | |
1196 int y) | |
1197 { | |
1198 uint8_t *dest; | |
1199 | |
4210
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1200 #ifdef USE_CONVERT2FB |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1201 if (pixel_format == IMGFMT_YV12) { |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1202 if(x < fb_xres && y < fb_yres) { |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1203 if(x+w > fb_xres) w= fb_xres-x; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1204 if(y+h > fb_yres) h= fb_yres-y; |
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 dest = L123123875 + (fb_xres * y + x) * fb_pixel_size; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1207 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
|
1208 stride[0], stride[1]); |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1209 } |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1210 |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1211 return 0; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1212 } |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1213 #endif |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1214 |
278 | 1215 dest = next_frame + (in_width * y + x) * fb_pixel_size; |
1216 yuv2rgb(dest, src[0], src[1], src[2], w, h, in_width * fb_pixel_size, | |
225 | 1217 stride[0], stride[1]); |
1218 return 0; | |
1219 } | |
1220 | |
1221 static void check_events(void) | |
1222 { | |
1223 } | |
1224 | |
519 | 1225 static void put_frame(void) |
225 | 1226 { |
1227 int i, out_offset = 0, in_offset = 0; | |
1228 | |
4210
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1229 #ifdef USE_CONVERT2FB |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1230 if(pixel_format == IMGFMT_YV12) |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1231 return; |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1232 #endif |
d43f0e4ac781
fbdev nocopy option - Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4198
diff
changeset
|
1233 |
225 | 1234 for (i = 0; i < in_height; i++) { |
519 | 1235 memcpy(L123123875 + out_offset, next_frame + in_offset, |
423 | 1236 in_width * fb_pixel_size); |
950 | 1237 out_offset += fb_line_len; |
278 | 1238 in_offset += in_width * fb_pixel_size; |
225 | 1239 } |
1240 } | |
1241 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1087
diff
changeset
|
1242 static void draw_osd(void) |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1087
diff
changeset
|
1243 { |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1087
diff
changeset
|
1244 vo_draw_text(in_width, in_height, draw_alpha); |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1087
diff
changeset
|
1245 } |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1087
diff
changeset
|
1246 |
246 | 1247 static void flip_page(void) |
1248 { | |
519 | 1249 put_frame(); |
246 | 1250 } |
1251 | |
225 | 1252 static void uninit(void) |
1253 { | |
379 | 1254 if (verbose > 0) |
393 | 1255 printf(FBDEV "uninit\n"); |
481 | 1256 if (fb_cmap_changed) { |
1257 if (ioctl(fb_dev_fd, FBIOPUTCMAP, &fb_oldcmap)) | |
393 | 1258 printf(FBDEV "Can't restore original cmap\n"); |
481 | 1259 fb_cmap_changed = 0; |
306 | 1260 } |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1261 if(next_frame) free(next_frame); |
503 | 1262 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) |
1263 printf(FBDEV "ioctl FBIOGET_VSCREENINFO: %s\n", strerror(errno)); | |
1264 fb_orig_vinfo.xoffset = fb_vinfo.xoffset; | |
1265 fb_orig_vinfo.yoffset = fb_vinfo.yoffset; | |
379 | 1266 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_orig_vinfo)) |
503 | 1267 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
|
1268 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
|
1269 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
|
1270 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
|
1271 } |
950 | 1272 if (vt_doit) |
1273 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
|
1274 close(fb_tty_fd); |
359 | 1275 close(fb_dev_fd); |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1276 if(frame_buffer) munmap(frame_buffer, fb_size); |
4089 | 1277 #ifdef CONFIG_VIDIX |
4084
e7be28567230
VIDIX expansion, Usage: -vo fbdev:vidix (-fs -zoom). Zoom is supported for VIDIX!!!
nick
parents:
2732
diff
changeset
|
1278 if(vidix_name) vidix_term(); |
4089 | 1279 #endif |
225 | 1280 } |
2354
0e2f4c4e55d4
Applied patch to switch to graphics mode with -fs by achurch@achurch.org (Andrew Church)
atmos4
parents:
1561
diff
changeset
|
1281 |
7676 | 1282 static uint32_t preinit(const char *vo_subdevice) |
4352 | 1283 { |
4380 | 1284 pre_init_err = 0; |
1285 #ifdef CONFIG_VIDIX | |
1286 if(vo_subdevice) parseSubDevice(vo_subdevice); | |
1287 if(vidix_name) pre_init_err = vidix_preinit(vidix_name,&video_out_fbdev); | |
1288 if(verbose > 2) | |
1289 printf("vo_subdevice: initialization returns: %i\n",pre_init_err); | |
1290 #endif | |
1291 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
|
1292 return(-1); |
4352 | 1293 } |
1294 | |
4596 | 1295 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 1296 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4434
diff
changeset
|
1297 switch (request) { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4434
diff
changeset
|
1298 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4434
diff
changeset
|
1299 return query_format(*((uint32_t*)data)); |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4434
diff
changeset
|
1300 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4434
diff
changeset
|
1301 return VO_NOTIMPL; |
4352 | 1302 } |