diff options
Diffstat (limited to 'apps/recorder/radio.c')
-rw-r--r-- | apps/recorder/radio.c | 96 |
1 files changed, 28 insertions, 68 deletions
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 | { |