stb0899_drv.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. STB0899 Multistandard 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 __STB0899_DRV_H
  18. #define __STB0899_DRV_H
  19. #include <linux/kernel.h>
  20. #include <linux/module.h>
  21. #include "dvb_frontend.h"
  22. #define STB0899_TSMODE_SERIAL 1
  23. #define STB0899_CLKPOL_FALLING 2
  24. #define STB0899_CLKNULL_PARITY 3
  25. #define STB0899_SYNC_FORCED 4
  26. #define STB0899_FECMODE_DSS 5
  27. struct stb0899_s1_reg {
  28. u16 address;
  29. u8 data;
  30. };
  31. struct stb0899_s2_reg {
  32. u16 offset;
  33. u32 base_address;
  34. u32 data;
  35. };
  36. enum stb0899_inversion {
  37. IQ_SWAP_OFF = 0,
  38. IQ_SWAP_ON,
  39. IQ_SWAP_AUTO
  40. };
  41. #define STB0899_GPIO00 0xf140
  42. #define STB0899_GPIO01 0xf141
  43. #define STB0899_GPIO02 0xf142
  44. #define STB0899_GPIO03 0xf143
  45. #define STB0899_GPIO04 0xf144
  46. #define STB0899_GPIO05 0xf145
  47. #define STB0899_GPIO06 0xf146
  48. #define STB0899_GPIO07 0xf147
  49. #define STB0899_GPIO08 0xf148
  50. #define STB0899_GPIO09 0xf149
  51. #define STB0899_GPIO10 0xf14a
  52. #define STB0899_GPIO11 0xf14b
  53. #define STB0899_GPIO12 0xf14c
  54. #define STB0899_GPIO13 0xf14d
  55. #define STB0899_GPIO14 0xf14e
  56. #define STB0899_GPIO15 0xf14f
  57. #define STB0899_GPIO16 0xf150
  58. #define STB0899_GPIO17 0xf151
  59. #define STB0899_GPIO18 0xf152
  60. #define STB0899_GPIO19 0xf153
  61. #define STB0899_GPIO20 0xf154
  62. #define STB0899_GPIOPULLUP 0x01 /* Output device is connected to Vdd */
  63. #define STB0899_GPIOPULLDN 0x00 /* Output device is connected to Vss */
  64. #define STB0899_POSTPROC_GPIO_POWER 0x00
  65. #define STB0899_POSTPROC_GPIO_LOCK 0x01
  66. /*
  67. * Post process output configuration control
  68. * 1. POWER ON/OFF (index 0)
  69. * 2. FE_HAS_LOCK/LOCK_LOSS (index 1)
  70. *
  71. * @gpio = one of the above listed GPIO's
  72. * @level = output state: pulled up or low
  73. */
  74. struct stb0899_postproc {
  75. u16 gpio;
  76. u8 level;
  77. };
  78. struct stb0899_config {
  79. const struct stb0899_s1_reg *init_dev;
  80. const struct stb0899_s2_reg *init_s2_demod;
  81. const struct stb0899_s1_reg *init_s1_demod;
  82. const struct stb0899_s2_reg *init_s2_fec;
  83. const struct stb0899_s1_reg *init_tst;
  84. const struct stb0899_postproc *postproc;
  85. enum stb0899_inversion inversion;
  86. u32 xtal_freq;
  87. u8 demod_address;
  88. u8 ts_output_mode;
  89. u8 block_sync_mode;
  90. u8 ts_pfbit_toggle;
  91. u8 clock_polarity;
  92. u8 data_clk_parity;
  93. u8 fec_mode;
  94. u8 data_output_ctl;
  95. u8 data_fifo_mode;
  96. u8 out_rate_comp;
  97. u8 i2c_repeater;
  98. // int inversion;
  99. int lo_clk;
  100. int hi_clk;
  101. u32 esno_ave;
  102. u32 esno_quant;
  103. u32 avframes_coarse;
  104. u32 avframes_fine;
  105. u32 miss_threshold;
  106. u32 uwp_threshold_acq;
  107. u32 uwp_threshold_track;
  108. u32 uwp_threshold_sof;
  109. u32 sof_search_timeout;
  110. u32 btr_nco_bits;
  111. u32 btr_gain_shift_offset;
  112. u32 crl_nco_bits;
  113. u32 ldpc_max_iter;
  114. int (*tuner_set_frequency)(struct dvb_frontend *fe, u32 frequency);
  115. int (*tuner_get_frequency)(struct dvb_frontend *fe, u32 *frequency);
  116. int (*tuner_set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
  117. int (*tuner_get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
  118. int (*tuner_set_rfsiggain)(struct dvb_frontend *fe, u32 rf_gain);
  119. };
  120. #if defined(CONFIG_DVB_STB0899) || (defined(CONFIG_DVB_STB0899_MODULE) && defined(MODULE))
  121. extern struct dvb_frontend *stb0899_attach(struct stb0899_config *config,
  122. struct i2c_adapter *i2c);
  123. #else
  124. static inline struct dvb_frontend *stb0899_attach(struct stb0899_config *config,
  125. struct i2c_adapter *i2c)
  126. {
  127. printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
  128. return NULL;
  129. }
  130. #endif //CONFIG_DVB_STB0899
  131. #endif