drmCheckModesettingSupported did erronously report that
kernel doesn't have modesetting support if kernel module
wasn't preloaded.

To make KMS checking load kernel module before retring
drmCheckModuleAndModesettingSupported takes module_name
as parameter. If drm module isn't loaded drm tries to
load the module.

drmCheckModesettingSupported is now deprecated.

Version bump is also required for the interface change.

Signed-off-by: Pauli Nieminen <[email protected]>
---
 configure.ac  |    2 +-
 xf86drm.c     |    3 ++-
 xf86drmMode.c |   29 ++++++++++++++++++++++++++++-
 xf86drmMode.h |    6 ++++++
 4 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index ef7700f..e279885 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,7 +19,7 @@
 #  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 AC_PREREQ(2.60)
-AC_INIT([libdrm], 2.4.18, [[email protected]], libdrm)
+AC_INIT([libdrm], 2.4.19, [[email protected]], libdrm)
 AC_USE_SYSTEM_EXTENSIONS
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2])
diff --git a/xf86drm.c b/xf86drm.c
index 220aaa1..b3b426f 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -797,9 +797,10 @@ drmVersionPtr drmGetLibVersion(int fd)
      *   revision 1.2.x = added drmSetInterfaceVersion
      *                    modified drmOpen to handle both busid and name
      *   revision 1.3.x = added server + memory manager
+     *   revision 1.4.x = added drmCheckModuleAndModesettingSupported
      */
     version->version_major      = 1;
-    version->version_minor      = 3;
+    version->version_minor      = 4;
     version->version_patchlevel = 0;
 
     return (drmVersionPtr)version;
diff --git a/xf86drmMode.c b/xf86drmMode.c
index f330e6f..e4f363f 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -655,7 +655,8 @@ int drmModeConnectorSetProperty(int fd, uint32_t 
connector_id, uint32_t property
  *  -EINVAL or invalid bus id
  *  -ENOSYS if no modesetting support
 */
-int drmCheckModesettingSupported(const char *busid)
+int drmCheckModuleAndModesettingSupported(const char *module_name,
+               const char *busid)
 {
 #ifdef __linux__
        char pci_dev_dir[1024];
@@ -664,6 +665,28 @@ int drmCheckModesettingSupported(const char *busid)
        struct dirent *dent;
        int found = 0, ret;
 
+       if (module_name) {
+               /* Check that kernel module is loaded */
+               /* If first try fails try again soon after */
+               int retries = 1;
+               int fd;
+               do {
+                       fd = drmOpen( module_name, busid );
+                       if (fd != -1)
+                               break;
+                       if (!retries--)
+                               break;
+                       usleep(100000);
+               } while (1);
+
+               if (fd == -1)
+                       return -ENOSYS;
+
+               drmClose(fd);
+       } else {
+               drmMsg("[drm] Checking for kernel modesetting without 
module_name is deprecated.\n");
+       }
+
        ret = sscanf(busid, "pci:%04x:%02x:%02x.%d", &domain, &bus, &dev, 
&func);
        if (ret != 4)
                return -EINVAL;
@@ -712,6 +735,10 @@ int drmCheckModesettingSupported(const char *busid)
 
 }
 
+int drmCheckModesettingSupported(const char *busid)
+{
+       return drmCheckModuleAndModesettingSupported(NULL, busid);
+}
 int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
                        uint16_t *red, uint16_t *green, uint16_t *blue)
 {
diff --git a/xf86drmMode.h b/xf86drmMode.h
index 44d90ed..6c81ed6 100644
--- a/xf86drmMode.h
+++ b/xf86drmMode.h
@@ -378,6 +378,12 @@ extern drmModePropertyBlobPtr drmModeGetPropertyBlob(int 
fd, uint32_t blob_id);
 extern void drmModeFreePropertyBlob(drmModePropertyBlobPtr ptr);
 extern int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t 
property_id,
                                    uint64_t value);
+
+extern int drmCheckModuleAndModesettingSupported(const char *module_name,
+               const char *busid);
+/**
+ * Deprecated because of possible bugs that kernel module is not loaded early
+ */
 extern int drmCheckModesettingSupported(const char *busid);
 
 extern int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size,
-- 
1.6.3.3


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to