summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/intel_chipset.c45
-rw-r--r--lib/intel_chipset.h21
-rw-r--r--lib/intel_drm.c42
-rw-r--r--lib/intel_gpu_tools.h18
4 files changed, 65 insertions, 61 deletions
diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
index e60e0d32..e5d2b5bd 100644
--- a/lib/intel_chipset.c
+++ b/lib/intel_chipset.c
@@ -36,8 +36,9 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
+#include "i915_drm.h"
-#include "intel_gpu_tools.h"
+#include "intel_chipset.h"
enum pch_type pch;
@@ -91,6 +92,48 @@ intel_get_pci_device(void)
return pci_dev;
}
+uint32_t
+intel_get_drm_devid(int fd)
+{
+ int ret;
+ struct drm_i915_getparam gp;
+ uint32_t devid;
+ char *override;
+
+ override = getenv("INTEL_DEVID_OVERRIDE");
+ if (override) {
+ devid = strtod(override, NULL);
+ } else {
+ gp.param = I915_PARAM_CHIPSET_ID;
+ gp.value = (int *)&devid;
+
+ ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+ assert(ret == 0);
+ }
+
+ return devid;
+}
+
+int intel_gen(uint32_t devid)
+{
+ if (IS_GEN2(devid))
+ return 2;
+ if (IS_GEN3(devid))
+ return 3;
+ if (IS_GEN4(devid))
+ return 4;
+ if (IS_GEN5(devid))
+ return 5;
+ if (IS_GEN6(devid))
+ return 6;
+ if (IS_GEN7(devid))
+ return 7;
+ if (IS_GEN8(devid))
+ return 8;
+
+ return -1;
+}
+
void
intel_check_pch(void)
{
diff --git a/lib/intel_chipset.h b/lib/intel_chipset.h
index 7ce09008..f50056f2 100644
--- a/lib/intel_chipset.h
+++ b/lib/intel_chipset.h
@@ -28,6 +28,27 @@
#ifndef _INTEL_CHIPSET_H
#define _INTEL_CHIPSET_H
+#include <sys/types.h>
+#include <pciaccess.h>
+
+struct pci_device *intel_get_pci_device(void);
+uint32_t intel_get_drm_devid(int fd);
+int intel_gen(uint32_t devid);
+
+extern enum pch_type pch;
+enum pch_type {
+ PCH_NONE,
+ PCH_IBX,
+ PCH_CPT,
+ PCH_LPT,
+};
+
+void intel_check_pch(void);
+
+#define HAS_IBX (pch == PCH_IBX)
+#define HAS_CPT (pch == PCH_CPT)
+#define HAS_LPT (pch == PCH_LPT)
+
#define PCI_CHIP_I810 0x7121
#define PCI_CHIP_I810_DC100 0x7123
#define PCI_CHIP_I810_E 0x7125
diff --git a/lib/intel_drm.c b/lib/intel_drm.c
index f16e5784..ce4dcbca 100644
--- a/lib/intel_drm.c
+++ b/lib/intel_drm.c
@@ -50,48 +50,6 @@
#include "intel_gpu_tools.h"
#include "i915_drm.h"
-uint32_t
-intel_get_drm_devid(int fd)
-{
- int ret;
- struct drm_i915_getparam gp;
- uint32_t devid;
- char *override;
-
- override = getenv("INTEL_DEVID_OVERRIDE");
- if (override) {
- devid = strtod(override, NULL);
- } else {
- gp.param = I915_PARAM_CHIPSET_ID;
- gp.value = (int *)&devid;
-
- ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
- assert(ret == 0);
- }
-
- return devid;
-}
-
-int intel_gen(uint32_t devid)
-{
- if (IS_GEN2(devid))
- return 2;
- if (IS_GEN3(devid))
- return 3;
- if (IS_GEN4(devid))
- return 4;
- if (IS_GEN5(devid))
- return 5;
- if (IS_GEN6(devid))
- return 6;
- if (IS_GEN7(devid))
- return 7;
- if (IS_GEN8(devid))
- return 8;
-
- return -1;
-}
-
uint64_t
intel_get_total_ram_mb(void)
{
diff --git a/lib/intel_gpu_tools.h b/lib/intel_gpu_tools.h
index 1ae1bab0..37cbcb19 100644
--- a/lib/intel_gpu_tools.h
+++ b/lib/intel_gpu_tools.h
@@ -100,27 +100,9 @@ OUTREG(uint32_t reg, uint32_t val)
*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
}
-struct pci_device *intel_get_pci_device(void);
-
-uint32_t intel_get_drm_devid(int fd);
-int intel_gen(uint32_t devid);
uint64_t intel_get_total_ram_mb(void);
uint64_t intel_get_total_swap_mb(void);
void intel_map_file(char *);
-enum pch_type {
- PCH_NONE,
- PCH_IBX,
- PCH_CPT,
- PCH_LPT,
-};
-
-extern enum pch_type pch;
-void intel_check_pch(void);
-
-#define HAS_IBX (pch == PCH_IBX)
-#define HAS_CPT (pch == PCH_CPT)
-#define HAS_LPT (pch == PCH_LPT)
-
#endif /* INTEL_GPU_TOOLS_H */