Index: firmware/export/tea5767.h =================================================================== --- firmware/export/tea5767.h (revision 28463) +++ firmware/export/tea5767.h (working copy) @@ -32,6 +32,7 @@ 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); Index: firmware/drivers/tuner/tea5767.c =================================================================== --- firmware/drivers/tuner/tea5767.c (revision 28463) +++ firmware/drivers/tuner/tea5767.c (working copy) @@ -34,6 +34,7 @@ #define I2C_ADR 0xC0 #endif +static bool tuner_present = false; 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 @@ switch(setting) { case RADIO_PRESENT: - val = 1; /* true */ + val = tuner_present ? 1 : 0; break; case RADIO_TUNED: @@ -136,6 +137,27 @@ return val; } +void tea5767_init(void) +{ + unsigned char buf[5]; + unsigned char chipid; + + /* init chipid register with 0xFF in case fmradio_i2c_read fails silently */ + buf[3] = 0xFF; + + /* read all registers */ + if (fmradio_i2c_read(I2C_ADR, buf, sizeof(buf)) < 0) { + /* no i2c device detected */ + return; + } + + /* check chip id */ + chipid = buf[3] & 0x0F; + if (chipid == 0) { + tuner_present = true; + } +} + void tea5767_dbg_info(struct tea5767_dbg_info *info) { fmradio_i2c_read(I2C_ADR, info->read_regs, 5); Index: firmware/tuner.c =================================================================== --- firmware/tuner.c (revision 28463) +++ firmware/tuner.c (working copy) @@ -74,7 +74,8 @@ #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,