fm_config.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #ifndef __FM_CONFIG_H__
  2. #define __FM_CONFIG_H__
  3. #include "fm_typedef.h"
  4. #include "fm_rds.h"
  5. #include "fm_dbg.h"
  6. #include "fm_err.h"
  7. #include "fm_stdlib.h"
  8. #include "fm_interface.h"
  9. /* band */
  10. #define FM_BAND_UNKNOWN 0
  11. #define FM_BAND_UE 1 /* US/Europe band 87.5MHz ~ 108MHz (DEFAULT) */
  12. #define FM_BAND_JAPAN 2 /* Japan band 76MHz ~ 90MHz */
  13. #define FM_BAND_JAPANW 3 /* Japan wideband 76MHZ ~ 108MHz */
  14. #define FM_BAND_SPECIAL 4 /* special band between 76MHZ and 108MHz */
  15. #define FM_BAND_DEFAULT FM_BAND_UE
  16. #define FM_RAIDO_BAND FM_BAND_UE
  17. #define FM_FREQ_MIN FM_RX_BAND_FREQ_L
  18. #define FM_FREQ_MAX FM_RX_BAND_FREQ_H
  19. #define FM_UE_FREQ_MIN 8750
  20. #define FM_UE_FREQ_MAX 10800
  21. #define FM_JP_FREQ_MIN 7600
  22. #define FM_JP_FREQ_MAX 10800
  23. #define FM_RX_BAND_FREQ_L 8750 /* FM radio special band low freq(Default 87.5MHz) */
  24. #define FM_RX_BAND_FREQ_H 10800 /* FM radio special band high freq(Default 108.0MHz) */
  25. /* TX */
  26. #define FM_TX_SCAN_HOLE_LOW 9230 /* 92.3MHz~95.4MHz should not show to user */
  27. #define FM_TX_SCAN_HOLE_HIGH 9540 /* 92.3MHz~95.4MHz should not show to user */
  28. /* space */
  29. #define FM_SPACE_UNKNOWN 0
  30. #define FM_SPACE_100K 1
  31. #define FM_SPACE_200K 2
  32. #define FM_SPACE_50K 5
  33. #ifdef CONFIG_MTK_FM_50KHZ_SUPPORT
  34. #define FM_SPACE_DEFAULT FM_SPACE_50K
  35. #else
  36. #define FM_SPACE_DEFAULT FM_SPACE_100K
  37. #endif
  38. #define FM_TX_SCAN_UP (0)
  39. #define FM_TX_SCAN_DOWN (1)
  40. #define FM_TX_SCAN_MAX 10
  41. #define FM_TX_SCAN_MIN 1
  42. /* seek direction */
  43. #define FM_SEEK_UP 0
  44. #define FM_SEEK_DOWN 1
  45. #define FM_CHIP_AR1000 0x1000
  46. #define FM_CHIP_MT5192 0x91
  47. #define FM_CHIP_MT5193 0x92
  48. #define FM_CHIP_MT6616 0x6616
  49. #define FM_CHIP_MT6626 0x6626
  50. #define FM_CHIP_MT6628 0x6628
  51. #define FM_CHIP_MT6620 0x6620
  52. #define FM_CHIP_MT6627 0x6627
  53. #define FM_CHIP_MT6580 0x6580
  54. #define FM_CHIP_UNSUPPORTED 0xffff
  55. enum fm_cfg_parser_state {
  56. FM_CFG_STAT_NONE = 0,
  57. FM_CFG_STAT_GROUP,
  58. FM_CFG_STAT_KEY,
  59. FM_CFG_STAT_VALUE,
  60. FM_CFG_STAT_COMMENT
  61. };
  62. typedef enum fm_cfg_parser_state fm_cfg_parser_state_t;
  63. #define COMMENT_CHAR '#'
  64. #define DELIMIT_CHAR '='
  65. #define isspace(a) ((a) == 0x20)
  66. #define FAKE_CH_MAX 10
  67. #define FM_CUST_CFG_PATH "/etc/fm_cust.cfg"
  68. struct fm_rx_cust_cfg {
  69. fm_s32 desene_rssi_th;
  70. fm_s32 pamd_th;
  71. fm_s32 mr_th;
  72. fm_s32 atdc_th;
  73. fm_s32 prx_th;
  74. fm_s32 atdev_th;
  75. fm_s32 short_ana_rssi_th;
  76. fm_s32 long_ana_rssi_th;
  77. fm_s32 cqi_th;
  78. /* fm_u16 mr_th; */
  79. fm_s32 smg_th;
  80. fm_s32 scan_ch_size;
  81. fm_s32 seek_space;
  82. fm_s32 band;
  83. fm_s32 band_freq_l;
  84. fm_s32 band_freq_h;
  85. fm_s32 scan_sort;
  86. fm_s32 fake_ch[FAKE_CH_MAX];
  87. fm_s32 fake_ch_num;
  88. fm_s32 fake_ch_rssi_th;
  89. fm_s32 deemphasis;
  90. fm_s32 osc_freq;
  91. };
  92. struct fm_tx_cust_cfg {
  93. fm_s32 scan_hole_low;
  94. fm_s32 scan_hole_high;
  95. fm_s32 power_level;
  96. fm_s32 pamd_th;
  97. fm_s32 mr_th;
  98. fm_s32 smg_th;
  99. };
  100. typedef struct {
  101. struct fm_rx_cust_cfg rx_cfg;
  102. struct fm_tx_cust_cfg tx_cfg;
  103. fm_audio_info_t aud_cfg;
  104. } fm_cust_cfg;
  105. enum fm_cust_cfg_op {
  106. FM_CFG_RX_RSSI_TH_LONG = 0,
  107. FM_CFG_RX_RSSI_TH_SHORT,
  108. FM_CFG_RX_CQI_TH,
  109. FM_CFG_RX_MR_TH,
  110. FM_CFG_RX_SMG_TH,
  111. FM_CFG_RX_SCAN_CH_SIZE,
  112. FM_CFG_RX_SEEK_SPACE,
  113. FM_CFG_RX_BAND,
  114. FM_CFG_RX_BAND_FREQ_L,
  115. FM_CFG_RX_BAND_FREQ_H,
  116. FM_CFG_RX_SCAN_SORT,
  117. FM_CFG_RX_FAKE_CH_NUM,
  118. FM_CFG_RX_FAKE_CH_RSSI,
  119. FM_CFG_RX_FAKE_CH,
  120. FM_CFG_RX_DEEMPHASIS,
  121. FM_CFG_RX_OSC_FREQ,
  122. FM_CFG_TX_SCAN_HOLE_LOW,
  123. FM_CFG_TX_SCAN_HOLE_HIGH,
  124. FM_CFG_TX_PWR_LEVEL,
  125. FM_CFG_MAX
  126. };
  127. typedef fm_s32(*CFG_HANDLER) (fm_s8 *grp, fm_s8 *key, fm_s8 *val, fm_cust_cfg *cfg);
  128. extern fm_s32 to_upper_n(fm_s8 *str, fm_s32 len);
  129. extern fm_s32 check_hex_str(fm_s8 *str, fm_s32 len);
  130. extern fm_s32 check_dec_str(fm_s8 *str, fm_s32 len);
  131. extern fm_s32 ascii_to_hex(fm_s8 *in_ascii, fm_u16 *out_hex);
  132. extern fm_s32 ascii_to_dec(fm_s8 *in_ascii, fm_s32 *out_dec);
  133. extern fm_s32 trim_string(fm_s8 **start);
  134. extern fm_s32 trim_path(fm_s8 **start);
  135. extern fm_s32 cfg_parser(fm_s8 *buffer, CFG_HANDLER handler, fm_cust_cfg *cfg);
  136. extern fm_s32 cfg_item_match(fm_s8 *src_key, fm_s8 *src_val, fm_s8 *dst_key, fm_s32 *dst_val);
  137. extern fm_s32 fm_cust_config(const fm_s8 *filepath);
  138. extern fm_u16 fm_cust_config_fetch(enum fm_cust_cfg_op op_code);
  139. #ifdef MT6628_FM
  140. extern fm_s32 MT6628fm_cust_config_setup(const fm_s8 *filepath);
  141. extern fm_u16 MT6628fm_cust_config_fetch(enum fm_cust_cfg_op op_code);
  142. #endif
  143. #ifdef MT6620_FM
  144. extern fm_s32 MT6620fm_cust_config_setup(const fm_s8 *filepath);
  145. extern fm_u16 MT6620fm_cust_config_fetch(enum fm_cust_cfg_op op_code);
  146. #endif
  147. #ifdef MT6627_FM
  148. extern fm_s32 MT6627fm_cust_config_setup(const fm_s8 *filepath);
  149. extern fm_u16 MT6627fm_cust_config_fetch(enum fm_cust_cfg_op op_code);
  150. #endif
  151. #ifdef MT6580_FM
  152. extern fm_s32 MT6580fm_cust_config_setup(const fm_s8 *filepath);
  153. extern fm_u16 MT6580fm_cust_config_fetch(enum fm_cust_cfg_op op_code);
  154. #endif
  155. #ifdef MT6630_FM
  156. extern fm_s32 MT6630fm_cust_config_setup(const fm_s8 *filepath);
  157. extern fm_u16 MT6630fm_cust_config_fetch(enum fm_cust_cfg_op op_code);
  158. #endif
  159. #endif /* __FM_CONFIG_H__ */