Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
acec9987
Commit
acec9987
authored
Sep 24, 2015
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5363 from avershov:opencl-vaapi-detect
parents
e5ece03d
5feca50f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
58 deletions
+26
-58
OpenCVFindVA.cmake
cmake/OpenCVFindVA.cmake
+1
-1
display.cpp.inc
samples/va_intel/display.cpp.inc
+25
-57
va_intel_interop.cpp
samples/va_intel/va_intel_interop.cpp
+0
-0
No files found.
cmake/OpenCVFindVA.cmake
View file @
acec9987
...
...
@@ -12,7 +12,7 @@ endif()
if
(
VA_INCLUDE_DIR
)
set
(
HAVE_VA TRUE
)
set
(
VA_LIBRARIES
"-lva"
"-lva-
x11
"
)
set
(
VA_LIBRARIES
"-lva"
"-lva-
drm
"
)
else
()
set
(
HAVE_VA FALSE
)
message
(
WARNING
"libva installation is not found."
)
...
...
samples/va_intel/display.cpp.inc
View file @
acec9987
...
...
@@ -10,27 +10,16 @@
#include "cvconfig.h"
#include <va/va.h>
#if defined(HAVE_VA_INTEL)
# include <va/va_drm.h>
#elif defined(HAVE_VA)
# include <va/va_x11.h>
# include <X11/Xlib.h>
#endif //HAVE_VA_INTEL / HAVE_VA
namespace
va
{
#if defined(HAVE_VA_INTEL) || defined(HAVE_VA)
bool
openDisplay
();
void
closeDisplay
();
VADisplay
display
=
NULL
;
bool
initialized
=
false
;
#endif //HAVE_VA_INTEL || HAVE_VA
#if defined(HAVE_VA_INTEL)
#define VA_INTEL_PCI_DIR "/sys/bus/pci/devices"
#define VA_INTEL_DRI_DIR "/dev/dri/"
#define VA_INTEL_PCI_DISPLAY_CONTROLLER_CLASS 0x03
...
...
@@ -161,15 +150,13 @@ private:
char
*
paths
[
NUM_NODES
];
};
bool
openDisplay
()
static
bool
openDeviceIntel
();
static
bool
openDeviceGeneric
();
static
bool
openDeviceIntel
()
{
if
(
!
initialized
)
{
const
unsigned
IntelVendorID
=
0x8086
;
drmfd
=
-
1
;
display
=
0
;
int
adapterIndex
=
findAdapter
(
IntelVendorID
);
if
(
adapterIndex
>=
0
)
{
...
...
@@ -182,58 +169,43 @@ bool openDisplay()
{
display
=
vaGetDisplayDRM
(
drmfd
);
if
(
display
)
{
int
majorVersion
=
0
,
minorVersion
=
0
;
if
(
vaInitialize
(
display
,
&
majorVersion
,
&
minorVersion
)
==
VA_STATUS_SUCCESS
)
{
initialized
=
true
;
return
true
;
}
display
=
0
;
}
close
(
drmfd
);
drmfd
=
-
1
;
}
}
}
if
(
adapterIndex
<
0
)
return
false
;
// Can't find Intel display adapter
if
((
drmfd
<
0
)
||
!
display
)
return
false
;
// Can't load VA display
}
return
true
;
return
false
;
}
void
closeDisplay
()
static
bool
openDeviceGeneric
()
{
if
(
initialized
)
static
const
char
*
device_paths
[]
=
{
"/dev/dri/renderD128"
,
"/dev/dri/card0"
};
static
const
int
num_devices
=
sizeof
(
device_paths
)
/
sizeof
(
device_paths
[
0
]);
for
(
int
i
=
0
;
i
<
num_devices
;
++
i
)
{
if
(
display
)
vaTerminate
(
display
);
drmfd
=
open
(
device_paths
[
i
],
O_RDWR
);
if
(
drmfd
>=
0
)
{
display
=
vaGetDisplayDRM
(
drmfd
);
if
(
display
)
return
true
;
close
(
drmfd
);
display
=
0
;
drmfd
=
-
1
;
initialized
=
false
;
}
}
return
false
;
}
#elif defined(HAVE_VA)
static
Display
*
x11Display
=
0
;
bool
openDisplay
()
{
if
(
!
initialized
)
{
drmfd
=
-
1
;
display
=
0
;
x11Display
=
XOpenDisplay
(
""
);
if
(
x11Display
!=
0
)
{
display
=
vaGetDisplay
(
x11Display
);
if
(
display
)
if
(
openDeviceIntel
()
||
openDeviceGeneric
())
{
int
majorVersion
=
0
,
minorVersion
=
0
;
if
(
vaInitialize
(
display
,
&
majorVersion
,
&
minorVersion
)
==
VA_STATUS_SUCCESS
)
...
...
@@ -241,13 +213,11 @@ bool openDisplay()
initialized
=
true
;
return
true
;
}
close
(
drmfd
);
display
=
0
;
drmfd
=
-
1
;
}
XCloseDisplay
(
x11Display
);
x11Display
=
0
;
}
return
false
;
// Can't initialize X11/VA display
return
false
;
// Can't open VA display
}
return
true
;
}
...
...
@@ -258,14 +228,12 @@ void closeDisplay()
{
if
(
display
)
vaTerminate
(
display
);
if
(
x11Display
)
XCloseDisplay
(
x11Display
);
if
(
drmfd
>=
0
)
close
(
drmfd
);
display
=
0
;
x11Display
=
0
;
drmfd
=
-
1
;
initialized
=
false
;
}
}
#endif // HAVE_VA_INTEL / HAVE_VA
}
// namespace va
samples/va_intel/va_intel_interop.cpp
View file @
acec9987
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment