forked from len0rd/rockbox
IAP: Reset IAP state upon headphone or dock unplug
Provides a semi-automatic way of recovering from desynchronization Change-Id: I527b0bacc22ef38c1e7213653e522ea1b0ac155d
This commit is contained in:
parent
80eca90481
commit
472a6a69c6
5 changed files with 93 additions and 15 deletions
|
@ -45,6 +45,10 @@
|
|||
#include "lcd.h" /* lcd_active() prototype */
|
||||
#endif
|
||||
|
||||
#if defined(IPOD_ACCESSORY_PROTOCOL) && (defined(IPOD_COLOR) || defined(IPOD_4G) || defined(IPOD_MINI) || defined(IPOD_MINI2G))
|
||||
#include "iap.h"
|
||||
#endif
|
||||
|
||||
static long lastbtn; /* Last valid button status */
|
||||
static long last_read; /* Last button status, for debouncing/filtering */
|
||||
static bool flipped; /* buttons can be flipped to match the LCD flip */
|
||||
|
@ -102,6 +106,12 @@ static int hp_detect_callback(struct timeout *tmo)
|
|||
/* Try to post only transistions */
|
||||
const long id = tmo->data ? SYS_PHONE_PLUGGED : SYS_PHONE_UNPLUGGED;
|
||||
button_queue_post_remove_head(id, 0);
|
||||
|
||||
#if defined(IPOD_ACCESSORY_PROTOCOL) && (defined(IPOD_COLOR) || defined(IPOD_4G) || defined(IPOD_MINI) || defined(IPOD_MINI2G))
|
||||
if (id == SYS_PHONE_UNPLUGGED)
|
||||
iap_reset_state(1);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
/*misc.c:hp_unplug_change*/
|
||||
}
|
||||
|
@ -113,6 +123,7 @@ static int lo_detect_callback(struct timeout *tmo)
|
|||
/* Try to post only transistions */
|
||||
const long id = tmo->data ? SYS_LINEOUT_PLUGGED : SYS_LINEOUT_UNPLUGGED;
|
||||
button_queue_post_remove_head(id, 0);
|
||||
|
||||
return 0;
|
||||
/*misc.c:lo_unplug_change*/
|
||||
}
|
||||
|
|
|
@ -37,5 +37,6 @@ const unsigned char *iap_get_serbuf(void);
|
|||
#ifdef HAVE_LINE_REC
|
||||
extern bool iap_record(bool onoff);
|
||||
#endif
|
||||
|
||||
void iap_reset_state(int port); /* 0 is dock, 1 is headphone */
|
||||
bool dbg_iap(void);
|
||||
#endif
|
||||
|
|
|
@ -51,6 +51,10 @@
|
|||
#include "gui/skin_engine/skin_engine.h"
|
||||
#endif
|
||||
|
||||
#if defined(IPOD_ACCESSORY_PROTOCOL)
|
||||
#include "iap.h"
|
||||
#endif
|
||||
|
||||
/* Conditions under which we want the entire driver */
|
||||
#if !defined(BOOTLOADER) || \
|
||||
(defined(HAVE_USBSTACK) && defined(HAVE_BOOTLOADER_USB_MODE)) || \
|
||||
|
@ -521,6 +525,10 @@ static void NORETURN_ATTR usb_thread(void)
|
|||
if(usb_state == USB_POWERED || usb_state == USB_INSERTED)
|
||||
usb_stack_enable(false);
|
||||
|
||||
#ifdef IPOD_ACCESSORY_PROTOCOL
|
||||
iap_reset_state(0);
|
||||
#endif
|
||||
|
||||
/* Only disable the USB slave mode if we really have enabled
|
||||
it. Some expected acks may not have been received. */
|
||||
if(usb_state == USB_INSERTED)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue