ui: Get the fd associated with udmabuf driver
Try to open the udmabuf dev node for the first time or return the fd if the device was previously opened. Based-on-patch-by: Gerd Hoffmann <kraxel@redhat.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com> Message-Id: <20210526231429.1045476-2-vivek.kasireddy@intel.com> [ kraxel: fixup fcntl.h include ] Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
ce7015d9e8
commit
87f12216d9
|
@ -471,4 +471,7 @@ bool vnc_display_reload_certs(const char *id, Error **errp);
|
||||||
/* input.c */
|
/* input.c */
|
||||||
int index_from_key(const char *key, size_t key_length);
|
int index_from_key(const char *key, size_t key_length);
|
||||||
|
|
||||||
|
/* udmabuf.c */
|
||||||
|
int udmabuf_fd(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,6 +12,7 @@ softmmu_ss.add(files(
|
||||||
'kbd-state.c',
|
'kbd-state.c',
|
||||||
'keymaps.c',
|
'keymaps.c',
|
||||||
'qemu-pixman.c',
|
'qemu-pixman.c',
|
||||||
|
'udmabuf.c',
|
||||||
))
|
))
|
||||||
softmmu_ss.add([spice_headers, files('spice-module.c')])
|
softmmu_ss.add([spice_headers, files('spice-module.c')])
|
||||||
softmmu_ss.add(when: spice_protocol, if_true: files('vdagent.c'))
|
softmmu_ss.add(when: spice_protocol, if_true: files('vdagent.c'))
|
||||||
|
|
40
ui/udmabuf.c
Normal file
40
ui/udmabuf.c
Normal file
|
@ -0,0 +1,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
|
Loading…
Reference in a new issue