annotate libvo/vo_fbdev.c @ 320:5427ff3e2e9d

status
author szabii
date Mon, 09 Apr 2001 21:06:54 +0000
parents 15a5f7635538
children 601822cc8c52
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>
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
4 *
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
5 * Some idea and code borrowed from Chris Lawrence's ppmtofb-0.27
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
6 */
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
7
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
8 #include <stdio.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
9 #include <stdlib.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
10 #include <string.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
11 #include <fcntl.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
12 #include <unistd.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
13 #include <errno.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
14
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
15 #include <sys/mman.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
16 #include <sys/ioctl.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
17 #include <linux/fb.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
18 #include <linux/vt.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
19
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
20 #include "config.h"
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
21 #include "video_out.h"
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
22 #include "video_out_internal.h"
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
23
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
24 #include "yuv2rgb.h"
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
25 extern void rgb15to16_mmx(char *s0, char *d0, int count);
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
26
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
27 LIBVO_EXTERN(fbdev)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
28
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
29 static vo_info_t vo_info = {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
30 "Framebuffer Device",
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
31 "fbdev",
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
32 "Szabolcs Berecz <szabi@inf.elte.hu>",
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
33 ""
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
34 };
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
35
230
2605bca34a96 works with .avi (for me :) )
szabii
parents: 229
diff changeset
36 static int vt_active = -1;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
37 static int vt_fd;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
38
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
39 char *fb_dev_name = NULL;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
40 static int fb_dev_fd;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
41 static size_t fb_size;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
42 static uint8_t *frame_buffer;
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
43 static int fb_pixel_size;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
44 static int fb_bpp;
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
45 static int fb_bpp_on_screen;
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
46 struct fb_fix_screeninfo fb_fix_info;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
47 struct fb_var_screeninfo fb_var_info;
246
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
48 static uint32_t fb_xres_virtual;
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
49 static uint32_t fb_yres_virtual;
306
344d115a285d restore old cmap
szabii
parents: 305
diff changeset
50 static struct fb_cmap *oldcmap = NULL;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
51
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
52 static int in_width;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
53 static int in_height;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
54 static int out_width;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
55 static int out_height;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
56 static uint8_t *next_frame;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
57 static int screen_width;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
58 static uint32_t pixel_format;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
59
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
60 static int fb_init_done = 0;
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
61 static int fb_works = 0;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
62
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
63 /*
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
64 * Note: this function is completely cut'n'pasted from
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
65 * Chris Lawrence's code.
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
66 * (modified a bit to fit in my code...)
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
67 */
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
68 struct fb_cmap *make_directcolor_cmap(struct fb_var_screeninfo *var)
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
69 {
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
70 /* Hopefully any DIRECTCOLOR device will have a big enough palette
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
71 * to handle mapping the full color depth.
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
72 * e.g. 8 bpp -> 256 entry palette
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
73 *
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
74 * We could handle some sort of gamma here
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
75 */
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
76 int i, cols, rcols, gcols, bcols;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
77 uint16_t *red, *green, *blue;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
78 struct fb_cmap *cmap;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
79
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
80 rcols = 1 << var->red.length;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
81 gcols = 1 << var->green.length;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
82 bcols = 1 << var->blue.length;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
83
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
84 /* Make our palette the length of the deepest color */
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
85 cols = (rcols > gcols ? rcols : gcols);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
86 cols = (cols > bcols ? cols : bcols);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
87
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
88 red = malloc(cols * sizeof(red[0]));
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
89 if(!red) {
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
90 printf("Can't allocate red palette with %d entries.\n", cols);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
91 return NULL;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
92 }
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
93 for(i=0; i< rcols; i++)
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
94 red[i] = (65535/(rcols-1)) * i;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
95
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
96 green = malloc(cols * sizeof(green[0]));
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
97 if(!green) {
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
98 printf("Can't allocate green palette with %d entries.\n", cols);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
99 free(red);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
100 return NULL;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
101 }
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
102 for(i=0; i< gcols; i++)
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
103 green[i] = (65535/(gcols-1)) * i;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
104
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
105 blue = malloc(cols * sizeof(blue[0]));
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
106 if(!blue) {
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
107 printf("Can't allocate blue palette with %d entries.\n", cols);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
108 free(red);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
109 free(green);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
110 return NULL;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
111 }
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
112 for(i=0; i< bcols; i++)
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
113 blue[i] = (65535/(bcols-1)) * i;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
114
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
115 cmap = malloc(sizeof(struct fb_cmap));
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
116 if(!cmap) {
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
117 printf("Can't allocate color map\n");
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
118 free(red);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
119 free(green);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
120 free(blue);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
121 return NULL;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
122 }
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
123 cmap->start = 0;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
124 cmap->transp = 0;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
125 cmap->len = cols;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
126 cmap->red = red;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
127 cmap->blue = blue;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
128 cmap->green = green;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
129 cmap->transp = NULL;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
130
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
131 return cmap;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
132 }
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
133
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
134 static int fb_init(void)
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
135 {
277
8d526cf59ffe report more info on fb
szabii
parents: 251
diff changeset
136 int fd;
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
137 struct fb_cmap *cmap;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
138
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
139 if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER")))
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
140 fb_dev_name = "/dev/fb0";
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
141 printf("fb_init: using %s\n", fb_dev_name);
245
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
142
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
143 if ((fb_dev_fd = open(fb_dev_name, O_RDWR)) == -1) {
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
144 printf("fb_init: Can't open %s: %s\n", fb_dev_name, strerror(errno));
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
145 goto err_out;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
146 }
245
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
147
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
148 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_var_info)) {
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
149 printf("fb_init: Can't get VSCREENINFO: %s\n", strerror(errno));
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
150 goto err_out_fd;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
151 }
245
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
152
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
153 /* disable scrolling */
246
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
154 fb_xres_virtual = fb_var_info.xres_virtual;
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
155 fb_yres_virtual = fb_var_info.yres_virtual;
245
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
156 fb_var_info.xres_virtual = fb_var_info.xres;
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
157 fb_var_info.yres_virtual = fb_var_info.yres;
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
158
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
159 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_var_info)) {
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
160 printf("fb_init: Can't put VSCREENINFO: %s\n", strerror(errno));
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
161 goto err_out_fd;
245
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
162 }
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
163
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
164 if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_fix_info)) {
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
165 printf("fb_init: Can't get VSCREENINFO: %s\n", strerror(errno));
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
166 goto err_out_fd;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
167 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
168 }
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
169 switch (fb_fix_info.type) {
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
170 case FB_TYPE_VGA_PLANES:
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
171 printf("fb_init: FB_TYPE_VGA_PLANES not supported.\n");
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
172 goto err_out_fd;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
173 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
174 case FB_TYPE_PLANES:
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
175 printf("fb_init: FB_TYPE_PLANES not supported.\n");
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
176 goto err_out_fd;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
177 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
178 case FB_TYPE_INTERLEAVED_PLANES:
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
179 printf("fb_init: FB_TYPE_INTERLEAVED_PLANES not supported.\n");
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
180 goto err_out_fd;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
181 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
182 #ifdef FB_TYPE_TEXT
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
183 case FB_TYPE_TEXT:
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
184 printf("fb_init: FB_TYPE_TEXT not supported.\n");
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
185 goto err_out_fd;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
186 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
187 #endif
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
188 case FB_TYPE_PACKED_PIXELS:
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
189 /* OK */
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
190 printf("fb_init: FB_TYPE_PACKED_PIXELS: OK\n");
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
191 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
192 default:
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
193 printf("fb_init: unknown FB_TYPE: %d\n", fb_fix_info.type);
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
194 goto err_out_fd;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
195 }
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
196 if (fb_fix_info.visual == FB_VISUAL_DIRECTCOLOR) {
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
197 printf("fb_init: creating cmap for directcolor\n");
306
344d115a285d restore old cmap
szabii
parents: 305
diff changeset
198 if (ioctl(fb_dev_fd, FBIOGETCMAP, oldcmap)) {
344d115a285d restore old cmap
szabii
parents: 305
diff changeset
199 printf("fb_init: can't get cmap: %s\n",
344d115a285d restore old cmap
szabii
parents: 305
diff changeset
200 strerror(errno));
344d115a285d restore old cmap
szabii
parents: 305
diff changeset
201 goto err_out_fd;
344d115a285d restore old cmap
szabii
parents: 305
diff changeset
202 }
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
203 if (!(cmap = make_directcolor_cmap(&fb_var_info)))
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
204 goto err_out_fd;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
205 if (ioctl(fb_dev_fd, FBIOPUTCMAP, cmap)) {
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
206 printf("fb_init: can't put cmap: %s\n",
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
207 strerror(errno));
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
208 goto err_out_fd;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
209 }
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
210 free(cmap->red);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
211 free(cmap->green);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
212 free(cmap->blue);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
213 free(cmap);
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
214 } else if (fb_fix_info.visual != FB_VISUAL_TRUECOLOR) {
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
215 printf("fb_init: visual: %d not yet supported\n",
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
216 fb_fix_info.visual);
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
217 goto err_out_fd;
245
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
218 }
cb4c682746c0 disabled scrollback buffer (virtual fb size set to real screen size)
szabii
parents: 231
diff changeset
219
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
220 fb_pixel_size = fb_var_info.bits_per_pixel / 8;
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
221 fb_bpp = fb_var_info.red.length + fb_var_info.green.length +
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
222 fb_var_info.blue.length;
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
223 fb_bpp_on_screen = (fb_pixel_size == 4) ? 32 : fb_bpp;
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
224 screen_width = fb_fix_info.line_length;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
225 fb_size = fb_fix_info.smem_len;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
226 if ((frame_buffer = (uint8_t *) mmap(0, fb_size, PROT_READ | PROT_WRITE,
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
227 MAP_SHARED, fb_dev_fd, 0)) == (uint8_t *) -1) {
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
228 printf("fb_init: Can't mmap %s: %s\n", fb_dev_name, strerror(errno));
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
229 goto err_out_fd;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
230 }
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
231
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
232 printf("fb_init: framebuffer @ %p\n", frame_buffer);
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
233 printf("fb_init: framebuffer size: %d bytes\n", fb_size);
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
234 printf("fb_init: bpp: %d\n", fb_bpp);
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
235 printf("fb_init: bpp on screen: %d\n", fb_bpp_on_screen);
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
236 printf("fb_init: pixel size: %d\n", fb_pixel_size);
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
237 printf("fb_init: pixel per line: %d\n", screen_width / fb_pixel_size);
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
238 printf("fb_init: visual: %d\n", fb_fix_info.visual);
277
8d526cf59ffe report more info on fb
szabii
parents: 251
diff changeset
239 printf("fb_init: red: %d %d %d\n", fb_var_info.red.offset,
8d526cf59ffe report more info on fb
szabii
parents: 251
diff changeset
240 fb_var_info.red.length, fb_var_info.red.msb_right);
8d526cf59ffe report more info on fb
szabii
parents: 251
diff changeset
241 printf("fb_init: green: %d %d %d\n", fb_var_info.green.offset,
8d526cf59ffe report more info on fb
szabii
parents: 251
diff changeset
242 fb_var_info.green.length, fb_var_info.green.msb_right);
8d526cf59ffe report more info on fb
szabii
parents: 251
diff changeset
243 printf("fb_init: blue: %d %d %d\n", fb_var_info.blue.offset,
8d526cf59ffe report more info on fb
szabii
parents: 251
diff changeset
244 fb_var_info.blue.length, fb_var_info.blue.msb_right);
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
245
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
246 fb_init_done = 1;
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
247 fb_works = 1;
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
248 return 0;
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
249 err_out_fd:
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
250 close(fb_dev_fd);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
251 fb_dev_fd = -1;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
252 err_out:
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
253 fb_init_done = 1;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
254 return 1;
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
255 }
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
256
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
257 static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width,
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
258 uint32_t d_height, uint32_t fullscreen, char *title,
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
259 uint32_t format)
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
260 {
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
261 if (!fb_init_done)
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
262 if (fb_init())
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
263 return 1;
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
264 if (!fb_works)
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
265 return 1;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
266
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
267 in_width = width;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
268 in_height = height;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
269 out_width = width;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
270 out_height = height;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
271 pixel_format = format;
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
272 if (!(next_frame = (uint8_t *) malloc(in_width * in_height * fb_pixel_size))) {
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
273 printf("Can't malloc next_frame: %s\n", strerror(errno));
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
274 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
275 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
276
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
277 if (format == IMGFMT_YV12)
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
278 // yuv2rgb_init(fb_pixel_size * 8, MODE_RGB);
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
279 yuv2rgb_init(fb_bpp_on_screen, MODE_RGB);
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
280 return 0;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
281 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
282
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
283 static uint32_t query_format(uint32_t format)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
284 {
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
285 if (!fb_init_done)
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
286 if (fb_init())
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
287 return 0;
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
288 if (!fb_works)
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
289 return 0;
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
290
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
291 if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR) {
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
292 int bpp = format & 0xff;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
293 if (bpp == fb_bpp_on_screen)
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
294 return 1;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
295 else if (bpp == 15 && fb_bpp_on_screen == 16)
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
296 return 1;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
297 else if (bpp == 24 && fb_bpp_on_screen == 32)
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
298 return 1;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
299 }
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
300 if (format == IMGFMT_YV12)
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
301 return 1;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
302 return 0;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
303 /*
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
304 printf("vo_fbdev: query_format(%#x(%.4s)): ", format, &format);
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
305 if (format & IMGFMT_BGR_MASK == IMGFMT_BGR)
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
306 goto not_supported;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
307 switch (format) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
308 case IMGFMT_YV12:
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
309 goto supported;
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
310
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
311 case IMGFMT_RGB32:
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
312 if (fb_bpp == 32)
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
313 goto supported;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
314 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
315 case IMGFMT_RGB24:
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
316 if (fb_bpp == 24)
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
317 goto supported;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
318 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
319 case IMGFMT_RGB16:
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
320 if (fb_bpp == 16)
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
321 goto supported;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
322 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
323 case IMGFMT_RGB15:
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
324 if (fb_bpp == 15)
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
325 goto supported;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
326 break;
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
327
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
328 case IMGFMT_BGR|32:
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
329 if (fb_bpp == 24 && fb_pixel_size == 4)
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
330 goto supported;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
331 break;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
332 case IMGFMT_BGR|24:
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
333 if (fb_bpp == 24 && fb_pixel_size == 3)
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
334 goto supported;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
335 break;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
336 case IMGFMT_BGR|16:
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
337 if (fb_bpp == 16)
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
338 goto supported;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
339 break;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
340 case IMGFMT_BGR|15:
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
341 if (fb_bpp == 15)
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
342 goto supported;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
343 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
344 }
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
345 not_supported:
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
346 printf("not_supported\n");
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
347 return 0;
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
348 supported:
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
349 printf("supported\n");
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
350 return 1;
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
351 */
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
352 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
353
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
354 static const vo_info_t *get_info(void)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
355 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
356 return &vo_info;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
357 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
358
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
359 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
360 unsigned char *srca, int stride)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
361 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
362 int x, y;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
363 uint8_t *dst;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
364
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
365 // if (pixel_format == IMGFMT_YV12) {
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
366 for (y = 0; y < h; y++){
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
367 dst = next_frame + (in_width * (y0 + y) + x0) * fb_pixel_size;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
368 for (x = 0; x < w; x++) {
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
369 if (srca[x]) {
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
370 dst[0]=((dst[0]*srca[x])>>8)+src[x];
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
371 dst[1]=((dst[1]*srca[x])>>8)+src[x];
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
372 dst[2]=((dst[2]*srca[x])>>8)+src[x];
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
373 }
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
374 dst += fb_pixel_size;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
375 }
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
376 src += stride;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
377 srca += stride;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
378 }
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
379 // }
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
380 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
381
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
382 static uint32_t draw_frame(uint8_t *src[])
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
383 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
384 if (pixel_format == IMGFMT_YV12) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
385 yuv2rgb(next_frame, src[0], src[1], src[2], in_width,
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
386 in_height, in_width * fb_pixel_size,
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
387 in_width, in_width / 2);
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
388 } else {
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
389 int sbpp = ((pixel_format & 0xff) + 7) / 8;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
390 char *d = next_frame;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
391 char *s = src[0];
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
392 if (sbpp == fb_pixel_size) {
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
393 if (fb_bpp == 16 && pixel_format == (IMGFMT_BGR|15)) {
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
394 #ifdef HAVE_MMX
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
395 rgb15to16_mmx(s, d, 2 * in_width * in_height);
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
396 #else
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
397 unsigned short *s1 = (unsigned short *) s;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
398 unsigned short *d1 = (unsigned short *) d;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
399 unsigned short *e = s1 + in_width * in_height;
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
400 while (s1<e) {
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
401 register x = *(s1++);
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
402 *(d1++) = (x&0x001f)|((x&0x7fe0)<<1);
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
403 }
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
404 #endif
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
405 } else
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
406 memcpy(d, s, sbpp * in_width * in_height);
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
407 }
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
408 }
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
409 /*
230
2605bca34a96 works with .avi (for me :) )
szabii
parents: 229
diff changeset
410 } else if ((pixel_format & IMGFMT_BGR_MASK) == IMGFMT_BGR) {
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
411 if (pixel_format == fb_bpp_on_screen)
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
412 memcpy(next_frame, src[0],
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
413 in_width * in_height * fb_pixel_size);
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
414 else {
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
415
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
416 }
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
417 }
311
15a5f7635538 codecs.conf support
szabii
parents: 306
diff changeset
418 */
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
419 return 0;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
420 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
421
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
422 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x,
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
423 int y)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
424 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
425 uint8_t *dest;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
426
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
427 dest = next_frame + (in_width * y + x) * fb_pixel_size;
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
428 yuv2rgb(dest, src[0], src[1], src[2], w, h, in_width * fb_pixel_size,
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
429 stride[0], stride[1]);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
430 return 0;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
431 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
432
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
433 static void check_events(void)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
434 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
435 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
436
246
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
437 static void put_frame(void)
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
438 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
439 int i, out_offset = 0, in_offset = 0;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
440
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
441 for (i = 0; i < in_height; i++) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
442 memcpy(frame_buffer + out_offset, next_frame + in_offset,
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
443 in_width * fb_pixel_size);
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
444 out_offset += screen_width;
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
445 in_offset += in_width * fb_pixel_size;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
446 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
447 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
448
246
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
449 static void flip_page(void)
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
450 {
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
451 vo_draw_text(in_width, in_height, draw_alpha);
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
452 check_events();
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
453 put_frame();
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
454 }
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
455
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
456 static void uninit(void)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
457 {
246
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
458 printf("vo_fbdev: uninit\n");
306
344d115a285d restore old cmap
szabii
parents: 305
diff changeset
459 if (oldcmap) {
344d115a285d restore old cmap
szabii
parents: 305
diff changeset
460 if (ioctl(fb_dev_fd, FBIOPUTCMAP, oldcmap))
344d115a285d restore old cmap
szabii
parents: 305
diff changeset
461 printf("vo_fbdev: Can't restore original cmap\n");
344d115a285d restore old cmap
szabii
parents: 305
diff changeset
462 oldcmap = NULL;
344d115a285d restore old cmap
szabii
parents: 305
diff changeset
463 }
246
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
464 fb_var_info.xres_virtual = fb_xres_virtual;
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
465 fb_var_info.yres_virtual = fb_yres_virtual;
305
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
466 if (fb_dev_fd != -1) {
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
467 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_var_info))
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
468 printf("vo_fbdev: Can't set virtual screensize to original value: %s\n", strerror(errno));
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
469 close(fb_dev_fd);
6c3a6322f81c directcolor support?
szabii
parents: 278
diff changeset
470 }
278
604b37178b3d now it works in 15bpp mode
szabii
parents: 277
diff changeset
471 memset(next_frame, '\0', in_height * in_width * fb_pixel_size);
246
5673f9146c54 clear the frame on uninit
szabii
parents: 245
diff changeset
472 put_frame();
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
473 if (vt_active >= 0)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
474 ioctl(vt_fd, VT_ACTIVATE, vt_active);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
475 free(next_frame);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
476 munmap(frame_buffer, fb_size);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
477 }