0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef TDA1004X_H
0011 #define TDA1004X_H
0012
0013 #include <linux/dvb/frontend.h>
0014 #include <linux/firmware.h>
0015
0016 enum tda10046_xtal {
0017 TDA10046_XTAL_4M,
0018 TDA10046_XTAL_16M,
0019 };
0020
0021 enum tda10046_agc {
0022 TDA10046_AGC_DEFAULT,
0023 TDA10046_AGC_IFO_AUTO_NEG,
0024 TDA10046_AGC_IFO_AUTO_POS,
0025 TDA10046_AGC_TDA827X,
0026 };
0027
0028
0029
0030
0031
0032 enum tda10046_gpio {
0033 TDA10046_GPTRI = 0x00,
0034 TDA10046_GP00 = 0x40,
0035 TDA10046_GP01 = 0x42,
0036 TDA10046_GP10 = 0x48,
0037 TDA10046_GP11 = 0x4a,
0038 TDA10046_GP00_I = 0x80,
0039 TDA10046_GP01_I = 0x82,
0040 TDA10046_GP10_I = 0x88,
0041 TDA10046_GP11_I = 0x8a,
0042 };
0043
0044 enum tda10046_if {
0045 TDA10046_FREQ_3617,
0046 TDA10046_FREQ_3613,
0047 TDA10046_FREQ_045,
0048 TDA10046_FREQ_052,
0049 };
0050
0051 enum tda10046_tsout {
0052 TDA10046_TS_PARALLEL = 0x00,
0053 TDA10046_TS_SERIAL = 0x01,
0054 };
0055
0056 struct tda1004x_config
0057 {
0058
0059 u8 demod_address;
0060
0061
0062 u8 invert;
0063
0064
0065 u8 invert_oclk;
0066
0067
0068 enum tda10046_tsout ts_mode;
0069
0070
0071 enum tda10046_xtal xtal_freq;
0072
0073
0074 enum tda10046_if if_freq;
0075
0076
0077 enum tda10046_agc agc_config;
0078
0079
0080 enum tda10046_gpio gpio_config;
0081
0082
0083 u8 tuner_address;
0084 u8 antenna_switch;
0085
0086
0087 u8 i2c_gate;
0088
0089
0090 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
0091 };
0092
0093 enum tda1004x_demod {
0094 TDA1004X_DEMOD_TDA10045,
0095 TDA1004X_DEMOD_TDA10046,
0096 };
0097
0098 struct tda1004x_state {
0099 struct i2c_adapter* i2c;
0100 const struct tda1004x_config* config;
0101 struct dvb_frontend frontend;
0102
0103
0104 enum tda1004x_demod demod_type;
0105 };
0106
0107 #if IS_REACHABLE(CONFIG_DVB_TDA1004X)
0108 extern struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
0109 struct i2c_adapter* i2c);
0110
0111 extern struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
0112 struct i2c_adapter* i2c);
0113 #else
0114 static inline struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
0115 struct i2c_adapter* i2c)
0116 {
0117 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
0118 return NULL;
0119 }
0120 static inline struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
0121 struct i2c_adapter* i2c)
0122 {
0123 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
0124 return NULL;
0125 }
0126 #endif
0127
0128 static inline int tda1004x_writereg(struct dvb_frontend *fe, u8 reg, u8 val) {
0129 int r = 0;
0130 u8 buf[] = {reg, val};
0131 if (fe->ops.write)
0132 r = fe->ops.write(fe, buf, 2);
0133 return r;
0134 }
0135
0136 #endif