summaryrefslogtreecommitdiff
path: root/firmware/target/arm/s3c2440/gigabeat-fx
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-01-27 21:13:04 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-01-27 21:13:04 +0000
commit0efdd7a5f74c955d0eb604cd3fef9069be57bcbb (patch)
tree3da7c91ca05c154a31564c0045308256c206b1fd /firmware/target/arm/s3c2440/gigabeat-fx
parent637e26e8e4c87e25bcdc5f6793b86d34061e7aae (diff)
downloadrockbox-0efdd7a5f74c955d0eb604cd3fef9069be57bcbb.tar.gz
rockbox-0efdd7a5f74c955d0eb604cd3fef9069be57bcbb.zip
Use the timeout API as a oneshot for headphone plug debouncing. Set at 1s for now which seems comfortable and was good for meg-fx but target-specific adjustment is easy enough (my 3G hp jack is dead so I can't check that one :( ). Do some minor rearrangements for init safety and consistency.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16178 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/s3c2440/gigabeat-fx')
-rw-r--r--firmware/target/arm/s3c2440/gigabeat-fx/button-meg-fx.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/button-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/button-meg-fx.c
index 4a818d6bfc..a80663d0d6 100644
--- a/firmware/target/arm/s3c2440/gigabeat-fx/button-meg-fx.c
+++ b/firmware/target/arm/s3c2440/gigabeat-fx/button-meg-fx.c
@@ -76,6 +76,16 @@ int button_read_device(void)
76 /* Only one button can be sensed at a time on the remote. */ 76 /* Only one button can be sensed at a time on the remote. */
77 /* Need to filter the remote button because the ADC is so fast */ 77 /* Need to filter the remote button because the ADC is so fast */
78 remote_adc = adc_read(ADC_HPREMOTE); 78 remote_adc = adc_read(ADC_HPREMOTE);
79
80 if (remote_adc != ADC_READ_ERROR)
81 {
82 /* If there is nothing in the headphone socket, the ADC reads high */
83 if (remote_adc < 940)
84 headphones_detect = true;
85 else
86 headphones_detect = false;
87 }
88
79 btn = remote_buttons[(remote_adc + 64) / 128]; 89 btn = remote_buttons[(remote_adc + 64) / 128];
80 if (btn != lastbutton) 90 if (btn != lastbutton)
81 { 91 {
@@ -136,14 +146,5 @@ int button_read_device(void)
136 146
137bool headphones_inserted(void) 147bool headphones_inserted(void)
138{ 148{
139 unsigned short remote_adc = adc_read(ADC_HPREMOTE);
140 if (remote_adc != ADC_READ_ERROR)
141 {
142 /* If there is nothing in the headphone socket, the ADC reads high */
143 if (remote_adc < 940)
144 headphones_detect = true;
145 else
146 headphones_detect = false;
147 }
148 return headphones_detect; 149 return headphones_detect;
149} 150}