summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2010-11-05 17:04:18 +0000
committerBertrik Sikken <bertrik@sikken.nl>2010-11-05 17:04:18 +0000
commit981a639ade46b89a14d37f86a240cb39cdfb2513 (patch)
treec419dda0520c56e3df0e6ecbe87d802f5a72494a
parentf174c3513b4b2a4a0583a2b72ee442bbb211d442 (diff)
downloadrockbox-981a639ade46b89a14d37f86a240cb39cdfb2513.tar.gz
rockbox-981a639ade46b89a14d37f86a240cb39cdfb2513.zip
Implement tea5767 tuner detection - FS#11714 by me
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28493 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/tuner/tea5767.c23
-rw-r--r--firmware/export/tea5767.h1
-rw-r--r--firmware/tuner.c3
3 files changed, 25 insertions, 2 deletions
diff --git a/firmware/drivers/tuner/tea5767.c b/firmware/drivers/tuner/tea5767.c
index b16bb4b7c5..7660fa783d 100644
--- a/firmware/drivers/tuner/tea5767.c
+++ b/firmware/drivers/tuner/tea5767.c
@@ -34,6 +34,7 @@
34#define I2C_ADR 0xC0 34#define I2C_ADR 0xC0
35#endif 35#endif
36 36
37static bool tuner_present = true;
37static unsigned char write_bytes[5] = { 0x00, 0x00, 0x00, 0x00, 0x00 }; 38static unsigned char write_bytes[5] = { 0x00, 0x00, 0x00, 0x00, 0x00 };
38 39
39static void tea5767_set_clear(int byte, unsigned char bits, int set) 40static void tea5767_set_clear(int byte, unsigned char bits, int set)
@@ -116,7 +117,7 @@ int tea5767_get(int setting)
116 switch(setting) 117 switch(setting)
117 { 118 {
118 case RADIO_PRESENT: 119 case RADIO_PRESENT:
119 val = 1; /* true */ 120 val = tuner_present;
120 break; 121 break;
121 122
122 case RADIO_TUNED: 123 case RADIO_TUNED:
@@ -136,6 +137,26 @@ int tea5767_get(int setting)
136 return val; 137 return val;
137} 138}
138 139
140void tea5767_init(void)
141{
142/* save binsize by only detecting presence for targets where it may be absent */
143#if defined(PHILIPS_HDD1630)
144 unsigned char buf[5];
145 unsigned char chipid;
146
147 /* init chipid register with 0xFF in case fmradio_i2c_read fails silently */
148 buf[3] = 0xFF;
149 if (fmradio_i2c_read(I2C_ADR, buf, sizeof(buf)) < 0) {
150 /* no i2c device detected */
151 tuner_present = false;
152 } else {
153 /* check chip id */
154 chipid = buf[3] & 0x0F;
155 tuner_present = (chipid == 0);
156 }
157#endif
158}
159
139void tea5767_dbg_info(struct tea5767_dbg_info *info) 160void tea5767_dbg_info(struct tea5767_dbg_info *info)
140{ 161{
141 fmradio_i2c_read(I2C_ADR, info->read_regs, 5); 162 fmradio_i2c_read(I2C_ADR, info->read_regs, 5);
diff --git a/firmware/export/tea5767.h b/firmware/export/tea5767.h
index eee469d1ea..64dd266311 100644
--- a/firmware/export/tea5767.h
+++ b/firmware/export/tea5767.h
@@ -32,6 +32,7 @@ struct tea5767_dbg_info
32 unsigned char write_regs[5]; 32 unsigned char write_regs[5];
33}; 33};
34 34
35void tea5767_init(void);
35int tea5767_set(int setting, int value); 36int tea5767_set(int setting, int value);
36int tea5767_get(int setting); 37int tea5767_get(int setting);
37void tea5767_dbg_info(struct tea5767_dbg_info *info); 38void tea5767_dbg_info(struct tea5767_dbg_info *info);
diff --git a/firmware/tuner.c b/firmware/tuner.c
index e08cef46ff..278584264b 100644
--- a/firmware/tuner.c
+++ b/firmware/tuner.c
@@ -74,7 +74,8 @@ void tuner_init(void)
74 #if (CONFIG_TUNER & TEA5767) 74 #if (CONFIG_TUNER & TEA5767)
75 TUNER_TYPE_CASE(TEA5767, 75 TUNER_TYPE_CASE(TEA5767,
76 tea5767_set, 76 tea5767_set,
77 tea5767_get) 77 tea5767_get,
78 tea5767_init())
78 #endif 79 #endif
79 #if (CONFIG_TUNER & S1A0903X01) 80 #if (CONFIG_TUNER & S1A0903X01)
80 TUNER_TYPE_CASE(S1A0903X01, 81 TUNER_TYPE_CASE(S1A0903X01,