1 /*
2 STB6100 Silicon Tuner
3 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
4
5 Copyright (C) ST Microelectronics
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include <linux/init.h>
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/slab.h>
26 #include <linux/string.h>
27
28 #include "dvb_frontend.h"
29 #include "stb6100.h"
30
31 static unsigned int verbose;
32 module_param(verbose, int, 0644);
33
34 /* Max transfer size done by I2C transfer functions */
35 #define MAX_XFER_SIZE 64
36
37 #define FE_ERROR 0
38 #define FE_NOTICE 1
39 #define FE_INFO 2
40 #define FE_DEBUG 3
41
42 #define dprintk(x, y, z, format, arg...) do { \
43 if (z) { \
44 if ((x > FE_ERROR) && (x > y)) \
45 printk(KERN_ERR "%s: " format "\n", __func__ , ##arg); \
46 else if ((x > FE_NOTICE) && (x > y)) \
47 printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg); \
48 else if ((x > FE_INFO) && (x > y)) \
49 printk(KERN_INFO "%s: " format "\n", __func__ , ##arg); \
50 else if ((x > FE_DEBUG) && (x > y)) \
51 printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg); \
52 } else { \
53 if (x > y) \
54 printk(format, ##arg); \
55 } \
56 } while (0)
57
58 struct stb6100_lkup {
59 u32 val_low;
60 u32 val_high;
61 u8 reg;
62 };
63
64 static int stb6100_release(struct dvb_frontend *fe);
65
66 static const struct stb6100_lkup lkup[] = {
67 { 0, 950000, 0x0a },
68 { 950000, 1000000, 0x0a },
69 { 1000000, 1075000, 0x0c },
70 { 1075000, 1200000, 0x00 },
71 { 1200000, 1300000, 0x01 },
72 { 1300000, 1370000, 0x02 },
73 { 1370000, 1470000, 0x04 },
74 { 1470000, 1530000, 0x05 },
75 { 1530000, 1650000, 0x06 },
76 { 1650000, 1800000, 0x08 },
77 { 1800000, 1950000, 0x0a },
78 { 1950000, 2150000, 0x0c },
79 { 2150000, 9999999, 0x0c },
80 { 0, 0, 0x00 }
81 };
82
83 /* Register names for easy debugging. */
84 static const char *stb6100_regnames[] = {
85 [STB6100_LD] = "LD",
86 [STB6100_VCO] = "VCO",
87 [STB6100_NI] = "NI",
88 [STB6100_NF_LSB] = "NF",
89 [STB6100_K] = "K",
90 [STB6100_G] = "G",
91 [STB6100_F] = "F",
92 [STB6100_DLB] = "DLB",
93 [STB6100_TEST1] = "TEST1",
94 [STB6100_FCCK] = "FCCK",
95 [STB6100_LPEN] = "LPEN",
96 [STB6100_TEST3] = "TEST3",
97 };
98
99 /* Template for normalisation, i.e. setting unused or undocumented
100 * bits as required according to the documentation.
101 */
102 struct stb6100_regmask {
103 u8 mask;
104 u8 set;
105 };
106
107 static const struct stb6100_regmask stb6100_template[] = {
108 [STB6100_LD] = { 0xff, 0x00 },
109 [STB6100_VCO] = { 0xff, 0x00 },
110 [STB6100_NI] = { 0xff, 0x00 },
111 [STB6100_NF_LSB] = { 0xff, 0x00 },
112 [STB6100_K] = { 0xc7, 0x38 },
113 [STB6100_G] = { 0xef, 0x10 },
114 [STB6100_F] = { 0x1f, 0xc0 },
115 [STB6100_DLB] = { 0x38, 0xc4 },
116 [STB6100_TEST1] = { 0x00, 0x8f },
117 [STB6100_FCCK] = { 0x40, 0x0d },
118 [STB6100_LPEN] = { 0xf0, 0x0b },
119 [STB6100_TEST3] = { 0x00, 0xde },
120 };
121
122 /*
123 * Currently unused. Some boards might need it in the future
124 */
stb6100_normalise_regs(u8 regs[])125 static inline void stb6100_normalise_regs(u8 regs[])
126 {
127 int i;
128
129 for (i = 0; i < STB6100_NUMREGS; i++)
130 regs[i] = (regs[i] & stb6100_template[i].mask) | stb6100_template[i].set;
131 }
132
stb6100_read_regs(struct stb6100_state * state,u8 regs[])133 static int stb6100_read_regs(struct stb6100_state *state, u8 regs[])
134 {
135 int rc;
136 struct i2c_msg msg = {
137 .addr = state->config->tuner_address,
138 .flags = I2C_M_RD,
139 .buf = regs,
140 .len = STB6100_NUMREGS
141 };
142
143 rc = i2c_transfer(state->i2c, &msg, 1);
144 if (unlikely(rc != 1)) {
145 dprintk(verbose, FE_ERROR, 1, "Read (0x%x) err, rc=[%d]",
146 state->config->tuner_address, rc);
147
148 return -EREMOTEIO;
149 }
150 if (unlikely(verbose > FE_DEBUG)) {
151 int i;
152
153 dprintk(verbose, FE_DEBUG, 1, " Read from 0x%02x", state->config->tuner_address);
154 for (i = 0; i < STB6100_NUMREGS; i++)
155 dprintk(verbose, FE_DEBUG, 1, " %s: 0x%02x", stb6100_regnames[i], regs[i]);
156 }
157 return 0;
158 }
159
stb6100_read_reg(struct stb6100_state * state,u8 reg)160 static int stb6100_read_reg(struct stb6100_state *state, u8 reg)
161 {
162 u8 regs[STB6100_NUMREGS];
163
164 struct i2c_msg msg = {
165 .addr = state->config->tuner_address + reg,
166 .flags = I2C_M_RD,
167 .buf = regs,
168 .len = 1
169 };
170
171 i2c_transfer(state->i2c, &msg, 1);
172
173 if (unlikely(reg >= STB6100_NUMREGS)) {
174 dprintk(verbose, FE_ERROR, 1, "Invalid register offset 0x%x", reg);
175 return -EINVAL;
176 }
177 if (unlikely(verbose > FE_DEBUG)) {
178 dprintk(verbose, FE_DEBUG, 1, " Read from 0x%02x", state->config->tuner_address);
179 dprintk(verbose, FE_DEBUG, 1, " %s: 0x%02x", stb6100_regnames[reg], regs[0]);
180 }
181
182 return (unsigned int)regs[0];
183 }
184
stb6100_write_reg_range(struct stb6100_state * state,u8 buf[],int start,int len)185 static int stb6100_write_reg_range(struct stb6100_state *state, u8 buf[], int start, int len)
186 {
187 int rc;
188 u8 cmdbuf[MAX_XFER_SIZE];
189 struct i2c_msg msg = {
190 .addr = state->config->tuner_address,
191 .flags = 0,
192 .buf = cmdbuf,
193 .len = len + 1
194 };
195
196 if (1 + len > sizeof(cmdbuf)) {
197 printk(KERN_WARNING
198 "%s: i2c wr: len=%d is too big!\n",
199 KBUILD_MODNAME, len);
200 return -EINVAL;
201 }
202
203 if (unlikely(start < 1 || start + len > STB6100_NUMREGS)) {
204 dprintk(verbose, FE_ERROR, 1, "Invalid register range %d:%d",
205 start, len);
206 return -EINVAL;
207 }
208 memcpy(&cmdbuf[1], buf, len);
209 cmdbuf[0] = start;
210
211 if (unlikely(verbose > FE_DEBUG)) {
212 int i;
213
214 dprintk(verbose, FE_DEBUG, 1, " Write @ 0x%02x: [%d:%d]", state->config->tuner_address, start, len);
215 for (i = 0; i < len; i++)
216 dprintk(verbose, FE_DEBUG, 1, " %s: 0x%02x", stb6100_regnames[start + i], buf[i]);
217 }
218 rc = i2c_transfer(state->i2c, &msg, 1);
219 if (unlikely(rc != 1)) {
220 dprintk(verbose, FE_ERROR, 1, "(0x%x) write err [%d:%d], rc=[%d]",
221 (unsigned int)state->config->tuner_address, start, len, rc);
222 return -EREMOTEIO;
223 }
224 return 0;
225 }
226
stb6100_write_reg(struct stb6100_state * state,u8 reg,u8 data)227 static int stb6100_write_reg(struct stb6100_state *state, u8 reg, u8 data)
228 {
229 u8 tmp = data; /* see gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 */
230
231 if (unlikely(reg >= STB6100_NUMREGS)) {
232 dprintk(verbose, FE_ERROR, 1, "Invalid register offset 0x%x", reg);
233 return -EREMOTEIO;
234 }
235 tmp = (tmp & stb6100_template[reg].mask) | stb6100_template[reg].set;
236 return stb6100_write_reg_range(state, &tmp, reg, 1);
237 }
238
239
stb6100_get_status(struct dvb_frontend * fe,u32 * status)240 static int stb6100_get_status(struct dvb_frontend *fe, u32 *status)
241 {
242 int rc;
243 struct stb6100_state *state = fe->tuner_priv;
244
245 rc = stb6100_read_reg(state, STB6100_LD);
246 if (rc < 0) {
247 dprintk(verbose, FE_ERROR, 1, "%s failed", __func__);
248 return rc;
249 }
250 return (rc & STB6100_LD_LOCK) ? TUNER_STATUS_LOCKED : 0;
251 }
252
stb6100_get_bandwidth(struct dvb_frontend * fe,u32 * bandwidth)253 static int stb6100_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
254 {
255 int rc;
256 u8 f;
257 struct stb6100_state *state = fe->tuner_priv;
258
259 rc = stb6100_read_reg(state, STB6100_F);
260 if (rc < 0)
261 return rc;
262 f = rc & STB6100_F_F;
263
264 state->status.bandwidth = (f + 5) * 2000; /* x2 for ZIF */
265
266 *bandwidth = state->bandwidth = state->status.bandwidth * 1000;
267 dprintk(verbose, FE_DEBUG, 1, "bandwidth = %u Hz", state->bandwidth);
268 return 0;
269 }
270
stb6100_set_bandwidth(struct dvb_frontend * fe,u32 bandwidth)271 static int stb6100_set_bandwidth(struct dvb_frontend *fe, u32 bandwidth)
272 {
273 u32 tmp;
274 int rc;
275 struct stb6100_state *state = fe->tuner_priv;
276
277 dprintk(verbose, FE_DEBUG, 1, "set bandwidth to %u Hz", bandwidth);
278
279 bandwidth /= 2; /* ZIF */
280
281 if (bandwidth >= 36000000) /* F[4:0] BW/2 max =31+5=36 mhz for F=31 */
282 tmp = 31;
283 else if (bandwidth <= 5000000) /* bw/2 min = 5Mhz for F=0 */
284 tmp = 0;
285 else /* if 5 < bw/2 < 36 */
286 tmp = (bandwidth + 500000) / 1000000 - 5;
287
288 /* Turn on LPF bandwidth setting clock control,
289 * set bandwidth, wait 10ms, turn off.
290 */
291 rc = stb6100_write_reg(state, STB6100_FCCK, 0x0d | STB6100_FCCK_FCCK);
292 if (rc < 0)
293 return rc;
294 rc = stb6100_write_reg(state, STB6100_F, 0xc0 | tmp);
295 if (rc < 0)
296 return rc;
297
298 msleep(5); /* This is dangerous as another (related) thread may start */
299
300 rc = stb6100_write_reg(state, STB6100_FCCK, 0x0d);
301 if (rc < 0)
302 return rc;
303
304 msleep(10); /* This is dangerous as another (related) thread may start */
305
306 return 0;
307 }
308
stb6100_get_frequency(struct dvb_frontend * fe,u32 * frequency)309 static int stb6100_get_frequency(struct dvb_frontend *fe, u32 *frequency)
310 {
311 int rc;
312 u32 nint, nfrac, fvco;
313 int psd2, odiv;
314 struct stb6100_state *state = fe->tuner_priv;
315 u8 regs[STB6100_NUMREGS];
316
317 rc = stb6100_read_regs(state, regs);
318 if (rc < 0)
319 return rc;
320
321 odiv = (regs[STB6100_VCO] & STB6100_VCO_ODIV) >> STB6100_VCO_ODIV_SHIFT;
322 psd2 = (regs[STB6100_K] & STB6100_K_PSD2) >> STB6100_K_PSD2_SHIFT;
323 nint = regs[STB6100_NI];
324 nfrac = ((regs[STB6100_K] & STB6100_K_NF_MSB) << 8) | regs[STB6100_NF_LSB];
325 fvco = (nfrac * state->reference >> (9 - psd2)) + (nint * state->reference << psd2);
326 *frequency = state->frequency = fvco >> (odiv + 1);
327
328 dprintk(verbose, FE_DEBUG, 1,
329 "frequency = %u kHz, odiv = %u, psd2 = %u, fxtal = %u kHz, fvco = %u kHz, N(I) = %u, N(F) = %u",
330 state->frequency, odiv, psd2, state->reference, fvco, nint, nfrac);
331 return 0;
332 }
333
334
stb6100_set_frequency(struct dvb_frontend * fe,u32 frequency)335 static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency)
336 {
337 int rc;
338 const struct stb6100_lkup *ptr;
339 struct stb6100_state *state = fe->tuner_priv;
340 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
341
342 u32 srate = 0, fvco, nint, nfrac;
343 u8 regs[STB6100_NUMREGS];
344 u8 g, psd2, odiv;
345
346 dprintk(verbose, FE_DEBUG, 1, "Version 2010-8-14 13:51");
347
348 if (fe->ops.get_frontend) {
349 dprintk(verbose, FE_DEBUG, 1, "Get frontend parameters");
350 fe->ops.get_frontend(fe);
351 }
352 srate = p->symbol_rate;
353
354 /* Set up tuner cleanly, LPF calibration on */
355 rc = stb6100_write_reg(state, STB6100_FCCK, 0x4d | STB6100_FCCK_FCCK);
356 if (rc < 0)
357 return rc; /* allow LPF calibration */
358
359 /* PLL Loop disabled, bias on, VCO on, synth on */
360 regs[STB6100_LPEN] = 0xeb;
361 rc = stb6100_write_reg(state, STB6100_LPEN, regs[STB6100_LPEN]);
362 if (rc < 0)
363 return rc;
364
365 /* Program the registers with their data values */
366
367 /* VCO divide ratio (LO divide ratio, VCO prescaler enable). */
368 if (frequency <= 1075000)
369 odiv = 1;
370 else
371 odiv = 0;
372
373 /* VCO enabled, search clock off as per LL3.7, 3.4.1 */
374 regs[STB6100_VCO] = 0xe0 | (odiv << STB6100_VCO_ODIV_SHIFT);
375
376 /* OSM */
377 for (ptr = lkup;
378 (ptr->val_high != 0) && !CHKRANGE(frequency, ptr->val_low, ptr->val_high);
379 ptr++);
380
381 if (ptr->val_high == 0) {
382 printk(KERN_ERR "%s: frequency out of range: %u kHz\n", __func__, frequency);
383 return -EINVAL;
384 }
385 regs[STB6100_VCO] = (regs[STB6100_VCO] & ~STB6100_VCO_OSM) | ptr->reg;
386 rc = stb6100_write_reg(state, STB6100_VCO, regs[STB6100_VCO]);
387 if (rc < 0)
388 return rc;
389
390 if ((frequency > 1075000) && (frequency <= 1325000))
391 psd2 = 0;
392 else
393 psd2 = 1;
394 /* F(VCO) = F(LO) * (ODIV == 0 ? 2 : 4) */
395 fvco = frequency << (1 + odiv);
396 /* N(I) = floor(f(VCO) / (f(XTAL) * (PSD2 ? 2 : 1))) */
397 nint = fvco / (state->reference << psd2);
398 /* N(F) = round(f(VCO) / f(XTAL) * (PSD2 ? 2 : 1) - N(I)) * 2 ^ 9 */
399 nfrac = DIV_ROUND_CLOSEST((fvco - (nint * state->reference << psd2))
400 << (9 - psd2), state->reference);
401
402 /* NI */
403 regs[STB6100_NI] = nint;
404 rc = stb6100_write_reg(state, STB6100_NI, regs[STB6100_NI]);
405 if (rc < 0)
406 return rc;
407
408 /* NF */
409 regs[STB6100_NF_LSB] = nfrac;
410 rc = stb6100_write_reg(state, STB6100_NF_LSB, regs[STB6100_NF_LSB]);
411 if (rc < 0)
412 return rc;
413
414 /* K */
415 regs[STB6100_K] = (0x38 & ~STB6100_K_PSD2) | (psd2 << STB6100_K_PSD2_SHIFT);
416 regs[STB6100_K] = (regs[STB6100_K] & ~STB6100_K_NF_MSB) | ((nfrac >> 8) & STB6100_K_NF_MSB);
417 rc = stb6100_write_reg(state, STB6100_K, regs[STB6100_K]);
418 if (rc < 0)
419 return rc;
420
421 /* G Baseband gain. */
422 if (srate >= 15000000)
423 g = 9; /* +4 dB */
424 else if (srate >= 5000000)
425 g = 11; /* +8 dB */
426 else
427 g = 14; /* +14 dB */
428
429 regs[STB6100_G] = (0x10 & ~STB6100_G_G) | g;
430 regs[STB6100_G] &= ~STB6100_G_GCT; /* mask GCT */
431 regs[STB6100_G] |= (1 << 5); /* 2Vp-p Mode */
432 rc = stb6100_write_reg(state, STB6100_G, regs[STB6100_G]);
433 if (rc < 0)
434 return rc;
435
436 /* F we don't write as it is set up in BW set */
437
438 /* DLB set DC servo loop BW to 160Hz (LLA 3.8 / 2.1) */
439 regs[STB6100_DLB] = 0xcc;
440 rc = stb6100_write_reg(state, STB6100_DLB, regs[STB6100_DLB]);
441 if (rc < 0)
442 return rc;
443
444 dprintk(verbose, FE_DEBUG, 1,
445 "frequency = %u, srate = %u, g = %u, odiv = %u, psd2 = %u, fxtal = %u, osm = %u, fvco = %u, N(I) = %u, N(F) = %u",
446 frequency, srate, (unsigned int)g, (unsigned int)odiv,
447 (unsigned int)psd2, state->reference,
448 ptr->reg, fvco, nint, nfrac);
449
450 /* Set up the test registers */
451 regs[STB6100_TEST1] = 0x8f;
452 rc = stb6100_write_reg(state, STB6100_TEST1, regs[STB6100_TEST1]);
453 if (rc < 0)
454 return rc;
455 regs[STB6100_TEST3] = 0xde;
456 rc = stb6100_write_reg(state, STB6100_TEST3, regs[STB6100_TEST3]);
457 if (rc < 0)
458 return rc;
459
460 /* Bring up tuner according to LLA 3.7 3.4.1, step 2 */
461 regs[STB6100_LPEN] = 0xfb; /* PLL Loop enabled, bias on, VCO on, synth on */
462 rc = stb6100_write_reg(state, STB6100_LPEN, regs[STB6100_LPEN]);
463 if (rc < 0)
464 return rc;
465
466 msleep(2);
467
468 /* Bring up tuner according to LLA 3.7 3.4.1, step 3 */
469 regs[STB6100_VCO] &= ~STB6100_VCO_OCK; /* VCO fast search */
470 rc = stb6100_write_reg(state, STB6100_VCO, regs[STB6100_VCO]);
471 if (rc < 0)
472 return rc;
473
474 msleep(10); /* This is dangerous as another (related) thread may start */ /* wait for LO to lock */
475
476 regs[STB6100_VCO] &= ~STB6100_VCO_OSCH; /* vco search disabled */
477 regs[STB6100_VCO] |= STB6100_VCO_OCK; /* search clock off */
478 rc = stb6100_write_reg(state, STB6100_VCO, regs[STB6100_VCO]);
479 if (rc < 0)
480 return rc;
481
482 rc = stb6100_write_reg(state, STB6100_FCCK, 0x0d);
483 if (rc < 0)
484 return rc; /* Stop LPF calibration */
485
486 msleep(10); /* This is dangerous as another (related) thread may start */
487 /* wait for stabilisation, (should not be necessary) */
488 return 0;
489 }
490
stb6100_sleep(struct dvb_frontend * fe)491 static int stb6100_sleep(struct dvb_frontend *fe)
492 {
493 /* TODO: power down */
494 return 0;
495 }
496
stb6100_init(struct dvb_frontend * fe)497 static int stb6100_init(struct dvb_frontend *fe)
498 {
499 struct stb6100_state *state = fe->tuner_priv;
500 struct tuner_state *status = &state->status;
501
502 status->tunerstep = 125000;
503 status->ifreq = 0;
504 status->refclock = 27000000; /* Hz */
505 status->iqsense = 1;
506 status->bandwidth = 36000; /* kHz */
507 state->bandwidth = status->bandwidth * 1000; /* Hz */
508 state->reference = status->refclock / 1000; /* kHz */
509
510 /* Set default bandwidth. Modified, PN 13-May-10 */
511 return 0;
512 }
513
stb6100_get_state(struct dvb_frontend * fe,enum tuner_param param,struct tuner_state * state)514 static int stb6100_get_state(struct dvb_frontend *fe,
515 enum tuner_param param,
516 struct tuner_state *state)
517 {
518 switch (param) {
519 case DVBFE_TUNER_FREQUENCY:
520 stb6100_get_frequency(fe, &state->frequency);
521 break;
522 case DVBFE_TUNER_TUNERSTEP:
523 break;
524 case DVBFE_TUNER_IFFREQ:
525 break;
526 case DVBFE_TUNER_BANDWIDTH:
527 stb6100_get_bandwidth(fe, &state->bandwidth);
528 break;
529 case DVBFE_TUNER_REFCLOCK:
530 break;
531 default:
532 break;
533 }
534
535 return 0;
536 }
537
stb6100_set_state(struct dvb_frontend * fe,enum tuner_param param,struct tuner_state * state)538 static int stb6100_set_state(struct dvb_frontend *fe,
539 enum tuner_param param,
540 struct tuner_state *state)
541 {
542 struct stb6100_state *tstate = fe->tuner_priv;
543
544 switch (param) {
545 case DVBFE_TUNER_FREQUENCY:
546 stb6100_set_frequency(fe, state->frequency);
547 tstate->frequency = state->frequency;
548 break;
549 case DVBFE_TUNER_TUNERSTEP:
550 break;
551 case DVBFE_TUNER_IFFREQ:
552 break;
553 case DVBFE_TUNER_BANDWIDTH:
554 stb6100_set_bandwidth(fe, state->bandwidth);
555 tstate->bandwidth = state->bandwidth;
556 break;
557 case DVBFE_TUNER_REFCLOCK:
558 break;
559 default:
560 break;
561 }
562
563 return 0;
564 }
565
566 static struct dvb_tuner_ops stb6100_ops = {
567 .info = {
568 .name = "STB6100 Silicon Tuner",
569 .frequency_min = 950000,
570 .frequency_max = 2150000,
571 .frequency_step = 0,
572 },
573
574 .init = stb6100_init,
575 .sleep = stb6100_sleep,
576 .get_status = stb6100_get_status,
577 .get_state = stb6100_get_state,
578 .set_state = stb6100_set_state,
579 .release = stb6100_release
580 };
581
stb6100_attach(struct dvb_frontend * fe,const struct stb6100_config * config,struct i2c_adapter * i2c)582 struct dvb_frontend *stb6100_attach(struct dvb_frontend *fe,
583 const struct stb6100_config *config,
584 struct i2c_adapter *i2c)
585 {
586 struct stb6100_state *state = NULL;
587
588 state = kzalloc(sizeof (struct stb6100_state), GFP_KERNEL);
589 if (!state)
590 return NULL;
591
592 state->config = config;
593 state->i2c = i2c;
594 state->frontend = fe;
595 state->reference = config->refclock / 1000; /* kHz */
596 fe->tuner_priv = state;
597 fe->ops.tuner_ops = stb6100_ops;
598
599 printk("%s: Attaching STB6100 \n", __func__);
600 return fe;
601 }
602
stb6100_release(struct dvb_frontend * fe)603 static int stb6100_release(struct dvb_frontend *fe)
604 {
605 struct stb6100_state *state = fe->tuner_priv;
606
607 fe->tuner_priv = NULL;
608 kfree(state);
609
610 return 0;
611 }
612
613 EXPORT_SYMBOL(stb6100_attach);
614 MODULE_PARM_DESC(verbose, "Set Verbosity level");
615
616 MODULE_AUTHOR("Manu Abraham");
617 MODULE_DESCRIPTION("STB6100 Silicon tuner");
618 MODULE_LICENSE("GPL");
619