This repository has been archived by the owner on Sep 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FmRadioController_slsi.h
256 lines (216 loc) · 6.68 KB
/
FmRadioController_slsi.h
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#ifndef __FM_RADIO_CONTROLLER_SLSI_H__
#define __FM_RADIO_CONTROLLER_SLSI_H__
#define FM_RADIO_TEST_MODE
#include <pthread.h>
#if defined(FM_RADIO_TEST_MODE)
#include "FmRadioController_test.h"
#else
#include "FmRadioRDSParser.h"
#endif
#include <linux/videodev2.h>
#define FM_RADIO_DEVICE "/dev/radio0"
#define FM_FAILURE -1
#define FM_SUCCESS 0
enum fm_radio_state
{
FM_RADIO_OFF = 0,
FM_RADIO_ON,
FM_RADIO_WORKING,
FM_RADIO_STOP,
};
/*******************************************************************************
*
* Definitions for radio basic functions
*
******************************************************************************/
enum fm_radio_seek_dir
{
FM_RADIO_SEEK_DOWN = 0,
FM_RADIO_SEEK_UP,
};
enum fm_radio_band
{
FM_RADIO_BAND_EUR = 0, /* European/U.S. (87.5 - 108)MHz */
FM_RADIO_BAND_JAP, /* Japanese (76 - 90)MHz */
};
enum fm_radio_mute
{
FM_RADIO_MUTE_ON = 0,
FM_RADIO_MUTE_OFF,
};
enum fm_radio_tuner_mode
{
FM_RADIO_TUNER_MONO = 0,
FM_RADIO_TUNER_STEREO,
};
#define FM_RADIO_SPACING_50KHZ 5
#define FM_RADIO_SPACING_100KHZ 10
#define FM_RADIO_SPACING_200KHZ 20
enum fm_radio_deconstant_val
{
FM_RADIO_DE_TIME_CONSTANT_0 = 0,
FM_RADIO_DE_TIME_CONSTANT_75,
};
enum fm_radio_search_mode
{
FM_RADIO_STOP_SEARCH_MODE = 0,
FM_RADIO_PRESET_MODE,
FM_RADIO_AUTONOMOUS_SEARCH_MODE,
FM_RADIO_AF_JUMP_MODE,
FM_RADIO_AUTONOMOUS_SEARCH_MODE_SKIP,
};
#define V4L2_CID_USER_S610_BASE (V4L2_CID_USER_BASE + 0x1070)
enum s610_ctrl_id {
V4L2_CID_S610_CH_SPACING = (V4L2_CID_USER_S610_BASE + 0x01),
V4L2_CID_S610_CH_BAND = (V4L2_CID_USER_S610_BASE + 0x02),
V4L2_CID_S610_SOFT_STEREO_BLEND = (V4L2_CID_USER_S610_BASE + 0x03),
V4L2_CID_S610_SOFT_STEREO_BLEND_COEFF = (V4L2_CID_USER_S610_BASE + 0x04),
V4L2_CID_S610_SOFT_MUTE_COEFF = (V4L2_CID_USER_S610_BASE + 0x05),
V4L2_CID_S610_RSSI_CURR = (V4L2_CID_USER_S610_BASE + 0x06),
V4L2_CID_S610_SNR_CURR = (V4L2_CID_USER_S610_BASE + 0x07),
V4L2_CID_S610_SEEK_CANCEL = (V4L2_CID_USER_S610_BASE + 0x08),
V4L2_CID_S610_SEEK_MODE = (V4L2_CID_USER_S610_BASE + 0x09),
V4L2_CID_S610_RDS_ON = (V4L2_CID_USER_S610_BASE + 0x0A),
V4L2_CID_S610_IF_COUNT1 = (V4L2_CID_USER_S610_BASE + 0x0B),
V4L2_CID_S610_IF_COUNT2 = (V4L2_CID_USER_S610_BASE + 0x0C),
V4L2_CID_S610_RSSI_TH = (V4L2_CID_USER_S610_BASE + 0x0D),
};
/*******************************************************************************
*
* Decalarations for RDS
*
******************************************************************************/
#define FM_RADIO_ENABLED_RDS (1 << 0)
#define FM_RADIO_ENABLED_DNS (1 << 1)
#define FM_RADIO_ENABLED_AF (1 << 2)
#define FM_RADIO_ENABLED_ALL (FM_RADIO_ENABLED_RDS | FM_RADIO_ENABLED_DNS | FM_RADIO_ENABLED_AF)
#define FM_RADIO_RDS_DATA_MAX 48
#define FM_RADIO_RDS_GRP_NUM 3
#define FM_RADIO_RDS_BLK_NUM 4
#define FM_RADIO_RDS_SET_NUM (FM_RADIO_RDS_GRP_NUM * FM_RADIO_RDS_BLK_NUM)
#define FM_RADIO_RDS_BLER_MASK (0x3 << 3)
enum fm_radio_rds_index
{
FM_RADIO_RDS_LSB = 0,
FM_RADIO_RDS_MSB,
FM_RADIO_RDS_BLER,
};
typedef enum {
RDS_EVT_UPDATE = 0x0001,
RDS_EVT_PI_UPDATE = 0x0002,
RDS_EVT_PTY_UPDATE = 0x0004,
RDS_EVT_PS_UPDATE = 0x0008,
RDS_EVT_RT_UPDATE = 0x0040,
RDS_EVT_AF_JUMP = 0x0080,
RDS_EVT_AF_LIST = 0x0100,
RDS_EVT_AF_LIST_UPDATE = 0x0200,
RDS_EVT_RDS_AVL = 0x2000,
RDS_EVT_RDS_NOT_AVL = 0x4000,
} RdsEvts;
#if !defined(FM_RADIO_TEST_MODE)
extern void RDSDataReceived(Final_RDS_data rdsData);
extern void RTPlusDataReceived(RTPlus_data rtplusData);
extern void PIECCDataReceived(PIECC_data PIECCData);
extern void AFDataReceived(long AF);
extern void CallbackAFStarted();
#endif
/*******************************************************************************
*
* FmRadioController_slsi Class
*
******************************************************************************/
class FmRadioController_slsi {
private:
int radio_state;
int radio_fd;
int is_mute_on;
int tuner_mode;
int channel_spacing;
int current_band;
long current_volume;
bool is_seeking;
/* RDS/DNS/AF */
#if !defined(FM_RADIO_TEST_MODE)
FmRadioRDSParser RDSParser;
AF_List AFList;
#endif
bool radio_thread_termination;
pthread_t radio_rds_thread;
pthread_t radio_af_thread;
unsigned char is_enabled_functions;
unsigned char is_af_switching;
unsigned short current_pi;
long curr_channel;
int af_threshold;
int afvalid_threshold;
bool cancel_af_switching;
/* Sub functions for RDS/DNS/AF */
int startThreadforFmRadio(unsigned char func);
int stopThreadforFmRadio(unsigned char func);
static void* radio_thread_handler(void *arg);
void radio_data_proc(unsigned char *buf, int count);
#if !defined(FM_RADIO_TEST_MODE)
void radio_af_switching();
static void* radio_af_thread_handler(void *arg);
int af_signal_check(AF_List *af_list);
#endif
public:
FmRadioController_slsi();
~FmRadioController_slsi();
int Initialise();
void TuneChannel(long channel);
long GetChannel();
long SeekUp();
long SeekDown();
long SearchUp();
long SearchDown();
long SearchAll();
void SeekCancel();
/* Audio */
void SetVolume(long volume);
long GetVolume();
long GetMaxVolume();
void SetSpeakerOn(bool on);
void SetRecordMode(int on);
void SetBand(int band);
void SetChannelSpacing(int spacing);
void SetStereo();
void SetMono();
void MuteOn();
void MuteOff();
void setSoftmute(bool setSoftmute);
void SetDeConstant(long constant);
long GetCurrentRSSI();
long GetCurrentSNR();
void SetCurrentRSSI(long rssi);
long GetSeekMode();
void SetSeekMode(long seek_mode);
int GetChannelSpacing();
void SetSoftStereoBlendCoeff(long value);
void SetSoftMuteCoeff(long value);
void EnableRDS();
void DisableRDS();
void EnableDNS();
void DisableDNS();
void EnableAF();
void DisableAF();
void CancelAfSwitchingProcess();
void SetAF_th(int freq);
int GetAF_th();
void SetAFValid_th(int freq);
int GetAFValid_th();
/* Not Support */
void SetSeekRSSI(long freq);
void SetSeekSNR(long freq);
void SetRSSI_th(int threshold);
void SetSNR_th(int threshold);
void SetCnt_th(int threshold);
int GetRSSI_th();
int GetSNR_th();
int GetCnt_th();
void setScanning(bool value);
ServiceName GetPs();
RadioText GetLrText();
int ReadRDS();
};
#endif /* __FM_RADIO_CONTROLLER_SLSI_H__ */