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
41
42
43
44
45
46
|
#include "config.h"
#include <glib.h>
#include <gio/gio.h>
#include "xapp-util.h"
#define PRIME_SUPPORTED_TEST_FILE "/var/lib/ubuntu-drivers-common/requires_offloading"
#define PRIME_MODE_FILE "/etc/prime-discrete"
/**
* xapp_util_gpu_offload_supported:
*
* Performs a check to see if on-demand mode for discrete graphics
* is supported.
*
* Returns: %TRUE if supported.
*
* Since: 1.8
*/
gboolean
xapp_util_gpu_offload_supported (void)
{
g_autoptr(GFile) modefile = NULL;
g_autofree gchar *contents = NULL;
if (!g_file_test (PRIME_SUPPORTED_TEST_FILE, G_FILE_TEST_EXISTS))
{
return FALSE;
}
modefile = g_file_new_for_path (PRIME_MODE_FILE);
if (!g_file_load_contents (modefile,
NULL,
&contents,
NULL,
NULL,
NULL))
{
return FALSE;
}
return g_strstr_len (contents, -1, "on-demand") != NULL;
}
|