1 /*
2 * Copyright (c) 2011 Stefano Sabatini
3 * Copyright (c) 2009 Giliard B. de Freitas <giliarde@gmail.com>
4 * Copyright (C) 2002 Gunnar Monell <gmo@linux.nu>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include <unistd.h>
24 #include <fcntl.h>
25 #include <sys/ioctl.h>
26 #include <stdlib.h>
32
37 };
38
40 // bpp, red_offset, green_offset, blue_offset, alpha_offset, pixfmt
48 };
49
51 {
53
56 if (
entry->bits_per_pixel == varinfo->bits_per_pixel &&
57 entry->red_offset == varinfo->red.offset &&
58 entry->green_offset == varinfo->green.offset &&
59 entry->blue_offset == varinfo->blue.offset)
61 }
62
64 }
65
67 {
68 const char *dev = getenv("FRAMEBUFFER");
69 if (!dev)
70 dev = "/dev/fb0";
71 return dev;
72 }
73
75 {
76 struct fb_var_screeninfo varinfo;
77 struct fb_fix_screeninfo fixinfo;
78 char device_file[12];
82
83 if (!device_list)
85
86 for (
i = 0;
i <= 31;
i++) {
87 snprintf(device_file,
sizeof(device_file),
"/dev/fb%d",
i);
88
94 continue;
95 }
96 if (ioctl(fd, FBIOGET_VSCREENINFO, &varinfo) == -1)
97 goto fail_device;
98 if (ioctl(fd, FBIOGET_FSCREENINFO, &fixinfo) == -1)
99 goto fail_device;
100
102 if (!device) {
104 goto fail_device;
105 }
110 goto fail_device;
111 }
112
115 goto fail_device;
116
117 if (default_device && !strcmp(device->
device_name, default_device)) {
119 default_device =
NULL;
120 }
121 close(fd);
122 continue;
123
124 fail_device:
125 if (device) {
129 }
130 if (fd >= 0)
131 close(fd);
134 }
135 return 0;
136 }