stb0899_drv.h 4.1 KB

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