From 537c7546f946d266e55fdbce03558352a3342908 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Tue, 26 Sep 2006 10:03:56 +0000 Subject: Patch #4899 by Robert Keevil - Automatic pause on iPod when removing the headphones git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11057 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/button.c | 28 ++++++++++++++++++++++++++++ firmware/export/button.h | 3 +++ firmware/export/config-ipod4g.h | 3 +++ firmware/export/config-ipodcolor.h | 3 +++ firmware/export/config-ipodnano.h | 3 +++ firmware/export/config-ipodvideo.h | 3 +++ firmware/export/kernel.h | 2 ++ 7 files changed, 45 insertions(+) (limited to 'firmware') diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 5add6cb817..0042d9b8eb 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c @@ -92,6 +92,10 @@ static bool remote_button_hold_only(void); int int_btn = BUTTON_NONE; #endif +#ifdef HAVE_HEADPHONE_DETECTION +bool phones_present = false; +#endif + #if (CONFIG_KEYPAD == IPOD_4G_PAD) && !defined(IPOD_MINI) static void opto_i2c_init(void) { @@ -433,6 +437,23 @@ static void button_tick(void) } #endif +#ifdef HAVE_HEADPHONE_DETECTION + if ( headphones_inserted() ) + { + if (! phones_present ) + { + queue_post(&button_queue, SYS_PHONE_PLUGGED, NULL); + phones_present = true; + } + } else { + if ( phones_present ) + { + queue_post(&button_queue, SYS_PHONE_UNPLUGGED, NULL); + phones_present = false; + } + } +#endif + btn = button_read(); /* Find out if a key has been released */ @@ -1327,3 +1348,10 @@ void button_clear_queue(void) queue_clear(&button_queue); } +#ifdef HAVE_HEADPHONE_DETECTION +bool headphones_inserted(void) +{ + return (GPIOA_INPUT_VAL & 0x80)?true:false; +} +#endif + diff --git a/firmware/export/button.h b/firmware/export/button.h index 0e11da9da5..39dfbff6fa 100644 --- a/firmware/export/button.h +++ b/firmware/export/button.h @@ -54,6 +54,9 @@ bool button_hold(void); #ifdef HAS_REMOTE_BUTTON_HOLD bool remote_button_hold(void); #endif +#ifdef HAVE_HEADPHONE_DETECTION +bool headphones_inserted(void); +#endif #define BUTTON_NONE 0x00000000 diff --git a/firmware/export/config-ipod4g.h b/firmware/export/config-ipod4g.h index a5f186782f..2e8c4dcc33 100644 --- a/firmware/export/config-ipod4g.h +++ b/firmware/export/config-ipod4g.h @@ -109,6 +109,9 @@ /* Define this if you have adjustable CPU frequency */ #define HAVE_ADJUSTABLE_CPU_FREQ +/* Define this if you can detect headphones */ +#define HAVE_HEADPHONE_DETECTION + #define BOOTFILE_EXT "ipod" #define BOOTFILE "rockbox." BOOTFILE_EXT diff --git a/firmware/export/config-ipodcolor.h b/firmware/export/config-ipodcolor.h index 3366baa8ea..964f103214 100644 --- a/firmware/export/config-ipodcolor.h +++ b/firmware/export/config-ipodcolor.h @@ -105,6 +105,9 @@ /* Define this if you have adjustable CPU frequency */ #define HAVE_ADJUSTABLE_CPU_FREQ +/* Define this if you can detect headphones */ +#define HAVE_HEADPHONE_DETECTION + #define BOOTFILE_EXT "ipod" #define BOOTFILE "rockbox." BOOTFILE_EXT diff --git a/firmware/export/config-ipodnano.h b/firmware/export/config-ipodnano.h index c077c381f8..03f5b8c753 100644 --- a/firmware/export/config-ipodnano.h +++ b/firmware/export/config-ipodnano.h @@ -110,6 +110,9 @@ /* Define this if you have adjustable CPU frequency */ #define HAVE_ADJUSTABLE_CPU_FREQ +/* Define this if you can detect headphones */ +#define HAVE_HEADPHONE_DETECTION + #define BOOTFILE_EXT "ipod" #define BOOTFILE "rockbox." BOOTFILE_EXT diff --git a/firmware/export/config-ipodvideo.h b/firmware/export/config-ipodvideo.h index 5cea64deb4..4781a2c887 100644 --- a/firmware/export/config-ipodvideo.h +++ b/firmware/export/config-ipodvideo.h @@ -110,6 +110,9 @@ /* Define this if you have adjustable CPU frequency */ #define HAVE_ADJUSTABLE_CPU_FREQ +/* Define this if you can detect headphones */ +#define HAVE_HEADPHONE_DETECTION + #define BOOTFILE_EXT "ipod" #define BOOTFILE "rockbox." BOOTFILE_EXT diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h index 482516b9dc..fcab2d923c 100644 --- a/firmware/export/kernel.h +++ b/firmware/export/kernel.h @@ -46,6 +46,8 @@ #define SYS_FS_CHANGED ((SYS_EVENT | ((long)9 << 27))) #define SYS_CHARGER_CONNECTED ((SYS_EVENT | ((long)10 << 27))) #define SYS_CHARGER_DISCONNECTED ((SYS_EVENT | ((long)11 << 27))) +#define SYS_PHONE_PLUGGED ((SYS_EVENT | ((long)12 << 27))) +#define SYS_PHONE_UNPLUGGED ((SYS_EVENT | ((long)13 << 27))) struct event { -- cgit v1.2.3