From patchwork Tue Feb 23 01:44:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Nieminen X-Patchwork-Id: 81378 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1N31u2J027405 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 23 Feb 2010 03:02:32 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Njl0E-0007tl-MH; Tue, 23 Feb 2010 03:00:02 +0000 Received: from sfi-mx-1.v28.ch3.sourceforge.com ([172.29.28.121] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Njl0D-0007tc-Kl for dri-devel@lists.sourceforge.net; Tue, 23 Feb 2010 03:00:01 +0000 Received-SPF: neutral (sfi-mx-1.v28.ch3.sourceforge.com: 213.243.153.189 is neither permitted nor denied by domain of gmail.com) client-ip=213.243.153.189; envelope-from=suokkos@gmail.com; helo=filtteri6.pp.htv.fi; Received: from filtteri6.pp.htv.fi ([213.243.153.189]) by sfi-mx-1.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1Njl0C-00081q-08 for dri-devel@lists.sourceforge.net; Tue, 23 Feb 2010 03:00:01 +0000 Received: from localhost (localhost [127.0.0.1]) by filtteri6.pp.htv.fi (Postfix) with ESMTP id 29B6E56E124; Tue, 23 Feb 2010 03:44:36 +0200 (EET) X-Virus-Scanned: Debian amavisd-new at pp.htv.fi Received: from smtp6.welho.com ([213.243.153.40]) by localhost (filtteri6.pp.htv.fi [213.243.153.189]) (amavisd-new, port 10024) with ESMTP id E1sUVTjv4gW1; Tue, 23 Feb 2010 03:44:35 +0200 (EET) Received: from localhost.localdomain (cs181130083.pp.htv.fi [82.181.130.83]) by smtp6.welho.com (Postfix) with ESMTP id 864D85BC002; Tue, 23 Feb 2010 03:44:35 +0200 (EET) From: Pauli Nieminen To: dri-devel@lists.sourceforge.net 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 Message-Id: <1266889447-22995-1-git-send-email-suokkos@gmail.com> X-Mailer: git-send-email 1.6.3.3 X-Spam-Score: 0.8 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 1.2 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) -0.4 AWL AWL: From: address is in the auto white-list X-Headers-End: 1Njl0C-00081q-08 Cc: xorg-driver-ati@lists.x.org X-BeenThere: dri-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 23 Feb 2010 03:02:32 +0000 (UTC) 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@lists.sourceforge.net], libdrm) +AC_INIT([libdrm], 2.4.19, [dri-devel@lists.sourceforge.net], 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,