diff --git a/configure.ac b/configure.ac index 681adbf99..cb91c7d1f 100644 --- a/configure.ac +++ b/configure.ac @@ -183,6 +183,26 @@ else fi AM_CONDITIONAL(HAVE_COLORHUG, test x$has_colorhug = xyes) +# Thunderbolt support +AC_ARG_ENABLE(thunderbolt, + AS_HELP_STRING([--enable-thunderbolt], + [Enable Thunderbolt support [default=auto]]),, + enable_thunderbolt=maybe) +if test x$enable_thunderbolt != xno; then + PKG_CHECK_MODULES(THUNDERBOLT, [libtbtfwu >= 0.9], + has_thunderbolt=yes, + has_thunderbolt=no) +fi +if test x$has_thunderbolt = xyes; then + AC_DEFINE(HAVE_THUNDERBOLT,1,[Use Thunderbolt support]) +else + has_thunderbolt=no + if test "x$enable_thunderbolt" = "xyes"; then + AC_MSG_ERROR([thunderbolt support requested but 'libtbtfwu-dev' was not found]) + fi +fi +AM_CONDITIONAL(HAVE_THUNDERBOLT, test x$has_thunderbolt = xyes) + # libelf support AC_ARG_ENABLE(libelf, AS_HELP_STRING([--enable-libelf], @@ -335,6 +355,7 @@ plugins/raspberrypi/Makefile plugins/raspberrypi/rpiupdate/Makefile plugins/steelseries/Makefile plugins/test/Makefile +plugins/thunderbolt/Makefile plugins/udev/Makefile plugins/uefi/Makefile plugins/unifying/Makefile @@ -360,4 +381,5 @@ echo " libelf: $has_libelf UEFI: $has_fwup Dell: $has_dell + Thunderbolt: $has_thunderbolt " diff --git a/contrib/fwupd.spec.in b/contrib/fwupd.spec.in index 848adf291..f9673758b 100644 --- a/contrib/fwupd.spec.in +++ b/contrib/fwupd.spec.in @@ -85,6 +85,7 @@ Files for development with libdfu. %build %configure \ --disable-static \ + --disable-thunderbolt \ --enable-gtk-doc \ --enable-colorhug \ %ifarch x86_64 %{ix86} aarch64 diff --git a/plugins/Makefile.am b/plugins/Makefile.am index cc7cbf3eb..d62c7a0f4 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -21,4 +21,8 @@ if HAVE_UEFI SUBDIRS += uefi endif +if HAVE_THUNDERBOLT +SUBDIRS += thunderbolt +endif + -include $(top_srcdir)/git.mk diff --git a/plugins/thunderbolt/Makefile.am b/plugins/thunderbolt/Makefile.am new file mode 100644 index 000000000..f8c72592b --- /dev/null +++ b/plugins/thunderbolt/Makefile.am @@ -0,0 +1,22 @@ +AM_CPPFLAGS = \ + $(APPSTREAM_GLIB_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GUDEV_CFLAGS) \ + $(GUSB_CFLAGS) \ + $(THUNDERBOLT_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/libfwupd \ + -I$(top_srcdir)/src + +plugindir = $(libdir)/fwupd-plugins-2 +plugin_LTLIBRARIES = libfu_plugin_thunderbolt.la +libfu_plugin_thunderbolt_la_SOURCES = \ + fu-plugin-thunderbolt.c +libfu_plugin_thunderbolt_la_LIBADD = $(GUDEV_LIBS) $(THUNDERBOLT_LIBS) +libfu_plugin_thunderbolt_la_LDFLAGS = -module -avoid-version +libfu_plugin_thunderbolt_la_CFLAGS = $(WARN_CFLAGS) \ + -DG_LOG_DOMAIN=\"FuPluginThunderbolt\" + +EXTRA_DIST = README.md + +-include $(top_srcdir)/git.mk diff --git a/plugins/thunderbolt/README.md b/plugins/thunderbolt/README.md new file mode 100644 index 000000000..9c7eec5fa --- /dev/null +++ b/plugins/thunderbolt/README.md @@ -0,0 +1,19 @@ +Thunderboltâ„¢ Support +==================== + +Introduction +------------ + +Thunderboltâ„¢ is the brand name of a hardware interface developed by Intel that +allows the connection of external peripherals to a computer. +Versions 1 and 2 use the same connector as Mini DisplayPort (MDP), whereas +version 3 uses USB Type-C. + +Build Requirements +------------------ + +For UEFI capsule support, you need to install libtbtfwu. +* source: https://github.com/01org/thunderbolt-software-user-space/tree/fwupdate + +If you don't want or need this functionality you can use the +`--disable-thunderbolt` option. diff --git a/plugins/thunderbolt/fu-plugin-thunderbolt.c b/plugins/thunderbolt/fu-plugin-thunderbolt.c new file mode 100644 index 000000000..08c045947 --- /dev/null +++ b/plugins/thunderbolt/fu-plugin-thunderbolt.c @@ -0,0 +1,75 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2016 Intel Corporation + * Copyright (C) 2016 Richard Hughes + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" + +#include +#include +#include + +#include "fu-plugin.h" +#include "fu-plugin-vfuncs.h" + +struct FuPluginData { + /* A handle on some state for dealing with our registration + * for udev events. + */ + GUdevClient *gudev_client; +}; + +void +fu_plugin_init (FuPlugin *plugin) +{ + FuPluginData *data = fu_plugin_alloc_data (plugin, sizeof (FuPluginData)); + const gchar* subsystems[] = { "pci", NULL }; + data->gudev_client = g_udev_client_new (subsystems); +} + +void +fu_plugin_destroy (FuPlugin *plugin) +{ + FuPluginData *data = fu_plugin_get_data (plugin); + tbt_fwu_shutdown (); + g_object_unref (data->gudev_client); +} + +gboolean +fu_plugin_startup (FuPlugin *plugin, GError **error) +{ + gint rc = tbt_fwu_init (); + if (rc != TBT_OK) { + g_set_error (error, + FWUPD_ERROR, + FWUPD_ERROR_INTERNAL, + "TBT initialization failed: %s", + tbt_strerror (rc)); + return FALSE; + } + return TRUE; +} + +gboolean +fu_plugin_coldplug (FuPlugin *plugin, GError **error) +{ + //FuPluginData *data = fu_plugin_get_data (plugin); + return TRUE; +}