Update the manual according to the changes in r26587 (PLA_EXIT and PLA_CANCEL on...
[kugel-rb.git] / firmware / export / usb.h
blob55b5f2cffb9804fd4bbf51576652da6d30cd3b55
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 #if defined(HAVE_USB_POWER) || defined(USB_DETECT_BY_DRV)
37 USB_POWERED, /* Event+State */
38 #endif
39 #ifdef USB_DETECT_BY_DRV
40 USB_UNPOWERED, /* Event */
41 #endif
42 #ifdef HAVE_LCD_BITMAP
43 USB_SCREENDUMP, /* State */
44 #endif
45 #if (CONFIG_STORAGE & STORAGE_MMC)
46 USB_REENABLE, /* Event */
47 #endif
48 #ifdef HAVE_USBSTACK
49 USB_TRANSFER_COMPLETION, /* Event */
50 #endif
51 #ifdef USB_FIREWIRE_HANDLING
52 USB_REQUEST_REBOOT, /* Event */
53 #endif
54 USB_QUIT, /* Event */
55 #if defined(HAVE_USB_CHARGING_ENABLE) && defined(HAVE_USBSTACK)
56 USB_CHARGER_UPDATE, /* Event */
57 #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 #elif (CONFIG_KEYPAD == IPOD_4G_PAD)
68 #define USBPOWER_BUTTON BUTTON_MENU
69 #define USBPOWER_BTN_IGNORE BUTTON_PLAY
70 #elif CONFIG_KEYPAD == IRIVER_H300_PAD
71 #define USBPOWER_BUTTON BUTTON_MODE
72 #define USBPOWER_BTN_IGNORE BUTTON_ON
73 #elif CONFIG_KEYPAD == GIGABEAT_PAD
74 #define USBPOWER_BUTTON BUTTON_MENU
75 #define USBPOWER_BTN_IGNORE BUTTON_POWER
76 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD) || \
77 (CONFIG_KEYPAD == MROBE100_PAD)
78 #define USBPOWER_BUTTON BUTTON_RIGHT
79 #define USBPOWER_BTN_IGNORE BUTTON_POWER
80 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
81 (CONFIG_KEYPAD == SANSA_C200_PAD) || \
82 (CONFIG_KEYPAD == SANSA_CLIP_PAD) || \
83 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
84 #define USBPOWER_BUTTON BUTTON_SELECT
85 #define USBPOWER_BTN_IGNORE BUTTON_POWER
86 #elif (CONFIG_KEYPAD == PHILIPS_SA9200_PAD)
87 #define USBPOWER_BUTTON BUTTON_PLAY
88 #define USBPOWER_BTN_IGNORE BUTTON_POWER
89 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
90 #define USBPOWER_BUTTON BUTTON_PLAYLIST
91 #define USBPOWER_BTN_IGNORE BUTTON_POWER
92 #elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD
93 #define USBPOWER_BUTTON BUTTON_SELECT
94 #define USBPOWER_BTN_IGNORE BUTTON_POWER
95 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
96 #define USBPOWER_BUTTON BUTTON_RIGHT
97 #define USBPOWER_BTN_IGNORE BUTTON_LEFT
98 #elif CONFIG_KEYPAD == COWON_D2_PAD
99 #define USBPOWER_BUTTON BUTTON_MENU
100 #define USBPOWER_BTN_IGNORE BUTTON_MINUS
101 #elif CONFIG_KEYPAD == ONDAVX747_PAD
102 #define USBPOWER_BUTTON BUTTON_VOL_UP
103 #define USBPOWER_BTN_IGNORE BUTTON_VOL_DOWN
104 #elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
105 #define USBPOWER_BUTTON BUTTON_REC
106 #define USBPOWER_BTN_IGNORE BUTTON_POWER
107 #endif
108 #endif /* HAVE_USB_POWER */
110 #ifdef HAVE_USBSTACK
111 /* USB class drivers */
112 enum {
113 #ifdef USB_ENABLE_STORAGE
114 USB_DRIVER_MASS_STORAGE,
115 #endif
116 #ifdef USB_ENABLE_SERIAL
117 USB_DRIVER_SERIAL,
118 #endif
119 #ifdef USB_ENABLE_CHARGING_ONLY
120 USB_DRIVER_CHARGING_ONLY,
121 #endif
122 #ifdef USB_ENABLE_HID
123 USB_DRIVER_HID,
124 #endif
125 USB_NUM_DRIVERS
128 struct usb_transfer_completion_event_data
130 unsigned char endpoint;
131 int dir;
132 int status;
133 int length;
134 void* data;
136 #endif /* HAVE_USBSTACK */
138 void usb_init(void) INIT_ATTR;
139 void usb_enable(bool on);
140 void usb_attach(void);
141 void usb_start_monitoring(void);
142 void usb_close(void);
143 void usb_acknowledge(long id);
144 void usb_wait_for_disconnect(struct event_queue *q);
145 int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks);
146 bool usb_inserted(void); /* return the official value, what's been reported to the threads */
147 int usb_detect(void); /* return the raw hardware value - nothing/pc/charger */
148 /* For tick-less USB monitoring (USB_STATUS_BY_EVENT) */
149 void usb_status_event(int current_status);
150 #ifdef HAVE_USB_POWER
151 bool usb_powered(void);
152 #ifdef HAVE_USB_CHARGING_ENABLE
153 enum {
154 USB_CHARGING_DISABLE,
155 USB_CHARGING_ENABLE,
156 USB_CHARGING_FORCE
158 /* called by app, implemented by usb_core on targets with rockbox usb
159 * or target-specific code on others
161 void usb_charging_enable(int state);
162 #ifdef HAVE_USBSTACK
163 void usb_charger_update(void);
164 #endif /* HAVE_USBSTACK */
165 #endif /* HAVE_USB_CHARGING_ENABLE */
166 #endif /* HAVE_USB_POWER */
167 #ifdef HAVE_USBSTACK
168 void usb_signal_transfer_completion(
169 struct usb_transfer_completion_event_data *event_data);
170 bool usb_driver_enabled(int driver);
171 bool usb_exclusive_storage(void); /* storage is available for usb */
172 void usb_storage_try_release_storage(void);
173 #endif
174 int usb_release_exclusive_storage(void);
176 #ifdef USB_FIREWIRE_HANDLING
177 bool firewire_detect(void);
178 void usb_firewire_connect_event(void);
179 #endif
181 #ifdef USB_ENABLE_HID
182 void usb_set_hid(bool enable);
183 #endif
185 #endif