2 * descriptions + helper functions for simple dvb plls.
4 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
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 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23 #include <linux/slab.h>
24 #include <linux/module.h>
25 #include <linux/dvb/frontend.h>
26 #include <asm/types.h>
30 #define dprintk(fmt, arg...) \
31 printk(KERN_DEBUG pr_fmt("%s: " fmt), __func__, ##arg)
39 struct i2c_adapter
*i2c
;
41 /* the PLL descriptor */
42 const struct dvb_pll_desc
*pll_desc
;
44 /* cached frequency/bandwidth */
49 #define DVB_PLL_MAX 64
51 static unsigned int dvb_pll_devcount
;
54 module_param(debug
, int, 0644);
55 MODULE_PARM_DESC(debug
, "enable verbose debug messages");
57 static unsigned int id
[DVB_PLL_MAX
] =
58 { [ 0 ... (DVB_PLL_MAX
-1) ] = DVB_PLL_UNDEFINED
};
59 module_param_array(id
, int, NULL
, 0644);
60 MODULE_PARM_DESC(id
, "force pll id to use (DEBUG ONLY)");
62 /* ----------------------------------------------------------- */
69 void (*set
)(struct dvb_frontend
*fe
, u8
*buf
);
82 /* ----------------------------------------------------------- */
85 static const struct dvb_pll_desc dvb_pll_thomson_dtt7579
= {
86 .name
= "Thomson dtt7579",
90 .sleepdata
= (u8
[]){ 2, 0xb4, 0x03 },
93 { 443250000, 166667, 0xb4, 0x02 },
94 { 542000000, 166667, 0xb4, 0x08 },
95 { 771000000, 166667, 0xbc, 0x08 },
96 { 999999999, 166667, 0xf4, 0x08 },
100 static void thomson_dtt759x_bw(struct dvb_frontend
*fe
, u8
*buf
)
102 u32 bw
= fe
->dtv_property_cache
.bandwidth_hz
;
107 static const struct dvb_pll_desc dvb_pll_thomson_dtt759x
= {
108 .name
= "Thomson dtt759x",
111 .set
= thomson_dtt759x_bw
,
113 .sleepdata
= (u8
[]){ 2, 0x84, 0x03 },
116 { 264000000, 166667, 0xb4, 0x02 },
117 { 470000000, 166667, 0xbc, 0x02 },
118 { 735000000, 166667, 0xbc, 0x08 },
119 { 835000000, 166667, 0xf4, 0x08 },
120 { 999999999, 166667, 0xfc, 0x08 },
124 static void thomson_dtt7520x_bw(struct dvb_frontend
*fe
, u8
*buf
)
126 u32 bw
= fe
->dtv_property_cache
.bandwidth_hz
;
131 static const struct dvb_pll_desc dvb_pll_thomson_dtt7520x
= {
132 .name
= "Thomson dtt7520x",
135 .set
= thomson_dtt7520x_bw
,
139 { 305000000, 166667, 0xb4, 0x12 },
140 { 405000000, 166667, 0xbc, 0x12 },
141 { 445000000, 166667, 0xbc, 0x12 },
142 { 465000000, 166667, 0xf4, 0x18 },
143 { 735000000, 166667, 0xfc, 0x18 },
144 { 835000000, 166667, 0xbc, 0x18 },
145 { 999999999, 166667, 0xfc, 0x18 },
149 static const struct dvb_pll_desc dvb_pll_lg_z201
= {
154 .sleepdata
= (u8
[]){ 2, 0xbc, 0x03 },
157 { 157500000, 166667, 0xbc, 0x01 },
158 { 443250000, 166667, 0xbc, 0x02 },
159 { 542000000, 166667, 0xbc, 0x04 },
160 { 830000000, 166667, 0xf4, 0x04 },
161 { 999999999, 166667, 0xfc, 0x04 },
165 static const struct dvb_pll_desc dvb_pll_unknown_1
= {
166 .name
= "unknown 1", /* used by dntv live dvb-t */
172 { 150000000, 166667, 0xb4, 0x01 },
173 { 173000000, 166667, 0xbc, 0x01 },
174 { 250000000, 166667, 0xb4, 0x02 },
175 { 400000000, 166667, 0xbc, 0x02 },
176 { 420000000, 166667, 0xf4, 0x02 },
177 { 470000000, 166667, 0xfc, 0x02 },
178 { 600000000, 166667, 0xbc, 0x08 },
179 { 730000000, 166667, 0xf4, 0x08 },
180 { 999999999, 166667, 0xfc, 0x08 },
184 /* Infineon TUA6010XS
185 * used in Thomson Cable Tuner
187 static const struct dvb_pll_desc dvb_pll_tua6010xs
= {
188 .name
= "Infineon TUA6010XS",
194 { 115750000, 62500, 0x8e, 0x03 },
195 { 403250000, 62500, 0x8e, 0x06 },
196 { 999999999, 62500, 0x8e, 0x85 },
200 /* Panasonic env57h1xd5 (some Philips PLL ?) */
201 static const struct dvb_pll_desc dvb_pll_env57h1xd5
= {
202 .name
= "Panasonic ENV57H1XD5",
208 { 153000000, 166667, 0xc2, 0x41 },
209 { 470000000, 166667, 0xc2, 0x42 },
210 { 526000000, 166667, 0xc2, 0x84 },
211 { 999999999, 166667, 0xc2, 0xa4 },
215 /* Philips TDA6650/TDA6651
216 * used in Panasonic ENV77H11D5
218 static void tda665x_bw(struct dvb_frontend
*fe
, u8
*buf
)
220 u32 bw
= fe
->dtv_property_cache
.bandwidth_hz
;
225 static const struct dvb_pll_desc dvb_pll_tda665x
= {
226 .name
= "Philips TDA6650/TDA6651",
231 .initdata
= (u8
[]){ 4, 0x0b, 0xf5, 0x85, 0xab },
234 { 93834000, 166667, 0xca, 0x61 /* 011 0 0 0 01 */ },
235 { 123834000, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
236 { 161000000, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
237 { 163834000, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
238 { 253834000, 166667, 0xca, 0x62 /* 011 0 0 0 10 */ },
239 { 383834000, 166667, 0xca, 0xa2 /* 101 0 0 0 10 */ },
240 { 443834000, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
241 { 444000000, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ },
242 { 583834000, 166667, 0xca, 0x64 /* 011 0 0 1 00 */ },
243 { 793834000, 166667, 0xca, 0xa4 /* 101 0 0 1 00 */ },
244 { 444834000, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ },
245 { 861000000, 166667, 0xca, 0xe4 /* 111 0 0 1 00 */ },
250 * used in LG TDTP E102P
252 static void tua6034_bw(struct dvb_frontend
*fe
, u8
*buf
)
254 u32 bw
= fe
->dtv_property_cache
.bandwidth_hz
;
259 static const struct dvb_pll_desc dvb_pll_tua6034
= {
260 .name
= "Infineon TUA6034",
267 { 174500000, 62500, 0xce, 0x01 },
268 { 230000000, 62500, 0xce, 0x02 },
269 { 999999999, 62500, 0xce, 0x04 },
274 * used in Nebula-Cards and USB boxes
276 static void tded4_bw(struct dvb_frontend
*fe
, u8
*buf
)
278 u32 bw
= fe
->dtv_property_cache
.bandwidth_hz
;
283 static const struct dvb_pll_desc dvb_pll_tded4
= {
284 .name
= "ALPS TDED4",
291 { 153000000, 166667, 0x85, 0x01 },
292 { 470000000, 166667, 0x85, 0x02 },
293 { 823000000, 166667, 0x85, 0x08 },
294 { 999999999, 166667, 0x85, 0x88 },
299 * used in AverTVHD MCE A180
301 static const struct dvb_pll_desc dvb_pll_tdhu2
= {
302 .name
= "ALPS TDHU2",
308 { 162000000, 62500, 0x85, 0x01 },
309 { 426000000, 62500, 0x85, 0x02 },
310 { 782000000, 62500, 0x85, 0x08 },
311 { 999999999, 62500, 0x85, 0x88 },
315 /* Samsung TBMV30111IN / TBMV30712IN1
316 * used in Air2PC ATSC - 2nd generation (nxt2002)
318 static const struct dvb_pll_desc dvb_pll_samsung_tbmv
= {
319 .name
= "Samsung TBMV30111IN / TBMV30712IN1",
325 { 172000000, 166667, 0xb4, 0x01 },
326 { 214000000, 166667, 0xb4, 0x02 },
327 { 467000000, 166667, 0xbc, 0x02 },
328 { 721000000, 166667, 0xbc, 0x08 },
329 { 841000000, 166667, 0xf4, 0x08 },
330 { 999999999, 166667, 0xfc, 0x02 },
335 * Philips SD1878 Tuner.
337 static const struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261
= {
338 .name
= "Philips SD1878",
341 .iffreq
= 249, /* zero-IF, offset 249 is to round up */
344 { 1250000, 500, 0xc4, 0x00},
345 { 1450000, 500, 0xc4, 0x40},
346 { 2050000, 500, 0xc4, 0x80},
347 { 2150000, 500, 0xc4, 0xc0},
351 static void opera1_bw(struct dvb_frontend
*fe
, u8
*buf
)
353 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
354 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
355 u32 b_w
= (c
->symbol_rate
* 27) / 32000;
356 struct i2c_msg msg
= {
357 .addr
= priv
->pll_i2c_address
,
365 if (fe
->ops
.i2c_gate_ctrl
)
366 fe
->ops
.i2c_gate_ctrl(fe
, 1);
368 result
= i2c_transfer(priv
->i2c
, &msg
, 1);
370 pr_err("%s: i2c_transfer failed:%d",
375 else if (b_w
<= 12000)
377 else if (b_w
<= 14000)
379 else if (b_w
<= 16000)
381 else if (b_w
<= 18000)
383 else if (b_w
<= 20000)
385 else if (b_w
<= 22000)
387 else if (b_w
<= 24000)
389 else if (b_w
<= 26000)
391 else if (b_w
<= 28000)
395 buf
[2] ^= 0x1c; /* Flip bits 3-5 */
397 buf
[2] |= ((lpf
>> 2) & 0x3) << 3;
398 buf
[3] |= (lpf
& 0x3) << 2;
403 static const struct dvb_pll_desc dvb_pll_opera1
= {
404 .name
= "Opera Tuner",
407 .initdata
= (u8
[]){ 4, 0x08, 0xe5, 0xe1, 0x00 },
408 .initdata2
= (u8
[]){ 4, 0x08, 0xe5, 0xe5, 0x00 },
413 { 1064000, 500, 0xf9, 0xc2 },
414 { 1169000, 500, 0xf9, 0xe2 },
415 { 1299000, 500, 0xf9, 0x20 },
416 { 1444000, 500, 0xf9, 0x40 },
417 { 1606000, 500, 0xf9, 0x60 },
418 { 1777000, 500, 0xf9, 0x80 },
419 { 1941000, 500, 0xf9, 0xa0 },
420 { 2250000, 500, 0xf9, 0xc0 },
424 static void samsung_dtos403ih102a_set(struct dvb_frontend
*fe
, u8
*buf
)
426 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
427 struct i2c_msg msg
= {
428 .addr
= priv
->pll_i2c_address
,
435 if (fe
->ops
.i2c_gate_ctrl
)
436 fe
->ops
.i2c_gate_ctrl(fe
, 1);
438 result
= i2c_transfer(priv
->i2c
, &msg
, 1);
440 pr_err("%s: i2c_transfer failed:%d",
449 /* unknown pll used in Samsung DTOS403IH102A DVB-C tuner */
450 static const struct dvb_pll_desc dvb_pll_samsung_dtos403ih102a
= {
451 .name
= "Samsung DTOS403IH102A",
456 .set
= samsung_dtos403ih102a_set
,
458 { 135000000, 62500, 0xbe, 0x01 },
459 { 177000000, 62500, 0xf6, 0x01 },
460 { 370000000, 62500, 0xbe, 0x02 },
461 { 450000000, 62500, 0xf6, 0x02 },
462 { 466000000, 62500, 0xfe, 0x02 },
463 { 538000000, 62500, 0xbe, 0x08 },
464 { 826000000, 62500, 0xf6, 0x08 },
465 { 999999999, 62500, 0xfe, 0x08 },
469 /* Samsung TDTC9251DH0 DVB-T NIM, as used on AirStar 2 */
470 static const struct dvb_pll_desc dvb_pll_samsung_tdtc9251dh0
= {
471 .name
= "Samsung TDTC9251DH0",
477 { 157500000, 166667, 0xcc, 0x09 },
478 { 443000000, 166667, 0xcc, 0x0a },
479 { 863000000, 166667, 0xcc, 0x08 },
483 /* Samsung TBDU18132 DVB-S NIM with TSA5059 PLL, used in SkyStar2 DVB-S 2.3 */
484 static const struct dvb_pll_desc dvb_pll_samsung_tbdu18132
= {
485 .name
= "Samsung TBDU18132",
487 .max
= 2150000, /* guesses */
491 { 1550000, 125, 0x84, 0x82 },
492 { 4095937, 125, 0x84, 0x80 },
494 /* TSA5059 PLL has a 17 bit divisor rather than the 15 bits supported
495 * by this driver. The two extra bits are 0x60 in the third byte. 15
496 * bits is enough for over 4 GHz, which is enough to cover the range
497 * of this tuner. We could use the additional divisor bits by adding
499 { 0x0ffff * 125 + 125/2, 125, 0x84 | 0x20, },
500 { 0x17fff * 125 + 125/2, 125, 0x84 | 0x40, },
501 { 0x1ffff * 125 + 125/2, 125, 0x84 | 0x60, }, */
504 /* Samsung TBMU24112 DVB-S NIM with SL1935 zero-IF tuner */
505 static const struct dvb_pll_desc dvb_pll_samsung_tbmu24112
= {
506 .name
= "Samsung TBMU24112",
508 .max
= 2150000, /* guesses */
512 { 1500000, 125, 0x84, 0x18 },
513 { 9999999, 125, 0x84, 0x08 },
517 /* Alps TDEE4 DVB-C NIM, used on Cablestar 2 */
518 /* byte 4 : 1 * * AGD R3 R2 R1 R0
519 * byte 5 : C1 * RE RTS BS4 BS3 BS2 BS1
520 * AGD = 1, R3 R2 R1 R0 = 0 1 0 1 => byte 4 = 1**10101 = 0x95
521 * Range(MHz) C1 * RE RTS BS4 BS3 BS2 BS1 Byte 5
522 * 47 - 153 0 * 0 0 0 0 0 1 0x01
523 * 153 - 430 0 * 0 0 0 0 1 0 0x02
524 * 430 - 822 0 * 0 0 1 0 0 0 0x08
525 * 822 - 862 1 * 0 0 1 0 0 0 0x88 */
526 static const struct dvb_pll_desc dvb_pll_alps_tdee4
= {
527 .name
= "ALPS TDEE4",
533 { 153000000, 62500, 0x95, 0x01 },
534 { 430000000, 62500, 0x95, 0x02 },
535 { 822000000, 62500, 0x95, 0x08 },
536 { 999999999, 62500, 0x95, 0x88 },
540 /* ----------------------------------------------------------- */
542 static const struct dvb_pll_desc
*pll_list
[] = {
543 [DVB_PLL_UNDEFINED
] = NULL
,
544 [DVB_PLL_THOMSON_DTT7579
] = &dvb_pll_thomson_dtt7579
,
545 [DVB_PLL_THOMSON_DTT759X
] = &dvb_pll_thomson_dtt759x
,
546 [DVB_PLL_THOMSON_DTT7520X
] = &dvb_pll_thomson_dtt7520x
,
547 [DVB_PLL_LG_Z201
] = &dvb_pll_lg_z201
,
548 [DVB_PLL_UNKNOWN_1
] = &dvb_pll_unknown_1
,
549 [DVB_PLL_TUA6010XS
] = &dvb_pll_tua6010xs
,
550 [DVB_PLL_ENV57H1XD5
] = &dvb_pll_env57h1xd5
,
551 [DVB_PLL_TUA6034
] = &dvb_pll_tua6034
,
552 [DVB_PLL_TDA665X
] = &dvb_pll_tda665x
,
553 [DVB_PLL_TDED4
] = &dvb_pll_tded4
,
554 [DVB_PLL_TDEE4
] = &dvb_pll_alps_tdee4
,
555 [DVB_PLL_TDHU2
] = &dvb_pll_tdhu2
,
556 [DVB_PLL_SAMSUNG_TBMV
] = &dvb_pll_samsung_tbmv
,
557 [DVB_PLL_PHILIPS_SD1878_TDA8261
] = &dvb_pll_philips_sd1878_tda8261
,
558 [DVB_PLL_OPERA1
] = &dvb_pll_opera1
,
559 [DVB_PLL_SAMSUNG_DTOS403IH102A
] = &dvb_pll_samsung_dtos403ih102a
,
560 [DVB_PLL_SAMSUNG_TDTC9251DH0
] = &dvb_pll_samsung_tdtc9251dh0
,
561 [DVB_PLL_SAMSUNG_TBDU18132
] = &dvb_pll_samsung_tbdu18132
,
562 [DVB_PLL_SAMSUNG_TBMU24112
] = &dvb_pll_samsung_tbmu24112
,
565 /* ----------------------------------------------------------- */
568 static int dvb_pll_configure(struct dvb_frontend
*fe
, u8
*buf
,
571 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
572 const struct dvb_pll_desc
*desc
= priv
->pll_desc
;
576 if (frequency
&& (frequency
< desc
->min
|| frequency
> desc
->max
))
579 for (i
= 0; i
< desc
->count
; i
++) {
580 if (frequency
> desc
->entries
[i
].limit
)
586 dprintk("pll: %s: freq=%d | i=%d/%d\n", desc
->name
,
587 frequency
, i
, desc
->count
);
588 if (i
== desc
->count
)
591 div
= (frequency
+ desc
->iffreq
+
592 desc
->entries
[i
].stepsize
/2) / desc
->entries
[i
].stepsize
;
595 buf
[2] = desc
->entries
[i
].config
;
596 buf
[3] = desc
->entries
[i
].cb
;
602 dprintk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
603 desc
->name
, div
, buf
[0], buf
[1], buf
[2], buf
[3]);
605 // calculate the frequency we set it to
606 return (div
* desc
->entries
[i
].stepsize
) - desc
->iffreq
;
609 static void dvb_pll_release(struct dvb_frontend
*fe
)
611 kfree(fe
->tuner_priv
);
612 fe
->tuner_priv
= NULL
;
615 static int dvb_pll_sleep(struct dvb_frontend
*fe
)
617 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
619 if (priv
->i2c
== NULL
)
622 if (priv
->pll_desc
->sleepdata
) {
623 struct i2c_msg msg
= { .flags
= 0,
624 .addr
= priv
->pll_i2c_address
,
625 .buf
= priv
->pll_desc
->sleepdata
+ 1,
626 .len
= priv
->pll_desc
->sleepdata
[0] };
630 if (fe
->ops
.i2c_gate_ctrl
)
631 fe
->ops
.i2c_gate_ctrl(fe
, 1);
632 if ((result
= i2c_transfer(priv
->i2c
, &msg
, 1)) != 1) {
637 /* Shouldn't be called when initdata is NULL, maybe BUG()? */
641 static int dvb_pll_set_params(struct dvb_frontend
*fe
)
643 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
644 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
647 { .addr
= priv
->pll_i2c_address
, .flags
= 0,
648 .buf
= buf
, .len
= sizeof(buf
) };
652 if (priv
->i2c
== NULL
)
655 result
= dvb_pll_configure(fe
, buf
, c
->frequency
);
661 if (fe
->ops
.i2c_gate_ctrl
)
662 fe
->ops
.i2c_gate_ctrl(fe
, 1);
663 if ((result
= i2c_transfer(priv
->i2c
, &msg
, 1)) != 1) {
667 priv
->frequency
= frequency
;
668 priv
->bandwidth
= c
->bandwidth_hz
;
673 static int dvb_pll_calc_regs(struct dvb_frontend
*fe
,
674 u8
*buf
, int buf_len
)
676 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
677 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
684 result
= dvb_pll_configure(fe
, buf
+ 1, c
->frequency
);
690 buf
[0] = priv
->pll_i2c_address
;
692 priv
->frequency
= frequency
;
693 priv
->bandwidth
= c
->bandwidth_hz
;
698 static int dvb_pll_get_frequency(struct dvb_frontend
*fe
, u32
*frequency
)
700 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
701 *frequency
= priv
->frequency
;
705 static int dvb_pll_get_bandwidth(struct dvb_frontend
*fe
, u32
*bandwidth
)
707 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
708 *bandwidth
= priv
->bandwidth
;
712 static int dvb_pll_init(struct dvb_frontend
*fe
)
714 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
716 if (priv
->i2c
== NULL
)
719 if (priv
->pll_desc
->initdata
) {
720 struct i2c_msg msg
= { .flags
= 0,
721 .addr
= priv
->pll_i2c_address
,
722 .buf
= priv
->pll_desc
->initdata
+ 1,
723 .len
= priv
->pll_desc
->initdata
[0] };
726 if (fe
->ops
.i2c_gate_ctrl
)
727 fe
->ops
.i2c_gate_ctrl(fe
, 1);
728 result
= i2c_transfer(priv
->i2c
, &msg
, 1);
731 if (priv
->pll_desc
->initdata2
) {
732 msg
.buf
= priv
->pll_desc
->initdata2
+ 1;
733 msg
.len
= priv
->pll_desc
->initdata2
[0];
734 if (fe
->ops
.i2c_gate_ctrl
)
735 fe
->ops
.i2c_gate_ctrl(fe
, 1);
736 result
= i2c_transfer(priv
->i2c
, &msg
, 1);
742 /* Shouldn't be called when initdata is NULL, maybe BUG()? */
746 static const struct dvb_tuner_ops dvb_pll_tuner_ops
= {
747 .release
= dvb_pll_release
,
748 .sleep
= dvb_pll_sleep
,
749 .init
= dvb_pll_init
,
750 .set_params
= dvb_pll_set_params
,
751 .calc_regs
= dvb_pll_calc_regs
,
752 .get_frequency
= dvb_pll_get_frequency
,
753 .get_bandwidth
= dvb_pll_get_bandwidth
,
756 struct dvb_frontend
*dvb_pll_attach(struct dvb_frontend
*fe
, int pll_addr
,
757 struct i2c_adapter
*i2c
,
758 unsigned int pll_desc_id
)
761 struct i2c_msg msg
= { .addr
= pll_addr
, .flags
= I2C_M_RD
,
762 .buf
= b1
, .len
= 1 };
763 struct dvb_pll_priv
*priv
= NULL
;
765 const struct dvb_pll_desc
*desc
;
767 if ((id
[dvb_pll_devcount
] > DVB_PLL_UNDEFINED
) &&
768 (id
[dvb_pll_devcount
] < ARRAY_SIZE(pll_list
)))
769 pll_desc_id
= id
[dvb_pll_devcount
];
771 BUG_ON(pll_desc_id
< 1 || pll_desc_id
>= ARRAY_SIZE(pll_list
));
773 desc
= pll_list
[pll_desc_id
];
776 if (fe
->ops
.i2c_gate_ctrl
)
777 fe
->ops
.i2c_gate_ctrl(fe
, 1);
779 ret
= i2c_transfer (i2c
, &msg
, 1);
782 if (fe
->ops
.i2c_gate_ctrl
)
783 fe
->ops
.i2c_gate_ctrl(fe
, 0);
786 priv
= kzalloc(sizeof(struct dvb_pll_priv
), GFP_KERNEL
);
790 priv
->pll_i2c_address
= pll_addr
;
792 priv
->pll_desc
= desc
;
793 priv
->nr
= dvb_pll_devcount
++;
795 memcpy(&fe
->ops
.tuner_ops
, &dvb_pll_tuner_ops
,
796 sizeof(struct dvb_tuner_ops
));
798 strncpy(fe
->ops
.tuner_ops
.info
.name
, desc
->name
,
799 sizeof(fe
->ops
.tuner_ops
.info
.name
));
800 fe
->ops
.tuner_ops
.info
.frequency_min
= desc
->min
;
801 fe
->ops
.tuner_ops
.info
.frequency_max
= desc
->max
;
803 fe
->ops
.tuner_ops
.init
= NULL
;
804 if (!desc
->sleepdata
)
805 fe
->ops
.tuner_ops
.sleep
= NULL
;
807 fe
->tuner_priv
= priv
;
809 if ((debug
) || (id
[priv
->nr
] == pll_desc_id
)) {
810 dprintk("dvb-pll[%d]", priv
->nr
);
812 pr_cont(" %d-%04x", i2c_adapter_id(i2c
), pll_addr
);
813 pr_cont(": id# %d (%s) attached, %s\n", pll_desc_id
, desc
->name
,
814 id
[priv
->nr
] == pll_desc_id
?
815 "insmod option" : "autodetected");
820 EXPORT_SYMBOL(dvb_pll_attach
);
822 MODULE_DESCRIPTION("dvb pll library");
823 MODULE_AUTHOR("Gerd Knorr");
824 MODULE_LICENSE("GPL");