summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2011-11-16 10:25:43 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2011-11-16 10:25:43 +0000
commitbe716c0be80e3f64a81a3f19b683db40489f47a1 (patch)
treebc461ad1de8b5fda6c3c14d0cfd737bdc69ddc83
parentb7508a766df991539bec5e10fd7739001c1fdb99 (diff)
downloadrockbox-be716c0be80e3f64a81a3f19b683db40489f47a1.tar.gz
rockbox-be716c0be80e3f64a81a3f19b683db40489f47a1.zip
Finally commit FS#5111 - piezo clicker for ipods!
Origional implementation by Robert Keevil with contributions from Frederik Vestre, Stoyan Stratev, Craig Elliott, Michael Sparmann, Thomas Schott, Rosso Maltese, and syncs from a bunch of other people! git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30995 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/features.txt4
-rw-r--r--apps/lang/english.lang34
-rw-r--r--apps/main.c8
-rw-r--r--apps/menus/settings_menu.c6
-rw-r--r--apps/misc.c26
-rw-r--r--apps/settings.h7
-rw-r--r--apps/settings_list.c11
-rw-r--r--firmware/SOURCES7
-rw-r--r--firmware/export/config/ipod4g.h2
-rw-r--r--firmware/export/config/ipodcolor.h2
-rw-r--r--firmware/export/config/ipodmini1g.h2
-rw-r--r--firmware/export/config/ipodmini2g.h2
-rw-r--r--firmware/export/config/ipodnano1g.h2
-rw-r--r--firmware/export/config/ipodnano2g.h2
-rw-r--r--firmware/export/config/ipodvideo.h2
-rw-r--r--firmware/export/thread.h8
-rw-r--r--firmware/target/arm/ipod/piezo.c209
-rw-r--r--firmware/target/arm/ipod/piezo.h30
-rw-r--r--firmware/target/arm/s5l8700/ipodnano2g/piezo-nano2g.c95
-rw-r--r--firmware/target/arm/s5l8700/ipodnano2g/piezo.h24
20 files changed, 481 insertions, 2 deletions
diff --git a/apps/features.txt b/apps/features.txt
index 44ef3ddf95..35f7bb50e0 100644
--- a/apps/features.txt
+++ b/apps/features.txt
@@ -270,3 +270,7 @@ recording_digital
270#if MEMORYSIZE <= 2 270#if MEMORYSIZE <= 2
271lowmem 271lowmem
272#endif 272#endif
273
274#if defined(HAVE_HARDWARE_CLICK)
275hardware_click
276#endif
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index de541af1f5..a228a78f7f 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -12917,3 +12917,37 @@
12917 *: "Shortcuts" 12917 *: "Shortcuts"
12918 </voice> 12918 </voice>
12919</phrase> 12919</phrase>
12920<phrase>
12921 id: LANG_KEYCLICK_SOFTWARE
12922 desc: in keyclick settings menu
12923 user: core
12924 <source>
12925 *: none
12926 hardware_click: "Headphone Keyclick"
12927 </source>
12928 <dest>
12929 *: none
12930 hardware_click: "Headphone Keyclick"
12931 </dest>
12932 <voice>
12933 *: none
12934 hardware_click: "Headphone Keyclick"
12935 </voice>
12936</phrase>
12937<phrase>
12938 id: LANG_KEYCLICK_HARDWARE
12939 desc: in keyclick settings menu
12940 user: core
12941 <source>
12942 *: none
12943 hardware_click: "Speaker Keyclick"
12944 </source>
12945 <dest>
12946 *: none
12947 hardware_click: "Speaker Keyclick"
12948 </dest>
12949 <voice>
12950 *: none
12951 hardware_click: "Speaker Keyclick"
12952 </voice>
12953</phrase>
diff --git a/apps/main.c b/apps/main.c
index 38de780c8d..9d83c62965 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -118,6 +118,10 @@
118#include "m5636.h" 118#include "m5636.h"
119#endif 119#endif
120 120
121#ifdef HAVE_HARDWARE_CLICK
122#include "piezo.h"
123#endif
124
121#if (CONFIG_PLATFORM & PLATFORM_NATIVE) 125#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
122#define MAIN_NORETURN_ATTR NORETURN_ATTR 126#define MAIN_NORETURN_ATTR NORETURN_ATTR
123#else 127#else
@@ -507,6 +511,10 @@ static void init(void)
507 radio_init(); 511 radio_init();
508#endif 512#endif
509 513
514#ifdef HAVE_HARDWARE_CLICK
515 piezo_init();
516#endif
517
510 /* Keep the order of this 3 (viewportmanager handles statusbars) 518 /* Keep the order of this 3 (viewportmanager handles statusbars)
511 * Must be done before any code uses the multi-screen API */ 519 * Must be done before any code uses the multi-screen API */
512 CHART(">gui_syncstatusbar_init"); 520 CHART(">gui_syncstatusbar_init");
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index 02f68aa4ab..079e86616d 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -229,9 +229,15 @@ MAKE_MENU(limits_menu, ID2P(LANG_LIMITS_MENU), 0, Icon_NOICON,
229#if CONFIG_CODEC == SWCODEC 229#if CONFIG_CODEC == SWCODEC
230MENUITEM_SETTING(keyclick, &global_settings.keyclick, NULL); 230MENUITEM_SETTING(keyclick, &global_settings.keyclick, NULL);
231MENUITEM_SETTING(keyclick_repeats, &global_settings.keyclick_repeats, NULL); 231MENUITEM_SETTING(keyclick_repeats, &global_settings.keyclick_repeats, NULL);
232#ifdef HAVE_HARDWARE_CLICK
233MENUITEM_SETTING(keyclick_hardware, &global_settings.keyclick_hardware, NULL);
234MAKE_MENU(keyclick_menu, ID2P(LANG_KEYCLICK), 0, Icon_NOICON,
235 &keyclick, &keyclick_hardware, &keyclick_repeats);
236#else
232MAKE_MENU(keyclick_menu, ID2P(LANG_KEYCLICK), 0, Icon_NOICON, 237MAKE_MENU(keyclick_menu, ID2P(LANG_KEYCLICK), 0, Icon_NOICON,
233 &keyclick, &keyclick_repeats); 238 &keyclick, &keyclick_repeats);
234#endif 239#endif
240#endif
235 241
236 242
237#if CONFIG_CODEC == MAS3507D 243#if CONFIG_CODEC == MAS3507D
diff --git a/apps/misc.c b/apps/misc.c
index 0608595d21..04a6d05c91 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -94,6 +94,10 @@
94#endif 94#endif
95#endif 95#endif
96 96
97#ifdef HAVE_HARDWARE_CLICK
98#include "piezo.h"
99#endif
100
97/* units used with output_dyn_value */ 101/* units used with output_dyn_value */
98const unsigned char * const byte_units[] = 102const unsigned char * const byte_units[] =
99{ 103{
@@ -873,14 +877,32 @@ void system_sound_play(enum system_sound sound)
873void keyclick_click(int button) 877void keyclick_click(int button)
874{ 878{
875 /* Settings filters */ 879 /* Settings filters */
876 if (global_settings.keyclick && 880 if (
877 (global_settings.keyclick_repeats || !(button & BUTTON_REPEAT))) 881#ifdef HAVE_HARDWARE_CLICK
882 (global_settings.keyclick || global_settings.keyclick_hardware)
883#else
884 global_settings.keyclick
885#endif
886 && (global_settings.keyclick_repeats || !(button & BUTTON_REPEAT)))
878 { 887 {
879 /* Button filters */ 888 /* Button filters */
880 if (button != BUTTON_NONE && !(button & BUTTON_REL) 889 if (button != BUTTON_NONE && !(button & BUTTON_REL)
881 && !(button & (SYS_EVENT|BUTTON_MULTIMEDIA)) ) 890 && !(button & (SYS_EVENT|BUTTON_MULTIMEDIA)) )
882 { 891 {
892#ifdef HAVE_HARDWARE_CLICK
893 if (global_settings.keyclick)
894 {
895 system_sound_play(SOUND_KEYCLICK);
896 }
897 if (global_settings.keyclick_hardware)
898 {
899#if !defined(SIMULATOR)
900 piezo_button_beep(false, false);
901#endif
902 }
903#else
883 system_sound_play(SOUND_KEYCLICK); 904 system_sound_play(SOUND_KEYCLICK);
905#endif
884 } 906 }
885 } 907 }
886} 908}
diff --git a/apps/settings.h b/apps/settings.h
index 92ffaf9019..06eba76e3c 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -835,6 +835,13 @@ struct user_settings
835#endif 835#endif
836 } hw_eq_bands[AUDIOHW_EQ_BAND_NUM]; 836 } hw_eq_bands[AUDIOHW_EQ_BAND_NUM];
837#endif /* AUDIOHW_HAVE_EQ */ 837#endif /* AUDIOHW_HAVE_EQ */
838
839#ifdef HAVE_HARDWARE_CLICK
840#if CONFIG_CODEC == SWCODEC
841 bool keyclick_hardware; /* hardware piezo keyclick */
842#endif
843#endif
844
838 char start_directory[MAX_PATHNAME+1]; 845 char start_directory[MAX_PATHNAME+1];
839}; 846};
840 847
diff --git a/apps/settings_list.c b/apps/settings_list.c
index e739f406cb..9232811ada 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -1757,12 +1757,23 @@ const struct settings_list settings[] = {
1757#endif /* HAVE_WHEEL_ACCELERATION */ 1757#endif /* HAVE_WHEEL_ACCELERATION */
1758#if CONFIG_CODEC == SWCODEC 1758#if CONFIG_CODEC == SWCODEC
1759 /* keyclick */ 1759 /* keyclick */
1760#ifdef HAVE_HARDWARE_CLICK
1761 CHOICE_SETTING(0, keyclick, LANG_KEYCLICK_SOFTWARE, 0,
1762 "keyclick", "off,weak,moderate,strong", NULL, 4,
1763 ID2P(LANG_OFF), ID2P(LANG_WEAK), ID2P(LANG_MODERATE),
1764 ID2P(LANG_STRONG)),
1765 OFFON_SETTING(0, keyclick_repeats, LANG_KEYCLICK_REPEATS, false,
1766 "keyclick repeats", NULL),
1767 OFFON_SETTING(0, keyclick_hardware, LANG_KEYCLICK_HARDWARE, false,
1768 "hardware keyclick", NULL),
1769#else
1760 CHOICE_SETTING(0, keyclick, LANG_KEYCLICK, 0, 1770 CHOICE_SETTING(0, keyclick, LANG_KEYCLICK, 0,
1761 "keyclick", "off,weak,moderate,strong", NULL, 4, 1771 "keyclick", "off,weak,moderate,strong", NULL, 4,
1762 ID2P(LANG_OFF), ID2P(LANG_WEAK), ID2P(LANG_MODERATE), 1772 ID2P(LANG_OFF), ID2P(LANG_WEAK), ID2P(LANG_MODERATE),
1763 ID2P(LANG_STRONG)), 1773 ID2P(LANG_STRONG)),
1764 OFFON_SETTING(0, keyclick_repeats, LANG_KEYCLICK_REPEATS, false, 1774 OFFON_SETTING(0, keyclick_repeats, LANG_KEYCLICK_REPEATS, false,
1765 "keyclick repeats", NULL), 1775 "keyclick repeats", NULL),
1776#endif
1766#endif /* CONFIG_CODEC == SWCODEC */ 1777#endif /* CONFIG_CODEC == SWCODEC */
1767 TEXT_SETTING(0, playlist_catalog_dir, "playlist catalog directory", 1778 TEXT_SETTING(0, playlist_catalog_dir, "playlist catalog directory",
1768 PLAYLIST_CATALOG_DEFAULT_DIR, NULL, NULL), 1779 PLAYLIST_CATALOG_DEFAULT_DIR, NULL, NULL),
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 0f6c21d673..6a84b5fc11 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1160,6 +1160,7 @@ target/arm/ata-pp5020.c
1160target/arm/ipod/adc-ipod-pcf.c 1160target/arm/ipod/adc-ipod-pcf.c
1161target/arm/ipod/backlight-4g_color.c 1161target/arm/ipod/backlight-4g_color.c
1162target/arm/ipod/button-clickwheel.c 1162target/arm/ipod/button-clickwheel.c
1163target/arm/ipod/piezo.c
1163target/arm/ipod/lcd-as-gray.S 1164target/arm/ipod/lcd-as-gray.S
1164target/arm/ipod/lcd-gray.c 1165target/arm/ipod/lcd-gray.c
1165target/arm/ipod/power-ipod.c 1166target/arm/ipod/power-ipod.c
@@ -1178,6 +1179,7 @@ target/arm/i2s-pp.c
1178target/arm/ipod/adc-ipod-pcf.c 1179target/arm/ipod/adc-ipod-pcf.c
1179target/arm/ipod/backlight-4g_color.c 1180target/arm/ipod/backlight-4g_color.c
1180target/arm/ipod/button-clickwheel.c 1181target/arm/ipod/button-clickwheel.c
1182target/arm/ipod/piezo.c
1181target/arm/ipod/lcd-color_nano.c 1183target/arm/ipod/lcd-color_nano.c
1182target/arm/ipod/lcd-as-color-nano.S 1184target/arm/ipod/lcd-as-color-nano.S
1183target/arm/ipod/power-ipod.c 1185target/arm/ipod/power-ipod.c
@@ -1196,6 +1198,7 @@ target/arm/i2s-pp.c
1196target/arm/ipod/adc-ipod-pcf.c 1198target/arm/ipod/adc-ipod-pcf.c
1197target/arm/ipod/backlight-nano_video.c 1199target/arm/ipod/backlight-nano_video.c
1198target/arm/ipod/button-clickwheel.c 1200target/arm/ipod/button-clickwheel.c
1201target/arm/ipod/piezo.c
1199target/arm/ipod/lcd-color_nano.c 1202target/arm/ipod/lcd-color_nano.c
1200target/arm/ipod/lcd-as-color-nano.S 1203target/arm/ipod/lcd-as-color-nano.S
1201target/arm/ipod/power-ipod.c 1204target/arm/ipod/power-ipod.c
@@ -1214,6 +1217,7 @@ target/arm/i2s-pp.c
1214target/arm/ipod/adc-ipod-pcf.c 1217target/arm/ipod/adc-ipod-pcf.c
1215target/arm/ipod/backlight-nano_video.c 1218target/arm/ipod/backlight-nano_video.c
1216target/arm/ipod/button-clickwheel.c 1219target/arm/ipod/button-clickwheel.c
1220target/arm/ipod/piezo.c
1217target/arm/ipod/power-ipod.c 1221target/arm/ipod/power-ipod.c
1218target/arm/ipod/powermgmt-ipod-pcf.c 1222target/arm/ipod/powermgmt-ipod-pcf.c
1219target/arm/ipod/video/lcd-as-video.S 1223target/arm/ipod/video/lcd-as-video.S
@@ -1268,6 +1272,7 @@ target/arm/i2s-pp.c
1268target/arm/ipod/adc-ipod-pcf.c 1272target/arm/ipod/adc-ipod-pcf.c
1269target/arm/ipod/backlight-mini1g_mini2g.c 1273target/arm/ipod/backlight-mini1g_mini2g.c
1270target/arm/ipod/button-mini1g.c 1274target/arm/ipod/button-mini1g.c
1275target/arm/ipod/piezo.c
1271target/arm/ipod/lcd-as-gray.S 1276target/arm/ipod/lcd-as-gray.S
1272target/arm/ipod/lcd-gray.c 1277target/arm/ipod/lcd-gray.c
1273target/arm/ipod/power-ipod.c 1278target/arm/ipod/power-ipod.c
@@ -1286,6 +1291,7 @@ target/arm/i2s-pp.c
1286target/arm/ipod/adc-ipod-pcf.c 1291target/arm/ipod/adc-ipod-pcf.c
1287target/arm/ipod/backlight-mini1g_mini2g.c 1292target/arm/ipod/backlight-mini1g_mini2g.c
1288target/arm/ipod/button-clickwheel.c 1293target/arm/ipod/button-clickwheel.c
1294target/arm/ipod/piezo.c
1289target/arm/ipod/lcd-as-gray.S 1295target/arm/ipod/lcd-as-gray.S
1290target/arm/ipod/lcd-gray.c 1296target/arm/ipod/lcd-gray.c
1291target/arm/ipod/power-ipod.c 1297target/arm/ipod/power-ipod.c
@@ -1639,6 +1645,7 @@ target/arm/s5l8700/pcm-s5l8700.c
1639target/arm/s5l8700/wmcodec-s5l8700.c 1645target/arm/s5l8700/wmcodec-s5l8700.c
1640target/arm/s5l8700/ipodnano2g/audio-nano2g.c 1646target/arm/s5l8700/ipodnano2g/audio-nano2g.c
1641target/arm/s5l8700/ipodnano2g/adc-nano2g.c 1647target/arm/s5l8700/ipodnano2g/adc-nano2g.c
1648target/arm/s5l8700/ipodnano2g/piezo-nano2g.c
1642#endif 1649#endif
1643#endif 1650#endif
1644#endif 1651#endif
diff --git a/firmware/export/config/ipod4g.h b/firmware/export/config/ipod4g.h
index 165f5967b4..957e3a4da5 100644
--- a/firmware/export/config/ipod4g.h
+++ b/firmware/export/config/ipod4g.h
@@ -212,6 +212,8 @@
212/* Define this if you can read an absolute wheel position */ 212/* Define this if you can read an absolute wheel position */
213#define HAVE_WHEEL_POSITION 213#define HAVE_WHEEL_POSITION
214 214
215#define HAVE_HARDWARE_CLICK
216
215#define BOOTFILE_EXT "ipod" 217#define BOOTFILE_EXT "ipod"
216#define BOOTFILE "rockbox." BOOTFILE_EXT 218#define BOOTFILE "rockbox." BOOTFILE_EXT
217#define BOOTDIR "/.rockbox" 219#define BOOTDIR "/.rockbox"
diff --git a/firmware/export/config/ipodcolor.h b/firmware/export/config/ipodcolor.h
index 645e20041c..cf021019b4 100644
--- a/firmware/export/config/ipodcolor.h
+++ b/firmware/export/config/ipodcolor.h
@@ -199,6 +199,8 @@
199/* Define this if you can read an absolute wheel position */ 199/* Define this if you can read an absolute wheel position */
200#define HAVE_WHEEL_POSITION 200#define HAVE_WHEEL_POSITION
201 201
202#define HAVE_HARDWARE_CLICK
203
202#define BOOTFILE_EXT "ipod" 204#define BOOTFILE_EXT "ipod"
203#define BOOTFILE "rockbox." BOOTFILE_EXT 205#define BOOTFILE "rockbox." BOOTFILE_EXT
204#define BOOTDIR "/.rockbox" 206#define BOOTDIR "/.rockbox"
diff --git a/firmware/export/config/ipodmini1g.h b/firmware/export/config/ipodmini1g.h
index 777dc6f9a2..04fa68e500 100644
--- a/firmware/export/config/ipodmini1g.h
+++ b/firmware/export/config/ipodmini1g.h
@@ -202,6 +202,8 @@
202/* Define this if you have adjustable CPU frequency */ 202/* Define this if you have adjustable CPU frequency */
203#define HAVE_ADJUSTABLE_CPU_FREQ 203#define HAVE_ADJUSTABLE_CPU_FREQ
204 204
205#define HAVE_HARDWARE_CLICK
206
205#define BOOTFILE_EXT "ipod" 207#define BOOTFILE_EXT "ipod"
206#define BOOTFILE "rockbox." BOOTFILE_EXT 208#define BOOTFILE "rockbox." BOOTFILE_EXT
207#define BOOTDIR "/.rockbox" 209#define BOOTDIR "/.rockbox"
diff --git a/firmware/export/config/ipodmini2g.h b/firmware/export/config/ipodmini2g.h
index c401170459..c10284e7a4 100644
--- a/firmware/export/config/ipodmini2g.h
+++ b/firmware/export/config/ipodmini2g.h
@@ -205,6 +205,8 @@
205/* Define this if you can read an absolute wheel position */ 205/* Define this if you can read an absolute wheel position */
206#define HAVE_WHEEL_POSITION 206#define HAVE_WHEEL_POSITION
207 207
208#define HAVE_HARDWARE_CLICK
209
208#define BOOTFILE_EXT "ipod" 210#define BOOTFILE_EXT "ipod"
209#define BOOTFILE "rockbox." BOOTFILE_EXT 211#define BOOTFILE "rockbox." BOOTFILE_EXT
210#define BOOTDIR "/.rockbox" 212#define BOOTDIR "/.rockbox"
diff --git a/firmware/export/config/ipodnano1g.h b/firmware/export/config/ipodnano1g.h
index 388ba34447..50f0511384 100644
--- a/firmware/export/config/ipodnano1g.h
+++ b/firmware/export/config/ipodnano1g.h
@@ -199,6 +199,8 @@
199/* Define this if you can read an absolute wheel position */ 199/* Define this if you can read an absolute wheel position */
200#define HAVE_WHEEL_POSITION 200#define HAVE_WHEEL_POSITION
201 201
202#define HAVE_HARDWARE_CLICK
203
202#define BOOTFILE_EXT "ipod" 204#define BOOTFILE_EXT "ipod"
203#define BOOTFILE "rockbox." BOOTFILE_EXT 205#define BOOTFILE "rockbox." BOOTFILE_EXT
204#define BOOTDIR "/.rockbox" 206#define BOOTDIR "/.rockbox"
diff --git a/firmware/export/config/ipodnano2g.h b/firmware/export/config/ipodnano2g.h
index 37a21b33ba..96cec799e4 100644
--- a/firmware/export/config/ipodnano2g.h
+++ b/firmware/export/config/ipodnano2g.h
@@ -191,6 +191,8 @@
191/* Define this if you can read an absolute wheel position */ 191/* Define this if you can read an absolute wheel position */
192#define HAVE_WHEEL_POSITION 192#define HAVE_WHEEL_POSITION
193 193
194#define HAVE_HARDWARE_CLICK
195
194/* Define this if you have adjustable CPU frequency */ 196/* Define this if you have adjustable CPU frequency */
195#define HAVE_ADJUSTABLE_CPU_FREQ 197#define HAVE_ADJUSTABLE_CPU_FREQ
196 198
diff --git a/firmware/export/config/ipodvideo.h b/firmware/export/config/ipodvideo.h
index 1dd7d48e30..c4e2cb2986 100644
--- a/firmware/export/config/ipodvideo.h
+++ b/firmware/export/config/ipodvideo.h
@@ -218,6 +218,8 @@
218/* Define this if you can read an absolute wheel position */ 218/* Define this if you can read an absolute wheel position */
219#define HAVE_WHEEL_POSITION 219#define HAVE_WHEEL_POSITION
220 220
221#define HAVE_HARDWARE_CLICK
222
221/* define this if the device has larger sectors when accessed via USB */ 223/* define this if the device has larger sectors when accessed via USB */
222/* (only relevant in disk.c, fat.c now always supports large virtual sectors) */ 224/* (only relevant in disk.c, fat.c now always supports large virtual sectors) */
223#define MAX_LOG_SECTOR_SIZE 2048 225#define MAX_LOG_SECTOR_SIZE 2048
diff --git a/firmware/export/thread.h b/firmware/export/thread.h
index d0f61f9d85..da06557f9c 100644
--- a/firmware/export/thread.h
+++ b/firmware/export/thread.h
@@ -65,10 +65,18 @@
65#if CONFIG_CODEC == SWCODEC 65#if CONFIG_CODEC == SWCODEC
66 66
67#ifdef HAVE_RECORDING 67#ifdef HAVE_RECORDING
68#ifdef HAVE_HARDWARE_CLICK
69#define BASETHREADS 18
70#else
71#define BASETHREADS 17
72#endif
73#else
74#ifdef HAVE_HARDWARE_CLICK
68#define BASETHREADS 17 75#define BASETHREADS 17
69#else 76#else
70#define BASETHREADS 16 77#define BASETHREADS 16
71#endif 78#endif
79#endif
72 80
73#else 81#else
74#define BASETHREADS 11 82#define BASETHREADS 11
diff --git a/firmware/target/arm/ipod/piezo.c b/firmware/target/arm/ipod/piezo.c
new file mode 100644
index 0000000000..2c3968e79a
--- /dev/null
+++ b/firmware/target/arm/ipod/piezo.c
@@ -0,0 +1,209 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006-2007 Robert Keevil
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "thread.h"
21#include "system.h"
22#include "kernel.h"
23#include "usb.h"
24#include "logf.h"
25#include "piezo.h"
26
27static long piezo_stack[DEFAULT_STACK_SIZE/sizeof(long)];
28static const char piezo_thread_name[] = "piezo";
29static struct event_queue piezo_queue;
30static unsigned int duration;
31static bool beeping;
32
33enum {
34 Q_PIEZO_BEEP = 1,
35 Q_PIEZO_BEEP_FOR_TICK,
36 Q_PIEZO_BEEP_FOR_USEC,
37 Q_PIEZO_STOP
38};
39
40static inline void piezo_hw_init(void)
41{
42#ifndef SIMULATOR
43 /*logf("PIEZO: hw_init");*/
44 outl(inl(0x70000010) & ~0xc, 0x70000010);
45 outl(inl(0x6000600c) | 0x20000, 0x6000600c); /* enable device */
46#endif
47}
48
49static void piezo_hw_tick(unsigned int form_and_period)
50{
51#ifndef SIMULATOR
52 outl(0x80000000 | form_and_period, 0x7000a000); /* set pitch */
53#endif
54}
55
56static inline void piezo_hw_stop(void)
57{
58#ifndef SIMULATOR
59 outl(0x0, 0x7000a000); /* piezo off */
60#endif
61}
62
63static void piezo_thread(void)
64{
65 struct queue_event ev;
66 long piezo_usec_off;
67
68 while(1)
69 {
70 queue_wait(&piezo_queue, &ev);
71 switch(ev.id)
72 {
73 case Q_PIEZO_BEEP:
74 piezo_hw_tick((unsigned int)ev.data);
75 beeping = true;
76 break;
77 case Q_PIEZO_BEEP_FOR_TICK:
78 piezo_hw_tick((unsigned int)ev.data);
79 beeping = true;
80 sleep(duration);
81 if (beeping)
82 piezo_hw_stop();
83 beeping = false;
84 /* remove anything that appeared while sleeping */
85 queue_clear(&piezo_queue);
86 break;
87 case Q_PIEZO_BEEP_FOR_USEC:
88 piezo_usec_off = USEC_TIMER + duration;
89 piezo_hw_tick((unsigned int)ev.data);
90 beeping = true;
91 while (TIME_BEFORE(USEC_TIMER, piezo_usec_off))
92 if (duration >= 5000) yield();
93 if (beeping)
94 piezo_hw_stop();
95 beeping = false;
96 /* remove anything that appeared while sleeping */
97 queue_clear(&piezo_queue);
98 break;
99 case Q_PIEZO_STOP:
100 if (beeping)
101 piezo_hw_stop();
102 beeping = false;
103 break;
104#ifndef SIMULATOR
105 case SYS_USB_CONNECTED:
106 /*logf("USB: Piezo core");*/
107 piezo_hw_stop();
108 queue_clear(&piezo_queue);
109 usb_acknowledge(SYS_USB_CONNECTED_ACK);
110 usb_wait_for_disconnect(&piezo_queue);
111 break ;
112#endif
113 case SYS_TIMEOUT:
114 break;
115 }
116 yield();
117 }
118}
119
120
121void piezo_play(unsigned short inv_freq, unsigned char form)
122{
123 queue_post(&piezo_queue, Q_PIEZO_BEEP,
124 (intptr_t)((unsigned int)form << 16 | inv_freq));
125}
126
127void piezo_play_for_tick(unsigned short inv_freq,
128 unsigned char form, unsigned int dur)
129{
130 duration = dur;
131 queue_post(&piezo_queue, Q_PIEZO_BEEP_FOR_TICK,
132 (intptr_t)((unsigned int)form << 16 | inv_freq));
133}
134
135void piezo_play_for_usec(unsigned short inv_freq,
136 unsigned char form, unsigned int dur)
137{
138 duration = dur;
139 queue_post(&piezo_queue, Q_PIEZO_BEEP_FOR_USEC,
140 (intptr_t)((unsigned int)form << 16 | inv_freq));
141}
142
143void piezo_stop(void)
144{
145 queue_post(&piezo_queue, Q_PIEZO_STOP, 0);
146}
147
148void piezo_clear(void)
149{
150 queue_clear(&piezo_queue);
151 piezo_stop();
152}
153
154bool piezo_busy(void)
155{
156 return !queue_empty(&piezo_queue);
157}
158
159/* conversion factor based on the following data
160
161 period Hz
162 10 8547
163 20 4465
164 30 3024
165 40 2286
166 50 1846
167 60 1537
168 70 1320
169 80 1165
170 90 1030
171 100 928
172
173 someone with better recording/analysing equipment should be able
174 to get more accurate figures
175*/
176unsigned int piezo_hz(unsigned int hz)
177{
178 if (hz > 0)
179 return 91225/hz;
180 else
181 return 0;
182}
183
184void piezo_init(void)
185{
186 /*logf("PIEZO: init");*/
187 piezo_hw_init();
188 queue_init(&piezo_queue, true);
189 create_thread(piezo_thread, piezo_stack, sizeof(piezo_stack), 0,
190 piezo_thread_name IF_PRIO(, PRIORITY_REALTIME)
191 IF_COP(, CPU));
192}
193
194void piezo_button_beep(bool beep, bool force)
195{
196 /* old on clickwheel action - piezo_play_for_usec(50, 0x80, 400);
197 old on button action - piezo_play_for_usec(50, 0x80, 3000); */
198
199 if (force)
200 piezo_clear();
201
202 if (queue_empty(&piezo_queue))
203 {
204 if (beep)
205 piezo_play_for_tick(40, 0x80, HZ/5);
206 else
207 piezo_play_for_usec(91, 0x80, 4000);
208 }
209}
diff --git a/firmware/target/arm/ipod/piezo.h b/firmware/target/arm/ipod/piezo.h
new file mode 100644
index 0000000000..78b50d0d39
--- /dev/null
+++ b/firmware/target/arm/ipod/piezo.h
@@ -0,0 +1,30 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006-2007 Robert Keevil
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20void piezo_init(void);
21void piezo_play(unsigned short inv_freq, unsigned char form);
22void piezo_play_for_tick(unsigned short inv_freq,
23 unsigned char form, unsigned int dur);
24void piezo_play_for_usec(unsigned short inv_freq,
25 unsigned char form, unsigned int dur);
26void piezo_stop(void);
27void piezo_clear(void);
28bool piezo_busy(void);
29unsigned int piezo_hz(unsigned int hz);
30void piezo_button_beep(bool beep, bool force);
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/piezo-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/piezo-nano2g.c
new file mode 100644
index 0000000000..d555b7232f
--- /dev/null
+++ b/firmware/target/arm/s5l8700/ipodnano2g/piezo-nano2g.c
@@ -0,0 +1,95 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006-2007 Robert Keevil
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "system.h"
21#include "kernel.h"
22#include "piezo.h"
23
24static unsigned int duration;
25static bool beeping;
26
27void INT_TIMERD(void)
28{
29 /* clear interrupt */
30 TDCON = TDCON;
31 if (!(--duration))
32 {
33 beeping = 0;
34 TDCMD = (1 << 1); /* TD_CLR */
35 }
36}
37
38void piezo_start(unsigned short cycles, unsigned short periods)
39{
40#ifndef SIMULATOR
41 duration = periods;
42 beeping = 1;
43 /* configure timer for 100 kHz */
44 TDCMD = (1 << 1); /* TD_CLR */
45 TDPRE = 30 - 1; /* prescaler */
46 TDCON = (1 << 13) | /* TD_INT1_EN */
47 (0 << 12) | /* TD_INT0_EN */
48 (0 << 11) | /* TD_START */
49 (2 << 8) | /* TD_CS = PCLK / 16 */
50 (1 << 4); /* TD_MODE_SEL = PWM mode */
51 TDDATA0 = cycles; /* set interval period */
52 TDDATA1 = cycles << 1; /* set interval period */
53 TDCMD = (1 << 0); /* TD_EN */
54
55 /* enable timer interrupt */
56 INTMSK |= INTMSK_TIMERD;
57#endif
58}
59
60void piezo_stop(void)
61{
62#ifndef SIMULATOR
63 TDCMD = (1 << 1); /* TD_CLR */
64#endif
65}
66
67void piezo_clear(void)
68{
69 piezo_stop();
70}
71
72bool piezo_busy(void)
73{
74 return beeping;
75}
76
77void piezo_init(void)
78{
79 beeping = 0;
80}
81
82void piezo_button_beep(bool beep, bool force)
83{
84 if (force)
85 while (beeping)
86 yield();
87
88 if (!beeping)
89 {
90 if (beep)
91 piezo_start(22, 457);
92 else
93 piezo_start(40, 4);
94 }
95}
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/piezo.h b/firmware/target/arm/s5l8700/ipodnano2g/piezo.h
new file mode 100644
index 0000000000..b8eae0943d
--- /dev/null
+++ b/firmware/target/arm/s5l8700/ipodnano2g/piezo.h
@@ -0,0 +1,24 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006-2007 Robert Keevil
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20void piezo_init(void);
21void piezo_stop(void);
22void piezo_clear(void);
23bool piezo_busy(void);
24void piezo_button_beep(bool beep, bool force);