summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 @@
#define I2C_ADR 0xC0
#endif
+static bool tuner_present = true;
static unsigned char write_bytes[5] = { 0x00, 0x00, 0x00, 0x00, 0x00 };
static void tea5767_set_clear(int byte, unsigned char bits, int set)
@@ -116,7 +117,7 @@ int tea5767_get(int setting)
switch(setting)
{
case RADIO_PRESENT:
- val = 1; /* true */
+ val = tuner_present;
break;
case RADIO_TUNED:
@@ -136,6 +137,26 @@ int tea5767_get(int setting)
return val;
}
+void tea5767_init(void)
+{
+/* save binsize by only detecting presence for targets where it may be absent */
+#if defined(PHILIPS_HDD1630)
+ unsigned char buf[5];
+ unsigned char chipid;
+
+ /* init chipid register with 0xFF in case fmradio_i2c_read fails silently */
+ buf[3] = 0xFF;
+ if (fmradio_i2c_read(I2C_ADR, buf, sizeof(buf)) < 0) {
+ /* no i2c device detected */
+ tuner_present = false;
+ } else {
+ /* check chip id */
+ chipid = buf[3] & 0x0F;
+ tuner_present = (chipid == 0);
+ }
+#endif
+}
+
void tea5767_dbg_info(struct tea5767_dbg_info *info)
{
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
unsigned char write_regs[5];
};
+void tea5767_init(void);
int tea5767_set(int setting, int value);
int tea5767_get(int setting);
void 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)
#if (CONFIG_TUNER & TEA5767)
TUNER_TYPE_CASE(TEA5767,
tea5767_set,
- tea5767_get)
+ tea5767_get,
+ tea5767_init())
#endif
#if (CONFIG_TUNER & S1A0903X01)
TUNER_TYPE_CASE(S1A0903X01,