Mercurial > mplayer.hg
annotate libvo/vo_fbdev.c @ 498:86c689b3e40e
disable ddebug printfs
author | arpi_esp |
---|---|
date | Wed, 18 Apr 2001 01:25:09 +0000 |
parents | 6e8a887c99cd |
children | 4aa16f9ff929 |
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> | |
22 #include <linux/fb.h> | |
23 #include <linux/vt.h> | |
24 | |
25 #include "config.h" | |
26 #include "video_out.h" | |
27 #include "video_out_internal.h" | |
28 | |
29 #include "yuv2rgb.h" | |
311 | 30 extern void rgb15to16_mmx(char *s0, char *d0, int count); |
225 | 31 |
354 | 32 #include "fastmemcpy.h" |
350 | 33 |
225 | 34 LIBVO_EXTERN(fbdev) |
35 | |
36 static vo_info_t vo_info = { | |
37 "Framebuffer Device", | |
38 "fbdev", | |
39 "Szabolcs Berecz <szabi@inf.elte.hu>", | |
40 "" | |
41 }; | |
42 | |
379 | 43 extern int verbose; |
44 | |
359 | 45 /****************************** |
393 | 46 * fb.modes support * |
359 | 47 ******************************/ |
48 | |
49 /* | |
50 * read the fb.modes manual page! | |
51 */ | |
52 | |
53 typedef struct { | |
54 char *name; | |
55 uint32_t xres, yres, vxres, vyres, depth; | |
56 uint32_t pixclock, left, right, upper, lower, hslen, vslen; | |
57 uint32_t sync; | |
58 uint32_t vmode; | |
59 } fb_mode_t; | |
60 | |
61 #define PRINT_LINENUM printf(" at line %d\n", line_num) | |
62 | |
63 #define MAX_NR_TOKEN 16 | |
64 | |
65 #define MAX_LINE_LEN 1000 | |
66 | |
67 #define RET_EOF -1 | |
68 #define RET_EOL -2 | |
69 | |
70 static int validate_mode(fb_mode_t *m) | |
71 { | |
72 if (!m->xres) { | |
73 printf("needs geometry "); | |
74 return 0; | |
75 } | |
76 if (!m->pixclock) { | |
77 printf("needs timings "); | |
78 return 0; | |
79 } | |
80 return 1; | |
81 } | |
82 | |
83 static FILE *fp; | |
84 static int line_num = 0; | |
85 static char *line; | |
86 static char *token[MAX_NR_TOKEN]; | |
87 | |
88 static int get_token(int num) | |
89 { | |
90 static int read_nextline = 1; | |
91 static int line_pos; | |
92 int i; | |
93 char c; | |
94 | |
95 if (num >= MAX_NR_TOKEN) { | |
96 printf("get_token(): max >= MAX_NR_TOKEN!"); | |
97 goto out_eof; | |
98 } | |
99 | |
100 if (read_nextline) { | |
101 if (!fgets(line, MAX_LINE_LEN, fp)) | |
102 goto out_eof; | |
103 line_pos = 0; | |
104 ++line_num; | |
105 read_nextline = 0; | |
106 } | |
107 for (i = 0; i < num; i++) { | |
108 while (isspace(line[line_pos])) | |
109 ++line_pos; | |
110 if (line[line_pos] == '\0' || line[line_pos] == '#') { | |
111 read_nextline = 1; | |
112 if (i == num) | |
113 goto out_ok; | |
114 goto out_eol; | |
115 } | |
116 token[i] = line + line_pos; | |
117 c = line[line_pos]; | |
118 if (c == '"' || c == '\'') { | |
119 token[i]++; | |
120 while (line[++line_pos] != c && line[line_pos]) | |
121 /* NOTHING */; | |
122 } else { | |
123 for (/* NOTHING */; !isspace(line[line_pos]) && | |
124 line[line_pos]; line_pos++) | |
125 /* NOTHING */; | |
126 } | |
127 if (!line[line_pos]) { | |
128 read_nextline = 1; | |
129 if (i == num - 1) | |
130 goto out_ok; | |
131 goto out_eol; | |
132 } | |
133 line[line_pos] = '\0'; | |
134 line_pos++; | |
135 } | |
136 out_ok: | |
137 return i; | |
138 out_eof: | |
139 return RET_EOF; | |
140 out_eol: | |
141 return RET_EOL; | |
142 } | |
143 | |
144 static fb_mode_t *fb_modes = NULL; | |
145 static int nr_modes = 0; | |
146 | |
147 static int parse_fbmode_cfg(char *cfgfile) | |
148 { | |
149 fb_mode_t *mode = NULL; | |
150 char *endptr; // strtoul()... | |
151 int tmp, i; | |
152 | |
153 #ifdef DEBUG | |
154 assert(cfgfile != NULL); | |
155 #endif | |
156 | |
157 printf("Reading %s: ", cfgfile); | |
158 | |
159 if ((fp = fopen(cfgfile, "r")) == NULL) { | |
160 printf("can't open '%s': %s\n", cfgfile, strerror(errno)); | |
161 return -1; | |
162 } | |
163 | |
164 if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) { | |
165 printf("can't get memory for 'line': %s\n", strerror(errno)); | |
166 return -2; | |
167 } | |
168 | |
169 /* | |
170 * check if the cfgfile starts with 'mode' | |
171 */ | |
172 while ((tmp = get_token(1)) == RET_EOL) | |
173 /* NOTHING */; | |
174 if (tmp == RET_EOF) | |
175 goto out; | |
176 if (!strcmp(token[0], "mode")) | |
177 goto loop_enter; | |
178 goto err_out_parse_error; | |
179 | |
180 while ((tmp = get_token(1)) != RET_EOF) { | |
181 if (tmp == RET_EOL) | |
182 continue; | |
183 if (!strcmp(token[0], "mode")) { | |
184 if (!validate_mode(mode)) | |
185 goto err_out_not_valid; | |
186 loop_enter: | |
187 if (!(fb_modes = (fb_mode_t *) realloc(fb_modes, | |
188 sizeof(fb_mode_t) * (nr_modes + 1)))) { | |
189 printf("can't realloc 'fb_modes': %s\n", strerror(errno)); | |
190 goto err_out; | |
191 } | |
192 mode=fb_modes + nr_modes; | |
193 ++nr_modes; | |
194 memset(mode,0,sizeof(fb_mode_t)); | |
225 | 195 |
359 | 196 if (get_token(1) < 0) |
197 goto err_out_parse_error; | |
198 for (i = 0; i < nr_modes - 1; i++) { | |
199 if (!strcmp(token[0], fb_modes[i].name)) { | |
200 printf("mode name '%s' isn't unique", token[0]); | |
201 goto err_out_print_linenum; | |
202 } | |
203 } | |
204 if (!(mode->name = strdup(token[0]))) { | |
205 printf("can't strdup -> 'name': %s\n", strerror(errno)); | |
206 goto err_out; | |
207 } | |
208 } else if (!strcmp(token[0], "geometry")) { | |
209 if (get_token(5) < 0) | |
210 goto err_out_parse_error; | |
211 mode->xres = strtoul(token[0], &endptr, 0); | |
212 if (*endptr) | |
213 goto err_out_parse_error; | |
214 mode->yres = strtoul(token[1], &endptr, 0); | |
215 if (*endptr) | |
216 goto err_out_parse_error; | |
217 mode->vxres = strtoul(token[2], &endptr, 0); | |
218 if (*endptr) | |
219 goto err_out_parse_error; | |
220 mode->vyres = strtoul(token[3], &endptr, 0); | |
221 if (*endptr) | |
222 goto err_out_parse_error; | |
223 mode->depth = strtoul(token[4], &endptr, 0); | |
224 if (*endptr) | |
225 goto err_out_parse_error; | |
226 } else if (!strcmp(token[0], "timings")) { | |
227 if (get_token(7) < 0) | |
228 goto err_out_parse_error; | |
229 mode->pixclock = strtoul(token[0], &endptr, 0); | |
230 if (*endptr) | |
231 goto err_out_parse_error; | |
232 mode->left = strtoul(token[1], &endptr, 0); | |
233 if (*endptr) | |
234 goto err_out_parse_error; | |
235 mode->right = strtoul(token[2], &endptr, 0); | |
236 if (*endptr) | |
237 goto err_out_parse_error; | |
238 mode->upper = strtoul(token[3], &endptr, 0); | |
239 if (*endptr) | |
240 goto err_out_parse_error; | |
241 mode->lower = strtoul(token[4], &endptr, 0); | |
242 if (*endptr) | |
243 goto err_out_parse_error; | |
244 mode->hslen = strtoul(token[5], &endptr, 0); | |
245 if (*endptr) | |
246 goto err_out_parse_error; | |
247 mode->vslen = strtoul(token[6], &endptr, 0); | |
248 if (*endptr) | |
249 goto err_out_parse_error; | |
250 } else if (!strcmp(token[0], "endmode")) { | |
251 /* NOTHING for now*/ | |
383 | 252 } else if (!strcmp(token[0], "accel")) { |
253 if (get_token(1) < 0) | |
254 goto err_out_parse_error; | |
393 | 255 /* |
256 * it's only used for text acceleration | |
257 * so we just ignore it. | |
258 */ | |
359 | 259 } else if (!strcmp(token[0], "hsync")) { |
260 if (get_token(1) < 0) | |
261 goto err_out_parse_error; | |
262 if (!strcmp(token[0], "low")) | |
263 mode->sync &= ~FB_SYNC_HOR_HIGH_ACT; | |
264 else if(!strcmp(token[0], "high")) | |
265 mode->sync |= FB_SYNC_HOR_HIGH_ACT; | |
266 else | |
267 goto err_out_parse_error; | |
268 } else if (!strcmp(token[0], "vsync")) { | |
269 if (get_token(1) < 0) | |
270 goto err_out_parse_error; | |
271 if (!strcmp(token[0], "low")) | |
272 mode->sync &= ~FB_SYNC_VERT_HIGH_ACT; | |
273 else if(!strcmp(token[0], "high")) | |
274 mode->sync |= FB_SYNC_VERT_HIGH_ACT; | |
275 else | |
276 goto err_out_parse_error; | |
277 } else if (!strcmp(token[0], "csync")) { | |
278 if (get_token(1) < 0) | |
279 goto err_out_parse_error; | |
280 if (!strcmp(token[0], "low")) | |
281 mode->sync &= ~FB_SYNC_COMP_HIGH_ACT; | |
282 else if(!strcmp(token[0], "high")) | |
283 mode->sync |= FB_SYNC_COMP_HIGH_ACT; | |
284 else | |
285 goto err_out_parse_error; | |
286 } else if (!strcmp(token[0], "extsync")) { | |
287 if (get_token(1) < 0) | |
288 goto err_out_parse_error; | |
289 if (!strcmp(token[0], "false")) | |
290 mode->sync &= ~FB_SYNC_EXT; | |
291 else if(!strcmp(token[0], "true")) | |
292 mode->sync |= FB_SYNC_EXT; | |
293 else | |
294 goto err_out_parse_error; | |
295 } else if (!strcmp(token[0], "laced")) { | |
296 if (get_token(1) < 0) | |
297 goto err_out_parse_error; | |
298 if (!strcmp(token[0], "false")) | |
299 mode->vmode = FB_VMODE_NONINTERLACED; | |
300 else if (!strcmp(token[0], "true")) | |
301 mode->vmode = FB_VMODE_INTERLACED; | |
302 else | |
303 goto err_out_parse_error; | |
479 | 304 } else if (!strcmp(token[0], "double")) { |
359 | 305 if (get_token(1) < 0) |
306 goto err_out_parse_error; | |
307 if (!strcmp(token[0], "false")) | |
308 ; | |
309 else if (!strcmp(token[0], "true")) | |
310 mode->vmode = FB_VMODE_DOUBLE; | |
311 else | |
312 goto err_out_parse_error; | |
313 } else | |
314 goto err_out_parse_error; | |
315 } | |
316 if (!validate_mode(mode)) | |
317 goto err_out_not_valid; | |
318 out: | |
319 printf("%d modes\n", nr_modes); | |
320 free(line); | |
321 fclose(fp); | |
322 return nr_modes; | |
323 err_out_parse_error: | |
324 printf("parse error"); | |
325 err_out_print_linenum: | |
326 PRINT_LINENUM; | |
327 err_out: | |
393 | 328 if (fb_modes) { |
359 | 329 free(fb_modes); |
393 | 330 fb_modes = NULL; |
331 } | |
332 nr_modes = 0; | |
359 | 333 free(line); |
334 free(fp); | |
335 return -2; | |
336 err_out_not_valid: | |
337 printf("mode is not definied correctly"); | |
338 goto err_out_print_linenum; | |
339 } | |
340 | |
341 static fb_mode_t *find_mode_by_name(char *name) | |
342 { | |
343 int i; | |
344 | |
345 for (i = 0; i < nr_modes; i++) { | |
346 if (!strcmp(name, fb_modes[i].name)) | |
347 return fb_modes + i; | |
348 } | |
349 return NULL; | |
350 } | |
351 | |
393 | 352 static float dcf(fb_mode_t *m) //driving clock frequency |
353 { | |
354 return 1000000.0f / m->pixclock; | |
355 } | |
356 | |
357 static float hsf(fb_mode_t *m) //horizontal scan frequency | |
358 { | |
359 int htotal = m->left + m->xres + m->right + m->hslen; | |
360 return dcf(m) / htotal; | |
361 } | |
362 | |
363 static float vsf(fb_mode_t *m) //vertical scan frequency | |
364 { | |
365 int vtotal = m->upper + m->yres + m->lower + m->vslen; | |
366 return hsf(m) / vtotal; | |
367 } | |
368 | |
369 typedef struct { | |
370 float min; | |
371 float max; | |
418 | 372 } range_t; |
393 | 373 |
418 | 374 static int in_range(range_t *r, float f) |
393 | 375 { |
418 | 376 for (/* NOTHING */; (r->min != -1 && r->max != -1); r++) { |
393 | 377 if (f >= r->min && f <= r->max) |
378 return 1; | |
379 } | |
380 return 0; | |
381 } | |
382 | |
418 | 383 static fb_mode_t *find_best_mode(int xres, int yres, range_t *hfreq, |
384 range_t *vfreq, range_t *dotclock) | |
393 | 385 { |
386 int i; | |
387 fb_mode_t *best = fb_modes; | |
388 fb_mode_t *curr = fb_modes + 1; | |
389 | |
390 for (i = nr_modes - 1; i; i--, curr++) { | |
391 if (curr->xres >= xres && curr->yres >= yres) { | |
392 if (curr->xres < best->xres && curr->yres < best->yres) { | |
393 if (!in_range(hfreq, hsf(curr))) | |
394 continue; | |
395 if (!in_range(vfreq, vsf(curr))) | |
396 continue; | |
397 if (!in_range(dotclock, dcf(curr))) | |
398 continue; | |
399 best = curr; | |
400 } | |
401 } | |
402 } | |
403 if ((best->xres < xres || best->yres < yres) || | |
404 !in_range(hfreq, hsf(best)) || | |
405 !in_range(vfreq, vsf(best)) || | |
406 !in_range(dotclock, dcf(curr))) | |
407 return NULL; | |
408 return best; | |
409 } | |
410 | |
418 | 411 static void set_bpp(struct fb_var_screeninfo *p, int bpp) |
412 { | |
476 | 413 /* p->bits_per_pixel = (bpp == 15) ? 16 : bpp; */ |
414 p->bits_per_pixel = (bpp + 1) & ~1; | |
418 | 415 p->red.msb_right = p->green.msb_right = p->blue.msb_right = 0; |
416 switch (bpp) { | |
417 case 32: | |
418 case 24: | |
419 p->red.offset = 16; | |
420 p->red.length = 8; | |
421 p->green.offset = 8; | |
422 p->green.length = 8; | |
423 p->blue.offset = 0; | |
424 p->blue.length = 8; | |
425 break; | |
426 case 16: | |
427 p->red.offset = 11; | |
428 p->red.length = 5; | |
429 p->green.offset = 5; | |
430 p->green.length = 6; | |
431 p->blue.offset = 0; | |
432 p->blue.length = 5; | |
433 break; | |
434 case 15: | |
435 p->red.offset = 10; | |
436 p->red.length = 5; | |
437 p->green.offset = 5; | |
438 p->green.length = 5; | |
439 p->blue.offset = 0; | |
440 p->blue.length = 5; | |
441 break; | |
442 } | |
443 } | |
444 | |
445 static void fb_mode2fb_vinfo(fb_mode_t *m, struct fb_var_screeninfo *v) | |
446 { | |
447 v->xres = m->xres; | |
448 v->yres = m->yres; | |
449 v->xres_virtual = m->vxres; | |
450 v->yres_virtual = m->vyres; | |
451 set_bpp(v, m->depth); | |
452 v->pixclock = m->pixclock; | |
453 v->left_margin = m->left; | |
454 v->right_margin = m->right; | |
455 v->upper_margin = m->upper; | |
456 v->lower_margin = m->lower; | |
457 v->hsync_len = m->hslen; | |
458 v->vsync_len = m->vslen; | |
459 v->sync = m->sync; | |
460 v->vmode = m->vmode; | |
461 } | |
462 | |
463 static range_t *str2range(char *s) | |
464 { | |
465 float tmp_min, tmp_max; | |
466 char *endptr = s; // to start the loop | |
467 range_t *r = NULL; | |
468 int i, j; | |
469 | |
470 if (!s) | |
471 return NULL; | |
472 for (i = 0; *endptr; i++) { | |
473 if (*s == ',') | |
474 goto out_err; | |
475 if (!(r = (range_t *) realloc(r, sizeof(*r) * i + 2))) { | |
476 printf("can't realloc 'r'\n"); | |
477 return NULL; | |
478 } | |
479 tmp_min = strtod(s, &endptr); | |
480 if (*endptr == 'k' || *endptr == 'K') { | |
481 tmp_min *= 1000.0; | |
482 endptr++; | |
483 } else if (*endptr == 'm' || *endptr == 'M') { | |
484 tmp_min *= 1000000.0; | |
485 endptr++; | |
486 } | |
487 if (*endptr == '-') { | |
488 tmp_max = strtod(endptr + 1, &endptr); | |
489 if (*endptr == 'k' || *endptr == 'K') { | |
490 tmp_max *= 1000.0; | |
491 endptr++; | |
492 } else if (*endptr == 'm' || *endptr == 'M') { | |
493 tmp_max *= 1000000.0; | |
494 endptr++; | |
495 } | |
496 if (*endptr != ',' && *endptr) | |
497 goto out_err; | |
498 } else if (*endptr == ',' || !*endptr) { | |
499 tmp_max = tmp_min; | |
500 } else | |
501 goto out_err; | |
502 r[i].min = tmp_min; | |
503 r[i].max = tmp_max; | |
504 s = endptr + 1; | |
505 } | |
506 /* check if we have negative numbers... */ | |
507 for (j = 0; j < i; j++) | |
508 if (r[j].min < 0 || r[j].max < 0) | |
509 goto out_err; | |
510 r[i].min = r[i].max = -1; | |
511 return r; | |
512 out_err: | |
513 if (r) | |
514 free(r); | |
515 return NULL; | |
516 } | |
517 | |
359 | 518 /****************************** |
519 * vo_fbdev * | |
520 ******************************/ | |
521 | |
393 | 522 /* |
523 * command line/config file options | |
524 */ | |
525 char *fb_dev_name = NULL; | |
526 char *fb_mode_cfgfile = "/etc/fb.modes"; | |
527 char *fb_mode_name = NULL; | |
418 | 528 char *monitor_hfreq_str = NULL; |
529 char *monitor_vfreq_str = NULL; | |
530 char *monitor_dotclock_str = NULL; | |
531 | |
532 range_t *monitor_hfreq = NULL; | |
533 range_t *monitor_vfreq = NULL; | |
534 range_t *monitor_dotclock = NULL; | |
393 | 535 |
536 static int fb_preinit_done = 0; | |
359 | 537 static int fb_works = 0; |
225 | 538 static int fb_dev_fd; |
539 static size_t fb_size; | |
540 static uint8_t *frame_buffer; | |
359 | 541 static struct fb_fix_screeninfo fb_finfo; |
542 static struct fb_var_screeninfo fb_orig_vinfo; | |
543 static struct fb_var_screeninfo fb_vinfo; | |
481 | 544 static struct fb_cmap fb_oldcmap; |
545 static int fb_cmap_changed = 0; | |
359 | 546 static int fb_pixel_size; // 32: 4 24: 3 16: 2 15: 2 |
547 static int fb_real_bpp; // 32: 24 24: 24 16: 16 15: 15 | |
548 static int fb_bpp; // 32: 32 24: 24 16: 16 15: 15 | |
393 | 549 static int fb_bpp_we_want; // 32: 32 24: 24 16: 16 15: 15 |
359 | 550 static int fb_screen_width; |
551 static fb_mode_t *fb_mode = NULL; | |
552 | |
418 | 553 static void (*put_frame)(void); |
554 static int left_band_width; | |
555 static int right_band_width; | |
556 static int upper_band_height; | |
557 static int lower_band_height; | |
359 | 558 static uint8_t *next_frame; |
225 | 559 static int in_width; |
560 static int in_height; | |
561 static int out_width; | |
562 static int out_height; | |
563 static uint32_t pixel_format; | |
564 | |
305 | 565 /* |
566 * Note: this function is completely cut'n'pasted from | |
567 * Chris Lawrence's code. | |
311 | 568 * (modified a bit to fit in my code...) |
305 | 569 */ |
570 struct fb_cmap *make_directcolor_cmap(struct fb_var_screeninfo *var) | |
571 { | |
572 /* Hopefully any DIRECTCOLOR device will have a big enough palette | |
573 * to handle mapping the full color depth. | |
574 * e.g. 8 bpp -> 256 entry palette | |
575 * | |
576 * We could handle some sort of gamma here | |
577 */ | |
578 int i, cols, rcols, gcols, bcols; | |
579 uint16_t *red, *green, *blue; | |
580 struct fb_cmap *cmap; | |
581 | |
582 rcols = 1 << var->red.length; | |
583 gcols = 1 << var->green.length; | |
584 bcols = 1 << var->blue.length; | |
585 | |
586 /* Make our palette the length of the deepest color */ | |
587 cols = (rcols > gcols ? rcols : gcols); | |
588 cols = (cols > bcols ? cols : bcols); | |
589 | |
590 red = malloc(cols * sizeof(red[0])); | |
591 if(!red) { | |
592 printf("Can't allocate red palette with %d entries.\n", cols); | |
593 return NULL; | |
594 } | |
595 for(i=0; i< rcols; i++) | |
596 red[i] = (65535/(rcols-1)) * i; | |
597 | |
598 green = malloc(cols * sizeof(green[0])); | |
599 if(!green) { | |
600 printf("Can't allocate green palette with %d entries.\n", cols); | |
601 free(red); | |
602 return NULL; | |
603 } | |
604 for(i=0; i< gcols; i++) | |
605 green[i] = (65535/(gcols-1)) * i; | |
606 | |
607 blue = malloc(cols * sizeof(blue[0])); | |
608 if(!blue) { | |
609 printf("Can't allocate blue palette with %d entries.\n", cols); | |
610 free(red); | |
611 free(green); | |
612 return NULL; | |
613 } | |
614 for(i=0; i< bcols; i++) | |
615 blue[i] = (65535/(bcols-1)) * i; | |
616 | |
617 cmap = malloc(sizeof(struct fb_cmap)); | |
618 if(!cmap) { | |
619 printf("Can't allocate color map\n"); | |
620 free(red); | |
621 free(green); | |
622 free(blue); | |
623 return NULL; | |
624 } | |
625 cmap->start = 0; | |
626 cmap->transp = 0; | |
627 cmap->len = cols; | |
628 cmap->red = red; | |
629 cmap->blue = blue; | |
630 cmap->green = green; | |
631 cmap->transp = NULL; | |
632 | |
633 return cmap; | |
634 } | |
225 | 635 |
393 | 636 static int fb_preinit(void) |
225 | 637 { |
393 | 638 if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER"))) |
639 fb_dev_name = "/dev/fb0"; | |
640 if (verbose > 0) | |
641 printf(FBDEV "using %s\n", fb_dev_name); | |
225 | 642 |
393 | 643 if ((fb_dev_fd = open(fb_dev_name, O_RDWR)) == -1) { |
644 printf(FBDEV "Can't open %s: %s\n", fb_dev_name, strerror(errno)); | |
645 goto err_out; | |
646 } | |
647 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) { | |
648 printf(FBDEV "Can't get VSCREENINFO: %s\n", strerror(errno)); | |
649 goto err_out_fd; | |
650 } | |
418 | 651 fb_orig_vinfo = fb_vinfo; |
393 | 652 |
653 fb_bpp = (fb_vinfo.bits_per_pixel == 32) ? 32 : | |
654 (fb_vinfo.red.length + fb_vinfo.green.length + | |
655 fb_vinfo.blue.length); | |
418 | 656 if (vo_dbpp) { |
657 if (vo_dbpp != 15 && vo_dbpp != 16 && vo_dbpp != 24 && | |
658 vo_dbpp != 32) { | |
659 printf(FBDEV "can't switch to %d bpp\n", vo_dbpp); | |
383 | 660 goto err_out; |
359 | 661 } |
418 | 662 fb_bpp = vo_dbpp; |
359 | 663 } |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
664 |
393 | 665 fb_preinit_done = 1; |
666 fb_works = 1; | |
667 return 0; | |
668 err_out_fd: | |
669 close(fb_dev_fd); | |
670 fb_dev_fd = -1; | |
671 err_out: | |
672 fb_preinit_done = 1; | |
673 return 1; | |
674 } | |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
675 |
418 | 676 static void put_frame_without_bands(void); |
677 static void put_frame_with_bands(void); | |
678 | |
393 | 679 static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, |
680 uint32_t d_height, uint32_t fullscreen, char *title, | |
681 uint32_t format) | |
682 { | |
418 | 683 #define FS (fullscreen & 0x01) |
684 #define VM (fullscreen & 0x02) | |
685 #define ZOOM (fullscreen & 0x04) | |
686 | |
393 | 687 struct fb_cmap *cmap; |
688 | |
689 if (!fb_preinit_done) | |
690 if (fb_preinit()) | |
691 return 1; | |
692 if (!fb_works) | |
693 return 1; | |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
694 |
418 | 695 if (ZOOM) { |
696 printf(FBDEV "-zoom is not supported\n"); | |
697 return 1; | |
698 } | |
699 if (fb_mode_name && !VM) { | |
700 printf(FBDEV "-fbmode can be used only with -vm" | |
701 " (is it the right behaviour?)\n"); | |
702 return 1; | |
703 } | |
704 if (VM) | |
705 if (parse_fbmode_cfg(fb_mode_cfgfile) < 0) | |
706 return 1; | |
707 if ((!d_width + !d_height) == 1) { | |
708 printf(FBDEV "use both -x and -y, or none of them\n"); | |
709 return 1; | |
710 } | |
711 if (d_width) { | |
712 out_width = d_width; | |
713 out_height = d_height; | |
714 } else { | |
715 out_width = width; | |
716 out_height = height; | |
717 } | |
718 in_width = width; | |
719 in_height = height; | |
720 pixel_format = format; | |
721 | |
393 | 722 if (fb_mode_name) { |
418 | 723 if (!(fb_mode = find_mode_by_name(fb_mode_name))) { |
724 printf(FBDEV "can't find requested video mode\n"); | |
725 return 1; | |
726 } | |
727 fb_mode2fb_vinfo(fb_mode, &fb_vinfo); | |
728 } else if (VM) { | |
729 monitor_hfreq = str2range(monitor_hfreq_str); | |
730 monitor_vfreq = str2range(monitor_vfreq_str); | |
731 monitor_dotclock = str2range(monitor_dotclock_str); | |
732 if (!monitor_hfreq || !monitor_vfreq || !monitor_dotclock) { | |
733 printf(FBDEV "you have to specify the capabilities of" | |
734 " the monitor.\n"); | |
735 return 1; | |
736 } | |
737 if (!(fb_mode = find_best_mode(out_width, out_height, | |
738 monitor_hfreq, monitor_vfreq, | |
739 monitor_dotclock))) { | |
740 printf(FBDEV "can't find best video mode\n"); | |
741 return 1; | |
742 } | |
743 fb_mode2fb_vinfo(fb_mode, &fb_vinfo); | |
359 | 744 } |
418 | 745 fb_bpp_we_want = fb_bpp; |
746 set_bpp(&fb_vinfo, fb_bpp); | |
359 | 747 fb_vinfo.xres_virtual = fb_vinfo.xres; |
748 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
|
749 |
359 | 750 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) { |
393 | 751 printf(FBDEV "Can't put VSCREENINFO: %s\n", strerror(errno)); |
752 return 1; | |
753 } | |
754 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) { | |
755 printf(FBDEV "Can't get VSCREENINFO: %s\n", strerror(errno)); | |
756 return 1; | |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
757 } |
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
758 |
393 | 759 if (verbose > 0) { |
760 printf(FBDEV "var info:\n"); | |
761 printf(FBDEV "xres: %ul\n", fb_vinfo.xres); | |
762 printf(FBDEV "yres: %ul\n", fb_vinfo.yres); | |
763 printf(FBDEV "xres_virtual: %ul\n", fb_vinfo.xres_virtual); | |
764 printf(FBDEV "yres_virtual: %ul\n", fb_vinfo.yres_virtual); | |
765 printf(FBDEV "xoffset: %ul\n", fb_vinfo.xoffset); | |
766 printf(FBDEV "yoffset: %ul\n", fb_vinfo.yoffset); | |
767 printf(FBDEV "bits_per_pixel: %ul\n", fb_vinfo.bits_per_pixel); | |
768 printf(FBDEV "grayscale: %ul\n", fb_vinfo.grayscale); | |
769 printf(FBDEV "red: %lu %lu %lu\n", | |
770 (unsigned long) fb_vinfo.red.offset, | |
771 (unsigned long) fb_vinfo.red.length, | |
772 (unsigned long) fb_vinfo.red.msb_right); | |
773 printf(FBDEV "green: %lu %lu %lu\n", | |
774 (unsigned long) fb_vinfo.green.offset, | |
775 (unsigned long) fb_vinfo.green.length, | |
776 (unsigned long) fb_vinfo.green.msb_right); | |
777 printf(FBDEV "blue: %lu %lu %lu\n", | |
778 (unsigned long) fb_vinfo.blue.offset, | |
779 (unsigned long) fb_vinfo.blue.length, | |
780 (unsigned long) fb_vinfo.blue.msb_right); | |
781 printf(FBDEV "transp: %lu %lu %lu\n", | |
782 (unsigned long) fb_vinfo.transp.offset, | |
783 (unsigned long) fb_vinfo.transp.length, | |
784 (unsigned long) fb_vinfo.transp.msb_right); | |
785 printf(FBDEV "nonstd: %ul\n", fb_vinfo.nonstd); | |
786 if (verbose > 1) { | |
787 printf(FBDEV "activate: %ul\n", fb_vinfo.activate); | |
788 printf(FBDEV "height: %ul\n", fb_vinfo.height); | |
789 printf(FBDEV "width: %ul\n", fb_vinfo.width); | |
790 printf(FBDEV "accel_flags: %ul\n", fb_vinfo.accel_flags); | |
791 printf(FBDEV "timing:\n"); | |
792 printf(FBDEV "pixclock: %ul\n", fb_vinfo.pixclock); | |
793 printf(FBDEV "left_margin: %ul\n", fb_vinfo.left_margin); | |
794 printf(FBDEV "right_margin: %ul\n", fb_vinfo.right_margin); | |
795 printf(FBDEV "upper_margin: %ul\n", fb_vinfo.upper_margin); | |
796 printf(FBDEV "lower_margin: %ul\n", fb_vinfo.lower_margin); | |
797 printf(FBDEV "hsync_len: %ul\n", fb_vinfo.hsync_len); | |
798 printf(FBDEV "vsync_len: %ul\n", fb_vinfo.vsync_len); | |
799 printf(FBDEV "sync: %ul\n", fb_vinfo.sync); | |
800 printf(FBDEV "vmode: %ul\n", fb_vinfo.vmode); | |
801 } | |
802 } | |
359 | 803 if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo)) { |
393 | 804 printf(FBDEV "Can't get FSCREENINFO: %s\n", strerror(errno)); |
225 | 805 return 1; |
806 } | |
393 | 807 if (verbose > 0) { |
808 printf(FBDEV "fix info:\n"); | |
809 if (verbose > 1) { | |
810 printf(FBDEV "id: %.16s\n", fb_finfo.id); | |
811 printf(FBDEV "smem_start: %p\n", (void *) fb_finfo.smem_start); | |
812 } | |
813 printf(FBDEV "framebuffer size: %d bytes\n", fb_size); | |
814 printf(FBDEV "type: %lu\n", (unsigned long) fb_finfo.type); | |
815 printf(FBDEV "type_aux: %lu\n", (unsigned long) fb_finfo.type_aux); | |
816 printf(FBDEV "visual: %lu\n", (unsigned long) fb_finfo.visual); | |
817 if (verbose > 1) { | |
818 printf(FBDEV "xpanstep: %u\n", fb_finfo.xpanstep); | |
819 printf(FBDEV "ypanstep: %u\n", fb_finfo.ypanstep); | |
820 printf(FBDEV "ywrapstep: %u\n", fb_finfo.ywrapstep); | |
821 } | |
822 printf(FBDEV "line_length: %lu bytes\n", (unsigned long) fb_finfo.line_length); | |
823 if (verbose > 1) { | |
824 printf(FBDEV "mmio_start: %p\n", (void *) fb_finfo.mmio_start); | |
825 printf(FBDEV "mmio_len: %ul bytes\n", fb_finfo.mmio_len); | |
826 printf(FBDEV "accel: %ul\n", fb_finfo.accel); | |
827 } | |
828 } | |
359 | 829 switch (fb_finfo.type) { |
225 | 830 case FB_TYPE_VGA_PLANES: |
393 | 831 printf(FBDEV "FB_TYPE_VGA_PLANES not supported.\n"); |
832 return 1; | |
225 | 833 case FB_TYPE_PLANES: |
393 | 834 printf(FBDEV "FB_TYPE_PLANES not supported.\n"); |
835 return 1; | |
225 | 836 case FB_TYPE_INTERLEAVED_PLANES: |
393 | 837 printf(FBDEV "FB_TYPE_INTERLEAVED_PLANES not supported.\n"); |
838 return 1; | |
225 | 839 #ifdef FB_TYPE_TEXT |
840 case FB_TYPE_TEXT: | |
393 | 841 printf(FBDEV "FB_TYPE_TEXT not supported.\n"); |
842 return 1; | |
225 | 843 #endif |
844 case FB_TYPE_PACKED_PIXELS: | |
845 /* OK */ | |
379 | 846 if (verbose > 0) |
393 | 847 printf(FBDEV "FB_TYPE_PACKED_PIXELS: OK\n"); |
225 | 848 break; |
849 default: | |
393 | 850 printf(FBDEV "unknown FB_TYPE: %d\n", fb_finfo.type); |
851 return 1; | |
305 | 852 } |
379 | 853 switch (fb_finfo.visual) { |
393 | 854 case FB_VISUAL_TRUECOLOR: |
855 break; | |
856 case FB_VISUAL_DIRECTCOLOR: | |
857 if (verbose > 0) | |
858 printf(FBDEV "creating cmap for directcolor\n"); | |
481 | 859 if (ioctl(fb_dev_fd, FBIOGETCMAP, &fb_oldcmap)) { |
393 | 860 printf(FBDEV "can't get cmap: %s\n", |
861 strerror(errno)); | |
862 return 1; | |
863 } | |
864 if (!(cmap = make_directcolor_cmap(&fb_vinfo))) | |
865 return 1; | |
866 if (ioctl(fb_dev_fd, FBIOPUTCMAP, cmap)) { | |
867 printf(FBDEV "can't put cmap: %s\n", | |
868 strerror(errno)); | |
869 return 1; | |
870 } | |
481 | 871 fb_cmap_changed = 1; |
393 | 872 free(cmap->red); |
873 free(cmap->green); | |
874 free(cmap->blue); | |
875 free(cmap); | |
876 break; | |
877 case FB_VISUAL_PSEUDOCOLOR: | |
878 printf(FBDEV "visual is FB_VISUAL_PSEUDOCOLOR." | |
879 "it's not tested!\n"); | |
880 break; | |
881 default: | |
882 printf(FBDEV "visual: %d not yet supported\n", | |
883 fb_finfo.visual); | |
884 return 1; | |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
885 } |
418 | 886 if (FS || (d_width && VM)) { |
887 out_width = fb_vinfo.xres; | |
888 out_height = fb_vinfo.yres; | |
889 } | |
890 if (out_width < in_width || out_height < in_height) { | |
891 printf(FBDEV "screensize is smaller than video size\n"); | |
892 return 1; | |
893 } | |
894 left_band_width = (out_width - in_width) / 2; | |
895 right_band_width = (out_width - in_width + 1) / 2; | |
896 upper_band_height = (out_height - in_height) / 2; | |
897 lower_band_height = (out_height - in_height + 1) / 2; | |
898 if (left_band_width || right_band_width || upper_band_height || | |
899 lower_band_height) | |
900 put_frame = put_frame_with_bands; | |
901 else | |
902 put_frame = put_frame_without_bands; | |
245
cb4c682746c0
disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents:
231
diff
changeset
|
903 |
359 | 904 fb_pixel_size = fb_vinfo.bits_per_pixel / 8; |
905 fb_real_bpp = fb_vinfo.red.length + fb_vinfo.green.length + | |
906 fb_vinfo.blue.length; | |
907 fb_bpp = (fb_pixel_size == 4) ? 32 : fb_real_bpp; | |
393 | 908 if (fb_bpp_we_want != fb_bpp) |
418 | 909 printf(FBDEV "requested %d bpp, got %d bpp)!!!\n", |
393 | 910 fb_bpp_we_want, fb_bpp); |
359 | 911 fb_screen_width = fb_finfo.line_length; |
912 fb_size = fb_finfo.smem_len; | |
225 | 913 if ((frame_buffer = (uint8_t *) mmap(0, fb_size, PROT_READ | PROT_WRITE, |
914 MAP_SHARED, fb_dev_fd, 0)) == (uint8_t *) -1) { | |
393 | 915 printf(FBDEV "Can't mmap %s: %s\n", fb_dev_name, strerror(errno)); |
916 return 1; | |
225 | 917 } |
229 | 918 |
393 | 919 if (verbose > 0) { |
920 printf(FBDEV "other:\n"); | |
921 if (verbose > 1) | |
922 printf(FBDEV "frame_buffer @ %p\n", frame_buffer); | |
923 printf(FBDEV "fb_bpp: %d\n", fb_bpp); | |
924 printf(FBDEV "fb_real_bpp: %d\n", fb_real_bpp); | |
925 printf(FBDEV "fb_pixel_size: %d bytes\n", fb_pixel_size); | |
926 printf(FBDEV "pixel per line: %d\n", fb_screen_width / fb_pixel_size); | |
379 | 927 } |
225 | 928 |
278 | 929 if (!(next_frame = (uint8_t *) malloc(in_width * in_height * fb_pixel_size))) { |
393 | 930 printf(FBDEV "Can't malloc next_frame: %s\n", strerror(errno)); |
225 | 931 return 1; |
932 } | |
933 | |
934 if (format == IMGFMT_YV12) | |
359 | 935 yuv2rgb_init(fb_bpp, MODE_RGB); |
225 | 936 return 0; |
937 } | |
938 | |
939 static uint32_t query_format(uint32_t format) | |
940 { | |
393 | 941 if (!fb_preinit_done) |
942 if (fb_preinit()) | |
229 | 943 return 0; |
305 | 944 if (!fb_works) |
945 return 0; | |
946 | |
380 | 947 if (verbose > 0) |
393 | 948 printf(FBDEV "query_format(%#lx(%.4s))\n",(unsigned long) format, |
949 (char *) &format); | |
311 | 950 if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR) { |
951 int bpp = format & 0xff; | |
359 | 952 if (bpp == fb_bpp) |
311 | 953 return 1; |
359 | 954 else if (bpp == 15 && fb_bpp == 16) |
311 | 955 return 1; |
359 | 956 else if (bpp == 24 && fb_bpp == 32) |
311 | 957 return 1; |
958 } | |
959 if (format == IMGFMT_YV12) | |
960 return 1; | |
961 return 0; | |
225 | 962 } |
963 | |
964 static const vo_info_t *get_info(void) | |
965 { | |
966 return &vo_info; | |
967 } | |
968 | |
393 | 969 extern void vo_draw_alpha_rgb32(int w, int h, unsigned char* src, |
970 unsigned char *srca, int srcstride, unsigned char* dstbase, | |
971 int dststride); | |
972 extern void vo_draw_alpha_rgb24(int w, int h, unsigned char* src, | |
973 unsigned char *srca, int srcstride, unsigned char* dstbase, | |
974 int dststride); | |
975 extern void vo_draw_alpha_rgb16(int w, int h, unsigned char* src, | |
976 unsigned char *srca, int srcstride, unsigned char* dstbase, | |
977 int dststride); | |
978 extern void vo_draw_alpha_rgb15(int w, int h, unsigned char* src, | |
979 unsigned char *srca, int srcstride, unsigned char* dstbase, | |
980 int dststride); | |
981 | |
225 | 982 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, |
983 unsigned char *srca, int stride) | |
984 { | |
359 | 985 uint8_t *dst = next_frame + (in_width * y0 + x0) * fb_pixel_size; |
986 int dstride = in_width * fb_pixel_size; | |
987 | |
988 switch (fb_real_bpp) { | |
989 case 24: | |
990 vo_draw_alpha_rgb24(w, h, src, srca, stride, dst, dstride); | |
991 break; | |
992 case 32: | |
993 vo_draw_alpha_rgb32(w, h, src, srca, stride, dst, dstride); | |
994 break; | |
995 case 15: | |
996 vo_draw_alpha_rgb15(w, h, src, srca, stride, dst, dstride); | |
997 break; | |
998 case 16: | |
999 vo_draw_alpha_rgb16(w, h, src, srca, stride, dst, dstride); | |
1000 break; | |
1001 } | |
225 | 1002 } |
1003 | |
1004 static uint32_t draw_frame(uint8_t *src[]) | |
1005 { | |
1006 if (pixel_format == IMGFMT_YV12) { | |
1007 yuv2rgb(next_frame, src[0], src[1], src[2], in_width, | |
278 | 1008 in_height, in_width * fb_pixel_size, |
225 | 1009 in_width, in_width / 2); |
311 | 1010 } else { |
1011 int sbpp = ((pixel_format & 0xff) + 7) / 8; | |
1012 char *d = next_frame; | |
1013 char *s = src[0]; | |
1014 if (sbpp == fb_pixel_size) { | |
359 | 1015 if (fb_real_bpp == 16 && pixel_format == (IMGFMT_BGR|15)) { |
311 | 1016 #ifdef HAVE_MMX |
1017 rgb15to16_mmx(s, d, 2 * in_width * in_height); | |
1018 #else | |
1019 unsigned short *s1 = (unsigned short *) s; | |
1020 unsigned short *d1 = (unsigned short *) d; | |
1021 unsigned short *e = s1 + in_width * in_height; | |
1022 while (s1<e) { | |
1023 register x = *(s1++); | |
1024 *(d1++) = (x&0x001f)|((x&0x7fe0)<<1); | |
1025 } | |
1026 #endif | |
1027 } else | |
1028 memcpy(d, s, sbpp * in_width * in_height); | |
1029 } | |
1030 } | |
225 | 1031 return 0; |
1032 } | |
1033 | |
1034 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, | |
1035 int y) | |
1036 { | |
1037 uint8_t *dest; | |
1038 | |
278 | 1039 dest = next_frame + (in_width * y + x) * fb_pixel_size; |
1040 yuv2rgb(dest, src[0], src[1], src[2], w, h, in_width * fb_pixel_size, | |
225 | 1041 stride[0], stride[1]); |
1042 return 0; | |
1043 } | |
1044 | |
1045 static void check_events(void) | |
1046 { | |
1047 } | |
1048 | |
418 | 1049 static void put_frame_without_bands(void) |
225 | 1050 { |
1051 int i, out_offset = 0, in_offset = 0; | |
1052 | |
1053 for (i = 0; i < in_height; i++) { | |
1054 memcpy(frame_buffer + out_offset, next_frame + in_offset, | |
423 | 1055 in_width * fb_pixel_size); |
359 | 1056 out_offset += fb_screen_width; |
278 | 1057 in_offset += in_width * fb_pixel_size; |
225 | 1058 } |
1059 } | |
1060 | |
418 | 1061 static void put_frame_with_bands(void) |
1062 { | |
1063 int i, out_offset = 0, in_offset = 0, w, bw, tmp; | |
1064 | |
1065 if (upper_band_height) { | |
1066 out_offset = upper_band_height * out_width * fb_pixel_size; | |
1067 memset(frame_buffer, 0x00, out_offset); | |
1068 } | |
1069 if (left_band_width) { | |
1070 tmp = left_band_width * fb_pixel_size; | |
1071 memset(frame_buffer + out_offset, 0x00, tmp); | |
1072 out_offset += tmp; | |
1073 } | |
1074 w = in_width * fb_pixel_size; | |
1075 bw = (left_band_width + right_band_width) * fb_pixel_size; | |
1076 for (i = 0; i < in_height - 1; i++) { | |
1077 memcpy(frame_buffer + out_offset, next_frame + in_offset, w); | |
1078 if (bw) | |
1079 memset(frame_buffer + out_offset + w, 0x00, bw); | |
1080 out_offset += fb_screen_width; | |
1081 in_offset += w; | |
1082 } | |
1083 memcpy(frame_buffer + out_offset, next_frame + in_offset, w); | |
1084 out_offset += w; | |
1085 if (right_band_width) { | |
1086 tmp = right_band_width * fb_pixel_size; | |
1087 memset(frame_buffer + out_offset, 0x00, tmp); | |
1088 out_offset += tmp; | |
1089 } | |
1090 if (lower_band_height) | |
1091 memset(frame_buffer + out_offset, 0x00, lower_band_height * | |
1092 out_width * fb_pixel_size); | |
1093 } | |
1094 | |
393 | 1095 extern void vo_draw_text(int dxs, int dys, void (*draw_alpha)(int x0, int y0, |
1096 int w, int h, unsigned char *src, unsigned char *srca, | |
1097 int stride)); | |
1098 | |
246 | 1099 static void flip_page(void) |
1100 { | |
1101 vo_draw_text(in_width, in_height, draw_alpha); | |
1102 check_events(); | |
418 | 1103 (*put_frame)(); |
246 | 1104 } |
1105 | |
225 | 1106 static void uninit(void) |
1107 { | |
379 | 1108 if (verbose > 0) |
393 | 1109 printf(FBDEV "uninit\n"); |
481 | 1110 if (fb_cmap_changed) { |
1111 if (ioctl(fb_dev_fd, FBIOPUTCMAP, &fb_oldcmap)) | |
393 | 1112 printf(FBDEV "Can't restore original cmap\n"); |
481 | 1113 fb_cmap_changed = 0; |
306 | 1114 } |
379 | 1115 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_orig_vinfo)) |
393 | 1116 printf(FBDEV "Can't set virtual screensize to original value: %s\n", strerror(errno)); |
359 | 1117 close(fb_dev_fd); |
278 | 1118 memset(next_frame, '\0', in_height * in_width * fb_pixel_size); |
246 | 1119 put_frame(); |
225 | 1120 free(next_frame); |
1121 munmap(frame_buffer, fb_size); | |
1122 } |