Add sound manager initial source code
[staging/soundmanager.git] / sample / radio / binding / rtl_fm.h
1 /*
2  * rtl-sdr, turns your Realtek RTL2832 based DVB dongle into a SDR receiver
3  * Copyright (C) 2016, 2017 Konsulko Group
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef RTL_FM_H
20 #define RTL_FM_H
21
22 #include <stdint.h>
23
24 #define RTL_FM_DEFAULT_BUF_LENGTH       (1 * 16384)
25 #define RTL_FM_MAXIMUM_OVERSAMPLE       16
26 #define RTL_FM_MAXIMUM_BUF_LENGTH       (RTL_FM_MAXIMUM_OVERSAMPLE * RTL_FM_DEFAULT_BUF_LENGTH)
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 typedef void (*rtl_fm_output_fn_t)(int16_t *result, int result_len, void *data);
33
34 int rtl_fm_init(uint32_t freq,
35                 uint32_t sample_rate,
36                 uint32_t resample_rate,
37                 rtl_fm_output_fn_t output_fn,
38                 void *output_fn_data);
39
40 void rtl_fm_start(void);
41
42 void rtl_fm_set_freq(uint32_t freq);
43
44 void rtl_fm_set_freq_callback(void (*callback)(uint32_t, void *),
45                               void *data);
46
47 uint32_t rtl_fm_get_freq(void);
48
49 void rtl_fm_stop(void);
50
51 void rtl_fm_scan_start(int direction,
52                        void (*callback)(uint32_t, void *),
53                        void *data,
54                        uint32_t step,
55                        uint32_t min,
56                        uint32_t max);
57
58 void rtl_fm_scan_stop(void);
59
60 void rtl_fm_scan_set_squelch_level(int level);
61
62 void rtl_fm_scan_set_squelch_limit(int count);
63
64 void rtl_fm_cleanup(void);
65
66 #ifdef __cplusplus
67 }
68 #endif
69
70 #endif /* RTL_FM_H */