blob: 881b85101a8e5cd47693caedd897461319cc4276 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001#ifndef __LINUX_TAVARUA_H
2#define __LINUX_TAVARUA_H
3
4#ifdef __KERNEL__
5#include <linux/types.h>
6#include <asm/sizes.h>
7#else
8#include <stdint.h>
9#endif
10#include <linux/ioctl.h>
11#include <linux/videodev2.h>
12
13
14#undef FM_DEBUG
15
16/* constants */
17#define RDS_BLOCKS_NUM (4)
18#define BYTES_PER_BLOCK (3)
19#define MAX_PS_LENGTH (96)
20#define MAX_RT_LENGTH (64)
21
22#define XFRDAT0 (0x20)
23#define XFRDAT1 (0x21)
24#define XFRDAT2 (0x22)
25
26#define INTDET_PEEK_MSB (0x88)
27#define INTDET_PEEK_LSB (0x26)
28
29#define RMSSI_PEEK_MSB (0x88)
30#define RMSSI_PEEK_LSB (0xA8)
31
32#define MPX_DCC_BYPASS_POKE_MSB (0x88)
33#define MPX_DCC_BYPASS_POKE_LSB (0xC0)
34
35#define MPX_DCC_PEEK_MSB_REG1 (0x88)
36#define MPX_DCC_PEEK_LSB_REG1 (0xC2)
37
38#define MPX_DCC_PEEK_MSB_REG2 (0x88)
39#define MPX_DCC_PEEK_LSB_REG2 (0xC3)
40
41#define MPX_DCC_PEEK_MSB_REG3 (0x88)
42#define MPX_DCC_PEEK_LSB_REG3 (0xC4)
43
Anantha Krishnanbdb128c2011-11-21 17:51:26 +053044#define ON_CHANNEL_TH_MSB (0x0B)
45#define ON_CHANNEL_TH_LSB (0xA8)
46
47#define OFF_CHANNEL_TH_MSB (0x0B)
48#define OFF_CHANNEL_TH_LSB (0xAC)
49
Anantha Krishnana02ef212011-06-28 00:57:25 +053050#define ENF_200Khz (1)
51#define SRCH200KHZ_OFFSET (7)
52#define SRCH_MASK (1 << SRCH200KHZ_OFFSET)
53
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070054/* Standard buffer size */
Ayaz Ahmad89265112012-10-05 19:39:11 +053055#define STD_BUF_SIZE (256)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056/* Search direction */
57#define SRCH_DIR_UP (0)
58#define SRCH_DIR_DOWN (1)
59
60/* control options */
61#define CTRL_ON (1)
62#define CTRL_OFF (0)
63
64#define US_LOW_BAND (87.5)
65#define US_HIGH_BAND (108)
66
67/* constant for Tx */
68
69#define MASK_PI (0x0000FFFF)
70#define MASK_PI_MSB (0x0000FF00)
71#define MASK_PI_LSB (0x000000FF)
72#define MASK_PTY (0x0000001F)
73#define MASK_TXREPCOUNT (0x0000000F)
74
75#undef FMDBG
76#ifdef FM_DEBUG
77 #define FMDBG(fmt, args...) printk(KERN_INFO "tavarua_radio: " fmt, ##args)
78#else
79 #define FMDBG(fmt, args...)
80#endif
81
82#undef FMDERR
83#define FMDERR(fmt, args...) printk(KERN_INFO "tavarua_radio: " fmt, ##args)
84
85#undef FMDBG_I2C
86#ifdef FM_DEBUG_I2C
87 #define FMDBG_I2C(fmt, args...) printk(KERN_INFO "fm_i2c: " fmt, ##args)
88#else
89 #define FMDBG_I2C(fmt, args...)
90#endif
91
92/* function declarations */
93/* FM Core audio paths. */
94#define TAVARUA_AUDIO_OUT_ANALOG_OFF (0)
95#define TAVARUA_AUDIO_OUT_ANALOG_ON (1)
96#define TAVARUA_AUDIO_OUT_DIGITAL_OFF (0)
97#define TAVARUA_AUDIO_OUT_DIGITAL_ON (1)
98
99int tavarua_set_audio_path(int digital_on, int analog_on);
100
101/* defines and enums*/
102
103#define MARIMBA_A0 0x01010013
104#define MARIMBA_2_1 0x02010204
105#define BAHAMA_1_0 0x0302010A
106#define BAHAMA_2_0 0x04020205
Venkateshwarlu Domakondaa6757832012-09-24 15:05:44 +0530107#define BAHAMA_2_1 0x04020309
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700108#define WAIT_TIMEOUT 2000
109#define RADIO_INIT_TIME 15
110#define TAVARUA_DELAY 10
111/*
112 * The frequency is set in units of 62.5 Hz when using V4L2_TUNER_CAP_LOW,
113 * 62.5 kHz otherwise.
114 * The tuner is able to have a channel spacing of 50, 100 or 200 kHz.
115 * tuner->capability is therefore set to V4L2_TUNER_CAP_LOW
116 * The FREQ_MUL is then: 1 MHz / 62.5 Hz = 16000
117 */
118#define FREQ_MUL (1000000 / 62.5)
119
120enum v4l2_cid_private_tavarua_t {
121 V4L2_CID_PRIVATE_TAVARUA_SRCHMODE = (V4L2_CID_PRIVATE_BASE + 1),
122 V4L2_CID_PRIVATE_TAVARUA_SCANDWELL,
123 V4L2_CID_PRIVATE_TAVARUA_SRCHON,
124 V4L2_CID_PRIVATE_TAVARUA_STATE,
125 V4L2_CID_PRIVATE_TAVARUA_TRANSMIT_MODE,
126 V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_MASK,
127 V4L2_CID_PRIVATE_TAVARUA_REGION,
128 V4L2_CID_PRIVATE_TAVARUA_SIGNAL_TH,
129 V4L2_CID_PRIVATE_TAVARUA_SRCH_PTY,
130 V4L2_CID_PRIVATE_TAVARUA_SRCH_PI,
131 V4L2_CID_PRIVATE_TAVARUA_SRCH_CNT,
132 V4L2_CID_PRIVATE_TAVARUA_EMPHASIS,
133 V4L2_CID_PRIVATE_TAVARUA_RDS_STD,
134 V4L2_CID_PRIVATE_TAVARUA_SPACING,
135 V4L2_CID_PRIVATE_TAVARUA_RDSON,
136 V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_PROC,
137 V4L2_CID_PRIVATE_TAVARUA_LP_MODE,
138 V4L2_CID_PRIVATE_TAVARUA_ANTENNA,
139 V4L2_CID_PRIVATE_TAVARUA_RDSD_BUF,
140 V4L2_CID_PRIVATE_TAVARUA_PSALL,
141 /*v4l2 Tx controls*/
142 V4L2_CID_PRIVATE_TAVARUA_TX_SETPSREPEATCOUNT,
143 V4L2_CID_PRIVATE_TAVARUA_STOP_RDS_TX_PS_NAME,
144 V4L2_CID_PRIVATE_TAVARUA_STOP_RDS_TX_RT,
145 V4L2_CID_PRIVATE_TAVARUA_IOVERC,
146 V4L2_CID_PRIVATE_TAVARUA_INTDET,
147 V4L2_CID_PRIVATE_TAVARUA_MPX_DCC,
Anantha Krishnane46ef6f2011-06-29 23:56:03 +0530148 V4L2_CID_PRIVATE_TAVARUA_AF_JUMP,
Anantha Krishnanf2258602011-06-30 01:32:09 +0530149 V4L2_CID_PRIVATE_TAVARUA_RSSI_DELTA,
Srinivasa Rao Uppala4e38bfc2011-09-15 16:00:31 +0530150 V4L2_CID_PRIVATE_TAVARUA_HLSI,
Anantha Krishnan71d6fa62011-12-13 19:30:51 +0530151
Srinivasa Rao Uppala4e38bfc2011-09-15 16:00:31 +0530152 /*
Anantha Krishnan40bcd052011-12-05 15:28:29 +0530153 * Here we have IOCTl's that are specific to IRIS
Anantha Krishnan71d6fa62011-12-13 19:30:51 +0530154 * (V4L2_CID_PRIVATE_BASE + 0x1E to V4L2_CID_PRIVATE_BASE + 0x28)
Srinivasa Rao Uppala4e38bfc2011-09-15 16:00:31 +0530155 */
Anantha Krishnana3dcce42012-01-05 19:27:57 +0530156 V4L2_CID_PRIVATE_SOFT_MUTE,/* 0x800001E*/
Anantha Krishnan71d6fa62011-12-13 19:30:51 +0530157 V4L2_CID_PRIVATE_RIVA_ACCS_ADDR,
158 V4L2_CID_PRIVATE_RIVA_ACCS_LEN,
159 V4L2_CID_PRIVATE_RIVA_PEEK,
160 V4L2_CID_PRIVATE_RIVA_POKE,
161 V4L2_CID_PRIVATE_SSBI_ACCS_ADDR,
162 V4L2_CID_PRIVATE_SSBI_PEEK,
163 V4L2_CID_PRIVATE_SSBI_POKE,
164 V4L2_CID_PRIVATE_TX_TONE,
165 V4L2_CID_PRIVATE_RDS_GRP_COUNTERS,
Anantha Krishnana3dcce42012-01-05 19:27:57 +0530166 V4L2_CID_PRIVATE_SET_NOTCH_FILTER,/* 0x8000028 */
Anantha Krishnan71d6fa62011-12-13 19:30:51 +0530167
Anantha Krishnana3dcce42012-01-05 19:27:57 +0530168 V4L2_CID_PRIVATE_TAVARUA_SET_AUDIO_PATH,/* 0x8000029 */
169 V4L2_CID_PRIVATE_TAVARUA_DO_CALIBRATION,/* 0x800002A : IRIS */
170 V4L2_CID_PRIVATE_TAVARUA_SRCH_ALGORITHM,/* 0x800002B */
171 V4L2_CID_PRIVATE_IRIS_GET_SINR, /* 0x800002C : IRIS */
172 V4L2_CID_PRIVATE_INTF_LOW_THRESHOLD, /* 0x800002D */
173 V4L2_CID_PRIVATE_INTF_HIGH_THRESHOLD, /* 0x800002E */
174 V4L2_CID_PRIVATE_SINR_THRESHOLD, /* 0x800002F : IRIS */
175 V4L2_CID_PRIVATE_SINR_SAMPLES, /* 0x8000030 : IRIS */
Anantha Krishnan93eb1762012-06-04 13:41:07 +0530176 V4L2_CID_PRIVATE_SPUR_FREQ,
177 V4L2_CID_PRIVATE_SPUR_FREQ_RMSSI,
178 V4L2_CID_PRIVATE_SPUR_SELECTION,
179 V4L2_CID_PRIVATE_UPDATE_SPUR_TABLE,
Anantha Krishnan4c2dcd42012-06-25 14:09:14 +0530180 V4L2_CID_PRIVATE_VALID_CHANNEL,
Anantha Krishnanbdb128c2011-11-21 17:51:26 +0530181
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700182};
183
184enum tavarua_buf_t {
185 TAVARUA_BUF_SRCH_LIST,
186 TAVARUA_BUF_EVENTS,
187 TAVARUA_BUF_RT_RDS,
188 TAVARUA_BUF_PS_RDS,
189 TAVARUA_BUF_RAW_RDS,
190 TAVARUA_BUF_AF_LIST,
191 TAVARUA_BUF_MAX
192};
193
194enum tavarua_xfr_t {
195 TAVARUA_XFR_SYNC,
196 TAVARUA_XFR_ERROR,
197 TAVARUA_XFR_SRCH_LIST,
198 TAVARUA_XFR_RT_RDS,
199 TAVARUA_XFR_PS_RDS,
200 TAVARUA_XFR_AF_LIST,
201 TAVARUA_XFR_MAX
202};
203
Anantha Krishnana02ef212011-06-28 00:57:25 +0530204enum channel_spacing {
205 FM_CH_SPACE_200KHZ,
206 FM_CH_SPACE_100KHZ,
207 FM_CH_SPACE_50KHZ
208};
209
210enum step_size {
211 NO_SRCH200khz,
212 ENF_SRCH200khz
213};
214
215enum emphasis {
216 EMP_75,
217 EMP_50
218};
219
220enum rds_std {
221 RBDS_STD,
222 RDS_STD
223};
224
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700225/* offsets */
226#define RAW_RDS 0x0F
227#define RDS_BLOCK 3
228
229/* registers*/
230#define MARIMBA_XO_BUFF_CNTRL 0x07
231#define RADIO_REGISTERS 0x30
232#define XFR_REG_NUM 16
233#define STATUS_REG_NUM 3
234
235/* TX constants */
236#define HEADER_SIZE 4
237#define TX_ON 0x80
238#define TAVARUA_TX_RT RDS_RT_0
239#define TAVARUA_TX_PS RDS_PS_0
240
241enum register_t {
242 STATUS_REG1 = 0,
243 STATUS_REG2,
244 STATUS_REG3,
245 RDCTRL,
246 FREQ,
247 TUNECTRL,
248 SRCHRDS1,
249 SRCHRDS2,
250 SRCHCTRL,
251 IOCTRL,
252 RDSCTRL,
253 ADVCTRL,
254 AUDIOCTRL,
255 RMSSI,
256 IOVERC,
257 AUDIOIND = 0x1E,
258 XFRCTRL,
259 FM_CTL0 = 0xFF,
260 LEAKAGE_CNTRL = 0xFE,
261};
262#define BAHAMA_RBIAS_CTL1 0x07
263#define BAHAMA_FM_MODE_REG 0xFD
264#define BAHAMA_FM_CTL1_REG 0xFE
265#define BAHAMA_FM_CTL0_REG 0xFF
266#define BAHAMA_FM_MODE_NORMAL 0x00
267#define BAHAMA_LDO_DREG_CTL0 0xF0
268#define BAHAMA_LDO_AREG_CTL0 0xF4
269
270/* Radio Control */
271#define RDCTRL_STATE_OFFSET 0
272#define RDCTRL_STATE_MASK (3 << RDCTRL_STATE_OFFSET)
273#define RDCTRL_BAND_OFFSET 2
274#define RDCTRL_BAND_MASK (1 << RDCTRL_BAND_OFFSET)
275#define RDCTRL_CHSPACE_OFFSET 3
276#define RDCTRL_CHSPACE_MASK (3 << RDCTRL_CHSPACE_OFFSET)
277#define RDCTRL_DEEMPHASIS_OFFSET 5
278#define RDCTRL_DEEMPHASIS_MASK (1 << RDCTRL_DEEMPHASIS_OFFSET)
279#define RDCTRL_HLSI_OFFSET 6
280#define RDCTRL_HLSI_MASK (3 << RDCTRL_HLSI_OFFSET)
Anantha Krishnane46ef6f2011-06-29 23:56:03 +0530281#define RDSAF_OFFSET 6
282#define RDSAF_MASK (1 << RDSAF_OFFSET)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700283
284/* Tune Control */
285#define TUNE_STATION 0x01
286#define ADD_OFFSET (1 << 1)
287#define SIGSTATE (1 << 5)
288#define MOSTSTATE (1 << 6)
289#define RDSSYNC (1 << 7)
290/* Search Control */
291#define SRCH_MODE_OFFSET 0
292#define SRCH_MODE_MASK (7 << SRCH_MODE_OFFSET)
293#define SRCH_DIR_OFFSET 3
294#define SRCH_DIR_MASK (1 << SRCH_DIR_OFFSET)
295#define SRCH_DWELL_OFFSET 4
296#define SRCH_DWELL_MASK (7 << SRCH_DWELL_OFFSET)
297#define SRCH_STATE_OFFSET 7
298#define SRCH_STATE_MASK (1 << SRCH_STATE_OFFSET)
299
300/* I/O Control */
301#define IOC_HRD_MUTE 0x03
302#define IOC_SFT_MUTE (1 << 2)
303#define IOC_MON_STR (1 << 3)
304#define IOC_SIG_BLND (1 << 4)
305#define IOC_INTF_BLND (1 << 5)
306#define IOC_ANTENNA (1 << 6)
307#define IOC_ANTENNA_OFFSET 6
308#define IOC_ANTENNA_MASK (1 << IOC_ANTENNA_OFFSET)
309
310/* RDS Control */
311#define RDS_ON 0x01
312#define RDSCTRL_STANDARD_OFFSET 1
313#define RDSCTRL_STANDARD_MASK (1 << RDSCTRL_STANDARD_OFFSET)
314
315/* Advanced features controls */
316#define RDSRTEN (1 << 3)
317#define RDSPSEN (1 << 4)
318
319/* Audio path control */
320#define AUDIORX_ANALOG_OFFSET 0
321#define AUDIORX_ANALOG_MASK (1 << AUDIORX_ANALOG_OFFSET)
322#define AUDIORX_DIGITAL_OFFSET 1
323#define AUDIORX_DIGITAL_MASK (1 << AUDIORX_DIGITAL_OFFSET)
324#define AUDIOTX_OFFSET 2
325#define AUDIOTX_MASK (1 << AUDIOTX_OFFSET)
326#define I2SCTRL_OFFSET 3
327#define I2SCTRL_MASK (1 << I2SCTRL_OFFSET)
328
329/* Search options */
330enum search_t {
331 SEEK,
332 SCAN,
333 SCAN_FOR_STRONG,
334 SCAN_FOR_WEAK,
335 RDS_SEEK_PTY,
336 RDS_SCAN_PTY,
337 RDS_SEEK_PI,
338 RDS_AF_JUMP,
339};
340
Anantha Krishnan4c2dcd42012-06-25 14:09:14 +0530341/* Band limits */
342#define REGION_US_EU_BAND_LOW 87500
343#define REGION_US_EU_BAND_HIGH 108000
344#define REGION_JAPAN_STANDARD_BAND_LOW 76000
345#define REGION_JAPAN_STANDARD_BAND_HIGH 90000
346#define REGION_JAPAN_WIDE_BAND_LOW 90000
347#define REGION_JAPAN_WIDE_BAND_HIGH 108000
348#define MPX_DCC_BYPASS_REG 0x88C0
349#define MPX_DCC_DATA_REG 0x88C2
350
Anantha Krishnanc72725a2011-09-06 09:28:22 +0530351enum audio_path {
352 FM_DIGITAL_PATH,
353 FM_ANALOG_PATH
354};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700355#define SRCH_MODE 0x07
356#define SRCH_DIR 0x08 /* 0-up 1-down */
357#define SCAN_DWELL 0x70
358#define SRCH_ON 0x80
359
360/* RDS CONFIG */
361#define RDS_CONFIG_PSALL 0x01
362
363#define FM_ENABLE 0x22
364#define SET_REG_FIELD(reg, val, offset, mask) \
365 (reg = (reg & ~mask) | (((val) << offset) & mask))
366#define GET_REG_FIELD(reg, offset, mask) ((reg & mask) >> offset)
Anantha Krishnan29f1d932011-12-29 21:17:29 +0530367#define RSH_DATA(val, offset) ((val) >> (offset))
Anantha Krishnana3dcce42012-01-05 19:27:57 +0530368#define LSH_DATA(val, offset) ((val) << (offset))
Anantha Krishnan29f1d932011-12-29 21:17:29 +0530369#define GET_ABS_VAL(val) ((val) & (0xFF))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700370
371enum radio_state_t {
372 FM_OFF,
373 FM_RECV,
374 FM_TRANS,
375 FM_RESET,
376};
377
378#define XFRCTRL_WRITE (1 << 7)
379
380/* Interrupt status */
381
382/* interrupt register 1 */
383#define READY (1 << 0) /* Radio ready after powerup or reset */
384#define TUNE (1 << 1) /* Tune completed */
385#define SEARCH (1 << 2) /* Search completed (read FREQ) */
386#define SCANNEXT (1 << 3) /* Scanning for next station */
387#define SIGNAL (1 << 4) /* Signal indicator change (read SIGSTATE) */
388#define INTF (1 << 5) /* Interference cnt has fallen outside range */
389#define SYNC (1 << 6) /* RDS sync state change (read RDSSYNC) */
390#define AUDIO (1 << 7) /* Audio Control indicator (read AUDIOIND) */
391
392/* interrupt register 2 */
393#define RDSDAT (1 << 0) /* New unread RDS data group available */
394#define BLOCKB (1 << 1) /* Block-B match condition exists */
395#define PROGID (1 << 2) /* Block-A or Block-C matched stored PI value*/
396#define RDSPS (1 << 3) /* New RDS Program Service Table available */
397#define RDSRT (1 << 4) /* New RDS Radio Text available */
398#define RDSAF (1 << 5) /* New RDS AF List available */
399#define TXRDSDAT (1 << 6) /* Transmitted an RDS group */
400#define TXRDSDONE (1 << 7) /* RDS raw group one-shot transmit completed */
401
402/* interrupt register 3 */
403#define TRANSFER (1 << 0) /* Data transfer (XFR) completed */
404#define RDSPROC (1 << 1) /* Dynamic RDS Processing complete */
405#define ERROR (1 << 7) /* Err occurred.Read code to determine cause */
406
407
408#define FM_TX_PWR_LVL_0 0 /* Lowest power lvl that can be set for Tx */
409#define FM_TX_PWR_LVL_MAX 7 /* Max power lvl for Tx */
Ayaz Ahmada0d56b52012-06-26 15:58:41 +0530410
411/* Tone Generator control value */
412#define TONE_GEN_CTRL_BYTE 0x00
413#define TONE_CHANNEL_EN_AND_SCALING_BYTE 0x01
414#define TONE_LEFT_FREQ_BYTE 0x02
415#define TONE_RIGHT_FREQ_BYTE 0x03
416#define TONE_LEFT_PHASE 0x04
417#define TONE_RIGHT_PHASE 0x05
418
419#define TONE_LEFT_CH_ENABLED 0x01
420#define TONE_RIGHT_CH_ENABLED 0x02
421#define TONE_LEFT_RIGHT_CH_ENABLED (TONE_LEFT_CH_ENABLED\
422 | TONE_RIGHT_CH_ENABLED)
423
424#define TONE_SCALING_SHIFT 0x02
425
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700426/* Transfer */
427enum tavarua_xfr_ctrl_t {
428 RDS_PS_0 = 0x01,
429 RDS_PS_1,
430 RDS_PS_2,
431 RDS_PS_3,
432 RDS_PS_4,
433 RDS_PS_5,
434 RDS_PS_6,
435 RDS_RT_0,
436 RDS_RT_1,
437 RDS_RT_2,
438 RDS_RT_3,
439 RDS_RT_4,
440 RDS_AF_0,
441 RDS_AF_1,
442 RDS_CONFIG,
443 RDS_TX_GROUPS,
444 RDS_COUNT_0,
445 RDS_COUNT_1,
446 RDS_COUNT_2,
447 RADIO_CONFIG,
448 RX_CONFIG,
449 RX_TIMERS,
450 RX_STATIONS_0,
451 RX_STATIONS_1,
452 INT_CTRL,
453 ERROR_CODE,
454 CHIPID,
455 CAL_DAT_0 = 0x20,
456 CAL_DAT_1,
457 CAL_DAT_2,
458 CAL_DAT_3,
459 CAL_CFG_0,
460 CAL_CFG_1,
461 DIG_INTF_0,
462 DIG_INTF_1,
463 DIG_AGC_0,
464 DIG_AGC_1,
465 DIG_AGC_2,
466 DIG_AUDIO_0,
467 DIG_AUDIO_1,
468 DIG_AUDIO_2,
469 DIG_AUDIO_3,
470 DIG_AUDIO_4,
471 DIG_RXRDS,
472 DIG_DCC,
473 DIG_SPUR,
474 DIG_MPXDCC,
475 DIG_PILOT,
476 DIG_DEMOD,
477 DIG_MOST,
478 DIG_TX_0,
479 DIG_TX_1,
480 PHY_TXGAIN = 0x3B,
481 PHY_CONFIG,
482 PHY_TXBLOCK,
483 PHY_TCB,
Ayaz Ahmada0d56b52012-06-26 15:58:41 +0530484 XFR_EXT,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700485 XFR_PEEK_MODE = 0x40,
486 XFR_POKE_MODE = 0xC0,
487 TAVARUA_XFR_CTRL_MAX
488};
489
490enum tavarua_evt_t {
491 TAVARUA_EVT_RADIO_READY,
492 TAVARUA_EVT_TUNE_SUCC,
493 TAVARUA_EVT_SEEK_COMPLETE,
494 TAVARUA_EVT_SCAN_NEXT,
495 TAVARUA_EVT_NEW_RAW_RDS,
496 TAVARUA_EVT_NEW_RT_RDS,
497 TAVARUA_EVT_NEW_PS_RDS,
498 TAVARUA_EVT_ERROR,
499 TAVARUA_EVT_BELOW_TH,
500 TAVARUA_EVT_ABOVE_TH,
501 TAVARUA_EVT_STEREO,
502 TAVARUA_EVT_MONO,
503 TAVARUA_EVT_RDS_AVAIL,
504 TAVARUA_EVT_RDS_NOT_AVAIL,
505 TAVARUA_EVT_NEW_SRCH_LIST,
506 TAVARUA_EVT_NEW_AF_LIST,
507 TAVARUA_EVT_TXRDSDAT,
Ayaz Ahmad0fa19842012-03-14 22:54:53 +0530508 TAVARUA_EVT_TXRDSDONE,
509 TAVARUA_EVT_RADIO_DISABLED
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700510};
511
512enum tavarua_region_t {
513 TAVARUA_REGION_US,
514 TAVARUA_REGION_EU,
515 TAVARUA_REGION_JAPAN,
516 TAVARUA_REGION_JAPAN_WIDE,
517 TAVARUA_REGION_OTHER
518};
519
Anantha Krishnan93eb1762012-06-04 13:41:07 +0530520enum {
521 ONE_BYTE = 1,
522 TWO_BYTE,
523 THREE_BYTE,
524 FOUR_BYTE,
525 FIVE_BYTE,
526 SIX_BYTE,
527 SEVEN_BYTE,
528 EIGHT_BYTE,
529 NINE_BYTE,
530 TEN_BYTE,
531 ELEVEN_BYTE,
532 TWELVE_BYTE,
533 THIRTEEN_BYTE
534};
Ayaz Ahmada0d56b52012-06-26 15:58:41 +0530535
Anantha Krishnan93eb1762012-06-04 13:41:07 +0530536#define XFR_READ (0)
537#define XFR_WRITE (1)
538#define XFR_MODE_OFFSET (0)
539#define XFR_ADDR_MSB_OFFSET (1)
540#define XFR_ADDR_LSB_OFFSET (2)
541#define XFR_DATA_OFFSET (3)
542#define SPUR_DATA_SIZE (3)
543#define MAX_SPUR_FREQ_LIMIT (30)
544#define READ_COMPLETE (0x20)
545#define SPUR_TABLE_ADDR (0x0BB7)
546#define SPUR_TABLE_START_ADDR (SPUR_TABLE_ADDR + 1)
547#define XFR_PEEK_COMPLETE (XFR_PEEK_MODE | READ_COMPLETE)
548#define XFR_POKE_COMPLETE (XFR_POKE_MODE)
Anantha Krishnan4c2dcd42012-06-25 14:09:14 +0530549#define TUNE_MULT (16)
550#define ADJ_CHANNEL_KHZ (50)
551#define MPX_DCC_UPPER_LIMIT (20000)
552#define MPX_DCC_LIMIT (12566)
553#define INVALID_CHANNEL (0)
554#define VALID_CHANNEL (1)
Anantha Krishnan93eb1762012-06-04 13:41:07 +0530555
556#define COMPUTE_SPUR(val) ((((val) - (76000)) / (50)))
557#define GET_FREQ(val, bit) ((bit == 1) ? ((val) >> 8) : ((val) & 0xFF))
558
559struct fm_spur_data {
560 int freq[MAX_SPUR_FREQ_LIMIT];
561 __s8 rmssi[MAX_SPUR_FREQ_LIMIT];
562} __packed;
563
564struct fm_def_data_wr_req {
565 __u8 mode;
566 __u8 length;
567 __u8 data[XFR_REG_NUM];
568} __packed;
569
Ayaz Ahmada0d56b52012-06-26 15:58:41 +0530570enum Internal_tone_gen_vals {
571 ONE_KHZ_LR_EQUA_0DBFS = 1,
572 ONE_KHZ_LEFTONLY_EQUA_0DBFS,
573 ONE_KHZ_RIGHTONLY_EQUA_0DBFS,
574 ONE_KHZ_LR_EQUA_l8DBFS,
575 FIFTEEN_KHZ_LR_EQUA_l8DBFS
576};
577
578enum Tone_scaling_indexes {
579 TONE_SCALE_IND_0,
580 TONE_SCALE_IND_1,
581 TONE_SCALE_IND_2,
582 TONE_SCALE_IND_3,
583 TONE_SCALE_IND_4,
584 TONE_SCALE_IND_5,
585 TONE_SCALE_IND_6,
586 TONE_SCALE_IND_7,
587 TONE_SCALE_IND_8,
588 TONE_SCALE_IND_9,
589 TONE_SCALE_IND_10,
590 TONE_SCALE_IND_11,
591 TONE_SCALE_IND_12
592};
593
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700594#endif /* __LINUX_TAVARUA_H */