stv090x_priv.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /*
  2. STV0900/0903 Multistandard Broadcast Frontend driver
  3. Copyright (C) Manu Abraham <abraham.manu@gmail.com>
  4. Copyright (C) ST Microelectronics
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17. #ifndef __STV090x_PRIV_H
  18. #define __STV090x_PRIV_H
  19. #include "dvb_frontend.h"
  20. #define FE_ERROR 0
  21. #define FE_NOTICE 1
  22. #define FE_INFO 2
  23. #define FE_DEBUG 3
  24. #define FE_DEBUGREG 4
  25. #define dprintk(__y, __z, format, arg...) do { \
  26. if (__z) { \
  27. if ((verbose > FE_ERROR) && (verbose > __y)) \
  28. printk(KERN_ERR "%s: " format "\n", __func__ , ##arg); \
  29. else if ((verbose > FE_NOTICE) && (verbose > __y)) \
  30. printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg); \
  31. else if ((verbose > FE_INFO) && (verbose > __y)) \
  32. printk(KERN_INFO "%s: " format "\n", __func__ , ##arg); \
  33. else if ((verbose > FE_DEBUG) && (verbose > __y)) \
  34. printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg); \
  35. } else { \
  36. if (verbose > __y) \
  37. printk(format, ##arg); \
  38. } \
  39. } while (0)
  40. #define STV090x_READ_DEMOD(__state, __reg) (( \
  41. (__state)->demod == STV090x_DEMODULATOR_1) ? \
  42. stv090x_read_reg(__state, STV090x_P2_##__reg) : \
  43. stv090x_read_reg(__state, STV090x_P1_##__reg))
  44. #define STV090x_WRITE_DEMOD(__state, __reg, __data) (( \
  45. (__state)->demod == STV090x_DEMODULATOR_1) ? \
  46. stv090x_write_reg(__state, STV090x_P2_##__reg, __data) :\
  47. stv090x_write_reg(__state, STV090x_P1_##__reg, __data))
  48. #define STV090x_ADDR_OFFST(__state, __x) (( \
  49. (__state->demod) == STV090x_DEMODULATOR_1) ? \
  50. STV090x_P1_##__x : \
  51. STV090x_P2_##__x)
  52. #define STV090x_SETFIELD(mask, bitf, val) (mask = (mask & (~(((1 << STV090x_WIDTH_##bitf) - 1) <<\
  53. STV090x_OFFST_##bitf))) | \
  54. (val << STV090x_OFFST_##bitf))
  55. #define STV090x_GETFIELD(val, bitf) ((val >> STV090x_OFFST_##bitf) & ((1 << STV090x_WIDTH_##bitf) - 1))
  56. #define STV090x_SETFIELD_Px(mask, bitf, val) (mask = (mask & (~(((1 << STV090x_WIDTH_Px_##bitf) - 1) <<\
  57. STV090x_OFFST_Px_##bitf))) | \
  58. (val << STV090x_OFFST_Px_##bitf))
  59. #define STV090x_GETFIELD_Px(val, bitf) ((val >> STV090x_OFFST_Px_##bitf) & ((1 << STV090x_WIDTH_Px_##bitf) - 1))
  60. #define MAKEWORD16(__a, __b) (((__a) << 8) | (__b))
  61. #define MSB(__x) ((__x >> 8) & 0xff)
  62. #define LSB(__x) (__x & 0xff)
  63. #define STV090x_IQPOWER_THRESHOLD 30
  64. #define STV090x_SEARCH_AGC2_TH_CUT20 700
  65. #define STV090x_SEARCH_AGC2_TH_CUT30 1400
  66. #define STV090x_SEARCH_AGC2_TH(__ver) \
  67. ((__ver <= 0x20) ? \
  68. STV090x_SEARCH_AGC2_TH_CUT20 : \
  69. STV090x_SEARCH_AGC2_TH_CUT30)
  70. enum stv090x_signal_state {
  71. STV090x_NOAGC1,
  72. STV090x_NOCARRIER,
  73. STV090x_NODATA,
  74. STV090x_DATAOK,
  75. STV090x_RANGEOK,
  76. STV090x_OUTOFRANGE
  77. };
  78. enum stv090x_fec {
  79. STV090x_PR12 = 0,
  80. STV090x_PR23,
  81. STV090x_PR34,
  82. STV090x_PR45,
  83. STV090x_PR56,
  84. STV090x_PR67,
  85. STV090x_PR78,
  86. STV090x_PR89,
  87. STV090x_PR910,
  88. STV090x_PRERR
  89. };
  90. enum stv090x_modulation {
  91. STV090x_QPSK,
  92. STV090x_8PSK,
  93. STV090x_16APSK,
  94. STV090x_32APSK,
  95. STV090x_UNKNOWN
  96. };
  97. enum stv090x_frame {
  98. STV090x_LONG_FRAME,
  99. STV090x_SHORT_FRAME
  100. };
  101. enum stv090x_pilot {
  102. STV090x_PILOTS_OFF,
  103. STV090x_PILOTS_ON
  104. };
  105. enum stv090x_rolloff {
  106. STV090x_RO_35,
  107. STV090x_RO_25,
  108. STV090x_RO_20
  109. };
  110. enum stv090x_inversion {
  111. STV090x_IQ_AUTO,
  112. STV090x_IQ_NORMAL,
  113. STV090x_IQ_SWAP
  114. };
  115. enum stv090x_modcod {
  116. STV090x_DUMMY_PLF = 0,
  117. STV090x_QPSK_14,
  118. STV090x_QPSK_13,
  119. STV090x_QPSK_25,
  120. STV090x_QPSK_12,
  121. STV090x_QPSK_35,
  122. STV090x_QPSK_23,
  123. STV090x_QPSK_34,
  124. STV090x_QPSK_45,
  125. STV090x_QPSK_56,
  126. STV090x_QPSK_89,
  127. STV090x_QPSK_910,
  128. STV090x_8PSK_35,
  129. STV090x_8PSK_23,
  130. STV090x_8PSK_34,
  131. STV090x_8PSK_56,
  132. STV090x_8PSK_89,
  133. STV090x_8PSK_910,
  134. STV090x_16APSK_23,
  135. STV090x_16APSK_34,
  136. STV090x_16APSK_45,
  137. STV090x_16APSK_56,
  138. STV090x_16APSK_89,
  139. STV090x_16APSK_910,
  140. STV090x_32APSK_34,
  141. STV090x_32APSK_45,
  142. STV090x_32APSK_56,
  143. STV090x_32APSK_89,
  144. STV090x_32APSK_910,
  145. STV090x_MODCODE_UNKNOWN
  146. };
  147. enum stv090x_search {
  148. STV090x_SEARCH_DSS = 0,
  149. STV090x_SEARCH_DVBS1,
  150. STV090x_SEARCH_DVBS2,
  151. STV090x_SEARCH_AUTO
  152. };
  153. enum stv090x_algo {
  154. STV090x_BLIND_SEARCH,
  155. STV090x_COLD_SEARCH,
  156. STV090x_WARM_SEARCH
  157. };
  158. enum stv090x_delsys {
  159. STV090x_ERROR = 0,
  160. STV090x_DVBS1 = 1,
  161. STV090x_DVBS2,
  162. STV090x_DSS
  163. };
  164. struct stv090x_long_frame_crloop {
  165. enum stv090x_modcod modcod;
  166. u8 crl_pilots_on_2;
  167. u8 crl_pilots_off_2;
  168. u8 crl_pilots_on_5;
  169. u8 crl_pilots_off_5;
  170. u8 crl_pilots_on_10;
  171. u8 crl_pilots_off_10;
  172. u8 crl_pilots_on_20;
  173. u8 crl_pilots_off_20;
  174. u8 crl_pilots_on_30;
  175. u8 crl_pilots_off_30;
  176. };
  177. struct stv090x_short_frame_crloop {
  178. enum stv090x_modulation modulation;
  179. u8 crl_2; /* SR < 3M */
  180. u8 crl_5; /* 3 < SR <= 7M */
  181. u8 crl_10; /* 7 < SR <= 15M */
  182. u8 crl_20; /* 10 < SR <= 25M */
  183. u8 crl_30; /* 10 < SR <= 45M */
  184. };
  185. struct stv090x_reg {
  186. u16 addr;
  187. u8 data;
  188. };
  189. struct stv090x_tab {
  190. s32 real;
  191. s32 read;
  192. };
  193. struct stv090x_internal {
  194. struct i2c_adapter *i2c_adap;
  195. u8 i2c_addr;
  196. struct mutex demod_lock; /* Lock access to shared register */
  197. struct mutex tuner_lock; /* Lock access to tuners */
  198. s32 mclk; /* Masterclock Divider factor */
  199. u32 dev_ver;
  200. int num_used;
  201. };
  202. struct stv090x_state {
  203. enum stv090x_device device;
  204. enum stv090x_demodulator demod;
  205. enum stv090x_mode demod_mode;
  206. struct stv090x_internal *internal;
  207. struct i2c_adapter *i2c;
  208. const struct stv090x_config *config;
  209. struct dvb_frontend frontend;
  210. u32 *verbose; /* Cached module verbosity */
  211. enum stv090x_delsys delsys;
  212. enum stv090x_fec fec;
  213. enum stv090x_modulation modulation;
  214. enum stv090x_modcod modcod;
  215. enum stv090x_search search_mode;
  216. enum stv090x_frame frame_len;
  217. enum stv090x_pilot pilots;
  218. enum stv090x_rolloff rolloff;
  219. enum stv090x_inversion inversion;
  220. enum stv090x_algo algo;
  221. u32 frequency;
  222. u32 srate;
  223. s32 tuner_bw;
  224. s32 search_range;
  225. s32 DemodTimeout;
  226. s32 FecTimeout;
  227. };
  228. #endif /* __STV090x_PRIV_H */