annotate libvo/vo_fbdev.c @ 229:a8170ba5496f

maybe it can play avi :)
author szabii
date Wed, 28 Mar 2001 16:35:14 +0000
parents 62ec84961b27
children 2605bca34a96
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
1 #include <stdio.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
2 #include <stdlib.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
3 #include <string.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
4 #include <fcntl.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
5 #include <unistd.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
6 #include <errno.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
7
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
8 #include <sys/mman.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
9 #include <sys/ioctl.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
10 #include <linux/fb.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
11 #include <linux/vt.h>
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
12
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
13 #include "config.h"
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
14 #include "video_out.h"
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
15 #include "video_out_internal.h"
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
16
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
17 #include "yuv2rgb.h"
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
18
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
19 LIBVO_EXTERN(fbdev)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
20
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
21 //#include "yuv2rgb.h"
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
22
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
23 static vo_info_t vo_info = {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
24 "Framebuffer Device",
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
25 "fbdev",
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
26 "Szabolcs Berecz <szabi@inf.elte.hu>",
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
27 ""
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
28 };
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
29
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
30 static int vt_active;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
31 static int vt_fd;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
32
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
33 char *fb_dev_name = NULL;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
34 static int fb_dev_fd;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
35 static size_t fb_size;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
36 static uint8_t *frame_buffer;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
37 static int fb_bpp;
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
38 struct fb_fix_screeninfo fb_fix_info;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
39 struct fb_var_screeninfo fb_var_info;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
40
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
41 static int in_width;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
42 static int in_height;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
43 static int out_width;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
44 static int out_height;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
45 static uint8_t *next_frame;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
46 static int screen_width;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
47 static uint32_t pixel_format;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
48
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
49 static int fb_init_done = 0;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
50
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
51 static int fb_init(void)
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
52 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
53 int fd, vt;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
54 char vt_name[11];
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
55 struct vt_stat vt_state;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
56 struct vt_mode vt_mode;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
57
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
58 #if 0
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
59 /* get a free vt */
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
60 if ((fd = open("/dev/tty0", O_WRONLY, 0)) == -1) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
61 printf("Can't open /dev/tty0: %s\n", strerror(errno));
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
62 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
63 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
64 if (ioctl(fd, VT_OPENQRY, &vt) < 0 || vt == -1) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
65 printf("Can't open a free VT: %s\n", strerror(errno));
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
66 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
67 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
68 close(fd);
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
69 #endif
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
70 #if 0
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
71 /* open the vt */
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
72 snprintf(vt_name, 10, "/dev/tty%d", vt);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
73 if ((vt_fd = open(vt_name, O_RDWR | O_NONBLOCK, 0)) == -1) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
74 printf("Can't open %s: %s\n", vt_name, strerror(errno));
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
75 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
76 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
77
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
78 /* save the current vtnum */
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
79 if (!ioctl(vt_fd, VT_GETSTATE, &vt_state))
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
80 vt_active = vt_state.v_active;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
81
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
82 /* detach the controlling tty */
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
83 if ((fd = open("/dev/tty", O_RDWR)) >= 0) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
84 ioctl(fd, TIOCNOTTY, 0);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
85 close(fd);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
86 }
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
87 #endif
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
88 #if 0
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
89 /* switch to the new vt */
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
90 if (ioctl(vt_fd, VT_ACTIVATE, vt_active))
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
91 printf("ioctl VT_ACTIVATE: %s\n", strerror(errno));
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
92 if (ioctl(vt_fd, VT_WAITACTIVE, vt_active))
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
93 printf("ioctl VT_WAITACTIVE: %s\n", strerror(errno));
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
94 if (ioctl(vt_fd, VT_GETMODE, &vt_mode) < 0) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
95 printf("ioctl VT_GETMODE: %s\n", strerror(errno));
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
96 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
97 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
98 signal(SIGUSR1, vt_request);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
99 vt_mode.mode = VT_PROCESS;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
100 vt_mode.relsig = SIGUSR1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
101 vt_mode.acqsig = SIGUSR1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
102 if (ioctl(vt_fd, VT_SETMODE, &vt_mode) < 0) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
103 printf("ioctl VT_SETMODE: %s\n", strerror(errno));
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
104 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
105 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
106 #endif
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
107 if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER")))
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
108 fb_dev_name = "/dev/fb0";
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
109 printf("fb_init: using %s\n", fb_dev_name);
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
110 if ((fb_dev_fd = open(fb_dev_name, O_RDWR)) == -1) {
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
111 printf("fb_init: Can't open %s: %s\n", fb_dev_name, strerror(errno));
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
112 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
113 }
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
114 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_var_info)) {
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
115 printf("fb_init: Can't get VSCREENINFO: %s\n", strerror(errno));
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
116 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
117 }
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
118 if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_fix_info)) {
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
119 printf("fb_init: Can't get VSCREENINFO: %s\n", strerror(errno));
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
120 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
121 }
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
122 switch (fb_fix_info.type) {
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
123 case FB_TYPE_VGA_PLANES:
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
124 printf("fb_init: FB_TYPE_VGA_PLANES not supported.\n");
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
125 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
126 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
127 case FB_TYPE_PLANES:
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
128 printf("fb_init: FB_TYPE_PLANES not supported.\n");
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
129 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
130 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
131 case FB_TYPE_INTERLEAVED_PLANES:
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
132 printf("fb_init: FB_TYPE_INTERLEAVED_PLANES not supported.\n");
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
133 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
134 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
135 #ifdef FB_TYPE_TEXT
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
136 case FB_TYPE_TEXT:
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
137 printf("fb_init: FB_TYPE_TEXT not supported.\n");
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
138 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
139 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
140 #endif
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
141 case FB_TYPE_PACKED_PIXELS:
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
142 /* OK */
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
143 printf("fb_init: FB_TYPE_PACKED_PIXELS: OK\n");
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
144 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
145 default:
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
146 printf("fb_init: unknown FB_TYPE: %d\n", fb_fix_info.type);
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
147 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
148 }
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
149 fb_bpp = fb_var_info.bits_per_pixel;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
150 screen_width = fb_fix_info.line_length;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
151 fb_size = fb_fix_info.smem_len;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
152 if ((frame_buffer = (uint8_t *) mmap(0, fb_size, PROT_READ | PROT_WRITE,
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
153 MAP_SHARED, fb_dev_fd, 0)) == (uint8_t *) -1) {
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
154 printf("fb_init: Can't mmap %s: %s\n", fb_dev_name, strerror(errno));
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
155 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
156 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
157 close(fb_dev_fd);
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
158
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
159 printf("fb_init: framebuffer @ %p\n", frame_buffer);
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
160 printf("fb_init: framebuffer size: %d bytes\n", fb_size);
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
161 printf("fb_init: bpp: %d\n", fb_bpp);
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
162 printf("fb_init: pixel per line: %d\n", screen_width / (fb_bpp / 8));
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
163 printf("fb_init: visual: %d\n", fb_fix_info.visual);
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
164
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
165 fb_init_done = 1;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
166 return 0;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
167 }
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
168
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
169 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
170 uint32_t d_height, uint32_t fullscreen, char *title,
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
171 uint32_t format)
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
172 {
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
173 if (!fb_init_done)
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
174 if (fb_init())
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
175 return 1;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
176
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
177 in_width = width;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
178 in_height = height;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
179 out_width = width;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
180 out_height = height;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
181 pixel_format = format;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
182 if (!(next_frame = (uint8_t *) malloc(in_width * in_height * (fb_bpp / 8)))) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
183 printf("Can't malloc next_frame: %s\n", strerror(errno));
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
184 return 1;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
185 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
186
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
187 if (format == IMGFMT_YV12)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
188 yuv2rgb_init(fb_bpp, MODE_RGB);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
189 return 0;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
190 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
191
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
192 static uint32_t query_format(uint32_t format)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
193 {
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
194 if (!fb_init_done)
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
195 if (fb_init())
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
196 return 0;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
197 printf("vo_fbdev: query_format(%#x): ", format);
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
198 if (format & IMGFMT_BGR_MASK == IMGFMT_BGR)
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
199 goto not_supported;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
200 switch (format) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
201 case IMGFMT_YV12:
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
202 goto supported;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
203 case IMGFMT_RGB32:
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
204 if (fb_bpp == 32)
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
205 goto supported;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
206 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
207 case IMGFMT_RGB24:
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
208 if (fb_bpp == 24)
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
209 goto supported;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
210 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
211 case IMGFMT_RGB16:
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
212 if (fb_bpp == 16)
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
213 goto supported;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
214 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
215 case IMGFMT_RGB15:
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
216 if (fb_bpp == 15)
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
217 goto supported;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
218 break;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
219 case IMGFMT_BGR|32:
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
220 if (fb_bpp == 32)
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
221 goto supported;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
222 break;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
223 case IMGFMT_BGR|24:
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
224 if (fb_bpp == 24)
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
225 goto supported;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
226 break;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
227 case IMGFMT_BGR|16:
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
228 if (fb_bpp == 16)
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
229 goto supported;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
230 break;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
231 case IMGFMT_BGR|15:
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
232 if (fb_bpp == 15)
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
233 goto supported;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
234 break;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
235 }
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
236 not_supported:
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
237 printf("not_supported\n");
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
238 return 0;
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
239 supported:
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
240 printf("supported\n");
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
241 return 1;
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
242 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
243
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
244 static const vo_info_t *get_info(void)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
245 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
246 return &vo_info;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
247 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
248
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
249 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
250 unsigned char *srca, int stride)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
251 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
252 int x, y;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
253 uint8_t *dst;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
254
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
255 if (pixel_format == IMGFMT_YV12) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
256 for (y = 0; y < h; y++){
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
257 dst = next_frame + (in_width * (y0 + y) + x0) * (fb_bpp / 8);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
258 for (x = 0; x < w; x++) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
259 if (srca[x]) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
260 dst[0] = (dst[0]*(srca[x]^255)+src[x]*(srca[x]))>>8;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
261 dst[1] = (dst[1]*(srca[x]^255)+src[x]*(srca[x]))>>8;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
262 dst[2] = (dst[2]*(srca[x]^255)+src[x]*(srca[x]))>>8;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
263 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
264 dst += fb_bpp / 8;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
265 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
266 src += stride;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
267 srca += stride;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
268 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
269 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
270 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
271
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
272 static uint32_t draw_frame(uint8_t *src[])
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
273 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
274 if (pixel_format == IMGFMT_YV12) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
275 yuv2rgb(next_frame, src[0], src[1], src[2], in_width,
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
276 in_height, in_width * (fb_bpp / 8),
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
277 in_width, in_width / 2);
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
278 } else if ((pixel_format & IMGFMT_RGB_MASK) == IMGFMT_RGB) {
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
279 int i;
229
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
280 uint8_t *dst = next_frame;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
281 uint8_t *s = src[0];
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
282 for (i = 0; i < in_height; i++) {
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
283 memcpy(next_frame, s, in_width * (fb_bpp / 8));
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
284 dst += screen_width;
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
285 s += in_width * (fb_bpp / 8);
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
286 }
a8170ba5496f maybe it can play avi :)
szabii
parents: 225
diff changeset
287 } else {
225
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
288 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
289 return 0;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
290 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
291
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
292 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x,
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
293 int y)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
294 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
295 uint8_t *dest;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
296
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
297 dest = next_frame + (in_width * y + x) * (fb_bpp / 8);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
298 yuv2rgb(dest, src[0], src[1], src[2], w, h, in_width * (fb_bpp / 8),
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
299 stride[0], stride[1]);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
300 return 0;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
301 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
302
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
303 static void check_events(void)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
304 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
305 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
306
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
307 static void flip_page(void)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
308 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
309 int i, out_offset = 0, in_offset = 0;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
310
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
311 vo_draw_text(in_width, in_height, draw_alpha);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
312 check_events();
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
313 for (i = 0; i < in_height; i++) {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
314 memcpy(frame_buffer + out_offset, next_frame + in_offset,
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
315 in_width * (fb_bpp / 8));
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
316 out_offset += screen_width;
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
317 in_offset += in_width * (fb_bpp / 8);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
318 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
319 }
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
320
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
321 static void uninit(void)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
322 {
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
323 if (vt_active >= 0)
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
324 ioctl(vt_fd, VT_ACTIVATE, vt_active);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
325 printf("vo_fbdev: uninit\n");
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
326 free(next_frame);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
327 munmap(frame_buffer, fb_size);
62ec84961b27 vo_fbdev added
szabii
parents:
diff changeset
328 }