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