blob: 2b9e8732c8024d30fe263bbe7e82ed1fb1f141cb [file] [log] [blame]
Oliver Endriss81ae9532008-09-03 18:16:09 -03001/*
2 * tdhd1.h - ALPS TDHD1-204A tuner support
3 *
4 * Copyright (C) 2008 Oliver Endriss <o.endriss@gmx.de>
5 *
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
21 *
22 *
Mauro Carvalho Chehab991ce922015-12-04 10:38:59 -020023 * The project's page is at https://linuxtv.org
Oliver Endriss81ae9532008-09-03 18:16:09 -030024 */
25
26#ifndef TDHD1_H
27#define TDHD1_H
28
29#include "tda1004x.h"
30
Oliver Endriss83512e22008-09-04 20:35:19 -030031static int alps_tdhd1_204_request_firmware(struct dvb_frontend *fe, const struct firmware **fw, char *name);
32
Oliver Endriss81ae9532008-09-03 18:16:09 -030033static struct tda1004x_config alps_tdhd1_204a_config = {
34 .demod_address = 0x8,
35 .invert = 1,
36 .invert_oclk = 0,
37 .xtal_freq = TDA10046_XTAL_4M,
38 .agc_config = TDA10046_AGC_DEFAULT,
39 .if_freq = TDA10046_FREQ_3617,
Oliver Endriss83512e22008-09-04 20:35:19 -030040 .request_firmware = alps_tdhd1_204_request_firmware
Oliver Endriss81ae9532008-09-03 18:16:09 -030041};
42
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -030043static int alps_tdhd1_204a_tuner_set_params(struct dvb_frontend *fe)
Oliver Endriss81ae9532008-09-03 18:16:09 -030044{
Mauro Carvalho Chehabe7e10de2011-12-23 18:27:35 -030045 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Oliver Endriss81ae9532008-09-03 18:16:09 -030046 struct i2c_adapter *i2c = fe->tuner_priv;
47 u8 data[4];
48 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
49 u32 div;
50
Mauro Carvalho Chehabe7e10de2011-12-23 18:27:35 -030051 div = (p->frequency + 36166666) / 166666;
Oliver Endriss81ae9532008-09-03 18:16:09 -030052
53 data[0] = (div >> 8) & 0x7f;
54 data[1] = div & 0xff;
55 data[2] = 0x85;
56
Mauro Carvalho Chehabe7e10de2011-12-23 18:27:35 -030057 if (p->frequency >= 174000000 && p->frequency <= 230000000)
Oliver Endriss81ae9532008-09-03 18:16:09 -030058 data[3] = 0x02;
Mauro Carvalho Chehabe7e10de2011-12-23 18:27:35 -030059 else if (p->frequency >= 470000000 && p->frequency <= 823000000)
Oliver Endriss81ae9532008-09-03 18:16:09 -030060 data[3] = 0x0C;
Mauro Carvalho Chehabe7e10de2011-12-23 18:27:35 -030061 else if (p->frequency > 823000000 && p->frequency <= 862000000)
Oliver Endriss81ae9532008-09-03 18:16:09 -030062 data[3] = 0x8C;
63 else
64 return -EINVAL;
65
66 if (fe->ops.i2c_gate_ctrl)
67 fe->ops.i2c_gate_ctrl(fe, 1);
68 if (i2c_transfer(i2c, &msg, 1) != 1)
69 return -EIO;
70
71 return 0;
72}
73
74#endif /* TDHD1_H */