stv090x.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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_H
  18. #define __STV090x_H
  19. enum stv090x_demodulator {
  20. STV090x_DEMODULATOR_0 = 1,
  21. STV090x_DEMODULATOR_1
  22. };
  23. enum stv090x_device {
  24. STV0903 = 0,
  25. STV0900,
  26. };
  27. enum stv090x_mode {
  28. STV090x_DUAL = 0,
  29. STV090x_SINGLE
  30. };
  31. enum stv090x_tsmode {
  32. STV090x_TSMODE_SERIAL_PUNCTURED = 1,
  33. STV090x_TSMODE_SERIAL_CONTINUOUS,
  34. STV090x_TSMODE_PARALLEL_PUNCTURED,
  35. STV090x_TSMODE_DVBCI
  36. };
  37. enum stv090x_clkmode {
  38. STV090x_CLK_INT = 0, /* Clk i/p = CLKI */
  39. STV090x_CLK_EXT = 2 /* Clk i/p = XTALI */
  40. };
  41. enum stv090x_i2crpt {
  42. STV090x_RPTLEVEL_256 = 0,
  43. STV090x_RPTLEVEL_128 = 1,
  44. STV090x_RPTLEVEL_64 = 2,
  45. STV090x_RPTLEVEL_32 = 3,
  46. STV090x_RPTLEVEL_16 = 4,
  47. STV090x_RPTLEVEL_8 = 5,
  48. STV090x_RPTLEVEL_4 = 6,
  49. STV090x_RPTLEVEL_2 = 7,
  50. };
  51. enum stv090x_adc_range {
  52. STV090x_ADC_2Vpp = 0,
  53. STV090x_ADC_1Vpp = 1
  54. };
  55. struct stv090x_config {
  56. enum stv090x_device device;
  57. enum stv090x_mode demod_mode;
  58. enum stv090x_clkmode clk_mode;
  59. u32 xtal; /* default: 8000000 */
  60. u8 address; /* default: 0x68 */
  61. u8 ts1_mode;
  62. u8 ts2_mode;
  63. u32 ts1_clk;
  64. u32 ts2_clk;
  65. u8 ts1_tei : 1;
  66. u8 ts2_tei : 1;
  67. enum stv090x_i2crpt repeater_level;
  68. u8 tuner_bbgain; /* default: 10db */
  69. enum stv090x_adc_range adc1_range; /* default: 2Vpp */
  70. enum stv090x_adc_range adc2_range; /* default: 2Vpp */
  71. bool diseqc_envelope_mode;
  72. int (*tuner_init)(struct dvb_frontend *fe);
  73. int (*tuner_sleep)(struct dvb_frontend *fe);
  74. int (*tuner_set_mode)(struct dvb_frontend *fe, enum tuner_mode mode);
  75. int (*tuner_set_frequency)(struct dvb_frontend *fe, u32 frequency);
  76. int (*tuner_get_frequency)(struct dvb_frontend *fe, u32 *frequency);
  77. int (*tuner_set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
  78. int (*tuner_get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
  79. int (*tuner_set_bbgain)(struct dvb_frontend *fe, u32 gain);
  80. int (*tuner_get_bbgain)(struct dvb_frontend *fe, u32 *gain);
  81. int (*tuner_set_refclk)(struct dvb_frontend *fe, u32 refclk);
  82. int (*tuner_get_status)(struct dvb_frontend *fe, u32 *status);
  83. void (*tuner_i2c_lock)(struct dvb_frontend *fe, int lock);
  84. /* dir = 0 -> output, dir = 1 -> input/open-drain */
  85. int (*set_gpio)(struct dvb_frontend *fe, u8 gpio, u8 dir, u8 value,
  86. u8 xor_value);
  87. };
  88. #if IS_REACHABLE(CONFIG_DVB_STV090x)
  89. struct dvb_frontend *stv090x_attach(struct stv090x_config *config,
  90. struct i2c_adapter *i2c,
  91. enum stv090x_demodulator demod);
  92. #else
  93. static inline struct dvb_frontend *stv090x_attach(const struct stv090x_config *config,
  94. struct i2c_adapter *i2c,
  95. enum stv090x_demodulator demod)
  96. {
  97. printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
  98. return NULL;
  99. }
  100. #endif /* CONFIG_DVB_STV090x */
  101. #endif /* __STV090x_H */