xref: /openbmc/qemu/ui/udmabuf.c (revision 0e660142)
1 /*
2  * udmabuf helper functions.
3  *
4  * This work is licensed under the terms of the GNU GPL, version 2 or later.
5  * See the COPYING file in the top-level directory.
6  */
7 #include "qemu/osdep.h"
8 #include "qapi/error.h"
9 #include "ui/console.h"
10 
11 #include <sys/ioctl.h>
12 
13 int udmabuf_fd(void)
14 {
15     static bool first = true;
16     static int udmabuf;
17 
18     if (!first) {
19         return udmabuf;
20     }
21     first = false;
22 
23     udmabuf = open("/dev/udmabuf", O_RDWR);
24     if (udmabuf < 0) {
25         warn_report("open /dev/udmabuf: %s", strerror(errno));
26     }
27     return udmabuf;
28 }
29