summaryrefslogtreecommitdiff
path: root/lib/intel_chipset.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2014-03-22 14:54:28 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-03-22 14:54:28 +0100
commitaed95c390ae834a1661fb1e4ec433177b1c01fcc (patch)
tree87fd16b091b495b4eb353160f6b8c4000312085b /lib/intel_chipset.c
parent94e1b6af99b3548014686a0943bb286e3c81a889 (diff)
lib: consolidate chipset helpers in intel_chipset.[hc]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'lib/intel_chipset.c')
-rw-r--r--lib/intel_chipset.c45
1 files changed, 44 insertions, 1 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)
{