blob: 720f4fb7e925df767cc46471015972289462b346 [file] [log] [blame]
Manu Abraham41e840b2009-12-02 21:57:10 -03001/*
2 Mantis VP-1033 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_vp1033.h"
23
24u8 lgtdqcs001f_inittab[] = {
25 0x01, 0x15,
26 0x02, 0x00,
27 0x03, 0x00,
28 0x04, 0x2a,
29 0x05, 0x85,
30 0x06, 0x02,
31 0x07, 0x00,
32 0x08, 0x00,
33 0x0c, 0x01,
34 0x0d, 0x81,
35 0x0e, 0x44,
36 0x0f, 0x94,
37 0x10, 0x3c,
38 0x11, 0x84,
39 0x12, 0xb9,
40 0x13, 0xb5,
41 0x14, 0x4f,
42 0x15, 0xc9,
43 0x16, 0x80,
44 0x17, 0x36,
45 0x18, 0xfb,
46 0x19, 0xcf,
47 0x1a, 0xbc,
48 0x1c, 0x2b,
49 0x1d, 0x27,
50 0x1e, 0x00,
51 0x1f, 0x0b,
52 0x20, 0xa1,
53 0x21, 0x60,
54 0x22, 0x00,
55 0x23, 0x00,
56 0x28, 0x00,
57 0x29, 0x28,
58 0x2a, 0x14,
59 0x2b, 0x0f,
60 0x2c, 0x09,
61 0x2d, 0x05,
62 0x31, 0x1f,
63 0x32, 0x19,
64 0x33, 0xfc,
65 0x34, 0x13,
66 0xff, 0xff,
67};
68
69struct stv0299_config lgtdqcs001f_config = {
70 .demod_address = 0x68,
71 .inittab = lgtdqcs001f_inittab,
72 .mclk = 88000000UL,
73// .invert = 0,
74 .invert = 1,
75// .enhanced_tuning = 0,
76 .skip_reinit = 0,
77 .lock_output = STV0229_LOCKOUTPUT_0,
78 .volt13_op0_op1 = STV0299_VOLT13_OP0,
79 .min_delay_ms = 100,
80 .set_symbol_rate = lgtdqcs001f_set_symbol_rate,
81// .pll_set = lgtdqcs001f_pll_set,
82};
83
84int lgtdqcs001f_tuner_set(struct dvb_frontend *fe,
85 struct dvb_frontend_parameters *params)
86{
87 u8 buf[4];
88 u32 div;
89
90 struct mantis_pci *mantis = fe->dvb->priv;
91
92 struct i2c_msg msg = {
93 .addr = 0x61,
94 .flags = 0,
95 .buf = buf,
96 .len = sizeof (buf)
97 };
98 div = params->frequency / 250;
99
100 buf[0] = (div >> 8) & 0x7f;
101 buf[1] = div & 0xff;
102 buf[2] = 0x83;
103 buf[3] = 0xc0;
104
105 if (params->frequency < 1531000)
106 buf[3] |= 0x04;
107 else
108 buf[3] &= ~0x04;
109 if (i2c_transfer(&mantis->adapter, &msg, 1) < 0) {
110 dprintk(verbose, MANTIS_ERROR, 1, "Write: I2C Transfer failed");
111 return -EIO;
112 }
113 msleep_interruptible(100);
114
115 return 0;
116}
117
118int lgtdqcs001f_set_symbol_rate(struct dvb_frontend *fe,
119 u32 srate, u32 ratio)
120{
121 u8 aclk = 0;
122 u8 bclk = 0;
123
124 if (srate < 1500000) {
125 aclk = 0xb7;
126 bclk = 0x47;
127 } else if (srate < 3000000) {
128 aclk = 0xb7;
129 bclk = 0x4b;
130 } else if (srate < 7000000) {
131 aclk = 0xb7;
132 bclk = 0x4f;
133 } else if (srate < 14000000) {
134 aclk = 0xb7;
135 bclk = 0x53;
136 } else if (srate < 30000000) {
137 aclk = 0xb6;
138 bclk = 0x53;
139 } else if (srate < 45000000) {
140 aclk = 0xb4;
141 bclk = 0x51;
142 }
143 stv0299_writereg (fe, 0x13, aclk);
144 stv0299_writereg (fe, 0x14, bclk);
145
146 stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
147 stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff);
148 stv0299_writereg (fe, 0x21, (ratio ) & 0xf0);
149
150 return 0;
151}