From 9a7df7a85d0de02bb5b8266c3fbd75580230a967 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Thu, 18 Feb 2021 17:19:47 +0300 Subject: [PATCH] VA sample: device autodetection changed --- samples/va_intel/display.cpp.inc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/samples/va_intel/display.cpp.inc b/samples/va_intel/display.cpp.inc index 6fd3e0cbf0..ecfa0324a2 100644 --- a/samples/va_intel/display.cpp.inc +++ b/samples/va_intel/display.cpp.inc @@ -87,7 +87,6 @@ static unsigned readId(const char* devName, const char* idName) static int findAdapter(unsigned desiredVendorId) { int adapterIndex = -1; - int numAdapters = 0; Directory dir(VA_INTEL_PCI_DIR); @@ -101,10 +100,18 @@ static int findAdapter(unsigned desiredVendorId) unsigned vendorId = readId(name, "vendor"); if (vendorId == desiredVendorId) { - adapterIndex = numAdapters; + char subdirName[256]; + snprintf(subdirName, sizeof(subdirName), "%s/%s/%s", VA_INTEL_PCI_DIR, name, "drm"); + Directory subdir(subdirName); + for (int j = 0; j < subdir.count(); ++j) + { + if (!strncmp(subdir[j]->d_name, "card", 4)) + { + adapterIndex = strtoul(subdir[j]->d_name + 4, NULL, 10); + } + } break; } - ++numAdapters; } }