summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2006-09-10 02:00:40 +0000
committerMichael Sevakis <jethead71@rockbox.org>2006-09-10 02:00:40 +0000
commit3d2e10bcbd13ec48decafe49f32afcc12c5e185a (patch)
tree60c490e727a28fd2359c3d185cf2a4f5fd8c328b /firmware
parent24ca76ffec3e0d782f75ac1cca2c0b2c8b71f5db (diff)
downloadrockbox-3d2e10bcbd13ec48decafe49f32afcc12c5e185a.tar.gz
rockbox-3d2e10bcbd13ec48decafe49f32afcc12c5e185a.zip
Added remote backlight on hold option to players with remote hold switch. Disabled IRQs while reading pcf50606 ADC. This seems to have stopped buttons becoming unresponsive when using remote. Maybe fixes other button glitches as well?
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10911 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/backlight.c57
-rw-r--r--firmware/drivers/adc.c2
-rw-r--r--firmware/drivers/button.c10
-rw-r--r--firmware/export/backlight.h23
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/adc-x5.c2
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/button-x5.c16
-rw-r--r--firmware/target/coldfire/iaudio/x5/pcf50606-x5.c2
7 files changed, 92 insertions, 20 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 6f7432c9e2..bf88cbe9bc 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -178,6 +178,9 @@ static int remote_backlight_timeout = 5*HZ;
178#ifdef CONFIG_CHARGING 178#ifdef CONFIG_CHARGING
179static int remote_backlight_timeout_plugged = 5*HZ; 179static int remote_backlight_timeout_plugged = 5*HZ;
180#endif 180#endif
181#ifdef HAS_REMOTE_BUTTON_HOLD
182static int remote_backlight_on_button_hold = 0;
183#endif
181#endif 184#endif
182 185
183#ifdef HAVE_LCD_SLEEP 186#ifdef HAVE_LCD_SLEEP
@@ -461,6 +464,10 @@ static void remote_backlight_update_state(void)
461 if (remote_backlight_timer < 0) 464 if (remote_backlight_timer < 0)
462 { 465 {
463 remote_backlight_timer = 0; /* Disable the timeout */ 466 remote_backlight_timer = 0; /* Disable the timeout */
467#ifdef HAS_REMOTE_BUTTON_HOLD
468 if (remote_backlight_on_button_hold == 2 && remote_button_hold())
469 return; /* Keep on if "On" */
470#endif
464 __remote_backlight_off(); 471 __remote_backlight_off();
465 } 472 }
466 else 473 else
@@ -471,8 +478,18 @@ static void remote_backlight_update_state(void)
471 backlight_update_state(); 478 backlight_update_state();
472 } 479 }
473 else 480 else
474#endif 481#endif
482 {
483#ifdef HAS_REMOTE_BUTTON_HOLD
484 if (remote_backlight_on_button_hold == 1 && remote_button_hold())
485 {
486 /* Keep off if "Off". */
487 remote_backlight_timer = 0; /* Disable the timeout */
488 return;
489 }
490#endif
475 __remote_backlight_on(); 491 __remote_backlight_on();
492 }
476 } 493 }
477} 494}
478#endif /* HAVE_REMOTE_LCD */ 495#endif /* HAVE_REMOTE_LCD */
@@ -493,9 +510,15 @@ void backlight_thread(void)
493 510
494 case REMOTE_BACKLIGHT_OFF: 511 case REMOTE_BACKLIGHT_OFF:
495 remote_backlight_timer = 0; /* Disable the timeout */ 512 remote_backlight_timer = 0; /* Disable the timeout */
513#ifdef HAS_REMOTE_BUTTON_HOLD
514 if (remote_backlight_on_button_hold == 2 &&
515 remote_button_hold())
516 break; /* Keep on if "On" */
517#endif
496 __remote_backlight_off(); 518 __remote_backlight_off();
497 break; 519 break;
498#endif 520#endif /* HAVE_REMOTE_LCD */
521
499 case BACKLIGHT_ON: 522 case BACKLIGHT_ON:
500 backlight_update_state(); 523 backlight_update_state();
501 break; 524 break;
@@ -701,9 +724,7 @@ void backlight_hold_changed(bool hold_button)
701 set to "Normal" */ 724 set to "Normal" */
702 /* Queue or freeze */ 725 /* Queue or freeze */
703 if (hold_button && backlight_on_button_hold == 1) 726 if (hold_button && backlight_on_button_hold == 1)
704 {
705 backlight_off(); /* setting == Off */ 727 backlight_off(); /* setting == Off */
706 }
707 else /* setting == On, Normal, no hold button, or anything else */ 728 else /* setting == On, Normal, no hold button, or anything else */
708 backlight_on(); 729 backlight_on();
709} 730}
@@ -774,6 +795,34 @@ void remote_backlight_set_timeout_plugged(int index)
774} 795}
775#endif /* CONFIG_CHARGING */ 796#endif /* CONFIG_CHARGING */
776 797
798#ifdef HAS_REMOTE_BUTTON_HOLD
799/* Remote hold button change event handler. */
800void remote_backlight_hold_changed(bool rc_hold_button)
801{
802 /* Hold switch overrides all backlight behavior except when
803 set to "Normal" */
804 /* Queue or freeze */
805 if (rc_hold_button && remote_backlight_on_button_hold == 1)
806 remote_backlight_off(); /* setting == Off */
807 else /* setting == On, Normal, no hold button, or anything else */
808 remote_backlight_on();
809
810}
811
812void remote_backlight_set_on_button_hold(int index)
813{
814 if ((unsigned)index >= 3)
815 /* if given a weird value, use default */
816 index = 0;
817
818 if (index == remote_backlight_on_button_hold)
819 return;
820
821 remote_backlight_on_button_hold = index;
822 remote_backlight_hold_changed(remote_button_hold());
823}
824#endif /* HAS_REMOTE_BUTTON_HOLD */
825
777/* return value in ticks; 0 means always on, <0 means always off */ 826/* return value in ticks; 0 means always on, <0 means always off */
778int remote_backlight_get_current_timeout(void) 827int remote_backlight_get_current_timeout(void)
779{ 828{
diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c
index 1ebac066e7..d00f89958a 100644
--- a/firmware/drivers/adc.c
+++ b/firmware/drivers/adc.c
@@ -123,6 +123,7 @@ static int channelnum[] =
123 123
124unsigned short adc_scan(int channel) 124unsigned short adc_scan(int channel)
125{ 125{
126 int level = set_irq_level(HIGHEST_IRQ_LEVEL);
126 unsigned char data; 127 unsigned char data;
127 128
128 pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1); 129 pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1);
@@ -130,6 +131,7 @@ unsigned short adc_scan(int channel)
130 131
131 adcdata[channel] = data; 132 adcdata[channel] = data;
132 133
134 set_irq_level(level);
133 return data; 135 return data;
134} 136}
135#else 137#else
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index f31ab33c87..5e6f6b4827 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -845,6 +845,7 @@ static int button_read(void)
845 static int prev_data = 0xff; 845 static int prev_data = 0xff;
846 static int last_valid = 0xff; 846 static int last_valid = 0xff;
847 bool hold_button_old; 847 bool hold_button_old;
848 bool remote_hold_button_old;
848 849
849 /* normal buttons */ 850 /* normal buttons */
850 hold_button_old = hold_button; 851 hold_button_old = hold_button;
@@ -916,12 +917,13 @@ static int button_read(void)
916 } 917 }
917 918
918 /* remote buttons */ 919 /* remote buttons */
920 remote_hold_button_old = remote_hold_button;
919 remote_hold_button = remote_button_hold_only(); 921 remote_hold_button = remote_button_hold_only();
920 922
921 if (remote_hold_button && !remote_button_hold_only()) 923#ifndef BOOTLOADER
922 { 924 if (remote_hold_button != remote_hold_button_old)
923 remote_backlight_on(); 925 remote_backlight_hold_changed(remote_hold_button);
924 } 926#endif
925 927
926 if (!remote_hold_button) 928 if (!remote_hold_button)
927 { 929 {
diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h
index 62f024816f..6875768f0c 100644
--- a/firmware/export/backlight.h
+++ b/firmware/export/backlight.h
@@ -25,27 +25,35 @@ bool is_backlight_on(void);
25void backlight_on(void); 25void backlight_on(void);
26void backlight_off(void); 26void backlight_off(void);
27void backlight_set_timeout(int index); 27void backlight_set_timeout(int index);
28
28#ifdef CONFIG_BACKLIGHT 29#ifdef CONFIG_BACKLIGHT
29void backlight_init(void); 30void backlight_init(void);
31
30#if defined(IAUDIO_X5) && !defined(SIMULATOR) 32#if defined(IAUDIO_X5) && !defined(SIMULATOR)
31#define X5_BACKLIGHT_SHUTDOWN 33#define X5_BACKLIGHT_SHUTDOWN
32void x5_backlight_shutdown(void); 34void x5_backlight_shutdown(void);
33#endif 35#endif
36
34int backlight_get_current_timeout(void); 37int backlight_get_current_timeout(void);
38
35#ifdef HAVE_BACKLIGHT_PWM_FADING 39#ifdef HAVE_BACKLIGHT_PWM_FADING
36void backlight_set_fade_in(int index); 40void backlight_set_fade_in(int index);
37void backlight_set_fade_out(int index); 41void backlight_set_fade_out(int index);
38#endif 42#endif
43
39void backlight_set_timeout_plugged(int index); 44void backlight_set_timeout_plugged(int index);
40extern const signed char backlight_timeout_value[]; 45extern const signed char backlight_timeout_value[];
46
41#ifdef HAS_BUTTON_HOLD 47#ifdef HAS_BUTTON_HOLD
42void backlight_set_on_button_hold(int index);
43void backlight_hold_changed(bool hold_button); 48void backlight_hold_changed(bool hold_button);
49void backlight_set_on_button_hold(int index);
44#endif 50#endif
51
45#ifdef HAVE_LCD_SLEEP 52#ifdef HAVE_LCD_SLEEP
46void lcd_set_sleep_after_backlight_off(int index); 53void lcd_set_sleep_after_backlight_off(int index);
47extern const signed char lcd_sleep_timeout_value[]; 54extern const signed char lcd_sleep_timeout_value[];
48#endif 55#endif
56
49#else /* ndef CONFIG_BACKLIGHT */ 57#else /* ndef CONFIG_BACKLIGHT */
50#define backlight_init() 58#define backlight_init()
51#endif /* CONFIG_BACKLIGHT */ 59#endif /* CONFIG_BACKLIGHT */
@@ -56,15 +64,20 @@ void remote_backlight_off(void);
56void remote_backlight_set_timeout(int index); 64void remote_backlight_set_timeout(int index);
57void remote_backlight_set_timeout_plugged(int index); 65void remote_backlight_set_timeout_plugged(int index);
58bool is_remote_backlight_on(void); 66bool is_remote_backlight_on(void);
67
68#ifdef HAS_REMOTE_BUTTON_HOLD
69void remote_backlight_hold_changed(bool rc_hold_button);
70void remote_backlight_set_on_button_hold(int index);
59#endif 71#endif
72#endif /* HAVE_REMOTE_LCD */
60 73
61#ifdef SIMULATOR 74#ifdef SIMULATOR
62void sim_backlight(int value); 75void sim_backlight(int value);
63void sim_remote_backlight(int value); 76void sim_remote_backlight(int value);
64#endif 77#endif
65#endif
66 78
67#ifdef HAVE_BACKLIGHT_BRIGHTNESS 79#ifdef HAVE_BACKLIGHT_BRIGHTNESS
80
68#ifdef IAUDIO_X5 81#ifdef IAUDIO_X5
69/* PFC50506 can output 0%-100% duty cycle but D305A expects %15-100%. */ 82/* PFC50506 can output 0%-100% duty cycle but D305A expects %15-100%. */
70#define MIN_BRIGHTNESS_SETTING 1 /* 15/16 (93.75%) */ 83#define MIN_BRIGHTNESS_SETTING 1 /* 15/16 (93.75%) */
@@ -74,7 +87,9 @@ void sim_remote_backlight(int value);
74#define MIN_BRIGHTNESS_SETTING 2 /* 2/16 (12.50%) */ 87#define MIN_BRIGHTNESS_SETTING 2 /* 2/16 (12.50%) */
75#define MAX_BRIGHTNESS_SETTING 15 /* 15/16 (93.75%) */ 88#define MAX_BRIGHTNESS_SETTING 15 /* 15/16 (93.75%) */
76#define DEFAULT_BRIGHTNESS_SETTING 9 /* 9/16 (56.25%) */ 89#define DEFAULT_BRIGHTNESS_SETTING 9 /* 9/16 (56.25%) */
77#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ 90#endif
78 91
79void backlight_set_brightness(int val); 92void backlight_set_brightness(int val);
80#endif 93#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
94
95#endif /* BACKLIGHT_H */
diff --git a/firmware/target/coldfire/iaudio/x5/adc-x5.c b/firmware/target/coldfire/iaudio/x5/adc-x5.c
index e465f38494..fc45da8624 100755
--- a/firmware/target/coldfire/iaudio/x5/adc-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/adc-x5.c
@@ -35,6 +35,7 @@ static int channelnum[] =
35 35
36unsigned short adc_scan(int channel) 36unsigned short adc_scan(int channel)
37{ 37{
38 int level = set_irq_level(HIGHEST_IRQ_LEVEL);
38 unsigned char data; 39 unsigned char data;
39 40
40 pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1); 41 pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1);
@@ -42,6 +43,7 @@ unsigned short adc_scan(int channel)
42 43
43 adcdata[channel] = data; 44 adcdata[channel] = data;
44 45
46 set_irq_level(level);
45 return data; 47 return data;
46} 48}
47 49
diff --git a/firmware/target/coldfire/iaudio/x5/button-x5.c b/firmware/target/coldfire/iaudio/x5/button-x5.c
index 287ee0e92b..84d1dbc7d8 100755
--- a/firmware/target/coldfire/iaudio/x5/button-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/button-x5.c
@@ -41,7 +41,7 @@ bool button_hold(void)
41 41
42bool remote_button_hold(void) 42bool remote_button_hold(void)
43{ 43{
44 return false; /* TODO X5 */ 44 return adc_scan(ADC_REMOTE) < 0x17;
45} 45}
46 46
47int button_read_device(void) 47int button_read_device(void)
@@ -51,6 +51,7 @@ int button_read_device(void)
51 static bool hold_button = false; 51 static bool hold_button = false;
52 static bool remote_hold_button = false; 52 static bool remote_hold_button = false;
53 bool hold_button_old; 53 bool hold_button_old;
54 bool remote_hold_button_old;
54 55
55 /* normal buttons */ 56 /* normal buttons */
56 hold_button_old = hold_button; 57 hold_button_old = hold_button;
@@ -90,14 +91,15 @@ int button_read_device(void)
90 } 91 }
91 92
92 /* remote buttons */ 93 /* remote buttons */
93 94 remote_hold_button_old = remote_hold_button;
94 /* TODO: add light handling for the remote */
95
96 remote_hold_button = remote_button_hold();
97 95
98 data = adc_scan(ADC_REMOTE); 96 data = adc_scan(ADC_REMOTE);
99 if(data < 0x17) 97 remote_hold_button = data < 0x17;
100 remote_hold_button = true; 98
99#ifndef BOOTLOADER
100 if (remote_hold_button != remote_hold_button_old)
101 remote_backlight_hold_changed(remote_hold_button);
102#endif
101 103
102 if(!remote_hold_button) 104 if(!remote_hold_button)
103 { 105 {
diff --git a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
index dde20d8b7c..032c30814a 100644
--- a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
@@ -177,7 +177,7 @@ void pcf50606_init(void)
177 and_l(~0x00000001, &GPIO_ENABLE); 177 and_l(~0x00000001, &GPIO_ENABLE);
178 or_l(0x00000001, &GPIO_FUNCTION); 178 or_l(0x00000001, &GPIO_FUNCTION);
179 or_l(0x00000100, &GPIO_INT_EN); /* GPI0 H-L */ 179 or_l(0x00000100, &GPIO_INT_EN); /* GPI0 H-L */
180 INTPRI5 |= 0x00000006; /* INT32 - Priority 6 */ 180 INTPRI5 |= (6 << 0); /* INT32 - Priority 6 */
181 181
182 pcf50606_write(0x39, 0x00); /* GPOOD0 = green led OFF */ 182 pcf50606_write(0x39, 0x00); /* GPOOD0 = green led OFF */
183 pcf50606_write(0x3a, 0x00); /* GPOOD1 = red led OFF */ 183 pcf50606_write(0x3a, 0x00); /* GPOOD1 = red led OFF */