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