Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-libdrm: Commit

external/libdrm


Commit MetaInfo

Révisionaa8425da5a098b45f1480954cbdc3469c07ece1f (tree)
l'heure2019-01-14 01:06:59
AuteurChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Message de Log

xf86drm: add drmOpenByFB

The new function looks up the DRM device with specified type
associated with the specified framebuffer and opens it.

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>

Change Summary

Modification

--- a/xf86drm.c
+++ b/xf86drm.c
@@ -790,6 +790,48 @@ drm_public int drmOpenRender(int minor)
790790 }
791791
792792 /**
793+ * Open the DRM device with specified type of specified framebuffer.
794+ *
795+ * Looks up the associated DRM device with specified type of the
796+ * specified framebuffer and opens it.
797+ *
798+ * \param fb the index of framebuffer.
799+ * \param type the device node type to open, PRIMARY, CONTROL or RENDER
800+ *
801+ * \return a file descriptor on success, or a negative value on error.
802+ *
803+ */
804+drm_public int drmOpenByFB(int fb, int type)
805+{
806+#ifdef __linux__
807+ DIR *sysdir;
808+ struct dirent *ent;
809+ char buf[64];
810+ const char *name = drmGetMinorName(type);
811+ int fd = -1, len = strlen(name);
812+
813+ snprintf(buf, sizeof(buf), "/sys/class/graphics/fb%d/device/drm", fb);
814+ sysdir = opendir(buf);
815+ if (!sysdir)
816+ return -errno;
817+
818+ while ((ent = readdir(sysdir))) {
819+ if (!strncmp(ent->d_name, name, len)) {
820+ snprintf(buf, sizeof(buf), "%s/%s", DRM_DIR_NAME, ent->d_name);
821+ fd = open(buf, O_RDWR | O_CLOEXEC, 0);
822+ break;
823+ }
824+ }
825+
826+ closedir(sysdir);
827+ return fd;
828+#else
829+#warning "Missing implementation of drmOpenByFB"
830+ return -EINVAL;
831+#endif
832+}
833+
834+/**
793835 * Free the version information returned by drmGetVersion().
794836 *
795837 * \param v pointer to the version information.
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -570,6 +570,7 @@ extern int drmOpenWithType(const char *name, const char *busid,
570570
571571 extern int drmOpenControl(int minor);
572572 extern int drmOpenRender(int minor);
573+extern int drmOpenByFB(int fb, int type);
573574 extern int drmClose(int fd);
574575 extern drmVersionPtr drmGetVersion(int fd);
575576 extern drmVersionPtr drmGetLibVersion(int fd);
Afficher sur ancien navigateur de dépôt.