license stuff
[ppcskel.git] / usb / core / usb.h
1 /*
2  * Copyright (c) 2006, Benedikt Sauter <sauter@ixbat.de>
3  * All rights reserved.
4  *
5  * Short descripton of file:
6  * I take the function names and parameters mainly from
7  * libusb.sf.net.
8  *
9  *
10  * Redistribution and use in source and binary forms, with or without 
11  * modification, are permitted provided that the following conditions 
12  * are met:
13  *
14  *   * Redistributions of source code must retain the above copyright 
15  *     notice, this list of conditions and the following disclaimer.
16  *   * Redistributions in binary form must reproduce the above 
17  *     copyright notice, this list of conditions and the following 
18  *     disclaimer in the documentation and/or other materials provided 
19  *     with the distribution.
20  *   * Neither the name of the FH Augsburg nor the names of its 
21  *     contributors may be used to endorse or promote products derived 
22  *     from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
27  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
28  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
30  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
31  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
33  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
34  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  */
36 /*
37         ppcskel - a Free Software replacement for the Nintendo/BroadOn bootloader.
38         libusb like interface
39
40 Copyright (C) 2009     Bernhard Urban <lewurm@gmx.net>
41 Copyright (C) 2009     Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
42
43 # This code is licensed to you under the terms of the GNU GPL, version 2;
44 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
45 */
46
47 #ifndef _USB_H_
48 #define _USB_H_
49
50 #include "../../types.h"
51 #include "core.h"
52
53
54 /******************* Device Operations **********************/
55
56 // use an own usb device
57 struct usb_device *usb_open(u32 vendor_id, u32 product_id);
58 struct usb_device *usb_open_class(u8 class);
59
60 s8 usb_close(struct usb_device *dev);
61
62
63 /**
64  * usb_reset resets the specified device by sending a RESET down the port 
65  * it is connected to. Returns 0 on success or < 0 on error.
66  */
67
68 s8 usb_reset(struct usb_device *dev);
69
70
71 /******************* Control Transfer **********************/
72 s8 usb_control_msg(struct usb_device *dev, u8 requesttype, u8 request, u16 value, u16 index, u16 length, u8 *buf, u16 timeout);
73 s8 usb_get_descriptor(struct usb_device *dev, u8 type, u8 index, u8 *buf, u8 size);
74 s8 usb_get_desc_dev_simple(struct usb_device *dev);
75 s8 usb_get_desc_dev(struct usb_device *dev);
76 s8 usb_get_desc_configuration(struct usb_device *dev, u8 index, struct usb_conf *conf);
77 s8 usb_get_desc_config_ext(struct usb_device *dev, u8 index, struct usb_conf *conf);
78
79 char *usb_get_string_simple(struct usb_device *dev, u8 index);
80 s8 usb_get_string(struct usb_device *dev, u8 index, u8 langid);
81
82 s8 usb_set_address(struct usb_device *dev, u8 address);
83 u8 usb_get_configuration(struct usb_device *dev);
84 s8 usb_set_configuration(struct usb_device *dev, u8 configuration);
85 s8 usb_set_altinterface(struct usb_device *dev, u8 alternate);
86
87
88 /******************* Bulk Transfer **********************/
89 s8 usb_bulk_write(struct usb_device *dev, u8 ep, u8 *buf, u8 size, u8 timeout);
90 s8 usb_bulk_read(struct usb_device *dev, u8 ep, u8 *buf, u8 size, u8 timeout);
91
92
93 /******************* Interrupt Transfer **********************/
94 s8 usb_interrupt_write(struct usb_device *dev, u8 ep, u8 *buf, u8 size, u8 timeout);
95 s8 usb_interrupt_read(struct usb_device *dev, u8 ep, u8 *buf, u8 size, u8 timeout);
96
97
98 /******************* Isochron Transfer **********************/
99 s8 usb_isochron_write(struct usb_device *dev, u8 ep, u8 *buf, u8 size, u8 timeout);
100 s8 usb_isochron_read(struct usb_device *dev, u8 ep, u8 *buf, u8 size, u8 timeout);
101
102 #endif  //_USB_H_