Index: apps/settings.c
===================================================================
--- apps/settings.c (リビジョン 14552)
+++ apps/settings.c (作業コピー)
@@ -102,6 +102,10 @@ struct system_status global_status;
#include "usbstack.h"
#endif
+#ifdef HAVE_PIEZO
+#include "piezo.h"
+#endif
+
long lasttime = 0;
/** NVRAM stuff, if the target doesnt have NVRAM it is saved in ROCKBOX_DIR /nvram.bin **/
@@ -854,6 +858,11 @@ void settings_apply(void)
spdif_power_enable(global_settings.spdif_enable);
#endif
+#ifdef HAVE_PIEZO
+ set_button_beep_type((unsigned short)global_settings.button_beep_length,
+ (unsigned short)global_settings.button_beep_frequency);
+#endif
+
#ifdef HAVE_BACKLIGHT
set_backlight_filter_keypress(global_settings.bl_filter_first_keypress);
#ifdef HAVE_REMOTE_LCD
Index: apps/lang/english.lang
===================================================================
--- apps/lang/english.lang (リビジョン 14552)
+++ apps/lang/english.lang (作業コピー)
@@ -11241,3 +11241,31 @@
usbstack: "Device Driver"
+
+ id: LANG_BUTTON_BEEP_LENGTH
+ desc: in lcd options
+ user:
+
+ *: "Button click duration"
+
+
+ *: "Button click duration"
+
+
+ *: "Button click duration"
+
+
+
+ id: LANG_BUTTON_BEEP_FREQUENCY
+ desc: in lcd options
+ user:
+
+ *: "Button click frequency"
+
+
+ *: "Button click frequency"
+
+
+ *: "Button click frequency"
+
+
Index: apps/settings.h
===================================================================
--- apps/settings.h (リビジョン 14552)
+++ apps/settings.h (作業コピー)
@@ -720,6 +720,10 @@ struct user_settings
#endif
/* Encoder Settings End */
#endif /* CONFIG_CODEC == SWCODEC */
+#ifdef HAVE_PIEZO
+ int button_beep_length;
+ int button_beep_frequency;
+#endif
bool cuesheet;
int start_in_screen;
#if defined(HAVE_RTC_ALARM) && \
Index: apps/menus/playback_menu.c
===================================================================
--- apps/menus/playback_menu.c (リビジョン 14552)
+++ apps/menus/playback_menu.c (作業コピー)
@@ -35,6 +35,10 @@
#include "audio.h"
#include "cuesheet.h"
+#ifdef HAVE_PIEZO
+#include "piezo.h"
+#endif
+
#if CONFIG_CODEC == SWCODEC
int setcrossfadeonexit_callback(int action,const struct menu_item_ex *this_item)
{
@@ -125,6 +129,10 @@ MAKE_MENU(replaygain_settings_menu,ID2P(
MENUITEM_SETTING(beep, &global_settings.beep ,NULL);
#endif /* CONFIG_CODEC == SWCODEC */
+#ifdef HAVE_PIEZO
+MENUITEM_SETTING(button_beep_frequency, &global_settings.button_beep_frequency, NULL);
+MENUITEM_SETTING(button_beep_length, &global_settings.button_beep_length, NULL);
+#endif
#ifdef HAVE_SPDIF_POWER
MENUITEM_SETTING(spdif_enable, &global_settings.spdif_enable, NULL);
@@ -183,6 +191,9 @@ MAKE_MENU(playback_menu_item,ID2P(LANG_P
#if CONFIG_CODEC == SWCODEC
&crossfade_settings_menu, &replaygain_settings_menu, &beep,
#endif
+#ifdef HAVE_PIEZO
+ &button_beep_length, &button_beep_frequency,
+#endif
#ifdef HAVE_SPDIF_POWER
&spdif_enable,
Index: apps/settings_list.c
===================================================================
--- apps/settings_list.c (リビジョン 14552)
+++ apps/settings_list.c (作業コピー)
@@ -145,6 +145,10 @@
{.int_setting = (struct int_setting[]){ \
{cb, unit, min, max, step, formatter, get_talk_id}}}}
+#ifdef HAVE_PIEZO
+#include "piezo.h"
+#endif
+
/* some sets of values which are used more than once, to save memory */
@@ -379,7 +383,20 @@ static long jumpscroll_getlang(int value
#else
#define BALANCE_FLIP 0
#endif
-
+
+#ifdef HAVE_PIEZO
+static void lcd_button_beep_freq(int freq)
+{
+ set_button_beep_type((unsigned short)global_settings.button_beep_length,
+ (unsigned short)freq);
+}
+
+static void lcd_button_beep_len(int len)
+{
+ set_button_beep_type((unsigned short)len,
+ (unsigned short)global_settings.button_beep_frequency);
+}
+#endif
const struct settings_list settings[] = {
/* sound settings */
SOUND_SETTING(0,volume, LANG_VOLUME, "volume", SOUND_VOLUME),
@@ -459,6 +476,14 @@ const struct settings_list settings[] =
/* display */
BOOL_SETTING(F_TEMPVAR, invert_cursor, LANG_INVERT_CURSOR, true ,"invert cursor", off_on,
LANG_INVERT_CURSOR_BAR, LANG_INVERT_CURSOR_POINTER, NULL),
+#ifdef HAVE_PIEZO
+ INT_SETTING(0, button_beep_frequency, LANG_BUTTON_BEEP_FREQUENCY, 27,
+ "button beep freq", UNIT_INT, 0, 250, 1, NULL, NULL,
+ lcd_button_beep_freq),
+ INT_SETTING(0, button_beep_length, LANG_BUTTON_BEEP_LENGTH, 0,
+ "button beep length", UNIT_INT, 0, 100, 1, NULL, NULL,
+ lcd_button_beep_len),
+#endif
OFFON_SETTING(F_THEMESETTING|F_TEMPVAR, statusbar,
LANG_STATUS_BAR, true,"statusbar", NULL),
OFFON_SETTING(0,scrollbar, LANG_SCROLL_BAR, true,"scrollbar", NULL),
Index: apps/main.c
===================================================================
--- apps/main.c (リビジョン 14552)
+++ apps/main.c (作業コピー)
@@ -113,6 +113,10 @@
#include "cuesheet.h"
+#ifdef HAVE_PIEZO
+#include "piezo.h"
+#endif
+
/*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */
const char appsversion[]=APPSVERSION;
@@ -580,6 +584,10 @@ static void init(void)
#if CONFIG_CHARGING
car_adapter_mode_init();
#endif
+
+#ifdef HAVE_PIEZO
+ piezo_init();
+#endif
}
#ifdef CPU_PP
Index: firmware/export/config-ipodmini2g.h
===================================================================
--- firmware/export/config-ipodmini2g.h (リビジョン 14552)
+++ firmware/export/config-ipodmini2g.h (作業コピー)
@@ -140,6 +140,8 @@
/* Define this if you can read an absolute wheel position */
#define HAVE_WHEEL_POSITION
+#define HAVE_PIEZO
+
#define BOOTFILE_EXT "ipod"
#define BOOTFILE "rockbox." BOOTFILE_EXT
#define BOOTDIR "/.rockbox"
Index: firmware/export/config-ipodnano.h
===================================================================
--- firmware/export/config-ipodnano.h (リビジョン 14552)
+++ firmware/export/config-ipodnano.h (作業コピー)
@@ -141,6 +141,8 @@
/* Define this if you can read an absolute wheel position */
#define HAVE_WHEEL_POSITION
+#define HAVE_PIEZO
+
#define BOOTFILE_EXT "ipod"
#define BOOTFILE "rockbox." BOOTFILE_EXT
#define BOOTDIR "/.rockbox"
Index: firmware/export/config-ipod4g.h
===================================================================
--- firmware/export/config-ipod4g.h (リビジョン 14552)
+++ firmware/export/config-ipod4g.h (作業コピー)
@@ -144,6 +144,8 @@
/* Define this if you can read an absolute wheel position */
#define HAVE_WHEEL_POSITION
+#define HAVE_PIEZO
+
#define BOOTFILE_EXT "ipod"
#define BOOTFILE "rockbox." BOOTFILE_EXT
#define BOOTDIR "/.rockbox"
Index: firmware/export/config-ipodvideo.h
===================================================================
--- firmware/export/config-ipodvideo.h (リビジョン 14552)
+++ firmware/export/config-ipodvideo.h (作業コピー)
@@ -145,6 +145,8 @@
/* Define this if you can read an absolute wheel position */
#define HAVE_WHEEL_POSITION
+#define HAVE_PIEZO
+
/* define this if the device has larger sectors when accessed via USB */
/* (only relevant in disk.c, fat.c now always supports large virtual sectors) */
#define MAX_LOG_SECTOR_SIZE 2048
Index: firmware/export/config-ipodcolor.h
===================================================================
--- firmware/export/config-ipodcolor.h (リビジョン 14552)
+++ firmware/export/config-ipodcolor.h (作業コピー)
@@ -135,6 +135,8 @@
/* Define this if you can read an absolute wheel position */
#define HAVE_WHEEL_POSITION
+#define HAVE_PIEZO
+
#define BOOTFILE_EXT "ipod"
#define BOOTFILE "rockbox." BOOTFILE_EXT
#define BOOTDIR "/.rockbox"
Index: firmware/export/config-ipodmini.h
===================================================================
--- firmware/export/config-ipodmini.h (リビジョン 14552)
+++ firmware/export/config-ipodmini.h (作業コピー)
@@ -137,6 +137,8 @@
/* Define this if you have adjustable CPU frequency */
#define HAVE_ADJUSTABLE_CPU_FREQ
+#define HAVE_PIEZO
+
#define BOOTFILE_EXT "ipod"
#define BOOTFILE "rockbox." BOOTFILE_EXT
#define BOOTDIR "/.rockbox"
Index: firmware/SOURCES
===================================================================
--- firmware/SOURCES (リビジョン 14552)
+++ firmware/SOURCES (作業コピー)
@@ -596,6 +596,7 @@ target/arm/ata-pp5020.c
target/arm/ipod/adc-ipod-pcf.c
target/arm/ipod/backlight-4g_color.c
target/arm/ipod/button-clickwheel.c
+target/arm/ipod/piezo.c
target/arm/ipod/lcd-gray.c
target/arm/ipod/power-ipod.c
target/arm/ipod/powermgmt-ipod-pcf.c
@@ -613,6 +614,7 @@ target/arm/i2s-pp.c
target/arm/ipod/adc-ipod-pcf.c
target/arm/ipod/backlight-4g_color.c
target/arm/ipod/button-clickwheel.c
+target/arm/ipod/piezo.c
target/arm/ipod/lcd-color_nano.c
target/arm/ipod/power-ipod.c
target/arm/ipod/powermgmt-ipod-pcf.c
@@ -630,6 +632,7 @@ target/arm/i2s-pp.c
target/arm/ipod/adc-ipod-pcf.c
target/arm/ipod/backlight-nano_video.c
target/arm/ipod/button-clickwheel.c
+target/arm/ipod/piezo.c
target/arm/ipod/lcd-color_nano.c
target/arm/ipod/power-ipod.c
target/arm/ipod/powermgmt-ipod-pcf.c
@@ -647,6 +650,7 @@ target/arm/i2s-pp.c
target/arm/ipod/adc-ipod-pcf.c
target/arm/ipod/backlight-nano_video.c
target/arm/ipod/button-clickwheel.c
+target/arm/ipod/piezo.c
target/arm/ipod/power-ipod.c
target/arm/ipod/powermgmt-ipod-pcf.c
target/arm/ipod/video/lcd-video.c
@@ -695,6 +699,7 @@ target/arm/i2s-pp.c
target/arm/ipod/adc-ipod-pcf.c
target/arm/ipod/backlight-mini1g_mini2g.c
target/arm/ipod/button-mini1g.c
+target/arm/ipod/piezo.c
target/arm/ipod/lcd-gray.c
target/arm/ipod/power-ipod.c
target/arm/ipod/powermgmt-ipod-pcf.c
Index: firmware/target/arm/ipod/button-clickwheel.c
===================================================================
--- firmware/target/arm/ipod/button-clickwheel.c (リビジョン 14552)
+++ firmware/target/arm/ipod/button-clickwheel.c (作業コピー)
@@ -40,6 +40,10 @@
#include "system.h"
#include "powermgmt.h"
+#ifdef HAVE_PIEZO
+#include "piezo.h"
+#endif
+
/* Variable to use for setting button status in interrupt handler */
int int_btn = BUTTON_NONE;
#ifdef HAVE_WHEEL_POSITION
@@ -143,6 +147,10 @@ static inline int ipod_4g_button_read(vo
data);
}
+#ifdef HAVE_PIEZO
+ piezo_button_beep(false);
+#endif
+
if (!wheel_repeat) wheel_repeat = BUTTON_REPEAT;
}
Index: firmware/target/arm/ipod/piezo.c
===================================================================
--- firmware/target/arm/ipod/piezo.c (リビジョン 0)
+++ firmware/target/arm/ipod/piezo.c (リビジョン 0)
@@ -0,0 +1,168 @@
+#include "thread.h"
+#include "system.h"
+#include "kernel.h"
+#include "usb.h"
+#include "logf.h"
+#include "piezo.h"
+
+#define PIEZO_HZ_CONVERSION 91225
+/* conversion factor based on the following data
+
+ period Hz
+ 10 8547
+ 20 4465
+ 30 3024
+ 40 2286
+ 50 1846
+ 60 1537
+ 70 1320
+ 80 1165
+ 90 1030
+ 100 928
+
+ someone with better recording/analysing equipment should be able
+ to get more accurate figures
+*/
+
+static long piezo_stack[DEFAULT_STACK_SIZE/sizeof(long)];
+static const char piezo_thread_name[] = "piezo";
+static struct event_queue piezo_queue;
+static unsigned int duration;
+static bool beeping;
+static unsigned short button_beep_length=0;
+static unsigned short button_beep_frequency=27;
+
+enum {
+ Q_PIEZO_BEEP = 1,
+ Q_PIEZO_BEEP_FOR,
+ Q_PIEZO_STOP
+};
+
+static inline void piezo_hw_init(void)
+{
+ logf("PIEZO: hw_init");
+ outl(inl(0x70000010) & ~0xc, 0x70000010);
+ outl(inl(0x6000600c) | 0x20000, 0x6000600c); /* enable device */
+}
+
+static void piezo_hw_tick(unsigned int form_and_period)
+{
+ outl(0x80000000 | form_and_period, 0x7000a000); /* set pitch */
+}
+
+static inline void piezo_hw_stop(void)
+{
+ outl(0x0, 0x7000a000); /* piezo off */
+}
+
+
+static void piezo_thread(void)
+{
+ struct event ev;
+
+ while(1)
+ {
+ queue_wait(&piezo_queue, &ev);
+ switch(ev.id)
+ {
+ case Q_PIEZO_BEEP:
+ piezo_hw_tick((unsigned int)ev.data);
+ beeping = true;
+ break;
+ case Q_PIEZO_BEEP_FOR:
+ piezo_hw_tick((unsigned int)ev.data);
+ beeping = true;
+ sleep(duration);
+ if (beeping)
+ piezo_hw_stop();
+ beeping = false;
+ /* remove anything that appeared while sleeping */
+ queue_clear(&piezo_queue);
+ break;
+ case Q_PIEZO_STOP:
+ if (beeping)
+ piezo_hw_stop();
+ beeping = false;
+ break;
+#ifndef SIMULATOR
+ case SYS_USB_CONNECTED:
+ /*logf("USB: Piezo core");*/
+ piezo_hw_stop();queue_clear(&piezo_queue);
+ usb_acknowledge(SYS_USB_CONNECTED_ACK);
+ usb_wait_for_disconnect(&piezo_queue);
+ break ;
+#endif
+ case SYS_TIMEOUT:
+ break;
+ }
+ yield();
+ }
+}
+
+
+void piezo_play(unsigned short inv_freq, unsigned char form)
+{
+ queue_post(&piezo_queue, Q_PIEZO_BEEP,
+ (intptr_t)((unsigned int)form << 16 | inv_freq));
+}
+
+void piezo_play_for(unsigned short inv_freq,
+ unsigned char form, unsigned int dur)
+{
+ duration = dur;
+ queue_post(&piezo_queue, Q_PIEZO_BEEP_FOR,
+ (intptr_t)((unsigned int)form << 16 | inv_freq));
+}
+
+void piezo_stop(void)
+{
+ queue_post(&piezo_queue, Q_PIEZO_STOP, 0);
+}
+
+void piezo_clear(void)
+{
+ queue_clear(&piezo_queue);
+ piezo_stop();
+}
+
+bool piezo_busy(void)
+{
+ return !queue_empty(&piezo_queue);
+}
+
+unsigned int piezo_hz(unsigned int hz)
+{
+ if (hz > 0)
+ return PIEZO_HZ_CONVERSION/hz;
+ else
+ return 0;
+}
+
+void piezo_init(void)
+{
+ logf("PIEZO: init");
+ piezo_hw_init();
+ queue_init(&piezo_queue, true);
+ create_thread(piezo_thread, piezo_stack, sizeof(piezo_stack),
+ piezo_thread_name IF_PRIO(, PRIORITY_USER_INTERFACE) IF_COP(, CPU, false));
+}
+
+void set_button_beep_type(unsigned short length, unsigned short frequency)
+{
+ button_beep_length = length;
+ button_beep_frequency = frequency;
+}
+
+void piezo_button_beep(bool wheel)
+{
+ if(button_beep_length>0 && queue_empty(&piezo_queue))
+ {
+ if(wheel)
+ piezo_play_for(button_beep_frequency, 0x80,
+ button_beep_length-1);
+ else
+ piezo_play_for(button_beep_frequency, 0x80,
+ (button_beep_length*2)-1);
+ }
+
+}
Index: firmware/target/arm/ipod/piezo.h
===================================================================
--- firmware/target/arm/ipod/piezo.h (リビジョン 0)
+++ firmware/target/arm/ipod/piezo.h (リビジョン 0)
@@ -0,0 +1,10 @@
+void piezo_init(void);
+void piezo_play(unsigned short inv_freq, unsigned char form);
+void piezo_play_for(unsigned short inv_freq,
+ unsigned char form, unsigned int dur);
+void piezo_stop(void);
+void piezo_clear(void);
+bool piezo_busy(void);
+unsigned int piezo_hz(unsigned int hz);
+void set_button_beep_type(unsigned short length, unsigned short frequency);
+void piezo_button_beep(bool wheel);
Index: firmware/drivers/button.c
===================================================================
--- firmware/drivers/button.c (リビジョン 14552)
+++ firmware/drivers/button.c (作業コピー)
@@ -37,6 +37,10 @@
#include "lcd-remote.h"
#endif
+#ifdef HAVE_PIEZO
+#include "piezo.h"
+#endif
+
#ifndef SIMULATOR
#if 0
/* Older than MAX_EVENT_AGE button events are going to be ignored.
@@ -243,7 +247,12 @@ static void button_tick(void)
|| (btn&BUTTON_REMOTE)
#endif
)
+ {
queue_post(&button_queue, btn, 0);
+#ifdef HAVE_PIEZO
+ piezo_button_beep(false);
+#endif
+ }
else
skip_release = true;
#else /* no backlight, nothing to skip */