Add initial skeleton for Intel Thunderbolt support

This commit is contained in:
Richard Hughes 2016-12-16 12:16:07 +00:00
parent 598a40d746
commit a59777ad8d
6 changed files with 143 additions and 0 deletions

View File

@ -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
"

View File

@ -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

View File

@ -21,4 +21,8 @@ if HAVE_UEFI
SUBDIRS += uefi
endif
if HAVE_THUNDERBOLT
SUBDIRS += thunderbolt
endif
-include $(top_srcdir)/git.mk

View File

@ -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

View File

@ -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.

View File

@ -0,0 +1,75 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2016 Intel Corporation <thunderbolt-software@lists.01.org>
* Copyright (C) 2016 Richard Hughes <richard@hughsie.com>
*
* 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 <appstream-glib.h>
#include <gudev/gudev.h>
#include <tbt/tbt_fwu.h>
#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;
}