Lua: add do_menu() wrapper. Also fix potential NULL pointer dereference
[kugel-rb.git] / firmware / tuner.c
blob5fd7fa1f389a578286eee979cb9299f7b2abec99
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 #ifdef CONFIG_TUNER_MULTI
93 int (*tuner_set)(int setting, int value);
94 int (*tuner_get)(int setting);
95 #define TUNER_TYPE_CASE(type, set, get, ...) \
96 case type: \
97 tuner_set = set; \
98 tuner_get = get; \
99 __VA_ARGS__; \
100 break;
101 #else
102 #define TUNER_TYPE_CASE(type, set, get, ...) \
103 __VA_ARGS__;
104 #endif /* CONFIG_TUNER_MULTI */
106 void tuner_init(void)
108 #ifdef CONFIG_TUNER_MULTI
109 switch (tuner_detect_type())
110 #endif
112 #if (CONFIG_TUNER & LV24020LP)
113 TUNER_TYPE_CASE(LV24020LP,
114 lv24020lp_set,
115 lv24020lp_get,
116 lv24020lp_init())
117 #endif
118 #if (CONFIG_TUNER & TEA5760)
119 TUNER_TYPE_CASE(TEA5760,
120 tea5760_set,
121 tea5760_get,
122 tea5760_init())
123 #endif
124 #if (CONFIG_TUNER & TEA5767)
125 TUNER_TYPE_CASE(TEA5767,
126 tea5767_set,
127 tea5767_get)
128 #endif
129 #if (CONFIG_TUNER & S1A0903X01)
130 TUNER_TYPE_CASE(S1A0903X01,
131 s1a0903x01_set,
132 s1a0903x01_get)
133 #endif
134 #if (CONFIG_TUNER & SI4700)
135 TUNER_TYPE_CASE(SI4700,
136 si4700_set,
137 si4700_get,
138 si4700_init())
139 #endif
143 #endif /* SIMULATOR */