All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pauli Nieminen <suokkos-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: dri-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: xorg-driver-ati-go0+a7rfsptAfugRpC6u6w@public.gmane.org
Subject: [PATCH] libdrm: Add drm function for KMS checkin that checks if kernel module is loaded.
Date: Tue, 23 Feb 2010 03:44:07 +0200	[thread overview]
Message-ID: <1266889447-22995-1-git-send-email-suokkos@gmail.com> (raw)

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 <suokkos-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 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, [dri-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org], libdrm)
+AC_INIT([libdrm], 2.4.19, [dri-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org], 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

             reply	other threads:[~2010-02-23  1:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-23  1:44 Pauli Nieminen [this message]
     [not found] ` <1266889447-22995-1-git-send-email-suokkos-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-02-23  1:47   ` [PATCH] kms: Use libdrm function to preload module before checking for KMS Pauli Nieminen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1266889447-22995-1-git-send-email-suokkos@gmail.com \
    --to=suokkos-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=dri-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=xorg-driver-ati-go0+a7rfsptAfugRpC6u6w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.