Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002   /*
0003      Driver for Philips tda1004xh OFDM Frontend
0004 
0005      (c) 2004 Andrew de Quincey
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,       /* original configuration */
0023     TDA10046_AGC_IFO_AUTO_NEG,  /* IF AGC only, automatic, negative */
0024     TDA10046_AGC_IFO_AUTO_POS,  /* IF AGC only, automatic, positive */
0025     TDA10046_AGC_TDA827X,       /* IF AGC only, special setup for tda827x */
0026 };
0027 
0028 /* Many (hybrid) boards use GPIO 1 and 3
0029     GPIO1   analog - dvb switch
0030     GPIO3   firmware eeprom address switch
0031 */
0032 enum tda10046_gpio {
0033     TDA10046_GPTRI  = 0x00,     /* All GPIOs tristate */
0034     TDA10046_GP00   = 0x40,     /* GPIO3=0, GPIO1=0 */
0035     TDA10046_GP01   = 0x42,     /* GPIO3=0, GPIO1=1 */
0036     TDA10046_GP10   = 0x48,     /* GPIO3=1, GPIO1=0 */
0037     TDA10046_GP11   = 0x4a,     /* GPIO3=1, GPIO1=1 */
0038     TDA10046_GP00_I = 0x80,     /* GPIO3=0, GPIO1=0, invert in sleep mode*/
0039     TDA10046_GP01_I = 0x82,     /* GPIO3=0, GPIO1=1, invert in sleep mode */
0040     TDA10046_GP10_I = 0x88,     /* GPIO3=1, GPIO1=0, invert in sleep mode */
0041     TDA10046_GP11_I = 0x8a,     /* GPIO3=1, GPIO1=1, invert in sleep mode */
0042 };
0043 
0044 enum tda10046_if {
0045     TDA10046_FREQ_3617,     /* original config, 36,166 MHZ */
0046     TDA10046_FREQ_3613,     /* 36,13 MHZ */
0047     TDA10046_FREQ_045,      /* low IF, 4.0, 4.5, or 5.0 MHZ */
0048     TDA10046_FREQ_052,      /* low IF, 5.1667 MHZ for tda9889 */
0049 };
0050 
0051 enum tda10046_tsout {
0052     TDA10046_TS_PARALLEL  = 0x00,   /* parallel transport stream, default */
0053     TDA10046_TS_SERIAL    = 0x01,   /* serial transport stream */
0054 };
0055 
0056 struct tda1004x_config
0057 {
0058     /* the demodulator's i2c address */
0059     u8 demod_address;
0060 
0061     /* does the "inversion" need inverted? */
0062     u8 invert;
0063 
0064     /* Does the OCLK signal need inverted? */
0065     u8 invert_oclk;
0066 
0067     /* parallel or serial transport stream */
0068     enum tda10046_tsout ts_mode;
0069 
0070     /* Xtal frequency, 4 or 16MHz*/
0071     enum tda10046_xtal xtal_freq;
0072 
0073     /* IF frequency */
0074     enum tda10046_if if_freq;
0075 
0076     /* AGC configuration */
0077     enum tda10046_agc agc_config;
0078 
0079     /* setting of GPIO1 and 3 */
0080     enum tda10046_gpio gpio_config;
0081 
0082     /* slave address and configuration of the tuner */
0083     u8 tuner_address;
0084     u8 antenna_switch;
0085 
0086     /* if the board uses another I2c Bridge (tda8290), its address */
0087     u8 i2c_gate;
0088 
0089     /* request firmware for device */
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     /* private demod data */
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 // CONFIG_DVB_TDA1004X
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 // TDA1004X_H