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>
30
35 };
36
38 // bpp, red_offset, green_offset, blue_offset, alpha_offset, pixfmt
46 };
47
49 {
50 int i;
51
59 }
60
62 }
63
65 {
66 const char *dev = getenv("FRAMEBUFFER");
67 if (!dev)
68 dev = "/dev/fb0";
69 return dev;
70 }
71
73 {
74 struct fb_var_screeninfo varinfo;
75 struct fb_fix_screeninfo fixinfo;
76 char device_file[12];
80
81 if (!device_list)
83
84 for (i = 0; i <= 31; i++) {
85 snprintf(device_file,
sizeof(device_file),
"/dev/fb%d", i);
86
92 continue;
93 }
94 if (ioctl(fd, FBIOGET_VSCREENINFO, &varinfo) == -1)
95 goto fail_device;
96 if (ioctl(fd, FBIOGET_FSCREENINFO, &fixinfo) == -1)
97 goto fail_device;
98
100 if (!device) {
102 goto fail_device;
103 }
108 goto fail_device;
109 }
110
113 goto fail_device;
114
115 if (default_device && !strcmp(device->
device_name, default_device)) {
117 default_device =
NULL;
118 }
119 close(fd);
120 continue;
121
122 fail_device:
123 if (device) {
127 }
128 if (fd >= 0)
129 close(fd);
130 if (ret < 0)
132 }
133 return 0;
134 }
Structure describes basic parameters of the device.
char * device_description
human friendly name
packed RGB 8:8:8, 24bpp, RGBRGB...
char * device_name
device name, format depends on device
#define FF_ARRAY_ELEMS(a)
const char * ff_fbdev_default_device()
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
int avpriv_open(const char *filename, int flags,...)
A wrapper for open() setting O_CLOEXEC.
Main libavdevice API header.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
enum AVPixelFormat pixfmt
AVDeviceInfo ** devices
list of autodetected devices
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
packed RGB 8:8:8, 24bpp, BGRBGR...
char * av_strdup(const char *s)
Duplicate the string s.
static const struct rgb_pixfmt_map_entry rgb_pixfmt_map[]
int ff_fbdev_get_device_list(AVDeviceInfoList *device_list)
int default_device
index of default device or -1 if no default
common internal and external API header
enum AVPixelFormat ff_get_pixfmt_from_fb_varinfo(struct fb_var_screeninfo *varinfo)
#define AV_PIX_FMT_RGB565
int nb_devices
number of autodetected devices
AVPixelFormat
Pixel format.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...