uterm: remove unused pciaccess helpers
authorDavid Herrmann <dh.herrmann@googlemail.com>
Mon, 7 Jan 2013 12:40:26 +0000 (13:40 +0100)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Mon, 7 Jan 2013 12:40:26 +0000 (13:40 +0100)
We now detect primary GPUs via udev so the pciaccess helpers are no longer
needed.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Makefile.am
README
configure.ac
src/uterm_pci.c [deleted file]
src/uterm_pci.h [deleted file]

index b996227..5380f97 100644 (file)
@@ -229,7 +229,6 @@ libuterm_la_SOURCES = \
        src/uterm.h \
        src/uterm_input_internal.h \
        src/uterm_video_internal.h \
-       src/uterm_pci.h \
        src/uterm_systemd_internal.h \
        src/uterm_video.c \
        src/uterm_monitor.c \
@@ -259,12 +258,6 @@ libuterm_la_CPPFLAGS += $(UDEV_CFLAGS)
 libuterm_la_LIBADD += $(UDEV_LIBS)
 endif
 
-if BUILD_ENABLE_PCIACCESS
-libuterm_la_CPPFLAGS += $(PCIACCESS_CFLAGS)
-libuterm_la_LIBADD += $(PCIACCESS_LIBS)
-libuterm_la_SOURCES += src/uterm_pci.c
-endif
-
 if BUILD_ENABLE_VIDEO_FBDEV
 libuterm_la_SOURCES += src/uterm_video_fbdev.c
 endif
diff --git a/README b/README
index d20b1e1..8def99d 100644 (file)
--- a/README
+++ b/README
@@ -43,7 +43,7 @@ console. See kmscon(1) man-page for usage information.
 
   If you want only a very basic kmscon program without any major dependencies,
   use:
-    $ ./configure --disable-debug --with-video=fbdev --disable-multi-seat --with-fonts=8x16 --disable-pciaccess --with-sessions=dummy,terminal
+    $ ./configure --disable-debug --with-video=fbdev --disable-multi-seat --with-fonts=8x16 --with-sessions=dummy,terminal
   However, you will loose a lot of functionality by dropping all dependencies.
 
   The following configure options are available. If build-time dependencies
@@ -53,7 +53,6 @@ console. See kmscon(1) man-page for usage information.
                          multi-seat support for kmscon. [default: on]
     --enable-hotplug: This requires libudev for hotplugging support. This is
                       currently mandatory and cannot be disabled. [default: on]
-    --enable-pciaccess: Enable GPU detection via pciaccess [default: on]
     --enable-debug: Enable debug mode/messages [default: on]
     --enable-optimizations: Enable code optimizations [default: on]
     --enable-eloop-dbus: Build dbus extension for eloop library [default: off]
