From 981a639ade46b89a14d37f86a240cb39cdfb2513 Mon Sep 17 00:00:00 2001 From: Bertrik Sikken Date: Fri, 5 Nov 2010 17:04:18 +0000 Subject: Implement tea5767 tuner detection - FS#11714 by me git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28493 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/tuner/tea5767.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'firmware/drivers/tuner/tea5767.c') 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); -- cgit v1.2.3