summaryrefslogtreecommitdiff
path: root/libusb
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-03-10 13:19:38 +0000
committerPete Batard <pbatard@gmail.com>2010-03-10 13:19:38 +0000
commitea78e1ce73c018eff041555ab41448fc889ce278 (patch)
tree44e7f8b5448b5310b83c2e6abc3cc5fd2cc85b64 /libusb
parentfae9c17bd2405813d44186c94367d6e66d3994e6 (diff)
downloadlibusb-ea78e1ce73c018eff041555ab41448fc889ce278.tar.gz
merge up to r202c191
Diffstat (limited to 'libusb')
-rw-r--r--libusb/Makefile.am4
-rw-r--r--libusb/core.c2
-rw-r--r--libusb/libusb-1.0.rc120
-rw-r--r--libusb/libusb.h2
-rw-r--r--libusb/os/poll_posix.h6
-rw-r--r--libusb/os/threads_windows.c2
-rw-r--r--libusb/os/windows_usb.c27
-rw-r--r--libusb/os/windows_usb.h10
8 files changed, 150 insertions, 23 deletions
diff --git a/libusb/Makefile.am b/libusb/Makefile.am
index c252b3d..48b28fb 100644
--- a/libusb/Makefile.am
+++ b/libusb/Makefile.am
@@ -8,7 +8,7 @@ endif
LINUX_USBFS_SRC = $(THREADS_SRC) os/poll_posix.h os/linux_usbfs.h os/linux_usbfs.c
DARWIN_USB_SRC = $(THREADS_SRC) os/poll_posix.h os/darwin_usb.h os/darwin_usb.c
-WINDOWS_USB_SRC = $(THREADS_SRC) os/poll_windows.h os/poll_windows.c os/windows_usb.h os/windows_usb.c
+WINDOWS_USB_SRC = $(THREADS_SRC) os/poll_windows.h os/poll_windows.c os/windows_usb.h os/windows_usb.c libusb-1.0.rc
EXTRA_DIST = $(LINUX_USBFS_SRC) $(DARWIN_USB_SRC) $(WINDOWS_USB_SRC)
@@ -23,6 +23,8 @@ endif
if OS_WINDOWS
OS_SRC = $(WINDOWS_USB_SRC)
+.rc.lo:
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) -i $< -o $@
endif
libusb_1_0_la_CFLAGS = $(VISIBILITY_CFLAGS) $(AM_CFLAGS)
diff --git a/libusb/core.c b/libusb/core.c
index 7be7f11..47d5108 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -831,8 +831,8 @@ API_EXPORTED void libusb_unref_device(libusb_device *dev)
usbi_mutex_lock(&dev->ctx->usb_devs_lock);
list_del(&dev->list);
usbi_mutex_unlock(&dev->ctx->usb_devs_lock);
- usbi_mutex_destroy(&dev->lock);
+ usbi_mutex_destroy(&dev->lock);
free(dev);
}
}
diff --git a/libusb/libusb-1.0.rc b/libusb/libusb-1.0.rc
new file mode 100644
index 0000000..5dea80c
--- /dev/null
+++ b/libusb/libusb-1.0.rc
@@ -0,0 +1,120 @@
+//Microsoft Developer Studio generated resource script.
+//
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winresrc.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef _DEBUG
+#define VER_ORIGINALFILENAME_STR "libusb-1.0_debug.dll\0"
+#else
+#define VER_ORIGINALFILENAME_STR "libusb-1.0.dll\0"
+#endif
+
+#define VER_MAJOR 1
+#define VER_MAJOR_STR "1"
+#define VER_MINOR 0
+#define VER_MINOR_STR "0"
+#define VER_MICRO 5
+#define VER_MICRO_STR "5"
+#define VER_NANO 0
+#define VER_NANO_STR "0"
+#define VER_VERSION_STR VER_MAJOR_STR ", " VER_MINOR_STR ", " VER_MICRO_STR ", " VER_NANO_STR "\0"
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""winresrc.h""\r\n"
+ "\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION VER_MAJOR,VER_MINOR,VER_MICRO,VER_NANO
+ PRODUCTVERSION VER_MAJOR,VER_MINOR,VER_MICRO,VER_NANO
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", "\0"
+ VALUE "CompanyName", "libusb.org\0"
+ VALUE "FileDescription", "libusb-1\0"
+ VALUE "FileVersion", VER_VERSION_STR
+ VALUE "InternalName", "libusb\0"
+ VALUE "LegalCopyright", "See individual source files, GNU LGPL v2.1 or later.\0"
+ VALUE "LegalTrademarks", "http://www.gnu.org/licenses/lgpl-2.1.html\0"
+ VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
+ VALUE "PrivateBuild", "\0"
+ VALUE "ProductName", "libusb-1\0"
+ VALUE "ProductVersion", VER_VERSION_STR
+ VALUE "SpecialBuild", "\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/libusb/libusb.h b/libusb/libusb.h
index 8986013..0127d9f 100644
--- a/libusb/libusb.h
+++ b/libusb/libusb.h
@@ -28,8 +28,8 @@
#include <sys/time.h>
#endif
#include <sys/types.h>
-#include <limits.h>
#include <time.h>
+#include <limits.h>
/* 'interface' might be defined as a macro on Windows, so we need to
* undefine it so as not to break the current libusb API, because
diff --git a/libusb/os/poll_posix.h b/libusb/os/poll_posix.h
index 0e9981d..17298a5 100644
--- a/libusb/os/poll_posix.h
+++ b/libusb/os/poll_posix.h
@@ -1,5 +1,5 @@
-#ifndef __LIBUSB_UNISTD_POSIX_H__
-#define __LIBUSB_UNISTD_POSIX_H__
+#ifndef __LIBUSB_POLL_POSIX_H__
+#define __LIBUSB_POLL_POSIX_H__
#include <unistd.h>
#include <poll.h>
@@ -9,4 +9,4 @@
#define usbi_pipe pipe
#define usbi_poll poll
-#endif /* __LIBUSB_UNISTD_POSIX_H__ */
+#endif /* __LIBUSB_POLL_POSIX_H__ */
diff --git a/libusb/os/threads_windows.c b/libusb/os/threads_windows.c
index da49eec..7762190 100644
--- a/libusb/os/threads_windows.c
+++ b/libusb/os/threads_windows.c
@@ -61,7 +61,7 @@ int usbi_mutex_lock(usbi_mutex_t *mutex) {
// so don't know proper errno
}
int usbi_mutex_unlock(usbi_mutex_t *mutex) {
- if(!mutex) return ((errno=EINVAL));
+ if(!mutex) return ((errno=EINVAL));
if(!ReleaseMutex(*mutex)) return ((errno=EPERM ));
return 0;
}
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 689a4e1..42ab75b 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -676,8 +676,10 @@ static int force_hcd_device_descriptor(struct libusb_device *dev, HANDLE handle)
priv->dev_descriptor.bLength = sizeof(USB_DEVICE_DESCRIPTOR);
priv->dev_descriptor.bDescriptorType = USB_DEVICE_DESCRIPTOR_TYPE;
dev->num_configurations = priv->dev_descriptor.bNumConfigurations = 1;
- priv->dev_descriptor.idVendor = 0x1d6b; // Linux Foundation root hub
+ // The following is used to set the VIS:PID of root HUBs similarly to what
+ // Linux does: 1d6b:0001 is for 1x root hubs, 1d6b:0002 for 2x
+ priv->dev_descriptor.idVendor = 0x1d6b; // Linux Foundation root hub
if (windows_version >= WINDOWS_VISTA_AND_LATER) {
size = sizeof(USB_HUB_CAPABILITIES_EX);
if (DeviceIoControl(handle, IOCTL_USB_GET_HUB_CAPABILITIES_EX, &hub_caps_ex,
@@ -694,8 +696,7 @@ static int force_hcd_device_descriptor(struct libusb_device *dev, HANDLE handle)
size, &hub_caps, size, &size, NULL)) {
usbi_warn(ctx, "could not read hub capabilities (std) for hub %s: %s",
priv->path, windows_error_str(0));
- /* Hmm. */
- priv->dev_descriptor.idProduct = 0;
+ priv->dev_descriptor.idProduct = 1; // Indicate 1x speed
} else {
priv->dev_descriptor.idProduct = hub_caps.HubIs2xCapable?2:1;
}
@@ -823,7 +824,7 @@ static int usb_enumerate_hub(struct libusb_context *ctx, struct discovered_devs
USB_HUB_NAME_FIXED s_hubname;
USB_NODE_CONNECTION_INFORMATION conn_info;
USB_NODE_INFORMATION hub_node;
- bool is_hcd;
+ bool is_hcd, need_unref = false;
int i, r;
LPCWSTR wstr;
char *tmp_str = NULL, *path_str = NULL;
@@ -856,7 +857,10 @@ static int usb_enumerate_hub(struct libusb_context *ctx, struct discovered_devs
for (i = 1, r = LIBUSB_SUCCESS; ; i++)
{
// safe loop: release all dynamic resources
- safe_unref_device(dev);
+ if (need_unref) {
+ safe_unref_device(dev);
+ need_unref = false;
+ }
safe_free(tmp_str);
safe_free(path_str);
safe_closehandle(handle);
@@ -969,6 +973,7 @@ static int usb_enumerate_hub(struct libusb_context *ctx, struct discovered_devs
if ((dev = usbi_alloc_device(ctx, session_id)) == NULL) {
LOOP_BREAK(LIBUSB_ERROR_NO_MEM);
}
+ need_unref = true;
LOOP_CHECK(initialize_device(dev, busnum, devaddr, path_str, i,
conn_info.CurrentConfigurationValue, parent_dev));
@@ -2097,12 +2102,12 @@ unsigned __stdcall windows_clock_gettime_threaded(void* param)
if (!QueryPerformanceFrequency(&li_frequency)) {
usbi_dbg("no hires timer available on this platform");
hires_frequency = 0;
- hires_ticks_to_ps = 0;
+ hires_ticks_to_ps = UINT64_C(0);
} else {
hires_frequency = li_frequency.QuadPart;
// The hires frequency can go as high as 4 GHz, so we'll use a conversion
// to picoseconds to compute the tv_nsecs part in clock_gettime
- hires_ticks_to_ps = UINT64_C(1000000000000) / hires_frequency;
+ hires_ticks_to_ps = UINT64_C(1000000000000) / hires_frequency;
usbi_dbg("hires timer available (Frequency: %"PRIu64" Hz)", hires_frequency);
}
@@ -2708,7 +2713,7 @@ static int winusb_submit_control_transfer(struct usbi_transfer *itransfer)
usbi_dbg("will use interface %d", current_interface);
winusb_handle = handle_priv->interface_handle[current_interface].api_handle;
- wfd = usbi_create_fd(winusb_handle, _O_RDONLY, ctx);
+ wfd = usbi_create_fd(winusb_handle, _O_RDONLY, ctx);
if (wfd.fd < 0) {
return LIBUSB_ERROR_NO_MEM;
}
@@ -2784,7 +2789,7 @@ static int winusb_submit_bulk_transfer(struct usbi_transfer *itransfer)
winusb_handle = handle_priv->interface_handle[current_interface].api_handle;
direction_in = transfer->endpoint & LIBUSB_ENDPOINT_IN;
- wfd = usbi_create_fd(winusb_handle, direction_in?_O_RDONLY:_O_WRONLY, ctx);
+ wfd = usbi_create_fd(winusb_handle, direction_in?_O_RDONLY:_O_WRONLY, ctx);
if (wfd.fd < 0) {
return LIBUSB_ERROR_NO_MEM;
}
@@ -4486,7 +4491,7 @@ static int hid_submit_control_transfer(struct usbi_transfer *itransfer)
usbi_dbg("will use interface %d", current_interface);
hid_handle = handle_priv->interface_handle[current_interface].api_handle;
- wfd = usbi_create_fd(hid_handle, _O_RDONLY, ctx);
+ wfd = usbi_create_fd(hid_handle, _O_RDONLY, ctx);
if (wfd.fd < 0) {
return LIBUSB_ERROR_NO_MEM;
}
@@ -4588,7 +4593,7 @@ static int hid_submit_bulk_transfer(struct usbi_transfer *itransfer) {
hid_handle = handle_priv->interface_handle[current_interface].api_handle;
direction_in = transfer->endpoint & LIBUSB_ENDPOINT_IN;
- wfd = usbi_create_fd(hid_handle, direction_in?_O_RDONLY:_O_WRONLY, ctx);
+ wfd = usbi_create_fd(hid_handle, direction_in?_O_RDONLY:_O_WRONLY, ctx);
if (wfd.fd < 0) {
return LIBUSB_ERROR_NO_MEM;
}
diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h
index 59bb074..921b1c0 100644
--- a/libusb/os/windows_usb.h
+++ b/libusb/os/windows_usb.h
@@ -351,11 +351,11 @@ typedef RETURN_TYPE CONFIGRET;
#define CR_SUCCESS 0x00000000
#define CR_NO_SUCH_DEVNODE 0x0000000D
-#if defined(_CFGMGR32_)
-#define CMAPI DECLSPEC_EXPORT
-#else
-#define CMAPI DECLSPEC_IMPORT
-#endif
+//#if defined(_CFGMGR32_)
+//#define CMAPI DECLSPEC_EXPORT
+//#else
+//#define CMAPI DECLSPEC_IMPORT
+//#endif
#define USB_DEVICE_DESCRIPTOR_TYPE LIBUSB_DT_DEVICE
#define USB_CONFIGURATION_DESCRIPTOR_TYPE LIBUSB_DT_CONFIG