index 5077f5f..a24b17b 100644 (file)
@@ -104,11 +104,6 @@ PKG_CHECK_MODULES([FUSE], [fuse],
 AC_SUBST(FUSE_CFLAGS)
 AC_SUBST(FUSE_LIBS)
 
-PKG_CHECK_MODULES([PCIACCESS], [pciaccess],
-                  [have_pciaccess=yes], [have_pciaccess=no])
-AC_SUBST(PCIACCESS_CFLAGS)
-AC_SUBST(PCIACCESS_LIBS)
-
 #
 # Parse arguments
 # This parses all arguments that are given via "--enable-XY" or "--with-XY" and
@@ -206,16 +201,6 @@ if test "x$enable_hotplug" = "x" ; then
 fi
 AC_MSG_RESULT([$enable_hotplug])
 
-# pciaccess
-AC_MSG_CHECKING([whether user wants pciaccess device detection])
-AC_ARG_ENABLE([pciaccess],
-              [AS_HELP_STRING([--enable-pciaccess],
-                              [enable device detection via pciaccess])])
-if test "x$enable_pciaccess" = "x" ; then
-        enable_pciaccess="yes (default)"
-fi
-AC_MSG_RESULT([$enable_pciaccess])
-
 # eloop-dbus
 AC_MSG_CHECKING([whether user wants eloop dbus support])
 AC_ARG_ENABLE([eloop-dbus],
@@ -528,25 +513,6 @@ else
         hotplug_missing="enable-hotplug"
 fi
 
-# pciaccess
-pciaccess_avail=no
-pciaccess_missing=""
-if test ! "x$enable_pciaccess" = "xno" ; then
-        pciaccess_avail=yes
-        if test "x$have_pciaccess" = "xno" ; then
-                pciaccess_avail=no
-                pciaccess_missing="libpciaccess"
-        fi
-
-        if test "x$pciaccess_avail" = "xno" ; then
-                if test "x$enable_pciaccess" = "xyes" ; then
-                        AC_ERROR([missing for pciaccess: $pciaccess_missing])
-                fi
-        fi
-else
-        pciaccess_missing="enable-pciaccess"
-fi
-
 # renderer bbulk
 renderer_bbulk_avail=no
 renderer_bbulk_missing=""
@@ -825,14 +791,6 @@ if test "x$renderer_bbulk_avail" = "xyes" ; then
         fi
 fi
 
-# pciaccess
-pciaccess_enabled=no
-if test "x$pciaccess_avail" = "xyes" ; then
-        if test "x${enable_pciaccess% *}" = "xyes" ; then
-                pciaccess_enabled=yes
-        fi
-fi
-
 # hotplug
 hotplug_enabled=no
 if test "x$hotplug_avail" = "xyes" ; then
@@ -1004,15 +962,6 @@ fi
 AM_CONDITIONAL([BUILD_ENABLE_HOTPLUG],
                [test "x$hotplug_enabled" = "xyes"])
 
-# pciaccess
-if test "x$pciaccess_enabled" = "xyes" ; then
-        AC_DEFINE([BUILD_ENABLE_PCIACCESS], [1],
-                  [Use pciaccess for device detection])
-fi
-
-AM_CONDITIONAL([BUILD_ENABLE_PCIACCESS],
-               [test "x$pciaccess_enabled" = "xyes"])
-
 # renderer bbulk
 if test "x$renderer_bbulk_enabled" = "xyes" ; then
         AC_DEFINE([BUILD_ENABLE_RENDERER_BBULK], [1],
@@ -1185,7 +1134,6 @@ AC_MSG_NOTICE([Build configuration:
         optimizations: $optimizations_enabled ($optimizations_avail: $optimizations_missing)
            multi-seat: $multi_seat_enabled ($multi_seat_avail: $multi_seat_missing)
               hotplug: $hotplug_enabled ($hotplug_avail: $hotplug_missing)
-            pciaccess: $pciaccess_enabled ($pciaccess_avail: $pciaccess_missing)
            eloop-dbus: $eloop_dbus_enabled ($eloop_dbus_avail: $eloop_dbus_missing)
 
   Video Backends:
diff --git a/src/uterm_pci.c b/src/uterm_pci.c
deleted file mode 100644 (file)
index 7bb59e1..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * uterm - Linux User-Space Terminal
- *
- * Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/*
- * PCI Helpers
- * This uses the pciaccess library to retrieve information from the PCI bus.
- */
-
-#include <errno.h>
-#include <inttypes.h>
-#include <pciaccess.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "log.h"
-#include "uterm.h"
-#include "uterm_pci.h"
-
-#define LOG_SUBSYSTEM "pci"
-
-/* pci classes */
-#define UTERM_PCI_CLASS_PREHISTORIC            0x00
-#define UTERM_PCI_CLASS_DISPLAY                0x03
-#define UTERM_PCI_CLASS_MULTIMEDIA             0x04
-#define UTERM_PCI_CLASS_PROCESSOR              0x0b
-
-/* pci sub-classes */
-#define UTERM_PCI_SUBCLASS_DISPLAY_VGA         0x00
-#define UTERM_PCI_SUBCLASS_MULTIMEDIA_VIDEO    0x00
-#define UTERM_PCI_SUBCLASS_PROCESSOR_COPROC    0x40
-
-/* pci registers */
-#define UTERM_PCI_CMD_MEM_ENABLE               0x02
-
-static bool uterm_pci_is_gpu(struct pci_device *dev)
-{
-       uint32_t class = dev->device_class;
-       uint32_t match;
-
-       match = UTERM_PCI_CLASS_PREHISTORIC << 16;
-       if ((class & 0x00ff0000) == match)
-               return true;
-
-       match = UTERM_PCI_CLASS_DISPLAY << 16;
-       if ((class & 0x00ff0000) == match)
-               return true;
-
-       match = UTERM_PCI_CLASS_MULTIMEDIA << 16;
-       match |= UTERM_PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8;
-       if ((class & 0x00ffff00) == match)
-               return true;
-
-       match = UTERM_PCI_CLASS_PROCESSOR << 16;
-       match |= UTERM_PCI_SUBCLASS_PROCESSOR_COPROC << 8;
-       if ((class & 0x00ffff00) == match)
-               return true;
-
-       return false;
-}
-
-static bool uterm_pci_is_vga(struct pci_device *dev)
-{
-       uint32_t class = dev->device_class;
-       uint32_t match;
-
-       match = UTERM_PCI_CLASS_DISPLAY << 16;
-       match |= UTERM_PCI_SUBCLASS_DISPLAY_VGA << 8;
-       return (class & 0x00ffff00) == match;
-}
-
-static const struct pci_slot_match uterm_pci_match = {
-       .domain = PCI_MATCH_ANY,
-       .bus = PCI_MATCH_ANY,
-       .dev = PCI_MATCH_ANY,
-       .func = PCI_MATCH_ANY,
-       .match_data = 0,
-};
-
-#define UTERM_PCI_FORMAT "pci:%04x:%02x:%02x.%d"
-
-int uterm_pci_get_primary_id(char **out)
-{
-       int ret;
-       struct pci_device_iterator *iter;
-       struct pci_device *dev;
-       char *buf;
-       uint16_t cmd;
-       unsigned int num;
-
-       if (!out)
-               return -EINVAL;
-
-       ret = pci_system_init();
-       if (ret) {
-               log_error("cannot initialize pciaccess library (%d/%d): %m",
-                         ret, errno);
-               return -EFAULT;
-       }
-
-       iter = pci_slot_match_iterator_create(&uterm_pci_match);
-       if (!iter) {
-               log_error("cannot create pci-slot iterator (%d): %m",
-                         errno);
-               ret = -EFAULT;
-               goto out_cleanup;
-       }
-
-       buf = NULL;
-       num = 0;
-       while ((dev = pci_device_next(iter))) {
-               if (!uterm_pci_is_gpu(dev))
-                       continue;
-
-               ++num;
-               if (!pci_device_is_boot_vga(dev))
-                       continue;
-
-               log_debug("primary PCI GPU: " UTERM_PCI_FORMAT,
-                         dev->domain, dev->bus, dev->dev, dev->func);
-
-               if (buf) {
-                       log_warning("multiple primary PCI GPUs found");
-                       continue;
-               }
-
-               ret = asprintf(&buf, UTERM_PCI_FORMAT, dev->domain, dev->bus,
-                              dev->dev, dev->func);
-               if (ret < 0) {
-                       log_error("cannot allocate memory for PCI name");
-                       goto out_iter;
-               }
-       }
-
-       free(iter);
-       if (buf) {
-               ret = 0;
-               *out = buf;
-               goto out_cleanup;
-       }
-
-       /* If no GPU is marked as boot_vga, we try finding a VGA card */
-       iter = pci_slot_match_iterator_create(&uterm_pci_match);
-       if (!iter) {
-               log_error("cannot create pci-slot iterator (%d): %m",
-                         errno);
-               ret = -EFAULT;
-               goto out_cleanup;
-       }
-
-       while ((dev = pci_device_next(iter))) {
-               if (!uterm_pci_is_gpu(dev))
-                       continue;
-
-               ret = pci_device_cfg_read_u16(dev, &cmd, 4);
-               if (ret)
-                       continue;
-               if (!(cmd & UTERM_PCI_CMD_MEM_ENABLE))
-                       continue;
-               if (num != 1 && !uterm_pci_is_vga(dev))
-                       continue;
-
-               log_debug("primary PCI VGA GPU: " UTERM_PCI_FORMAT,
-                         dev->domain, dev->bus, dev->dev, dev->func);
-
-               if (buf) {
-                       log_warning("multiple primary PCI VGA GPUs found");
-                       continue;
-               }
-
-               ret = asprintf(&buf, UTERM_PCI_FORMAT, dev->domain, dev->bus,
-                              dev->dev, dev->func);
-               if (ret < 0) {
-                       log_error("cannot allocate memory for PCI name");
-                       goto out_iter;
-               }
-       }
-
-       if (buf) {
-               ret = 0;
-               *out = buf;
-       } else {
-               log_warning("no primary PCI GPU found");
-               ret = -ENOENT;
-       }
-
-out_iter:
-       free(iter);
-out_cleanup:
-       pci_system_cleanup();
-       return ret;
-}
diff --git a/src/uterm_pci.h b/src/uterm_pci.h
deleted file mode 100644 (file)
index dbb28e2..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * uterm - Linux User-Space Terminal
- *
- * Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/*
- * PCI Helpers
- * This uses the pciaccess library to retrieve information from the PCI bus.
- */
-
-#ifndef UTERM_PCI_H
-#define UTERM_PCI_H
-
-#include <stdlib.h>
-#include "uterm.h"
-
-#ifdef BUILD_ENABLE_PCIACCESS
-
-int uterm_pci_get_primary_id(char **out);
-
-#else
-
-static inline int uterm_pci_get_primary_id(char **out)
-{
-       return -EOPNOTSUPP;
-}
-
-#endif
-
-#endif /* UTERM_PCI_H */