stv090x.h 2.9 KB

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