2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-02-28 19:09:48 +08:00
|
|
|
* Copyright (c) 2017 - 2018, Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "igfxfmid.h"
|
|
|
|
#include "runtime/utilities/api_intercept.h"
|
|
|
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <cerrno>
|
|
|
|
#include <string>
|
|
|
|
|
2018-02-05 15:54:46 +08:00
|
|
|
struct GT_SYSTEM_INFO;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
namespace OCLRT {
|
|
|
|
#define I915_CONTEXT_PRIVATE_PARAM_BOOST 0x80000000
|
|
|
|
|
|
|
|
class DeviceFactory;
|
2018-02-05 15:54:46 +08:00
|
|
|
struct HardwareInfo;
|
2018-08-27 18:11:07 +08:00
|
|
|
struct FeatureTable;
|
2018-02-05 15:54:46 +08:00
|
|
|
|
|
|
|
struct DeviceDescriptor {
|
|
|
|
unsigned short deviceId;
|
|
|
|
const HardwareInfo *pHwInfo;
|
2018-08-27 18:11:07 +08:00
|
|
|
void (*setupHardwareInfo)(GT_SYSTEM_INFO *, FeatureTable *, bool);
|
2018-02-05 15:54:46 +08:00
|
|
|
GTTYPE eGtType;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const DeviceDescriptor deviceDescriptorTable[];
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
class Drm {
|
|
|
|
friend DeviceFactory;
|
|
|
|
|
|
|
|
public:
|
|
|
|
uint32_t lowPriorityContextId;
|
|
|
|
static Drm *get(int32_t deviceOrdinal);
|
|
|
|
|
|
|
|
virtual int ioctl(unsigned long request, void *arg);
|
|
|
|
|
|
|
|
int getDeviceID(int &devId);
|
|
|
|
int getDeviceRevID(int &revId);
|
|
|
|
int getExecSoftPin(int &execSoftPin);
|
|
|
|
int enableTurboBoost();
|
|
|
|
int getEuTotal(int &euTotal);
|
|
|
|
int getSubsliceTotal(int &subsliceTotal);
|
|
|
|
|
|
|
|
int getMaxGpuFrequency(int &maxGpuFrequency);
|
|
|
|
int getEnabledPooledEu(int &enabled);
|
|
|
|
int getMinEuInPool(int &minEUinPool);
|
|
|
|
|
|
|
|
bool is48BitAddressRangeSupported();
|
|
|
|
MOCKABLE_VIRTUAL bool hasPreemption();
|
|
|
|
bool setLowPriority();
|
|
|
|
int getFileDescriptor() const { return fd; }
|
|
|
|
bool contextCreate();
|
|
|
|
void contextDestroy();
|
|
|
|
|
|
|
|
void setGtType(GTTYPE eGtType) { this->eGtType = eGtType; }
|
|
|
|
GTTYPE getGtType() const { return this->eGtType; }
|
2018-02-28 19:09:48 +08:00
|
|
|
MOCKABLE_VIRTUAL int getErrno();
|
2018-07-27 19:59:39 +08:00
|
|
|
void setSimplifiedMocsTableUsage(bool value);
|
|
|
|
bool getSimplifiedMocsTableUsage() const;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
protected:
|
2018-07-27 19:59:39 +08:00
|
|
|
bool useSimplifiedMocsTable = false;
|
2017-12-21 07:45:38 +08:00
|
|
|
int fd;
|
|
|
|
int deviceId;
|
|
|
|
int revisionId;
|
|
|
|
GTTYPE eGtType;
|
|
|
|
Drm(int fd) : lowPriorityContextId(0), fd(fd), deviceId(0), revisionId(0), eGtType(GTTYPE_UNDEFINED) {}
|
|
|
|
virtual ~Drm();
|
|
|
|
|
|
|
|
static bool isi915Version(int fd);
|
|
|
|
static int getDeviceFd(const int devType);
|
|
|
|
static int openDevice();
|
|
|
|
static Drm *create(int32_t deviceOrdinal);
|
|
|
|
static void closeDevice(int32_t deviceOrdinal);
|
|
|
|
|
|
|
|
std::string getSysFsPciPath(int deviceID);
|
|
|
|
|
|
|
|
#pragma pack(1)
|
|
|
|
struct PCIConfig {
|
|
|
|
uint16_t VendorID;
|
|
|
|
uint16_t DeviceID;
|
|
|
|
uint16_t Command;
|
|
|
|
uint16_t Status;
|
|
|
|
uint8_t Revision;
|
|
|
|
uint8_t ProgIF;
|
|
|
|
uint8_t Subclass;
|
|
|
|
uint8_t ClassCode;
|
|
|
|
uint8_t cacheLineSize;
|
|
|
|
uint8_t LatencyTimer;
|
|
|
|
uint8_t HeaderType;
|
|
|
|
uint8_t BIST;
|
|
|
|
uint32_t BAR0[6];
|
|
|
|
uint32_t CardbusCISPointer;
|
|
|
|
uint16_t SubsystemVendorID;
|
|
|
|
uint16_t SubsystemDeviceID;
|
|
|
|
uint32_t ROM;
|
|
|
|
uint8_t Capabilities;
|
|
|
|
uint8_t Reserved[7];
|
|
|
|
uint8_t InterruptLine;
|
|
|
|
uint8_t InterruptPIN;
|
|
|
|
uint8_t MinGrant;
|
|
|
|
uint8_t MaxLatency;
|
|
|
|
};
|
|
|
|
#pragma pack()
|
|
|
|
static const char *sysFsDefaultGpuPath;
|
|
|
|
static const char *maxGpuFrequencyFile;
|
|
|
|
static const char *configFileName;
|
2018-03-12 19:03:20 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
int getParamIoctl(int param, int *dstValue);
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
} // namespace OCLRT
|