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 #ifdef CONFIG_LINUX 12 13 #include <fcntl.h> 14 #include <sys/ioctl.h> 15 16 int udmabuf_fd(void) 17 { 18 static bool first = true; 19 static int udmabuf; 20 21 if (!first) { 22 return udmabuf; 23 } 24 first = false; 25 26 udmabuf = open("/dev/udmabuf", O_RDWR); 27 if (udmabuf < 0) { 28 warn_report("open /dev/udmabuf: %s", strerror(errno)); 29 } 30 return udmabuf; 31 } 32 33 #else 34 35 int udmabuf_fd(void) 36 { 37 return -1; 38 } 39 40 #endif 41