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_
|
|
|
|
|
2011-12-19 20:12:52 +00:00
|
|
|
#include "config.h"
|
2003-02-07 09:41:57 +00:00
|
|
|
#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 */
|
2011-12-15 00:14:36 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
USB_SCREENDUMP = -1, /* State */
|
|
|
|
#endif
|
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 */
|
2011-12-15 00:14:36 +00:00
|
|
|
USB_POWERED, /* State - transitional indicator if no power */
|
2009-01-13 16:27:35 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_MMC)
|
|
|
|
USB_REENABLE, /* Event */
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_USBSTACK
|
|
|
|
USB_TRANSFER_COMPLETION, /* Event */
|
2012-12-07 12:37:26 +00:00
|
|
|
USB_NOTIFY_SET_ADDR, /* Event */
|
|
|
|
USB_NOTIFY_SET_CONFIG, /* Event */
|
2009-01-13 16:27:35 +00:00
|
|
|
#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
|
2011-01-15 08:19:30 +00:00
|
|
|
#ifdef HAVE_BOOTLOADER_USB_MODE
|
|
|
|
USB_HANDLED, /* Bootloader status code */
|
|
|
|
#endif
|
2008-02-27 19:08:30 +00:00
|
|
|
};
|
2011-12-15 00:14:36 +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
|
2011-05-16 21:10:31 +00:00
|
|
|
/*allow people to define this in config-target.h if they need it*/
|
|
|
|
#elif !defined(USBPOWER_BTN_IGNORE)
|
2011-05-16 20:27:14 +00:00
|
|
|
#define USBPOWER_BTN_IGNORE 0
|
|
|
|
#endif
|
2007-09-04 08:03:07 +00:00
|
|
|
#endif
|
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);
|
2011-12-19 20:12:52 +00:00
|
|
|
void usb_start_monitoring(void) INIT_ATTR;
|
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);
|
2012-12-07 12:37:26 +00:00
|
|
|
void usb_signal_notify(long id, intptr_t 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 */
|
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
|
|
|
|
|
2011-09-09 16:15:35 +00:00
|
|
|
#if defined(USB_ENABLE_STORAGE) && defined(HAVE_MULTIDRIVE)
|
|
|
|
void usb_set_skip_first_drive(bool skip);
|
|
|
|
#endif
|
|
|
|
|
2011-12-31 18:43:41 +00:00
|
|
|
#if !defined(SIMULATOR) && !defined(USB_NONE)
|
|
|
|
void usb_init_device(void);
|
|
|
|
#endif
|
|
|
|
|
2003-02-07 09:41:57 +00:00
|
|
|
#endif
|