blob: 853b558b928e8fb6864484193f1f35ee06ac64c6 [file] [log] [blame]
Manu Abraham41e840b2009-12-02 21:57:10 -03001/*
2 Mantis VP-2033 driver
3
4 Copyright (C) 2005, 2006 Manu Abraham (abraham.manu@gmail.com)
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 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21#include "mantis_common.h"
22#include "mantis_vp2033.h"
23
Manu Abrahamdf0cca12009-12-02 22:07:24 -030024#define MANTIS_MODEL_NAME "VP-2033"
25#define MANTIS_DEV_TYPE "DVB-C"
26
27struct mantis_hwconfig vp2033_mantis_config = {
28 .model_name = MANTIS_MODEL_NAME,
29 .dev_type = MANTIS_DEV_TYPE,
30};
31
Manu Abraham41e840b2009-12-02 21:57:10 -030032struct cu1216_config philips_cu1216_config = {
Manu Abrahamdf0cca12009-12-02 22:07:24 -030033 .demod_address = 0x18 >> 1,
34 .pll_set = philips_cu1216_tuner_set,
Manu Abraham41e840b2009-12-02 21:57:10 -030035// .fe_reset = mantis_fe_reset,
36};
37
38int philips_cu1216_tuner_set(struct dvb_frontend *fe,
39 struct dvb_frontend_parameters *params)
40{
Manu Abraham41e840b2009-12-02 21:57:10 -030041 struct mantis_pci *mantis = fe->dvb->priv;
42
43 u8 buf[4];
44
45 struct i2c_msg msg = {
Manu Abrahamdf0cca12009-12-02 22:07:24 -030046 .addr = 0xc0 >> 1,
47 .flags = 0,
48 .buf = buf,
49 .len = sizeof (buf)
Manu Abraham41e840b2009-12-02 21:57:10 -030050 };
51
52#define TUNER_MUL 62500
53
54 u32 div = (params->frequency + 36125000 + TUNER_MUL / 2) / TUNER_MUL;
55
56 buf[0] = (div >> 8) & 0x7f;
57 buf[1] = div & 0xff;
58 buf[2] = 0x86;
59 buf[3] = (params->frequency < 150000000 ? 0xA1 :
60 params->frequency < 445000000 ? 0x92 : 0x34);
61
Manu Abraham41e840b2009-12-02 21:57:10 -030062 if (i2c_transfer(&mantis->adapter, &msg, 1) < 0) {
63 printk("%s tuner not ack!\n", __FUNCTION__);
64 return -EIO;
65 }
66 msleep(100);
Manu Abrahamda7365f2009-12-02 22:11:00 -030067
Manu Abraham41e840b2009-12-02 21:57:10 -030068 return 0;
69}