summaryrefslogtreecommitdiff
path: root/firmware/drivers/tuner/s1a0903x01.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-07-15 19:40:55 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-07-24 21:20:13 +0000
commit092c340a2062fa98b7387fc5fd63578ddae7d0b6 (patch)
tree98ec96946eeb2ae709cb0528cc6998e21bb9b290 /firmware/drivers/tuner/s1a0903x01.c
parent17f7cc92c258bc456a27c3e7c5a19c9409851879 (diff)
downloadrockbox-092c340a2062fa98b7387fc5fd63578ddae7d0b6.tar.gz
rockbox-092c340a2062fa98b7387fc5fd63578ddae7d0b6.zip
[1/4] Remove SH support and all archos targets
This removes all code specific to SH targets Change-Id: I7980523785d2596e65c06430f4638eec74a06061
Diffstat (limited to 'firmware/drivers/tuner/s1a0903x01.c')
-rw-r--r--firmware/drivers/tuner/s1a0903x01.c179
1 files changed, 0 insertions, 179 deletions
diff --git a/firmware/drivers/tuner/s1a0903x01.c b/firmware/drivers/tuner/s1a0903x01.c
deleted file mode 100644
index 91d1319fb5..0000000000
--- a/firmware/drivers/tuner/s1a0903x01.c
+++ /dev/null
@@ -1,179 +0,0 @@
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 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22
23#include <stdbool.h>
24#include <stdlib.h>
25#include "config.h"
26#include "kernel.h"
27#include "tuner.h" /* tuner abstraction interface */
28#include "fmradio.h" /* physical interface driver */
29#include "sound.h"
30#include "mas35xx.h"
31#include "power.h"
32
33#define DEFAULT_IN1 0x100003 /* Mute */
34#define DEFAULT_IN2 0x140884 /* 5kHz, 7.2MHz crystal */
35#define PLL_FREQ_STEP 10000
36
37static int fm_in1;
38static int fm_in2;
39static int fm_present = -1; /* unknown */
40
41/* tuner abstraction layer: set something to the tuner */
42int s1a0903x01_set(int setting, int value)
43{
44 int val = 1;
45
46 switch(setting)
47 {
48 case RADIO_SLEEP:
49 if (!value)
50 {
51 tuner_power(true);
52 /* wakeup: just unit */
53 fm_in1 = DEFAULT_IN1;
54 fm_in2 = DEFAULT_IN2;
55 fmradio_set(1, fm_in1);
56 fmradio_set(2, fm_in2);
57 }
58 else
59 tuner_power(false);
60 /* else we have no sleep mode? */
61 break;
62
63 case RADIO_FREQUENCY:
64 {
65 int pll_cnt;
66#if CONFIG_CODEC == MAS3587F
67 /* Shift the MAS internal clock away for certain frequencies to
68 * avoid interference. */
69 int pitch = 1000;
70
71 /* 4th harmonic falls in the FM frequency range */
72 int if_freq = 4 * mas_get_pllfreq();
73
74 /* shift the mas harmonic >= 300 kHz away using the direction
75 * which needs less shifting. */
76 if (value < if_freq)
77 {
78 if (if_freq - value < 300000)
79 pitch = 1003 - (if_freq - value) / 100000;
80 }
81 else
82 {
83 if (value - if_freq < 300000)
84 pitch = 997 + (value - if_freq) / 100000;
85 }
86 sound_set_pitch(pitch);
87#endif
88 /* We add the standard Intermediate Frequency 10.7MHz
89 ** before calculating the divisor
90 ** The reference frequency is set to 50kHz, and the VCO
91 ** output is prescaled by 2.
92 */
93
94 pll_cnt = (value + 10700000) / (PLL_FREQ_STEP/2) / 2;
95
96 /* 0x100000 == FM mode
97 ** 0x000002 == Microprocessor controlled Mute
98 */
99 fm_in1 = (fm_in1 & 0xfff00007) | (pll_cnt << 3);
100 fmradio_set(1, fm_in1);
101 break;
102 }
103
104 case RADIO_SCAN_FREQUENCY:
105 /* Tune in and delay */
106 s1a0903x01_set(RADIO_FREQUENCY, value);
107 sleep(1);
108 /* Start IF measurement */
109 fm_in1 |= 4;
110 fmradio_set(1, fm_in1);
111 sleep(1);
112 val = s1a0903x01_get(RADIO_TUNED);
113 break;
114
115 case RADIO_MUTE:
116 fm_in1 = (fm_in1 & 0xfffffffe) | (value?1:0);
117 fmradio_set(1, fm_in1);
118 break;
119
120 case RADIO_FORCE_MONO:
121 fm_in2 = (fm_in2 & 0xfffffffb) | (value?0:4);
122 fmradio_set(2, fm_in2);
123 break;
124 /* NOTE: These were only zeroed when starting the tuner from OFF
125 but the default values already set them to 0. */
126#if 0
127 case S1A0903X01_IF_MEASUREMENT:
128 fm_in1 = (fm_in1 & 0xfffffffb) | (value?4:0);
129 fmradio_set(1, fm_in1);
130 break;
131
132 case S1A0903X01_SENSITIVITY:
133 fm_in2 = (fm_in2 & 0xffff9fff) | ((value & 3) << 13);
134 fmradio_set(2, fm_in2);
135 break;
136#endif
137 default:
138 val = -1;
139 }
140
141 return val;
142}
143
144/* tuner abstraction layer: read something from the tuner */
145int s1a0903x01_get(int setting)
146{
147 int val = -1;
148 switch(setting)
149 {
150 case RADIO_PRESENT:
151 if (fm_present == -1)
152 {
153#ifdef HAVE_TUNER_PWR_CTRL
154 bool fmstatus = tuner_power(true);
155#endif
156 /* 5kHz, 7.2MHz crystal, test mode 1 */
157 fmradio_set(2, 0x140885);
158 fm_present = (fmradio_read(0) == 0x140885);
159#ifdef HAVE_TUNER_PWR_CTRL
160 if (!fmstatus)
161 tuner_power(false);
162#endif
163 }
164
165 val = fm_present;
166 break;
167
168 case RADIO_TUNED:
169 val = fmradio_read(3);
170 val = abs(10700 - ((val & 0x7ffff) / 8)) < 50; /* convert to kHz */
171 break;
172
173 case RADIO_STEREO:
174 val = fmradio_read(3);
175 val = ((val & 0x100000) ? true : false);
176 break;
177 }
178 return val;
179}