2003-02-07 09:41:57 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Linus Nielsen Feltzing
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2003-02-07 09:41:57 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef _USB_H_
|
|
|
|
#define _USB_H_
|
|
|
|
|
|
|
|
#include "kernel.h"
|
2007-09-04 08:03:07 +00:00
|
|
|
#include "button.h"
|
|
|
|
|
2009-01-13 16:27:35 +00:00
|
|
|
#if defined(IPOD_COLOR) || defined(IPOD_4G) \
|
|
|
|
|| defined(IPOD_MINI) || defined(IPOD_MINI2G)
|
|
|
|
#define USB_FIREWIRE_HANDLING
|
|
|
|
#endif
|
|
|
|
|
2007-09-04 08:03:07 +00:00
|
|
|
/* Messages from usb_tick and thread states */
|
2008-02-27 19:08:30 +00:00
|
|
|
enum {
|
2009-01-22 22:05:04 +00:00
|
|
|
USB_EXTRACTED = 0, /* Event+State */
|
2009-01-13 16:27:35 +00:00
|
|
|
USB_INSERTED, /* Event+State */
|
2009-01-19 13:41:25 +00:00
|
|
|
#if defined(HAVE_USB_POWER) || defined(USB_DETECT_BY_DRV)
|
|
|
|
USB_POWERED, /* Event+State */
|
|
|
|
#endif
|
|
|
|
#ifdef USB_DETECT_BY_DRV
|
|
|
|
USB_UNPOWERED, /* Event */
|
2009-01-13 16:27:35 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
USB_SCREENDUMP, /* State */
|
|
|
|
#endif
|
|
|
|
#if (CONFIG_STORAGE & STORAGE_MMC)
|
|
|
|
USB_REENABLE, /* Event */
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_USBSTACK
|
|
|
|
USB_TRANSFER_COMPLETION, /* Event */
|
|
|
|
#endif
|
|
|
|
#ifdef USB_FIREWIRE_HANDLING
|
|
|
|
USB_REQUEST_REBOOT, /* Event */
|
|
|
|
#endif
|
|
|
|
USB_QUIT, /* Event */
|
2010-06-05 20:43:30 +00:00
|
|
|
#if defined(HAVE_USB_CHARGING_ENABLE) && defined(HAVE_USBSTACK)
|
|
|
|
USB_CHARGER_UPDATE, /* Event */
|
|
|
|
#endif
|
2008-02-27 19:08:30 +00:00
|
|
|
};
|
2007-09-04 08:03:07 +00:00
|
|
|
|
2008-02-27 19:08:30 +00:00
|
|
|
#ifdef HAVE_USB_POWER
|
2007-09-04 08:03:07 +00:00
|
|
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
|
|
|
#define USBPOWER_BUTTON BUTTON_F1
|
|
|
|
#define USBPOWER_BTN_IGNORE BUTTON_ON
|
|
|
|
#elif CONFIG_KEYPAD == ONDIO_PAD
|
|
|
|
#define USBPOWER_BUTTON BUTTON_MENU
|
|
|
|
#define USBPOWER_BTN_IGNORE BUTTON_OFF
|
|
|
|
#elif (CONFIG_KEYPAD == IPOD_4G_PAD)
|
|
|
|
#define USBPOWER_BUTTON BUTTON_MENU
|
|
|
|
#define USBPOWER_BTN_IGNORE BUTTON_PLAY
|
|
|
|
#elif CONFIG_KEYPAD == IRIVER_H300_PAD
|
2008-07-04 18:12:01 +00:00
|
|
|
#define USBPOWER_BUTTON BUTTON_MODE
|
2007-09-04 08:03:07 +00:00
|
|
|
#define USBPOWER_BTN_IGNORE BUTTON_ON
|
|
|
|
#elif CONFIG_KEYPAD == GIGABEAT_PAD
|
|
|
|
#define USBPOWER_BUTTON BUTTON_MENU
|
|
|
|
#define USBPOWER_BTN_IGNORE BUTTON_POWER
|
2008-01-09 07:24:43 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IRIVER_H10_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == MROBE100_PAD)
|
2007-11-22 20:51:00 +00:00
|
|
|
#define USBPOWER_BUTTON BUTTON_RIGHT
|
2007-09-04 08:03:07 +00:00
|
|
|
#define USBPOWER_BTN_IGNORE BUTTON_POWER
|
2007-09-06 03:28:58 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
|
2008-05-21 03:55:17 +00:00
|
|
|
(CONFIG_KEYPAD == SANSA_C200_PAD) || \
|
2008-11-09 06:17:21 +00:00
|
|
|
(CONFIG_KEYPAD == SANSA_CLIP_PAD) || \
|
2009-06-19 03:23:38 +00:00
|
|
|
(CONFIG_KEYPAD == SANSA_FUZE_PAD)
|
2007-09-04 08:03:07 +00:00
|
|
|
#define USBPOWER_BUTTON BUTTON_SELECT
|
|
|
|
#define USBPOWER_BTN_IGNORE BUTTON_POWER
|
2009-06-19 03:23:38 +00:00
|
|
|
#elif (CONFIG_KEYPAD == PHILIPS_SA9200_PAD)
|
|
|
|
#define USBPOWER_BUTTON BUTTON_PLAY
|
|
|
|
#define USBPOWER_BTN_IGNORE BUTTON_POWER
|
2008-06-27 18:40:25 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
|
|
|
|
#define USBPOWER_BUTTON BUTTON_PLAYLIST
|
|
|
|
#define USBPOWER_BTN_IGNORE BUTTON_POWER
|
2009-12-25 04:05:01 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD
|
2010-10-18 19:30:54 +00:00
|
|
|
#define USBPOWER_BUTTON BUTTON_LEFT
|
2009-12-25 04:05:01 +00:00
|
|
|
#define USBPOWER_BTN_IGNORE BUTTON_POWER
|
2009-05-25 21:10:45 +00:00
|
|
|
#elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
|
|
|
|
#define USBPOWER_BUTTON BUTTON_RIGHT
|
|
|
|
#define USBPOWER_BTN_IGNORE BUTTON_LEFT
|
2009-12-15 20:51:41 +00:00
|
|
|
#elif CONFIG_KEYPAD == COWON_D2_PAD
|
2009-10-20 20:44:30 +00:00
|
|
|
#define USBPOWER_BUTTON BUTTON_MENU
|
|
|
|
#define USBPOWER_BTN_IGNORE BUTTON_MINUS
|
2009-12-18 12:29:56 +00:00
|
|
|
#elif CONFIG_KEYPAD == ONDAVX747_PAD
|
|
|
|
#define USBPOWER_BUTTON BUTTON_VOL_UP
|
|
|
|
#define USBPOWER_BTN_IGNORE BUTTON_VOL_DOWN
|
2010-01-18 19:05:20 +00:00
|
|
|
#elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
|
|
|
|
#define USBPOWER_BUTTON BUTTON_REC
|
|
|
|
#define USBPOWER_BTN_IGNORE BUTTON_POWER
|
2007-09-04 08:03:07 +00:00
|
|
|
#endif
|
|
|
|
#endif /* HAVE_USB_POWER */
|
2003-02-07 09:41:57 +00:00
|
|
|
|
2008-02-25 23:43:11 +00:00
|
|
|
#ifdef HAVE_USBSTACK
|
|
|
|
/* USB class drivers */
|
|
|
|
enum {
|
2009-11-02 04:37:57 +00:00
|
|
|
#ifdef USB_ENABLE_STORAGE
|
2008-02-25 23:43:11 +00:00
|
|
|
USB_DRIVER_MASS_STORAGE,
|
2009-11-02 04:37:57 +00:00
|
|
|
#endif
|
|
|
|
#ifdef USB_ENABLE_SERIAL
|
2008-02-25 23:43:11 +00:00
|
|
|
USB_DRIVER_SERIAL,
|
2009-11-02 04:37:57 +00:00
|
|
|
#endif
|
|
|
|
#ifdef USB_ENABLE_CHARGING_ONLY
|
2008-03-06 21:25:09 +00:00
|
|
|
USB_DRIVER_CHARGING_ONLY,
|
2009-11-02 04:37:57 +00:00
|
|
|
#endif
|
|
|
|
#ifdef USB_ENABLE_HID
|
2009-04-19 21:17:18 +00:00
|
|
|
USB_DRIVER_HID,
|
2009-11-02 04:37:57 +00:00
|
|
|
#endif
|
2008-03-06 21:25:09 +00:00
|
|
|
USB_NUM_DRIVERS
|
2008-02-25 23:43:11 +00:00
|
|
|
};
|
2009-04-18 21:32:41 +00:00
|
|
|
|
2008-02-27 19:08:30 +00:00
|
|
|
struct usb_transfer_completion_event_data
|
|
|
|
{
|
|
|
|
unsigned char endpoint;
|
2008-10-03 22:43:16 +00:00
|
|
|
int dir;
|
2008-02-27 19:08:30 +00:00
|
|
|
int status;
|
|
|
|
int length;
|
|
|
|
void* data;
|
|
|
|
};
|
2009-05-16 15:30:09 +00:00
|
|
|
#endif /* HAVE_USBSTACK */
|
2008-02-25 23:43:11 +00:00
|
|
|
|
2010-03-03 23:20:32 +00:00
|
|
|
void usb_init(void) INIT_ATTR;
|
2005-12-06 12:12:29 +00:00
|
|
|
void usb_enable(bool on);
|
2009-01-19 13:41:25 +00:00
|
|
|
void usb_attach(void);
|
2003-02-07 09:41:57 +00:00
|
|
|
void usb_start_monitoring(void);
|
2008-05-10 18:00:11 +00:00
|
|
|
void usb_close(void);
|
2005-01-30 15:16:58 +00:00
|
|
|
void usb_acknowledge(long id);
|
2003-02-07 09:41:57 +00:00
|
|
|
void usb_wait_for_disconnect(struct event_queue *q);
|
|
|
|
int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks);
|
2003-07-03 22:11:14 +00:00
|
|
|
bool usb_inserted(void); /* return the official value, what's been reported to the threads */
|
2007-09-04 08:03:07 +00:00
|
|
|
int usb_detect(void); /* return the raw hardware value - nothing/pc/charger */
|
2009-01-14 07:01:49 +00:00
|
|
|
/* For tick-less USB monitoring (USB_STATUS_BY_EVENT) */
|
|
|
|
void usb_status_event(int current_status);
|
2005-06-23 02:18:29 +00:00
|
|
|
#ifdef HAVE_USB_POWER
|
|
|
|
bool usb_powered(void);
|
2010-06-05 10:05:27 +00:00
|
|
|
#ifdef HAVE_USB_CHARGING_ENABLE
|
|
|
|
enum {
|
|
|
|
USB_CHARGING_DISABLE,
|
|
|
|
USB_CHARGING_ENABLE,
|
|
|
|
USB_CHARGING_FORCE
|
|
|
|
};
|
|
|
|
/* called by app, implemented by usb_core on targets with rockbox usb
|
|
|
|
* or target-specific code on others
|
|
|
|
*/
|
|
|
|
void usb_charging_enable(int state);
|
2010-06-05 20:43:30 +00:00
|
|
|
#ifdef HAVE_USBSTACK
|
|
|
|
void usb_charger_update(void);
|
|
|
|
#endif /* HAVE_USBSTACK */
|
|
|
|
#endif /* HAVE_USB_CHARGING_ENABLE */
|
|
|
|
#endif /* HAVE_USB_POWER */
|
2008-02-27 19:08:30 +00:00
|
|
|
#ifdef HAVE_USBSTACK
|
2009-04-18 18:17:29 +00:00
|
|
|
void usb_signal_transfer_completion(
|
|
|
|
struct usb_transfer_completion_event_data *event_data);
|
2008-02-27 19:08:30 +00:00
|
|
|
bool usb_driver_enabled(int driver);
|
2009-01-13 16:27:35 +00:00
|
|
|
bool usb_exclusive_storage(void); /* storage is available for usb */
|
2009-03-08 18:45:19 +00:00
|
|
|
void usb_storage_try_release_storage(void);
|
2008-02-27 19:08:30 +00:00
|
|
|
#endif
|
2009-02-28 15:16:54 +00:00
|
|
|
int usb_release_exclusive_storage(void);
|
2008-02-27 19:08:30 +00:00
|
|
|
|
2009-01-13 16:27:35 +00:00
|
|
|
#ifdef USB_FIREWIRE_HANDLING
|
2008-02-27 19:08:30 +00:00
|
|
|
bool firewire_detect(void);
|
2009-01-22 22:05:04 +00:00
|
|
|
void usb_firewire_connect_event(void);
|
2008-02-27 19:08:30 +00:00
|
|
|
#endif
|
2003-02-07 09:41:57 +00:00
|
|
|
|
2009-10-23 13:29:19 +00:00
|
|
|
#ifdef USB_ENABLE_HID
|
|
|
|
void usb_set_hid(bool enable);
|
|
|
|
#endif
|
|
|
|
|
2003-02-07 09:41:57 +00:00
|
|
|
#endif
|