summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2006-02-17 22:38:38 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2006-02-17 22:38:38 +0000
commit00811840c9198833e6b234939b1509d52a51c880 (patch)
tree21659dbffbd8f1714d4c72eddfefa2f938291628 /firmware
parent5519d82137062f49f264332af329e711299ce6f0 (diff)
downloadrockbox-00811840c9198833e6b234939b1509d52a51c880.tar.gz
rockbox-00811840c9198833e6b234939b1509d52a51c880.tar.bz2
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.c9
-rw-r--r--firmware/drivers/lcd-h100-remote.c24
-rw-r--r--firmware/export/adc.h1
-rw-r--r--firmware/export/config-h100.h5
-rw-r--r--firmware/export/config-h120.h4
-rw-r--r--firmware/export/config-h300.h5
-rw-r--r--firmware/export/lcd-remote.h8
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];
#ifdef IRIVER_H300_SERIES
static int channelnum[] =
{
- 5, /* ADC_BUTTONS */
- 6, /* ADC_REMOTE */
- 0, /* ADC_BATTERY */
+ 5, /* ADC_BUTTONS (ADCIN2) */
+ 6, /* ADC_REMOTE (ADCIN3) */
+ 0, /* ADC_BATTERY (BATVOLT, resistive divider) */
+ 2, /* ADC_REMOTEDETECT (ADCIN1, resistive divider) */
};
unsigned char adc_scan(int channel)
@@ -212,6 +213,8 @@ static void adc_tick(void)
{
adc_counter = 0;
adc_scan(ADC_BATTERY);
+ adc_scan(ADC_REMOTEDETECT); /* Temporary. Remove when the remote
+ detection feels stable. */
}
}
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)
lcd_remote_roll(cached_roll);
}
+static int _remote_type = 0;
+
+int remote_type(void)
+{
+ return _remote_type;
+}
+
/* Monitor remote hotswap */
static void remote_tick(void)
{
bool current_status;
+ int val;
+ int level;
current_status = ((GPIO_READ & 0x40000000) == 0);
/* Only report when the status has changed */
@@ -468,6 +477,20 @@ static void remote_tick(void)
{
if (current_status)
{
+ /* Determine which type of remote it is.
+ The number 8 is just a fudge factor. */
+ level = set_irq_level(HIGHEST_IRQ_LEVEL);
+ val = adc_scan(ADC_REMOTEDETECT);
+ set_irq_level(level);
+
+ if(val < (ADCVAL_H100_LCD_REMOTE + 8))
+ if(val < (ADCVAL_H300_LCD_REMOTE + 8))
+ _remote_type = REMOTETYPE_H300_LCD;
+ else
+ _remote_type = REMOTETYPE_H100_LCD;
+ else
+ _remote_type = REMOTETYPE_H300_NONLCD;
+
init_remote = true;
/* request init in scroll_thread */
}
@@ -476,6 +499,7 @@ static void remote_tick(void)
CLK_LO;
CS_HI;
remote_initialized = false;
+ _remote_type = 0;
}
}
}
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 @@
#define ADC_BUTTONS 0
#define ADC_REMOTE 1
#define ADC_BATTERY 2
+#define ADC_REMOTEDETECT 3
#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */
#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 @@
/* Define this if you can control the S/PDIF power */
#define HAVE_SPDIF_POWER
#define SPDIF_POWER_INVERTED
+
+/* ADC values for different remote control types */
+#define ADCVAL_H100_LCD_REMOTE 0x6a
+#define ADCVAL_H300_LCD_REMOTE 0x50
+#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 @@
/* Define this if you can control the S/PDIF power */
#define HAVE_SPDIF_POWER
+/* ADC values for different remote control types */
+#define ADCVAL_H100_LCD_REMOTE 0x6a
+#define ADCVAL_H300_LCD_REMOTE 0x50
+#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 @@
/* define this if the unit can be powered or charged via USB */
#define HAVE_USB_POWER
+/* ADC values for different remote control types */
+#define ADCVAL_H100_LCD_REMOTE 0x3c
+#define ADCVAL_H300_LCD_REMOTE 0x2b
+#define ADCVAL_H300_NONLCD_REMOTE 0x8e
+
#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 @@
#include <stdbool.h>
#include "cpu.h"
#include "config.h"
+#include "adc.h"
#ifdef HAVE_REMOTE_LCD
#define STYLE_DEFAULT 0
#define STYLE_INVERT 1
+#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
+#define REMOTETYPE_H100_LCD 1
+#define REMOTETYPE_H300_LCD 2
+#define REMOTETYPE_H300_NONLCD 3
+extern int remote_type(void);
+#endif
+
extern void lcd_remote_init(void);
extern int lcd_remote_default_contrast(void);
extern void lcd_remote_set_contrast(int val);