usb_libusb10.h
Go to the documentation of this file.
1 /*
2  * This file is part of the OpenKinect Project. http://www.openkinect.org
3  *
4  * Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file
5  * for details.
6  *
7  * This code is licensed to you under the terms of the Apache License, version
8  * 2.0, or, at your option, the terms of the GNU General Public License,
9  * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
10  * or the following URLs:
11  * http://www.apache.org/licenses/LICENSE-2.0
12  * http://www.gnu.org/licenses/gpl-2.0.txt
13  *
14  * If you redistribute this file in source form, modified or unmodified, you
15  * may:
16  * 1) Leave this header intact and distribute it under the same terms,
17  * accompanying it with the APACHE20 and GPL20 files, or
18  * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
19  * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file
20  * In all cases you must keep the copyright notice intact and include a copy
21  * of the CONTRIB file.
22  *
23  * Binary distributions must follow the binary distribution requirements of
24  * either License.
25  */
26 
27 #pragma once
28 
29 #include "libfreenect.h"
30 #include <libusb.h>
31 
32 #if defined(__APPLE__)
33 /*
34  From Github Issue 22 by Roefer -
35  https://github.com/OpenKinect/libfreenect/issues/#issue/22
36 
37  The current implementation still does not reach 30 Hz on MacOS. This
38  is due to bad scheduling of USB transfers in libusb (Ed Note: libusb
39  1.0.8). A fix can be found at
40  http://www.informatik.uni-bremen.de/~roefer/libusb/libusb-osx-kinect.diff
41 
42  (Ed Note: patch applies to libusb repo at 7da756e09fd)
43 
44  In camera.c, I use PKTS_PER_XFER = 128, NUM_XFERS = 4. There are a
45  few rules: PKTS_PER_XFER * NUM_XFERS <= 1000, PKTS_PER_XFER % 8 == 0.
46 */
47 #define PKTS_PER_XFER 128
48 #define NUM_XFERS 4
49 #define DEPTH_PKTBUF 2048
50 #define VIDEO_PKTBUF 2048
51 #else
52 #ifdef _WIN32
53  #define PKTS_PER_XFER 32
54  #define NUM_XFERS 8
55 #else
56  #define PKTS_PER_XFER 16
57  #define NUM_XFERS 16
58 #endif
59 #define DEPTH_PKTBUF 1920
60 #define VIDEO_PKTBUF 1920
61 #endif
62 
63 typedef struct {
66 } fnusb_ctx;
67 
68 typedef struct {
69  freenect_device *parent; //so we can go up from the libusb userdata
71  int device_dead; // set to 1 when the underlying libusb_device_handle vanishes (ie, Kinect was unplugged)
72 } fnusb_dev;
73 
74 typedef struct {
75  fnusb_dev *parent; //so we can go up from the libusb userdata
79  int num_xfers;
80  int pkts;
81  int len;
82  int dead;
85 
88 
92 int fnusb_process_events_timeout(fnusb_ctx *ctx, struct timeval* timeout);
93 
94 int fnusb_open_subdevices(freenect_device *dev, int index);
96 
97 int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_iso_cb cb, int ep, int xfers, int pkts, int len);
99 
100 int fnusb_control(fnusb_dev *dev, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint8_t *data, uint16_t wLength);
101 int fnusb_bulk(fnusb_dev *dev, uint8_t endpoint, uint8_t *data, int len, int *transferred);
fnusb_iso_cb cb
Definition: usb_libusb10.h:78
int fnusb_close_subdevices(freenect_device *dev)
Definition: usb_libusb10.c:650
unsigned short uint16_t
int fnusb_shutdown(fnusb_ctx *ctx)
Definition: usb_libusb10.c:235
void freenect_usb_context
Definition: libfreenect.h:182
int fnusb_init(fnusb_ctx *ctx, freenect_usb_context *usb_ctx)
Definition: usb_libusb10.c:214
int fnusb_control(fnusb_dev *dev, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint8_t *data, uint16_t wLength)
Definition: usb_libusb10.c:823
uint8_t * buffer
Definition: usb_libusb10.h:77
int should_free_ctx
Definition: usb_libusb10.h:65
int fnusb_start_iso(fnusb_dev *dev, fnusb_isoc_stream *strm, fnusb_iso_cb cb, int ep, int xfers, int pkts, int len)
Definition: usb_libusb10.c:755
unsigned char uint8_t
unsigned int timeout
Definition: libusb.h:162
int device_dead
Definition: usb_libusb10.h:71
int fnusb_stop_iso(fnusb_dev *dev, fnusb_isoc_stream *strm)
Definition: usb_libusb10.c:793
libusb_device_handle * dev
Definition: usb_libusb10.h:70
fnusb_dev * parent
Definition: usb_libusb10.h:75
void(* fnusb_iso_cb)(freenect_device *dev, uint8_t *buf, int len)
int fnusb_num_devices(fnusb_ctx *ctx)
Definition: usb_libusb10.c:40
freenect_device * parent
Definition: usb_libusb10.h:69
static freenect_context * ctx
int fnusb_open_subdevices(freenect_device *dev, int index)
Definition: usb_libusb10.c:255
int fnusb_process_events_timeout(fnusb_ctx *ctx, struct timeval *timeout)
Definition: usb_libusb10.c:250
int fnusb_list_device_attributes(fnusb_ctx *ctx, struct freenect_device_attributes **attribute_list)
Definition: usb_libusb10.c:110
int fnusb_num_interfaces(fnusb_dev *dev)
Definition: usb_libusb10.c:833
int fnusb_process_events(fnusb_ctx *ctx)
Definition: usb_libusb10.c:245
unsigned char endpoint
Definition: libusb.h:160
libusb_context * ctx
Definition: usb_libusb10.h:64
struct libusb_transfer ** xfers
Definition: usb_libusb10.h:76
int fnusb_bulk(fnusb_dev *dev, uint8_t endpoint, uint8_t *data, int len, int *transferred)
Definition: usb_libusb10.c:828


libfreenect
Author(s): Hector Martin, Josh Blake, Kyle Machulis, OpenKinect community
autogenerated on Thu Jun 6 2019 19:25:38