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