Directly open the files in sysfs to remove the last usage of
the deprecated libsysfs library in fbdev.c and remove libsysfs
from the build system.
v2: actually set vendor, model and
remove unnecessary linux/limits.h include
---
configure.in | 28 -----------
directfb-config.in | 5 +-
systems/fbdev/Makefile.am | 3 +-
systems/fbdev/fbdev.c | 119 +++++++++++++++++++++++++--------------------
4 files changed, 69 insertions(+), 86 deletions(-)
diff --git a/configure.in b/configure.in
index 374bf7f..c5aa8c5 100644
--- a/configure.in
+++ b/configure.in
@@ -839,33 +839,6 @@ AC_SUBST(MESA_CFLAGS)
-dnl Test for libsysfs
-AC_ARG_ENABLE(sysfs,
- AC_HELP_STRING([--enable-sysfs],
- [build with sysfs support @<:@default=auto@:>@]),
- [], [enable_sysfs=yes])
-
-use_sysfs=no
-SYSFS_LIBS=
-
-if test "$enable_sysfs" = "yes"; then
- AC_CHECK_LIB(sysfs, sysfs_get_mnt_path,
- [
- AC_CHECK_HEADER(sysfs/libsysfs.h,
- use_sysfs=yes
- AC_DEFINE(USE_SYSFS,1,[Define to 1 to build with sysfs support.])
- SYSFS_LIBS='-lsysfs',
- AC_MSG_WARN([
-*** libsysfs header files not found -- Building without sysfs support.]))
- ],[
- AC_MSG_WARN([ *** libsysfs not found -- Building without sysfs
support.])
- ])
-fi
-
-AC_SUBST(SYSFS_LIBS)
-
-
-
dnl Test for libjpeg
JPEG=no
@@ -2216,7 +2189,6 @@ Misc options:
Dithering $with_dither
Dithering 565 $with_dither_rgb16
zlib compression $use_zlib $ZLIB_LIBS
- sysfs support $use_sysfs $SYSFS_LIBS
Using setsockopt $with_setsockopt
Building Tests $with_tests
diff --git a/directfb-config.in b/directfb-config.in
index 212675c..0fa0bb7 100644
--- a/directfb-config.in
+++ b/directfb-config.in
@@ -126,9 +126,6 @@ while test $# -gt 0; do
for i in `echo $optarg | sed 's/,/ /g'`; do
echo_system="$echo_system $moduledir/systems/libdirectfb_$i.o"
case $i in
- fbdev)
- echo_system="$echo_system @SYSFS_LIBS@"
- ;;
sdl)
echo_system="$echo_system @SDL_LIBS@"
;;
@@ -233,7 +230,7 @@ if test -n "$echo_static"; then
echo -static
if test -z "$echo_system"; then
- echo $moduledir/systems/libdirectfb_fbdev.o @SYSFS_LIBS@
+ echo $moduledir/systems/libdirectfb_fbdev.o
fi
if test -z "$echo_wm"; then
diff --git a/systems/fbdev/Makefile.am b/systems/fbdev/Makefile.am
index cf4ff8f..2911ad8 100644
--- a/systems/fbdev/Makefile.am
+++ b/systems/fbdev/Makefile.am
@@ -29,8 +29,7 @@ systems_LTLIBRARIES = libdirectfb_fbdev.la
libdirectfb_fbdev_la_LDFLAGS = \
-avoid-version \
- -module \
- $(SYSFS_LIBS)
+ -module
libdirectfb_fbdev_la_SOURCES = \
agp.c \
diff --git a/systems/fbdev/fbdev.c b/systems/fbdev/fbdev.c
index 242469b..96356b0 100644
--- a/systems/fbdev/fbdev.c
+++ b/systems/fbdev/fbdev.c
@@ -48,9 +48,10 @@
#include <pthread.h>
-#ifdef USE_SYSFS
-# include <sysfs/libsysfs.h>
-#endif
+#define SYS_CLASS_GRAPHICS_DEV "/sys/class/graphics/%s/device"
+#define SYS_CLASS_GRAPHICS_DEV_VENDOR "/sys/class/graphics/%s/device/vendor"
+#define SYS_CLASS_GRAPHICS_DEV_MODEL "/sys/class/graphics/%s/device/device"
+#define SYSFS_PATH_MAX 128
#include <fusion/arena.h>
#include <fusion/fusion.h>
@@ -324,65 +325,79 @@ error:
static void
dfb_fbdev_get_pci_info( FBDevShared *shared )
{
- char buf[512];
- int vendor = -1;
- int model = -1;
-
-#ifdef USE_SYSFS
- if (!sysfs_get_mnt_path( buf, 512 )) {
- struct sysfs_class_device *classdev;
- struct sysfs_device *device;
- struct sysfs_attribute *attr;
- char *fbdev;
- char dev[5] = { 'f', 'b', '0', 0, 0 };
-
- fbdev = dfb_config->fb_device;
- if (!fbdev)
- fbdev = getenv( "FRAMEBUFFER" );
-
- if (fbdev) {
- if (!strncmp( fbdev, "/dev/fb/", 8 ))
- snprintf( dev, 5, "fb%s", fbdev+8 );
- else if (!strncmp( fbdev, "/dev/fb", 7 ))
- snprintf( dev, 5, "fb%s", fbdev+7 );
+ char buf[512];
+ int vendor = -1;
+ int model = -1;
+ FILE *fp;
+ int bus;
+ int dev;
+ int func;
+ char *fbdev;
+ char devname[5] = { 'f', 'b', '0', 0, 0 };
+ char path[SYSFS_PATH_MAX];
+ int len;
+
+ /* try sysfs interface */
+ fbdev = dfb_config->fb_device;
+ if (!fbdev)
+ fbdev = getenv( "FRAMEBUFFER" );
+
+ if (fbdev) {
+ if (!strncmp( fbdev, "/dev/fb/", 8 ))
+ snprintf( devname, 5, "fb%s", fbdev+8 );
+ else if (!strncmp( fbdev, "/dev/fb", 7 ))
+ snprintf( devname, 5, "fb%s", fbdev+7 );
+ }
+
+ snprintf(path, SYSFS_PATH_MAX, SYS_CLASS_GRAPHICS_DEV, devname);
+
+ len = readlink(path,buf,512);
+ if(len != -1) {
+ char * base;
+ buf[len] = '\0';
+ base = basename(buf);
+
+ if (sscanf( base, "0000:%02x:%02x.%1x", &bus, &dev, &func ) == 3) {
+ shared->pci.bus = bus;
+ shared->pci.dev = dev;
+ shared->pci.func = func;
+ }
+
+ snprintf(path, SYSFS_PATH_MAX, SYS_CLASS_GRAPHICS_DEV_VENDOR,
devname);
+
+ fp = fopen(path,"r");
+ if(fp) {
+ if(fgets(buf,512,fp)) {
+ if(sscanf(buf,"0x%04x", &vendor) == 1)
+ shared->device.vendor = vendor;
+ }
+ fclose(fp);
+ } else {
+ D_DEBUG( "DirectFB/FBDev: "
+ "couldn't access %s!\n", path );
}
- classdev = sysfs_open_class_device( "graphics", dev );
- if (classdev) {
- device = sysfs_get_classdev_device( classdev );
-
- if (device) {
- attr = sysfs_get_device_attr( device, "vendor" );
- if (attr)
- sscanf( attr->value, "0x%04x", &vendor );
-
- attr = sysfs_get_device_attr( device, "device" );
- if (attr)
- sscanf( attr->value, "0x%04x", &model );
-
- if (vendor != -1 && model != -1) {
- sscanf( device->name, "0000:%02x:%02x.%1x",
- &shared->pci.bus,
- &shared->pci.dev,
- &shared->pci.func );
+ snprintf(path, SYSFS_PATH_MAX, SYS_CLASS_GRAPHICS_DEV_MODEL,
devname);
- shared->device.vendor = vendor;
- shared->device.model = model;
- }
+ fp = fopen(path,"r");
+ if(fp) {
+ if(fgets(buf,512,fp)) {
+ if(sscanf(buf,"0x%04x", &model) == 1)
+ shared->device.model = model;
}
-
- sysfs_close_class_device( classdev );
+ fclose(fp);
+ } else {
+ D_DEBUG( "DirectFB/FBDev: "
+ "couldn't access %s!\n", path );
}
+ } else {
+ D_DEBUG( "DirectFB/FBDev: "
+ "couldn't access %s!\n", path );
}
-#endif /* USE_SYSFS */
/* try /proc interface */
if (vendor == -1 || model == -1) {
- FILE *fp;
int id;
- int bus;
- int dev;
- int func;
fp = fopen( "/proc/bus/pci/devices", "r" );
if (!fp) {
--
1.7.10
_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev