annotate libvo/vo_fbdev.c @ 16756:bede9bedd45a

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