blob: bda0b7663c29df04d16f1e74f1f9d8a4f98ce34a [file] [log] [blame]
Frank Gevaertsf0b4a322008-03-06 21:25:09 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
Michael Sevakis1eed0122008-04-18 17:05:15 +00008 * $Id$
Frank Gevaertsf0b4a322008-03-06 21:25:09 +00009 *
10 * Copyright (C) 2008 Frank Gevaerts
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Frank Gevaertsf0b4a322008-03-06 21:25:09 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef _USB_CLASS_DRIVER_H_
23#define _USB_CLASS_DRIVER_H_
24
25/* Common api, implemented by all class drivers */
26
27struct usb_class_driver {
Frank Gevaertsbec6aa32008-04-26 19:02:16 +000028 /* First some runtime data */
Frank Gevaertsf0b4a322008-03-06 21:25:09 +000029 bool enabled;
Frank Gevaertsbec6aa32008-04-26 19:02:16 +000030 int first_interface;
31 int last_interface;
32
33 /* Driver api starts here */
34
35 /* Set this to true if the driver needs exclusive disk access (e.g. usb storage) */
Frank Gevaertsf0b4a322008-03-06 21:25:09 +000036 bool needs_exclusive_ata;
Frank Gevaertsbec6aa32008-04-26 19:02:16 +000037
38 /* Tells the driver what its first interface number will be. The driver
39 returns the number of the first available interface for the next driver
40 (i.e. a driver with one interface will return interface+1)
41 A driver must have at least one interface
42 Mandatory function */
43 int (*set_first_interface)(int interface);
44
45 /* Tells the driver what its first endpoint pair number will be. The driver
46 returns the number of the first available endpoint pair for the next
47 driver (i.e. a driver with one endpoint pair will return endpoint +1)
48 Mandatory function */
49 int (*set_first_endpoint)(int endpoint);
Frank Gevaertsf0b4a322008-03-06 21:25:09 +000050
51 /* Asks the driver to put the interface descriptor and all other
Frank Gevaertsbec6aa32008-04-26 19:02:16 +000052 needed descriptor for this driver at dest.
53 Returns the number of bytes taken by these descriptors.
54 Mandatory function */
55 int (*get_config_descriptor)(unsigned char *dest, int max_packet_size);
Frank Gevaertsf0b4a322008-03-06 21:25:09 +000056
57 /* Tells the driver that a usb connection has been set up and is now
Frank Gevaertsbec6aa32008-04-26 19:02:16 +000058 ready to use.
59 Optional function */
60 void (*init_connection)(void);
Frank Gevaertsf0b4a322008-03-06 21:25:09 +000061
62 /* Initialises the driver. This can be called multiple times,
63 and should not perform any action that can disturb other threads
Frank Gevaertsbec6aa32008-04-26 19:02:16 +000064 (like getting the audio buffer)
65 Optional function */
Frank Gevaertsf0b4a322008-03-06 21:25:09 +000066 void (*init)(void);
67
Frank Gevaertsbec6aa32008-04-26 19:02:16 +000068 /* Tells the driver that the usb connection is no longer active
69 Optional function */
Frank Gevaertsf0b4a322008-03-06 21:25:09 +000070 void (*disconnect)(void);
71
72 /* Tells the driver that a usb transfer has been completed. Note that "in"
Frank Gevaertsbec6aa32008-04-26 19:02:16 +000073 is relative to the host
74 Optional function */
75 void (*transfer_complete)(int ep,bool in, int status, int length);
Frank Gevaertsf0b4a322008-03-06 21:25:09 +000076
77 /* Tells the driver that a control request has come in. If the driver is
78 able to handle it, it should ack the request, and return true. Otherwise
Frank Gevaertsbec6aa32008-04-26 19:02:16 +000079 it should return false.
80 Optional function */
Frank Gevaertsf0b4a322008-03-06 21:25:09 +000081 bool (*control_request)(struct usb_ctrlrequest* req);
Frank Gevaerts74513302008-03-10 20:55:24 +000082
83#ifdef HAVE_HOTSWAP
84 /* Tells the driver that a hotswappable disk/card was inserted or
Frank Gevaertsbec6aa32008-04-26 19:02:16 +000085 extracted
86 Optional function */
Frank Gevaerts74513302008-03-10 20:55:24 +000087 void (*notify_hotswap)(int volume, bool inserted);
88#endif
Frank Gevaertsf0b4a322008-03-06 21:25:09 +000089};
90
91#endif