udmabuf.c 600 B

1234567891011121314151617181920212223242526272829
  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. #include "qemu/error-report.h"
  11. #include <sys/ioctl.h>
  12. int udmabuf_fd(void)
  13. {
  14. static bool first = true;
  15. static int udmabuf;
  16. if (!first) {
  17. return udmabuf;
  18. }
  19. first = false;
  20. udmabuf = open("/dev/udmabuf", O_RDWR);
  21. if (udmabuf < 0) {
  22. warn_report("open /dev/udmabuf: %s", strerror(errno));
  23. }
  24. return udmabuf;
  25. }