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