blob: 6d8fe884323714f89392ecf221e81f3c6b8b0214 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * descriptions + helper functions for simple dvb plls.
3 *
4 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
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
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090021#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <linux/module.h>
23#include <linux/dvb/frontend.h>
24#include <asm/types.h>
25
26#include "dvb-pll.h"
27
Michael Krufky05a46112007-09-07 18:19:57 -030028struct dvb_pll_priv {
29 /* pll number */
30 int nr;
31
32 /* i2c details */
33 int pll_i2c_address;
34 struct i2c_adapter *i2c;
35
36 /* the PLL descriptor */
37 struct dvb_pll_desc *pll_desc;
38
39 /* cached frequency/bandwidth */
40 u32 frequency;
41 u32 bandwidth;
42};
43
Michael Krufkyff3e7dd2007-09-09 13:00:45 -030044#define DVB_PLL_MAX 64
Michael Krufky05a46112007-09-07 18:19:57 -030045
46static unsigned int dvb_pll_devcount;
47
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030048static int debug;
Michael Krufky05a46112007-09-07 18:19:57 -030049module_param(debug, int, 0644);
50MODULE_PARM_DESC(debug, "enable verbose debug messages");
51
Michael Krufky704e39b2007-09-07 18:27:43 -030052static unsigned int id[DVB_PLL_MAX] =
53 { [ 0 ... (DVB_PLL_MAX-1) ] = DVB_PLL_UNDEFINED };
54module_param_array(id, int, NULL, 0644);
55MODULE_PARM_DESC(id, "force pll id to use (DEBUG ONLY)");
56
Michael Krufky05a46112007-09-07 18:19:57 -030057/* ----------------------------------------------------------- */
58
Michael Krufky47a99912007-06-12 16:10:51 -030059struct dvb_pll_desc {
60 char *name;
61 u32 min;
62 u32 max;
63 u32 iffreq;
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -030064 void (*set)(struct dvb_frontend *fe, u8 *buf);
Michael Krufky47a99912007-06-12 16:10:51 -030065 u8 *initdata;
Malcolm Priestley2b743342011-02-06 12:29:51 -030066 u8 *initdata2;
Michael Krufky47a99912007-06-12 16:10:51 -030067 u8 *sleepdata;
68 int count;
69 struct {
70 u32 limit;
71 u32 stepsize;
72 u8 config;
73 u8 cb;
74 } entries[12];
75};
76
Linus Torvalds1da177e2005-04-16 15:20:36 -070077/* ----------------------------------------------------------- */
78/* descriptions */
79
Michael Krufky47a99912007-06-12 16:10:51 -030080static struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 .name = "Thomson dtt7579",
82 .min = 177000000,
83 .max = 858000000,
Trent Piephodf78cb02007-03-19 02:24:04 -030084 .iffreq= 36166667,
Trent Piephod519dcf2007-03-19 02:24:09 -030085 .sleepdata = (u8[]){ 2, 0xb4, 0x03 },
86 .count = 4,
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 .entries = {
Trent Piephodf78cb02007-03-19 02:24:04 -030088 { 443250000, 166667, 0xb4, 0x02 },
89 { 542000000, 166667, 0xb4, 0x08 },
90 { 771000000, 166667, 0xbc, 0x08 },
91 { 999999999, 166667, 0xf4, 0x08 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 },
93};
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -030095static void thomson_dtt759x_bw(struct dvb_frontend *fe, u8 *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096{
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -030097 u32 bw = fe->dtv_property_cache.bandwidth_hz;
98 if (bw == 7000000)
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 buf[3] |= 0x10;
100}
101
Michael Krufky47a99912007-06-12 16:10:51 -0300102static struct dvb_pll_desc dvb_pll_thomson_dtt759x = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 .name = "Thomson dtt759x",
104 .min = 177000000,
105 .max = 896000000,
Michael Krufky77d67502007-05-05 12:05:39 -0300106 .set = thomson_dtt759x_bw,
Trent Piephodf78cb02007-03-19 02:24:04 -0300107 .iffreq= 36166667,
Trent Piephod519dcf2007-03-19 02:24:09 -0300108 .sleepdata = (u8[]){ 2, 0x84, 0x03 },
109 .count = 5,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 .entries = {
Trent Piephodf78cb02007-03-19 02:24:04 -0300111 { 264000000, 166667, 0xb4, 0x02 },
112 { 470000000, 166667, 0xbc, 0x02 },
113 { 735000000, 166667, 0xbc, 0x08 },
114 { 835000000, 166667, 0xf4, 0x08 },
115 { 999999999, 166667, 0xfc, 0x08 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 },
117};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
Patrice Chotard5fb67072012-07-31 15:31:20 -0300119static void thomson_dtt7520x_bw(struct dvb_frontend *fe, u8 *buf)
120{
121 u32 bw = fe->dtv_property_cache.bandwidth_hz;
122 if (bw == 8000000)
123 buf[3] ^= 0x10;
124}
125
126static struct dvb_pll_desc dvb_pll_thomson_dtt7520x = {
127 .name = "Thomson dtt7520x",
128 .min = 185000000,
129 .max = 900000000,
130 .set = thomson_dtt7520x_bw,
131 .iffreq = 36166667,
132 .count = 7,
133 .entries = {
134 { 305000000, 166667, 0xb4, 0x12 },
135 { 405000000, 166667, 0xbc, 0x12 },
136 { 445000000, 166667, 0xbc, 0x12 },
137 { 465000000, 166667, 0xf4, 0x18 },
138 { 735000000, 166667, 0xfc, 0x18 },
139 { 835000000, 166667, 0xbc, 0x18 },
140 { 999999999, 166667, 0xfc, 0x18 },
141 },
142};
143
Michael Krufky47a99912007-06-12 16:10:51 -0300144static struct dvb_pll_desc dvb_pll_lg_z201 = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 .name = "LG z201",
146 .min = 174000000,
147 .max = 862000000,
Trent Piephodf78cb02007-03-19 02:24:04 -0300148 .iffreq= 36166667,
Trent Piephod519dcf2007-03-19 02:24:09 -0300149 .sleepdata = (u8[]){ 2, 0xbc, 0x03 },
150 .count = 5,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 .entries = {
Trent Piephodf78cb02007-03-19 02:24:04 -0300152 { 157500000, 166667, 0xbc, 0x01 },
153 { 443250000, 166667, 0xbc, 0x02 },
154 { 542000000, 166667, 0xbc, 0x04 },
155 { 830000000, 166667, 0xf4, 0x04 },
156 { 999999999, 166667, 0xfc, 0x04 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 },
158};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
Michael Krufky47a99912007-06-12 16:10:51 -0300160static struct dvb_pll_desc dvb_pll_unknown_1 = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 .name = "unknown 1", /* used by dntv live dvb-t */
162 .min = 174000000,
163 .max = 862000000,
Trent Piephodf78cb02007-03-19 02:24:04 -0300164 .iffreq= 36166667,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 .count = 9,
166 .entries = {
Trent Piephodf78cb02007-03-19 02:24:04 -0300167 { 150000000, 166667, 0xb4, 0x01 },
168 { 173000000, 166667, 0xbc, 0x01 },
169 { 250000000, 166667, 0xb4, 0x02 },
170 { 400000000, 166667, 0xbc, 0x02 },
171 { 420000000, 166667, 0xf4, 0x02 },
172 { 470000000, 166667, 0xfc, 0x02 },
173 { 600000000, 166667, 0xbc, 0x08 },
174 { 730000000, 166667, 0xf4, 0x08 },
175 { 999999999, 166667, 0xfc, 0x08 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 },
177};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700179/* Infineon TUA6010XS
180 * used in Thomson Cable Tuner
181 */
Michael Krufky47a99912007-06-12 16:10:51 -0300182static struct dvb_pll_desc dvb_pll_tua6010xs = {
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700183 .name = "Infineon TUA6010XS",
184 .min = 44250000,
185 .max = 858000000,
Trent Piephodf78cb02007-03-19 02:24:04 -0300186 .iffreq= 36125000,
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700187 .count = 3,
188 .entries = {
Trent Piephodf78cb02007-03-19 02:24:04 -0300189 { 115750000, 62500, 0x8e, 0x03 },
190 { 403250000, 62500, 0x8e, 0x06 },
191 { 999999999, 62500, 0x8e, 0x85 },
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700192 },
193};
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700194
195/* Panasonic env57h1xd5 (some Philips PLL ?) */
Michael Krufky47a99912007-06-12 16:10:51 -0300196static struct dvb_pll_desc dvb_pll_env57h1xd5 = {
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700197 .name = "Panasonic ENV57H1XD5",
198 .min = 44250000,
199 .max = 858000000,
Trent Piephodf78cb02007-03-19 02:24:04 -0300200 .iffreq= 36125000,
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700201 .count = 4,
202 .entries = {
Trent Piephodf78cb02007-03-19 02:24:04 -0300203 { 153000000, 166667, 0xc2, 0x41 },
204 { 470000000, 166667, 0xc2, 0x42 },
205 { 526000000, 166667, 0xc2, 0x84 },
206 { 999999999, 166667, 0xc2, 0xa4 },
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700207 },
208};
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700209
210/* Philips TDA6650/TDA6651
211 * used in Panasonic ENV77H11D5
212 */
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300213static void tda665x_bw(struct dvb_frontend *fe, u8 *buf)
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700214{
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300215 u32 bw = fe->dtv_property_cache.bandwidth_hz;
216 if (bw == 8000000)
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700217 buf[3] |= 0x08;
218}
219
Michael Krufky47a99912007-06-12 16:10:51 -0300220static struct dvb_pll_desc dvb_pll_tda665x = {
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700221 .name = "Philips TDA6650/TDA6651",
222 .min = 44250000,
223 .max = 858000000,
Michael Krufky77d67502007-05-05 12:05:39 -0300224 .set = tda665x_bw,
Trent Piephodf78cb02007-03-19 02:24:04 -0300225 .iffreq= 36166667,
Michael Krufkyfbfee862007-05-09 15:58:17 -0300226 .initdata = (u8[]){ 4, 0x0b, 0xf5, 0x85, 0xab },
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700227 .count = 12,
228 .entries = {
Trent Piephodf78cb02007-03-19 02:24:04 -0300229 { 93834000, 166667, 0xca, 0x61 /* 011 0 0 0 01 */ },
230 { 123834000, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
231 { 161000000, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
232 { 163834000, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
233 { 253834000, 166667, 0xca, 0x62 /* 011 0 0 0 10 */ },
234 { 383834000, 166667, 0xca, 0xa2 /* 101 0 0 0 10 */ },
235 { 443834000, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
236 { 444000000, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ },
237 { 583834000, 166667, 0xca, 0x64 /* 011 0 0 1 00 */ },
238 { 793834000, 166667, 0xca, 0xa4 /* 101 0 0 1 00 */ },
239 { 444834000, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ },
240 { 861000000, 166667, 0xca, 0xe4 /* 111 0 0 1 00 */ },
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700241 }
242};
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700243
244/* Infineon TUA6034
245 * used in LG TDTP E102P
246 */
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300247static void tua6034_bw(struct dvb_frontend *fe, u8 *buf)
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700248{
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300249 u32 bw = fe->dtv_property_cache.bandwidth_hz;
250 if (bw == 7000000)
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700251 buf[3] |= 0x08;
252}
253
Michael Krufky47a99912007-06-12 16:10:51 -0300254static struct dvb_pll_desc dvb_pll_tua6034 = {
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700255 .name = "Infineon TUA6034",
256 .min = 44250000,
257 .max = 858000000,
Trent Piephodf78cb02007-03-19 02:24:04 -0300258 .iffreq= 36166667,
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700259 .count = 3,
Michael Krufky77d67502007-05-05 12:05:39 -0300260 .set = tua6034_bw,
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700261 .entries = {
Trent Piephodf78cb02007-03-19 02:24:04 -0300262 { 174500000, 62500, 0xce, 0x01 },
263 { 230000000, 62500, 0xce, 0x02 },
264 { 999999999, 62500, 0xce, 0x04 },
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700265 },
266};
Johannes Stezenbach776338e2005-06-23 22:02:35 -0700267
Patrick Boettcher0589b8e2005-07-07 17:58:12 -0700268/* ALPS TDED4
269 * used in Nebula-Cards and USB boxes
270 */
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300271static void tded4_bw(struct dvb_frontend *fe, u8 *buf)
Patrick Boettcher0589b8e2005-07-07 17:58:12 -0700272{
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300273 u32 bw = fe->dtv_property_cache.bandwidth_hz;
274 if (bw == 8000000)
Patrick Boettcher0589b8e2005-07-07 17:58:12 -0700275 buf[3] |= 0x04;
276}
277
Michael Krufky47a99912007-06-12 16:10:51 -0300278static struct dvb_pll_desc dvb_pll_tded4 = {
Patrick Boettcher0589b8e2005-07-07 17:58:12 -0700279 .name = "ALPS TDED4",
280 .min = 47000000,
281 .max = 863000000,
Trent Piephodf78cb02007-03-19 02:24:04 -0300282 .iffreq= 36166667,
Michael Krufky77d67502007-05-05 12:05:39 -0300283 .set = tded4_bw,
Patrick Boettcher0589b8e2005-07-07 17:58:12 -0700284 .count = 4,
285 .entries = {
Trent Piephodf78cb02007-03-19 02:24:04 -0300286 { 153000000, 166667, 0x85, 0x01 },
287 { 470000000, 166667, 0x85, 0x02 },
288 { 823000000, 166667, 0x85, 0x08 },
289 { 999999999, 166667, 0x85, 0x88 },
Patrick Boettcher0589b8e2005-07-07 17:58:12 -0700290 }
291};
Patrick Boettcher0589b8e2005-07-07 17:58:12 -0700292
Kirk Lapray147418c2005-11-08 21:35:39 -0800293/* ALPS TDHU2
294 * used in AverTVHD MCE A180
295 */
Michael Krufky47a99912007-06-12 16:10:51 -0300296static struct dvb_pll_desc dvb_pll_tdhu2 = {
Kirk Lapray147418c2005-11-08 21:35:39 -0800297 .name = "ALPS TDHU2",
298 .min = 54000000,
299 .max = 864000000,
Trent Piephodf78cb02007-03-19 02:24:04 -0300300 .iffreq= 44000000,
Kirk Lapray147418c2005-11-08 21:35:39 -0800301 .count = 4,
302 .entries = {
Trent Piephodf78cb02007-03-19 02:24:04 -0300303 { 162000000, 62500, 0x85, 0x01 },
304 { 426000000, 62500, 0x85, 0x02 },
305 { 782000000, 62500, 0x85, 0x08 },
306 { 999999999, 62500, 0x85, 0x88 },
Kirk Lapray147418c2005-11-08 21:35:39 -0800307 }
308};
Kirk Lapray147418c2005-11-08 21:35:39 -0800309
Michael Krufkyd76a6172006-01-23 17:11:06 -0200310/* Samsung TBMV30111IN / TBMV30712IN1
Kirk Lapray147418c2005-11-08 21:35:39 -0800311 * used in Air2PC ATSC - 2nd generation (nxt2002)
312 */
Michael Krufky47a99912007-06-12 16:10:51 -0300313static struct dvb_pll_desc dvb_pll_samsung_tbmv = {
Michael Krufky28f3d4b2006-01-23 17:11:07 -0200314 .name = "Samsung TBMV30111IN / TBMV30712IN1",
Kirk Lapray147418c2005-11-08 21:35:39 -0800315 .min = 54000000,
316 .max = 860000000,
Trent Piephodf78cb02007-03-19 02:24:04 -0300317 .iffreq= 44000000,
Michael Krufky17c37ef2006-01-15 19:04:04 -0200318 .count = 6,
Kirk Lapray147418c2005-11-08 21:35:39 -0800319 .entries = {
Trent Piephodf78cb02007-03-19 02:24:04 -0300320 { 172000000, 166667, 0xb4, 0x01 },
321 { 214000000, 166667, 0xb4, 0x02 },
322 { 467000000, 166667, 0xbc, 0x02 },
323 { 721000000, 166667, 0xbc, 0x08 },
324 { 841000000, 166667, 0xf4, 0x08 },
325 { 999999999, 166667, 0xfc, 0x02 },
Kirk Lapray147418c2005-11-08 21:35:39 -0800326 }
327};
Kirk Lapray147418c2005-11-08 21:35:39 -0800328
Regis Prevotf8bf1342006-01-11 23:31:53 -0200329/*
330 * Philips SD1878 Tuner.
331 */
Michael Krufky47a99912007-06-12 16:10:51 -0300332static struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = {
Regis Prevotf8bf1342006-01-11 23:31:53 -0200333 .name = "Philips SD1878",
334 .min = 950000,
335 .max = 2150000,
Trent Piephodf78cb02007-03-19 02:24:04 -0300336 .iffreq= 249, /* zero-IF, offset 249 is to round up */
Regis Prevotf8bf1342006-01-11 23:31:53 -0200337 .count = 4,
338 .entries = {
Trent Piephodf78cb02007-03-19 02:24:04 -0300339 { 1250000, 500, 0xc4, 0x00},
Manu Abrahamb3332a92007-07-03 09:58:57 -0300340 { 1450000, 500, 0xc4, 0x40},
Trent Piephodf78cb02007-03-19 02:24:04 -0300341 { 2050000, 500, 0xc4, 0x80},
342 { 2150000, 500, 0xc4, 0xc0},
Regis Prevotf8bf1342006-01-11 23:31:53 -0200343 },
344};
Regis Prevotf8bf1342006-01-11 23:31:53 -0200345
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300346static void opera1_bw(struct dvb_frontend *fe, u8 *buf)
Marco Gittler941491f2007-04-19 11:26:47 -0300347{
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300348 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
Malcolm Priestley2b743342011-02-06 12:29:51 -0300349 struct dvb_pll_priv *priv = fe->tuner_priv;
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300350 u32 b_w = (c->symbol_rate * 27) / 32000;
Malcolm Priestley2b743342011-02-06 12:29:51 -0300351 struct i2c_msg msg = {
352 .addr = priv->pll_i2c_address,
353 .flags = 0,
354 .buf = buf,
355 .len = 4
356 };
357 int result;
358 u8 lpf;
359
360 if (fe->ops.i2c_gate_ctrl)
361 fe->ops.i2c_gate_ctrl(fe, 1);
362
363 result = i2c_transfer(priv->i2c, &msg, 1);
364 if (result != 1)
365 printk(KERN_ERR "%s: i2c_transfer failed:%d",
366 __func__, result);
367
368 if (b_w <= 10000)
369 lpf = 0xc;
370 else if (b_w <= 12000)
371 lpf = 0x2;
372 else if (b_w <= 14000)
373 lpf = 0xa;
374 else if (b_w <= 16000)
375 lpf = 0x6;
376 else if (b_w <= 18000)
377 lpf = 0xe;
378 else if (b_w <= 20000)
379 lpf = 0x1;
380 else if (b_w <= 22000)
381 lpf = 0x9;
382 else if (b_w <= 24000)
383 lpf = 0x5;
384 else if (b_w <= 26000)
385 lpf = 0xd;
386 else if (b_w <= 28000)
387 lpf = 0x3;
388 else
389 lpf = 0xb;
390 buf[2] ^= 0x1c; /* Flip bits 3-5 */
391 /* Set lpf */
392 buf[2] |= ((lpf >> 2) & 0x3) << 3;
393 buf[3] |= (lpf & 0x3) << 2;
394
395 return;
Marco Gittler941491f2007-04-19 11:26:47 -0300396}
397
Michael Krufky47a99912007-06-12 16:10:51 -0300398static struct dvb_pll_desc dvb_pll_opera1 = {
Marco Gittler941491f2007-04-19 11:26:47 -0300399 .name = "Opera Tuner",
400 .min = 900000,
401 .max = 2250000,
Malcolm Priestley2b743342011-02-06 12:29:51 -0300402 .initdata = (u8[]){ 4, 0x08, 0xe5, 0xe1, 0x00 },
403 .initdata2 = (u8[]){ 4, 0x08, 0xe5, 0xe5, 0x00 },
Marco Gittler941491f2007-04-19 11:26:47 -0300404 .iffreq= 0,
Michael Krufky77d67502007-05-05 12:05:39 -0300405 .set = opera1_bw,
Marco Gittler941491f2007-04-19 11:26:47 -0300406 .count = 8,
407 .entries = {
Malcolm Priestley2b743342011-02-06 12:29:51 -0300408 { 1064000, 500, 0xf9, 0xc2 },
409 { 1169000, 500, 0xf9, 0xe2 },
410 { 1299000, 500, 0xf9, 0x20 },
411 { 1444000, 500, 0xf9, 0x40 },
412 { 1606000, 500, 0xf9, 0x60 },
413 { 1777000, 500, 0xf9, 0x80 },
414 { 1941000, 500, 0xf9, 0xa0 },
415 { 2250000, 500, 0xf9, 0xc0 },
Marco Gittler941491f2007-04-19 11:26:47 -0300416 }
417};
Michael Krufky47a99912007-06-12 16:10:51 -0300418
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300419static void samsung_dtos403ih102a_set(struct dvb_frontend *fe, u8 *buf)
Antti Palosaari139dfeb2008-05-17 23:02:00 -0300420{
421 struct dvb_pll_priv *priv = fe->tuner_priv;
422 struct i2c_msg msg = {
423 .addr = priv->pll_i2c_address,
424 .flags = 0,
425 .buf = buf,
426 .len = 4
427 };
428 int result;
429
430 if (fe->ops.i2c_gate_ctrl)
431 fe->ops.i2c_gate_ctrl(fe, 1);
432
433 result = i2c_transfer(priv->i2c, &msg, 1);
434 if (result != 1)
435 printk(KERN_ERR "%s: i2c_transfer failed:%d",
436 __func__, result);
437
438 buf[2] = 0x9e;
439 buf[3] = 0x90;
440
441 return;
442}
443
444/* unknown pll used in Samsung DTOS403IH102A DVB-C tuner */
445static struct dvb_pll_desc dvb_pll_samsung_dtos403ih102a = {
446 .name = "Samsung DTOS403IH102A",
447 .min = 44250000,
448 .max = 858000000,
449 .iffreq = 36125000,
450 .count = 8,
451 .set = samsung_dtos403ih102a_set,
452 .entries = {
453 { 135000000, 62500, 0xbe, 0x01 },
454 { 177000000, 62500, 0xf6, 0x01 },
455 { 370000000, 62500, 0xbe, 0x02 },
456 { 450000000, 62500, 0xf6, 0x02 },
457 { 466000000, 62500, 0xfe, 0x02 },
458 { 538000000, 62500, 0xbe, 0x08 },
459 { 826000000, 62500, 0xf6, 0x08 },
460 { 999999999, 62500, 0xfe, 0x08 },
461 }
462};
463
Trent Piephoa104ed02009-06-11 19:21:34 -0300464/* Samsung TDTC9251DH0 DVB-T NIM, as used on AirStar 2 */
465static struct dvb_pll_desc dvb_pll_samsung_tdtc9251dh0 = {
466 .name = "Samsung TDTC9251DH0",
467 .min = 48000000,
468 .max = 863000000,
469 .iffreq = 36166667,
470 .count = 3,
471 .entries = {
472 { 157500000, 166667, 0xcc, 0x09 },
473 { 443000000, 166667, 0xcc, 0x0a },
474 { 863000000, 166667, 0xcc, 0x08 },
475 }
476};
477
Trent Piephof52c4852009-06-11 19:21:34 -0300478/* Samsung TBDU18132 DVB-S NIM with TSA5059 PLL, used in SkyStar2 DVB-S 2.3 */
479static struct dvb_pll_desc dvb_pll_samsung_tbdu18132 = {
480 .name = "Samsung TBDU18132",
481 .min = 950000,
482 .max = 2150000, /* guesses */
483 .iffreq = 0,
484 .count = 2,
485 .entries = {
486 { 1550000, 125, 0x84, 0x82 },
487 { 4095937, 125, 0x84, 0x80 },
488 }
489 /* TSA5059 PLL has a 17 bit divisor rather than the 15 bits supported
490 * by this driver. The two extra bits are 0x60 in the third byte. 15
491 * bits is enough for over 4 GHz, which is enough to cover the range
492 * of this tuner. We could use the additional divisor bits by adding
493 * more entries, e.g.
494 { 0x0ffff * 125 + 125/2, 125, 0x84 | 0x20, },
495 { 0x17fff * 125 + 125/2, 125, 0x84 | 0x40, },
496 { 0x1ffff * 125 + 125/2, 125, 0x84 | 0x60, }, */
497};
498
Trent Piepho9d5d75a2009-06-11 19:21:34 -0300499/* Samsung TBMU24112 DVB-S NIM with SL1935 zero-IF tuner */
500static struct dvb_pll_desc dvb_pll_samsung_tbmu24112 = {
501 .name = "Samsung TBMU24112",
502 .min = 950000,
503 .max = 2150000, /* guesses */
504 .iffreq = 0,
505 .count = 2,
506 .entries = {
507 { 1500000, 125, 0x84, 0x18 },
508 { 9999999, 125, 0x84, 0x08 },
509 }
510};
511
Trent Piephod799ce52009-06-11 19:24:00 -0300512/* Alps TDEE4 DVB-C NIM, used on Cablestar 2 */
513/* byte 4 : 1 * * AGD R3 R2 R1 R0
514 * byte 5 : C1 * RE RTS BS4 BS3 BS2 BS1
515 * AGD = 1, R3 R2 R1 R0 = 0 1 0 1 => byte 4 = 1**10101 = 0x95
516 * Range(MHz) C1 * RE RTS BS4 BS3 BS2 BS1 Byte 5
517 * 47 - 153 0 * 0 0 0 0 0 1 0x01
518 * 153 - 430 0 * 0 0 0 0 1 0 0x02
519 * 430 - 822 0 * 0 0 1 0 0 0 0x08
520 * 822 - 862 1 * 0 0 1 0 0 0 0x88 */
521static struct dvb_pll_desc dvb_pll_alps_tdee4 = {
522 .name = "ALPS TDEE4",
523 .min = 47000000,
524 .max = 862000000,
525 .iffreq = 36125000,
526 .count = 4,
527 .entries = {
528 { 153000000, 62500, 0x95, 0x01 },
529 { 430000000, 62500, 0x95, 0x02 },
530 { 822000000, 62500, 0x95, 0x08 },
531 { 999999999, 62500, 0x95, 0x88 },
532 }
533};
534
Michael Krufky47a99912007-06-12 16:10:51 -0300535/* ----------------------------------------------------------- */
536
537static struct dvb_pll_desc *pll_list[] = {
538 [DVB_PLL_UNDEFINED] = NULL,
539 [DVB_PLL_THOMSON_DTT7579] = &dvb_pll_thomson_dtt7579,
540 [DVB_PLL_THOMSON_DTT759X] = &dvb_pll_thomson_dtt759x,
Patrice Chotard5fb67072012-07-31 15:31:20 -0300541 [DVB_PLL_THOMSON_DTT7520X] = &dvb_pll_thomson_dtt7520x,
Michael Krufky47a99912007-06-12 16:10:51 -0300542 [DVB_PLL_LG_Z201] = &dvb_pll_lg_z201,
Michael Krufky47a99912007-06-12 16:10:51 -0300543 [DVB_PLL_UNKNOWN_1] = &dvb_pll_unknown_1,
544 [DVB_PLL_TUA6010XS] = &dvb_pll_tua6010xs,
545 [DVB_PLL_ENV57H1XD5] = &dvb_pll_env57h1xd5,
546 [DVB_PLL_TUA6034] = &dvb_pll_tua6034,
Michael Krufky47a99912007-06-12 16:10:51 -0300547 [DVB_PLL_TDA665X] = &dvb_pll_tda665x,
Michael Krufky47a99912007-06-12 16:10:51 -0300548 [DVB_PLL_TDED4] = &dvb_pll_tded4,
Trent Piephod799ce52009-06-11 19:24:00 -0300549 [DVB_PLL_TDEE4] = &dvb_pll_alps_tdee4,
Michael Krufky47a99912007-06-12 16:10:51 -0300550 [DVB_PLL_TDHU2] = &dvb_pll_tdhu2,
551 [DVB_PLL_SAMSUNG_TBMV] = &dvb_pll_samsung_tbmv,
552 [DVB_PLL_PHILIPS_SD1878_TDA8261] = &dvb_pll_philips_sd1878_tda8261,
Michael Krufky47a99912007-06-12 16:10:51 -0300553 [DVB_PLL_OPERA1] = &dvb_pll_opera1,
Antti Palosaari139dfeb2008-05-17 23:02:00 -0300554 [DVB_PLL_SAMSUNG_DTOS403IH102A] = &dvb_pll_samsung_dtos403ih102a,
Trent Piephoa104ed02009-06-11 19:21:34 -0300555 [DVB_PLL_SAMSUNG_TDTC9251DH0] = &dvb_pll_samsung_tdtc9251dh0,
Trent Piephof52c4852009-06-11 19:21:34 -0300556 [DVB_PLL_SAMSUNG_TBDU18132] = &dvb_pll_samsung_tbdu18132,
Trent Piepho9d5d75a2009-06-11 19:21:34 -0300557 [DVB_PLL_SAMSUNG_TBMU24112] = &dvb_pll_samsung_tbmu24112,
Michael Krufky47a99912007-06-12 16:10:51 -0300558};
559
560/* ----------------------------------------------------------- */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561/* code */
562
Michael Krufky5d7802b2007-09-07 18:03:58 -0300563static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf,
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300564 const u32 frequency)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565{
Michael Krufky5d7802b2007-09-07 18:03:58 -0300566 struct dvb_pll_priv *priv = fe->tuner_priv;
567 struct dvb_pll_desc *desc = priv->pll_desc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 u32 div;
569 int i;
570
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300571 if (frequency && (frequency < desc->min || frequency > desc->max))
Michael Krufky77d67502007-05-05 12:05:39 -0300572 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573
574 for (i = 0; i < desc->count; i++) {
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300575 if (frequency > desc->entries[i].limit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 continue;
577 break;
578 }
Michael Krufky77d67502007-05-05 12:05:39 -0300579
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 if (debug)
Michael Krufky77d67502007-05-05 12:05:39 -0300581 printk("pll: %s: freq=%d | i=%d/%d\n", desc->name,
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300582 frequency, i, desc->count);
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300583 if (i == desc->count)
584 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300586 div = (frequency + desc->iffreq +
Michael Krufky77d67502007-05-05 12:05:39 -0300587 desc->entries[i].stepsize/2) / desc->entries[i].stepsize;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 buf[0] = div >> 8;
589 buf[1] = div & 0xff;
Michael Krufkyab66b222006-01-23 17:11:11 -0200590 buf[2] = desc->entries[i].config;
591 buf[3] = desc->entries[i].cb;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592
Michael Krufky77d67502007-05-05 12:05:39 -0300593 if (desc->set)
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300594 desc->set(fe, buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595
596 if (debug)
597 printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
598 desc->name, div, buf[0], buf[1], buf[2], buf[3]);
599
Michael Krufky89faeef2006-11-20 16:45:29 -0300600 // calculate the frequency we set it to
Trent Piephodf78cb02007-03-19 02:24:04 -0300601 return (div * desc->entries[i].stepsize) - desc->iffreq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300604static int dvb_pll_release(struct dvb_frontend *fe)
605{
Michael Krufky22139182006-11-19 19:49:11 -0300606 kfree(fe->tuner_priv);
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300607 fe->tuner_priv = NULL;
608 return 0;
609}
610
611static int dvb_pll_sleep(struct dvb_frontend *fe)
612{
613 struct dvb_pll_priv *priv = fe->tuner_priv;
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300614
Chris Pascoec162dff2006-08-08 15:48:08 -0300615 if (priv->i2c == NULL)
616 return -EINVAL;
617
Trent Piephod519dcf2007-03-19 02:24:09 -0300618 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] };
623
624 int result;
625
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) {
629 return result;
630 }
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300631 return 0;
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300632 }
Trent Piephod519dcf2007-03-19 02:24:09 -0300633 /* Shouldn't be called when initdata is NULL, maybe BUG()? */
634 return -EINVAL;
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300635}
636
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300637static int dvb_pll_set_params(struct dvb_frontend *fe)
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300638{
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300639 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300640 struct dvb_pll_priv *priv = fe->tuner_priv;
641 u8 buf[4];
642 struct i2c_msg msg =
Michael Krufky47ae9ae2006-11-20 16:38:42 -0300643 { .addr = priv->pll_i2c_address, .flags = 0,
644 .buf = buf, .len = sizeof(buf) };
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300645 int result;
Michael Krufky77d67502007-05-05 12:05:39 -0300646 u32 frequency = 0;
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300647
648 if (priv->i2c == NULL)
649 return -EINVAL;
650
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300651 result = dvb_pll_configure(fe, buf, c->frequency);
652 if (result < 0)
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300653 return result;
Michael Krufky89faeef2006-11-20 16:45:29 -0300654 else
655 frequency = result;
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300656
Patrick Boettcherdea74862006-05-14 05:01:31 -0300657 if (fe->ops.i2c_gate_ctrl)
658 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300659 if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) {
660 return result;
661 }
662
Michael Krufky89faeef2006-11-20 16:45:29 -0300663 priv->frequency = frequency;
Mauro Carvalho Chehabc6f56e72011-12-26 20:02:28 -0300664 priv->bandwidth = c->bandwidth_hz;
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300665
666 return 0;
667}
668
Michael Krufky47ae9ae2006-11-20 16:38:42 -0300669static int dvb_pll_calc_regs(struct dvb_frontend *fe,
Michael Krufky47ae9ae2006-11-20 16:38:42 -0300670 u8 *buf, int buf_len)
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300671{
Mauro Carvalho Chehab249fa0b2011-12-24 12:03:05 -0300672 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300673 struct dvb_pll_priv *priv = fe->tuner_priv;
674 int result;
Michael Krufky77d67502007-05-05 12:05:39 -0300675 u32 frequency = 0;
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300676
677 if (buf_len < 5)
678 return -EINVAL;
679
Mauro Carvalho Chehab249fa0b2011-12-24 12:03:05 -0300680 result = dvb_pll_configure(fe, buf + 1, c->frequency);
Mauro Carvalho Chehab80d8d492011-12-21 11:16:39 -0300681 if (result < 0)
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300682 return result;
Michael Krufky89faeef2006-11-20 16:45:29 -0300683 else
684 frequency = result;
685
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300686 buf[0] = priv->pll_i2c_address;
687
Michael Krufky89faeef2006-11-20 16:45:29 -0300688 priv->frequency = frequency;
Mauro Carvalho Chehab249fa0b2011-12-24 12:03:05 -0300689 priv->bandwidth = c->bandwidth_hz;
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300690
691 return 5;
692}
693
694static int dvb_pll_get_frequency(struct dvb_frontend *fe, u32 *frequency)
695{
696 struct dvb_pll_priv *priv = fe->tuner_priv;
697 *frequency = priv->frequency;
698 return 0;
699}
700
701static int dvb_pll_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
702{
703 struct dvb_pll_priv *priv = fe->tuner_priv;
704 *bandwidth = priv->bandwidth;
705 return 0;
706}
707
Trent Piepho26aed922007-04-27 12:31:29 -0300708static int dvb_pll_init(struct dvb_frontend *fe)
709{
710 struct dvb_pll_priv *priv = fe->tuner_priv;
711
712 if (priv->i2c == NULL)
713 return -EINVAL;
714
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] };
720
721 int result;
722 if (fe->ops.i2c_gate_ctrl)
723 fe->ops.i2c_gate_ctrl(fe, 1);
Malcolm Priestley2b743342011-02-06 12:29:51 -0300724 result = i2c_transfer(priv->i2c, &msg, 1);
725 if (result != 1)
Trent Piepho26aed922007-04-27 12:31:29 -0300726 return result;
Malcolm Priestley2b743342011-02-06 12:29:51 -0300727 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);
733 if (result != 1)
734 return result;
Trent Piepho26aed922007-04-27 12:31:29 -0300735 }
736 return 0;
737 }
738 /* Shouldn't be called when initdata is NULL, maybe BUG()? */
739 return -EINVAL;
740}
741
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300742static struct dvb_tuner_ops dvb_pll_tuner_ops = {
743 .release = dvb_pll_release,
744 .sleep = dvb_pll_sleep,
Trent Piephod519dcf2007-03-19 02:24:09 -0300745 .init = dvb_pll_init,
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300746 .set_params = dvb_pll_set_params,
Andrew de Quinceybd4956b2006-04-18 21:38:49 -0300747 .calc_regs = dvb_pll_calc_regs,
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300748 .get_frequency = dvb_pll_get_frequency,
749 .get_bandwidth = dvb_pll_get_bandwidth,
750};
751
Michael Krufky47ae9ae2006-11-20 16:38:42 -0300752struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr,
753 struct i2c_adapter *i2c,
Michael Krufky47a99912007-06-12 16:10:51 -0300754 unsigned int pll_desc_id)
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300755{
Andrew de Quincey061b6232006-07-10 03:34:14 -0300756 u8 b1 [] = { 0 };
Michael Krufky47ae9ae2006-11-20 16:38:42 -0300757 struct i2c_msg msg = { .addr = pll_addr, .flags = I2C_M_RD,
758 .buf = b1, .len = 1 };
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300759 struct dvb_pll_priv *priv = NULL;
Andrew de Quincey061b6232006-07-10 03:34:14 -0300760 int ret;
Michael Krufky47a99912007-06-12 16:10:51 -0300761 struct dvb_pll_desc *desc;
762
Michael Krufky704e39b2007-09-07 18:27:43 -0300763 if ((id[dvb_pll_devcount] > DVB_PLL_UNDEFINED) &&
764 (id[dvb_pll_devcount] < ARRAY_SIZE(pll_list)))
765 pll_desc_id = id[dvb_pll_devcount];
766
Michael Krufky47a99912007-06-12 16:10:51 -0300767 BUG_ON(pll_desc_id < 1 || pll_desc_id >= ARRAY_SIZE(pll_list));
768
769 desc = pll_list[pll_desc_id];
Andrew de Quincey061b6232006-07-10 03:34:14 -0300770
Andrew de Quincey55c05b62006-07-16 19:41:41 -0300771 if (i2c != NULL) {
772 if (fe->ops.i2c_gate_ctrl)
773 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quincey061b6232006-07-10 03:34:14 -0300774
Andrew de Quincey95faba22006-07-18 16:37:13 -0300775 ret = i2c_transfer (i2c, &msg, 1);
776 if (ret != 1)
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300777 return NULL;
Andrew de Quincey55c05b62006-07-16 19:41:41 -0300778 if (fe->ops.i2c_gate_ctrl)
779 fe->ops.i2c_gate_ctrl(fe, 0);
780 }
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300781
782 priv = kzalloc(sizeof(struct dvb_pll_priv), GFP_KERNEL);
783 if (priv == NULL)
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300784 return NULL;
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300785
786 priv->pll_i2c_address = pll_addr;
787 priv->i2c = i2c;
788 priv->pll_desc = desc;
Michael Krufkya27e5e72007-09-07 18:11:15 -0300789 priv->nr = dvb_pll_devcount++;
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300790
Michael Krufky47ae9ae2006-11-20 16:38:42 -0300791 memcpy(&fe->ops.tuner_ops, &dvb_pll_tuner_ops,
792 sizeof(struct dvb_tuner_ops));
793
Trent Piepho982dd1b2007-04-27 12:31:27 -0300794 strncpy(fe->ops.tuner_ops.info.name, desc->name,
795 sizeof(fe->ops.tuner_ops.info.name));
Patrick Boettcherdea74862006-05-14 05:01:31 -0300796 fe->ops.tuner_ops.info.frequency_min = desc->min;
Trent Piepho0d84a622007-08-17 18:36:44 -0300797 fe->ops.tuner_ops.info.frequency_max = desc->max;
Trent Piephod519dcf2007-03-19 02:24:09 -0300798 if (!desc->initdata)
799 fe->ops.tuner_ops.init = NULL;
800 if (!desc->sleepdata)
801 fe->ops.tuner_ops.sleep = NULL;
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300802
803 fe->tuner_priv = priv;
Michael Krufkya27e5e72007-09-07 18:11:15 -0300804
Michael Krufky8528fa42007-09-09 05:08:30 -0300805 if ((debug) || (id[priv->nr] == pll_desc_id)) {
Michael Krufkya27e5e72007-09-07 18:11:15 -0300806 printk("dvb-pll[%d]", priv->nr);
807 if (i2c != NULL)
808 printk(" %d-%04x", i2c_adapter_id(i2c), pll_addr);
Michael Krufky704e39b2007-09-07 18:27:43 -0300809 printk(": id# %d (%s) attached, %s\n", pll_desc_id, desc->name,
810 id[priv->nr] == pll_desc_id ?
811 "insmod option" : "autodetected");
Michael Krufky4562fbe2007-09-09 05:16:34 -0300812 }
Michael Krufkya27e5e72007-09-07 18:11:15 -0300813
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300814 return fe;
Andrew de Quincey272bc4d2006-04-18 17:47:12 -0300815}
816EXPORT_SYMBOL(dvb_pll_attach);
817
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818MODULE_DESCRIPTION("dvb pll library");
819MODULE_AUTHOR("Gerd Knorr");
820MODULE_LICENSE("GPL");