carlu: merge usb-frontend context carlusb into generic carlu struct
[carl9170fw.git] / tools / carlu / src / usb.h
1 /*
2  * carl9170user - userspace testing utility for ar9170 devices
3  *
4  * USB back-end API declaration
5  *
6  * Copyright 2009, 2010 Christian Lamparter <chunkeey@googlemail.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 #ifndef __CARL9170USER_USB_H
24 #define __CARL9170USER_USB_H
25
26 #include "SDL.h"
27 #include "SDL_thread.h"
28 #include "libusb.h"
29 #include "frame.h"
30 #include "list.h"
31
32 #include "fwcmd.h"
33 #include <unistd.h>
34 #include "carlu.h"
35
36 #define AR9170_RX_BULK_BUFS             16
37 #define AR9170_RX_BULK_BUF_SIZE         8192
38 #define AR9170_RX_BULK_IRQ_SIZE         64
39
40 /* endpoints */
41 #define AR9170_EP_TX                            (LIBUSB_ENDPOINT_OUT | AR9170_USB_EP_TX)
42 #define AR9170_EP_RX                            (LIBUSB_ENDPOINT_IN  | AR9170_USB_EP_RX)
43 #define AR9170_EP_IRQ                           (LIBUSB_ENDPOINT_IN  | AR9170_USB_EP_IRQ)
44 #define AR9170_EP_CMD                           (LIBUSB_ENDPOINT_OUT | AR9170_USB_EP_CMD)
45
46 #define AR9170_TX_MAX_ACTIVE_URBS               8
47
48 #define CARL9170_FIRMWARE_FILE "/lib/firmware/carl9170-1"
49
50 struct carlu;
51
52 void carlusb_reset_txep(struct carlu *ar);
53
54 int usb_init(void);
55 void usb_exit(void);
56
57 struct carlu *carlusb_probe(void);
58 void carlusb_close(struct carlu *ar);
59
60 void carlusb_tx(struct carlu *ar, struct frame *frame);
61 int carlusb_fw_check(struct carlu *ar);
62
63 int carlusb_cmd(struct carlu *_ar, uint8_t oid, uint8_t *cmd, size_t clen,
64                 uint8_t *rsp, size_t rlen);
65
66 int carlusb_print_known_devices(void);
67
68 #endif /* __CARL9170USER_USB_H */