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