File: drm_wrappers.cpp

package info (click to toggle)
intel-compute-runtime-legacy 24.35.30872.40-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 73,292 kB
  • sloc: cpp: 826,355; lisp: 3,686; sh: 677; makefile: 148; python: 21
file content (81 lines) | stat: -rw-r--r-- 2,154 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * Copyright (C) 2022-2023 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#include "shared/source/os_interface/linux/drm_wrappers.h"

#include "shared/source/os_interface/linux/i915.h"
#include "shared/source/os_interface/linux/ioctl_helper.h"

#include <cstddef>

namespace NEO {

unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest, IoctlHelper *ioctlHelper) {
    if (ioctlHelper) {
        return ioctlHelper->getIoctlRequestValue(ioctlRequest);
    }
    switch (ioctlRequest) {
    case DrmIoctl::getparam:
        return DRM_IOCTL_I915_GETPARAM;
    case DrmIoctl::version:
        return DRM_IOCTL_VERSION;
    default:
        UNRECOVERABLE_IF(true);
        return 0;
    }
}

bool checkIfIoctlReinvokeRequired(int error, DrmIoctl ioctlRequest, IoctlHelper *ioctlHelper) {
    if (ioctlHelper) {
        return ioctlHelper->checkIfIoctlReinvokeRequired(error, ioctlRequest);
    }
    return (error == EINTR || error == EAGAIN || error == EBUSY || error == -EBUSY);
}

int getDrmParamValue(DrmParam drmParam, IoctlHelper *ioctlHelper) {
    if (ioctlHelper) {
        return ioctlHelper->getDrmParamValue(drmParam);
    }
    switch (drmParam) {
    case DrmParam::paramChipsetId:
        return I915_PARAM_CHIPSET_ID;
    case DrmParam::paramRevision:
        return I915_PARAM_REVISION;
    default:
        UNRECOVERABLE_IF(true);
        return 0;
    }
}

std::string getDrmParamString(DrmParam drmParam, IoctlHelper *ioctlHelper) {
    if (ioctlHelper) {
        return ioctlHelper->getDrmParamString(drmParam);
    }
    switch (drmParam) {
    case DrmParam::paramChipsetId:
        return "I915_PARAM_CHIPSET_ID";
    case DrmParam::paramRevision:
        return "I915_PARAM_REVISION";
    default:
        UNRECOVERABLE_IF(true);
        return "";
    }
}

std::string getIoctlString(DrmIoctl ioctlRequest, IoctlHelper *ioctlHelper) {
    if (ioctlHelper) {
        return ioctlHelper->getIoctlString(ioctlRequest);
    }
    switch (ioctlRequest) {
    case DrmIoctl::getparam:
        return "DRM_IOCTL_I915_GETPARAM";
    default:
        UNRECOVERABLE_IF(true);
        return "";
    }
}
} // namespace NEO