summaryrefslogtreecommitdiffstats
path: root/firmware/tuner.c
blob: cca5cf2491fc77a6e4ac2b0db4d090f3359e258b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 * General tuner functions
 *
 * Copyright (C) 2007 by Michael Sevakis
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/
#include <stdlib.h>
#include "config.h"
#include "kernel.h"
#include "tuner.h"
#include "fmradio.h"

/* General region information */
const struct fm_region_data fm_region_data[TUNER_NUM_REGIONS] =
{
    [REGION_EUROPE]    = { 87500000, 108000000, 100000 },
    [REGION_US_CANADA] = { 87900000, 107900000, 200000 },
    [REGION_JAPAN]     = { 76000000,  90000000, 100000 },
    [REGION_KOREA]     = { 87500000, 108000000, 200000 },
    [REGION_ITALY]     = { 87500000, 108000000,  50000 },
    [REGION_OTHER]     = { 87500000, 108000000,  50000 }
};

#ifndef SIMULATOR

/* Tuner-specific region information */

#if (CONFIG_TUNER & LV24020LP)
/* deemphasis setting for region */
const unsigned char lv24020lp_region_data[TUNER_NUM_REGIONS] =
{
    [REGION_EUROPE]    = 0, /* 50uS */
    [REGION_US_CANADA] = 1, /* 75uS */
    [REGION_JAPAN]     = 0, /* 50uS */
    [REGION_KOREA]     = 0, /* 50uS */
    [REGION_ITALY]     = 0, /* 50uS */
    [REGION_OTHER]     = 0, /* 50uS */
};
#endif /* (CONFIG_TUNER & LV24020LP) */

#if (CONFIG_TUNER & TEA5760)
const struct tea5760_region_data tea5760_region_data[TUNER_NUM_REGIONS] =
{
    [REGION_EUROPE]    = { 1, 0 }, /* 50uS, US/Europe band */
    [REGION_US_CANADA] = { 0, 0 }, /* 75uS, US/Europe band */
    [REGION_JAPAN]     = { 1, 1 }, /* 50uS, Japanese band  */
    [REGION_KOREA]     = { 1, 0 }, /* 50uS, US/Europe band */ 
    [REGION_ITALY]     = { 1, 0 }, /* 50uS, US/Europe band */ 
    [REGION_OTHER]     = { 1, 0 }, /* 50uS, US/Europe band */ 
};
#endif /* (CONFIG_TUNER & TEA5760) */

#if (CONFIG_TUNER & TEA5767)
const struct tea5767_region_data tea5767_region_data[TUNER_NUM_REGIONS] =
{
    [REGION_EUROPE]    = { 0, 0 }, /* 50uS, US/Europe band */
    [REGION_US_CANADA] = { 1, 0 }, /* 75uS, US/Europe band */
    [REGION_JAPAN]     = { 0, 1 }, /* 50uS, Japanese band  */
    [REGION_KOREA]     = { 0, 0 }, /* 50uS, US/Europe band */ 
    [REGION_ITALY]     = { 0, 0 }, /* 50uS, US/Europe band */ 
    [REGION_OTHER]     = { 0, 0 }, /* 50uS, US/Europe band */ 
};
#endif /* (CONFIG_TUNER & TEA5767) */

#if (CONFIG_TUNER & SI4700)
const struct si4700_region_data si4700_region_data[TUNER_NUM_REGIONS] =
{
    [REGION_EUROPE]    = { 1, 0, 1 }, /* 50uS, US/Europe band, 100kHz spacing */
    [REGION_US_CANADA] = { 0, 0, 0 }, /* 75uS, US/Europe band, 200kHz spacing */
    [REGION_JAPAN]     = { 1, 2, 1 }, /* 50uS, Japanese band,  100kHz spacing */
    [REGION_KOREA]     = { 1, 0, 0 }, /* 50uS, US/Europe band, 200kHz spacing */
    [REGION_ITALY]     = { 1, 0, 2 }, /* 50uS, US/Europe band,  50kHz spacing */
    [REGION_OTHER]     = { 1, 0, 2 }, /* 50uS, US/Europe band,  50kHz spacing */
};
#endif /* (CONFIG_TUNER & SI4700) */

#if (CONFIG_TUNER & IPOD_REMOTE_TUNER)
const struct rmt_tuner_region_data
                        rmt_tuner_region_data[TUNER_NUM_REGIONS] =
{
    [REGION_EUROPE]    = { 1, 0, 1 }, /* 50uS, US/Europe band, 100kHz spacing */
    [REGION_US_CANADA] = { 0, 0, 0 }, /* 75uS, US/Europe band, 200kHz spacing */
    [REGION_JAPAN]     = { 1, 2, 1 }, /* 50uS, Japanese band,  100kHz spacing */
    [REGION_KOREA]     = { 1, 0, 0 }, /* 50uS, US/Europe band, 200kHz spacing */
    [REGION_ITALY]     = { 1, 0, 2 }, /* 50uS, US/Europe band,  50kHz spacing */
    [REGION_OTHER]     = { 1, 0, 2 }, /* 50uS, US/Europe band,  50kHz spacing */
};
#endif /* (CONFIG_TUNER & IPOD_REMOTE_TUNER) */

#ifdef CONFIG_TUNER_MULTI
int (*tuner_set)(int setting, int value);
int (*tuner_get)(int setting);

#define TUNER_TYPE_CASE(type, set, get, ...)         \
    case type:                                       \
        tuner_set = set;                             \
        tuner_get = get;                             \
        __VA_ARGS__;                                 \
        break;
#else
#define TUNER_TYPE_CASE(type, set, get, ...)         \
        __VA_ARGS__;
#endif /* CONFIG_TUNER_MULTI */

void tuner_init(void)
{
#ifdef CONFIG_TUNER_MULTI
    switch (tuner_detect_type())
#endif
    {
    #if (CONFIG_TUNER & LV24020LP)
        TUNER_TYPE_CASE(LV24020LP,
                        lv24020lp_set,
                        lv24020lp_get,
                        lv24020lp_init())
    #endif
    #if (CONFIG_TUNER & TEA5760)
        TUNER_TYPE_CASE(TEA5760,
                        tea5760_set,
                        tea5760_get,
                        tea5760_init())
    #endif
    #if (CONFIG_TUNER & TEA5767)
        TUNER_TYPE_CASE(TEA5767,
                        tea5767_set,
                        tea5767_get)
    #endif
    #if (CONFIG_TUNER & S1A0903X01)
        TUNER_TYPE_CASE(S1A0903X01,
                        s1a0903x01_set,
                        s1a0903x01_get)
    #endif
    #if (CONFIG_TUNER & SI4700)
        TUNER_TYPE_CASE(SI4700,
                        si4700_set,
                        si4700_get,
                        si4700_init())
    #endif
    }
}
#endif /* SIMULATOR */