1
2
3
4
5
6
7
8
9 #ifndef _FMDRV_COMMON_H
10 #define _FMDRV_COMMON_H
11
12 #define FM_ST_REG_TIMEOUT msecs_to_jiffies(6000)
13 #define FM_PKT_LOGICAL_CHAN_NUMBER 0x08
14
15 #define REG_RD 0x1
16 #define REG_WR 0x0
17
18 struct fm_reg_table {
19 u8 opcode;
20 u8 type;
21 u8 *name;
22 };
23
24 #define STEREO_GET 0
25 #define RSSI_LVL_GET 1
26 #define IF_COUNT_GET 2
27 #define FLAG_GET 3
28 #define RDS_SYNC_GET 4
29 #define RDS_DATA_GET 5
30 #define FREQ_SET 10
31 #define AF_FREQ_SET 11
32 #define MOST_MODE_SET 12
33 #define MOST_BLEND_SET 13
34 #define DEMPH_MODE_SET 14
35 #define SEARCH_LVL_SET 15
36 #define BAND_SET 16
37 #define MUTE_STATUS_SET 17
38 #define RDS_PAUSE_LVL_SET 18
39 #define RDS_PAUSE_DUR_SET 19
40 #define RDS_MEM_SET 20
41 #define RDS_BLK_B_SET 21
42 #define RDS_MSK_B_SET 22
43 #define RDS_PI_MASK_SET 23
44 #define RDS_PI_SET 24
45 #define RDS_SYSTEM_SET 25
46 #define INT_MASK_SET 26
47 #define SEARCH_DIR_SET 27
48 #define VOLUME_SET 28
49 #define AUDIO_ENABLE_SET 29
50 #define PCM_MODE_SET 30
51 #define I2S_MODE_CONFIG_SET 31
52 #define POWER_SET 32
53 #define INTX_CONFIG_SET 33
54 #define PULL_EN_SET 34
55 #define HILO_SET 35
56 #define SWITCH2FREF 36
57 #define FREQ_DRIFT_REPORT 37
58
59 #define PCE_GET 40
60 #define FIRM_VER_GET 41
61 #define ASIC_VER_GET 42
62 #define ASIC_ID_GET 43
63 #define MAN_ID_GET 44
64 #define TUNER_MODE_SET 45
65 #define STOP_SEARCH 46
66 #define RDS_CNTRL_SET 47
67
68 #define WRITE_HARDWARE_REG 100
69 #define CODE_DOWNLOAD 101
70 #define RESET 102
71
72 #define FM_POWER_MODE 254
73 #define FM_INTERRUPT 255
74
75
76
77 #define CHANL_SET 55
78 #define CHANL_BW_SET 56
79 #define REF_SET 57
80 #define POWER_ENB_SET 90
81 #define POWER_ATT_SET 58
82 #define POWER_LEV_SET 59
83 #define AUDIO_DEV_SET 60
84 #define PILOT_DEV_SET 61
85 #define RDS_DEV_SET 62
86 #define TX_BAND_SET 65
87 #define PUPD_SET 91
88 #define AUDIO_IO_SET 63
89 #define PREMPH_SET 64
90 #define MONO_SET 66
91 #define MUTE 92
92 #define MPX_LMT_ENABLE 67
93 #define PI_SET 93
94 #define ECC_SET 69
95 #define PTY 70
96 #define AF 71
97 #define DISPLAY_MODE 74
98 #define RDS_REP_SET 77
99 #define RDS_CONFIG_DATA_SET 98
100 #define RDS_DATA_SET 99
101 #define RDS_DATA_ENB 94
102 #define TA_SET 78
103 #define TP_SET 79
104 #define DI_SET 80
105 #define MS_SET 81
106 #define PS_SCROLL_SPEED 82
107 #define TX_AUDIO_LEVEL_TEST 96
108 #define TX_AUDIO_LEVEL_TEST_THRESHOLD 73
109 #define TX_AUDIO_INPUT_LEVEL_RANGE_SET 54
110 #define RX_ANTENNA_SELECT 87
111 #define I2C_DEV_ADDR_SET 86
112 #define REF_ERR_CALIB_PARAM_SET 88
113 #define REF_ERR_CALIB_PERIODICITY_SET 89
114 #define SOC_INT_TRIGGER 52
115 #define SOC_AUDIO_PATH_SET 83
116 #define SOC_PCMI_OVERRIDE 84
117 #define SOC_I2S_OVERRIDE 85
118 #define RSSI_BLOCK_SCAN_FREQ_SET 95
119 #define RSSI_BLOCK_SCAN_START 97
120 #define RSSI_BLOCK_SCAN_DATA_GET 5
121 #define READ_FMANT_TUNE_VALUE 104
122
123
124 struct fm_skb_cb {
125 __u8 fm_op;
126 struct completion *completion;
127 };
128
129 #define fm_cb(skb) ((struct fm_skb_cb *)(skb->cb))
130
131
132 struct fm_cmd_msg_hdr {
133 __u8 hdr;
134 __u8 len;
135 __u8 op;
136 __u8 rd_wr;
137 __u8 dlen;
138 } __attribute__ ((packed));
139
140 #define FM_CMD_MSG_HDR_SIZE 5
141
142
143 struct fm_event_msg_hdr {
144 __u8 header;
145 __u8 len;
146 __u8 status;
147 __u8 num_fm_hci_cmds;
148 __u8 op;
149 __u8 rd_wr;
150 __u8 dlen;
151 } __attribute__ ((packed));
152
153 #define FM_EVT_MSG_HDR_SIZE 7
154
155
156 #define FM_FW_FILE_HEADER_MAGIC 0x42535442
157
158 #define FM_ENABLE 1
159 #define FM_DISABLE 0
160
161
162 #define FM_FR_EVENT BIT(0)
163 #define FM_BL_EVENT BIT(1)
164 #define FM_RDS_EVENT BIT(2)
165 #define FM_BBLK_EVENT BIT(3)
166 #define FM_LSYNC_EVENT BIT(4)
167 #define FM_LEV_EVENT BIT(5)
168 #define FM_IFFR_EVENT BIT(6)
169 #define FM_PI_EVENT BIT(7)
170 #define FM_PD_EVENT BIT(8)
171 #define FM_STIC_EVENT BIT(9)
172 #define FM_MAL_EVENT BIT(10)
173 #define FM_POW_ENB_EVENT BIT(11)
174
175
176
177
178
179 #define FM_FMC_FW_FILE_START ("fmc_ch8")
180 #define FM_RX_FW_FILE_START ("fm_rx_ch8")
181 #define FM_TX_FW_FILE_START ("fm_tx_ch8")
182
183 #define FM_UNDEFINED_FREQ 0xFFFFFFFF
184
185
186 #define FM_BAND_EUROPE_US 0
187 #define FM_BAND_JAPAN 1
188
189
190 #define FM_SEARCH_DIRECTION_DOWN 0
191 #define FM_SEARCH_DIRECTION_UP 1
192
193
194 #define FM_TUNER_STOP_SEARCH_MODE 0
195 #define FM_TUNER_PRESET_MODE 1
196 #define FM_TUNER_AUTONOMOUS_SEARCH_MODE 2
197 #define FM_TUNER_AF_JUMP_MODE 3
198
199
200 #define FM_RX_VOLUME_MIN 0
201 #define FM_RX_VOLUME_MAX 70
202
203
204 #define FM_RX_VOLUME_GAIN_STEP 0x370
205
206
207 #define FM_MUTE_ON 0
208 #define FM_MUTE_OFF 1
209 #define FM_MUTE_ATTENUATE 2
210
211 #define FM_RX_UNMUTE_MODE 0x00
212 #define FM_RX_RF_DEP_MODE 0x01
213 #define FM_RX_AC_MUTE_MODE 0x02
214 #define FM_RX_HARD_MUTE_LEFT_MODE 0x04
215 #define FM_RX_HARD_MUTE_RIGHT_MODE 0x08
216 #define FM_RX_SOFT_MUTE_FORCE_MODE 0x10
217
218
219 #define FM_RX_RF_DEPENDENT_MUTE_ON 1
220 #define FM_RX_RF_DEPENDENT_MUTE_OFF 0
221
222
223 #define FM_RX_RSSI_THRESHOLD_MIN -128
224 #define FM_RX_RSSI_THRESHOLD_MAX 127
225
226
227 #define FM_STEREO_MODE 0
228 #define FM_MONO_MODE 1
229 #define FM_STEREO_SOFT_BLEND 1
230
231
232 #define FM_RX_EMPHASIS_FILTER_50_USEC 0
233 #define FM_RX_EMPHASIS_FILTER_75_USEC 1
234
235
236 #define FM_RDS_DISABLE 0
237 #define FM_RDS_ENABLE 1
238
239 #define FM_NO_PI_CODE 0
240
241
242 #define FM_RX_PWR_SET_FM_ON_RDS_OFF 0x1
243 #define FM_RX_PWR_SET_FM_AND_RDS_BLK_ON 0x3
244 #define FM_RX_PWR_SET_FM_AND_RDS_BLK_OFF 0x0
245
246
247 #define FM_RX_RDS_FLUSH_FIFO 0x1
248 #define FM_RX_RDS_FIFO_THRESHOLD 64
249 #define FM_RDS_BLK_SIZE 3
250
251
252 #define FM_RDS_BLOCK_A 0
253 #define FM_RDS_BLOCK_B 1
254 #define FM_RDS_BLOCK_C 2
255 #define FM_RDS_BLOCK_Ctag 3
256 #define FM_RDS_BLOCK_D 4
257 #define FM_RDS_BLOCK_E 5
258
259 #define FM_RDS_BLK_IDX_A 0
260 #define FM_RDS_BLK_IDX_B 1
261 #define FM_RDS_BLK_IDX_C 2
262 #define FM_RDS_BLK_IDX_D 3
263 #define FM_RDS_BLK_IDX_UNKNOWN 0xF0
264
265 #define FM_RDS_STATUS_ERR_MASK 0x18
266
267
268
269
270
271 #define FM_RDS_GROUP_TYPE_MASK_0A BIT(0)
272 #define FM_RDS_GROUP_TYPE_MASK_0B BIT(1)
273 #define FM_RDS_GROUP_TYPE_MASK_1A BIT(2)
274 #define FM_RDS_GROUP_TYPE_MASK_1B BIT(3)
275 #define FM_RDS_GROUP_TYPE_MASK_2A BIT(4)
276 #define FM_RDS_GROUP_TYPE_MASK_2B BIT(5)
277 #define FM_RDS_GROUP_TYPE_MASK_3A BIT(6)
278 #define FM_RDS_GROUP_TYPE_MASK_3B BIT(7)
279 #define FM_RDS_GROUP_TYPE_MASK_4A BIT(8)
280 #define FM_RDS_GROUP_TYPE_MASK_4B BIT(9)
281 #define FM_RDS_GROUP_TYPE_MASK_5A BIT(10)
282 #define FM_RDS_GROUP_TYPE_MASK_5B BIT(11)
283 #define FM_RDS_GROUP_TYPE_MASK_6A BIT(12)
284 #define FM_RDS_GROUP_TYPE_MASK_6B BIT(13)
285 #define FM_RDS_GROUP_TYPE_MASK_7A BIT(14)
286 #define FM_RDS_GROUP_TYPE_MASK_7B BIT(15)
287 #define FM_RDS_GROUP_TYPE_MASK_8A BIT(16)
288 #define FM_RDS_GROUP_TYPE_MASK_8B BIT(17)
289 #define FM_RDS_GROUP_TYPE_MASK_9A BIT(18)
290 #define FM_RDS_GROUP_TYPE_MASK_9B BIT(19)
291 #define FM_RDS_GROUP_TYPE_MASK_10A BIT(20)
292 #define FM_RDS_GROUP_TYPE_MASK_10B BIT(21)
293 #define FM_RDS_GROUP_TYPE_MASK_11A BIT(22)
294 #define FM_RDS_GROUP_TYPE_MASK_11B BIT(23)
295 #define FM_RDS_GROUP_TYPE_MASK_12A BIT(24)
296 #define FM_RDS_GROUP_TYPE_MASK_12B BIT(25)
297 #define FM_RDS_GROUP_TYPE_MASK_13A BIT(26)
298 #define FM_RDS_GROUP_TYPE_MASK_13B BIT(27)
299 #define FM_RDS_GROUP_TYPE_MASK_14A BIT(28)
300 #define FM_RDS_GROUP_TYPE_MASK_14B BIT(29)
301 #define FM_RDS_GROUP_TYPE_MASK_15A BIT(30)
302 #define FM_RDS_GROUP_TYPE_MASK_15B BIT(31)
303
304
305 #define FM_RDS_MIN_AF 1
306 #define FM_RDS_MAX_AF 204
307 #define FM_RDS_MAX_AF_JAPAN 140
308 #define FM_RDS_1_AF_FOLLOWS 225
309 #define FM_RDS_25_AF_FOLLOWS 249
310
311
312 #define FM_RDS_SYSTEM_RDS 0
313 #define FM_RDS_SYSTEM_RBDS 1
314
315
316 #define FM_RX_RDS_AF_SWITCH_MODE_ON 1
317 #define FM_RX_RDS_AF_SWITCH_MODE_OFF 0
318
319
320 #define FM_IRQ_TIMEOUT_RETRY_MAX 5
321
322
323 #define FM_RX_AUDIO_ENABLE_I2S 0x01
324 #define FM_RX_AUDIO_ENABLE_ANALOG 0x02
325 #define FM_RX_AUDIO_ENABLE_I2S_AND_ANALOG 0x03
326 #define FM_RX_AUDIO_ENABLE_DISABLE 0x00
327
328
329 #define FM_RX_IFFREQ_TO_HI_SIDE 0x0
330 #define FM_RX_IFFREQ_TO_LO_SIDE 0x1
331 #define FM_RX_IFFREQ_HILO_AUTOMATIC 0x2
332
333
334
335
336
337 #define FM_DEFAULT_RX_VOLUME 10
338 #define FM_DEFAULT_RSSI_THRESHOLD 3
339
340
341 #define FM_PWR_LVL_LOW 91
342 #define FM_PWR_LVL_HIGH 122
343
344
345 #define FM_PWR_LVL_DEF 4
346
347
348 #define FM_TX_PREEMPH_OFF 1
349 #define FM_TX_PREEMPH_50US 0
350 #define FM_TX_PREEMPH_75US 2
351
352
353 #define FM_TX_ANT_IMP_50 0
354 #define FM_TX_ANT_IMP_200 1
355 #define FM_TX_ANT_IMP_500 2
356
357
358 int fmc_prepare(struct fmdev *);
359 int fmc_release(struct fmdev *);
360
361 void fmc_update_region_info(struct fmdev *, u8);
362 int fmc_send_cmd(struct fmdev *, u8, u16,
363 void *, unsigned int, void *, int *);
364 int fmc_is_rds_data_available(struct fmdev *, struct file *,
365 struct poll_table_struct *);
366 int fmc_transfer_rds_from_internal_buff(struct fmdev *, struct file *,
367 u8 __user *, size_t);
368
369 int fmc_set_freq(struct fmdev *, u32);
370 int fmc_set_mode(struct fmdev *, u8);
371 int fmc_set_region(struct fmdev *, u8);
372 int fmc_set_mute_mode(struct fmdev *, u8);
373 int fmc_set_stereo_mono(struct fmdev *, u16);
374 int fmc_set_rds_mode(struct fmdev *, u8);
375
376 int fmc_get_freq(struct fmdev *, u32 *);
377 int fmc_get_region(struct fmdev *, u8 *);
378 int fmc_get_mode(struct fmdev *, u8 *);
379
380
381
382
383 #define FM_CHANNEL_SPACING_50KHZ 1
384 #define FM_CHANNEL_SPACING_100KHZ 2
385 #define FM_CHANNEL_SPACING_200KHZ 4
386 #define FM_FREQ_MUL 50
387
388 #endif
389