A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 * General tuner functions
10 *
11 * Copyright (C) 2007 by Michael Sevakis
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#include <stdlib.h>
23#include "config.h"
24#include "kernel.h"
25#include "tuner.h"
26#include "fmradio.h"
27#ifdef HAVE_RDS_CAP
28#include "rds.h"
29#endif /* HAVE_RDS_CAP */
30
31/* General region information */
32const struct fm_region_data fm_region_data[TUNER_NUM_REGIONS] =
33{
34 [REGION_EUROPE] = { 87500000, 108000000, 100000, 50 },
35 [REGION_US_CANADA] = { 87900000, 107900000, 200000, 75 },
36 [REGION_JAPAN] = { 76000000, 90000000, 100000, 50 },
37 [REGION_KOREA] = { 87500000, 108000000, 200000, 50 },
38 [REGION_ITALY] = { 87500000, 108000000, 50000, 50 },
39 [REGION_OTHER] = { 87500000, 108000000, 50000, 50 }
40};
41
42#ifndef SIMULATOR
43
44#ifdef CONFIG_TUNER_MULTI
45int (*tuner_set)(int setting, int value);
46int (*tuner_get)(int setting);
47
48#define TUNER_TYPE_CASE(type, set, get, ...) \
49 case type: \
50 tuner_set = set; \
51 tuner_get = get; \
52 __VA_ARGS__; \
53 break;
54#else
55#define TUNER_TYPE_CASE(type, set, get, ...) \
56 __VA_ARGS__;
57#endif /* CONFIG_TUNER_MULTI */
58
59void tuner_init(void)
60{
61#ifdef CONFIG_TUNER_MULTI
62 switch (tuner_detect_type())
63#endif
64 {
65 #if (CONFIG_TUNER & LV24020LP)
66 TUNER_TYPE_CASE(LV24020LP,
67 lv24020lp_set,
68 lv24020lp_get,
69 lv24020lp_init())
70 #endif
71 #if (CONFIG_TUNER & TEA5760)
72 TUNER_TYPE_CASE(TEA5760,
73 tea5760_set,
74 tea5760_get,
75 tea5760_init())
76 #endif
77 #if (CONFIG_TUNER & TEA5767)
78 TUNER_TYPE_CASE(TEA5767,
79 tea5767_set,
80 tea5767_get,
81 tea5767_init())
82 #endif
83 #if (CONFIG_TUNER & SI4700)
84 TUNER_TYPE_CASE(SI4700,
85 si4700_set,
86 si4700_get,
87 si4700_init())
88 #endif
89 #if (CONFIG_TUNER & RDA5802)
90 TUNER_TYPE_CASE(RDA5802,
91 rda5802_set,
92 rda5802_get,
93 rda5802_init())
94 #endif
95 #if (CONFIG_TUNER & STFM1000)
96 TUNER_TYPE_CASE(STFM1000,
97 stfm1000_set,
98 stfm1000_get,
99 stfm1000_init())
100 #endif
101 }
102}
103
104#ifdef HAVE_RDS_CAP
105size_t tuner_get_rds_info(int setting, void *dst, size_t dstsize)
106{
107 /* TODO: integrate this into tuner_get/set */
108 static const unsigned char info_id_tbl[] =
109 {
110 [RADIO_RDS_NAME] = RDS_INFO_PS,
111 [RADIO_RDS_TEXT] = RDS_INFO_RT,
112 [RADIO_RDS_PROGRAM_INFO] = RDS_INFO_PI,
113 [RADIO_RDS_CURRENT_TIME] = RDS_INFO_CT,
114 };
115
116 if ((unsigned int)setting >= ARRAYLEN(info_id_tbl))
117 return 0;
118
119 return rds_pull_info(info_id_tbl[setting], (uintptr_t)dst, dstsize);
120}
121#endif /* HAVE_RDS_CAP */
122
123#endif /* SIMULATOR */