2 * lgh06xf.c - ATSC Tuner support for LG TDVS-H06xF
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #define LG_H06XF_PLL_I2C_ADDR 0x61
25 struct i2c_adapter *i2c;
29 static int lgh06xf_release(struct dvb_frontend *fe)
31 kfree(fe->tuner_priv);
32 fe->tuner_priv = NULL;
36 static int lgh06xf_set_params(struct dvb_frontend* fe,
37 struct dvb_frontend_parameters* params)
39 struct lgh06xf_priv *priv = fe->tuner_priv;
41 struct i2c_msg msg = { .addr = LG_H06XF_PLL_I2C_ADDR, .flags = 0,
42 .buf = buf, .len = sizeof(buf) };
46 if ((result = dvb_pll_configure(&dvb_pll_lg_tdvs_h06xf, buf,
47 params->frequency, 0)) < 0)
52 if (fe->ops.i2c_gate_ctrl)
53 fe->ops.i2c_gate_ctrl(fe, 1);
54 if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) {
55 printk(KERN_WARNING "lgh06xf: %s error "
56 "(addr %02x <- %02x, result = %i)\n",
57 __FUNCTION__, buf[0], buf[1], result);
64 /* Set the Auxiliary Byte. */
70 if (fe->ops.i2c_gate_ctrl)
71 fe->ops.i2c_gate_ctrl(fe, 1);
72 if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) {
73 printk(KERN_WARNING "lgh06xf: %s error "
74 "(addr %02x <- %02x, result = %i)\n",
75 __FUNCTION__, buf[0], buf[1], result);
82 priv->frequency = frequency;
87 static int lgh06xf_get_frequency(struct dvb_frontend *fe, u32 *frequency)
89 struct lgh06xf_priv *priv = fe->tuner_priv;
90 *frequency = priv->frequency;
94 static struct dvb_tuner_ops lgh06xf_tuner_ops = {
95 .release = lgh06xf_release,
96 .set_params = lgh06xf_set_params,
97 .get_frequency = lgh06xf_get_frequency,
100 struct dvb_frontend* lgh06xf_attach(struct dvb_frontend *fe,
101 struct i2c_adapter *i2c)
103 struct lgh06xf_priv *priv = NULL;
105 priv = kzalloc(sizeof(struct lgh06xf_priv), GFP_KERNEL);
111 memcpy(&fe->ops.tuner_ops, &lgh06xf_tuner_ops,
112 sizeof(struct dvb_tuner_ops));
114 strlcpy(fe->ops.tuner_ops.info.name, dvb_pll_lg_tdvs_h06xf.name,
115 sizeof(fe->ops.tuner_ops.info.name));
117 fe->ops.tuner_ops.info.frequency_min = dvb_pll_lg_tdvs_h06xf.min;
118 fe->ops.tuner_ops.info.frequency_max = dvb_pll_lg_tdvs_h06xf.max;
120 fe->tuner_priv = priv;
124 EXPORT_SYMBOL(lgh06xf_attach);
126 MODULE_DESCRIPTION("LG TDVS-H06xF ATSC Tuner support");
127 MODULE_AUTHOR("Michael Krufky");
128 MODULE_LICENSE("GPL");