annotate libvo/vo_fbdev.c @ 745:c653430f0789

<sigh> links replaced again </sigh>
author gabucino
date Wed, 09 May 2001 23:41:01 +0000
parents 121cb2047c08
children c3fad5e1698e
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>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
22 #include <linux/fb.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
23
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
24 #include "config.h"
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
25 #include "video_out.h"
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
26 #include "video_out_internal.h"
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
27 #include "fastmemcpy.h"
633
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
28 #include "osd.h"
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
29 #include "sub.h"
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
30 #include "yuv2rgb.h"
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
31 extern void rgb15to16_mmx(char *s0, char *d0, int count);
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
32
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
33 LIBVO_EXTERN(fbdev)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
34
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
35 static vo_info_t vo_info = {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
36 "Framebuffer Device",
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
37 "fbdev",
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
38 "Szabolcs Berecz <szabi@inf.elte.hu>",
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
39 ""
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
40 };
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
41
379
368f16e72583 cleanup
szabii
parents: 365
diff changeset
42 extern int verbose;
368f16e72583 cleanup
szabii
parents: 365
diff changeset
43
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
44 /******************************
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
45 * fb.modes support *
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
46 ******************************/
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
47
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
48 /*
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
49 * read the fb.modes manual page!
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
50 */
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
51
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
52 typedef struct {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
53 char *name;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
54 uint32_t xres, yres, vxres, vyres, depth;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
55 uint32_t pixclock, left, right, upper, lower, hslen, vslen;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
56 uint32_t sync;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
57 uint32_t vmode;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
58 } fb_mode_t;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
59
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
60 #define PRINT_LINENUM printf(" at line %d\n", line_num)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
61
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
62 #define MAX_NR_TOKEN 16
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
63
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
64 #define MAX_LINE_LEN 1000
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
65
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
66 #define RET_EOF -1
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
67 #define RET_EOL -2
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
68
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
69 static int validate_mode(fb_mode_t *m)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
70 {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
71 if (!m->xres) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
72 printf("needs geometry ");
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
73 return 0;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
74 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
75 if (!m->pixclock) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
76 printf("needs timings ");
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
77 return 0;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
78 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
79 return 1;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
80 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
81
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
82 static FILE *fp;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
83 static int line_num = 0;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
84 static char *line;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
85 static char *token[MAX_NR_TOKEN];
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
86
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
87 static int get_token(int num)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
88 {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
89 static int read_nextline = 1;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
90 static int line_pos;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
91 int i;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
92 char c;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
93
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
94 if (num >= MAX_NR_TOKEN) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
95 printf("get_token(): max >= MAX_NR_TOKEN!");
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
96 goto out_eof;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
97 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
98
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
99 if (read_nextline) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
100 if (!fgets(line, MAX_LINE_LEN, fp))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
101 goto out_eof;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
102 line_pos = 0;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
103 ++line_num;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
104 read_nextline = 0;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
105 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
106 for (i = 0; i < num; i++) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
107 while (isspace(line[line_pos]))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
108 ++line_pos;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
109 if (line[line_pos] == '\0' || line[line_pos] == '#') {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
110 read_nextline = 1;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
111 if (i == num)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
112 goto out_ok;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
113 goto out_eol;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
114 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
115 token[i] = line + line_pos;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
116 c = line[line_pos];
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
117 if (c == '"' || c == '\'') {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
118 token[i]++;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
119 while (line[++line_pos] != c && line[line_pos])
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
120 /* NOTHING */;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
121 } else {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
122 for (/* NOTHING */; !isspace(line[line_pos]) &&
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
123 line[line_pos]; line_pos++)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
124 /* NOTHING */;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
125 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
126 if (!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 if (i == num - 1)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
129 goto out_ok;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
130 goto out_eol;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
131 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
132 line[line_pos] = '\0';
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
133 line_pos++;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
134 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
135 out_ok:
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
136 return i;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
137 out_eof:
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
138 return RET_EOF;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
139 out_eol:
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
140 return RET_EOL;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
141 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
142
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
143 static fb_mode_t *fb_modes = NULL;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
144 static int nr_modes = 0;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
145
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
146 static int parse_fbmode_cfg(char *cfgfile)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
147 {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
148 fb_mode_t *mode = NULL;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
149 char *endptr; // strtoul()...
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
150 int tmp, i;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
151
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
152 #ifdef DEBUG
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
153 assert(cfgfile != NULL);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
154 #endif
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
155
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
156 printf("Reading %s: ", cfgfile);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
157
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
158 if ((fp = fopen(cfgfile, "r")) == NULL) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
159 printf("can't open '%s': %s\n", cfgfile, strerror(errno));
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
160 return -1;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
161 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
162
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
163 if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
164 printf("can't get memory for 'line': %s\n", strerror(errno));
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
165 return -2;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
166 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
167
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
168 /*
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
169 * check if the cfgfile starts with 'mode'
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
170 */
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
171 while ((tmp = get_token(1)) == RET_EOL)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
172 /* NOTHING */;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
173 if (tmp == RET_EOF)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
174 goto out;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
175 if (!strcmp(token[0], "mode"))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
176 goto loop_enter;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
177 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
178
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
179 while ((tmp = get_token(1)) != RET_EOF) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
180 if (tmp == RET_EOL)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
181 continue;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
182 if (!strcmp(token[0], "mode")) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
183 if (!validate_mode(mode))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
184 goto err_out_not_valid;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
185 loop_enter:
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
186 if (!(fb_modes = (fb_mode_t *) realloc(fb_modes,
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
187 sizeof(fb_mode_t) * (nr_modes + 1)))) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
188 printf("can't realloc 'fb_modes': %s\n", strerror(errno));
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
189 goto err_out;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
190 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
191 mode=fb_modes + nr_modes;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
192 ++nr_modes;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
193 memset(mode,0,sizeof(fb_mode_t));
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
194
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
195 if (get_token(1) < 0)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
196 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
197 for (i = 0; i < nr_modes - 1; i++) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
198 if (!strcmp(token[0], fb_modes[i].name)) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
199 printf("mode name '%s' isn't unique", token[0]);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
200 goto err_out_print_linenum;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
201 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
202 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
203 if (!(mode->name = strdup(token[0]))) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
204 printf("can't strdup -> 'name': %s\n", strerror(errno));
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
205 goto err_out;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
206 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
207 } else if (!strcmp(token[0], "geometry")) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
208 if (get_token(5) < 0)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
209 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
210 mode->xres = strtoul(token[0], &endptr, 0);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
211 if (*endptr)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
212 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
213 mode->yres = strtoul(token[1], &endptr, 0);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
214 if (*endptr)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
215 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
216 mode->vxres = strtoul(token[2], &endptr, 0);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
217 if (*endptr)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
218 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
219 mode->vyres = strtoul(token[3], &endptr, 0);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
220 if (*endptr)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
221 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
222 mode->depth = strtoul(token[4], &endptr, 0);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
223 if (*endptr)
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 } else if (!strcmp(token[0], "timings")) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
226 if (get_token(7) < 0)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
227 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
228 mode->pixclock = strtoul(token[0], &endptr, 0);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
229 if (*endptr)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
230 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
231 mode->left = strtoul(token[1], &endptr, 0);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
232 if (*endptr)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
233 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
234 mode->right = strtoul(token[2], &endptr, 0);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
235 if (*endptr)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
236 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
237 mode->upper = strtoul(token[3], &endptr, 0);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
238 if (*endptr)
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->lower = strtoul(token[4], &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->hslen = strtoul(token[5], &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->vslen = strtoul(token[6], &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 } else if (!strcmp(token[0], "endmode")) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
250 /* NOTHING for now*/
383
086c66d570d8 some fixes
szabii
parents: 380
diff changeset
251 } else if (!strcmp(token[0], "accel")) {
086c66d570d8 some fixes
szabii
parents: 380
diff changeset
252 if (get_token(1) < 0)
086c66d570d8 some fixes
szabii
parents: 380
diff changeset
253 goto err_out_parse_error;
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
254 /*
e847396dc49f some changes...
szabii
parents: 383
diff changeset
255 * it's only used for text acceleration
e847396dc49f some changes...
szabii
parents: 383
diff changeset
256 * so we just ignore it.
e847396dc49f some changes...
szabii
parents: 383
diff changeset
257 */
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
258 } else if (!strcmp(token[0], "hsync")) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
259 if (get_token(1) < 0)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
260 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
261 if (!strcmp(token[0], "low"))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
262 mode->sync &= ~FB_SYNC_HOR_HIGH_ACT;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
263 else if(!strcmp(token[0], "high"))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
264 mode->sync |= FB_SYNC_HOR_HIGH_ACT;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
265 else
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
266 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
267 } else if (!strcmp(token[0], "vsync")) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
268 if (get_token(1) < 0)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
269 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
270 if (!strcmp(token[0], "low"))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
271 mode->sync &= ~FB_SYNC_VERT_HIGH_ACT;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
272 else if(!strcmp(token[0], "high"))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
273 mode->sync |= FB_SYNC_VERT_HIGH_ACT;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
274 else
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
275 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
276 } else if (!strcmp(token[0], "csync")) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
277 if (get_token(1) < 0)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
278 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
279 if (!strcmp(token[0], "low"))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
280 mode->sync &= ~FB_SYNC_COMP_HIGH_ACT;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
281 else if(!strcmp(token[0], "high"))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
282 mode->sync |= FB_SYNC_COMP_HIGH_ACT;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
283 else
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
284 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
285 } else if (!strcmp(token[0], "extsync")) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
286 if (get_token(1) < 0)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
287 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
288 if (!strcmp(token[0], "false"))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
289 mode->sync &= ~FB_SYNC_EXT;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
290 else if(!strcmp(token[0], "true"))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
291 mode->sync |= FB_SYNC_EXT;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
292 else
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
293 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
294 } else if (!strcmp(token[0], "laced")) {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
295 if (get_token(1) < 0)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
296 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
297 if (!strcmp(token[0], "false"))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
298 mode->vmode = FB_VMODE_NONINTERLACED;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
299 else if (!strcmp(token[0], "true"))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
300 mode->vmode = FB_VMODE_INTERLACED;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
301 else
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
302 goto err_out_parse_error;
479
1302e63cee73 dumb bug
szabii
parents: 476
diff changeset
303 } else if (!strcmp(token[0], "double")) {
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
304 if (get_token(1) < 0)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
305 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
306 if (!strcmp(token[0], "false"))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
307 ;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
308 else if (!strcmp(token[0], "true"))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
309 mode->vmode = FB_VMODE_DOUBLE;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
310 else
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
311 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
312 } else
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
313 goto err_out_parse_error;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
314 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
315 if (!validate_mode(mode))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
316 goto err_out_not_valid;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
317 out:
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
318 printf("%d modes\n", nr_modes);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
319 free(line);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
320 fclose(fp);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
321 return nr_modes;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
322 err_out_parse_error:
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
323 printf("parse error");
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
324 err_out_print_linenum:
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
325 PRINT_LINENUM;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
326 err_out:
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
327 if (fb_modes) {
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
328 free(fb_modes);
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
329 fb_modes = NULL;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
330 }
e847396dc49f some changes...
szabii
parents: 383
diff changeset
331 nr_modes = 0;
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
332 free(line);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
333 free(fp);
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
334 return -2;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
335 err_out_not_valid:
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
336 printf("mode is not definied correctly");
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
337 goto err_out_print_linenum;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
338 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
339
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
340 static fb_mode_t *find_mode_by_name(char *name)
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
341 {
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
342 int i;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
343
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
344 for (i = 0; i < nr_modes; i++)
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
345 if (!strcmp(name, fb_modes[i].name))
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
346 return fb_modes + i;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
347 return NULL;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
348 }
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
349
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
350 static float dcf(fb_mode_t *m) //driving clock frequency
e847396dc49f some changes...
szabii
parents: 383
diff changeset
351 {
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
352 return 1e12f / m->pixclock;
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
353 }
e847396dc49f some changes...
szabii
parents: 383
diff changeset
354
e847396dc49f some changes...
szabii
parents: 383
diff changeset
355 static float hsf(fb_mode_t *m) //horizontal scan frequency
e847396dc49f some changes...
szabii
parents: 383
diff changeset
356 {
e847396dc49f some changes...
szabii
parents: 383
diff changeset
357 int htotal = m->left + m->xres + m->right + m->hslen;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
358 return dcf(m) / htotal;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
359 }
e847396dc49f some changes...
szabii
parents: 383
diff changeset
360
e847396dc49f some changes...
szabii
parents: 383
diff changeset
361 static float vsf(fb_mode_t *m) //vertical scan frequency
e847396dc49f some changes...
szabii
parents: 383
diff changeset
362 {
e847396dc49f some changes...
szabii
parents: 383
diff changeset
363 int vtotal = m->upper + m->yres + m->lower + m->vslen;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
364 return hsf(m) / vtotal;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
365 }
e847396dc49f some changes...
szabii
parents: 383
diff changeset
366
e847396dc49f some changes...
szabii
parents: 383
diff changeset
367 typedef struct {
e847396dc49f some changes...
szabii
parents: 383
diff changeset
368 float min;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
369 float max;
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
370 } range_t;
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
371
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
372 static int in_range(range_t *r, float f)
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
373 {
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
374 for (/* NOTHING */; (r->min != -1 && r->max != -1); r++)
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
375 if (f >= r->min && f <= r->max)
e847396dc49f some changes...
szabii
parents: 383
diff changeset
376 return 1;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
377 return 0;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
378 }
e847396dc49f some changes...
szabii
parents: 383
diff changeset
379
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
380 static fb_mode_t *find_best_mode(int xres, int yres, range_t *hfreq,
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
381 range_t *vfreq, range_t *dotclock)
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
382 {
e847396dc49f some changes...
szabii
parents: 383
diff changeset
383 int i;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
384 fb_mode_t *best = fb_modes;
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
385 fb_mode_t *curr;
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
386
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
387 /* find first working mode */
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
388 for (i = nr_modes - 1; i; i--, best++) {
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
389 if (in_range(hfreq, hsf(best)) && in_range(vfreq, vsf(best)) &&
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
390 in_range(dotclock, dcf(best)))
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
391 break;
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
392 if (verbose > 1)
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
393 printf(FBDEV "can't set %dx%d\n", best->xres, best->yres);
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
394 }
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
395
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
396 if (!i)
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
397 return NULL;
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
398 if (i == 1)
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
399 return best;
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
400
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
401 for (curr = best + 1; i; i--, curr++) {
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
402 if (!in_range(hfreq, hsf(curr)))
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
403 continue;
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
404 if (!in_range(vfreq, vsf(curr)))
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
405 continue;
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
406 if (!in_range(dotclock, dcf(curr)))
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
407 continue;
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
408 if (verbose > 1)
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
409 printf(FBDEV "%dx%d ", curr->xres, curr->yres);
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
410 if ((best->xres < xres || best->yres < yres) &&
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
411 (curr->xres > best->xres ||
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
412 curr->yres > best->yres)) {
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
413 if (verbose > 1)
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
414 printf("better than %dx%d\n", best->xres,
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
415 best->yres);
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
416 best = curr;
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
417 } else if (curr->xres >= xres && curr->yres >= yres) {
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
418 if (curr->xres < best->xres && curr->yres < best->yres) {
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
419 if (verbose > 1)
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
420 printf("smaller than %dx%d\n",
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
421 best->xres, best->yres);
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
422 best = curr;
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
423 } else if (curr->xres == best->xres &&
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
424 curr->yres == best->yres &&
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
425 (vsf(curr) > vsf(best))) {
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
426 if (verbose > 1)
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
427 printf("faster screen refresh\n");
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
428 best = curr;
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
429 } else if (verbose > 1)
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
430 printf("\n");
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
431 } else if (verbose > 1)
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
432 printf("is too small\n");
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
433 }
e847396dc49f some changes...
szabii
parents: 383
diff changeset
434 return best;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
435 }
e847396dc49f some changes...
szabii
parents: 383
diff changeset
436
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
437 static void set_bpp(struct fb_var_screeninfo *p, int bpp)
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
438 {
476
1897ed6661bf small change
szabii
parents: 423
diff changeset
439 p->bits_per_pixel = (bpp + 1) & ~1;
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
440 p->red.msb_right = p->green.msb_right = p->blue.msb_right = 0;
563
5eb28ba8a96a nothing important
szabii
parents: 550
diff changeset
441 p->transp.offset = p->transp.length = 0;
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
442 switch (bpp) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
443 case 32:
563
5eb28ba8a96a nothing important
szabii
parents: 550
diff changeset
444 p->transp.offset = 24;
5eb28ba8a96a nothing important
szabii
parents: 550
diff changeset
445 p->transp.length = 8;
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
446 case 24:
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
447 p->red.offset = 16;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
448 p->red.length = 8;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
449 p->green.offset = 8;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
450 p->green.length = 8;
550
58b24a998cb5 nothing important?
szabii
parents: 538
diff changeset
451 p->blue.length = 8;
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
452 p->blue.offset = 0;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
453 break;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
454 case 16:
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
455 p->red.offset = 11;
550
58b24a998cb5 nothing important?
szabii
parents: 538
diff changeset
456 p->green.length = 6;
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
457 p->red.length = 5;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
458 p->green.offset = 5;
550
58b24a998cb5 nothing important?
szabii
parents: 538
diff changeset
459 p->blue.length = 5;
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
460 p->blue.offset = 0;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
461 break;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
462 case 15:
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
463 p->red.offset = 10;
550
58b24a998cb5 nothing important?
szabii
parents: 538
diff changeset
464 p->green.length = 5;
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
465 p->red.length = 5;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
466 p->green.offset = 5;
550
58b24a998cb5 nothing important?
szabii
parents: 538
diff changeset
467 p->blue.length = 5;
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
468 p->blue.offset = 0;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
469 break;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
470 }
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
471 }
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
472
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
473 static void fb_mode2fb_vinfo(fb_mode_t *m, struct fb_var_screeninfo *v)
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
474 {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
475 v->xres = m->xres;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
476 v->yres = m->yres;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
477 v->xres_virtual = m->vxres;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
478 v->yres_virtual = m->vyres;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
479 set_bpp(v, m->depth);
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
480 v->pixclock = m->pixclock;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
481 v->left_margin = m->left;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
482 v->right_margin = m->right;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
483 v->upper_margin = m->upper;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
484 v->lower_margin = m->lower;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
485 v->hsync_len = m->hslen;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
486 v->vsync_len = m->vslen;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
487 v->sync = m->sync;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
488 v->vmode = m->vmode;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
489 }
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
490
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
491 static range_t *str2range(char *s)
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
492 {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
493 float tmp_min, tmp_max;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
494 char *endptr = s; // to start the loop
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
495 range_t *r = NULL;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
496 int i, j;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
497
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
498 if (!s)
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
499 return NULL;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
500 for (i = 0; *endptr; i++) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
501 if (*s == ',')
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
502 goto out_err;
538
eea574dff0fd dumb bug fixed
szabii
parents: 520
diff changeset
503 if (!(r = (range_t *) realloc(r, sizeof(*r) * (i + 2)))) {
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
504 printf("can't realloc 'r'\n");
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
505 return NULL;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
506 }
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
507 tmp_min = strtod(s, &endptr);
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
508 if (*endptr == 'k' || *endptr == 'K') {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
509 tmp_min *= 1000.0;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
510 endptr++;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
511 } else if (*endptr == 'm' || *endptr == 'M') {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
512 tmp_min *= 1000000.0;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
513 endptr++;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
514 }
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
515 if (*endptr == '-') {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
516 tmp_max = strtod(endptr + 1, &endptr);
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
517 if (*endptr == 'k' || *endptr == 'K') {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
518 tmp_max *= 1000.0;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
519 endptr++;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
520 } else if (*endptr == 'm' || *endptr == 'M') {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
521 tmp_max *= 1000000.0;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
522 endptr++;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
523 }
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
524 if (*endptr != ',' && *endptr)
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
525 goto out_err;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
526 } else if (*endptr == ',' || !*endptr) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
527 tmp_max = tmp_min;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
528 } else
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
529 goto out_err;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
530 r[i].min = tmp_min;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
531 r[i].max = tmp_max;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
532 s = endptr + 1;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
533 }
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
534 /* check if we have negative numbers... */
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
535 for (j = 0; j < i; j++)
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
536 if (r[j].min < 0 || r[j].max < 0)
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
537 goto out_err;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
538 r[i].min = r[i].max = -1;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
539 return r;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
540 out_err:
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
541 if (r)
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
542 free(r);
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
543 return NULL;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
544 }
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
545
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
546 /******************************
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
547 * vo_fbdev *
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
548 ******************************/
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
549
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
550 /* command line/config file options */
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
551 char *fb_dev_name = NULL;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
552 char *fb_mode_cfgfile = "/etc/fb.modes";
e847396dc49f some changes...
szabii
parents: 383
diff changeset
553 char *fb_mode_name = NULL;
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
554 char *monitor_hfreq_str = NULL;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
555 char *monitor_vfreq_str = NULL;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
556 char *monitor_dotclock_str = NULL;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
557
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
558 /* fb.modes related variables */
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
559 range_t *monitor_hfreq = NULL;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
560 range_t *monitor_vfreq = NULL;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
561 range_t *monitor_dotclock = NULL;
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
562 static fb_mode_t *fb_mode = NULL;
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
563
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
564 /* vo_fbdev related variables */
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
565 static int fb_preinit_done = 0;
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
566 static int fb_works = 0;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
567 static int fb_dev_fd;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
568 static size_t fb_size;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
569 static uint8_t *frame_buffer;
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
570 static uint8_t *L123123875; /* thx .so :) */
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
571 static struct fb_fix_screeninfo fb_finfo;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
572 static struct fb_var_screeninfo fb_orig_vinfo;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
573 static struct fb_var_screeninfo fb_vinfo;
481
6e8a887c99cd cmap bug fixed (I think)
szabii
parents: 479
diff changeset
574 static struct fb_cmap fb_oldcmap;
6e8a887c99cd cmap bug fixed (I think)
szabii
parents: 479
diff changeset
575 static int fb_cmap_changed = 0;
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
576 static int fb_pixel_size; // 32: 4 24: 3 16: 2 15: 2
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
577 static int fb_real_bpp; // 32: 24 24: 24 16: 16 15: 15
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
578 static int fb_bpp; // 32: 32 24: 24 16: 16 15: 15
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
579 static int fb_bpp_we_want; // 32: 32 24: 24 16: 16 15: 15
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
580 static int fb_screen_width;
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
581 static void (*draw_alpha_p)(int w, int h, unsigned char *src,
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
582 unsigned char *srca, int stride, unsigned char *dst,
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
583 int dstride);
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
584
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
585 static uint8_t *next_frame;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
586 static int in_width;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
587 static int in_height;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
588 static int out_width;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
589 static int out_height;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
590 static uint32_t pixel_format;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
591
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
592 /*
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
593 * Note: this function is completely cut'n'pasted from
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
594 * Chris Lawrence's code.
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
595 * (modified a bit to fit in my code...)
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
596 */
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
597 struct fb_cmap *make_directcolor_cmap(struct fb_var_screeninfo *var)
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
598 {
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
599 /* Hopefully any DIRECTCOLOR device will have a big enough palette
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
600 * to handle mapping the full color depth.
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
601 * e.g. 8 bpp -> 256 entry palette
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
602 *
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
603 * We could handle some sort of gamma here
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
604 */
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
605 int i, cols, rcols, gcols, bcols;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
606 uint16_t *red, *green, *blue;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
607 struct fb_cmap *cmap;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
608
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
609 rcols = 1 << var->red.length;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
610 gcols = 1 << var->green.length;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
611 bcols = 1 << var->blue.length;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
612
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
613 /* Make our palette the length of the deepest color */
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
614 cols = (rcols > gcols ? rcols : gcols);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
615 cols = (cols > bcols ? cols : bcols);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
616
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
617 red = malloc(cols * sizeof(red[0]));
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
618 if(!red) {
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
619 printf("Can't allocate red palette with %d entries.\n", cols);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
620 return NULL;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
621 }
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
622 for(i=0; i< rcols; i++)
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
623 red[i] = (65535/(rcols-1)) * i;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
624
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
625 green = malloc(cols * sizeof(green[0]));
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
626 if(!green) {
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
627 printf("Can't allocate green palette with %d entries.\n", cols);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
628 free(red);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
629 return NULL;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
630 }
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
631 for(i=0; i< gcols; i++)
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
632 green[i] = (65535/(gcols-1)) * i;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
633
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
634 blue = malloc(cols * sizeof(blue[0]));
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
635 if(!blue) {
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
636 printf("Can't allocate blue palette with %d entries.\n", cols);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
637 free(red);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
638 free(green);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
639 return NULL;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
640 }
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
641 for(i=0; i< bcols; i++)
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
642 blue[i] = (65535/(bcols-1)) * i;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
643
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
644 cmap = malloc(sizeof(struct fb_cmap));
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
645 if(!cmap) {
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
646 printf("Can't allocate color map\n");
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
647 free(red);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
648 free(green);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
649 free(blue);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
650 return NULL;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
651 }
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
652 cmap->start = 0;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
653 cmap->transp = 0;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
654 cmap->len = cols;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
655 cmap->red = red;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
656 cmap->blue = blue;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
657 cmap->green = green;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
658 cmap->transp = NULL;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
659
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
660 return cmap;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
661 }
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
662
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
663 static int fb_preinit(void)
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
664 {
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
665 if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER")))
e847396dc49f some changes...
szabii
parents: 383
diff changeset
666 fb_dev_name = "/dev/fb0";
e847396dc49f some changes...
szabii
parents: 383
diff changeset
667 if (verbose > 0)
e847396dc49f some changes...
szabii
parents: 383
diff changeset
668 printf(FBDEV "using %s\n", fb_dev_name);
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
669
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
670 if ((fb_dev_fd = open(fb_dev_name, O_RDWR)) == -1) {
e847396dc49f some changes...
szabii
parents: 383
diff changeset
671 printf(FBDEV "Can't open %s: %s\n", fb_dev_name, strerror(errno));
e847396dc49f some changes...
szabii
parents: 383
diff changeset
672 goto err_out;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
673 }
e847396dc49f some changes...
szabii
parents: 383
diff changeset
674 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) {
e847396dc49f some changes...
szabii
parents: 383
diff changeset
675 printf(FBDEV "Can't get VSCREENINFO: %s\n", strerror(errno));
e847396dc49f some changes...
szabii
parents: 383
diff changeset
676 goto err_out_fd;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
677 }
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
678 fb_orig_vinfo = fb_vinfo;
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
679
663
121cb2047c08 nothing important
szabii
parents: 659
diff changeset
680 fb_bpp = fb_vinfo.bits_per_pixel;
121cb2047c08 nothing important
szabii
parents: 659
diff changeset
681
121cb2047c08 nothing important
szabii
parents: 659
diff changeset
682 /* 16 and 15 bpp is reported 16 bpp */
121cb2047c08 nothing important
szabii
parents: 659
diff changeset
683 if (fb_bpp == 16)
121cb2047c08 nothing important
szabii
parents: 659
diff changeset
684 fb_bpp = fb_vinfo.red.length + fb_vinfo.green.length +
121cb2047c08 nothing important
szabii
parents: 659
diff changeset
685 fb_vinfo.blue.length;
121cb2047c08 nothing important
szabii
parents: 659
diff changeset
686
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
687 if (vo_dbpp) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
688 if (vo_dbpp != 15 && vo_dbpp != 16 && vo_dbpp != 24 &&
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
689 vo_dbpp != 32) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
690 printf(FBDEV "can't switch to %d bpp\n", vo_dbpp);
383
086c66d570d8 some fixes
szabii
parents: 380
diff changeset
691 goto err_out;
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
692 }
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
693 fb_bpp = vo_dbpp;
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
694 }
245
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
695
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
696 fb_preinit_done = 1;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
697 fb_works = 1;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
698 return 0;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
699 err_out_fd:
e847396dc49f some changes...
szabii
parents: 383
diff changeset
700 close(fb_dev_fd);
e847396dc49f some changes...
szabii
parents: 383
diff changeset
701 fb_dev_fd = -1;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
702 err_out:
e847396dc49f some changes...
szabii
parents: 383
diff changeset
703 fb_preinit_done = 1;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
704 return 1;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
705 }
245
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
706
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
707 static void clear_bg(void)
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
708 {
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
709 int i, offset = 0;
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
710
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
711 for (i = 0; i < out_height; i++, offset += fb_screen_width)
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
712 memset(frame_buffer + offset, 0x0, out_width * fb_pixel_size);
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
713 }
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
714
633
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
715 static void lots_of_printf(void)
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
716 {
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
717 if (verbose > 0) {
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
718 printf(FBDEV "var info:\n");
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
719 printf(FBDEV "xres: %u\n", fb_vinfo.xres);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
720 printf(FBDEV "yres: %u\n", fb_vinfo.yres);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
721 printf(FBDEV "xres_virtual: %u\n", fb_vinfo.xres_virtual);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
722 printf(FBDEV "yres_virtual: %u\n", fb_vinfo.yres_virtual);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
723 printf(FBDEV "xoffset: %u\n", fb_vinfo.xoffset);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
724 printf(FBDEV "yoffset: %u\n", fb_vinfo.yoffset);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
725 printf(FBDEV "bits_per_pixel: %u\n", fb_vinfo.bits_per_pixel);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
726 printf(FBDEV "grayscale: %u\n", fb_vinfo.grayscale);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
727 printf(FBDEV "red: %lu %lu %lu\n",
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
728 (unsigned long) fb_vinfo.red.offset,
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
729 (unsigned long) fb_vinfo.red.length,
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
730 (unsigned long) fb_vinfo.red.msb_right);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
731 printf(FBDEV "green: %lu %lu %lu\n",
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
732 (unsigned long) fb_vinfo.green.offset,
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
733 (unsigned long) fb_vinfo.green.length,
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
734 (unsigned long) fb_vinfo.green.msb_right);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
735 printf(FBDEV "blue: %lu %lu %lu\n",
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
736 (unsigned long) fb_vinfo.blue.offset,
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
737 (unsigned long) fb_vinfo.blue.length,
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
738 (unsigned long) fb_vinfo.blue.msb_right);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
739 printf(FBDEV "transp: %lu %lu %lu\n",
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
740 (unsigned long) fb_vinfo.transp.offset,
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
741 (unsigned long) fb_vinfo.transp.length,
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
742 (unsigned long) fb_vinfo.transp.msb_right);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
743 printf(FBDEV "nonstd: %u\n", fb_vinfo.nonstd);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
744 if (verbose > 1) {
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
745 printf(FBDEV "activate: %u\n", fb_vinfo.activate);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
746 printf(FBDEV "height: %u\n", fb_vinfo.height);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
747 printf(FBDEV "width: %u\n", fb_vinfo.width);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
748 printf(FBDEV "accel_flags: %u\n", fb_vinfo.accel_flags);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
749 printf(FBDEV "timing:\n");
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
750 printf(FBDEV "pixclock: %u\n", fb_vinfo.pixclock);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
751 printf(FBDEV "left_margin: %u\n", fb_vinfo.left_margin);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
752 printf(FBDEV "right_margin: %u\n", fb_vinfo.right_margin);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
753 printf(FBDEV "upper_margin: %u\n", fb_vinfo.upper_margin);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
754 printf(FBDEV "lower_margin: %u\n", fb_vinfo.lower_margin);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
755 printf(FBDEV "hsync_len: %u\n", fb_vinfo.hsync_len);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
756 printf(FBDEV "vsync_len: %u\n", fb_vinfo.vsync_len);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
757 printf(FBDEV "sync: %u\n", fb_vinfo.sync);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
758 printf(FBDEV "vmode: %u\n", fb_vinfo.vmode);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
759 }
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
760 printf(FBDEV "fix info:\n");
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
761 printf(FBDEV "framebuffer size: %d bytes\n", fb_finfo.smem_len);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
762 printf(FBDEV "type: %lu\n", (unsigned long) fb_finfo.type);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
763 printf(FBDEV "type_aux: %lu\n", (unsigned long) fb_finfo.type_aux);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
764 printf(FBDEV "visual: %lu\n", (unsigned long) fb_finfo.visual);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
765 printf(FBDEV "line_length: %lu bytes\n", (unsigned long) fb_finfo.line_length);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
766 if (verbose > 1) {
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
767 printf(FBDEV "id: %.16s\n", fb_finfo.id);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
768 printf(FBDEV "smem_start: %p\n", (void *) fb_finfo.smem_start);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
769 printf(FBDEV "xpanstep: %u\n", fb_finfo.xpanstep);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
770 printf(FBDEV "ypanstep: %u\n", fb_finfo.ypanstep);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
771 printf(FBDEV "ywrapstep: %u\n", fb_finfo.ywrapstep);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
772 printf(FBDEV "mmio_start: %p\n", (void *) fb_finfo.mmio_start);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
773 printf(FBDEV "mmio_len: %u bytes\n", fb_finfo.mmio_len);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
774 printf(FBDEV "accel: %u\n", fb_finfo.accel);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
775 }
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
776 }
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
777 }
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
778
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
779 static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width,
e847396dc49f some changes...
szabii
parents: 383
diff changeset
780 uint32_t d_height, uint32_t fullscreen, char *title,
e847396dc49f some changes...
szabii
parents: 383
diff changeset
781 uint32_t format)
e847396dc49f some changes...
szabii
parents: 383
diff changeset
782 {
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
783 #define FS (fullscreen & 0x01)
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
784 #define VM (fullscreen & 0x02)
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
785 #define ZOOM (fullscreen & 0x04)
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
786
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
787 struct fb_cmap *cmap;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
788
e847396dc49f some changes...
szabii
parents: 383
diff changeset
789 if (!fb_preinit_done)
e847396dc49f some changes...
szabii
parents: 383
diff changeset
790 if (fb_preinit())
e847396dc49f some changes...
szabii
parents: 383
diff changeset
791 return 1;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
792 if (!fb_works)
e847396dc49f some changes...
szabii
parents: 383
diff changeset
793 return 1;
245
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
794
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
795 if (ZOOM) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
796 printf(FBDEV "-zoom is not supported\n");
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
797 return 1;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
798 }
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
799 if (fb_mode_name && !VM) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
800 printf(FBDEV "-fbmode can be used only with -vm"
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
801 " (is it the right behaviour?)\n");
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
802 return 1;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
803 }
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
804 if (VM)
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
805 if (parse_fbmode_cfg(fb_mode_cfgfile) < 0)
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
806 return 1;
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
807 #if 0
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
808 if ((!d_width + !d_height) == 1) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
809 printf(FBDEV "use both -x and -y, or none of them\n");
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
810 return 1;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
811 }
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
812 #endif
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
813 if (d_width) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
814 out_width = d_width;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
815 out_height = d_height;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
816 } else {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
817 out_width = width;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
818 out_height = height;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
819 }
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
820 in_width = width;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
821 in_height = height;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
822 pixel_format = format;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
823
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
824 if (fb_mode_name) {
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
825 if (!(fb_mode = find_mode_by_name(fb_mode_name))) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
826 printf(FBDEV "can't find requested video mode\n");
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
827 return 1;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
828 }
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
829 fb_mode2fb_vinfo(fb_mode, &fb_vinfo);
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
830 } else if (VM) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
831 monitor_hfreq = str2range(monitor_hfreq_str);
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
832 monitor_vfreq = str2range(monitor_vfreq_str);
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
833 monitor_dotclock = str2range(monitor_dotclock_str);
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
834 if (!monitor_hfreq || !monitor_vfreq || !monitor_dotclock) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
835 printf(FBDEV "you have to specify the capabilities of"
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
836 " the monitor.\n");
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
837 return 1;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
838 }
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
839 if (!(fb_mode = find_best_mode(out_width, out_height,
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
840 monitor_hfreq, monitor_vfreq,
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
841 monitor_dotclock))) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
842 printf(FBDEV "can't find best video mode\n");
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
843 return 1;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
844 }
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
845 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
846 fb_mode->yres, vsf(fb_mode));
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
847 fb_mode2fb_vinfo(fb_mode, &fb_vinfo);
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
848 }
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
849 fb_bpp_we_want = fb_bpp;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
850 set_bpp(&fb_vinfo, fb_bpp);
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
851 fb_vinfo.xres_virtual = fb_vinfo.xres;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
852 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
853
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
854 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) {
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
855 printf(FBDEV "Can't put VSCREENINFO: %s\n", strerror(errno));
e847396dc49f some changes...
szabii
parents: 383
diff changeset
856 return 1;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
857 }
618
b105a9f2bbe7 some cleanup
szabii
parents: 616
diff changeset
858 if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo)) {
b105a9f2bbe7 some cleanup
szabii
parents: 616
diff changeset
859 printf(FBDEV "Can't get FSCREENINFO: %s\n", strerror(errno));
b105a9f2bbe7 some cleanup
szabii
parents: 616
diff changeset
860 return 1;
b105a9f2bbe7 some cleanup
szabii
parents: 616
diff changeset
861 }
633
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
862
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
863 lots_of_printf();
245
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
864
633
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
865 if (fb_finfo.type != FB_TYPE_PACKED_PIXELS) {
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
866 printf(FBDEV "type %d not supported\n", fb_finfo.type);
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
867 return 1;
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
868 }
618
b105a9f2bbe7 some cleanup
szabii
parents: 616
diff changeset
869
379
368f16e72583 cleanup
szabii
parents: 365
diff changeset
870 switch (fb_finfo.visual) {
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
871 case FB_VISUAL_TRUECOLOR:
e847396dc49f some changes...
szabii
parents: 383
diff changeset
872 break;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
873 case FB_VISUAL_DIRECTCOLOR:
e847396dc49f some changes...
szabii
parents: 383
diff changeset
874 if (verbose > 0)
e847396dc49f some changes...
szabii
parents: 383
diff changeset
875 printf(FBDEV "creating cmap for directcolor\n");
481
6e8a887c99cd cmap bug fixed (I think)
szabii
parents: 479
diff changeset
876 if (ioctl(fb_dev_fd, FBIOGETCMAP, &fb_oldcmap)) {
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
877 printf(FBDEV "can't get cmap: %s\n",
e847396dc49f some changes...
szabii
parents: 383
diff changeset
878 strerror(errno));
e847396dc49f some changes...
szabii
parents: 383
diff changeset
879 return 1;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
880 }
e847396dc49f some changes...
szabii
parents: 383
diff changeset
881 if (!(cmap = make_directcolor_cmap(&fb_vinfo)))
e847396dc49f some changes...
szabii
parents: 383
diff changeset
882 return 1;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
883 if (ioctl(fb_dev_fd, FBIOPUTCMAP, cmap)) {
e847396dc49f some changes...
szabii
parents: 383
diff changeset
884 printf(FBDEV "can't put cmap: %s\n",
e847396dc49f some changes...
szabii
parents: 383
diff changeset
885 strerror(errno));
e847396dc49f some changes...
szabii
parents: 383
diff changeset
886 return 1;
e847396dc49f some changes...
szabii
parents: 383
diff changeset
887 }
481
6e8a887c99cd cmap bug fixed (I think)
szabii
parents: 479
diff changeset
888 fb_cmap_changed = 1;
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
889 free(cmap->red);
e847396dc49f some changes...
szabii
parents: 383
diff changeset
890 free(cmap->green);
e847396dc49f some changes...
szabii
parents: 383
diff changeset
891 free(cmap->blue);
e847396dc49f some changes...
szabii
parents: 383
diff changeset
892 free(cmap);
e847396dc49f some changes...
szabii
parents: 383
diff changeset
893 break;
633
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
894 // case FB_VISUAL_PSEUDOCOLOR:
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
895 // printf(FBDEV "visual is FB_VISUAL_PSEUDOCOLOR."
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
896 // "it's not tested!\n");
bdaa6d334d01 some cleanup
szabii
parents: 618
diff changeset
897 // break;
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
898 default:
e847396dc49f some changes...
szabii
parents: 383
diff changeset
899 printf(FBDEV "visual: %d not yet supported\n",
e847396dc49f some changes...
szabii
parents: 383
diff changeset
900 fb_finfo.visual);
e847396dc49f some changes...
szabii
parents: 383
diff changeset
901 return 1;
245
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
902 }
618
b105a9f2bbe7 some cleanup
szabii
parents: 616
diff changeset
903
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
904 if (FS || (d_width && VM)) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
905 out_width = fb_vinfo.xres;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
906 out_height = fb_vinfo.yres;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
907 }
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
908 if (out_width < in_width || out_height < in_height) {
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
909 printf(FBDEV "screensize is smaller than video size\n");
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
910 return 1;
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
911 }
245
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
912
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
913 fb_pixel_size = fb_vinfo.bits_per_pixel / 8;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
914 fb_real_bpp = fb_vinfo.red.length + fb_vinfo.green.length +
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
915 fb_vinfo.blue.length;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
916 fb_bpp = (fb_pixel_size == 4) ? 32 : fb_real_bpp;
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
917 if (fb_bpp_we_want != fb_bpp)
418
d75c826a8ab9 lots of changes
szabii
parents: 393
diff changeset
918 printf(FBDEV "requested %d bpp, got %d bpp)!!!\n",
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
919 fb_bpp_we_want, fb_bpp);
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
920 fb_screen_width = fb_finfo.line_length;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
921 fb_size = fb_finfo.smem_len;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
922 if ((frame_buffer = (uint8_t *) mmap(0, fb_size, PROT_READ | PROT_WRITE,
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
923 MAP_SHARED, fb_dev_fd, 0)) == (uint8_t *) -1) {
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
924 printf(FBDEV "Can't mmap %s: %s\n", fb_dev_name, strerror(errno));
e847396dc49f some changes...
szabii
parents: 383
diff changeset
925 return 1;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
926 }
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
927 L123123875 = frame_buffer + (out_width - in_width) * fb_pixel_size /
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
928 2 + (out_height - in_height) * fb_screen_width / 2;
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
929
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
930 if (verbose > 0) {
e847396dc49f some changes...
szabii
parents: 383
diff changeset
931 printf(FBDEV "other:\n");
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
932 if (verbose > 1) {
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
933 printf(FBDEV "frame_buffer @ %p\n", frame_buffer);
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
934 printf(FBDEV "L123123875 @ %p\n", L123123875);
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
935 }
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
936 printf(FBDEV "fb_bpp: %d\n", fb_bpp);
e847396dc49f some changes...
szabii
parents: 383
diff changeset
937 printf(FBDEV "fb_real_bpp: %d\n", fb_real_bpp);
e847396dc49f some changes...
szabii
parents: 383
diff changeset
938 printf(FBDEV "fb_pixel_size: %d bytes\n", fb_pixel_size);
e847396dc49f some changes...
szabii
parents: 383
diff changeset
939 printf(FBDEV "pixel per line: %d\n", fb_screen_width / fb_pixel_size);
379
368f16e72583 cleanup
szabii
parents: 365
diff changeset
940 }
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
941
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
942 switch (fb_bpp) {
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
943 case 32:
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
944 draw_alpha_p = vo_draw_alpha_rgb32;
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
945 break;
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
946 case 24:
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
947 draw_alpha_p = vo_draw_alpha_rgb24;
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
948 break;
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
949 case 16:
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
950 draw_alpha_p = vo_draw_alpha_rgb16;
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
951 break;
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
952 case 15:
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
953 draw_alpha_p = vo_draw_alpha_rgb15;
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
954 break;
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
955 }
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
956 if (verbose > 1)
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
957 printf(FBDEV "draw_alpha_p:%dbpp = %p\n", fb_bpp, draw_alpha_p);
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
958
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
959 if (!(next_frame = (uint8_t *) malloc(in_width * in_height * fb_pixel_size))) {
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
960 printf(FBDEV "Can't malloc next_frame: %s\n", strerror(errno));
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
961 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
962 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
963
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
964 if (format == IMGFMT_YV12)
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
965 yuv2rgb_init(fb_bpp, MODE_RGB);
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
966 clear_bg();
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
967 return 0;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
968 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
969
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
970 static uint32_t query_format(uint32_t format)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
971 {
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
972 int ret = 0x4; /* osd/sub is supported on every bpp */
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
973
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
974 if (!fb_preinit_done)
e847396dc49f some changes...
szabii
parents: 383
diff changeset
975 if (fb_preinit())
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
976 return 0;
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
977 if (!fb_works)
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
978 return 0;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
979
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
980 if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR) {
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
981 int bpp = format & 0xff;
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
982
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
983 if (bpp == fb_bpp)
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
984 return ret|0x2;
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
985 else if (bpp == 15 && fb_bpp == 16)
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
986 return ret|0x1;
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
987 else if (bpp == 24 && fb_bpp == 32)
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
988 return ret|0x1;
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
989 }
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
990 if (format == IMGFMT_YV12)
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
991 return ret|0x1;
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
992 return 0;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
993 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
994
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
995 static const vo_info_t *get_info(void)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
996 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
997 return &vo_info;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
998 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
999
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1000 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1001 unsigned char *srca, int stride)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1002 {
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
1003 unsigned char *dst = next_frame + (in_width * y0 + x0) * fb_pixel_size;
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
1004 int dstride = in_width * fb_pixel_size;
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
1005
658
ae02d4734ad6 some cleanups
szabii
parents: 633
diff changeset
1006 (*draw_alpha_p)(w, h, src, srca, stride, dst, dstride);
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1007 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1008
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1009 static uint32_t draw_frame(uint8_t *src[])
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1010 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1011 if (pixel_format == IMGFMT_YV12) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1012 yuv2rgb(next_frame, src[0], src[1], src[2], in_width,
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
1013 in_height, in_width * fb_pixel_size,
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1014 in_width, in_width / 2);
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1015 } else {
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1016 int sbpp = ((pixel_format & 0xff) + 7) / 8;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1017 char *d = next_frame;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1018 char *s = src[0];
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1019 if (sbpp == fb_pixel_size) {
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
1020 if (fb_real_bpp == 16 && pixel_format == (IMGFMT_BGR|15)) {
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1021 #ifdef HAVE_MMX
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1022 rgb15to16_mmx(s, d, 2 * in_width * in_height);
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1023 #else
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1024 unsigned short *s1 = (unsigned short *) s;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1025 unsigned short *d1 = (unsigned short *) d;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1026 unsigned short *e = s1 + in_width * in_height;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1027 while (s1<e) {
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1028 register x = *(s1++);
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1029 *(d1++) = (x&0x001f)|((x&0x7fe0)<<1);
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1030 }
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1031 #endif
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1032 } else
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1033 memcpy(d, s, sbpp * in_width * in_height);
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1034 }
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
1035 }
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1036 return 0;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1037 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1038
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1039 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x,
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1040 int y)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1041 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1042 uint8_t *dest;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1043
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
1044 dest = next_frame + (in_width * y + x) * fb_pixel_size;
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
1045 yuv2rgb(dest, src[0], src[1], src[2], w, h, in_width * fb_pixel_size,
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1046 stride[0], stride[1]);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1047 return 0;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1048 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1049
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1050 static void check_events(void)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1051 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1052 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1053
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
1054 static void put_frame(void)
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1055 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1056 int i, out_offset = 0, in_offset = 0;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1057
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1058 for (i = 0; i < in_height; i++) {
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
1059 memcpy(L123123875 + out_offset, next_frame + in_offset,
423
bb28d8242239 small change
szabii
parents: 418
diff changeset
1060 in_width * fb_pixel_size);
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
1061 out_offset += fb_screen_width;
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
1062 in_offset += in_width * fb_pixel_size;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1063 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1064 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1065
246
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
1066 static void flip_page(void)
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
1067 {
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
1068 vo_draw_text(in_width, in_height, draw_alpha);
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
1069 check_events();
519
5e8d5422854d changed query_format return; lots of fixes/changes
szabii
parents: 503
diff changeset
1070 put_frame();
246
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
1071 }
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
1072
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1073 static void uninit(void)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1074 {
379
368f16e72583 cleanup
szabii
parents: 365
diff changeset
1075 if (verbose > 0)
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
1076 printf(FBDEV "uninit\n");
481
6e8a887c99cd cmap bug fixed (I think)
szabii
parents: 479
diff changeset
1077 if (fb_cmap_changed) {
6e8a887c99cd cmap bug fixed (I think)
szabii
parents: 479
diff changeset
1078 if (ioctl(fb_dev_fd, FBIOPUTCMAP, &fb_oldcmap))
393
e847396dc49f some changes...
szabii
parents: 383
diff changeset
1079 printf(FBDEV "Can't restore original cmap\n");
481
6e8a887c99cd cmap bug fixed (I think)
szabii
parents: 479
diff changeset
1080 fb_cmap_changed = 0;
306
344d115a285d restore old cmap
szabii
parents: 305
diff changeset
1081 }
503
4aa16f9ff929 fbdev reset fixed
szabii
parents: 481
diff changeset
1082 free(next_frame);
4aa16f9ff929 fbdev reset fixed
szabii
parents: 481
diff changeset
1083 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo))
4aa16f9ff929 fbdev reset fixed
szabii
parents: 481
diff changeset
1084 printf(FBDEV "ioctl FBIOGET_VSCREENINFO: %s\n", strerror(errno));
4aa16f9ff929 fbdev reset fixed
szabii
parents: 481
diff changeset
1085 fb_orig_vinfo.xoffset = fb_vinfo.xoffset;
4aa16f9ff929 fbdev reset fixed
szabii
parents: 481
diff changeset
1086 fb_orig_vinfo.yoffset = fb_vinfo.yoffset;
379
368f16e72583 cleanup
szabii
parents: 365
diff changeset
1087 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_orig_vinfo))
503
4aa16f9ff929 fbdev reset fixed
szabii
parents: 481
diff changeset
1088 printf(FBDEV "Can't reset original fb_var_screeninfo: %s\n", strerror(errno));
359
db6b78fa7331 video mode change supported
szabii
parents: 354
diff changeset
1089 close(fb_dev_fd);
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1090 munmap(frame_buffer, fb_size);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1091 }