aboutsummaryrefslogtreecommitdiffstats
path: root/binding/radio_impl.h
blob: 3e549ac4ccda2b260084fcd74898fcad85393bf2 (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
/*
 * Copyright (C) 2017 Konsulko Group
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _RADIO_IMPL_H
#define _RADIO_IMPL_H

#include <stdint.h>

typedef enum {
	BAND_AM = 0,
	BAND_FM
} radio_band_t;

typedef enum {
	SCAN_FORWARD = 0,
	SCAN_BACKWARD
} radio_scan_direction_t;

typedef void (*radio_scan_callback_t)(uint32_t frequency, void *data);

typedef void (*radio_freq_callback_t)(uint32_t frequency, void *data);

typedef void (*radio_rds_callback_t)(void *rds_data);

typedef enum {
	MONO = 0,
	STEREO
} radio_stereo_mode_t;

/*
 * AF_update
 * true if quality belongs to an alternative frequency
 *
 * time_stamp
 * if time_stamp is zero, quality data won't be valid
 * reliability depending on time stamp
 * it takes some time after tuning to get valid quality data
 *
 * rssi
 * (signed)
 * level detector result(RF input level)
 *
 * usn
 * FM ultrasonic noise detector (relative usn detector result)
 *
 * bandwidth
 * IF bandwidth
 */
typedef struct
{
	bool     af_update;
	uint16_t time_stamp;
	int16_t  rssi;
	uint16_t usn;
	uint16_t bandw;
} station_quality_t;

typedef struct {
	char *name;

	int (*probe)(void);

	/* NOTE: init should return -1 if called before probe has been called and returned success */
	int (*init)(void);

	void (*set_output)(const char *output);

	uint32_t (*get_frequency)(void);

	void (*set_frequency)(uint32_t frequency);

	void (*set_frequency_callback)(radio_freq_callback_t callback,
				       void *data);

	void (*set_rds_callback)(radio_rds_callback_t callback);

	radio_band_t (*get_band)(void);

	void (*set_band)(radio_band_t band);

	int (*band_supported)(radio_band_t band);

	uint32_t (*get_min_frequency)(radio_band_t band);

	uint32_t (*get_max_frequency)(radio_band_t band);

	uint32_t (*get_frequency_step)(radio_band_t band);

	bool (*get_corking_state)(void);

	void (*start)(void);

	void (*stop)(void);

	void (*scan_start)(radio_scan_direction_t direction,
			   radio_scan_callback_t callback,
			   void *data);

	void (*scan_stop)(void);

	radio_stereo_mode_t (*get_stereo_mode)(void);

	void (*set_stereo_mode)(radio_stereo_mode_t mode);

	char * (*get_rds_info)(void);

	station_quality_t * (*get_quality_info)(void);

	void (*set_alternative_frequency)(uint32_t frequency);
} radio_impl_ops_t;

#endif /* _RADIO_IMPL_H */