V4L/DVB (13787): [Mantis] Fix build
[deliverable/linux.git] / drivers / media / dvb / mantis / mantis_vp1033.c
CommitLineData
41e840b1
MA
1/*
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,
616f75e1 77// .lock_output = STV0229_LOCKOUTPUT_0,
41e840b1
MA
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
df0cca17
MA
84#define MANTIS_MODEL_NAME "VP-1033"
85#define MANTIS_DEV_TYPE "DVB-S/DSS"
86
87struct mantis_hwconfig vp1033_mantis_config = {
88 .model_name = MANTIS_MODEL_NAME,
89 .dev_type = MANTIS_DEV_TYPE,
01a8c3ee 90 .ts_size = MANTIS_TS_204,
df0cca17
MA
91};
92
41e840b1
MA
93int lgtdqcs001f_tuner_set(struct dvb_frontend *fe,
94 struct dvb_frontend_parameters *params)
95{
96 u8 buf[4];
97 u32 div;
98
99 struct mantis_pci *mantis = fe->dvb->priv;
100
101 struct i2c_msg msg = {
102 .addr = 0x61,
103 .flags = 0,
104 .buf = buf,
105 .len = sizeof (buf)
106 };
107 div = params->frequency / 250;
108
109 buf[0] = (div >> 8) & 0x7f;
110 buf[1] = div & 0xff;
111 buf[2] = 0x83;
112 buf[3] = 0xc0;
113
114 if (params->frequency < 1531000)
115 buf[3] |= 0x04;
116 else
117 buf[3] &= ~0x04;
118 if (i2c_transfer(&mantis->adapter, &msg, 1) < 0) {
119 dprintk(verbose, MANTIS_ERROR, 1, "Write: I2C Transfer failed");
120 return -EIO;
121 }
122 msleep_interruptible(100);
123
124 return 0;
125}
126
127int lgtdqcs001f_set_symbol_rate(struct dvb_frontend *fe,
128 u32 srate, u32 ratio)
129{
130 u8 aclk = 0;
131 u8 bclk = 0;
132
133 if (srate < 1500000) {
134 aclk = 0xb7;
135 bclk = 0x47;
136 } else if (srate < 3000000) {
137 aclk = 0xb7;
138 bclk = 0x4b;
139 } else if (srate < 7000000) {
140 aclk = 0xb7;
141 bclk = 0x4f;
142 } else if (srate < 14000000) {
143 aclk = 0xb7;
144 bclk = 0x53;
145 } else if (srate < 30000000) {
146 aclk = 0xb6;
147 bclk = 0x53;
148 } else if (srate < 45000000) {
149 aclk = 0xb4;
150 bclk = 0x51;
151 }
152 stv0299_writereg (fe, 0x13, aclk);
153 stv0299_writereg (fe, 0x14, bclk);
154
155 stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
156 stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff);
157 stv0299_writereg (fe, 0x21, (ratio ) & 0xf0);
158
159 return 0;
160}
This page took 0.037022 seconds and 5 git commands to generate.