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 | |
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
-rw-r--r-- | apps/main.c | 4 | ||||
-rw-r--r-- | apps/recorder/radio.c | 96 | ||||
-rw-r--r-- | apps/recorder/radio.h | 1 | ||||
-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 |
12 files changed, 340 insertions, 72 deletions
diff --git a/apps/main.c b/apps/main.c index d391b6cd02..363e174d24 100644 --- a/apps/main.c +++ b/apps/main.c | |||
@@ -98,6 +98,7 @@ int main(void) | |||
98 | #include "power.h" | 98 | #include "power.h" |
99 | #include "talk.h" | 99 | #include "talk.h" |
100 | #include "plugin.h" | 100 | #include "plugin.h" |
101 | #include "radio.h" | ||
101 | 102 | ||
102 | /*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */ | 103 | /*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */ |
103 | 104 | ||
@@ -285,6 +286,9 @@ void init(void) | |||
285 | global_settings.superbass); | 286 | global_settings.superbass); |
286 | mpeg_init(); | 287 | mpeg_init(); |
287 | talk_init(); | 288 | talk_init(); |
289 | #ifdef CONFIG_TUNER | ||
290 | radio_init(); | ||
291 | #endif | ||
288 | 292 | ||
289 | #ifdef AUTOROCK | 293 | #ifdef AUTOROCK |
290 | if (!usb_detect()) | 294 | if (!usb_detect()) |
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 8b2420066a..8eaff1d917 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c | |||
@@ -47,6 +47,8 @@ | |||
47 | #include "sound_menu.h" | 47 | #include "sound_menu.h" |
48 | #include "recording.h" | 48 | #include "recording.h" |
49 | #include "talk.h" | 49 | #include "talk.h" |
50 | #include "tuner.h" | ||
51 | #include "hwcompat.h" | ||
50 | 52 | ||
51 | #ifdef CONFIG_TUNER | 53 | #ifdef CONFIG_TUNER |
52 | 54 | ||
@@ -66,24 +68,10 @@ | |||
66 | 68 | ||
67 | #define MAX_FREQ (108000000) | 69 | #define MAX_FREQ (108000000) |
68 | #define MIN_FREQ (87500000) | 70 | #define MIN_FREQ (87500000) |
69 | #define PLL_FREQ_STEP 10000 | ||
70 | #define FREQ_STEP 100000 | 71 | #define FREQ_STEP 100000 |
71 | 72 | ||
72 | #define RADIO_FREQUENCY 0 | ||
73 | #define RADIO_MUTE 1 | ||
74 | #define RADIO_IF_MEASUREMENT 2 | ||
75 | #define RADIO_SENSITIVITY 3 | ||
76 | #define RADIO_FORCE_MONO 4 | ||
77 | |||
78 | #define DEFAULT_IN1 0x100003 /* Mute */ | ||
79 | #define DEFAULT_IN2 0x140884 /* 5kHz, 7.2MHz crystal */ | ||
80 | |||
81 | static int fm_in1 = DEFAULT_IN1; | ||
82 | static int fm_in2 = DEFAULT_IN2; | ||
83 | |||
84 | static int curr_preset = -1; | 73 | static int curr_preset = -1; |
85 | static int curr_freq; | 74 | static int curr_freq; |
86 | static int pll_cnt; | ||
87 | 75 | ||
88 | #define MAX_PRESETS 32 | 76 | #define MAX_PRESETS 32 |
89 | static bool presets_loaded = false; | 77 | static bool presets_loaded = false; |
@@ -101,46 +89,31 @@ void radio_load_presets(void); | |||
101 | bool handle_radio_presets(void); | 89 | bool handle_radio_presets(void); |
102 | bool radio_menu(void); | 90 | bool radio_menu(void); |
103 | 91 | ||
104 | void radio_set(int setting, int value) | 92 | #if CONFIG_TUNER == S1A0903X01 |
93 | #define radio_set samsung_set | ||
94 | #define radio_get samsung_get | ||
95 | #elif CONFIG_TUNER == TEA5767 | ||
96 | #define radio_set philips_set | ||
97 | #define radio_get philips_get | ||
98 | #elif CONFIG_TUNER == (S1A0903X01 | TEA5767) | ||
99 | void (*radio_set)(int setting, int value); | ||
100 | int (*radio_get)(int setting); | ||
101 | #endif | ||
102 | |||
103 | void radio_init(void) | ||
105 | { | 104 | { |
106 | switch(setting) | 105 | #if CONFIG_TUNER == (S1A0903X01 | TEA5767) |
106 | if (read_hw_mask() & TUNER_MODEL) | ||
107 | { | 107 | { |
108 | case RADIO_FREQUENCY: | 108 | radio_set = philips_set; |
109 | /* We add the standard Intermediate Frequency 10.7MHz | 109 | radio_get = philips_get; |
110 | ** before calculating the divisor | ||
111 | ** The reference frequency is set to 50kHz, and the VCO | ||
112 | ** output is prescaled by 2. | ||
113 | */ | ||
114 | |||
115 | pll_cnt = (value + 10700000) / (PLL_FREQ_STEP/2) / 2; | ||
116 | |||
117 | /* 0x100000 == FM mode | ||
118 | ** 0x000002 == Microprocessor controlled Mute | ||
119 | */ | ||
120 | fm_in1 = (fm_in1 & 0xfff00007) | (pll_cnt << 3); | ||
121 | fmradio_set(1, fm_in1); | ||
122 | break; | ||
123 | |||
124 | case RADIO_MUTE: | ||
125 | fm_in1 = (fm_in1 & 0xfffffffe) | (value?1:0); | ||
126 | fmradio_set(1, fm_in1); | ||
127 | break; | ||
128 | |||
129 | case RADIO_IF_MEASUREMENT: | ||
130 | fm_in1 = (fm_in1 & 0xfffffffb) | (value?4:0); | ||
131 | fmradio_set(1, fm_in1); | ||
132 | break; | ||
133 | |||
134 | case RADIO_SENSITIVITY: | ||
135 | fm_in2 = (fm_in2 & 0xffff9fff) | ((value & 3) << 13); | ||
136 | fmradio_set(2, fm_in2); | ||
137 | break; | ||
138 | |||
139 | case RADIO_FORCE_MONO: | ||
140 | fm_in2 = (fm_in2 & 0xfffffffb) | (value?0:4); | ||
141 | fmradio_set(2, fm_in2); | ||
142 | break; | ||
143 | } | 110 | } |
111 | else | ||
112 | { | ||
113 | radio_set = samsung_set; | ||
114 | radio_get = samsung_get; | ||
115 | } | ||
116 | #endif | ||
144 | } | 117 | } |
145 | 118 | ||
146 | void radio_stop(void) | 119 | void radio_stop(void) |
@@ -150,15 +123,7 @@ void radio_stop(void) | |||
150 | 123 | ||
151 | bool radio_hardware_present(void) | 124 | bool radio_hardware_present(void) |
152 | { | 125 | { |
153 | int val; | 126 | return radio_get(RADIO_PRESENT); |
154 | |||
155 | fmradio_set(2, 0x140885); /* 5kHz, 7.2MHz crystal, test mode 1 */ | ||
156 | val = fmradio_read(0); | ||
157 | debug_fm_detection = val; | ||
158 | if(val == 0x140885) | ||
159 | return true; | ||
160 | else | ||
161 | return false; | ||
162 | } | 127 | } |
163 | 128 | ||
164 | static int find_preset(int freq) | 129 | static int find_preset(int freq) |
@@ -184,7 +149,6 @@ bool radio_screen(void) | |||
184 | char buf[MAX_PATH]; | 149 | char buf[MAX_PATH]; |
185 | bool done = false; | 150 | bool done = false; |
186 | int button; | 151 | int button; |
187 | int val; | ||
188 | int freq; | 152 | int freq; |
189 | int i_freq; | 153 | int i_freq; |
190 | bool stereo = false; | 154 | bool stereo = false; |
@@ -247,9 +211,7 @@ bool radio_screen(void) | |||
247 | 211 | ||
248 | curr_freq = global_settings.last_frequency * FREQ_STEP + MIN_FREQ; | 212 | curr_freq = global_settings.last_frequency * FREQ_STEP + MIN_FREQ; |
249 | 213 | ||
250 | fmradio_set(1, DEFAULT_IN1); | 214 | radio_set(RADIO_INIT, 0); |
251 | fmradio_set(2, DEFAULT_IN2); | ||
252 | |||
253 | radio_set(RADIO_FREQUENCY, curr_freq); | 215 | radio_set(RADIO_FREQUENCY, curr_freq); |
254 | radio_set(RADIO_IF_MEASUREMENT, 0); | 216 | radio_set(RADIO_IF_MEASUREMENT, 0); |
255 | radio_set(RADIO_SENSITIVITY, 0); | 217 | radio_set(RADIO_SENSITIVITY, 0); |
@@ -282,8 +244,7 @@ bool radio_screen(void) | |||
282 | sleep(1); | 244 | sleep(1); |
283 | 245 | ||
284 | /* Now check how close to the IF frequency we are */ | 246 | /* Now check how close to the IF frequency we are */ |
285 | val = fmradio_read(3); | 247 | i_freq = radio_get(RADIO_IF_MEASURED); |
286 | i_freq = (val & 0x7ffff) / 80; | ||
287 | 248 | ||
288 | /* Stop searching if the IF frequency is close to 10.7MHz */ | 249 | /* Stop searching if the IF frequency is close to 10.7MHz */ |
289 | if(i_freq > 1065 && i_freq < 1075) | 250 | if(i_freq > 1065 && i_freq < 1075) |
@@ -474,8 +435,7 @@ bool radio_screen(void) | |||
474 | { | 435 | { |
475 | timeout = current_tick + HZ; | 436 | timeout = current_tick + HZ; |
476 | 437 | ||
477 | val = fmradio_read(3); | 438 | stereo = radio_get(RADIO_STEREO) && |
478 | stereo = ((val & 0x100000)?true:false) & | ||
479 | !global_settings.fm_force_mono; | 439 | !global_settings.fm_force_mono; |
480 | if(stereo != last_stereo_status) | 440 | if(stereo != last_stereo_status) |
481 | { | 441 | { |
diff --git a/apps/recorder/radio.h b/apps/recorder/radio.h index 76a4af3b9f..127bea0723 100644 --- a/apps/recorder/radio.h +++ b/apps/recorder/radio.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #define RADIO_H | 20 | #define RADIO_H |
21 | 21 | ||
22 | #ifdef CONFIG_TUNER | 22 | #ifdef CONFIG_TUNER |
23 | void radio_init(void); | ||
23 | bool radio_screen(void); | 24 | bool radio_screen(void); |
24 | void radio_stop(void); | 25 | void radio_stop(void); |
25 | bool radio_hardware_present(void); | 26 | bool radio_hardware_present(void); |
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 | |||
38 | drivers/dac.c | 38 | drivers/dac.c |
39 | drivers/fat.c | 39 | drivers/fat.c |
40 | #ifdef CONFIG_TUNER | 40 | #ifdef CONFIG_TUNER |
41 | #if (CONFIG_TUNER & S1A0903X01) | ||
41 | drivers/fmradio.c | 42 | drivers/fmradio.c |
43 | tuner_samsung.c | ||
44 | #endif | ||
45 | #if (CONFIG_TUNER & TEA5767) | ||
46 | drivers/fmradio_i2c.c | ||
47 | tuner_philips.c | ||
48 | #endif | ||
42 | #endif | 49 | #endif |
43 | drivers/i2c.c | 50 | drivers/i2c.c |
44 | #ifdef HAVE_LCD_CHARCELLS | 51 | #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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * Physical interface of the Philips TEA5767 in Archos Ondio | ||
10 | * | ||
11 | * Copyright (C) 2004 by Jörg Hohensohn | ||
12 | * | ||
13 | * All files in this archive are subject to the GNU General Public License. | ||
14 | * See the file COPYING in the source tree root for full license agreement. | ||
15 | * | ||
16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
17 | * KIND, either express or implied. | ||
18 | * | ||
19 | ****************************************************************************/ | ||
20 | #include "lcd.h" | ||
21 | #include "sh7034.h" | ||
22 | #include "kernel.h" | ||
23 | #include "thread.h" | ||
24 | #include "debug.h" | ||
25 | #include "system.h" | ||
26 | |||
27 | #ifdef CONFIG_TUNER | ||
28 | |||
29 | /* reads 5 byte */ | ||
30 | void fmradio_i2c_read(unsigned char* p_data) | ||
31 | { | ||
32 | (void)p_data; | ||
33 | } | ||
34 | |||
35 | /* writes 5 bytes */ | ||
36 | void fmradio_i2c_set(const unsigned char* p_data) | ||
37 | { | ||
38 | (void)p_data; | ||
39 | } | ||
40 | |||
41 | #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 @@ | |||
41 | #define FIRMWARE_OFFSET_FILE_DATA 24 | 41 | #define FIRMWARE_OFFSET_FILE_DATA 24 |
42 | 42 | ||
43 | /* Define this if you have an FM Radio */ | 43 | /* Define this if you have an FM Radio */ |
44 | #define CONFIG_TUNER TEA5767 | 44 | #define CONFIG_TUNER (S1A0903X01 | TEA5767) /* to be decided at runtime */ |
45 | 45 | ||
46 | /* How to detect USB */ | 46 | /* How to detect USB */ |
47 | #define USB_FMRECORDERSTYLE 1 /* like FM, on AN1 */ | 47 | #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 @@ | |||
22 | 22 | ||
23 | /* symbolic names for multiple choice configurations: */ | 23 | /* symbolic names for multiple choice configurations: */ |
24 | 24 | ||
25 | /* CONFIG_TUNER */ | 25 | /* CONFIG_TUNER (note these are combineable bit-flags) */ |
26 | #define S1A0903X01 0 /* Samsung */ | 26 | #define S1A0903X01 0x01 /* Samsung */ |
27 | #define TEA5767 1 /* Philips */ | 27 | #define TEA5767 0x02 /* Philips */ |
28 | 28 | ||
29 | /* CONFIG_HWCODEC */ | 29 | /* CONFIG_HWCODEC */ |
30 | #define MAS3587F 3587 | 30 | #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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * Physical interface of the Philips TEA5767 in Archos Ondio | ||
10 | * | ||
11 | * Copyright (C) 2004 by Jörg Hohensohn | ||
12 | * | ||
13 | * All files in this archive are subject to the GNU General Public License. | ||
14 | * See the file COPYING in the source tree root for full license agreement. | ||
15 | * | ||
16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
17 | * KIND, either express or implied. | ||
18 | * | ||
19 | ****************************************************************************/ | ||
20 | #ifndef FMRADIO_I2C_H | ||
21 | #define FMRADIO_I2C_H | ||
22 | |||
23 | void fmradio_i2c_read(unsigned char* p_data); /* reads 5 byte */ | ||
24 | void fmradio_i2c_set(const unsigned char* p_data); /* writes 5 bytes */ | ||
25 | |||
26 | #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 @@ | |||
27 | #define USB_ACTIVE_HIGH 0x0100 | 27 | #define USB_ACTIVE_HIGH 0x0100 |
28 | #define PR_ACTIVE_HIGH 0x0100 | 28 | #define PR_ACTIVE_HIGH 0x0100 |
29 | #define LCD_CONTRAST_BIAS 0x0200 | 29 | #define LCD_CONTRAST_BIAS 0x0200 |
30 | #define TUNER_MODEL 0x0800 | ||
30 | 31 | ||
31 | int read_rom_version(void); | 32 | int read_rom_version(void); |
32 | int read_hw_mask(void); | 33 | 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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * Tuner abstraction layer | ||
10 | * | ||
11 | * Copyright (C) 2004 Jörg Hohensohn | ||
12 | * | ||
13 | * All files in this archive are subject to the GNU General Public License. | ||
14 | * See the file COPYING in the source tree root for full license agreement. | ||
15 | * | ||
16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
17 | * KIND, either express or implied. | ||
18 | * | ||
19 | ****************************************************************************/ | ||
20 | #ifndef __TUNER_SAMSUNG_H__ | ||
21 | #define __TUNER_SAMSUNG_H__ | ||
22 | |||
23 | /* settings to the tuner layer */ | ||
24 | #define RADIO_INIT 0 | ||
25 | #define RADIO_FREQUENCY 1 | ||
26 | #define RADIO_MUTE 2 | ||
27 | #define RADIO_IF_MEASUREMENT 3 | ||
28 | #define RADIO_SENSITIVITY 4 | ||
29 | #define RADIO_FORCE_MONO 5 | ||
30 | /* readback from the tuner layer */ | ||
31 | #define RADIO_PRESENT 0 | ||
32 | #define RADIO_IF_MEASURED 1 | ||
33 | #define RADIO_STEREO 2 | ||
34 | |||
35 | #ifdef CONFIG_TUNER | ||
36 | |||
37 | #if (CONFIG_TUNER & S1A0903X01) | ||
38 | void samsung_set(int setting, int value); | ||
39 | int samsung_get(int setting); | ||
40 | #endif | ||
41 | |||
42 | #if (CONFIG_TUNER & TEA5767) | ||
43 | void philips_set(int setting, int value); | ||
44 | int philips_get(int setting); | ||
45 | #endif | ||
46 | |||
47 | #endif /* #ifdef CONFIG_TUNER */ | ||
48 | |||
49 | #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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * Tuner "middleware" for Philips TEA5767 chip | ||
10 | * | ||
11 | * Copyright (C) 2004 Jörg Hohensohn | ||
12 | * | ||
13 | * All files in this archive are subject to the GNU General Public License. | ||
14 | * See the file COPYING in the source tree root for full license agreement. | ||
15 | * | ||
16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
17 | * KIND, either express or implied. | ||
18 | * | ||
19 | ****************************************************************************/ | ||
20 | |||
21 | #include <stdbool.h> | ||
22 | #include "tuner.h" /* tuner abstraction interface */ | ||
23 | #include "fmradio_i2c.h" /* physical interface driver */ | ||
24 | |||
25 | /* FIXME: this is just a dummy */ | ||
26 | |||
27 | /* tuner abstraction layer: set something to the tuner */ | ||
28 | void philips_set(int setting, int value) | ||
29 | { | ||
30 | (void)value; | ||
31 | switch(setting) | ||
32 | { | ||
33 | case RADIO_INIT: | ||
34 | break; | ||
35 | |||
36 | case RADIO_FREQUENCY: | ||
37 | break; | ||
38 | |||
39 | case RADIO_MUTE: | ||
40 | break; | ||
41 | |||
42 | case RADIO_IF_MEASUREMENT: | ||
43 | break; | ||
44 | |||
45 | case RADIO_SENSITIVITY: | ||
46 | break; | ||
47 | |||
48 | case RADIO_FORCE_MONO: | ||
49 | break; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | /* tuner abstraction layer: read something from the tuner */ | ||
54 | int philips_get(int setting) | ||
55 | { | ||
56 | int val = -1; | ||
57 | switch(setting) | ||
58 | { | ||
59 | case RADIO_PRESENT: | ||
60 | val = 0; /* false */ | ||
61 | break; | ||
62 | |||
63 | case RADIO_IF_MEASURED: | ||
64 | break; | ||
65 | |||
66 | case RADIO_STEREO: | ||
67 | break; | ||
68 | } | ||
69 | return val; | ||
70 | } | ||
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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * Tuner "middleware" for Samsung S1A0903X01 chip | ||
10 | * | ||
11 | * Copyright (C) 2003 Linus Nielsen Feltzing | ||
12 | * | ||
13 | * All files in this archive are subject to the GNU General Public License. | ||
14 | * See the file COPYING in the source tree root for full license agreement. | ||
15 | * | ||
16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
17 | * KIND, either express or implied. | ||
18 | * | ||
19 | ****************************************************************************/ | ||
20 | |||
21 | #include <stdbool.h> | ||
22 | #include "tuner.h" /* tuner abstraction interface */ | ||
23 | #include "fmradio.h" /* physical interface driver */ | ||
24 | |||
25 | #define DEFAULT_IN1 0x100003 /* Mute */ | ||
26 | #define DEFAULT_IN2 0x140884 /* 5kHz, 7.2MHz crystal */ | ||
27 | #define PLL_FREQ_STEP 10000 | ||
28 | |||
29 | int debug_fm_detection; | ||
30 | static int fm_in1; | ||
31 | static int fm_in2; | ||
32 | |||
33 | /* tuner abstraction layer: set something to the tuner */ | ||
34 | void samsung_set(int setting, int value) | ||
35 | { | ||
36 | switch(setting) | ||
37 | { | ||
38 | case RADIO_INIT: | ||
39 | fm_in1 = DEFAULT_IN1; | ||
40 | fm_in2 = DEFAULT_IN2; | ||
41 | fmradio_set(1, fm_in1); | ||
42 | fmradio_set(2, fm_in2); | ||
43 | break; | ||
44 | |||
45 | case RADIO_FREQUENCY: | ||
46 | { | ||
47 | int pll_cnt; | ||
48 | /* We add the standard Intermediate Frequency 10.7MHz | ||
49 | ** before calculating the divisor | ||
50 | ** The reference frequency is set to 50kHz, and the VCO | ||
51 | ** output is prescaled by 2. | ||
52 | */ | ||
53 | |||
54 | pll_cnt = (value + 10700000) / (PLL_FREQ_STEP/2) / 2; | ||
55 | |||
56 | /* 0x100000 == FM mode | ||
57 | ** 0x000002 == Microprocessor controlled Mute | ||
58 | */ | ||
59 | fm_in1 = (fm_in1 & 0xfff00007) | (pll_cnt << 3); | ||
60 | fmradio_set(1, fm_in1); | ||
61 | break; | ||
62 | } | ||
63 | |||
64 | case RADIO_MUTE: | ||
65 | fm_in1 = (fm_in1 & 0xfffffffe) | (value?1:0); | ||
66 | fmradio_set(1, fm_in1); | ||
67 | break; | ||
68 | |||
69 | case RADIO_IF_MEASUREMENT: | ||
70 | fm_in1 = (fm_in1 & 0xfffffffb) | (value?4:0); | ||
71 | fmradio_set(1, fm_in1); | ||
72 | break; | ||
73 | |||
74 | case RADIO_SENSITIVITY: | ||
75 | fm_in2 = (fm_in2 & 0xffff9fff) | ((value & 3) << 13); | ||
76 | fmradio_set(2, fm_in2); | ||
77 | break; | ||
78 | |||
79 | case RADIO_FORCE_MONO: | ||
80 | fm_in2 = (fm_in2 & 0xfffffffb) | (value?0:4); | ||
81 | fmradio_set(2, fm_in2); | ||
82 | break; | ||
83 | } | ||
84 | } | ||
85 | |||
86 | /* tuner abstraction layer: read something from the tuner */ | ||
87 | int samsung_get(int setting) | ||
88 | { | ||
89 | int val = -1; | ||
90 | switch(setting) | ||
91 | { | ||
92 | case RADIO_PRESENT: | ||
93 | fmradio_set(2, 0x140885); /* 5kHz, 7.2MHz crystal, test mode 1 */ | ||
94 | val = fmradio_read(0); | ||
95 | debug_fm_detection = val; | ||
96 | val = (val == 0x140885); | ||
97 | break; | ||
98 | |||
99 | case RADIO_IF_MEASURED: | ||
100 | val = fmradio_read(3); | ||
101 | val = (val & 0x7ffff) / 80; /* convert to kHz */ | ||
102 | break; | ||
103 | |||
104 | case RADIO_STEREO: | ||
105 | val = fmradio_read(3); | ||
106 | val = ((val & 0x100000) ? true : false); | ||
107 | } | ||
108 | return val; | ||
109 | } | ||