summaryrefslogtreecommitdiff
path: root/src/intel_module.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-06-22 17:30:02 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-06-23 07:33:56 +0100
commit7ec0378b64e88923ba1c4eba043488685aa3a795 (patch)
tree1d11f3c1bbc292083fb2f8fd86c40d40fe21d921 /src/intel_module.c
parent41badce186fe0f6e8f49e30b6c1c251027161e35 (diff)
sna: Only open the /dev/dri/cardX device once
Merge the device open in the main driver with the probing so that we can open the path explicitly passed in by the PlatformProbe and keep that fd around for the main driver and so avoid a later search. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/intel_module.c')
-rw-r--r--src/intel_module.c66
1 files changed, 27 insertions, 39 deletions
diff --git a/src/intel_module.c b/src/intel_module.c
index c1d0e099..45de1ef6 100644
--- a/src/intel_module.c
+++ b/src/intel_module.c
@@ -29,7 +29,6 @@
#endif
#include <unistd.h>
-#include <xf86_OSproc.h>
#include <xf86Parser.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
@@ -435,49 +434,37 @@ static Bool intel_driver_func(ScrnInfoPtr pScrn,
}
}
-static Bool has_kernel_mode_setting(const struct pci_device *dev)
+static Bool has_kernel_mode_setting(int entity_num,
+ const struct pci_device *dev,
+ const char *path)
{
- char id[20];
+ drmVersionPtr version;
int ret, fd;
- snprintf(id, sizeof(id),
- "pci:%04x:%02x:%02x.%d",
- dev->domain, dev->bus, dev->dev, dev->func);
-
- ret = drmCheckModesettingSupported(id);
- if (ret) {
- if (xf86LoadKernelModule("i915"))
- ret = drmCheckModesettingSupported(id);
- if (ret)
- return FALSE;
- /* Be nice to the user and load fbcon too */
- (void)xf86LoadKernelModule("fbcon");
- }
+ fd = intel_open_device(entity_num, dev, path);
+ if (fd == -1)
+ return FALSE;
/* Confirm that this is a i915.ko device with GEM/KMS enabled */
ret = FALSE;
- fd = drmOpen(NULL, id);
- if (fd != -1) {
- drmVersionPtr version = drmGetVersion(fd);
- if (version) {
- ret = strcmp ("i915", version->name) == 0;
- drmFreeVersion(version);
- }
- if (ret) {
- struct drm_i915_getparam gp;
- gp.param = I915_PARAM_HAS_GEM;
- gp.value = &ret;
- if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
- ret = FALSE;
- }
- if (ret) {
- struct drm_mode_card_res res;
+ version = drmGetVersion(fd);
+ if (version) {
+ ret = strcmp ("i915", version->name) == 0;
+ drmFreeVersion(version);
+ }
+ if (ret) {
+ struct drm_i915_getparam gp;
+ gp.param = I915_PARAM_HAS_GEM;
+ gp.value = &ret;
+ if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
+ ret = FALSE;
+ }
+ if (ret) {
+ struct drm_mode_card_res res;
- memset(&res, 0, sizeof(res));
- if (drmIoctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res))
- ret = FALSE;
- }
- close(fd);
+ memset(&res, 0, sizeof(res));
+ if (drmIoctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res))
+ ret = FALSE;
}
return ret;
@@ -578,7 +565,7 @@ static Bool intel_pci_probe(DriverPtr driver,
struct pci_device *device,
intptr_t match_data)
{
- if (!has_kernel_mode_setting(device)) {
+ if (!has_kernel_mode_setting(entity_num, device, NULL)) {
#if KMS_ONLY
return FALSE;
#else
@@ -609,7 +596,8 @@ intel_platform_probe(DriverPtr driver,
if (!dev->pdev)
return FALSE;
- if (!has_kernel_mode_setting(dev->pdev))
+ if (!has_kernel_mode_setting(entity_num, dev->pdev,
+ xf86_get_platform_device_attrib(dev, ODEV_ATTRIB_PATH)))
return FALSE;
/* Allow ourselves to act as a slaved output if not primary */