1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 ****************************************************************************/
27 #if defined(IPOD_COLOR) || defined(IPOD_4G) \
28 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
29 #define USB_FIREWIRE_HANDLING
32 /* Messages from usb_tick and thread states */
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 */
39 #ifdef USB_DETECT_BY_DRV
40 USB_UNPOWERED
, /* Event */
42 #ifdef HAVE_LCD_BITMAP
43 USB_SCREENDUMP
, /* State */
45 #if (CONFIG_STORAGE & STORAGE_MMC)
46 USB_REENABLE
, /* Event */
49 USB_TRANSFER_COMPLETION
, /* Event */
51 #ifdef USB_FIREWIRE_HANDLING
52 USB_REQUEST_REBOOT
, /* Event */
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 == PHILIPS_HDD6330_PAD
90 #define USBPOWER_BUTTON BUTTON_SELECT
91 #define USBPOWER_BTN_IGNORE BUTTON_POWER
92 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
93 #define USBPOWER_BUTTON BUTTON_RIGHT
94 #define USBPOWER_BTN_IGNORE BUTTON_LEFT
95 #elif CONFIG_KEYPAD == COWON_D2_PAD
96 #define USBPOWER_BUTTON BUTTON_MENU
97 #define USBPOWER_BTN_IGNORE BUTTON_MINUS
98 #elif CONFIG_KEYPAD == ONDAVX747_PAD
99 #define USBPOWER_BUTTON BUTTON_VOL_UP
100 #define USBPOWER_BTN_IGNORE BUTTON_VOL_DOWN
101 #elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
102 #define USBPOWER_BUTTON BUTTON_REC
103 #define USBPOWER_BTN_IGNORE BUTTON_POWER
105 #endif /* HAVE_USB_POWER */
108 /* USB class drivers */
110 #ifdef USB_ENABLE_STORAGE
111 USB_DRIVER_MASS_STORAGE
,
113 #ifdef USB_ENABLE_SERIAL
116 #ifdef USB_ENABLE_CHARGING_ONLY
117 USB_DRIVER_CHARGING_ONLY
,
119 #ifdef USB_ENABLE_HID
125 struct usb_transfer_completion_event_data
127 unsigned char endpoint
;
133 #endif /* HAVE_USBSTACK */
136 void usb_enable(bool on
);
137 void usb_attach(void);
138 void usb_start_monitoring(void);
139 void usb_close(void);
140 void usb_acknowledge(long id
);
141 void usb_wait_for_disconnect(struct event_queue
*q
);
142 int usb_wait_for_disconnect_w_tmo(struct event_queue
*q
, int ticks
);
143 bool usb_inserted(void); /* return the official value, what's been reported to the threads */
144 int usb_detect(void); /* return the raw hardware value - nothing/pc/charger */
145 /* For tick-less USB monitoring (USB_STATUS_BY_EVENT) */
146 void usb_status_event(int current_status
);
147 #ifdef HAVE_USB_POWER
148 bool usb_powered(void);
149 #ifdef CONFIG_CHARGING
150 bool usb_charging_enable(bool on
);
151 bool usb_charging_enabled(void);
155 void usb_signal_transfer_completion(
156 struct usb_transfer_completion_event_data
*event_data
);
157 bool usb_driver_enabled(int driver
);
158 bool usb_exclusive_storage(void); /* storage is available for usb */
159 void usb_storage_try_release_storage(void);
161 int usb_release_exclusive_storage(void);
163 #ifdef USB_FIREWIRE_HANDLING
164 bool firewire_detect(void);
165 void usb_firewire_connect_event(void);
168 #ifdef USB_ENABLE_HID
169 void usb_set_hid(bool enable
);