Skip to content

Commit 9a7df7a

Browse files
committed
VA sample: device autodetection changed
1 parent 0aca3fb commit 9a7df7a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

samples/va_intel/display.cpp.inc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ static unsigned readId(const char* devName, const char* idName)
8787
static int findAdapter(unsigned desiredVendorId)
8888
{
8989
int adapterIndex = -1;
90-
int numAdapters = 0;
9190

9291
Directory dir(VA_INTEL_PCI_DIR);
9392

@@ -101,10 +100,18 @@ static int findAdapter(unsigned desiredVendorId)
101100
unsigned vendorId = readId(name, "vendor");
102101
if (vendorId == desiredVendorId)
103102
{
104-
adapterIndex = numAdapters;
103+
char subdirName[256];
104+
snprintf(subdirName, sizeof(subdirName), "%s/%s/%s", VA_INTEL_PCI_DIR, name, "drm");
105+
Directory subdir(subdirName);
106+
for (int j = 0; j < subdir.count(); ++j)
107+
{
108+
if (!strncmp(subdir[j]->d_name, "card", 4))
109+
{
110+
adapterIndex = strtoul(subdir[j]->d_name + 4, NULL, 10);
111+
}
112+
}
105113
break;
106114
}
107-
++numAdapters;
108115
}
109116
}
110117

0 commit comments

Comments
 (0)