diff options
author | Jörg Hohensohn <hohensoh@rockbox.org> | 2004-10-15 21:41:46 +0000 |
---|---|---|
committer | Jörg Hohensohn <hohensoh@rockbox.org> | 2004-10-15 21:41:46 +0000 |
commit | 8f8fbac1fddee1df554d6fe9f9ac344404257b82 (patch) | |
tree | 5a5526618155edd41e66bd357e52492aacbffcbf /firmware | |
parent | 566eae2e119f3c57b1df0782ddcc29fccedbf816 (diff) | |
download | rockbox-8f8fbac1fddee1df554d6fe9f9ac344404257b82.tar.gz rockbox-8f8fbac1fddee1df554d6fe9f9ac344404257b82.zip |
Philips tuner prepared, new middle layer to abstract which tuner is used
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5289 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/SOURCES | 7 | ||||
-rw-r--r-- | firmware/drivers/fmradio_i2c.c | 41 | ||||
-rw-r--r-- | firmware/export/config-ondiofm.h | 2 | ||||
-rw-r--r-- | firmware/export/config.h | 6 | ||||
-rw-r--r-- | firmware/export/fmradio_i2c.h | 26 | ||||
-rw-r--r-- | firmware/export/hwcompat.h | 1 | ||||
-rw-r--r-- | firmware/export/tuner.h | 49 | ||||
-rw-r--r-- | firmware/tuner_philips.c | 70 | ||||
-rw-r--r-- | firmware/tuner_samsung.c | 109 |
9 files changed, 307 insertions, 4 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 7594c6dc1a..6df69bf2a3 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -38,7 +38,14 @@ drivers/button.c drivers/dac.c drivers/fat.c #ifdef CONFIG_TUNER +#if (CONFIG_TUNER & S1A0903X01) drivers/fmradio.c +tuner_samsung.c +#endif +#if (CONFIG_TUNER & TEA5767) +drivers/fmradio_i2c.c +tuner_philips.c +#endif #endif drivers/i2c.c #ifdef HAVE_LCD_CHARCELLS diff --git a/firmware/drivers/fmradio_i2c.c b/firmware/drivers/fmradio_i2c.c new file mode 100644 index 0000000000..93c5d2fa91 --- /dev/null +++ b/firmware/drivers/fmradio_i2c.c @@ -0,0 +1,41 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * Physical interface of the Philips TEA5767 in Archos Ondio + * + * Copyright (C) 2004 by Jörg Hohensohn + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "lcd.h" +#include "sh7034.h" +#include "kernel.h" +#include "thread.h" +#include "debug.h" +#include "system.h" + +#ifdef CONFIG_TUNER + +/* reads 5 byte */ +void fmradio_i2c_read(unsigned char* p_data) +{ + (void)p_data; +} + +/* writes 5 bytes */ +void fmradio_i2c_set(const unsigned char* p_data) +{ + (void)p_data; +} + +#endif diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h index 437f8682a8..f459934fbc 100644 --- a/firmware/export/config-ondiofm.h +++ b/firmware/export/config-ondiofm.h @@ -41,7 +41,7 @@ #define FIRMWARE_OFFSET_FILE_DATA 24 /* Define this if you have an FM Radio */ -#define CONFIG_TUNER TEA5767 +#define CONFIG_TUNER (S1A0903X01 | TEA5767) /* to be decided at runtime */ /* How to detect USB */ #define USB_FMRECORDERSTYLE 1 /* like FM, on AN1 */ diff --git a/firmware/export/config.h b/firmware/export/config.h index 76a2bd9316..823a5dc3ed 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -22,9 +22,9 @@ /* symbolic names for multiple choice configurations: */ -/* CONFIG_TUNER */ -#define S1A0903X01 0 /* Samsung */ -#define TEA5767 1 /* Philips */ +/* CONFIG_TUNER (note these are combineable bit-flags) */ +#define S1A0903X01 0x01 /* Samsung */ +#define TEA5767 0x02 /* Philips */ /* CONFIG_HWCODEC */ #define MAS3587F 3587 diff --git a/firmware/export/fmradio_i2c.h b/firmware/export/fmradio_i2c.h new file mode 100644 index 0000000000..06b7f9f7b7 --- /dev/null +++ b/firmware/export/fmradio_i2c.h @@ -0,0 +1,26 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * Physical interface of the Philips TEA5767 in Archos Ondio + * + * Copyright (C) 2004 by Jörg Hohensohn + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef FMRADIO_I2C_H +#define FMRADIO_I2C_H + +void fmradio_i2c_read(unsigned char* p_data); /* reads 5 byte */ +void fmradio_i2c_set(const unsigned char* p_data); /* writes 5 bytes */ + +#endif diff --git a/firmware/export/hwcompat.h b/firmware/export/hwcompat.h index ef3892b1fa..66f29f8b16 100644 --- a/firmware/export/hwcompat.h +++ b/firmware/export/hwcompat.h @@ -27,6 +27,7 @@ #define USB_ACTIVE_HIGH 0x0100 #define PR_ACTIVE_HIGH 0x0100 #define LCD_CONTRAST_BIAS 0x0200 +#define TUNER_MODEL 0x0800 int read_rom_version(void); int read_hw_mask(void); diff --git a/firmware/export/tuner.h b/firmware/export/tuner.h new file mode 100644 index 0000000000..ae31c6d354 --- /dev/null +++ b/firmware/export/tuner.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * Tuner abstraction layer + * + * Copyright (C) 2004 Jörg Hohensohn + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef __TUNER_SAMSUNG_H__ +#define __TUNER_SAMSUNG_H__ + +/* settings to the tuner layer */ +#define RADIO_INIT 0 +#define RADIO_FREQUENCY 1 +#define RADIO_MUTE 2 +#define RADIO_IF_MEASUREMENT 3 +#define RADIO_SENSITIVITY 4 +#define RADIO_FORCE_MONO 5 +/* readback from the tuner layer */ +#define RADIO_PRESENT 0 +#define RADIO_IF_MEASURED 1 +#define RADIO_STEREO 2 + +#ifdef CONFIG_TUNER + +#if (CONFIG_TUNER & S1A0903X01) +void samsung_set(int setting, int value); +int samsung_get(int setting); +#endif + +#if (CONFIG_TUNER & TEA5767) +void philips_set(int setting, int value); +int philips_get(int setting); +#endif + +#endif /* #ifdef CONFIG_TUNER */ + +#endif diff --git a/firmware/tuner_philips.c b/firmware/tuner_philips.c new file mode 100644 index 0000000000..50559af23e --- /dev/null +++ b/firmware/tuner_philips.c @@ -0,0 +1,70 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * Tuner "middleware" for Philips TEA5767 chip + * + * Copyright (C) 2004 Jörg Hohensohn + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include <stdbool.h> +#include "tuner.h" /* tuner abstraction interface */ +#include "fmradio_i2c.h" /* physical interface driver */ + +/* FIXME: this is just a dummy */ + +/* tuner abstraction layer: set something to the tuner */ +void philips_set(int setting, int value) +{ + (void)value; + switch(setting) + { + case RADIO_INIT: + break; + + case RADIO_FREQUENCY: + break; + + case RADIO_MUTE: + break; + + case RADIO_IF_MEASUREMENT: + break; + + case RADIO_SENSITIVITY: + break; + + case RADIO_FORCE_MONO: + break; + } +} + +/* tuner abstraction layer: read something from the tuner */ +int philips_get(int setting) +{ + int val = -1; + switch(setting) + { + case RADIO_PRESENT: + val = 0; /* false */ + break; + + case RADIO_IF_MEASURED: + break; + + case RADIO_STEREO: + break; + } + return val; +} diff --git a/firmware/tuner_samsung.c b/firmware/tuner_samsung.c new file mode 100644 index 0000000000..781a4bcd3e --- /dev/null +++ b/firmware/tuner_samsung.c @@ -0,0 +1,109 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * Tuner "middleware" for Samsung S1A0903X01 chip + * + * Copyright (C) 2003 Linus Nielsen Feltzing + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include <stdbool.h> +#include "tuner.h" /* tuner abstraction interface */ +#include "fmradio.h" /* physical interface driver */ + +#define DEFAULT_IN1 0x100003 /* Mute */ +#define DEFAULT_IN2 0x140884 /* 5kHz, 7.2MHz crystal */ +#define PLL_FREQ_STEP 10000 + +int debug_fm_detection; +static int fm_in1; +static int fm_in2; + +/* tuner abstraction layer: set something to the tuner */ +void samsung_set(int setting, int value) +{ + switch(setting) + { + case RADIO_INIT: + fm_in1 = DEFAULT_IN1; + fm_in2 = DEFAULT_IN2; + fmradio_set(1, fm_in1); + fmradio_set(2, fm_in2); + break; + + case RADIO_FREQUENCY: + { + int pll_cnt; + /* We add the standard Intermediate Frequency 10.7MHz + ** before calculating the divisor + ** The reference frequency is set to 50kHz, and the VCO + ** output is prescaled by 2. + */ + + pll_cnt = (value + 10700000) / (PLL_FREQ_STEP/2) / 2; + + /* 0x100000 == FM mode + ** 0x000002 == Microprocessor controlled Mute + */ + fm_in1 = (fm_in1 & 0xfff00007) | (pll_cnt << 3); + fmradio_set(1, fm_in1); + break; + } + + case RADIO_MUTE: + fm_in1 = (fm_in1 & 0xfffffffe) | (value?1:0); + fmradio_set(1, fm_in1); + break; + + case RADIO_IF_MEASUREMENT: + fm_in1 = (fm_in1 & 0xfffffffb) | (value?4:0); + fmradio_set(1, fm_in1); + break; + + case RADIO_SENSITIVITY: + fm_in2 = (fm_in2 & 0xffff9fff) | ((value & 3) << 13); + fmradio_set(2, fm_in2); + break; + + case RADIO_FORCE_MONO: + fm_in2 = (fm_in2 & 0xfffffffb) | (value?0:4); + fmradio_set(2, fm_in2); + break; + } +} + +/* tuner abstraction layer: read something from the tuner */ +int samsung_get(int setting) +{ + int val = -1; + switch(setting) + { + case RADIO_PRESENT: + fmradio_set(2, 0x140885); /* 5kHz, 7.2MHz crystal, test mode 1 */ + val = fmradio_read(0); + debug_fm_detection = val; + val = (val == 0x140885); + break; + + case RADIO_IF_MEASURED: + val = fmradio_read(3); + val = (val & 0x7ffff) / 80; /* convert to kHz */ + break; + + case RADIO_STEREO: + val = fmradio_read(3); + val = ((val & 0x100000) ? true : false); + } + return val; +} |