diff options
author | Antti Palosaari <crope@iki.fi> | 2012-09-01 20:09:21 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-09-18 11:24:59 -0400 |
commit | ed85adaad624724a157a292b2e970f7a0f595269 (patch) | |
tree | 44c249587d71ec010ec49cd3d2dade149a01e99d | |
parent | ed7dd240075fabf38e489930e39eab2dfa836520 (diff) |
[media] Elonics E4000 silicon tuner driver
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/tuners/Kconfig | 7 | ||||
-rw-r--r-- | drivers/media/tuners/Makefile | 1 | ||||
-rw-r--r-- | drivers/media/tuners/e4000.c | 408 | ||||
-rw-r--r-- | drivers/media/tuners/e4000.h | 52 | ||||
-rw-r--r-- | drivers/media/tuners/e4000_priv.h | 147 |
5 files changed, 615 insertions, 0 deletions
diff --git a/drivers/media/tuners/Kconfig b/drivers/media/tuners/Kconfig index 80238b9063b0..f9e299c3900f 100644 --- a/drivers/media/tuners/Kconfig +++ b/drivers/media/tuners/Kconfig | |||
@@ -222,6 +222,13 @@ config MEDIA_TUNER_TDA18212 | |||
222 | help | 222 | help |
223 | NXP TDA18212 silicon tuner driver. | 223 | NXP TDA18212 silicon tuner driver. |
224 | 224 | ||
225 | config MEDIA_TUNER_E4000 | ||
226 | tristate "Elonics E4000 silicon tuner" | ||
227 | depends on MEDIA_SUPPORT && I2C | ||
228 | default m if !MEDIA_SUBDRV_AUTOSELECT | ||
229 | help | ||
230 | Elonics E4000 silicon tuner driver. | ||
231 | |||
225 | config MEDIA_TUNER_TUA9001 | 232 | config MEDIA_TUNER_TUA9001 |
226 | tristate "Infineon TUA 9001 silicon tuner" | 233 | tristate "Infineon TUA 9001 silicon tuner" |
227 | depends on MEDIA_SUPPORT && I2C | 234 | depends on MEDIA_SUPPORT && I2C |
diff --git a/drivers/media/tuners/Makefile b/drivers/media/tuners/Makefile index 112aeee90202..9f7b2c2aa83f 100644 --- a/drivers/media/tuners/Makefile +++ b/drivers/media/tuners/Makefile | |||
@@ -28,6 +28,7 @@ obj-$(CONFIG_MEDIA_TUNER_MC44S803) += mc44s803.o | |||
28 | obj-$(CONFIG_MEDIA_TUNER_MAX2165) += max2165.o | 28 | obj-$(CONFIG_MEDIA_TUNER_MAX2165) += max2165.o |
29 | obj-$(CONFIG_MEDIA_TUNER_TDA18218) += tda18218.o | 29 | obj-$(CONFIG_MEDIA_TUNER_TDA18218) += tda18218.o |
30 | obj-$(CONFIG_MEDIA_TUNER_TDA18212) += tda18212.o | 30 | obj-$(CONFIG_MEDIA_TUNER_TDA18212) += tda18212.o |
31 | obj-$(CONFIG_MEDIA_TUNER_E4000) += e4000.o | ||
31 | obj-$(CONFIG_MEDIA_TUNER_TUA9001) += tua9001.o | 32 | obj-$(CONFIG_MEDIA_TUNER_TUA9001) += tua9001.o |
32 | obj-$(CONFIG_MEDIA_TUNER_FC0011) += fc0011.o | 33 | obj-$(CONFIG_MEDIA_TUNER_FC0011) += fc0011.o |
33 | obj-$(CONFIG_MEDIA_TUNER_FC0012) += fc0012.o | 34 | obj-$(CONFIG_MEDIA_TUNER_FC0012) += fc0012.o |
diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c new file mode 100644 index 000000000000..ffaa4824d6af --- /dev/null +++ b/drivers/media/tuners/e4000.c | |||
@@ -0,0 +1,408 @@ | |||
1 | /* | ||
2 | * Elonics E4000 silicon tuner driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Antti Palosaari <crope@iki.fi> | ||
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 along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #include "e4000_priv.h" | ||
22 | |||
23 | /* write multiple registers */ | ||
24 | static int e4000_wr_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len) | ||
25 | { | ||
26 | int ret; | ||
27 | u8 buf[1 + len]; | ||
28 | struct i2c_msg msg[1] = { | ||
29 | { | ||
30 | .addr = priv->cfg->i2c_addr, | ||
31 | .flags = 0, | ||
32 | .len = sizeof(buf), | ||
33 | .buf = buf, | ||
34 | } | ||
35 | }; | ||
36 | |||
37 | buf[0] = reg; | ||
38 | memcpy(&buf[1], val, len); | ||
39 | |||
40 | ret = i2c_transfer(priv->i2c, msg, 1); | ||
41 | if (ret == 1) { | ||
42 | ret = 0; | ||
43 | } else { | ||
44 | dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d reg=%02x " \ | ||
45 | "len=%d\n", KBUILD_MODNAME, ret, reg, len); | ||
46 | ret = -EREMOTEIO; | ||
47 | } | ||
48 | return ret; | ||
49 | } | ||
50 | |||
51 | /* read multiple registers */ | ||
52 | static int e4000_rd_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len) | ||
53 | { | ||
54 | int ret; | ||
55 | u8 buf[len]; | ||
56 | struct i2c_msg msg[2] = { | ||
57 | { | ||
58 | .addr = priv->cfg->i2c_addr, | ||
59 | .flags = 0, | ||
60 | .len = 1, | ||
61 | .buf = ®, | ||
62 | }, { | ||
63 | .addr = priv->cfg->i2c_addr, | ||
64 | .flags = I2C_M_RD, | ||
65 | .len = sizeof(buf), | ||
66 | .buf = buf, | ||
67 | } | ||
68 | }; | ||
69 | |||
70 | ret = i2c_transfer(priv->i2c, msg, 2); | ||
71 | if (ret == 2) { | ||
72 | memcpy(val, buf, len); | ||
73 | ret = 0; | ||
74 | } else { | ||
75 | dev_warn(&priv->i2c->dev, "%s: i2c rd failed=%d reg=%02x " \ | ||
76 | "len=%d\n", KBUILD_MODNAME, ret, reg, len); | ||
77 | ret = -EREMOTEIO; | ||
78 | } | ||
79 | |||
80 | return ret; | ||
81 | } | ||
82 | |||
83 | /* write single register */ | ||
84 | static int e4000_wr_reg(struct e4000_priv *priv, u8 reg, u8 val) | ||
85 | { | ||
86 | return e4000_wr_regs(priv, reg, &val, 1); | ||
87 | } | ||
88 | |||
89 | /* read single register */ | ||
90 | static int e4000_rd_reg(struct e4000_priv *priv, u8 reg, u8 *val) | ||
91 | { | ||
92 | return e4000_rd_regs(priv, reg, val, 1); | ||
93 | } | ||
94 | |||
95 | static int e4000_init(struct dvb_frontend *fe) | ||
96 | { | ||
97 | struct e4000_priv *priv = fe->tuner_priv; | ||
98 | int ret; | ||
99 | |||
100 | dev_dbg(&priv->i2c->dev, "%s:\n", __func__); | ||
101 | |||
102 | if (fe->ops.i2c_gate_ctrl) | ||
103 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
104 | |||
105 | /* dummy I2C to ensure I2C wakes up */ | ||
106 | ret = e4000_wr_reg(priv, 0x02, 0x40); | ||
107 | |||
108 | /* reset */ | ||
109 | ret = e4000_wr_reg(priv, 0x00, 0x01); | ||
110 | if (ret < 0) | ||
111 | goto err; | ||
112 | |||
113 | /* disable output clock */ | ||
114 | ret = e4000_wr_reg(priv, 0x06, 0x00); | ||
115 | if (ret < 0) | ||
116 | goto err; | ||
117 | |||
118 | ret = e4000_wr_reg(priv, 0x7a, 0x96); | ||
119 | if (ret < 0) | ||
120 | goto err; | ||
121 | |||
122 | /* configure gains */ | ||
123 | ret = e4000_wr_regs(priv, 0x7e, "\x01\xfe", 2); | ||
124 | if (ret < 0) | ||
125 | goto err; | ||
126 | |||
127 | ret = e4000_wr_reg(priv, 0x82, 0x00); | ||
128 | if (ret < 0) | ||
129 | goto err; | ||
130 | |||
131 | ret = e4000_wr_reg(priv, 0x24, 0x05); | ||
132 | if (ret < 0) | ||
133 | goto err; | ||
134 | |||
135 | ret = e4000_wr_regs(priv, 0x87, "\x20\x01", 2); | ||
136 | if (ret < 0) | ||
137 | goto err; | ||
138 | |||
139 | ret = e4000_wr_regs(priv, 0x9f, "\x7f\x07", 2); | ||
140 | if (ret < 0) | ||
141 | goto err; | ||
142 | |||
143 | /* | ||
144 | * TODO: Implement DC offset control correctly. | ||
145 | * DC offsets has quite much effect for received signal quality in case | ||
146 | * of direct conversion tuners (Zero-IF). Surely we will now lose few | ||
147 | * decimals or even decibels from SNR... | ||
148 | */ | ||
149 | /* DC offset control */ | ||
150 | ret = e4000_wr_reg(priv, 0x2d, 0x0c); | ||
151 | if (ret < 0) | ||
152 | goto err; | ||
153 | |||
154 | /* gain control */ | ||
155 | ret = e4000_wr_reg(priv, 0x1a, 0x17); | ||
156 | if (ret < 0) | ||
157 | goto err; | ||
158 | |||
159 | ret = e4000_wr_reg(priv, 0x1f, 0x1a); | ||
160 | if (ret < 0) | ||
161 | goto err; | ||
162 | |||
163 | if (fe->ops.i2c_gate_ctrl) | ||
164 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
165 | |||
166 | return 0; | ||
167 | err: | ||
168 | if (fe->ops.i2c_gate_ctrl) | ||
169 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
170 | |||
171 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); | ||
172 | return ret; | ||
173 | } | ||
174 | |||
175 | static int e4000_sleep(struct dvb_frontend *fe) | ||
176 | { | ||
177 | struct e4000_priv *priv = fe->tuner_priv; | ||
178 | int ret; | ||
179 | |||
180 | dev_dbg(&priv->i2c->dev, "%s:\n", __func__); | ||
181 | |||
182 | if (fe->ops.i2c_gate_ctrl) | ||
183 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
184 | |||
185 | ret = e4000_wr_reg(priv, 0x00, 0x00); | ||
186 | if (ret < 0) | ||
187 | goto err; | ||
188 | |||
189 | if (fe->ops.i2c_gate_ctrl) | ||
190 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
191 | |||
192 | return 0; | ||
193 | err: | ||
194 | if (fe->ops.i2c_gate_ctrl) | ||
195 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
196 | |||
197 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); | ||
198 | return ret; | ||
199 | } | ||
200 | |||
201 | static int e4000_set_params(struct dvb_frontend *fe) | ||
202 | { | ||
203 | struct e4000_priv *priv = fe->tuner_priv; | ||
204 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
205 | int ret, i, sigma_delta; | ||
206 | unsigned int f_VCO; | ||
207 | u8 buf[5]; | ||
208 | |||
209 | dev_dbg(&priv->i2c->dev, "%s: delivery_system=%d frequency=%d " \ | ||
210 | "bandwidth_hz=%d\n", __func__, | ||
211 | c->delivery_system, c->frequency, c->bandwidth_hz); | ||
212 | |||
213 | if (fe->ops.i2c_gate_ctrl) | ||
214 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
215 | |||
216 | /* gain control manual */ | ||
217 | ret = e4000_wr_reg(priv, 0x1a, 0x00); | ||
218 | if (ret < 0) | ||
219 | goto err; | ||
220 | |||
221 | /* PLL */ | ||
222 | for (i = 0; i < ARRAY_SIZE(e4000_pll_lut); i++) { | ||
223 | if (c->frequency <= e4000_pll_lut[i].freq) | ||
224 | break; | ||
225 | } | ||
226 | |||
227 | if (i == ARRAY_SIZE(e4000_pll_lut)) | ||
228 | goto err; | ||
229 | |||
230 | /* | ||
231 | * Note: Currently f_VCO overflows when c->frequency is 1 073 741 824 Hz | ||
232 | * or more. | ||
233 | */ | ||
234 | f_VCO = c->frequency * e4000_pll_lut[i].mul; | ||
235 | sigma_delta = 0x10000UL * (f_VCO % priv->cfg->clock) / priv->cfg->clock; | ||
236 | buf[0] = f_VCO / priv->cfg->clock; | ||
237 | buf[1] = (sigma_delta >> 0) & 0xff; | ||
238 | buf[2] = (sigma_delta >> 8) & 0xff; | ||
239 | buf[3] = 0x00; | ||
240 | buf[4] = e4000_pll_lut[i].div; | ||
241 | |||
242 | dev_dbg(&priv->i2c->dev, "%s: f_VCO=%u pll div=%d sigma_delta=%04x\n", | ||
243 | __func__, f_VCO, buf[0], sigma_delta); | ||
244 | |||
245 | ret = e4000_wr_regs(priv, 0x09, buf, 5); | ||
246 | if (ret < 0) | ||
247 | goto err; | ||
248 | |||
249 | /* LNA filter (RF filter) */ | ||
250 | for (i = 0; i < ARRAY_SIZE(e400_lna_filter_lut); i++) { | ||
251 | if (c->frequency <= e400_lna_filter_lut[i].freq) | ||
252 | break; | ||
253 | } | ||
254 | |||
255 | if (i == ARRAY_SIZE(e400_lna_filter_lut)) | ||
256 | goto err; | ||
257 | |||
258 | ret = e4000_wr_reg(priv, 0x10, e400_lna_filter_lut[i].val); | ||
259 | if (ret < 0) | ||
260 | goto err; | ||
261 | |||
262 | /* IF filters */ | ||
263 | for (i = 0; i < ARRAY_SIZE(e4000_if_filter_lut); i++) { | ||
264 | if (c->bandwidth_hz <= e4000_if_filter_lut[i].freq) | ||
265 | break; | ||
266 | } | ||
267 | |||
268 | if (i == ARRAY_SIZE(e4000_if_filter_lut)) | ||
269 | goto err; | ||
270 | |||
271 | buf[0] = e4000_if_filter_lut[i].reg11_val; | ||
272 | buf[1] = e4000_if_filter_lut[i].reg12_val; | ||
273 | |||
274 | ret = e4000_wr_regs(priv, 0x11, buf, 2); | ||
275 | if (ret < 0) | ||
276 | goto err; | ||
277 | |||
278 | /* frequency band */ | ||
279 | for (i = 0; i < ARRAY_SIZE(e4000_band_lut); i++) { | ||
280 | if (c->frequency <= e4000_band_lut[i].freq) | ||
281 | break; | ||
282 | } | ||
283 | |||
284 | if (i == ARRAY_SIZE(e4000_band_lut)) | ||
285 | goto err; | ||
286 | |||
287 | ret = e4000_wr_reg(priv, 0x07, e4000_band_lut[i].reg07_val); | ||
288 | if (ret < 0) | ||
289 | goto err; | ||
290 | |||
291 | ret = e4000_wr_reg(priv, 0x78, e4000_band_lut[i].reg78_val); | ||
292 | if (ret < 0) | ||
293 | goto err; | ||
294 | |||
295 | /* gain control auto */ | ||
296 | ret = e4000_wr_reg(priv, 0x1a, 0x17); | ||
297 | if (ret < 0) | ||
298 | goto err; | ||
299 | |||
300 | if (fe->ops.i2c_gate_ctrl) | ||
301 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
302 | |||
303 | return 0; | ||
304 | err: | ||
305 | if (fe->ops.i2c_gate_ctrl) | ||
306 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
307 | |||
308 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); | ||
309 | return ret; | ||
310 | } | ||
311 | |||
312 | static int e4000_get_if_frequency(struct dvb_frontend *fe, u32 *frequency) | ||
313 | { | ||
314 | struct e4000_priv *priv = fe->tuner_priv; | ||
315 | |||
316 | dev_dbg(&priv->i2c->dev, "%s:\n", __func__); | ||
317 | |||
318 | *frequency = 0; /* Zero-IF */ | ||
319 | |||
320 | return 0; | ||
321 | } | ||
322 | |||
323 | static int e4000_release(struct dvb_frontend *fe) | ||
324 | { | ||
325 | struct e4000_priv *priv = fe->tuner_priv; | ||
326 | |||
327 | dev_dbg(&priv->i2c->dev, "%s:\n", __func__); | ||
328 | |||
329 | kfree(fe->tuner_priv); | ||
330 | |||
331 | return 0; | ||
332 | } | ||
333 | |||
334 | static const struct dvb_tuner_ops e4000_tuner_ops = { | ||
335 | .info = { | ||
336 | .name = "Elonics E4000", | ||
337 | .frequency_min = 174000000, | ||
338 | .frequency_max = 862000000, | ||
339 | }, | ||
340 | |||
341 | .release = e4000_release, | ||
342 | |||
343 | .init = e4000_init, | ||
344 | .sleep = e4000_sleep, | ||
345 | .set_params = e4000_set_params, | ||
346 | |||
347 | .get_if_frequency = e4000_get_if_frequency, | ||
348 | }; | ||
349 | |||
350 | struct dvb_frontend *e4000_attach(struct dvb_frontend *fe, | ||
351 | struct i2c_adapter *i2c, const struct e4000_config *cfg) | ||
352 | { | ||
353 | struct e4000_priv *priv; | ||
354 | int ret; | ||
355 | u8 chip_id; | ||
356 | |||
357 | if (fe->ops.i2c_gate_ctrl) | ||
358 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
359 | |||
360 | priv = kzalloc(sizeof(struct e4000_priv), GFP_KERNEL); | ||
361 | if (!priv) { | ||
362 | ret = -ENOMEM; | ||
363 | dev_err(&i2c->dev, "%s: kzalloc() failed\n", KBUILD_MODNAME); | ||
364 | goto err; | ||
365 | } | ||
366 | |||
367 | priv->cfg = cfg; | ||
368 | priv->i2c = i2c; | ||
369 | fe->tuner_priv = priv; | ||
370 | memcpy(&fe->ops.tuner_ops, &e4000_tuner_ops, | ||
371 | sizeof(struct dvb_tuner_ops)); | ||
372 | |||
373 | /* check if the tuner is there */ | ||
374 | ret = e4000_rd_reg(priv, 0x02, &chip_id); | ||
375 | if (ret < 0) | ||
376 | goto err; | ||
377 | |||
378 | dev_dbg(&priv->i2c->dev, "%s: chip_id=%02x\n", __func__, chip_id); | ||
379 | |||
380 | if (chip_id != 0x40) | ||
381 | goto err; | ||
382 | |||
383 | /* put sleep as chip seems to be in normal mode by default */ | ||
384 | ret = e4000_wr_reg(priv, 0x00, 0x00); | ||
385 | if (ret < 0) | ||
386 | goto err; | ||
387 | |||
388 | dev_info(&priv->i2c->dev, | ||
389 | "%s: Elonics E4000 successfully identified\n", | ||
390 | KBUILD_MODNAME); | ||
391 | |||
392 | if (fe->ops.i2c_gate_ctrl) | ||
393 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
394 | |||
395 | return fe; | ||
396 | err: | ||
397 | if (fe->ops.i2c_gate_ctrl) | ||
398 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
399 | |||
400 | dev_dbg(&i2c->dev, "%s: failed=%d\n", __func__, ret); | ||
401 | kfree(priv); | ||
402 | return NULL; | ||
403 | } | ||
404 | EXPORT_SYMBOL(e4000_attach); | ||
405 | |||
406 | MODULE_DESCRIPTION("Elonics E4000 silicon tuner driver"); | ||
407 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); | ||
408 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/tuners/e4000.h b/drivers/media/tuners/e4000.h new file mode 100644 index 000000000000..71b1935eb3d2 --- /dev/null +++ b/drivers/media/tuners/e4000.h | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * Elonics E4000 silicon tuner driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Antti Palosaari <crope@iki.fi> | ||
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 along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef E4000_H | ||
22 | #define E4000_H | ||
23 | |||
24 | #include "dvb_frontend.h" | ||
25 | |||
26 | struct e4000_config { | ||
27 | /* | ||
28 | * I2C address | ||
29 | * 0x64, 0x65, 0x66, 0x67 | ||
30 | */ | ||
31 | u8 i2c_addr; | ||
32 | |||
33 | /* | ||
34 | * clock | ||
35 | */ | ||
36 | u32 clock; | ||
37 | }; | ||
38 | |||
39 | #if defined(CONFIG_MEDIA_TUNER_E4000) || \ | ||
40 | (defined(CONFIG_MEDIA_TUNER_E4000_MODULE) && defined(MODULE)) | ||
41 | extern struct dvb_frontend *e4000_attach(struct dvb_frontend *fe, | ||
42 | struct i2c_adapter *i2c, const struct e4000_config *cfg); | ||
43 | #else | ||
44 | static inline struct dvb_frontend *e4000_attach(struct dvb_frontend *fe, | ||
45 | struct i2c_adapter *i2c, const struct e4000_config *cfg) | ||
46 | { | ||
47 | pr_warn("%s: driver disabled by Kconfig\n", __func__); | ||
48 | return NULL; | ||
49 | } | ||
50 | #endif | ||
51 | |||
52 | #endif | ||
diff --git a/drivers/media/tuners/e4000_priv.h b/drivers/media/tuners/e4000_priv.h new file mode 100644 index 000000000000..a3855053e78f --- /dev/null +++ b/drivers/media/tuners/e4000_priv.h | |||
@@ -0,0 +1,147 @@ | |||
1 | /* | ||
2 | * Elonics E4000 silicon tuner driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Antti Palosaari <crope@iki.fi> | ||
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 along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef E4000_PRIV_H | ||
22 | #define E4000_PRIV_H | ||
23 | |||
24 | #include "e4000.h" | ||
25 | |||
26 | struct e4000_priv { | ||
27 | const struct e4000_config *cfg; | ||
28 | struct i2c_adapter *i2c; | ||
29 | }; | ||
30 | |||
31 | struct e4000_pll { | ||
32 | u32 freq; | ||
33 | u8 div; | ||
34 | u8 mul; | ||
35 | }; | ||
36 | |||
37 | static const struct e4000_pll e4000_pll_lut[] = { | ||
38 | /* VCO min VCO max */ | ||
39 | { 72400000, 0x0f, 48 }, /* .......... 3475200000 */ | ||
40 | { 81200000, 0x0e, 40 }, /* 2896000000 3248000000 */ | ||
41 | { 108300000, 0x0d, 32 }, /* 2598400000 3465600000 */ | ||
42 | { 162500000, 0x0c, 24 }, /* 2599200000 3900000000 */ | ||
43 | { 216600000, 0x0b, 16 }, /* 2600000000 3465600000 */ | ||
44 | { 325000000, 0x0a, 12 }, /* 2599200000 3900000000 */ | ||
45 | { 350000000, 0x09, 8 }, /* 2600000000 2800000000 */ | ||
46 | { 432000000, 0x03, 8 }, /* 2800000000 3456000000 */ | ||
47 | { 667000000, 0x02, 6 }, /* 2592000000 4002000000 */ | ||
48 | { 1200000000, 0x01, 4 }, /* 2668000000 4800000000 */ | ||
49 | { 0xffffffff, 0x00, 2 }, /* 2400000000 .......... */ | ||
50 | }; | ||
51 | |||
52 | struct e4000_lna_filter { | ||
53 | u32 freq; | ||
54 | u8 val; | ||
55 | }; | ||
56 | |||
57 | static const struct e4000_lna_filter e400_lna_filter_lut[] = { | ||
58 | { 370000000, 0 }, | ||
59 | { 392500000, 1 }, | ||
60 | { 415000000, 2 }, | ||
61 | { 437500000, 3 }, | ||
62 | { 462500000, 4 }, | ||
63 | { 490000000, 5 }, | ||
64 | { 522500000, 6 }, | ||
65 | { 557500000, 7 }, | ||
66 | { 595000000, 8 }, | ||
67 | { 642500000, 9 }, | ||
68 | { 695000000, 10 }, | ||
69 | { 740000000, 11 }, | ||
70 | { 800000000, 12 }, | ||
71 | { 865000000, 13 }, | ||
72 | { 930000000, 14 }, | ||
73 | { 1000000000, 15 }, | ||
74 | { 1310000000, 0 }, | ||
75 | { 1340000000, 1 }, | ||
76 | { 1385000000, 2 }, | ||
77 | { 1427500000, 3 }, | ||
78 | { 1452500000, 4 }, | ||
79 | { 1475000000, 5 }, | ||
80 | { 1510000000, 6 }, | ||
81 | { 1545000000, 7 }, | ||
82 | { 1575000000, 8 }, | ||
83 | { 1615000000, 9 }, | ||
84 | { 1650000000, 10 }, | ||
85 | { 1670000000, 11 }, | ||
86 | { 1690000000, 12 }, | ||
87 | { 1710000000, 13 }, | ||
88 | { 1735000000, 14 }, | ||
89 | { 0xffffffff, 15 }, | ||
90 | }; | ||
91 | |||
92 | struct e4000_band { | ||
93 | u32 freq; | ||
94 | u8 reg07_val; | ||
95 | u8 reg78_val; | ||
96 | }; | ||
97 | |||
98 | static const struct e4000_band e4000_band_lut[] = { | ||
99 | { 140000000, 0x01, 0x03 }, | ||
100 | { 350000000, 0x03, 0x03 }, | ||
101 | { 1000000000, 0x05, 0x03 }, | ||
102 | { 0xffffffff, 0x07, 0x00 }, | ||
103 | }; | ||
104 | |||
105 | struct e4000_if_filter { | ||
106 | u32 freq; | ||
107 | u8 reg11_val; | ||
108 | u8 reg12_val; | ||
109 | }; | ||
110 | |||
111 | static const struct e4000_if_filter e4000_if_filter_lut[] = { | ||
112 | { 4300000, 0xfd, 0x1f }, | ||
113 | { 4400000, 0xfd, 0x1e }, | ||
114 | { 4480000, 0xfc, 0x1d }, | ||
115 | { 4560000, 0xfc, 0x1c }, | ||
116 | { 4600000, 0xfc, 0x1b }, | ||
117 | { 4800000, 0xfc, 0x1a }, | ||
118 | { 4900000, 0xfc, 0x19 }, | ||
119 | { 5000000, 0xfc, 0x18 }, | ||
120 | { 5100000, 0xfc, 0x17 }, | ||
121 | { 5200000, 0xfc, 0x16 }, | ||
122 | { 5400000, 0xfc, 0x15 }, | ||
123 | { 5500000, 0xfc, 0x14 }, | ||
124 | { 5600000, 0xfc, 0x13 }, | ||
125 | { 5800000, 0xfb, 0x12 }, | ||
126 | { 5900000, 0xfb, 0x11 }, | ||
127 | { 6000000, 0xfb, 0x10 }, | ||
128 | { 6200000, 0xfb, 0x0f }, | ||
129 | { 6400000, 0xfa, 0x0e }, | ||
130 | { 6600000, 0xfa, 0x0d }, | ||
131 | { 6800000, 0xf9, 0x0c }, | ||
132 | { 7200000, 0xf9, 0x0b }, | ||
133 | { 7400000, 0xf9, 0x0a }, | ||
134 | { 7600000, 0xf8, 0x09 }, | ||
135 | { 7800000, 0xf8, 0x08 }, | ||
136 | { 8200000, 0xf8, 0x07 }, | ||
137 | { 8600000, 0xf7, 0x06 }, | ||
138 | { 8800000, 0xf7, 0x05 }, | ||
139 | { 9200000, 0xf7, 0x04 }, | ||
140 | { 9600000, 0xf6, 0x03 }, | ||
141 | { 10000000, 0xf6, 0x02 }, | ||
142 | { 10600000, 0xf5, 0x01 }, | ||
143 | { 11000000, 0xf5, 0x00 }, | ||
144 | { 0xffffffff, 0x00, 0x20 }, | ||
145 | }; | ||
146 | |||
147 | #endif | ||