annotate libvo/vo_fbdev.c @ 31366:0bf908d29807

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