Gigibeat S Manual - redo r23795 to look like it was originally meant to look.
[kugel-rb.git] / firmware / export / usb.h
blobd432b39b1442db88fd2523ebdf1622f0ec85ff34
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 */
57 #ifdef HAVE_USB_POWER
58 #if CONFIG_KEYPAD == RECORDER_PAD
59 #define USBPOWER_BUTTON BUTTON_F1
60 #define USBPOWER_BTN_IGNORE BUTTON_ON
61 #elif CONFIG_KEYPAD == ONDIO_PAD
62 #define USBPOWER_BUTTON BUTTON_MENU
63 #define USBPOWER_BTN_IGNORE BUTTON_OFF
64 #elif (CONFIG_KEYPAD == IPOD_4G_PAD)
65 #define USBPOWER_BUTTON BUTTON_MENU
66 #define USBPOWER_BTN_IGNORE BUTTON_PLAY
67 #elif CONFIG_KEYPAD == IRIVER_H300_PAD
68 #define USBPOWER_BUTTON BUTTON_MODE
69 #define USBPOWER_BTN_IGNORE BUTTON_ON
70 #elif CONFIG_KEYPAD == GIGABEAT_PAD
71 #define USBPOWER_BUTTON BUTTON_MENU
72 #define USBPOWER_BTN_IGNORE BUTTON_POWER
73 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD) || \
74 (CONFIG_KEYPAD == MROBE100_PAD)
75 #define USBPOWER_BUTTON BUTTON_RIGHT
76 #define USBPOWER_BTN_IGNORE BUTTON_POWER
77 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
78 (CONFIG_KEYPAD == SANSA_C200_PAD) || \
79 (CONFIG_KEYPAD == SANSA_CLIP_PAD) || \
80 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
81 #define USBPOWER_BUTTON BUTTON_SELECT
82 #define USBPOWER_BTN_IGNORE BUTTON_POWER
83 #elif (CONFIG_KEYPAD == PHILIPS_SA9200_PAD)
84 #define USBPOWER_BUTTON BUTTON_PLAY
85 #define USBPOWER_BTN_IGNORE BUTTON_POWER
86 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
87 #define USBPOWER_BUTTON BUTTON_PLAYLIST
88 #define USBPOWER_BTN_IGNORE BUTTON_POWER
89 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
90 #define USBPOWER_BUTTON BUTTON_RIGHT
91 #define USBPOWER_BTN_IGNORE BUTTON_LEFT
92 #elif CONFIG_KEYPAD == COWOND2_PAD
93 #define USBPOWER_BUTTON BUTTON_MENU
94 #define USBPOWER_BTN_IGNORE BUTTON_MINUS
95 #endif
96 #endif /* HAVE_USB_POWER */
98 #ifdef HAVE_USBSTACK
99 /* USB class drivers */
100 enum {
101 #ifdef USB_ENABLE_STORAGE
102 USB_DRIVER_MASS_STORAGE,
103 #endif
104 #ifdef USB_ENABLE_SERIAL
105 USB_DRIVER_SERIAL,
106 #endif
107 #ifdef USB_ENABLE_CHARGING_ONLY
108 USB_DRIVER_CHARGING_ONLY,
109 #endif
110 #ifdef USB_ENABLE_HID
111 USB_DRIVER_HID,
112 #endif
113 USB_NUM_DRIVERS
116 struct usb_transfer_completion_event_data
118 unsigned char endpoint;
119 int dir;
120 int status;
121 int length;
122 void* data;
124 #endif /* HAVE_USBSTACK */
126 void usb_init(void);
127 void usb_enable(bool on);
128 void usb_attach(void);
129 void usb_start_monitoring(void);
130 void usb_close(void);
131 void usb_acknowledge(long id);
132 void usb_wait_for_disconnect(struct event_queue *q);
133 int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks);
134 bool usb_inserted(void); /* return the official value, what's been reported to the threads */
135 int usb_detect(void); /* return the raw hardware value - nothing/pc/charger */
136 /* For tick-less USB monitoring (USB_STATUS_BY_EVENT) */
137 void usb_status_event(int current_status);
138 #ifdef HAVE_USB_POWER
139 bool usb_powered(void);
140 #ifdef CONFIG_CHARGING
141 bool usb_charging_enable(bool on);
142 bool usb_charging_enabled(void);
143 #endif
144 #endif
145 #ifdef HAVE_USBSTACK
146 void usb_signal_transfer_completion(
147 struct usb_transfer_completion_event_data *event_data);
148 bool usb_driver_enabled(int driver);
149 bool usb_exclusive_storage(void); /* storage is available for usb */
150 void usb_storage_try_release_storage(void);
151 #endif
152 int usb_release_exclusive_storage(void);
154 #ifdef USB_FIREWIRE_HANDLING
155 bool firewire_detect(void);
156 void usb_firewire_connect_event(void);
157 #endif
159 #ifdef USB_ENABLE_HID
160 void usb_set_hid(bool enable);
161 #endif
163 #endif