aboutsummaryrefslogtreecommitdiff
path: root/ui/udmabuf.c
blob: 23abe1e7eb91b864728ac9fb3f0f9f1cb2ebda84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * udmabuf helper functions.
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 */
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "ui/console.h"

#ifdef CONFIG_LINUX

#include <fcntl.h>
#include <sys/ioctl.h>

int udmabuf_fd(void)
{
    static bool first = true;
    static int udmabuf;

    if (!first) {
        return udmabuf;
    }
    first = false;

    udmabuf = open("/dev/udmabuf", O_RDWR);
    if (udmabuf < 0) {
        warn_report("open /dev/udmabuf: %s", strerror(errno));
    }
    return udmabuf;
}

#else

int udmabuf_fd(void)
{
    return -1;
}

#endif