Frank Gevaerts | f0b4a32 | 2008-03-06 21:25:09 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
Michael Sevakis | 1eed012 | 2008-04-18 17:05:15 +0000 | [diff] [blame] | 8 | * $Id$ |
Frank Gevaerts | f0b4a32 | 2008-03-06 21:25:09 +0000 | [diff] [blame] | 9 | * |
| 10 | * Copyright (C) 2008 Frank Gevaerts |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 12 | * 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 Gevaerts | f0b4a32 | 2008-03-06 21:25:09 +0000 | [diff] [blame] | 16 | * |
| 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 | |
| 27 | struct usb_class_driver { |
Frank Gevaerts | bec6aa3 | 2008-04-26 19:02:16 +0000 | [diff] [blame] | 28 | /* First some runtime data */ |
Frank Gevaerts | f0b4a32 | 2008-03-06 21:25:09 +0000 | [diff] [blame] | 29 | bool enabled; |
Frank Gevaerts | bec6aa3 | 2008-04-26 19:02:16 +0000 | [diff] [blame] | 30 | 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 Gevaerts | f0b4a32 | 2008-03-06 21:25:09 +0000 | [diff] [blame] | 36 | bool needs_exclusive_ata; |
Frank Gevaerts | bec6aa3 | 2008-04-26 19:02:16 +0000 | [diff] [blame] | 37 | |
| 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 Gevaerts | f0b4a32 | 2008-03-06 21:25:09 +0000 | [diff] [blame] | 50 | |
| 51 | /* Asks the driver to put the interface descriptor and all other |
Frank Gevaerts | bec6aa3 | 2008-04-26 19:02:16 +0000 | [diff] [blame] | 52 | 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 Gevaerts | f0b4a32 | 2008-03-06 21:25:09 +0000 | [diff] [blame] | 56 | |
| 57 | /* Tells the driver that a usb connection has been set up and is now |
Frank Gevaerts | bec6aa3 | 2008-04-26 19:02:16 +0000 | [diff] [blame] | 58 | ready to use. |
| 59 | Optional function */ |
| 60 | void (*init_connection)(void); |
Frank Gevaerts | f0b4a32 | 2008-03-06 21:25:09 +0000 | [diff] [blame] | 61 | |
| 62 | /* Initialises the driver. This can be called multiple times, |
| 63 | and should not perform any action that can disturb other threads |
Frank Gevaerts | bec6aa3 | 2008-04-26 19:02:16 +0000 | [diff] [blame] | 64 | (like getting the audio buffer) |
| 65 | Optional function */ |
Frank Gevaerts | f0b4a32 | 2008-03-06 21:25:09 +0000 | [diff] [blame] | 66 | void (*init)(void); |
| 67 | |
Frank Gevaerts | bec6aa3 | 2008-04-26 19:02:16 +0000 | [diff] [blame] | 68 | /* Tells the driver that the usb connection is no longer active |
| 69 | Optional function */ |
Frank Gevaerts | f0b4a32 | 2008-03-06 21:25:09 +0000 | [diff] [blame] | 70 | void (*disconnect)(void); |
| 71 | |
| 72 | /* Tells the driver that a usb transfer has been completed. Note that "in" |
Frank Gevaerts | bec6aa3 | 2008-04-26 19:02:16 +0000 | [diff] [blame] | 73 | is relative to the host |
| 74 | Optional function */ |
| 75 | void (*transfer_complete)(int ep,bool in, int status, int length); |
Frank Gevaerts | f0b4a32 | 2008-03-06 21:25:09 +0000 | [diff] [blame] | 76 | |
| 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 Gevaerts | bec6aa3 | 2008-04-26 19:02:16 +0000 | [diff] [blame] | 79 | it should return false. |
| 80 | Optional function */ |
Frank Gevaerts | f0b4a32 | 2008-03-06 21:25:09 +0000 | [diff] [blame] | 81 | bool (*control_request)(struct usb_ctrlrequest* req); |
Frank Gevaerts | 7451330 | 2008-03-10 20:55:24 +0000 | [diff] [blame] | 82 | |
| 83 | #ifdef HAVE_HOTSWAP |
| 84 | /* Tells the driver that a hotswappable disk/card was inserted or |
Frank Gevaerts | bec6aa3 | 2008-04-26 19:02:16 +0000 | [diff] [blame] | 85 | extracted |
| 86 | Optional function */ |
Frank Gevaerts | 7451330 | 2008-03-10 20:55:24 +0000 | [diff] [blame] | 87 | void (*notify_hotswap)(int volume, bool inserted); |
| 88 | #endif |
Frank Gevaerts | f0b4a32 | 2008-03-06 21:25:09 +0000 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | #endif |