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 (CONFIG_KEYPAD == PHILIPS_SA9200_PAD)
82 #define USBPOWER_BUTTON BUTTON_SELECT
83 #define USBPOWER_BTN_IGNORE BUTTON_POWER
84 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
85 #define USBPOWER_BUTTON BUTTON_PLAYLIST
86 #define USBPOWER_BTN_IGNORE BUTTON_POWER
88 #endif /* HAVE_USB_POWER */
91 /* USB class drivers */
93 USB_DRIVER_MASS_STORAGE
,
95 USB_DRIVER_CHARGING_ONLY
,
99 struct usb_transfer_completion_event_data
101 unsigned char endpoint
;
110 void usb_enable(bool on
);
111 void usb_attach(void);
112 void usb_start_monitoring(void);
113 void usb_close(void);
114 void usb_acknowledge(long id
);
115 void usb_wait_for_disconnect(struct event_queue
*q
);
116 int usb_wait_for_disconnect_w_tmo(struct event_queue
*q
, int ticks
);
117 bool usb_inserted(void); /* return the official value, what's been reported to the threads */
118 int usb_detect(void); /* return the raw hardware value - nothing/pc/charger */
119 /* For tick-less USB monitoring (USB_STATUS_BY_EVENT) */
120 void usb_status_event(int current_status
);
121 #ifdef HAVE_USB_POWER
122 bool usb_powered(void);
123 #ifdef CONFIG_CHARGING
124 bool usb_charging_enable(bool on
);
125 bool usb_charging_enabled(void);
129 void usb_signal_transfer_completion(
130 struct usb_transfer_completion_event_data
*event_data
);
131 bool usb_driver_enabled(int driver
);
132 bool usb_exclusive_storage(void); /* storage is available for usb */
133 void usb_storage_try_release_storage(void);
135 int usb_release_exclusive_storage(void);
137 #ifdef USB_FIREWIRE_HANDLING
138 bool firewire_detect(void);
139 void usb_firewire_connect_event(void);