Fix the pesky write corruption bug in 4bit mode.
[kugel-rb.git] / firmware / tuner.c
blob3232147bbb35f708c3359591b7d34125dc994847
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 * General tuner functions
11 * Copyright (C) 2007 by Michael Sevakis
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.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
22 #include <stdlib.h>
23 #include "config.h"
24 #include "kernel.h"
25 #include "tuner.h"
26 #include "fmradio.h"
28 /* General region information */
29 const struct fm_region_data fm_region_data[TUNER_NUM_REGIONS] =
31 [REGION_EUROPE] = { 87500000, 108000000, 100000 },
32 [REGION_US_CANADA] = { 87900000, 107900000, 200000 },
33 [REGION_JAPAN] = { 76000000, 90000000, 100000 },
34 [REGION_KOREA] = { 87500000, 108000000, 200000 },
35 [REGION_ITALY] = { 87500000, 108000000, 50000 },
36 [REGION_OTHER] = { 87500000, 108000000, 50000 }
39 #ifndef SIMULATOR
41 /* Tuner-specific region information */
43 #if (CONFIG_TUNER & LV24020LP)
44 /* deemphasis setting for region */
45 const unsigned char lv24020lp_region_data[TUNER_NUM_REGIONS] =
47 [REGION_EUROPE] = 0, /* 50uS */
48 [REGION_US_CANADA] = 1, /* 75uS */
49 [REGION_JAPAN] = 0, /* 50uS */
50 [REGION_KOREA] = 0, /* 50uS */
51 [REGION_ITALY] = 0, /* 50uS */
52 [REGION_OTHER] = 0, /* 50uS */
54 #endif /* (CONFIG_TUNER & LV24020LP) */
56 #if (CONFIG_TUNER & TEA5760)
57 const struct tea5760_region_data tea5760_region_data[TUNER_NUM_REGIONS] =
59 [REGION_EUROPE] = { 1, 0 }, /* 50uS, US/Europe band */
60 [REGION_US_CANADA] = { 0, 0 }, /* 75uS, US/Europe band */
61 [REGION_JAPAN] = { 1, 1 }, /* 50uS, Japanese band */
62 [REGION_KOREA] = { 1, 0 }, /* 50uS, US/Europe band */
63 [REGION_ITALY] = { 1, 0 }, /* 50uS, US/Europe band */
64 [REGION_OTHER] = { 1, 0 }, /* 50uS, US/Europe band */
66 #endif /* (CONFIG_TUNER & TEA5760) */
68 #if (CONFIG_TUNER & TEA5767)
69 const struct tea5767_region_data tea5767_region_data[TUNER_NUM_REGIONS] =
71 [REGION_EUROPE] = { 0, 0 }, /* 50uS, US/Europe band */
72 [REGION_US_CANADA] = { 1, 0 }, /* 75uS, US/Europe band */
73 [REGION_JAPAN] = { 0, 1 }, /* 50uS, Japanese band */
74 [REGION_KOREA] = { 0, 0 }, /* 50uS, US/Europe band */
75 [REGION_ITALY] = { 0, 0 }, /* 50uS, US/Europe band */
76 [REGION_OTHER] = { 0, 0 }, /* 50uS, US/Europe band */
78 #endif /* (CONFIG_TUNER & TEA5767) */
80 #if (CONFIG_TUNER & SI4700)
81 const struct si4700_region_data si4700_region_data[TUNER_NUM_REGIONS] =
83 [REGION_EUROPE] = { 1, 0, 1 }, /* 50uS, US/Europe band, 100kHz spacing */
84 [REGION_US_CANADA] = { 0, 0, 0 }, /* 75uS, US/Europe band, 200kHz spacing */
85 [REGION_JAPAN] = { 1, 2, 1 }, /* 50uS, Japanese band, 100kHz spacing */
86 [REGION_KOREA] = { 1, 0, 0 }, /* 50uS, US/Europe band, 200kHz spacing */
87 [REGION_ITALY] = { 1, 0, 2 }, /* 50uS, US/Europe band, 50kHz spacing */
88 [REGION_OTHER] = { 1, 0, 2 }, /* 50uS, US/Europe band, 50kHz spacing */
90 #endif /* (CONFIG_TUNER & SI4700) */
92 #if (CONFIG_TUNER & RDA5802)
93 const struct rda5802_region_data rda5802_region_data[TUNER_NUM_REGIONS] =
95 [REGION_EUROPE] = { 1, 0 }, /* 50uS, US/Europe band */
96 [REGION_US_CANADA] = { 0, 0 }, /* 75uS, US/Europe band */
97 [REGION_JAPAN] = { 1, 1 }, /* 50uS, Japanese band */
98 [REGION_KOREA] = { 1, 0 }, /* 50uS, US/Europe band */
99 [REGION_ITALY] = { 1, 0 }, /* 50uS, US/Europe band */
100 [REGION_OTHER] = { 1, 0 }, /* 50uS, US/Europe band */
102 #endif /* (CONFIG_TUNER & RDA5802) */
104 #if (CONFIG_TUNER & IPOD_REMOTE_TUNER)
105 const struct rmt_tuner_region_data
106 rmt_tuner_region_data[TUNER_NUM_REGIONS] =
108 [REGION_EUROPE] = { 1, 0, 1 }, /* 50uS, US/Europe band, 100kHz spacing */
109 [REGION_US_CANADA] = { 0, 0, 0 }, /* 75uS, US/Europe band, 200kHz spacing */
110 [REGION_JAPAN] = { 1, 2, 1 }, /* 50uS, Japanese band, 100kHz spacing */
111 [REGION_KOREA] = { 1, 0, 0 }, /* 50uS, US/Europe band, 200kHz spacing */
112 [REGION_ITALY] = { 1, 0, 2 }, /* 50uS, US/Europe band, 50kHz spacing */
113 [REGION_OTHER] = { 1, 0, 2 }, /* 50uS, US/Europe band, 50kHz spacing */
115 #endif /* (CONFIG_TUNER & IPOD_REMOTE_TUNER) */
117 #ifdef CONFIG_TUNER_MULTI
118 int (*tuner_set)(int setting, int value);
119 int (*tuner_get)(int setting);
121 #define TUNER_TYPE_CASE(type, set, get, ...) \
122 case type: \
123 tuner_set = set; \
124 tuner_get = get; \
125 __VA_ARGS__; \
126 break;
127 #else
128 #define TUNER_TYPE_CASE(type, set, get, ...) \
129 __VA_ARGS__;
130 #endif /* CONFIG_TUNER_MULTI */
132 void tuner_init(void)
134 #ifdef CONFIG_TUNER_MULTI
135 switch (tuner_detect_type())
136 #endif
138 #if (CONFIG_TUNER & LV24020LP)
139 TUNER_TYPE_CASE(LV24020LP,
140 lv24020lp_set,
141 lv24020lp_get,
142 lv24020lp_init())
143 #endif
144 #if (CONFIG_TUNER & TEA5760)
145 TUNER_TYPE_CASE(TEA5760,
146 tea5760_set,
147 tea5760_get,
148 tea5760_init())
149 #endif
150 #if (CONFIG_TUNER & TEA5767)
151 TUNER_TYPE_CASE(TEA5767,
152 tea5767_set,
153 tea5767_get)
154 #endif
155 #if (CONFIG_TUNER & S1A0903X01)
156 TUNER_TYPE_CASE(S1A0903X01,
157 s1a0903x01_set,
158 s1a0903x01_get)
159 #endif
160 #if (CONFIG_TUNER & SI4700)
161 TUNER_TYPE_CASE(SI4700,
162 si4700_set,
163 si4700_get,
164 si4700_init())
165 #endif
166 #if (CONFIG_TUNER & RDA5802)
167 TUNER_TYPE_CASE(RDA5802,
168 rda5802_set,
169 rda5802_get,
170 rda5802_init())
171 #endif
174 #endif /* SIMULATOR */