0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef __TDA18271_PRIV_H__
0010 #define __TDA18271_PRIV_H__
0011
0012 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
0013
0014 #include <linux/kernel.h>
0015 #include <linux/types.h>
0016 #include <linux/mutex.h>
0017 #include "tuner-i2c.h"
0018 #include "tda18271.h"
0019
0020 #define R_ID 0x00
0021 #define R_TM 0x01
0022 #define R_PL 0x02
0023 #define R_EP1 0x03
0024 #define R_EP2 0x04
0025 #define R_EP3 0x05
0026 #define R_EP4 0x06
0027 #define R_EP5 0x07
0028 #define R_CPD 0x08
0029 #define R_CD1 0x09
0030 #define R_CD2 0x0a
0031 #define R_CD3 0x0b
0032 #define R_MPD 0x0c
0033 #define R_MD1 0x0d
0034 #define R_MD2 0x0e
0035 #define R_MD3 0x0f
0036 #define R_EB1 0x10
0037 #define R_EB2 0x11
0038 #define R_EB3 0x12
0039 #define R_EB4 0x13
0040 #define R_EB5 0x14
0041 #define R_EB6 0x15
0042 #define R_EB7 0x16
0043 #define R_EB8 0x17
0044 #define R_EB9 0x18
0045 #define R_EB10 0x19
0046 #define R_EB11 0x1a
0047 #define R_EB12 0x1b
0048 #define R_EB13 0x1c
0049 #define R_EB14 0x1d
0050 #define R_EB15 0x1e
0051 #define R_EB16 0x1f
0052 #define R_EB17 0x20
0053 #define R_EB18 0x21
0054 #define R_EB19 0x22
0055 #define R_EB20 0x23
0056 #define R_EB21 0x24
0057 #define R_EB22 0x25
0058 #define R_EB23 0x26
0059
0060 #define TDA18271_NUM_REGS 39
0061
0062
0063
0064 struct tda18271_rf_tracking_filter_cal {
0065 u32 rfmax;
0066 u8 rfband;
0067 u32 rf1_def;
0068 u32 rf2_def;
0069 u32 rf3_def;
0070 u32 rf1;
0071 u32 rf2;
0072 u32 rf3;
0073 s32 rf_a1;
0074 s32 rf_b1;
0075 s32 rf_a2;
0076 s32 rf_b2;
0077 };
0078
0079 enum tda18271_pll {
0080 TDA18271_MAIN_PLL,
0081 TDA18271_CAL_PLL,
0082 };
0083
0084 struct tda18271_map_layout;
0085
0086 enum tda18271_ver {
0087 TDA18271HDC1,
0088 TDA18271HDC2,
0089 };
0090
0091 struct tda18271_priv {
0092 unsigned char tda18271_regs[TDA18271_NUM_REGS];
0093
0094 struct list_head hybrid_tuner_instance_list;
0095 struct tuner_i2c_props i2c_props;
0096
0097 enum tda18271_mode mode;
0098 enum tda18271_role role;
0099 enum tda18271_i2c_gate gate;
0100 enum tda18271_ver id;
0101 enum tda18271_output_options output_opt;
0102 enum tda18271_small_i2c small_i2c;
0103
0104 unsigned int config;
0105 unsigned int cal_initialized:1;
0106
0107 u8 tm_rfcal;
0108
0109 struct tda18271_map_layout *maps;
0110 struct tda18271_std_map std;
0111 struct tda18271_rf_tracking_filter_cal rf_cal_state[8];
0112
0113 struct mutex lock;
0114
0115 u16 if_freq;
0116
0117 u32 frequency;
0118 u32 bandwidth;
0119 };
0120
0121
0122
0123 extern int tda18271_debug;
0124
0125 #define DBG_INFO 1
0126 #define DBG_MAP 2
0127 #define DBG_REG 4
0128 #define DBG_ADV 8
0129 #define DBG_CAL 16
0130
0131 __attribute__((format(printf, 4, 5)))
0132 void _tda_printk(struct tda18271_priv *state, const char *level,
0133 const char *func, const char *fmt, ...);
0134
0135 #define tda_printk(st, lvl, fmt, arg...) \
0136 _tda_printk(st, lvl, __func__, fmt, ##arg)
0137
0138 #define tda_dprintk(st, lvl, fmt, arg...) \
0139 do { \
0140 if (tda18271_debug & lvl) \
0141 tda_printk(st, KERN_DEBUG, fmt, ##arg); \
0142 } while (0)
0143
0144 #define tda_info(fmt, arg...) pr_info(fmt, ##arg)
0145 #define tda_warn(fmt, arg...) tda_printk(priv, KERN_WARNING, fmt, ##arg)
0146 #define tda_err(fmt, arg...) tda_printk(priv, KERN_ERR, fmt, ##arg)
0147 #define tda_dbg(fmt, arg...) tda_dprintk(priv, DBG_INFO, fmt, ##arg)
0148 #define tda_map(fmt, arg...) tda_dprintk(priv, DBG_MAP, fmt, ##arg)
0149 #define tda_reg(fmt, arg...) tda_dprintk(priv, DBG_REG, fmt, ##arg)
0150 #define tda_cal(fmt, arg...) tda_dprintk(priv, DBG_CAL, fmt, ##arg)
0151
0152 #define tda_fail(ret) \
0153 ({ \
0154 int __ret; \
0155 __ret = (ret < 0); \
0156 if (__ret) \
0157 tda_printk(priv, KERN_ERR, \
0158 "error %d on line %d\n", ret, __LINE__); \
0159 __ret; \
0160 })
0161
0162
0163
0164 enum tda18271_map_type {
0165
0166 MAIN_PLL,
0167 CAL_PLL,
0168
0169 RF_CAL,
0170 RF_CAL_KMCO,
0171 RF_CAL_DC_OVER_DT,
0172 BP_FILTER,
0173 RF_BAND,
0174 GAIN_TAPER,
0175 IR_MEASURE,
0176 };
0177
0178 extern int tda18271_lookup_pll_map(struct dvb_frontend *fe,
0179 enum tda18271_map_type map_type,
0180 u32 *freq, u8 *post_div, u8 *div);
0181 extern int tda18271_lookup_map(struct dvb_frontend *fe,
0182 enum tda18271_map_type map_type,
0183 u32 *freq, u8 *val);
0184
0185 extern int tda18271_lookup_thermometer(struct dvb_frontend *fe);
0186
0187 extern int tda18271_lookup_rf_band(struct dvb_frontend *fe,
0188 u32 *freq, u8 *rf_band);
0189
0190 extern int tda18271_lookup_cid_target(struct dvb_frontend *fe,
0191 u32 *freq, u8 *cid_target,
0192 u16 *count_limit);
0193
0194 extern int tda18271_assign_map_layout(struct dvb_frontend *fe);
0195
0196
0197
0198 extern int tda18271_read_regs(struct dvb_frontend *fe);
0199 extern int tda18271_read_extended(struct dvb_frontend *fe);
0200 extern int tda18271_write_regs(struct dvb_frontend *fe, int idx, int len);
0201 extern int tda18271_init_regs(struct dvb_frontend *fe);
0202
0203 extern int tda18271_charge_pump_source(struct dvb_frontend *fe,
0204 enum tda18271_pll pll, int force);
0205 extern int tda18271_set_standby_mode(struct dvb_frontend *fe,
0206 int sm, int sm_lt, int sm_xt);
0207
0208 extern int tda18271_calc_main_pll(struct dvb_frontend *fe, u32 freq);
0209 extern int tda18271_calc_cal_pll(struct dvb_frontend *fe, u32 freq);
0210
0211 extern int tda18271_calc_bp_filter(struct dvb_frontend *fe, u32 *freq);
0212 extern int tda18271_calc_km(struct dvb_frontend *fe, u32 *freq);
0213 extern int tda18271_calc_rf_band(struct dvb_frontend *fe, u32 *freq);
0214 extern int tda18271_calc_gain_taper(struct dvb_frontend *fe, u32 *freq);
0215 extern int tda18271_calc_ir_measure(struct dvb_frontend *fe, u32 *freq);
0216 extern int tda18271_calc_rf_cal(struct dvb_frontend *fe, u32 *freq);
0217
0218 #endif