lib: consolidate chipset helpers in intel_chipset.[hc]
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Sat, 22 Mar 2014 13:54:28 +0000 (14:54 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Sat, 22 Mar 2014 13:54:28 +0000 (14:54 +0100)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/intel_chipset.c
lib/intel_chipset.h
lib/intel_drm.c
lib/intel_gpu_tools.h

index e60e0d3..e5d2b5b 100644 (file)
@@ -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)
 {
index 7ce0900..f50056f 100644 (file)
 #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
index f16e578..ce4dcbc 100644 (file)
 #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)
 {
index 1ae1bab..37cbcb1 100644 (file)
@@ -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 */