merge 19488 back from the 3.1 branch
[kugel-rb.git] / firmware / export / usb.h
blob00517b247568c51313b0b29ac04f1cf989de496d
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 /* Messages from usb_tick and thread states */
28 enum {
29 USB_INSERTED,
30 USB_EXTRACTED,
31 USB_REENABLE,
32 USB_POWERED,
33 USB_TRANSFER_COMPLETION,
34 USB_REQUEST_DISK,
35 USB_RELEASE_DISK,
36 USB_REQUEST_REBOOT,
37 USB_QUIT,
41 #ifdef HAVE_USB_POWER
42 #if CONFIG_KEYPAD == RECORDER_PAD
43 #define USBPOWER_BUTTON BUTTON_F1
44 #define USBPOWER_BTN_IGNORE BUTTON_ON
45 #elif CONFIG_KEYPAD == ONDIO_PAD
46 #define USBPOWER_BUTTON BUTTON_MENU
47 #define USBPOWER_BTN_IGNORE BUTTON_OFF
48 #elif (CONFIG_KEYPAD == IPOD_4G_PAD)
49 #define USBPOWER_BUTTON BUTTON_MENU
50 #define USBPOWER_BTN_IGNORE BUTTON_PLAY
51 #elif CONFIG_KEYPAD == IRIVER_H300_PAD
52 #define USBPOWER_BUTTON BUTTON_MODE
53 #define USBPOWER_BTN_IGNORE BUTTON_ON
54 #elif CONFIG_KEYPAD == GIGABEAT_PAD
55 #define USBPOWER_BUTTON BUTTON_MENU
56 #define USBPOWER_BTN_IGNORE BUTTON_POWER
57 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
58 #define USBPOWER_BUTTON BUTTON_MENU
59 #define USBPOWER_BTN_IGNORE BUTTON_BACK
60 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD) || \
61 (CONFIG_KEYPAD == MROBE100_PAD)
62 #define USBPOWER_BUTTON BUTTON_RIGHT
63 #define USBPOWER_BTN_IGNORE BUTTON_POWER
64 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
65 (CONFIG_KEYPAD == SANSA_C200_PAD) || \
66 (CONFIG_KEYPAD == SANSA_CLIP_PAD) || \
67 (CONFIG_KEYPAD == SANSA_FUZE_PAD) || \
68 (CONFIG_KEYPAD == PHILIPS_SA9200_PAD)
69 #define USBPOWER_BUTTON BUTTON_SELECT
70 #define USBPOWER_BTN_IGNORE BUTTON_POWER
71 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
72 #define USBPOWER_BUTTON BUTTON_PLAYLIST
73 #define USBPOWER_BTN_IGNORE BUTTON_POWER
74 #endif
75 #endif /* HAVE_USB_POWER */
77 #ifdef HAVE_USBSTACK
78 /* USB class drivers */
79 enum {
80 USB_DRIVER_MASS_STORAGE,
81 USB_DRIVER_SERIAL,
82 USB_DRIVER_CHARGING_ONLY,
83 USB_NUM_DRIVERS
85 #endif
86 #ifdef HAVE_USBSTACK
87 struct usb_transfer_completion_event_data
89 unsigned char endpoint;
90 int dir;
91 int status;
92 int length;
93 void* data;
95 #endif
98 void usb_init(void);
99 void usb_enable(bool on);
100 void usb_start_monitoring(void);
101 void usb_close(void);
102 void usb_acknowledge(long id);
103 void usb_wait_for_disconnect(struct event_queue *q);
104 int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks);
105 bool usb_inserted(void); /* return the official value, what's been reported to the threads */
106 int usb_detect(void); /* return the raw hardware value - nothing/pc/charger */
107 #ifdef HAVE_USB_POWER
108 bool usb_powered(void);
109 #ifdef CONFIG_CHARGING
110 bool usb_charging_enable(bool on);
111 bool usb_charging_enabled(void);
112 #endif
113 #endif
114 #ifdef HAVE_USBSTACK
115 void usb_signal_transfer_completion(struct usb_transfer_completion_event_data* event_data);
116 bool usb_driver_enabled(int driver);
117 bool usb_exclusive_ata(void); /* ata is available for usb */
118 void usb_request_exclusive_ata(void);
119 void usb_release_exclusive_ata(void);
120 #endif
122 #if defined(IPOD_COLOR) || defined(IPOD_4G) \
123 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
124 bool firewire_detect(void);
125 #endif
127 #endif