annotate libvo/vo_fbdev2.c @ 36886:590e9305f12c

configure: Fix unnecessary rebuilds.
author reimar
date Fri, 07 Mar 2014 18:29:27 +0000
parents 598ef7d90b78
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
1 /*
28446
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
2 * video driver for framebuffer device
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
3 * copyright (C) 2003 Joey Parrish <joey@nicewarrior.org>
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
4 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
5 * This file is part of MPlayer.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
6 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
7 * MPlayer is free software; you can redistribute it and/or modify
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
8 * it under the terms of the GNU General Public License as published by
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
10 * (at your option) any later version.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
11 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
12 * MPlayer is distributed in the hope that it will be useful,
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
15 * GNU General Public License for more details.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
16 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
17 * You should have received a copy of the GNU General Public License along
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
18 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 25220
diff changeset
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
20 */
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
21
11412
ec3dac7d17a0 Warning fixes (approved by A'rpi).
rathann
parents: 11055
diff changeset
22 #include <stdio.h>
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
23 #include <stdlib.h>
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
24 #include <string.h>
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
25 #include <fcntl.h>
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
26 #include <unistd.h>
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
27 #include <errno.h>
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
28
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
29 #include <sys/mman.h>
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
30 #include <sys/ioctl.h>
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
31 #include <linux/fb.h>
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 #include "config.h"
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
34 #include "video_out.h"
36517
5d3f93051de9 Remove empty draw_slice and draw_frame stubs.
reimar
parents: 35054
diff changeset
35 #define NO_DRAW_FRAME
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
36 #include "video_out_internal.h"
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
37 #include "fastmemcpy.h"
32467
fbe5c829c69b Move libvo/sub.[ch] from libvo to sub.
cigaes
parents: 31082
diff changeset
38 #include "sub/sub.h"
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
39 #include "mp_msg.h"
33211
77a9d13fa30e Add -geometry support reusing common code to fbdev2.
reimar
parents: 32537
diff changeset
40 #include "aspect.h"
33212
c52a2600de15 Clip x/y offsets to avoid bad video placement.
reimar
parents: 33211
diff changeset
41 #include "libavutil/common.h"
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
42
25216
3aee342be929 Make vo info structs const
reimar
parents: 23457
diff changeset
43 static const vo_info_t info = {
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
44 "Framebuffer Device",
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
45 "fbdev2",
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
46 "Joey Parrish <joey@nicewarrior.org>",
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
47 ""
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
48 };
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
49
25220
c9e9ac2008c2 Mark the vo_functions_t definitions as const where possible.
reimar
parents: 25216
diff changeset
50 const LIBVO_EXTERN(fbdev2)
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
51
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
52 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
53 {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
54 p->bits_per_pixel = (bpp + 1) & ~1;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
55 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
56 p->transp.offset = p->transp.length = 0;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
57 p->blue.offset = 0;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
58 switch (bpp) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
59 case 32:
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
60 p->transp.offset = 24;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
61 p->transp.length = 8;
36641
598ef7d90b78 Document switch case fallthroughs.
reimar
parents: 36517
diff changeset
62 /* Fallthrough, rest matches 24 bit */
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
63 case 24:
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
64 p->red.offset = 16;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
65 p->red.length = 8;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
66 p->green.offset = 8;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
67 p->green.length = 8;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
68 p->blue.length = 8;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
69 break;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
70 case 16:
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
71 p->red.offset = 11;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
72 p->green.length = 6;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
73 p->red.length = 5;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
74 p->green.offset = 5;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
75 p->blue.length = 5;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
76 break;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
77 case 15:
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
78 p->red.offset = 10;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
79 p->green.length = 5;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
80 p->red.length = 5;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
81 p->green.offset = 5;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
82 p->blue.length = 5;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
83 break;
31082
92f88bb315c5 Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents: 30702
diff changeset
84 case 12:
92f88bb315c5 Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents: 30702
diff changeset
85 p->red.offset = 8;
92f88bb315c5 Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents: 30702
diff changeset
86 p->green.length = 4;
92f88bb315c5 Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents: 30702
diff changeset
87 p->red.length = 4;
92f88bb315c5 Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents: 30702
diff changeset
88 p->green.offset = 4;
92f88bb315c5 Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents: 30702
diff changeset
89 p->blue.length = 4;
92f88bb315c5 Add support for 12-bit color mode on framebuffer devices.
cehoyos
parents: 30702
diff changeset
90 break;
10763
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 }
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 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
95 static int fb_dev_fd; // handle for fb_dev_name
35054
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
96 static int fb_omap; // whether this looks like a omapfb device
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
97 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
98 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
99 static struct fb_fix_screeninfo fb_finfo; // fixed info
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
100 static struct fb_var_screeninfo fb_vinfo; // variable info
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
101 static struct fb_var_screeninfo fb_orig_vinfo; // variable info to restore later
17637
479b64764d9e Fix colormap save/restore for directcolor fb devices
pacman
parents: 16171
diff changeset
102 static unsigned short fb_ored[256], fb_ogreen[256], fb_oblue[256];
479b64764d9e Fix colormap save/restore for directcolor fb devices
pacman
parents: 16171
diff changeset
103 static struct fb_cmap fb_oldcmap = { 0, 256, fb_ored, fb_ogreen, fb_oblue };
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
104 static int fb_cmap_changed = 0; // to restore map
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
105 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
106 static size_t fb_size; // size of frame_buffer
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
107 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
108 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
109 unsigned char *srca, int stride, unsigned char *dst,
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
110 int dstride);
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
111
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
112 static uint8_t *next_frame = NULL; // for double buffering
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
113 static int in_width;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
114 static int in_height;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
115
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
116 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
117 {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
118 int i, cols, rcols, gcols, bcols;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
119 uint16_t *red, *green, *blue;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
120 struct fb_cmap *cmap;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28446
diff changeset
121
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
122 rcols = 1 << var->red.length;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
123 gcols = 1 << var->green.length;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
124 bcols = 1 << var->blue.length;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28446
diff changeset
125
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
126 /* Make our palette the length of the deepest color */
33213
d7b577e7e644 Simplify by using FFMAX3.
reimar
parents: 33212
diff changeset
127 cols = FFMAX3(rcols, gcols, bcols);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28446
diff changeset
128
33215
4c7b564719e0 Simplify colormap generation code, avoid some mallocs and add frees
reimar
parents: 33213
diff changeset
129 red = malloc(3 * cols * sizeof(red[0]));
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
130 if(!red) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
131 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
132 return NULL;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
133 }
33215
4c7b564719e0 Simplify colormap generation code, avoid some mallocs and add frees
reimar
parents: 33213
diff changeset
134 green = red + cols;
4c7b564719e0 Simplify colormap generation code, avoid some mallocs and add frees
reimar
parents: 33213
diff changeset
135 blue = green + cols;
4c7b564719e0 Simplify colormap generation code, avoid some mallocs and add frees
reimar
parents: 33213
diff changeset
136 for (i = 0; i < cols; i++) {
4c7b564719e0 Simplify colormap generation code, avoid some mallocs and add frees
reimar
parents: 33213
diff changeset
137 red[i] = (65535/(rcols-1)) * i;
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
138 green[i] = (65535/(gcols-1)) * i;
33215
4c7b564719e0 Simplify colormap generation code, avoid some mallocs and add frees
reimar
parents: 33213
diff changeset
139 blue[i] = (65535/(bcols-1)) * i;
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
140 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28446
diff changeset
141
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
142 cmap = malloc(sizeof(struct fb_cmap));
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
143 if(!cmap) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
144 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
145 free(red);
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
146 return NULL;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
147 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
148 cmap->start = 0;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
149 cmap->transp = 0;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
150 cmap->len = cols;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
151 cmap->red = red;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
152 cmap->blue = blue;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
153 cmap->green = green;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
154 cmap->transp = NULL;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28446
diff changeset
155
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
156 return cmap;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
157 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
158
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
159 static int fb_preinit(int reset)
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 static int fb_preinit_done = 0;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
162 static int fb_err = -1;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
163
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
164 if (reset) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
165 fb_preinit_done = 0;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
166 return 0;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
167 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28446
diff changeset
168
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
169 if (fb_preinit_done)
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
170 return fb_err;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
171 fb_preinit_done = 1;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
172
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
173 if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER")))
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
174 fb_dev_name = strdup("/dev/fb0");
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
175
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
176 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
177
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
178 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
179 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
180 goto err_out;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
181 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
182 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
183 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
184 goto err_out;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
185 }
35054
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
186 // random ioctl to check if we seem to run on OMAPFB
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
187 #define OMAPFB_SYNC_GFX (('O' << 8) | 37)
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
188 fb_omap = ioctl(fb_dev_fd, OMAPFB_SYNC_GFX) == 0;
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
189 fb_orig_vinfo = fb_vinfo;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
190
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
191 fb_err = 0;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
192 return 0;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
193 err_out:
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
194 if (fb_dev_fd >= 0) close(fb_dev_fd);
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
195 fb_dev_fd = -1;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
196 fb_err = -1;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
197 return -1;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
198 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
199
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
200 static int preinit(const char *subdevice)
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
201 {
11055
497104408c30 correct handling of subdevice, -fb device is obsoleted
alex
parents: 10763
diff changeset
202 if (subdevice)
497104408c30 correct handling of subdevice, -fb device is obsoleted
alex
parents: 10763
diff changeset
203 {
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 32467
diff changeset
204 free(fb_dev_name);
11055
497104408c30 correct handling of subdevice, -fb device is obsoleted
alex
parents: 10763
diff changeset
205 fb_dev_name = strdup(subdevice);
497104408c30 correct handling of subdevice, -fb device is obsoleted
alex
parents: 10763
diff changeset
206 }
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
207 return fb_preinit(0);
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
208 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
209
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
210 static int config(uint32_t width, uint32_t height, uint32_t d_width,
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
211 uint32_t d_height, uint32_t flags, char *title,
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
212 uint32_t format)
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 struct fb_cmap *cmap;
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 14094
diff changeset
215 int fs = flags & VOFLAG_FULLSCREEN;
33212
c52a2600de15 Clip x/y offsets to avoid bad video placement.
reimar
parents: 33211
diff changeset
216 int x_offset = vo_dx + (d_width - width ) / 2;
c52a2600de15 Clip x/y offsets to avoid bad video placement.
reimar
parents: 33211
diff changeset
217 int y_offset = vo_dy + (d_height - height) / 2;
c52a2600de15 Clip x/y offsets to avoid bad video placement.
reimar
parents: 33211
diff changeset
218 x_offset = av_clip(x_offset, 0, fb_vinfo.xres - width);
c52a2600de15 Clip x/y offsets to avoid bad video placement.
reimar
parents: 33211
diff changeset
219 y_offset = av_clip(y_offset, 0, fb_vinfo.yres - height);
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
220
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
221 in_width = width;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
222 in_height = height;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
223
33211
77a9d13fa30e Add -geometry support reusing common code to fbdev2.
reimar
parents: 32537
diff changeset
224 if (fb_vinfo.xres < in_width || fb_vinfo.yres < in_height) {
10763
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",
33211
77a9d13fa30e Add -geometry support reusing common code to fbdev2.
reimar
parents: 32537
diff changeset
226 fb_vinfo.xres, fb_vinfo.yres, in_width, in_height);
10763
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
35050
b291f44d864a Avoid some code duplication related to drawing the OSD.
reimar
parents: 33305
diff changeset
230 draw_alpha_p = vo_get_draw_alpha(format);
35052
60e92b725c3d Remove unused fb_bpp and change fb_pixel_size initialization
reimar
parents: 35051
diff changeset
231 fb_pixel_size = pixel_stride(format);
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
232
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
233 if (vo_config_count == 0) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
234 if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo)) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
235 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
236 return 1;
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
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
239 if (fb_finfo.type != FB_TYPE_PACKED_PIXELS) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
240 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
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 switch (fb_finfo.visual) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
245 case FB_VISUAL_TRUECOLOR:
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
246 break;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
247 case FB_VISUAL_DIRECTCOLOR:
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
248 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
249 if (ioctl(fb_dev_fd, FBIOGETCMAP, &fb_oldcmap)) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
250 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
251 return 1;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
252 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
253 if (!(cmap = make_directcolor_cmap(&fb_vinfo)))
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
254 return 1;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
255 if (ioctl(fb_dev_fd, FBIOPUTCMAP, cmap)) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
256 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] can't put cmap: %s\n", strerror(errno));
33215
4c7b564719e0 Simplify colormap generation code, avoid some mallocs and add frees
reimar
parents: 33213
diff changeset
257 free(cmap->red);
4c7b564719e0 Simplify colormap generation code, avoid some mallocs and add frees
reimar
parents: 33213
diff changeset
258 free(cmap);
10763
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 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
261 fb_cmap_changed = 1;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
262 free(cmap->red);
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
263 free(cmap);
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
264 break;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
265 default:
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
266 mp_msg(MSGT_VO, MSGL_ERR, "[fbdev2] visual: %d not yet supported\n", fb_finfo.visual);
35054
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
267 break;
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
268 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
269
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
270 fb_size = fb_finfo.smem_len;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
271 fb_line_len = fb_finfo.line_length;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
272 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
273 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
274 return 1;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
275 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
276 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
277
17728
fe2520f6039e When centering a video with odd width, be sure to start on a pixel boundary.
pacman
parents: 17637
diff changeset
278 center = frame_buffer +
33212
c52a2600de15 Clip x/y offsets to avoid bad video placement.
reimar
parents: 33211
diff changeset
279 x_offset * fb_pixel_size +
c52a2600de15 Clip x/y offsets to avoid bad video placement.
reimar
parents: 33211
diff changeset
280 y_offset * fb_line_len;
10763
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 #ifndef USE_CONVERT2FB
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30207
diff changeset
283 if (!(next_frame = realloc(next_frame, in_width * in_height * fb_pixel_size))) {
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
284 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
285 return 1;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
286 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
287 #endif
35054
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
288 if (fs) {
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
289 int len = fb_line_len * fb_vinfo.yres;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
290 int i;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
291 switch (format) {
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
292 case IMGFMT_YUY2:
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
293 for (i = 0; i < len - 3;) {
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
294 frame_buffer[i++] = 0;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
295 frame_buffer[i++] = 0x80;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
296 frame_buffer[i++] = 0;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
297 frame_buffer[i++] = 0x80;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
298 }
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
299 break;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
300 case IMGFMT_UYVY:
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
301 for (i = 0; i < len - 3;) {
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
302 frame_buffer[i++] = 0x80;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
303 frame_buffer[i++] = 0;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
304 frame_buffer[i++] = 0x80;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
305 frame_buffer[i++] = 0;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
306 }
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
307 break;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
308 default:
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
309 memset(frame_buffer, 0, len);
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
310 }
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
311 }
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
312
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
313 return 0;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
314 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
315
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
316 static int query_format(uint32_t format)
10763
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 // open the device, etc.
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
319 if (fb_preinit(0)) return 0;
35054
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
320 // At least IntelFB silently ignores nonstd value,
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
321 // so we can run the ioctl check only if already
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
322 // determined we are running on OMAPFB
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
323 if (fb_omap && (format == IMGFMT_YUY2 ||
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
324 format == IMGFMT_UYVY)) {
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
325 fb_vinfo.xres_virtual = fb_vinfo.xres;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
326 fb_vinfo.yres_virtual = fb_vinfo.yres;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
327 fb_vinfo.nonstd = format == IMGFMT_YUY2 ? 8 : 1;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
328 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo) == 0)
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
329 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_ACCEPT_STRIDE;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
330 return 0;
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
331 }
35051
fdd4b7d35537 Simplify a condition.
reimar
parents: 35050
diff changeset
332 if (IMGFMT_IS_BGR(format)) {
35052
60e92b725c3d Remove unused fb_bpp and change fb_pixel_size initialization
reimar
parents: 35051
diff changeset
333 int bpp;
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
334 int fb_target_bpp = format & 0xff;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
335 set_bpp(&fb_vinfo, fb_target_bpp);
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
336 fb_vinfo.xres_virtual = fb_vinfo.xres;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
337 fb_vinfo.yres_virtual = fb_vinfo.yres;
35054
37a527d635ef Add support for OMAPFB YUV framebuffer.
reimar
parents: 35052
diff changeset
338 fb_vinfo.nonstd = 0;
30207
6d8765b75f37 Fix fbdev2 to work with Intel framebuffer.
reimar
parents: 29263
diff changeset
339 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo))
6d8765b75f37 Fix fbdev2 to work with Intel framebuffer.
reimar
parents: 29263
diff changeset
340 // Needed for Intel framebuffer with 32 bpp
6d8765b75f37 Fix fbdev2 to work with Intel framebuffer.
reimar
parents: 29263
diff changeset
341 fb_vinfo.transp.length = fb_vinfo.transp.offset = 0;
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
342 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
343 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
344 return 0;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
345 }
35052
60e92b725c3d Remove unused fb_bpp and change fb_pixel_size initialization
reimar
parents: 35051
diff changeset
346 bpp = fb_vinfo.bits_per_pixel;
60e92b725c3d Remove unused fb_bpp and change fb_pixel_size initialization
reimar
parents: 35051
diff changeset
347 if (bpp == 16)
60e92b725c3d Remove unused fb_bpp and change fb_pixel_size initialization
reimar
parents: 35051
diff changeset
348 bpp = fb_vinfo.red.length + fb_vinfo.green.length + fb_vinfo.blue.length;
60e92b725c3d Remove unused fb_bpp and change fb_pixel_size initialization
reimar
parents: 35051
diff changeset
349 if (bpp == fb_target_bpp)
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
350 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
351 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
352 return 0;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
353 }
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 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
356 unsigned char *srca, int stride)
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
357 {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
358 unsigned char *dst;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
359 int dstride;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
360
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
361 #ifdef USE_CONVERT2FB
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
362 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
363 dstride = fb_line_len;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
364 #else
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
365 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
366 dstride = in_width * fb_pixel_size;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
367 #endif
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
368 (*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
369 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
370
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
371 static void draw_osd(void)
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
372 {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
373 vo_draw_text(in_width, in_height, draw_alpha);
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
374 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
375
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
376 static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y)
10763
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 uint8_t *in = src[0];
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
379 #ifdef USE_CONVERT2FB
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
380 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
381 int next = fb_line_len;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
382 #else
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
383 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
384 int next = in_width * fb_pixel_size;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
385 #endif
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
386
33216
5f00ed06579d Use memcpy_pic instead of reimplementing it.
reimar
parents: 33215
diff changeset
387 memcpy_pic(dest, in, w * fb_pixel_size, h, next, stride[0]);
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
388 return 0;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
389 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
390
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
391 static void check_events(void)
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
392 {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
393 }
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 static void flip_page(void)
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
396 {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
397 #ifndef USE_CONVERT2FB
33216
5f00ed06579d Use memcpy_pic instead of reimplementing it.
reimar
parents: 33215
diff changeset
398 int out_offset = 0, in_offset = 0;
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
399
33216
5f00ed06579d Use memcpy_pic instead of reimplementing it.
reimar
parents: 33215
diff changeset
400 memcpy_pic(center + out_offset, next_frame + in_offset,
5f00ed06579d Use memcpy_pic instead of reimplementing it.
reimar
parents: 33215
diff changeset
401 in_width * fb_pixel_size, in_height,
5f00ed06579d Use memcpy_pic instead of reimplementing it.
reimar
parents: 33215
diff changeset
402 fb_line_len, in_width * fb_pixel_size);
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
403 #endif
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
404 }
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 static void uninit(void)
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
407 {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
408 if (fb_cmap_changed) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
409 if (ioctl(fb_dev_fd, FBIOPUTCMAP, &fb_oldcmap))
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
410 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
411 fb_cmap_changed = 0;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
412 }
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 32467
diff changeset
413 free(next_frame);
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
414 if (fb_dev_fd >= 0) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
415 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
416 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
417 close(fb_dev_fd);
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
418 fb_dev_fd = -1;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
419 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
420 if(frame_buffer) munmap(frame_buffer, fb_size);
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
421 next_frame = frame_buffer = NULL;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
422 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
423 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
424
33305
ddb45e9443ec Remove the variable arguments from the libvo control() functions.
iive
parents: 33216
diff changeset
425 static int control(uint32_t request, void *data)
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
426 {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
427 switch (request) {
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
428 case VOCTRL_QUERY_FORMAT:
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
429 return query_format(*((uint32_t*)data));
33211
77a9d13fa30e Add -geometry support reusing common code to fbdev2.
reimar
parents: 32537
diff changeset
430 case VOCTRL_UPDATE_SCREENINFO:
77a9d13fa30e Add -geometry support reusing common code to fbdev2.
reimar
parents: 32537
diff changeset
431 vo_screenwidth = fb_vinfo.xres;
77a9d13fa30e Add -geometry support reusing common code to fbdev2.
reimar
parents: 32537
diff changeset
432 vo_screenheight = fb_vinfo.yres;
77a9d13fa30e Add -geometry support reusing common code to fbdev2.
reimar
parents: 32537
diff changeset
433 aspect_save_screenres(vo_screenwidth, vo_screenheight);
77a9d13fa30e Add -geometry support reusing common code to fbdev2.
reimar
parents: 32537
diff changeset
434 return VO_TRUE;
10763
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
435 }
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
436 return VO_NOTIMPL;
7436a53876b0 vo_fbdev2 written by Joey Parrish with some minor modifications
alex
parents:
diff changeset
437 }