1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef DIB7000P_H
3*4882a593Smuzhiyun #define DIB7000P_H
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun #include "dibx000_common.h"
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun struct dib7000p_config {
8*4882a593Smuzhiyun u8 output_mpeg2_in_188_bytes;
9*4882a593Smuzhiyun u8 hostbus_diversity;
10*4882a593Smuzhiyun u8 tuner_is_baseband;
11*4882a593Smuzhiyun int (*update_lna) (struct dvb_frontend *, u16 agc_global);
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun u8 agc_config_count;
14*4882a593Smuzhiyun struct dibx000_agc_config *agc;
15*4882a593Smuzhiyun struct dibx000_bandwidth_config *bw;
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun #define DIB7000P_GPIO_DEFAULT_DIRECTIONS 0xffff
18*4882a593Smuzhiyun u16 gpio_dir;
19*4882a593Smuzhiyun #define DIB7000P_GPIO_DEFAULT_VALUES 0x0000
20*4882a593Smuzhiyun u16 gpio_val;
21*4882a593Smuzhiyun #define DIB7000P_GPIO_PWM_POS0(v) ((v & 0xf) << 12)
22*4882a593Smuzhiyun #define DIB7000P_GPIO_PWM_POS1(v) ((v & 0xf) << 8 )
23*4882a593Smuzhiyun #define DIB7000P_GPIO_PWM_POS2(v) ((v & 0xf) << 4 )
24*4882a593Smuzhiyun #define DIB7000P_GPIO_PWM_POS3(v) (v & 0xf)
25*4882a593Smuzhiyun #define DIB7000P_GPIO_DEFAULT_PWM_POS 0xffff
26*4882a593Smuzhiyun u16 gpio_pwm_pos;
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun u16 pwm_freq_div;
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun u8 quartz_direct;
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun u8 spur_protect;
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun int (*agc_control) (struct dvb_frontend *, u8 before);
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun u8 output_mode;
37*4882a593Smuzhiyun u8 disable_sample_and_hold:1;
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun u8 enable_current_mirror:1;
40*4882a593Smuzhiyun u16 diversity_delay;
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun u8 default_i2c_addr;
43*4882a593Smuzhiyun u8 enMpegOutput:1;
44*4882a593Smuzhiyun };
45*4882a593Smuzhiyun
46*4882a593Smuzhiyun #define DEFAULT_DIB7000P_I2C_ADDRESS 18
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun struct dib7000p_ops {
49*4882a593Smuzhiyun int (*set_wbd_ref)(struct dvb_frontend *demod, u16 value);
50*4882a593Smuzhiyun int (*get_agc_values)(struct dvb_frontend *fe,
51*4882a593Smuzhiyun u16 *agc_global, u16 *agc1, u16 *agc2, u16 *wbd);
52*4882a593Smuzhiyun int (*set_agc1_min)(struct dvb_frontend *fe, u16 v);
53*4882a593Smuzhiyun int (*update_pll)(struct dvb_frontend *fe, struct dibx000_bandwidth_config *bw);
54*4882a593Smuzhiyun int (*set_gpio)(struct dvb_frontend *demod, u8 num, u8 dir, u8 val);
55*4882a593Smuzhiyun u32 (*ctrl_timf)(struct dvb_frontend *fe, u8 op, u32 timf);
56*4882a593Smuzhiyun int (*dib7000pc_detection)(struct i2c_adapter *i2c_adap);
57*4882a593Smuzhiyun struct i2c_adapter *(*get_i2c_master)(struct dvb_frontend *demod, enum dibx000_i2c_interface intf, int gating);
58*4882a593Smuzhiyun int (*pid_filter_ctrl)(struct dvb_frontend *fe, u8 onoff);
59*4882a593Smuzhiyun int (*pid_filter)(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff);
60*4882a593Smuzhiyun int (*i2c_enumeration)(struct i2c_adapter *i2c, int no_of_demods, u8 default_addr, struct dib7000p_config cfg[]);
61*4882a593Smuzhiyun struct i2c_adapter *(*get_i2c_tuner)(struct dvb_frontend *fe);
62*4882a593Smuzhiyun int (*tuner_sleep)(struct dvb_frontend *fe, int onoff);
63*4882a593Smuzhiyun int (*get_adc_power)(struct dvb_frontend *fe);
64*4882a593Smuzhiyun int (*slave_reset)(struct dvb_frontend *fe);
65*4882a593Smuzhiyun struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib7000p_config *cfg);
66*4882a593Smuzhiyun };
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun #if IS_REACHABLE(CONFIG_DVB_DIB7000P)
69*4882a593Smuzhiyun void *dib7000p_attach(struct dib7000p_ops *ops);
70*4882a593Smuzhiyun #else
dib7000p_attach(struct dib7000p_ops * ops)71*4882a593Smuzhiyun static inline void *dib7000p_attach(struct dib7000p_ops *ops)
72*4882a593Smuzhiyun {
73*4882a593Smuzhiyun printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
74*4882a593Smuzhiyun return NULL;
75*4882a593Smuzhiyun }
76*4882a593Smuzhiyun #endif
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun #endif
79