0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef __STB0899_DRV_H
0011 #define __STB0899_DRV_H
0012
0013 #include <linux/kernel.h>
0014 #include <linux/module.h>
0015
0016 #include <media/dvb_frontend.h>
0017
0018 #define STB0899_TSMODE_SERIAL 1
0019 #define STB0899_CLKPOL_FALLING 2
0020 #define STB0899_CLKNULL_PARITY 3
0021 #define STB0899_SYNC_FORCED 4
0022 #define STB0899_FECMODE_DSS 5
0023
0024 struct stb0899_s1_reg {
0025 u16 address;
0026 u8 data;
0027 };
0028
0029 struct stb0899_s2_reg {
0030 u16 offset;
0031 u32 base_address;
0032 u32 data;
0033 };
0034
0035 enum stb0899_inversion {
0036 IQ_SWAP_OFF = +1,
0037 IQ_SWAP_ON = -1,
0038 };
0039
0040 #define STB0899_GPIO00 0xf140
0041 #define STB0899_GPIO01 0xf141
0042 #define STB0899_GPIO02 0xf142
0043 #define STB0899_GPIO03 0xf143
0044 #define STB0899_GPIO04 0xf144
0045 #define STB0899_GPIO05 0xf145
0046 #define STB0899_GPIO06 0xf146
0047 #define STB0899_GPIO07 0xf147
0048 #define STB0899_GPIO08 0xf148
0049 #define STB0899_GPIO09 0xf149
0050 #define STB0899_GPIO10 0xf14a
0051 #define STB0899_GPIO11 0xf14b
0052 #define STB0899_GPIO12 0xf14c
0053 #define STB0899_GPIO13 0xf14d
0054 #define STB0899_GPIO14 0xf14e
0055 #define STB0899_GPIO15 0xf14f
0056 #define STB0899_GPIO16 0xf150
0057 #define STB0899_GPIO17 0xf151
0058 #define STB0899_GPIO18 0xf152
0059 #define STB0899_GPIO19 0xf153
0060 #define STB0899_GPIO20 0xf154
0061
0062 #define STB0899_GPIOPULLUP 0x01
0063 #define STB0899_GPIOPULLDN 0x00
0064
0065 #define STB0899_POSTPROC_GPIO_POWER 0x00
0066 #define STB0899_POSTPROC_GPIO_LOCK 0x01
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076 struct stb0899_postproc {
0077 u16 gpio;
0078 u8 level;
0079 };
0080
0081 struct stb0899_config {
0082 const struct stb0899_s1_reg *init_dev;
0083 const struct stb0899_s2_reg *init_s2_demod;
0084 const struct stb0899_s1_reg *init_s1_demod;
0085 const struct stb0899_s2_reg *init_s2_fec;
0086 const struct stb0899_s1_reg *init_tst;
0087
0088 const struct stb0899_postproc *postproc;
0089
0090 enum stb0899_inversion inversion;
0091
0092 u32 xtal_freq;
0093
0094 u8 demod_address;
0095 u8 ts_output_mode;
0096 u8 block_sync_mode;
0097 u8 ts_pfbit_toggle;
0098
0099 u8 clock_polarity;
0100 u8 data_clk_parity;
0101 u8 fec_mode;
0102 u8 data_output_ctl;
0103 u8 data_fifo_mode;
0104 u8 out_rate_comp;
0105 u8 i2c_repeater;
0106
0107 int lo_clk;
0108 int hi_clk;
0109
0110 u32 esno_ave;
0111 u32 esno_quant;
0112 u32 avframes_coarse;
0113 u32 avframes_fine;
0114 u32 miss_threshold;
0115 u32 uwp_threshold_acq;
0116 u32 uwp_threshold_track;
0117 u32 uwp_threshold_sof;
0118 u32 sof_search_timeout;
0119
0120 u32 btr_nco_bits;
0121 u32 btr_gain_shift_offset;
0122 u32 crl_nco_bits;
0123 u32 ldpc_max_iter;
0124
0125 int (*tuner_set_frequency)(struct dvb_frontend *fe, u32 frequency);
0126 int (*tuner_get_frequency)(struct dvb_frontend *fe, u32 *frequency);
0127 int (*tuner_set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
0128 int (*tuner_get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
0129 int (*tuner_set_rfsiggain)(struct dvb_frontend *fe, u32 rf_gain);
0130 };
0131
0132 #if IS_REACHABLE(CONFIG_DVB_STB0899)
0133
0134 extern struct dvb_frontend *stb0899_attach(struct stb0899_config *config,
0135 struct i2c_adapter *i2c);
0136
0137 #else
0138
0139 static inline struct dvb_frontend *stb0899_attach(struct stb0899_config *config,
0140 struct i2c_adapter *i2c)
0141 {
0142 printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
0143 return NULL;
0144 }
0145
0146 #endif
0147
0148
0149 #endif