libdrm: Add drm function for KMS checkin that checks if kernel module is loaded.
PATCH 1/1 libdrm: Add drm function for KMS checkin that checks if kernel module is loaded.
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.
--- configure.ac | 2 +- xf86drm.c | 3 ++- xf86drmMode.c | 29 ++++++++++++++++++++++++++++- xf86drmMode.h | 6 ++++++ 4 files changed, 37 insertions(+), 3 deletions(-)
configure.ac +1 -1
@@ -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])
xf86drm.c +2 -1
@@ -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;
xf86drmMode.c +28 -1
@@ -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) {
xf86drmMode.h +6 -0
@@ -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,
Signature · 1 line
1.6.3.3
A message that is not in the archive (sent off-list or not yet received): 1266889447-22995-1-git-send-email-suokkos-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 1/1 kms: Use libdrm function to preload module before checking for KMS.
This prevents ddx from selecting UMS if KMS is enabled but kernel module is not loaded before X.
--- configure.ac | 3 +++ src/radeon_probe.c | 6 ++++++ 2 files changed, 9 insertions(+), 0 deletions(-)
configure.ac +3 -0
@@ -115,6 +115,9 @@ if test "$DRI" != no; then [have_dristruct_h="yes"], [have_dristruct_h="no"],[-]) AC_CHECK_HEADER([damage.h], [have_damage_h="yes"], [have_damage_h="no"],[-]) + + CPPFLAGS="$CPPFLAGS $DRI_LIBS" + AC_CHECK_FUNCS([drmCheckModuleAndModesettingSupported]) CPPFLAGS="$save_CPPFLAGS" fi
src/radeon_probe.c +6 -0
@@ -99,7 +99,13 @@ static Bool radeon_kernel_mode_enabled(ScrnInfoPtr pScrn, struct pci_device *pci } busIdString =DRICreatePCIBusID (pci_dev); + +#ifdef HAVE_DRMCHECKMODULEANDMODESETTINGSUPPORTED + ret =drmCheckModuleAndModesettingSupported (RADEON_DRIVER_NAME , busIdString); +#else +#warning "libdrm doesn't support module loading in KMS check. You should upgrade libdrm to 2.4.19." ret =drmCheckModesettingSupported (busIdString); +#endif xfree (busIdString);if (ret) { xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0,
Signature · 1 line
1.6.3.3