4 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
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.
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.
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.
21 #include <linux/signal.h>
22 #include <linux/sched.h>
23 #include <linux/interrupt.h>
27 #include "dvb_demux.h"
28 #include "dvb_frontend.h"
32 #include "mantis_common.h"
33 #include "mantis_ioc.h"
34 #include "mantis_dvb.h"
35 #include "mantis_vp2040.h"
37 #define MANTIS_MODEL_NAME "VP-2040"
38 #define MANTIS_DEV_TYPE "DVB-C"
40 struct tda1002x_config vp2040_tda1002x_cu1216_config
= {
41 .demod_address
= 0x18 >> 1,
45 struct tda10023_config vp2040_tda10023_cu1216_config
= {
46 .demod_address
= 0x18 >> 1,
50 static int tda1002x_cu1216_tuner_set(struct dvb_frontend
*fe
, struct dvb_frontend_parameters
*params
)
52 struct mantis_pci
*mantis
= fe
->dvb
->priv
;
53 struct i2c_adapter
*adapter
= &mantis
->adapter
;
56 struct i2c_msg msg
= {.addr
= 0x60, .flags
= 0, .buf
= buf
, .len
= sizeof(buf
)};
59 #define CU1216_IF 36125000
60 #define TUNER_MUL 62500
62 u32 div
= (params
->frequency
+ CU1216_IF
+ TUNER_MUL
/ 2) / TUNER_MUL
;
64 buf
[0] = (div
>> 8) & 0x7f;
67 buf
[3] = (params
->frequency
< 150000000 ? 0x01 :
68 params
->frequency
< 445000000 ? 0x02 : 0x04);
72 if (fe
->ops
.i2c_gate_ctrl
)
73 fe
->ops
.i2c_gate_ctrl(fe
, 1);
75 if (i2c_transfer(adapter
, &msg
, 1) != 1)
78 /* wait for the pll lock */
81 for (i
= 0; i
< 20; i
++) {
82 if (fe
->ops
.i2c_gate_ctrl
)
83 fe
->ops
.i2c_gate_ctrl(fe
, 1);
85 if (i2c_transfer(adapter
, &msg
, 1) == 1 && (buf
[0] & 0x40))
91 /* switch the charge pump to the lower current */
96 if (fe
->ops
.i2c_gate_ctrl
)
97 fe
->ops
.i2c_gate_ctrl(fe
, 1);
99 if (i2c_transfer(adapter
, &msg
, 1) != 1)
105 static u8
read_pwm(struct mantis_pci
*mantis
)
107 struct i2c_adapter
*adapter
= &mantis
->adapter
;
111 struct i2c_msg msg
[] = {
112 {.addr
= 0x50, .flags
= 0, .buf
= &b
, .len
= 1},
113 {.addr
= 0x50, .flags
= I2C_M_RD
, .buf
= &pwm
, .len
= 1}
116 if ((i2c_transfer(adapter
, msg
, 2) != 2)
123 static int vp2040_frontend_init(struct mantis_pci
*mantis
, struct dvb_frontend
*fe
)
125 struct i2c_adapter
*adapter
= &mantis
->adapter
;
129 err
= mantis_frontend_power(mantis
, POWER_ON
);
131 mantis_frontend_soft_reset(mantis
);
134 dprintk(MANTIS_ERROR
, 1, "Probing for CU1216 (DVB-C)");
135 fe
= dvb_attach(tda10021_attach
, &vp2040_tda1002x_cu1216_config
,
140 dprintk(MANTIS_ERROR
, 1,
141 "found Philips CU1216 DVB-C frontend (TDA10021) @ 0x%02x",
142 vp2040_tda1002x_cu1216_config
.demod_address
);
144 fe
= dvb_attach(tda10023_attach
, &vp2040_tda10023_cu1216_config
,
149 dprintk(MANTIS_ERROR
, 1,
150 "found Philips CU1216 DVB-C frontend (TDA10023) @ 0x%02x",
151 vp2040_tda1002x_cu1216_config
.demod_address
);
156 fe
->ops
.tuner_ops
.set_params
= tda1002x_cu1216_tuner_set
;
157 dprintk(MANTIS_ERROR
, 1, "Mantis DVB-C Philips CU1216 frontend attach success");
162 dprintk(MANTIS_ERROR
, 1, "Frontend on <%s> POWER ON failed! <%d>",
169 dprintk(MANTIS_DEBUG
, 1, "Done!");
174 struct mantis_hwconfig vp2040_config
= {
175 .model_name
= MANTIS_MODEL_NAME
,
176 .dev_type
= MANTIS_DEV_TYPE
,
177 .ts_size
= MANTIS_TS_204
,
179 .baud_rate
= MANTIS_BAUD_9600
,
180 .parity
= MANTIS_PARITY_NONE
,
183 .frontend_init
= vp2040_frontend_init
,