Add "USB Hide Internal Drive" option for multidrive devices with software usb.
[maemo-rb.git] / firmware / export / usb.h
blobca3f72eaa46e3a2022fbabac076f5baca439b86a
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #ifndef _USB_H_
22 #define _USB_H_
24 #include "kernel.h"
25 #include "button.h"
27 #if defined(IPOD_COLOR) || defined(IPOD_4G) \
28 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
29 #define USB_FIREWIRE_HANDLING
30 #endif
32 /* Messages from usb_tick and thread states */
33 enum {
34 USB_EXTRACTED = 0, /* Event+State */
35 USB_INSERTED, /* Event+State */
36 USB_POWERED, /* Event+State - transitional indicator if no power */
37 #if defined(USB_DETECT_BY_DRV) || defined(USB_DETECT_BY_CORE)
38 USB_UNPOWERED, /* Event */
39 #endif
40 #ifdef HAVE_LCD_BITMAP
41 USB_SCREENDUMP, /* State */
42 #endif
43 #if (CONFIG_STORAGE & STORAGE_MMC)
44 USB_REENABLE, /* Event */
45 #endif
46 #ifdef HAVE_USBSTACK
47 USB_TRANSFER_COMPLETION, /* Event */
48 #endif
49 #ifdef USB_FIREWIRE_HANDLING
50 USB_REQUEST_REBOOT, /* Event */
51 #endif
52 USB_QUIT, /* Event */
53 #if defined(HAVE_USB_CHARGING_ENABLE) && defined(HAVE_USBSTACK)
54 USB_CHARGER_UPDATE, /* Event */
55 #endif
56 #ifdef HAVE_BOOTLOADER_USB_MODE
57 USB_HANDLED, /* Bootloader status code */
58 #endif
60 #ifdef HAVE_USB_POWER
61 #if CONFIG_KEYPAD == RECORDER_PAD
62 #define USBPOWER_BUTTON BUTTON_F1
63 #define USBPOWER_BTN_IGNORE BUTTON_ON
64 #elif CONFIG_KEYPAD == ONDIO_PAD
65 #define USBPOWER_BUTTON BUTTON_MENU
66 #define USBPOWER_BTN_IGNORE BUTTON_OFF
67 /*allow people to define this in config-target.h if they need it*/
68 #elif !defined(USBPOWER_BTN_IGNORE)
69 #define USBPOWER_BTN_IGNORE 0
70 #endif
71 #endif
73 #ifdef HAVE_USBSTACK
74 /* USB class drivers */
75 enum {
76 #ifdef USB_ENABLE_STORAGE
77 USB_DRIVER_MASS_STORAGE,
78 #endif
79 #ifdef USB_ENABLE_SERIAL
80 USB_DRIVER_SERIAL,
81 #endif
82 #ifdef USB_ENABLE_CHARGING_ONLY
83 USB_DRIVER_CHARGING_ONLY,
84 #endif
85 #ifdef USB_ENABLE_HID
86 USB_DRIVER_HID,
87 #endif
88 USB_NUM_DRIVERS
91 struct usb_transfer_completion_event_data
93 unsigned char endpoint;
94 int dir;
95 int status;
96 int length;
97 void* data;
99 #endif /* HAVE_USBSTACK */
101 void usb_init(void) INIT_ATTR;
102 void usb_enable(bool on);
103 void usb_attach(void);
104 void usb_start_monitoring(void);
105 void usb_close(void);
106 void usb_acknowledge(long id);
107 void usb_wait_for_disconnect(struct event_queue *q);
108 int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks);
109 bool usb_inserted(void); /* return the official value, what's been reported to the threads */
110 int usb_detect(void); /* return the raw hardware value - nothing/pc/charger */
111 /* For tick-less USB monitoring (USB_STATUS_BY_EVENT) */
112 void usb_status_event(int current_status);
113 #ifdef HAVE_USB_POWER
114 bool usb_powered(void);
115 #ifdef HAVE_USB_CHARGING_ENABLE
116 enum {
117 USB_CHARGING_DISABLE,
118 USB_CHARGING_ENABLE,
119 USB_CHARGING_FORCE
121 /* called by app, implemented by usb_core on targets with rockbox usb
122 * or target-specific code on others
124 void usb_charging_enable(int state);
125 #ifdef HAVE_USBSTACK
126 void usb_charger_update(void);
127 #endif /* HAVE_USBSTACK */
128 #endif /* HAVE_USB_CHARGING_ENABLE */
129 #endif /* HAVE_USB_POWER */
130 #ifdef HAVE_USBSTACK
131 void usb_signal_transfer_completion(
132 struct usb_transfer_completion_event_data *event_data);
133 bool usb_driver_enabled(int driver);
134 bool usb_exclusive_storage(void); /* storage is available for usb */
135 void usb_storage_try_release_storage(void);
136 #endif
137 int usb_release_exclusive_storage(void);
139 #ifdef USB_FIREWIRE_HANDLING
140 bool firewire_detect(void);
141 void usb_firewire_connect_event(void);
142 #endif
144 #ifdef USB_ENABLE_HID
145 void usb_set_hid(bool enable);
146 #endif
148 #if defined(USB_ENABLE_STORAGE) && defined(HAVE_MULTIDRIVE)
149 void usb_set_skip_first_drive(bool skip);
150 #endif
152 #endif