summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-05-28 01:09:19 +0000
committerJens Arnold <amiconn@rockbox.org>2005-05-28 01:09:19 +0000
commit7a977b833fed49f67a74636addb590f078d12636 (patch)
tree49a13ff70ad4c8d31e1380158462cdbf7c0096f0
parent8ca1831a5e87cf4216b3d36a373ca8ed481941f1 (diff)
downloadrockbox-7a977b833fed49f67a74636addb590f078d12636.zip
rockbox-7a977b833fed49f67a74636addb590f078d12636.tar.gz
rockbox-7a977b833fed49f67a74636addb590f078d12636.tar.bz2
rockbox-7a977b833fed49f67a74636addb590f078d12636.tar.xz
Avoid radio interference from the MAS internal clock on devices with the Samsung tuner (FM recorder, old Ondio FM) by slightly shifting it away when necessary.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6531 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/mpeg.h3
-rw-r--r--firmware/mpeg.c16
-rw-r--r--firmware/tuner_samsung.c25
3 files changed, 44 insertions, 0 deletions
diff --git a/firmware/export/mpeg.h b/firmware/export/mpeg.h
index ca0de1f..71e61a0 100644
--- a/firmware/export/mpeg.h
+++ b/firmware/export/mpeg.h
@@ -50,6 +50,9 @@ void mpeg_set_recording_options(int frequency, int quality,
int source, int channel_mode,
bool editable, int prerecord_time);
void mpeg_set_recording_gain(int left, int right, bool use_mic);
+#if CONFIG_TUNER & S1A0903X01
+int mpeg_get_mas_pllfreq(void);
+#endif
unsigned long mpeg_recorded_time(void);
unsigned long mpeg_num_recorded_bytes(void);
void mpeg_pause_recording(void);
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index ff3f95c..28bfa62 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -2382,6 +2382,22 @@ void mpeg_set_recording_gain(int left, int right, bool use_mic)
mas_codec_writereg(0x0, shadow_codec_reg0);
}
+#if CONFIG_TUNER & S1A0903X01
+/* Get the (unpitched) MAS PLL frequency, for avoiding FM interference with the
+ * Samsung tuner. Zero means unknown. Currently handles recording from analog
+ * input only. */
+int mpeg_get_mas_pllfreq(void)
+{
+ if (mpeg_mode != MPEG_ENCODER)
+ return 0;
+
+ if (rec_frequency_index == 0) /* 44.1 kHz / 22.05 kHz */
+ return 22579000;
+ else
+ return 24576000;
+}
+#endif
+
/* try to make some kind of beep, also in recording mode */
void audio_beep(int duration)
{
diff --git a/firmware/tuner_samsung.c b/firmware/tuner_samsung.c
index 632fb75..c024fce 100644
--- a/firmware/tuner_samsung.c
+++ b/firmware/tuner_samsung.c
@@ -20,8 +20,11 @@
#include <stdbool.h>
#include <stdlib.h>
+#include "config.h"
#include "tuner.h" /* tuner abstraction interface */
#include "fmradio.h" /* physical interface driver */
+#include "mpeg.h"
+#include "sound.h"
#define DEFAULT_IN1 0x100003 /* Mute */
#define DEFAULT_IN2 0x140884 /* 5kHz, 7.2MHz crystal */
@@ -49,6 +52,28 @@ void samsung_set(int setting, int value)
case RADIO_FREQUENCY:
{
int pll_cnt;
+#if CONFIG_HWCODEC == MAS3587F
+ /* Shift the MAS internal clock away for certain frequencies to
+ * avoid interference. */
+ int pitch = 1000;
+
+ /* 4th harmonic falls in the FM frequency range */
+ int if_freq = 4 * mpeg_get_mas_pllfreq();
+
+ /* shift the mas harmonic >= 300 kHz away using the direction
+ * which needs less shifting. */
+ if (value < if_freq)
+ {
+ if (if_freq - value < 300000)
+ pitch = 1003 - (if_freq - value) / 100000;
+ }
+ else
+ {
+ if (value - if_freq < 300000)
+ pitch = 997 + (value - if_freq) / 100000;
+ }
+ sound_set_pitch(pitch);
+#endif
/* We add the standard Intermediate Frequency 10.7MHz
** before calculating the divisor
** The reference frequency is set to 50kHz, and the VCO