diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2006-02-17 22:38:38 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2006-02-17 22:38:38 +0000 |
commit | 00811840c9198833e6b234939b1509d52a51c880 (patch) | |
tree | 21659dbffbd8f1714d4c72eddfefa2f938291628 /firmware | |
parent | 5519d82137062f49f264332af329e711299ce6f0 (diff) | |
download | rockbox-00811840c9198833e6b234939b1509d52a51c880.tar.gz rockbox-00811840c9198833e6b234939b1509d52a51c880.zip |
Remote type autodetection on iriver, remote_type() returns REMOTETYPE_H100_LCD, REMOTETYPE_H300_LCD or REMOTETYPE_H300_NONLCD
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8721 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/adc.c | 9 | ||||
-rw-r--r-- | firmware/drivers/lcd-h100-remote.c | 24 | ||||
-rw-r--r-- | firmware/export/adc.h | 1 | ||||
-rw-r--r-- | firmware/export/config-h100.h | 5 | ||||
-rw-r--r-- | firmware/export/config-h120.h | 4 | ||||
-rw-r--r-- | firmware/export/config-h300.h | 5 | ||||
-rw-r--r-- | firmware/export/lcd-remote.h | 8 |
7 files changed, 53 insertions, 3 deletions
diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c index c9e11e0f56..b71583ca05 100644 --- a/firmware/drivers/adc.c +++ b/firmware/drivers/adc.c | |||
@@ -113,9 +113,10 @@ static unsigned char adcdata[NUM_ADC_CHANNELS]; | |||
113 | #ifdef IRIVER_H300_SERIES | 113 | #ifdef IRIVER_H300_SERIES |
114 | static int channelnum[] = | 114 | static int channelnum[] = |
115 | { | 115 | { |
116 | 5, /* ADC_BUTTONS */ | 116 | 5, /* ADC_BUTTONS (ADCIN2) */ |
117 | 6, /* ADC_REMOTE */ | 117 | 6, /* ADC_REMOTE (ADCIN3) */ |
118 | 0, /* ADC_BATTERY */ | 118 | 0, /* ADC_BATTERY (BATVOLT, resistive divider) */ |
119 | 2, /* ADC_REMOTEDETECT (ADCIN1, resistive divider) */ | ||
119 | }; | 120 | }; |
120 | 121 | ||
121 | unsigned char adc_scan(int channel) | 122 | unsigned char adc_scan(int channel) |
@@ -212,6 +213,8 @@ static void adc_tick(void) | |||
212 | { | 213 | { |
213 | adc_counter = 0; | 214 | adc_counter = 0; |
214 | adc_scan(ADC_BATTERY); | 215 | adc_scan(ADC_BATTERY); |
216 | adc_scan(ADC_REMOTEDETECT); /* Temporary. Remove when the remote | ||
217 | detection feels stable. */ | ||
215 | } | 218 | } |
216 | } | 219 | } |
217 | 220 | ||
diff --git a/firmware/drivers/lcd-h100-remote.c b/firmware/drivers/lcd-h100-remote.c index 0b9edf6c99..6bbe01a4c9 100644 --- a/firmware/drivers/lcd-h100-remote.c +++ b/firmware/drivers/lcd-h100-remote.c | |||
@@ -446,10 +446,19 @@ static void remote_lcd_init(void) | |||
446 | lcd_remote_roll(cached_roll); | 446 | lcd_remote_roll(cached_roll); |
447 | } | 447 | } |
448 | 448 | ||
449 | static int _remote_type = 0; | ||
450 | |||
451 | int remote_type(void) | ||
452 | { | ||
453 | return _remote_type; | ||
454 | } | ||
455 | |||
449 | /* Monitor remote hotswap */ | 456 | /* Monitor remote hotswap */ |
450 | static void remote_tick(void) | 457 | static void remote_tick(void) |
451 | { | 458 | { |
452 | bool current_status; | 459 | bool current_status; |
460 | int val; | ||
461 | int level; | ||
453 | 462 | ||
454 | current_status = ((GPIO_READ & 0x40000000) == 0); | 463 | current_status = ((GPIO_READ & 0x40000000) == 0); |
455 | /* Only report when the status has changed */ | 464 | /* Only report when the status has changed */ |
@@ -468,6 +477,20 @@ static void remote_tick(void) | |||
468 | { | 477 | { |
469 | if (current_status) | 478 | if (current_status) |
470 | { | 479 | { |
480 | /* Determine which type of remote it is. | ||
481 | The number 8 is just a fudge factor. */ | ||
482 | level = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
483 | val = adc_scan(ADC_REMOTEDETECT); | ||
484 | set_irq_level(level); | ||
485 | |||
486 | if(val < (ADCVAL_H100_LCD_REMOTE + 8)) | ||
487 | if(val < (ADCVAL_H300_LCD_REMOTE + 8)) | ||
488 | _remote_type = REMOTETYPE_H300_LCD; | ||
489 | else | ||
490 | _remote_type = REMOTETYPE_H100_LCD; | ||
491 | else | ||
492 | _remote_type = REMOTETYPE_H300_NONLCD; | ||
493 | |||
471 | init_remote = true; | 494 | init_remote = true; |
472 | /* request init in scroll_thread */ | 495 | /* request init in scroll_thread */ |
473 | } | 496 | } |
@@ -476,6 +499,7 @@ static void remote_tick(void) | |||
476 | CLK_LO; | 499 | CLK_LO; |
477 | CS_HI; | 500 | CS_HI; |
478 | remote_initialized = false; | 501 | remote_initialized = false; |
502 | _remote_type = 0; | ||
479 | } | 503 | } |
480 | } | 504 | } |
481 | } | 505 | } |
diff --git a/firmware/export/adc.h b/firmware/export/adc.h index 8364cdb012..4082e4b39b 100644 --- a/firmware/export/adc.h +++ b/firmware/export/adc.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #define ADC_BUTTONS 0 | 27 | #define ADC_BUTTONS 0 |
28 | #define ADC_REMOTE 1 | 28 | #define ADC_REMOTE 1 |
29 | #define ADC_BATTERY 2 | 29 | #define ADC_BATTERY 2 |
30 | #define ADC_REMOTEDETECT 3 | ||
30 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | 31 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ |
31 | 32 | ||
32 | #elif defined(IRIVER_IFP7XX) | 33 | #elif defined(IRIVER_IFP7XX) |
diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h index b9677b5fb2..87598c208e 100644 --- a/firmware/export/config-h100.h +++ b/firmware/export/config-h100.h | |||
@@ -114,3 +114,8 @@ | |||
114 | /* Define this if you can control the S/PDIF power */ | 114 | /* Define this if you can control the S/PDIF power */ |
115 | #define HAVE_SPDIF_POWER | 115 | #define HAVE_SPDIF_POWER |
116 | #define SPDIF_POWER_INVERTED | 116 | #define SPDIF_POWER_INVERTED |
117 | |||
118 | /* ADC values for different remote control types */ | ||
119 | #define ADCVAL_H100_LCD_REMOTE 0x6a | ||
120 | #define ADCVAL_H300_LCD_REMOTE 0x50 | ||
121 | #define ADCVAL_H300_NONLCD_REMOTE 0xfc | ||
diff --git a/firmware/export/config-h120.h b/firmware/export/config-h120.h index 252d3c1af8..fd62243d8a 100644 --- a/firmware/export/config-h120.h +++ b/firmware/export/config-h120.h | |||
@@ -109,3 +109,7 @@ | |||
109 | /* Define this if you can control the S/PDIF power */ | 109 | /* Define this if you can control the S/PDIF power */ |
110 | #define HAVE_SPDIF_POWER | 110 | #define HAVE_SPDIF_POWER |
111 | 111 | ||
112 | /* ADC values for different remote control types */ | ||
113 | #define ADCVAL_H100_LCD_REMOTE 0x6a | ||
114 | #define ADCVAL_H300_LCD_REMOTE 0x50 | ||
115 | #define ADCVAL_H300_NONLCD_REMOTE 0xfc | ||
diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h index 88feb9d649..45d3265010 100644 --- a/firmware/export/config-h300.h +++ b/firmware/export/config-h300.h | |||
@@ -113,4 +113,9 @@ | |||
113 | /* define this if the unit can be powered or charged via USB */ | 113 | /* define this if the unit can be powered or charged via USB */ |
114 | #define HAVE_USB_POWER | 114 | #define HAVE_USB_POWER |
115 | 115 | ||
116 | /* ADC values for different remote control types */ | ||
117 | #define ADCVAL_H100_LCD_REMOTE 0x3c | ||
118 | #define ADCVAL_H300_LCD_REMOTE 0x2b | ||
119 | #define ADCVAL_H300_NONLCD_REMOTE 0x8e | ||
120 | |||
116 | #endif | 121 | #endif |
diff --git a/firmware/export/lcd-remote.h b/firmware/export/lcd-remote.h index 8e5fa950b1..c27a0d4e73 100644 --- a/firmware/export/lcd-remote.h +++ b/firmware/export/lcd-remote.h | |||
@@ -23,12 +23,20 @@ | |||
23 | #include <stdbool.h> | 23 | #include <stdbool.h> |
24 | #include "cpu.h" | 24 | #include "cpu.h" |
25 | #include "config.h" | 25 | #include "config.h" |
26 | #include "adc.h" | ||
26 | 27 | ||
27 | #ifdef HAVE_REMOTE_LCD | 28 | #ifdef HAVE_REMOTE_LCD |
28 | 29 | ||
29 | #define STYLE_DEFAULT 0 | 30 | #define STYLE_DEFAULT 0 |
30 | #define STYLE_INVERT 1 | 31 | #define STYLE_INVERT 1 |
31 | 32 | ||
33 | #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) | ||
34 | #define REMOTETYPE_H100_LCD 1 | ||
35 | #define REMOTETYPE_H300_LCD 2 | ||
36 | #define REMOTETYPE_H300_NONLCD 3 | ||
37 | extern int remote_type(void); | ||
38 | #endif | ||
39 | |||
32 | extern void lcd_remote_init(void); | 40 | extern void lcd_remote_init(void); |
33 | extern int lcd_remote_default_contrast(void); | 41 | extern int lcd_remote_default_contrast(void); |
34 | extern void lcd_remote_set_contrast(int val); | 42 | extern void lcd_remote_set_contrast(int val); |