xref: /linux/drivers/media/dvb-frontends/stv090x.h (revision ebf68996de0ab250c5d520eb2291ab65643e9a1e)
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 
61 	u32 xtal; /* default: 8000000 */
62 	u8 address; /* default: 0x68 */
63 
64 	u8 ts1_mode;
65 	u8 ts2_mode;
66 	u32 ts1_clk;
67 	u32 ts2_clk;
68 
69 	u8 ts1_tei : 1;
70 	u8 ts2_tei : 1;
71 
72 	enum stv090x_i2crpt	repeater_level;
73 
74 	u8			tuner_bbgain; /* default: 10db */
75 	enum stv090x_adc_range	adc1_range; /* default: 2Vpp */
76 	enum stv090x_adc_range	adc2_range; /* default: 2Vpp */
77 
78 	bool diseqc_envelope_mode;
79 
80 	int (*tuner_init)(struct dvb_frontend *fe);
81 	int (*tuner_sleep)(struct dvb_frontend *fe);
82 	int (*tuner_set_mode)(struct dvb_frontend *fe, enum tuner_mode mode);
83 	int (*tuner_set_frequency)(struct dvb_frontend *fe, u32 frequency);
84 	int (*tuner_get_frequency)(struct dvb_frontend *fe, u32 *frequency);
85 	int (*tuner_set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
86 	int (*tuner_get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
87 	int (*tuner_set_bbgain)(struct dvb_frontend *fe, u32 gain);
88 	int (*tuner_get_bbgain)(struct dvb_frontend *fe, u32 *gain);
89 	int (*tuner_set_refclk)(struct dvb_frontend *fe, u32 refclk);
90 	int (*tuner_get_status)(struct dvb_frontend *fe, u32 *status);
91 	void (*tuner_i2c_lock)(struct dvb_frontend *fe, int lock);
92 
93 	/* dir = 0 -> output, dir = 1 -> input/open-drain */
94 	int (*set_gpio)(struct dvb_frontend *fe, u8 gpio, u8 dir, u8 value,
95 			u8 xor_value);
96 };
97 
98 #if IS_REACHABLE(CONFIG_DVB_STV090x)
99 
100 struct dvb_frontend *stv090x_attach(struct stv090x_config *config,
101 				    struct i2c_adapter *i2c,
102 				    enum stv090x_demodulator demod);
103 
104 #else
105 
106 static inline struct dvb_frontend *stv090x_attach(const struct stv090x_config *config,
107 						  struct i2c_adapter *i2c,
108 						  enum stv090x_demodulator demod)
109 {
110 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
111 	return NULL;
112 }
113 
114 #endif /* CONFIG_DVB_STV090x */
115 
116 #endif /* __STV090x_H */
117