xref: /linux/drivers/media/dvb-frontends/dib0090.h (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Linux-DVB Driver for DiBcom's DiB0090 base-band RF Tuner.
4  *
5  * Copyright (C) 2005-7 DiBcom (http://www.dibcom.fr/)
6  */
7 #ifndef DIB0090_H
8 #define DIB0090_H
9 
10 struct dvb_frontend;
11 struct i2c_adapter;
12 
13 #define DEFAULT_DIB0090_I2C_ADDRESS 0x60
14 
15 struct dib0090_io_config {
16 	u32 clock_khz;
17 
18 	u8 pll_bypass:1;
19 	u8 pll_range:1;
20 	u8 pll_prediv:6;
21 	u8 pll_loopdiv:6;
22 
23 	u8 adc_clock_ratio;	/* valid is 8, 7 ,6 */
24 	u16 pll_int_loop_filt;
25 };
26 
27 struct dib0090_wbd_slope {
28 	u16 max_freq;		/* for every frequency less than or equal to that field: this information is correct */
29 	u16 slope_cold;
30 	u16 offset_cold;
31 	u16 slope_hot;
32 	u16 offset_hot;
33 	u8 wbd_gain;
34 };
35 
36 struct dib0090_low_if_offset_table {
37 	int std;
38 	u32 RF_freq;
39 	s32 offset_khz;
40 };
41 
42 struct dib0090_config {
43 	struct dib0090_io_config io;
44 	int (*reset) (struct dvb_frontend *, int);
45 	int (*sleep) (struct dvb_frontend *, int);
46 
47 	/*  offset in kHz */
48 	int freq_offset_khz_uhf;
49 	int freq_offset_khz_vhf;
50 
51 	int (*get_adc_power) (struct dvb_frontend *);
52 
53 	u8 clkouttobamse:1;	/* activate or deactivate clock output */
54 	u8 analog_output;
55 
56 	u8 i2c_address;
57 	/* add drives and other things if necessary */
58 	u16 wbd_vhf_offset;
59 	u16 wbd_cband_offset;
60 	u8 use_pwm_agc;
61 	u8 clkoutdrive;
62 
63 	u8 ls_cfg_pad_drv;
64 	u8 data_tx_drv;
65 
66 	u8 in_soc;
67 	const struct dib0090_low_if_offset_table *low_if;
68 	u8 fref_clock_ratio;
69 	u16 force_cband_input;
70 	struct dib0090_wbd_slope *wbd;
71 	u8 is_dib7090e;
72 	u8 force_crystal_mode;
73 };
74 
75 #if IS_REACHABLE(CONFIG_DVB_TUNER_DIB0090)
76 extern struct dvb_frontend *dib0090_register(struct dvb_frontend *fe, struct i2c_adapter *i2c, const struct dib0090_config *config);
77 extern struct dvb_frontend *dib0090_fw_register(struct dvb_frontend *fe, struct i2c_adapter *i2c, const struct dib0090_config *config);
78 extern void dib0090_dcc_freq(struct dvb_frontend *fe, u8 fast);
79 extern void dib0090_pwm_gain_reset(struct dvb_frontend *fe);
80 extern u16 dib0090_get_wbd_target(struct dvb_frontend *tuner);
81 extern u16 dib0090_get_wbd_offset(struct dvb_frontend *fe);
82 extern int dib0090_gain_control(struct dvb_frontend *fe);
83 extern enum frontend_tune_state dib0090_get_tune_state(struct dvb_frontend *fe);
84 extern int dib0090_set_tune_state(struct dvb_frontend *fe, enum frontend_tune_state tune_state);
85 extern void dib0090_get_current_gain(struct dvb_frontend *fe, u16 * rf, u16 * bb, u16 * rf_gain_limit, u16 * rflt);
86 extern void dib0090_set_dc_servo(struct dvb_frontend *fe, u8 DC_servo_cutoff);
87 extern int dib0090_set_switch(struct dvb_frontend *fe, u8 sw1, u8 sw2, u8 sw3);
88 extern int dib0090_set_vga(struct dvb_frontend *fe, u8 onoff);
89 extern int dib0090_update_rframp_7090(struct dvb_frontend *fe,
90 		u8 cfg_sensitivity);
91 extern int dib0090_update_tuning_table_7090(struct dvb_frontend *fe,
92 		u8 cfg_sensitivity);
93 #else
dib0090_register(struct dvb_frontend * fe,struct i2c_adapter * i2c,const struct dib0090_config * config)94 static inline struct dvb_frontend *dib0090_register(struct dvb_frontend *fe, struct i2c_adapter *i2c, const struct dib0090_config *config)
95 {
96 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
97 	return NULL;
98 }
99 
dib0090_fw_register(struct dvb_frontend * fe,struct i2c_adapter * i2c,struct dib0090_config * config)100 static inline struct dvb_frontend *dib0090_fw_register(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dib0090_config *config)
101 {
102 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
103 	return NULL;
104 }
105 
dib0090_dcc_freq(struct dvb_frontend * fe,u8 fast)106 static inline void dib0090_dcc_freq(struct dvb_frontend *fe, u8 fast)
107 {
108 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
109 }
110 
dib0090_pwm_gain_reset(struct dvb_frontend * fe)111 static inline void dib0090_pwm_gain_reset(struct dvb_frontend *fe)
112 {
113 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
114 }
115 
dib0090_get_wbd_target(struct dvb_frontend * tuner)116 static inline u16 dib0090_get_wbd_target(struct dvb_frontend *tuner)
117 {
118 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
119 	return 0;
120 }
121 
dib0090_get_wbd_offset(struct dvb_frontend * fe)122 static inline u16 dib0090_get_wbd_offset(struct dvb_frontend *fe)
123 {
124 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
125 	return 0;
126 }
127 
dib0090_gain_control(struct dvb_frontend * fe)128 static inline int dib0090_gain_control(struct dvb_frontend *fe)
129 {
130 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
131 	return -ENODEV;
132 }
133 
dib0090_get_tune_state(struct dvb_frontend * fe)134 static inline enum frontend_tune_state dib0090_get_tune_state(struct dvb_frontend *fe)
135 {
136 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
137 	return CT_DONE;
138 }
139 
dib0090_set_tune_state(struct dvb_frontend * fe,enum frontend_tune_state tune_state)140 static inline int dib0090_set_tune_state(struct dvb_frontend *fe, enum frontend_tune_state tune_state)
141 {
142 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
143 	return -ENODEV;
144 }
145 
dib0090_get_current_gain(struct dvb_frontend * fe,u16 * rf,u16 * bb,u16 * rf_gain_limit,u16 * rflt)146 static inline void dib0090_get_current_gain(struct dvb_frontend *fe, u16 * rf, u16 * bb, u16 * rf_gain_limit, u16 * rflt)
147 {
148 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
149 }
150 
dib0090_set_dc_servo(struct dvb_frontend * fe,u8 DC_servo_cutoff)151 static inline void dib0090_set_dc_servo(struct dvb_frontend *fe, u8 DC_servo_cutoff)
152 {
153 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
154 }
155 
dib0090_set_switch(struct dvb_frontend * fe,u8 sw1,u8 sw2,u8 sw3)156 static inline int dib0090_set_switch(struct dvb_frontend *fe,
157 		u8 sw1, u8 sw2, u8 sw3)
158 {
159 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
160 	return -ENODEV;
161 }
162 
dib0090_set_vga(struct dvb_frontend * fe,u8 onoff)163 static inline int dib0090_set_vga(struct dvb_frontend *fe, u8 onoff)
164 {
165 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
166 	return -ENODEV;
167 }
168 
dib0090_update_rframp_7090(struct dvb_frontend * fe,u8 cfg_sensitivity)169 static inline int dib0090_update_rframp_7090(struct dvb_frontend *fe,
170 		u8 cfg_sensitivity)
171 {
172 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
173 	return -ENODEV;
174 }
175 
dib0090_update_tuning_table_7090(struct dvb_frontend * fe,u8 cfg_sensitivity)176 static inline int dib0090_update_tuning_table_7090(struct dvb_frontend *fe,
177 		u8 cfg_sensitivity)
178 {
179 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
180 	return -ENODEV;
181 }
182 #endif
183 
184 #endif
185