Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

Commit a57a48b

Browse files
committed
Add a API for querying GVT active from kernel
Add a API for querying if GVT is active in kernel via the IOCTL GETPARAM Tests: Work well for both GVT-d and GVT-g Tracked-On: OAM-91485 Signed-off-by: Shaofeng Tang <shaofeng.tang@intel.com>
1 parent d3505e4 commit a57a48b

6 files changed

Lines changed: 97 additions & 3 deletions

File tree

include/drm/i915_drm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,8 @@ typedef struct drm_i915_irq_wait {
564564
*/
565565
#define I915_PARAM_CS_TIMESTAMP_FREQUENCY 51
566566

567+
#define I915_PARAM_IS_GVT 55
568+
567569
/*
568570
* Once upon a time we supposed that writes through the GGTT would be
569571
* immediately in physical memory (once flushed out of the CPU path). However,

intel/Android.sources.bp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ cc_defaults {
99
"intel_decode.c",
1010
"intel_chipset.c",
1111
"mm.c",
12+
"intel_gvt.c",
1213
],
1314
}

intel/Makefile.sources

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ LIBDRM_INTEL_FILES := \
77
intel_decode.c \
88
intel_chipset.h \
99
intel_chipset.c \
10+
intel_gvt.c \
1011
mm.c \
1112
mm.h \
1213
uthash.h
1314

1415
LIBDRM_INTEL_H_FILES := \
1516
intel_bufmgr.h \
1617
intel_aub.h \
17-
intel_debug.h
18+
intel_debug.h \
19+
intel_gvt.h

intel/intel_gvt.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright © 2007 Intel Corporation
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice (including the next
12+
* paragraph) shall be included in all copies or substantial portions of the
13+
* Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21+
* IN THE SOFTWARE.
22+
*
23+
* Authors:
24+
* Tang Shaofeng <shaofeng.tang@intel.com>
25+
*
26+
*/
27+
28+
#include <sys/ioctl.h>
29+
#include <sys/stat.h>
30+
#include <sys/types.h>
31+
#include <string.h>
32+
#include <errno.h>
33+
34+
#include "i915_drm.h"
35+
#include "intel_gvt.h"
36+
37+
int drm_intel_get_gvt_active(int fd, int *active)
38+
{
39+
drm_i915_getparam_t gp;
40+
int ret;
41+
42+
memset(&gp, 0, sizeof(gp));
43+
gp.value = (int*)active;
44+
gp.param = I915_PARAM_IS_GVT;
45+
do {
46+
ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
47+
} while (ret == -1 && (errno == EINTR || errno == EAGAIN));
48+
return ret;
49+
}

intel/intel_gvt.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright © 2011 Intel Corporation
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice (including the next
12+
* paragraph) shall be included in all copies or substantial portions of the
13+
* Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21+
* IN THE SOFTWARE.
22+
*
23+
* Authors:
24+
* Tang, Shaofeng <shaofeng.tang@intel.com>
25+
*
26+
*/
27+
28+
#ifndef INTEL_GVT_H
29+
#define INTEL_GVT_H
30+
31+
#include <stdint.h>
32+
#if defined(__cplusplus)
33+
extern "C" {
34+
#endif
35+
int drm_intel_get_gvt_active(int fd, int *active);
36+
37+
#if defined(__cplusplus)
38+
}
39+
#endif
40+
#endif /* INTEL_GVT_H */

intel/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ libdrm_intel = shared_library(
2323
[
2424
files(
2525
'intel_bufmgr.c', 'intel_bufmgr_fake.c', 'intel_bufmgr_gem.c',
26-
'intel_decode.c', 'mm.c', 'intel_chipset.c',
26+
'intel_decode.c', 'mm.c', 'intel_chipset.c', 'intel_gvt.c',
2727
),
2828
config_file,
2929
],
@@ -41,7 +41,7 @@ ext_libdrm_intel = declare_dependency(
4141
)
4242

4343
install_headers(
44-
'intel_bufmgr.h', 'intel_aub.h', 'intel_debug.h',
44+
'intel_bufmgr.h', 'intel_aub.h', 'intel_debug.h', 'intel_gvt.h',
4545
subdir : 'libdrm',
4646
)
4747

0 commit comments

Comments
 (0)