mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-11 18:06:13 +00:00
lib: consolidate chipset helpers in intel_chipset.[hc]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
94e1b6af99
commit
aed95c390a
@ -36,8 +36,9 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include "i915_drm.h"
|
||||||
|
|
||||||
#include "intel_gpu_tools.h"
|
#include "intel_chipset.h"
|
||||||
|
|
||||||
enum pch_type pch;
|
enum pch_type pch;
|
||||||
|
|
||||||
@ -91,6 +92,48 @@ intel_get_pci_device(void)
|
|||||||
return pci_dev;
|
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
|
void
|
||||||
intel_check_pch(void)
|
intel_check_pch(void)
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,27 @@
|
|||||||
#ifndef _INTEL_CHIPSET_H
|
#ifndef _INTEL_CHIPSET_H
|
||||||
#define _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 0x7121
|
||||||
#define PCI_CHIP_I810_DC100 0x7123
|
#define PCI_CHIP_I810_DC100 0x7123
|
||||||
#define PCI_CHIP_I810_E 0x7125
|
#define PCI_CHIP_I810_E 0x7125
|
||||||
|
@ -50,48 +50,6 @@
|
|||||||
#include "intel_gpu_tools.h"
|
#include "intel_gpu_tools.h"
|
||||||
#include "i915_drm.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
|
uint64_t
|
||||||
intel_get_total_ram_mb(void)
|
intel_get_total_ram_mb(void)
|
||||||
{
|
{
|
||||||
|
@ -100,27 +100,9 @@ OUTREG(uint32_t reg, uint32_t val)
|
|||||||
*(volatile uint32_t *)((volatile char *)mmio + reg) = 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_ram_mb(void);
|
||||||
uint64_t intel_get_total_swap_mb(void);
|
uint64_t intel_get_total_swap_mb(void);
|
||||||
|
|
||||||
void intel_map_file(char *);
|
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 */
|
#endif /* INTEL_GPU_TOOLS_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user