blob: e98959769120308b667b193d02095888638a3fde [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
24struct tda10021_state {
25 struct i2c_adapter *i2c;
26 struct dvb_frontend_ops ops;
27 /* configuration settings */
28 const struct tda10021_config *config;
29 struct dvb_frontend frontend;
30
31 u8 pwm;
32 u8 reg0;
33};
34
Manu Abrahamdf0cca12009-12-02 22:07:24 -030035#define MANTIS_MODEL_NAME "VP-2033"
36#define MANTIS_DEV_TYPE "DVB-C"
37
38struct mantis_hwconfig vp2033_mantis_config = {
39 .model_name = MANTIS_MODEL_NAME,
40 .dev_type = MANTIS_DEV_TYPE,
41};
42
Manu Abraham41e840b2009-12-02 21:57:10 -030043struct cu1216_config philips_cu1216_config = {
Manu Abrahamdf0cca12009-12-02 22:07:24 -030044 .demod_address = 0x18 >> 1,
45 .pll_set = philips_cu1216_tuner_set,
Manu Abraham41e840b2009-12-02 21:57:10 -030046// .fe_reset = mantis_fe_reset,
47};
48
49int philips_cu1216_tuner_set(struct dvb_frontend *fe,
50 struct dvb_frontend_parameters *params)
51{
52// struct tda10021_state *state = fe->demodulator_priv;
53 struct mantis_pci *mantis = fe->dvb->priv;
54
55 u8 buf[4];
56
57 struct i2c_msg msg = {
Manu Abrahamdf0cca12009-12-02 22:07:24 -030058 .addr = 0xc0 >> 1,
59 .flags = 0,
60 .buf = buf,
61 .len = sizeof (buf)
Manu Abraham41e840b2009-12-02 21:57:10 -030062 };
63
64#define TUNER_MUL 62500
65
66 u32 div = (params->frequency + 36125000 + TUNER_MUL / 2) / TUNER_MUL;
67
68 buf[0] = (div >> 8) & 0x7f;
69 buf[1] = div & 0xff;
70 buf[2] = 0x86;
71 buf[3] = (params->frequency < 150000000 ? 0xA1 :
72 params->frequency < 445000000 ? 0x92 : 0x34);
73
74// if (i2c_transfer(state->i2c, &msg, 1) < 0) {
75 if (i2c_transfer(&mantis->adapter, &msg, 1) < 0) {
76 printk("%s tuner not ack!\n", __FUNCTION__);
77 return -EIO;
78 }
79 msleep(100);
80 return 0;
81}