stv090x_priv.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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 STV090x_SEARCH_AGC2_TH 700
  62. enum stv090x_signal_state {
  63. STV090x_NOCARRIER,
  64. STV090x_NODATA,
  65. STV090x_DATAOK,
  66. STV090x_RANGEOK,
  67. STV090x_OUTOFRANGE
  68. };
  69. enum stv090x_fec {
  70. STV090x_PR12 = 0,
  71. STV090x_PR23,
  72. STV090x_PR34,
  73. STV090x_PR45,
  74. STV090x_PR56,
  75. STV090x_PR67,
  76. STV090x_PR78,
  77. STV090x_PR89,
  78. STV090x_PR910,
  79. STV090x_PRERR
  80. };
  81. enum stv090x_modulation {
  82. STV090x_QPSK,
  83. STV090x_8PSK,
  84. STV090x_16APSK,
  85. STV090x_32APSK,
  86. STV090x_UNKNOWN
  87. };
  88. enum stv090x_frame {
  89. STV090x_LONG_FRAME,
  90. STV090x_SHORT_FRAME
  91. };
  92. enum stv090x_pilot {
  93. STV090x_PILOTS_OFF,
  94. STV090x_PILOTS_ON
  95. };
  96. enum stv090x_rolloff {
  97. STV090x_RO_35,
  98. STV090x_RO_25,
  99. STV090x_RO_20
  100. };
  101. enum stv090x_inversion {
  102. STV090x_IQ_AUTO,
  103. STV090x_IQ_NORMAL,
  104. STV090x_IQ_SWAP
  105. };
  106. enum stv090x_modcod {
  107. STV090x_DUMMY_PLF = 0,
  108. STV090x_QPSK_14,
  109. STV090x_QPSK_13,
  110. STV090x_QPSK_25,
  111. STV090x_QPSK_12,
  112. STV090x_QPSK_35,
  113. STV090x_QPSK_23,
  114. STV090x_QPSK_34,
  115. STV090x_QPSK_45,
  116. STV090x_QPSK_56,
  117. STV090x_QPSK_89,
  118. STV090x_QPSK_910,
  119. STV090x_8PSK_35,
  120. STV090x_8PSK_23,
  121. STV090x_8PSK_34,
  122. STV090x_8PSK_56,
  123. STV090x_8PSK_89,
  124. STV090x_8PSK_910,
  125. STV090x_16APSK_23,
  126. STV090x_16APSK_34,
  127. STV090x_16APSK_45,
  128. STV090x_16APSK_56,
  129. STV090x_16APSK_89,
  130. STV090x_16APSK_910,
  131. STV090x_32APSK_34,
  132. STV090x_32APSK_45,
  133. STV090x_32APSK_56,
  134. STV090x_32APSK_89,
  135. STV090x_32APSK_910,
  136. STV090x_MODCODE_UNKNOWN
  137. };
  138. enum stv090x_search {
  139. STV090x_SEARCH_DSS = 0,
  140. STV090x_SEARCH_DVBS1,
  141. STV090x_SEARCH_DVBS2,
  142. STV090x_SEARCH_AUTO
  143. };
  144. enum stv090x_algo {
  145. STV090x_BLIND_SEARCH,
  146. STV090x_COLD_SEARCH,
  147. STV090x_WARM_SEARCH
  148. };
  149. enum stv090x_delsys {
  150. STV090x_ERROR = 0,
  151. STV090x_DVBS1 = 1,
  152. STV090x_DVBS2,
  153. STV090x_DSS
  154. };
  155. struct stv090x_long_frame_crloop {
  156. enum stv090x_modcod modcod;
  157. u8 crl_pilots_on_2;
  158. u8 crl_pilots_off_2;
  159. u8 crl_pilots_on_5;
  160. u8 crl_pilots_off_5;
  161. u8 crl_pilots_on_10;
  162. u8 crl_pilots_off_10;
  163. u8 crl_pilots_on_20;
  164. u8 crl_pilots_off_20;
  165. u8 crl_pilots_on_30;
  166. u8 crl_pilots_off_30;
  167. };
  168. struct stv090x_short_frame_crloop {
  169. enum stv090x_modulation modulation;
  170. u8 crl_cut12_2; /* Cut 1.2, SR <= 3M */
  171. u8 crl_cut20_2; /* Cut 2.0, SR < 3M */
  172. u8 crl_cut12_5; /* Cut 1.2, 3 < SR <= 7M */
  173. u8 crl_cut20_5; /* Cut 2.0, 3 < SR <= 7M */
  174. u8 crl_cut12_10; /* Cut 1.2, 7 < SR <= 15M */
  175. u8 crl_cut20_10; /* Cut 2.0, 7 < SR <= 15M */
  176. u8 crl_cut12_20; /* Cut 1.2, 10 < SR <= 25M */
  177. u8 crl_cut20_20; /* Cut 2.0, 10 < SR <= 25M */
  178. u8 crl_cut12_30; /* Cut 1.2, 25 < SR <= 45M */
  179. u8 crl_cut20_30; /* Cut 2.0, 10 < SR <= 45M */
  180. };
  181. struct stv090x_short_frame_vsmod_crloop {
  182. enum stv090x_modulation modulation;
  183. u8 crl_2; /* < 3M */
  184. u8 crl_5; /* 3 < SR <= 7M */
  185. u8 crl_10; /* 7 < SR <= 15M */
  186. u8 crl_20; /* 10 < SR <= 25M */
  187. u8 crl_30; /* 10 < SR <= 45M */
  188. };
  189. struct stv090x_reg {
  190. u16 addr;
  191. u8 data;
  192. };
  193. struct stv090x_tab {
  194. s32 real;
  195. s32 read;
  196. };
  197. struct stv090x_state {
  198. enum stv090x_device device;
  199. enum stv090x_demodulator demod;
  200. enum stv090x_mode demod_mode;
  201. u32 dev_ver;
  202. struct i2c_adapter *i2c;
  203. const struct stv090x_config *config;
  204. struct dvb_frontend frontend;
  205. u32 *verbose; /* Cached module verbosity */
  206. enum stv090x_delsys delsys;
  207. enum stv090x_fec fec;
  208. enum stv090x_modulation modulation;
  209. enum stv090x_modcod modcod;
  210. enum stv090x_search search_mode;
  211. enum stv090x_frame frame_len;
  212. enum stv090x_pilot pilots;
  213. enum stv090x_rolloff rolloff;
  214. enum stv090x_inversion inversion;
  215. enum stv090x_algo algo;
  216. u32 frequency;
  217. u32 srate;
  218. s32 mclk; /* Masterclock Divider factor */
  219. s32 tuner_bw;
  220. u32 tuner_refclk;
  221. s32 search_range;
  222. s32 DemodTimeout;
  223. s32 FecTimeout;
  224. };
  225. #endif /* __STV090x_PRIV_H */