- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
- Preamble
+ Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
\f
- GNU LESSER GENERAL PUBLIC LICENSE
+ GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
-
+
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
- NO WARRANTY
+ NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
- END OF TERMS AND CONDITIONS
+ END OF TERMS AND CONDITIONS
\f
How to Apply These Terms to Your New Libraries
Ty Coon, President of Vice
That's all there is to it!
-
-
--- /dev/null
+The MIT License
+
+Copyright (c) <year> <copyright holders>
+
+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.
LIBS="${LIBS} -lbe"
;;
linux)
+ AC_ARG_ENABLE([usbhost_api],
+ [AC_HELP_STRING([--enable-usbhost-api], [Request to deviced to obtain dev node fds [default=no]])],
+ [], [enable_usbhost_api="no"])
+ if test "x$enable_usbhost_api" = "xyes"; then
+ PKG_CHECK_MODULES([USBHOST_API], [dbus-1])
+ AC_DEFINE(USE_USBHOST_API, 1, [Request to deviced to obtain dev node fds])
+ fi
+
+ AC_SUBST(USE_USBHOST_API)
+
AC_SEARCH_LIBS([clock_gettime], [rt], [], [], [])
AC_CHECK_FUNCS([pthread_setname_np])
AC_ARG_ENABLE([udev],
AM_CONDITIONAL([PLATFORM_POSIX], [test "x$platform" = xposix])
AM_CONDITIONAL([PLATFORM_WINDOWS], [test "x$platform" = xwindows])
AM_CONDITIONAL([USE_UDEV], [test "x$use_udev" = xyes])
+AM_CONDITIONAL([USE_USBHOST_API], [test "x$enable_usbhost_api" = "xyes"])
dnl The -Wcast-function-type warning causes a flurry of warnings when compiling
dnl Windows with GCC 8 or later because of dynamically loaded functions
core.c descriptor.c hotplug.h hotplug.c io.c strerror.c sync.c \
$(PLATFORM_SRC) $(OS_SRC)
+if USE_USBHOST_API
+libusb_1_0_la_CFLAGS = $(USBHOST_API_CFLAGS)
+libusb_1_0_la_LIBADD = $(USBHOST_API_LIBS)
+endif
pkginclude_HEADERS = libusb.h
#include <sys/vfs.h>
#include <unistd.h>
+/* Tizen specific */
+#ifdef USE_USBHOST_API
+#include <dbus/dbus.h>
+#endif
+
/* sysfs vs usbfs:
* opening a usbfs node causes the device to be resumed, so we attempt to
* avoid this during enumeration.
int iso_packet_offset;
};
-static int get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent)
+static int _direct_open_device(struct libusb_context *ctx, const char *path,
+ mode_t mode, int silent)
{
- struct libusb_context *ctx = DEVICE_CTX(dev);
- char path[24];
int fd;
- if (usbdev_names)
- sprintf(path, USBDEV_PATH "/usbdev%u.%u",
- dev->bus_number, dev->device_address);
- else
- sprintf(path, USB_DEVTMPFS_PATH "/%03u/%03u",
- dev->bus_number, dev->device_address);
-
fd = open(path, mode | O_CLOEXEC);
if (fd != -1)
return fd; /* Success */
return fd; /* Success */
}
+ return fd;
+}
+
+#ifdef USE_USBHOST_API
+
+#define DEVICED_BUS_NAME "org.tizen.system.deviced"
+#define DEVICED_OBJECT_PATH "/Org/Tizen/System/DeviceD"
+#define DEVICED_INTERFACE_NAME DEVICED_BUS_NAME
+#define DEVICED_PATH_USBHOST DEVICED_OBJECT_PATH"/Usbhost"
+#define DEVICED_INTERFACE_USBHOST DEVICED_INTERFACE_NAME".Usbhost"
+#define METHOD_OPEN_DEVICE "OpenDevice"
+
+DBusMessage *dbus_method_sync_with_reply(const char *dest, const char *path,
+ const char *interface, const char *method, const char *param)
+{
+ DBusConnection *conn;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ DBusError err;
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (!conn) {
+ usbi_err(NULL, "dbus_bus_get error");
+ return NULL;
+ }
+
+ msg = dbus_message_new_method_call(dest, path, interface, method);
+ if (!msg) {
+ usbi_err(NULL, "dbus_message_new_method_call(%s:%s-%s)",
+ path, interface, method);
+ dbus_connection_unref (conn);
+ return NULL;
+ }
+
+ dbus_message_iter_init_append(msg, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, ¶m);
+
+ dbus_error_init(&err);
+
+ reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &err);
+ if (!reply) {
+ usbi_err(NULL, "dbus_connection_send error(No reply) %s %s:%s-%s",
+ dest, path, interface, method);
+ }
+
+ if (dbus_error_is_set(&err)) {
+ usbi_err(NULL, "dbus_connection_send error(%s:%s) %s %s:%s-%s",
+ err.name, err.message, dest, path, interface, method);
+ dbus_error_free(&err);
+ reply = NULL;
+ }
+
+ dbus_message_unref(msg);
+ dbus_connection_unref (conn);
+ return reply;
+}
+
+static int open_usb_device(const char *path, int *fd)
+{
+ DBusMessage *reply;
+ DBusError err;
+ int ret, rfd;
+ dbus_bool_t result;
+
+ if (!fd || !path)
+ return -EINVAL;
+
+ dbus_error_init(&err);
+
+ reply = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
+ DEVICED_PATH_USBHOST,
+ DEVICED_INTERFACE_USBHOST,
+ METHOD_OPEN_DEVICE,
+ path);
+
+ if (!reply) {
+ usbi_err(NULL, "Unable to open USB device");
+ return -1;
+ }
+
+ result = dbus_message_get_args(reply, &err,
+ DBUS_TYPE_INT32, &ret,
+ DBUS_TYPE_UNIX_FD, &rfd,
+ DBUS_TYPE_INVALID);
+ if (!result) {
+ usbi_err(NULL, "Failed to get arguments: %s", err.message);
+ return -1;
+ }
+
+ if (ret >= 0)
+ *fd = rfd;
+
+ return ret;
+}
+
+static int _ask_for_open(const char *path, mode_t mode, int silent)
+{
+ int ret;
+ int fd;
+
+ ret = open_usb_device(path, &fd);
+ if (ret < 0) {
+ /*
+ * We have an error so let's set errno correctly
+ * just like open does
+ */
+ errno= -ret;
+ ret = -1;
+ } else {
+ ret = fd;
+ }
+
+ return ret;
+}
+#endif /* USE_USBHOST_API */
+
+static int get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent)
+{
+ struct libusb_context *ctx = DEVICE_CTX(dev);
+ char path[24];
+ int fd;
+
+ if (usbdev_names)
+ sprintf(path, USBDEV_PATH "/usbdev%u.%u",
+ dev->bus_number, dev->device_address);
+ else
+ sprintf(path, USB_DEVTMPFS_PATH "/%03u/%03u",
+ dev->bus_number, dev->device_address);
+
+ fd = _direct_open_device(ctx, path, mode, silent);
+ if (fd != -1)
+ return fd; /* Success */
+
+#ifdef USE_USBHOST_API
+ /*
+ * If we are here, we were unable to go simple
+ * path and open the device directly. In Tizen
+ * we have USB security daemon (USD) which
+ * manages access rights to USB device nodes.
+ * Now let's ask him to open this device node
+ * for us.
+ */
+
+ /*
+ * USD is applicable only for RW access.
+ */
+ if (mode & O_RDWR) {
+ if (!silent)
+ usbi_info(ctx, "No direct access to device node: %s. "
+ "Trying to use deviced", path);
+
+ fd = _ask_for_open(path, mode, silent);
+ if (fd != -1)
+ return fd;
+ }
+#endif /* USE_USBHOST_API */
+
if (!silent) {
usbi_err(ctx, "libusb couldn't open USB device %s, errno=%d", path, errno);
if (errno == EACCES && mode == O_RDWR)
--- /dev/null
+libusb
+libusb-devel
+ requires -libusb-<targettype>
+ requires "libusb-<targettype> = <version>"
+
--- /dev/null
+* Mon Mar 18 2013 Anas Nashif <anas.nashif@intel.com> upstream/1.0.9@8f72b70
+- Update package groups
+
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+%define TIZEN_FEATURE_USBHOST_API on
+
+Name: libusb
+Version: 1.0.24
+Release: 0
+License: LGPL-2.1+, MIT
+Summary: USB Library
+Url: http://www.libusb.org/
+Group: Base/Device Management
+Source: %{name}-%{version}.tar.bz2
+Source1: baselibs.conf
+Source1001: libusb.manifest
+BuildRequires: pkg-config
+BuildRequires: systemd-devel
+%if %{?TIZEN_FEATURE_USBHOST_API} == on
+BuildRequires: pkgconfig(dbus-1)
+%endif
+
+%description
+Libusb is a library that allows userspace access to USB devices.
+
+%package devel
+Summary: USB Library
+Group: Development/Libraries
+Requires: glibc-devel
+Requires: libusb = %{version}
+
+%description devel
+Libusb is a library that allows userspace access to USB devices.
+
+%prep
+%setup -q
+cp %{SOURCE1001} .
+
+%build
+%reconfigure\
+ --with-pic\
+%if %{?TIZEN_FEATURE_USBHOST_API} == on
+ --enable-usbhost-api \
+%endif
+ --disable-static
+make %{?_smp_mflags}
+
+%install
+%make_install
+# usbhost_module
+mkdir -p %{buildroot}%{_prefix}/lib/udev/rules.d
+install -m 644 udev/99-usbhost.rules %{buildroot}%{_prefix}/lib/udev/rules.d/99-usbhost.rules
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%license LICENSE.LGPL-2.1+ LICENSE.MIT
+%{_libdir}/*.so.*
+# usbhost_module
+%{_prefix}/lib/udev/rules.d/99-usbhost.rules
+
+%files devel
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%license LICENSE.LGPL-2.1+ LICENSE.MIT
+%{_includedir}/libusb-1.0
+%{_libdir}/*.so
+%{_libdir}/pkgconfig/*.pc
+
+%changelog
--- /dev/null
+SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", DEVPATH!="/devices/platform/dummy_hcd.*", MODE="0660", GROUP="system_share", SECLABEL{smack}="*"
+SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", DEVPATH=="/devices/platform/dummy_hcd.*", MODE="0666", GROUP="system_share", SECLABEL{smack}="*"