Implement tea5767 tuner detection - FS#11714 by me

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28493 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Bertrik Sikken 2010-11-05 17:04:18 +00:00
parent f174c3513b
commit 981a639ade
3 changed files with 25 additions and 2 deletions

View file

@ -34,6 +34,7 @@
#define I2C_ADR 0xC0 #define I2C_ADR 0xC0
#endif #endif
static bool tuner_present = true;
static unsigned char write_bytes[5] = { 0x00, 0x00, 0x00, 0x00, 0x00 }; static unsigned char write_bytes[5] = { 0x00, 0x00, 0x00, 0x00, 0x00 };
static void tea5767_set_clear(int byte, unsigned char bits, int set) static void tea5767_set_clear(int byte, unsigned char bits, int set)
@ -116,7 +117,7 @@ int tea5767_get(int setting)
switch(setting) switch(setting)
{ {
case RADIO_PRESENT: case RADIO_PRESENT:
val = 1; /* true */ val = tuner_present;
break; break;
case RADIO_TUNED: case RADIO_TUNED:
@ -136,6 +137,26 @@ int tea5767_get(int setting)
return val; 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) void tea5767_dbg_info(struct tea5767_dbg_info *info)
{ {
fmradio_i2c_read(I2C_ADR, info->read_regs, 5); fmradio_i2c_read(I2C_ADR, info->read_regs, 5);

View file

@ -32,6 +32,7 @@ struct tea5767_dbg_info
unsigned char write_regs[5]; unsigned char write_regs[5];
}; };
void tea5767_init(void);
int tea5767_set(int setting, int value); int tea5767_set(int setting, int value);
int tea5767_get(int setting); int tea5767_get(int setting);
void tea5767_dbg_info(struct tea5767_dbg_info *info); void tea5767_dbg_info(struct tea5767_dbg_info *info);

View file

@ -74,7 +74,8 @@ void tuner_init(void)
#if (CONFIG_TUNER & TEA5767) #if (CONFIG_TUNER & TEA5767)
TUNER_TYPE_CASE(TEA5767, TUNER_TYPE_CASE(TEA5767,
tea5767_set, tea5767_set,
tea5767_get) tea5767_get,
tea5767_init())
#endif #endif
#if (CONFIG_TUNER & S1A0903X01) #if (CONFIG_TUNER & S1A0903X01)
TUNER_TYPE_CASE(S1A0903X01, TUNER_TYPE_CASE(S1A0903X01,