mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-06 02:18:05 +08:00
Return proper clDevice for given media adapter
Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
64d772d366
commit
edf066a54b
@@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/os_interface/linux/sys_calls.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
@@ -12,7 +13,11 @@
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <system_error>
|
||||
|
||||
namespace NEO {
|
||||
namespace SysCalls {
|
||||
@@ -20,6 +25,8 @@ uint32_t closeFuncCalled = 0u;
|
||||
int closeFuncArgPassed = 0;
|
||||
constexpr int fakeFileDescriptor = 123;
|
||||
uint32_t vmId = 0;
|
||||
bool makeFakeDevicePath = false;
|
||||
bool allowFakeDevicePath = false;
|
||||
|
||||
int close(int fileDescriptor) {
|
||||
closeFuncCalled++;
|
||||
@@ -55,5 +62,35 @@ int ioctl(int fileDescriptor, unsigned long int request, void *arg) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int access(const char *pathName, int mode) {
|
||||
if (allowFakeDevicePath || strcmp(pathName, "/sys/dev/char/226:128") == 0) {
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int readlink(const char *path, char *buf, size_t bufsize) {
|
||||
if (strcmp(path, "/sys/dev/char/226:128") != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
constexpr size_t sizeofPath = sizeof("../../devices/pci0000:00/0000:00:02.0/drm/renderD128");
|
||||
|
||||
strcpy_s(buf, sizeofPath, "../../devices/pci0000:00/0000:00:02.0/drm/renderD128");
|
||||
return sizeofPath;
|
||||
}
|
||||
|
||||
int getDevicePath(int deviceFd, char *buf, size_t &bufSize) {
|
||||
if (deviceFd <= 0) {
|
||||
return -1;
|
||||
}
|
||||
constexpr size_t sizeofPath = sizeof("/sys/dev/char/226:128");
|
||||
|
||||
makeFakeDevicePath ? strcpy_s(buf, sizeofPath, "/sys/dev/char/xyzwerq") : strcpy_s(buf, sizeofPath, "/sys/dev/char/226:128");
|
||||
bufSize = sizeofPath;
|
||||
|
||||
return 0;
|
||||
}
|
||||
} // namespace SysCalls
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user