blob: ec502d71b83c6c170a993d0604e705fd96a10338 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001 /*
2 Driver for Philips tda1004xh OFDM Frontend
3
4 (c) 2004 Andrew de Quincey
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 */
22
23#ifndef TDA1004X_H
24#define TDA1004X_H
25
26#include <linux/dvb/frontend.h>
27#include <linux/firmware.h>
28
Hartmut Hackmannecb60de2005-07-07 17:57:40 -070029enum tda10046_xtal {
30 TDA10046_XTAL_4M,
31 TDA10046_XTAL_16M,
32};
33
34enum tda10046_agc {
35 TDA10046_AGC_DEFAULT, /* original configuration */
36 TDA10046_AGC_IFO_AUTO_NEG, /* IF AGC only, automatic, negtive */
Hartmut Hackmannf03cbea2005-07-07 17:57:43 -070037 TDA10046_AGC_IFO_AUTO_POS, /* IF AGC only, automatic, positive */
Hartmut Hackmann550a9a52006-11-15 21:31:54 -030038 TDA10046_AGC_TDA827X_GP11, /* IF AGC only, special setup for tda827x */
39 TDA10046_AGC_TDA827X_GP00, /* same as above, but GPIOs 0 */
40 TDA10046_AGC_TDA827X_GP01, /* same as above, but GPIO3=0 GPIO1=1*/
Hartmut Hackmannecb60de2005-07-07 17:57:40 -070041};
42
43enum tda10046_if {
44 TDA10046_FREQ_3617, /* original config, 36,166 MHZ */
45 TDA10046_FREQ_3613, /* 36,13 MHZ */
Hartmut Hackmannf03cbea2005-07-07 17:57:43 -070046 TDA10046_FREQ_045, /* low IF, 4.0, 4.5, or 5.0 MHZ */
47 TDA10046_FREQ_052, /* low IF, 5.1667 MHZ for tda9889 */
Hartmut Hackmannecb60de2005-07-07 17:57:40 -070048};
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050struct tda1004x_config
51{
52 /* the demodulator's i2c address */
53 u8 demod_address;
54
55 /* does the "inversion" need inverted? */
Johannes Stezenbachdd102c72005-05-16 21:54:35 -070056 u8 invert;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58 /* Does the OCLK signal need inverted? */
Johannes Stezenbachdd102c72005-05-16 21:54:35 -070059 u8 invert_oclk;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Hartmut Hackmannecb60de2005-07-07 17:57:40 -070061 /* Xtal frequency, 4 or 16MHz*/
62 enum tda10046_xtal xtal_freq;
63
64 /* IF frequency */
65 enum tda10046_if if_freq;
66
67 /* AGC configuration */
68 enum tda10046_agc agc_config;
Johannes Stezenbach1dfb8002005-05-16 21:54:35 -070069
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 /* request firmware for device */
Hartmut Hackmannecb60de2005-07-07 17:57:40 -070071 /* set this to NULL if the card has a firmware EEPROM */
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
73};
74
Trent Piephoc5dec9f2006-10-14 15:44:44 -030075#if defined(CONFIG_DVB_TDA1004X) || (defined(CONFIG_DVB_TDA1004X_MODULE) && defined(MODULE))
Linus Torvalds1da177e2005-04-16 15:20:36 -070076extern struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
77 struct i2c_adapter* i2c);
78
79extern struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
80 struct i2c_adapter* i2c);
Andrew de Quincey102a3422006-08-08 09:10:08 -030081#else
82static inline struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
83 struct i2c_adapter* i2c)
84{
85 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
86 return NULL;
87}
88static inline struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
89 struct i2c_adapter* i2c)
90{
91 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
92 return NULL;
93}
94#endif // CONFIG_DVB_TDA1004X
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Andrew de Quinceyc10d14d2006-08-08 09:10:08 -030096static inline int tda1004x_writereg(struct dvb_frontend *fe, u8 reg, u8 val) {
97 int r = 0;
98 u8 buf[] = {reg, val};
99 if (fe->ops.write)
100 r = fe->ops.write(fe, buf, 2);
101 return r;
102}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
104#endif // TDA1004X_H