18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef DIB8000_H 38c2ecf20Sopenharmony_ci#define DIB8000_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include "dibx000_common.h" 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_cistruct dib8000_config { 88c2ecf20Sopenharmony_ci u8 output_mpeg2_in_188_bytes; 98c2ecf20Sopenharmony_ci u8 hostbus_diversity; 108c2ecf20Sopenharmony_ci u8 tuner_is_baseband; 118c2ecf20Sopenharmony_ci int (*update_lna) (struct dvb_frontend *, u16 agc_global); 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci u8 agc_config_count; 148c2ecf20Sopenharmony_ci struct dibx000_agc_config *agc; 158c2ecf20Sopenharmony_ci struct dibx000_bandwidth_config *pll; 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define DIB8000_GPIO_DEFAULT_DIRECTIONS 0xffff 188c2ecf20Sopenharmony_ci u16 gpio_dir; 198c2ecf20Sopenharmony_ci#define DIB8000_GPIO_DEFAULT_VALUES 0x0000 208c2ecf20Sopenharmony_ci u16 gpio_val; 218c2ecf20Sopenharmony_ci#define DIB8000_GPIO_PWM_POS0(v) ((v & 0xf) << 12) 228c2ecf20Sopenharmony_ci#define DIB8000_GPIO_PWM_POS1(v) ((v & 0xf) << 8 ) 238c2ecf20Sopenharmony_ci#define DIB8000_GPIO_PWM_POS2(v) ((v & 0xf) << 4 ) 248c2ecf20Sopenharmony_ci#define DIB8000_GPIO_PWM_POS3(v) (v & 0xf) 258c2ecf20Sopenharmony_ci#define DIB8000_GPIO_DEFAULT_PWM_POS 0xffff 268c2ecf20Sopenharmony_ci u16 gpio_pwm_pos; 278c2ecf20Sopenharmony_ci u16 pwm_freq_div; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci void (*agc_control) (struct dvb_frontend *, u8 before); 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci u16 drives; 328c2ecf20Sopenharmony_ci u16 diversity_delay; 338c2ecf20Sopenharmony_ci u8 div_cfg; 348c2ecf20Sopenharmony_ci u8 output_mode; 358c2ecf20Sopenharmony_ci u8 refclksel; 368c2ecf20Sopenharmony_ci u8 enMpegOutput:1; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci struct dibx000_bandwidth_config *plltable; 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define DEFAULT_DIB8000_I2C_ADDRESS 18 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cistruct dib8000_ops { 448c2ecf20Sopenharmony_ci int (*set_wbd_ref)(struct dvb_frontend *fe, u16 value); 458c2ecf20Sopenharmony_ci int (*update_pll)(struct dvb_frontend *fe, 468c2ecf20Sopenharmony_ci struct dibx000_bandwidth_config *pll, u32 bw, u8 ratio); 478c2ecf20Sopenharmony_ci int (*set_gpio)(struct dvb_frontend *fe, u8 num, u8 dir, u8 val); 488c2ecf20Sopenharmony_ci void (*pwm_agc_reset)(struct dvb_frontend *fe); 498c2ecf20Sopenharmony_ci struct i2c_adapter *(*get_i2c_tuner)(struct dvb_frontend *fe); 508c2ecf20Sopenharmony_ci int (*tuner_sleep)(struct dvb_frontend *fe, int onoff); 518c2ecf20Sopenharmony_ci s32 (*get_adc_power)(struct dvb_frontend *fe, u8 mode); 528c2ecf20Sopenharmony_ci int (*get_dc_power)(struct dvb_frontend *fe, u8 IQ); 538c2ecf20Sopenharmony_ci u32 (*ctrl_timf)(struct dvb_frontend *fe, uint8_t op, uint32_t timf); 548c2ecf20Sopenharmony_ci enum frontend_tune_state (*get_tune_state)(struct dvb_frontend *fe); 558c2ecf20Sopenharmony_ci int (*set_tune_state)(struct dvb_frontend *fe, enum frontend_tune_state tune_state); 568c2ecf20Sopenharmony_ci int (*set_slave_frontend)(struct dvb_frontend *fe, struct dvb_frontend *fe_slave); 578c2ecf20Sopenharmony_ci struct dvb_frontend *(*get_slave_frontend)(struct dvb_frontend *fe, int slave_index); 588c2ecf20Sopenharmony_ci int (*i2c_enumeration)(struct i2c_adapter *host, int no_of_demods, 598c2ecf20Sopenharmony_ci u8 default_addr, u8 first_addr, u8 is_dib8096p); 608c2ecf20Sopenharmony_ci struct i2c_adapter *(*get_i2c_master)(struct dvb_frontend *fe, enum dibx000_i2c_interface intf, int gating); 618c2ecf20Sopenharmony_ci int (*pid_filter_ctrl)(struct dvb_frontend *fe, u8 onoff); 628c2ecf20Sopenharmony_ci int (*pid_filter)(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff); 638c2ecf20Sopenharmony_ci struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib8000_config *cfg); 648c2ecf20Sopenharmony_ci}; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#if IS_REACHABLE(CONFIG_DVB_DIB8000) 678c2ecf20Sopenharmony_civoid *dib8000_attach(struct dib8000_ops *ops); 688c2ecf20Sopenharmony_ci#else 698c2ecf20Sopenharmony_cistatic inline void *dib8000_attach(struct dib8000_ops *ops) 708c2ecf20Sopenharmony_ci{ 718c2ecf20Sopenharmony_ci printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 728c2ecf20Sopenharmony_ci return NULL; 738c2ecf20Sopenharmony_ci} 748c2ecf20Sopenharmony_ci#endif 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci#endif 77