annotate libvo/vo_fbdev.c @ 7149:aa9debe16559

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