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.
17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19 #include <linux/slab.h>
20 #include <linux/module.h>
21 #include <linux/dvb/frontend.h>
22 #include <asm/types.h>
26 #define dprintk(fmt, arg...) \
27 printk(KERN_DEBUG pr_fmt("%s: " fmt), __func__, ##arg)
35 struct i2c_adapter
*i2c
;
37 /* the PLL descriptor */
38 const struct dvb_pll_desc
*pll_desc
;
40 /* cached frequency/bandwidth */
45 #define DVB_PLL_MAX 64
47 static unsigned int dvb_pll_devcount
;
50 module_param(debug
, int, 0644);
51 MODULE_PARM_DESC(debug
, "enable verbose debug messages");
53 static unsigned int id
[DVB_PLL_MAX
] =
54 { [ 0 ... (DVB_PLL_MAX
-1) ] = DVB_PLL_UNDEFINED
};
55 module_param_array(id
, int, NULL
, 0644);
56 MODULE_PARM_DESC(id
, "force pll id to use (DEBUG ONLY)");
58 /* ----------------------------------------------------------- */
65 void (*set
)(struct dvb_frontend
*fe
, u8
*buf
);
78 /* ----------------------------------------------------------- */
81 static const struct dvb_pll_desc dvb_pll_thomson_dtt7579
= {
82 .name
= "Thomson dtt7579",
86 .sleepdata
= (u8
[]){ 2, 0xb4, 0x03 },
89 { 443250000, 166667, 0xb4, 0x02 },
90 { 542000000, 166667, 0xb4, 0x08 },
91 { 771000000, 166667, 0xbc, 0x08 },
92 { 999999999, 166667, 0xf4, 0x08 },
96 static void thomson_dtt759x_bw(struct dvb_frontend
*fe
, u8
*buf
)
98 u32 bw
= fe
->dtv_property_cache
.bandwidth_hz
;
103 static const struct dvb_pll_desc dvb_pll_thomson_dtt759x
= {
104 .name
= "Thomson dtt759x",
107 .set
= thomson_dtt759x_bw
,
109 .sleepdata
= (u8
[]){ 2, 0x84, 0x03 },
112 { 264000000, 166667, 0xb4, 0x02 },
113 { 470000000, 166667, 0xbc, 0x02 },
114 { 735000000, 166667, 0xbc, 0x08 },
115 { 835000000, 166667, 0xf4, 0x08 },
116 { 999999999, 166667, 0xfc, 0x08 },
120 static void thomson_dtt7520x_bw(struct dvb_frontend
*fe
, u8
*buf
)
122 u32 bw
= fe
->dtv_property_cache
.bandwidth_hz
;
127 static const struct dvb_pll_desc dvb_pll_thomson_dtt7520x
= {
128 .name
= "Thomson dtt7520x",
131 .set
= thomson_dtt7520x_bw
,
135 { 305000000, 166667, 0xb4, 0x12 },
136 { 405000000, 166667, 0xbc, 0x12 },
137 { 445000000, 166667, 0xbc, 0x12 },
138 { 465000000, 166667, 0xf4, 0x18 },
139 { 735000000, 166667, 0xfc, 0x18 },
140 { 835000000, 166667, 0xbc, 0x18 },
141 { 999999999, 166667, 0xfc, 0x18 },
145 static const struct dvb_pll_desc dvb_pll_lg_z201
= {
150 .sleepdata
= (u8
[]){ 2, 0xbc, 0x03 },
153 { 157500000, 166667, 0xbc, 0x01 },
154 { 443250000, 166667, 0xbc, 0x02 },
155 { 542000000, 166667, 0xbc, 0x04 },
156 { 830000000, 166667, 0xf4, 0x04 },
157 { 999999999, 166667, 0xfc, 0x04 },
161 static const struct dvb_pll_desc dvb_pll_unknown_1
= {
162 .name
= "unknown 1", /* used by dntv live dvb-t */
168 { 150000000, 166667, 0xb4, 0x01 },
169 { 173000000, 166667, 0xbc, 0x01 },
170 { 250000000, 166667, 0xb4, 0x02 },
171 { 400000000, 166667, 0xbc, 0x02 },
172 { 420000000, 166667, 0xf4, 0x02 },
173 { 470000000, 166667, 0xfc, 0x02 },
174 { 600000000, 166667, 0xbc, 0x08 },
175 { 730000000, 166667, 0xf4, 0x08 },
176 { 999999999, 166667, 0xfc, 0x08 },
180 /* Infineon TUA6010XS
181 * used in Thomson Cable Tuner
183 static const struct dvb_pll_desc dvb_pll_tua6010xs
= {
184 .name
= "Infineon TUA6010XS",
190 { 115750000, 62500, 0x8e, 0x03 },
191 { 403250000, 62500, 0x8e, 0x06 },
192 { 999999999, 62500, 0x8e, 0x85 },
196 /* Panasonic env57h1xd5 (some Philips PLL ?) */
197 static const struct dvb_pll_desc dvb_pll_env57h1xd5
= {
198 .name
= "Panasonic ENV57H1XD5",
204 { 153000000, 166667, 0xc2, 0x41 },
205 { 470000000, 166667, 0xc2, 0x42 },
206 { 526000000, 166667, 0xc2, 0x84 },
207 { 999999999, 166667, 0xc2, 0xa4 },
211 /* Philips TDA6650/TDA6651
212 * used in Panasonic ENV77H11D5
214 static void tda665x_bw(struct dvb_frontend
*fe
, u8
*buf
)
216 u32 bw
= fe
->dtv_property_cache
.bandwidth_hz
;
221 static const struct dvb_pll_desc dvb_pll_tda665x
= {
222 .name
= "Philips TDA6650/TDA6651",
227 .initdata
= (u8
[]){ 4, 0x0b, 0xf5, 0x85, 0xab },
230 { 93834000, 166667, 0xca, 0x61 /* 011 0 0 0 01 */ },
231 { 123834000, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
232 { 161000000, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
233 { 163834000, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
234 { 253834000, 166667, 0xca, 0x62 /* 011 0 0 0 10 */ },
235 { 383834000, 166667, 0xca, 0xa2 /* 101 0 0 0 10 */ },
236 { 443834000, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
237 { 444000000, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ },
238 { 583834000, 166667, 0xca, 0x64 /* 011 0 0 1 00 */ },
239 { 793834000, 166667, 0xca, 0xa4 /* 101 0 0 1 00 */ },
240 { 444834000, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ },
241 { 861000000, 166667, 0xca, 0xe4 /* 111 0 0 1 00 */ },
246 * used in LG TDTP E102P
248 static void tua6034_bw(struct dvb_frontend
*fe
, u8
*buf
)
250 u32 bw
= fe
->dtv_property_cache
.bandwidth_hz
;
255 static const struct dvb_pll_desc dvb_pll_tua6034
= {
256 .name
= "Infineon TUA6034",
263 { 174500000, 62500, 0xce, 0x01 },
264 { 230000000, 62500, 0xce, 0x02 },
265 { 999999999, 62500, 0xce, 0x04 },
270 * used in Nebula-Cards and USB boxes
272 static void tded4_bw(struct dvb_frontend
*fe
, u8
*buf
)
274 u32 bw
= fe
->dtv_property_cache
.bandwidth_hz
;
279 static const struct dvb_pll_desc dvb_pll_tded4
= {
280 .name
= "ALPS TDED4",
287 { 153000000, 166667, 0x85, 0x01 },
288 { 470000000, 166667, 0x85, 0x02 },
289 { 823000000, 166667, 0x85, 0x08 },
290 { 999999999, 166667, 0x85, 0x88 },
295 * used in AverTVHD MCE A180
297 static const struct dvb_pll_desc dvb_pll_tdhu2
= {
298 .name
= "ALPS TDHU2",
304 { 162000000, 62500, 0x85, 0x01 },
305 { 426000000, 62500, 0x85, 0x02 },
306 { 782000000, 62500, 0x85, 0x08 },
307 { 999999999, 62500, 0x85, 0x88 },
311 /* Samsung TBMV30111IN / TBMV30712IN1
312 * used in Air2PC ATSC - 2nd generation (nxt2002)
314 static const struct dvb_pll_desc dvb_pll_samsung_tbmv
= {
315 .name
= "Samsung TBMV30111IN / TBMV30712IN1",
321 { 172000000, 166667, 0xb4, 0x01 },
322 { 214000000, 166667, 0xb4, 0x02 },
323 { 467000000, 166667, 0xbc, 0x02 },
324 { 721000000, 166667, 0xbc, 0x08 },
325 { 841000000, 166667, 0xf4, 0x08 },
326 { 999999999, 166667, 0xfc, 0x02 },
331 * Philips SD1878 Tuner.
333 static const struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261
= {
334 .name
= "Philips SD1878",
337 .iffreq
= 249, /* zero-IF, offset 249 is to round up */
340 { 1250000, 500, 0xc4, 0x00},
341 { 1450000, 500, 0xc4, 0x40},
342 { 2050000, 500, 0xc4, 0x80},
343 { 2150000, 500, 0xc4, 0xc0},
347 static void opera1_bw(struct dvb_frontend
*fe
, u8
*buf
)
349 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
350 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
351 u32 b_w
= (c
->symbol_rate
* 27) / 32000;
352 struct i2c_msg msg
= {
353 .addr
= priv
->pll_i2c_address
,
361 if (fe
->ops
.i2c_gate_ctrl
)
362 fe
->ops
.i2c_gate_ctrl(fe
, 1);
364 result
= i2c_transfer(priv
->i2c
, &msg
, 1);
366 pr_err("%s: i2c_transfer failed:%d",
371 else if (b_w
<= 12000)
373 else if (b_w
<= 14000)
375 else if (b_w
<= 16000)
377 else if (b_w
<= 18000)
379 else if (b_w
<= 20000)
381 else if (b_w
<= 22000)
383 else if (b_w
<= 24000)
385 else if (b_w
<= 26000)
387 else if (b_w
<= 28000)
391 buf
[2] ^= 0x1c; /* Flip bits 3-5 */
393 buf
[2] |= ((lpf
>> 2) & 0x3) << 3;
394 buf
[3] |= (lpf
& 0x3) << 2;
399 static const struct dvb_pll_desc dvb_pll_opera1
= {
400 .name
= "Opera Tuner",
403 .initdata
= (u8
[]){ 4, 0x08, 0xe5, 0xe1, 0x00 },
404 .initdata2
= (u8
[]){ 4, 0x08, 0xe5, 0xe5, 0x00 },
409 { 1064000, 500, 0xf9, 0xc2 },
410 { 1169000, 500, 0xf9, 0xe2 },
411 { 1299000, 500, 0xf9, 0x20 },
412 { 1444000, 500, 0xf9, 0x40 },
413 { 1606000, 500, 0xf9, 0x60 },
414 { 1777000, 500, 0xf9, 0x80 },
415 { 1941000, 500, 0xf9, 0xa0 },
416 { 2250000, 500, 0xf9, 0xc0 },
420 static void samsung_dtos403ih102a_set(struct dvb_frontend
*fe
, u8
*buf
)
422 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
423 struct i2c_msg msg
= {
424 .addr
= priv
->pll_i2c_address
,
431 if (fe
->ops
.i2c_gate_ctrl
)
432 fe
->ops
.i2c_gate_ctrl(fe
, 1);
434 result
= i2c_transfer(priv
->i2c
, &msg
, 1);
436 pr_err("%s: i2c_transfer failed:%d",
445 /* unknown pll used in Samsung DTOS403IH102A DVB-C tuner */
446 static const struct dvb_pll_desc dvb_pll_samsung_dtos403ih102a
= {
447 .name
= "Samsung DTOS403IH102A",
452 .set
= samsung_dtos403ih102a_set
,
454 { 135000000, 62500, 0xbe, 0x01 },
455 { 177000000, 62500, 0xf6, 0x01 },
456 { 370000000, 62500, 0xbe, 0x02 },
457 { 450000000, 62500, 0xf6, 0x02 },
458 { 466000000, 62500, 0xfe, 0x02 },
459 { 538000000, 62500, 0xbe, 0x08 },
460 { 826000000, 62500, 0xf6, 0x08 },
461 { 999999999, 62500, 0xfe, 0x08 },
465 /* Samsung TDTC9251DH0 DVB-T NIM, as used on AirStar 2 */
466 static const struct dvb_pll_desc dvb_pll_samsung_tdtc9251dh0
= {
467 .name
= "Samsung TDTC9251DH0",
473 { 157500000, 166667, 0xcc, 0x09 },
474 { 443000000, 166667, 0xcc, 0x0a },
475 { 863000000, 166667, 0xcc, 0x08 },
479 /* Samsung TBDU18132 DVB-S NIM with TSA5059 PLL, used in SkyStar2 DVB-S 2.3 */
480 static const struct dvb_pll_desc dvb_pll_samsung_tbdu18132
= {
481 .name
= "Samsung TBDU18132",
483 .max
= 2150000, /* guesses */
487 { 1550000, 125, 0x84, 0x82 },
488 { 4095937, 125, 0x84, 0x80 },
490 /* TSA5059 PLL has a 17 bit divisor rather than the 15 bits supported
491 * by this driver. The two extra bits are 0x60 in the third byte. 15
492 * bits is enough for over 4 GHz, which is enough to cover the range
493 * of this tuner. We could use the additional divisor bits by adding
495 { 0x0ffff * 125 + 125/2, 125, 0x84 | 0x20, },
496 { 0x17fff * 125 + 125/2, 125, 0x84 | 0x40, },
497 { 0x1ffff * 125 + 125/2, 125, 0x84 | 0x60, }, */
500 /* Samsung TBMU24112 DVB-S NIM with SL1935 zero-IF tuner */
501 static const struct dvb_pll_desc dvb_pll_samsung_tbmu24112
= {
502 .name
= "Samsung TBMU24112",
504 .max
= 2150000, /* guesses */
508 { 1500000, 125, 0x84, 0x18 },
509 { 9999999, 125, 0x84, 0x08 },
513 /* Alps TDEE4 DVB-C NIM, used on Cablestar 2 */
514 /* byte 4 : 1 * * AGD R3 R2 R1 R0
515 * byte 5 : C1 * RE RTS BS4 BS3 BS2 BS1
516 * AGD = 1, R3 R2 R1 R0 = 0 1 0 1 => byte 4 = 1**10101 = 0x95
517 * Range(MHz) C1 * RE RTS BS4 BS3 BS2 BS1 Byte 5
518 * 47 - 153 0 * 0 0 0 0 0 1 0x01
519 * 153 - 430 0 * 0 0 0 0 1 0 0x02
520 * 430 - 822 0 * 0 0 1 0 0 0 0x08
521 * 822 - 862 1 * 0 0 1 0 0 0 0x88 */
522 static const struct dvb_pll_desc dvb_pll_alps_tdee4
= {
523 .name
= "ALPS TDEE4",
529 { 153000000, 62500, 0x95, 0x01 },
530 { 430000000, 62500, 0x95, 0x02 },
531 { 822000000, 62500, 0x95, 0x08 },
532 { 999999999, 62500, 0x95, 0x88 },
536 /* ----------------------------------------------------------- */
538 static const struct dvb_pll_desc
*pll_list
[] = {
539 [DVB_PLL_UNDEFINED
] = NULL
,
540 [DVB_PLL_THOMSON_DTT7579
] = &dvb_pll_thomson_dtt7579
,
541 [DVB_PLL_THOMSON_DTT759X
] = &dvb_pll_thomson_dtt759x
,
542 [DVB_PLL_THOMSON_DTT7520X
] = &dvb_pll_thomson_dtt7520x
,
543 [DVB_PLL_LG_Z201
] = &dvb_pll_lg_z201
,
544 [DVB_PLL_UNKNOWN_1
] = &dvb_pll_unknown_1
,
545 [DVB_PLL_TUA6010XS
] = &dvb_pll_tua6010xs
,
546 [DVB_PLL_ENV57H1XD5
] = &dvb_pll_env57h1xd5
,
547 [DVB_PLL_TUA6034
] = &dvb_pll_tua6034
,
548 [DVB_PLL_TDA665X
] = &dvb_pll_tda665x
,
549 [DVB_PLL_TDED4
] = &dvb_pll_tded4
,
550 [DVB_PLL_TDEE4
] = &dvb_pll_alps_tdee4
,
551 [DVB_PLL_TDHU2
] = &dvb_pll_tdhu2
,
552 [DVB_PLL_SAMSUNG_TBMV
] = &dvb_pll_samsung_tbmv
,
553 [DVB_PLL_PHILIPS_SD1878_TDA8261
] = &dvb_pll_philips_sd1878_tda8261
,
554 [DVB_PLL_OPERA1
] = &dvb_pll_opera1
,
555 [DVB_PLL_SAMSUNG_DTOS403IH102A
] = &dvb_pll_samsung_dtos403ih102a
,
556 [DVB_PLL_SAMSUNG_TDTC9251DH0
] = &dvb_pll_samsung_tdtc9251dh0
,
557 [DVB_PLL_SAMSUNG_TBDU18132
] = &dvb_pll_samsung_tbdu18132
,
558 [DVB_PLL_SAMSUNG_TBMU24112
] = &dvb_pll_samsung_tbmu24112
,
561 /* ----------------------------------------------------------- */
564 static int dvb_pll_configure(struct dvb_frontend
*fe
, u8
*buf
,
567 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
568 const struct dvb_pll_desc
*desc
= priv
->pll_desc
;
572 if (frequency
&& (frequency
< desc
->min
|| frequency
> desc
->max
))
575 for (i
= 0; i
< desc
->count
; i
++) {
576 if (frequency
> desc
->entries
[i
].limit
)
582 dprintk("pll: %s: freq=%d | i=%d/%d\n", desc
->name
,
583 frequency
, i
, desc
->count
);
584 if (i
== desc
->count
)
587 div
= (frequency
+ desc
->iffreq
+
588 desc
->entries
[i
].stepsize
/2) / desc
->entries
[i
].stepsize
;
591 buf
[2] = desc
->entries
[i
].config
;
592 buf
[3] = desc
->entries
[i
].cb
;
598 dprintk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
599 desc
->name
, div
, buf
[0], buf
[1], buf
[2], buf
[3]);
601 // calculate the frequency we set it to
602 return (div
* desc
->entries
[i
].stepsize
) - desc
->iffreq
;
605 static void dvb_pll_release(struct dvb_frontend
*fe
)
607 kfree(fe
->tuner_priv
);
608 fe
->tuner_priv
= NULL
;
611 static int dvb_pll_sleep(struct dvb_frontend
*fe
)
613 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
615 if (priv
->i2c
== NULL
)
618 if (priv
->pll_desc
->sleepdata
) {
619 struct i2c_msg msg
= { .flags
= 0,
620 .addr
= priv
->pll_i2c_address
,
621 .buf
= priv
->pll_desc
->sleepdata
+ 1,
622 .len
= priv
->pll_desc
->sleepdata
[0] };
626 if (fe
->ops
.i2c_gate_ctrl
)
627 fe
->ops
.i2c_gate_ctrl(fe
, 1);
628 if ((result
= i2c_transfer(priv
->i2c
, &msg
, 1)) != 1) {
633 /* Shouldn't be called when initdata is NULL, maybe BUG()? */
637 static int dvb_pll_set_params(struct dvb_frontend
*fe
)
639 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
640 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
643 { .addr
= priv
->pll_i2c_address
, .flags
= 0,
644 .buf
= buf
, .len
= sizeof(buf
) };
648 if (priv
->i2c
== NULL
)
651 result
= dvb_pll_configure(fe
, buf
, c
->frequency
);
657 if (fe
->ops
.i2c_gate_ctrl
)
658 fe
->ops
.i2c_gate_ctrl(fe
, 1);
659 if ((result
= i2c_transfer(priv
->i2c
, &msg
, 1)) != 1) {
663 priv
->frequency
= frequency
;
664 priv
->bandwidth
= c
->bandwidth_hz
;
669 static int dvb_pll_calc_regs(struct dvb_frontend
*fe
,
670 u8
*buf
, int buf_len
)
672 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
673 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
680 result
= dvb_pll_configure(fe
, buf
+ 1, c
->frequency
);
686 buf
[0] = priv
->pll_i2c_address
;
688 priv
->frequency
= frequency
;
689 priv
->bandwidth
= c
->bandwidth_hz
;
694 static int dvb_pll_get_frequency(struct dvb_frontend
*fe
, u32
*frequency
)
696 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
697 *frequency
= priv
->frequency
;
701 static int dvb_pll_get_bandwidth(struct dvb_frontend
*fe
, u32
*bandwidth
)
703 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
704 *bandwidth
= priv
->bandwidth
;
708 static int dvb_pll_init(struct dvb_frontend
*fe
)
710 struct dvb_pll_priv
*priv
= fe
->tuner_priv
;
712 if (priv
->i2c
== NULL
)
715 if (priv
->pll_desc
->initdata
) {
716 struct i2c_msg msg
= { .flags
= 0,
717 .addr
= priv
->pll_i2c_address
,
718 .buf
= priv
->pll_desc
->initdata
+ 1,
719 .len
= priv
->pll_desc
->initdata
[0] };
722 if (fe
->ops
.i2c_gate_ctrl
)
723 fe
->ops
.i2c_gate_ctrl(fe
, 1);
724 result
= i2c_transfer(priv
->i2c
, &msg
, 1);
727 if (priv
->pll_desc
->initdata2
) {
728 msg
.buf
= priv
->pll_desc
->initdata2
+ 1;
729 msg
.len
= priv
->pll_desc
->initdata2
[0];
730 if (fe
->ops
.i2c_gate_ctrl
)
731 fe
->ops
.i2c_gate_ctrl(fe
, 1);
732 result
= i2c_transfer(priv
->i2c
, &msg
, 1);
738 /* Shouldn't be called when initdata is NULL, maybe BUG()? */
742 static const struct dvb_tuner_ops dvb_pll_tuner_ops
= {
743 .release
= dvb_pll_release
,
744 .sleep
= dvb_pll_sleep
,
745 .init
= dvb_pll_init
,
746 .set_params
= dvb_pll_set_params
,
747 .calc_regs
= dvb_pll_calc_regs
,
748 .get_frequency
= dvb_pll_get_frequency
,
749 .get_bandwidth
= dvb_pll_get_bandwidth
,
752 struct dvb_frontend
*dvb_pll_attach(struct dvb_frontend
*fe
, int pll_addr
,
753 struct i2c_adapter
*i2c
,
754 unsigned int pll_desc_id
)
757 struct i2c_msg msg
= { .addr
= pll_addr
, .flags
= I2C_M_RD
, .len
= 1 };
758 struct dvb_pll_priv
*priv
= NULL
;
760 const struct dvb_pll_desc
*desc
;
762 b1
= kmalloc(1, GFP_KERNEL
);
769 if ((id
[dvb_pll_devcount
] > DVB_PLL_UNDEFINED
) &&
770 (id
[dvb_pll_devcount
] < ARRAY_SIZE(pll_list
)))
771 pll_desc_id
= id
[dvb_pll_devcount
];
773 BUG_ON(pll_desc_id
< 1 || pll_desc_id
>= ARRAY_SIZE(pll_list
));
775 desc
= pll_list
[pll_desc_id
];
778 if (fe
->ops
.i2c_gate_ctrl
)
779 fe
->ops
.i2c_gate_ctrl(fe
, 1);
781 ret
= i2c_transfer (i2c
, &msg
, 1);
786 if (fe
->ops
.i2c_gate_ctrl
)
787 fe
->ops
.i2c_gate_ctrl(fe
, 0);
790 priv
= kzalloc(sizeof(struct dvb_pll_priv
), GFP_KERNEL
);
796 priv
->pll_i2c_address
= pll_addr
;
798 priv
->pll_desc
= desc
;
799 priv
->nr
= dvb_pll_devcount
++;
801 memcpy(&fe
->ops
.tuner_ops
, &dvb_pll_tuner_ops
,
802 sizeof(struct dvb_tuner_ops
));
804 strncpy(fe
->ops
.tuner_ops
.info
.name
, desc
->name
,
805 sizeof(fe
->ops
.tuner_ops
.info
.name
));
806 fe
->ops
.tuner_ops
.info
.frequency_min
= desc
->min
;
807 fe
->ops
.tuner_ops
.info
.frequency_max
= desc
->max
;
809 fe
->ops
.tuner_ops
.init
= NULL
;
810 if (!desc
->sleepdata
)
811 fe
->ops
.tuner_ops
.sleep
= NULL
;
813 fe
->tuner_priv
= priv
;
815 if ((debug
) || (id
[priv
->nr
] == pll_desc_id
)) {
816 dprintk("dvb-pll[%d]", priv
->nr
);
818 pr_cont(" %d-%04x", i2c_adapter_id(i2c
), pll_addr
);
819 pr_cont(": id# %d (%s) attached, %s\n", pll_desc_id
, desc
->name
,
820 id
[priv
->nr
] == pll_desc_id
?
821 "insmod option" : "autodetected");
828 EXPORT_SYMBOL(dvb_pll_attach
);
830 MODULE_DESCRIPTION("dvb pll library");
831 MODULE_AUTHOR("Gerd Knorr");
832 MODULE_LICENSE("GPL");