Mercurial > mplayer.hg
annotate libvo/vo_fbdev2.c @ 12947:555140a0d8f5
Sync, some spelling and copy/paste issues.
author | wight |
---|---|
date | Tue, 03 Aug 2004 21:05:34 +0000 |
parents | e0b096f0e640 |
children | a0197f7b0784 |
rev | line source |
---|---|
10763
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
1 /* |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
2 * Video driver for Framebuffer device |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
3 * by Joey Parrish <joey@nicewarrior.org> |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
4 * (C) 2003 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
5 */ |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
6 |
11412 | 7 #include <stdio.h> |
10763
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
8 #include <stdlib.h> |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
9 #include <string.h> |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
10 #include <fcntl.h> |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
11 #include <unistd.h> |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
12 #include <errno.h> |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
13 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
14 #include <sys/mman.h> |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
15 #include <sys/ioctl.h> |
11765
e0b096f0e640
linux 2.6 patch by "ismail 'cartman' d«Ónmez" <ismail.donmez@boun.edu.tr>
attila
parents:
11412
diff
changeset
|
16 #include "kerneltwosix.h" |
10763
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
17 #include <linux/fb.h> |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
18 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
19 #include "config.h" |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
20 #include "video_out.h" |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
21 #include "video_out_internal.h" |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
22 #include "fastmemcpy.h" |
11412 | 23 #include "sub.h" |
10763
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
24 #include "mp_msg.h" |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
25 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
26 static vo_info_t info = { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
27 "Framebuffer Device", |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
28 "fbdev2", |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
29 "Joey Parrish <joey@nicewarrior.org>", |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
30 "" |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
31 }; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
32 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
33 LIBVO_EXTERN(fbdev2) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
34 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
35 static void set_bpp(struct fb_var_screeninfo *p, int bpp) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
36 { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
37 p->bits_per_pixel = (bpp + 1) & ~1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
38 p->red.msb_right = p->green.msb_right = p->blue.msb_right = p->transp.msb_right = 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
39 p->transp.offset = p->transp.length = 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
40 p->blue.offset = 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
41 switch (bpp) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
42 case 32: |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
43 p->transp.offset = 24; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
44 p->transp.length = 8; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
45 case 24: |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
46 p->red.offset = 16; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
47 p->red.length = 8; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
48 p->green.offset = 8; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
49 p->green.length = 8; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
50 p->blue.length = 8; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
51 break; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
52 case 16: |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
53 p->red.offset = 11; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
54 p->green.length = 6; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
55 p->red.length = 5; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
56 p->green.offset = 5; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
57 p->blue.length = 5; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
58 break; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
59 case 15: |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
60 p->red.offset = 10; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
61 p->green.length = 5; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
62 p->red.length = 5; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
63 p->green.offset = 5; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
64 p->blue.length = 5; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
65 break; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
66 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
67 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
68 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
69 static char *fb_dev_name = NULL; // such as /dev/fb0 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
70 static int fb_dev_fd; // handle for fb_dev_name |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
71 static uint8_t *frame_buffer = NULL; // mmap'd access to fbdev |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
72 static uint8_t *center = NULL; // where to begin writing our image (centered?) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
73 static struct fb_fix_screeninfo fb_finfo; // fixed info |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
74 static struct fb_var_screeninfo fb_vinfo; // variable info |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
75 static struct fb_var_screeninfo fb_orig_vinfo; // variable info to restore later |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
76 static struct fb_cmap fb_oldcmap; // cmap to restore later |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
77 static int fb_cmap_changed = 0; // to restore map |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
78 static int fb_pixel_size; // 32: 4 24: 3 16: 2 15: 2 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
79 static int fb_bpp; // 32: 32 24: 24 16: 16 15: 15 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
80 static size_t fb_size; // size of frame_buffer |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
81 static int fb_line_len; // length of one line in bytes |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
82 static void (*draw_alpha_p)(int w, int h, unsigned char *src, |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
83 unsigned char *srca, int stride, unsigned char *dst, |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
84 int dstride); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
85 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
86 static uint8_t *next_frame = NULL; // for double buffering |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
87 static int in_width; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
88 static int in_height; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
89 static int out_width; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
90 static int out_height; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
91 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
92 static struct fb_cmap *make_directcolor_cmap(struct fb_var_screeninfo *var) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
93 { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
94 int i, cols, rcols, gcols, bcols; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
95 uint16_t *red, *green, *blue; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
96 struct fb_cmap *cmap; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
97 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
98 rcols = 1 << var->red.length; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
99 gcols = 1 << var->green.length; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
100 bcols = 1 << var->blue.length; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
101 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
102 /* Make our palette the length of the deepest color */ |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
103 cols = (rcols > gcols ? rcols : gcols); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
104 cols = (cols > bcols ? cols : bcols); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
105 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
106 red = malloc(cols * sizeof(red[0])); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
107 if(!red) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
108 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't allocate red palette with %d entries.\n", cols); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
109 return NULL; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
110 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
111 for(i=0; i< rcols; i++) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
112 red[i] = (65535/(rcols-1)) * i; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
113 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
114 green = malloc(cols * sizeof(green[0])); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
115 if(!green) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
116 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't allocate green palette with %d entries.\n", cols); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
117 free(red); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
118 return NULL; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
119 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
120 for(i=0; i< gcols; i++) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
121 green[i] = (65535/(gcols-1)) * i; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
122 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
123 blue = malloc(cols * sizeof(blue[0])); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
124 if(!blue) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
125 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't allocate blue palette with %d entries.\n", cols); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
126 free(red); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
127 free(green); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
128 return NULL; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
129 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
130 for(i=0; i< bcols; i++) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
131 blue[i] = (65535/(bcols-1)) * i; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
132 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
133 cmap = malloc(sizeof(struct fb_cmap)); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
134 if(!cmap) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
135 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't allocate color map\n"); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
136 free(red); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
137 free(green); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
138 free(blue); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
139 return NULL; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
140 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
141 cmap->start = 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
142 cmap->transp = 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
143 cmap->len = cols; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
144 cmap->red = red; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
145 cmap->blue = blue; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
146 cmap->green = green; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
147 cmap->transp = NULL; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
148 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
149 return cmap; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
150 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
151 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
152 static int fb_preinit(int reset) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
153 { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
154 static int fb_preinit_done = 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
155 static int fb_err = -1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
156 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
157 if (reset) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
158 fb_preinit_done = 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
159 return 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
160 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
161 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
162 if (fb_preinit_done) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
163 return fb_err; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
164 fb_preinit_done = 1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
165 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
166 if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER"))) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
167 fb_dev_name = strdup("/dev/fb0"); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
168 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
169 mp_msg(MSGT_VO, MSGL_V, "[fbdev2] Using device %s\n", fb_dev_name); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
170 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
171 if ((fb_dev_fd = open(fb_dev_name, O_RDWR)) == -1) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
172 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't open %s: %s\n", fb_dev_name, strerror(errno)); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
173 goto err_out; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
174 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
175 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
176 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't get VSCREENINFO: %s\n", strerror(errno)); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
177 goto err_out; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
178 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
179 fb_orig_vinfo = fb_vinfo; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
180 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
181 fb_bpp = fb_vinfo.bits_per_pixel; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
182 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
183 /* 16 and 15 bpp is reported as 16 bpp */ |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
184 if (fb_bpp == 16) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
185 fb_bpp = fb_vinfo.red.length + fb_vinfo.green.length + |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
186 fb_vinfo.blue.length; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
187 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
188 fb_err = 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
189 return 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
190 err_out: |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
191 if (fb_dev_fd >= 0) close(fb_dev_fd); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
192 fb_dev_fd = -1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
193 fb_err = -1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
194 return -1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
195 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
196 |
11055
497104408c30
correct handling of subdevice, -fb device is obsoleted
alex
parents:
10763
diff
changeset
|
197 static uint32_t preinit(const char *subdevice) |
10763
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
198 { |
11055
497104408c30
correct handling of subdevice, -fb device is obsoleted
alex
parents:
10763
diff
changeset
|
199 if (subdevice) |
497104408c30
correct handling of subdevice, -fb device is obsoleted
alex
parents:
10763
diff
changeset
|
200 { |
497104408c30
correct handling of subdevice, -fb device is obsoleted
alex
parents:
10763
diff
changeset
|
201 if (fb_dev_name) free(fb_dev_name); |
497104408c30
correct handling of subdevice, -fb device is obsoleted
alex
parents:
10763
diff
changeset
|
202 fb_dev_name = strdup(subdevice); |
497104408c30
correct handling of subdevice, -fb device is obsoleted
alex
parents:
10763
diff
changeset
|
203 } |
10763
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
204 return fb_preinit(0); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
205 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
206 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
207 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
208 uint32_t d_height, uint32_t flags, char *title, |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
209 uint32_t format) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
210 { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
211 struct fb_cmap *cmap; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
212 int fs = flags & 0x01; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
213 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
214 out_width = width; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
215 out_height = height; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
216 in_width = width; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
217 in_height = height; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
218 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
219 if (fs) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
220 out_width = fb_vinfo.xres; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
221 out_height = fb_vinfo.yres; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
222 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
223 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
224 if (out_width < in_width || out_height < in_height) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
225 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Screensize is smaller than video size (%dx%d < %dx%d)\n", |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
226 out_width, out_height, in_width, in_height); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
227 return 1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
228 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
229 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
230 switch (fb_bpp) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
231 case 32: draw_alpha_p = vo_draw_alpha_rgb32; break; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
232 case 24: draw_alpha_p = vo_draw_alpha_rgb24; break; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
233 case 16: draw_alpha_p = vo_draw_alpha_rgb16; break; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
234 case 15: draw_alpha_p = vo_draw_alpha_rgb15; break; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
235 default: return 1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
236 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
237 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
238 if (vo_config_count == 0) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
239 if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo)) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
240 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't get FSCREENINFO: %s\n", strerror(errno)); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
241 return 1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
242 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
243 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
244 if (fb_finfo.type != FB_TYPE_PACKED_PIXELS) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
245 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] type %d not supported\n", fb_finfo.type); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
246 return 1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
247 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
248 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
249 switch (fb_finfo.visual) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
250 case FB_VISUAL_TRUECOLOR: |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
251 break; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
252 case FB_VISUAL_DIRECTCOLOR: |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
253 mp_msg(MSGT_VO, MSGL_V, "[fbdev2] creating cmap for directcolor\n"); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
254 if (ioctl(fb_dev_fd, FBIOGETCMAP, &fb_oldcmap)) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
255 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] can't get cmap: %s\n", strerror(errno)); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
256 return 1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
257 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
258 if (!(cmap = make_directcolor_cmap(&fb_vinfo))) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
259 return 1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
260 if (ioctl(fb_dev_fd, FBIOPUTCMAP, cmap)) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
261 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] can't put cmap: %s\n", strerror(errno)); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
262 return 1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
263 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
264 fb_cmap_changed = 1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
265 free(cmap->red); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
266 free(cmap->green); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
267 free(cmap->blue); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
268 free(cmap); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
269 break; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
270 default: |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
271 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] visual: %d not yet supported\n", fb_finfo.visual); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
272 return 1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
273 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
274 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
275 fb_size = fb_finfo.smem_len; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
276 fb_line_len = fb_finfo.line_length; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
277 if ((frame_buffer = (uint8_t *) mmap(0, fb_size, PROT_READ | PROT_WRITE, MAP_SHARED, fb_dev_fd, 0)) == (uint8_t *) -1) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
278 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't mmap %s: %s\n", fb_dev_name, strerror(errno)); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
279 return 1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
280 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
281 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
282 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
283 center = frame_buffer + (out_width - in_width) * fb_pixel_size / |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
284 2 + ( (out_height - in_height) / 2 ) * fb_line_len; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
285 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
286 #ifndef USE_CONVERT2FB |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
287 if (!(next_frame = (uint8_t *) realloc(next_frame, in_width * in_height * fb_pixel_size))) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
288 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't malloc next_frame: %s\n", strerror(errno)); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
289 return 1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
290 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
291 #endif |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
292 if (fs) memset(frame_buffer, '\0', fb_line_len * fb_vinfo.yres); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
293 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
294 return 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
295 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
296 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
297 static uint32_t query_format(uint32_t format) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
298 { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
299 // open the device, etc. |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
300 if (fb_preinit(0)) return 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
301 if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
302 int fb_target_bpp = format & 0xff; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
303 set_bpp(&fb_vinfo, fb_target_bpp); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
304 fb_vinfo.xres_virtual = fb_vinfo.xres; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
305 fb_vinfo.yres_virtual = fb_vinfo.yres; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
306 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
307 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't put VSCREENINFO: %s\n", strerror(errno)); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
308 return 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
309 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
310 fb_pixel_size = fb_vinfo.bits_per_pixel / 8; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
311 fb_bpp = fb_vinfo.red.length + fb_vinfo.green.length + |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
312 fb_vinfo.blue.length + fb_vinfo.transp.length; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
313 if (fb_bpp == fb_target_bpp) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
314 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_ACCEPT_STRIDE; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
315 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
316 return 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
317 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
318 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
319 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
320 unsigned char *srca, int stride) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
321 { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
322 unsigned char *dst; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
323 int dstride; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
324 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
325 #ifdef USE_CONVERT2FB |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
326 dst = center + (fb_line_len * y0) + (x0 * fb_pixel_size); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
327 dstride = fb_line_len; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
328 #else |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
329 dst = next_frame + (in_width * y0 + x0) * fb_pixel_size; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
330 dstride = in_width * fb_pixel_size; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
331 #endif |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
332 (*draw_alpha_p)(w, h, src, srca, stride, dst, dstride); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
333 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
334 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
335 static void draw_osd(void) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
336 { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
337 vo_draw_text(in_width, in_height, draw_alpha); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
338 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
339 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
340 // all csp support stride |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
341 static uint32_t draw_frame(uint8_t *src[]) { return 1; } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
342 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
343 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
344 { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
345 uint8_t *in = src[0]; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
346 #ifdef USE_CONVERT2FB |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
347 uint8_t *dest = center + (fb_line_len * y) + (x * fb_pixel_size); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
348 int next = fb_line_len; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
349 #else |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
350 uint8_t *dest = next_frame + (in_width * y + x) * fb_pixel_size; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
351 int next = in_width * fb_pixel_size; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
352 #endif |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
353 int i; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
354 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
355 for (i = 0; i < h; i++) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
356 memcpy(dest, in, w * fb_pixel_size); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
357 dest += next; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
358 in += stride[0]; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
359 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
360 return 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
361 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
362 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
363 static void check_events(void) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
364 { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
365 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
366 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
367 static void flip_page(void) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
368 { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
369 #ifndef USE_CONVERT2FB |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
370 int i, out_offset = 0, in_offset = 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
371 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
372 for (i = 0; i < in_height; i++) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
373 memcpy(center + out_offset, next_frame + in_offset, |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
374 in_width * fb_pixel_size); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
375 out_offset += fb_line_len; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
376 in_offset += in_width * fb_pixel_size; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
377 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
378 #endif |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
379 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
380 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
381 static void uninit(void) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
382 { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
383 if (fb_cmap_changed) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
384 if (ioctl(fb_dev_fd, FBIOPUTCMAP, &fb_oldcmap)) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
385 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't restore original cmap\n"); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
386 fb_cmap_changed = 0; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
387 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
388 if(next_frame) free(next_frame); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
389 if (fb_dev_fd >= 0) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
390 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_orig_vinfo)) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
391 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] Can't reset original fb_var_screeninfo: %s\n", strerror(errno)); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
392 close(fb_dev_fd); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
393 fb_dev_fd = -1; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
394 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
395 if(frame_buffer) munmap(frame_buffer, fb_size); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
396 next_frame = frame_buffer = NULL; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
397 fb_preinit(1); // so that later calls to preinit don't fail |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
398 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
399 |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
400 static uint32_t control(uint32_t request, void *data, ...) |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
401 { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
402 switch (request) { |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
403 case VOCTRL_QUERY_FORMAT: |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
404 return query_format(*((uint32_t*)data)); |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
405 } |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
406 return VO_NOTIMPL; |
7436a53876b0
vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff
changeset
|
407 } |