aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/b2c2
diff options
context:
space:
mode:
authorAndrew de Quincey <adq_dvb@lidskialf.net>2006-04-18 16:47:12 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-06-25 00:59:32 -0400
commit56e0314d7bf56ada38f16edc44bec61741975b4d (patch)
treeb97e11adbcd053175e49bd3ee4f8e03deb229467 /drivers/media/dvb/b2c2
parent30fa61a5ee91bc546f9ebea70c7abda04b5b3e1e (diff)
V4L/DVB (3886): Convert flexcop-fe-tuner to refactored tuner code
Rename pll calls to appropriate tuner calls. Remove pll functions from demod structures. Hook tuner call into tuner_ops. Attach dvb-pll where possible. Add pll gate control calls where appropriate. Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/b2c2')
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c81
1 files changed, 67 insertions, 14 deletions
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index 9f758042ea47..89ea76201506 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -167,11 +167,12 @@ static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend* fe, u32 srate,
167 return 0; 167 return 0;
168} 168}
169 169
170static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) 170static int samsung_tbmu24112_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
171{ 171{
172 u8 buf[4]; 172 u8 buf[4];
173 u32 div; 173 u32 div;
174 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) }; 174 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
175 struct flexcop_device *fc = fe->dvb->priv;
175 176
176 div = params->frequency / 125; 177 div = params->frequency / 125;
177 178
@@ -182,8 +183,11 @@ static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct i2c_adapter
182 183
183 if (params->frequency < 1500000) buf[3] |= 0x10; 184 if (params->frequency < 1500000) buf[3] |= 0x10;
184 185
185 if (i2c_transfer(i2c, &msg, 1) != 1) 186 if (fe->ops->i2c_gate_ctrl)
187 fe->ops->i2c_gate_ctrl(fe, 1);
188 if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) {
186 return -EIO; 189 return -EIO;
190 }
187 return 0; 191 return 0;
188} 192}
189 193
@@ -242,7 +246,6 @@ static struct stv0299_config samsung_tbmu24112_config = {
242 .volt13_op0_op1 = STV0299_VOLT13_OP1, 246 .volt13_op0_op1 = STV0299_VOLT13_OP1,
243 .min_delay_ms = 100, 247 .min_delay_ms = 100,
244 .set_symbol_rate = samsung_tbmu24112_set_symbol_rate, 248 .set_symbol_rate = samsung_tbmu24112_set_symbol_rate,
245 .pll_set = samsung_tbmu24112_pll_set,
246}; 249};
247 250
248/* dvb-t mt352 */ 251/* dvb-t mt352 */
@@ -265,11 +268,14 @@ static int samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
265 return 0; 268 return 0;
266} 269}
267 270
268static int samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf) 271static int samsung_tdtc9251dh0_calc_regs(struct dvb_frontend* fe, struct dvb_frontend_parameters *params, u8* pllbuf, int buf_len)
269{ 272{
270 u32 div; 273 u32 div;
271 unsigned char bs = 0; 274 unsigned char bs = 0;
272 275
276 if (buf_len < 5)
277 return -EINVAL;
278
273 #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ 279 #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
274 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; 280 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
275 281
@@ -277,19 +283,18 @@ static int samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct dvb_front
277 if (params->frequency >= 161000000 && params->frequency <= 439000000) bs = 0x0a; 283 if (params->frequency >= 161000000 && params->frequency <= 439000000) bs = 0x0a;
278 if (params->frequency >= 447000000 && params->frequency <= 863000000) bs = 0x08; 284 if (params->frequency >= 447000000 && params->frequency <= 863000000) bs = 0x08;
279 285
280 pllbuf[0] = 0xc2; /* Note: non-linux standard PLL i2c address */ 286 pllbuf[0] = 0x61;
281 pllbuf[1] = div >> 8; 287 pllbuf[1] = div >> 8;
282 pllbuf[2] = div & 0xff; 288 pllbuf[2] = div & 0xff;
283 pllbuf[3] = 0xcc; 289 pllbuf[3] = 0xcc;
284 pllbuf[4] = bs; 290 pllbuf[4] = bs;
285 291
286 return 0; 292 return 5;
287} 293}
288 294
289static struct mt352_config samsung_tdtc9251dh0_config = { 295static struct mt352_config samsung_tdtc9251dh0_config = {
290 .demod_address = 0x0f, 296 .demod_address = 0x0f,
291 .demod_init = samsung_tdtc9251dh0_demod_init, 297 .demod_init = samsung_tdtc9251dh0_demod_init,
292 .pll_set = samsung_tdtc9251dh0_pll_set,
293}; 298};
294 299
295static int flexcop_fe_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name) 300static int flexcop_fe_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
@@ -298,8 +303,7 @@ static int flexcop_fe_request_firmware(struct dvb_frontend* fe, const struct fir
298 return request_firmware(fw, name, fc->dev); 303 return request_firmware(fw, name, fc->dev);
299} 304}
300 305
301static int lgdt3303_pll_set(struct dvb_frontend* fe, 306static int lgdt3303_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
302 struct dvb_frontend_parameters* params)
303{ 307{
304 struct flexcop_device *fc = fe->dvb->priv; 308 struct flexcop_device *fc = fe->dvb->priv;
305 return lg_h06xf_pll_set(fe, &fc->i2c_adap, params); 309 return lg_h06xf_pll_set(fe, &fc->i2c_adap, params);
@@ -309,14 +313,11 @@ static struct lgdt330x_config air2pc_atsc_hd5000_config = {
309 .demod_address = 0x59, 313 .demod_address = 0x59,
310 .demod_chip = LGDT3303, 314 .demod_chip = LGDT3303,
311 .serial_mpeg = 0x04, 315 .serial_mpeg = 0x04,
312 .pll_set = lgdt3303_pll_set,
313 .clock_polarity_flip = 1, 316 .clock_polarity_flip = 1,
314}; 317};
315 318
316static struct nxt200x_config samsung_tbmv_config = { 319static struct nxt200x_config samsung_tbmv_config = {
317 .demod_address = 0x0a, 320 .demod_address = 0x0a,
318 .pll_address = 0xc2,
319 .pll_desc = &dvb_pll_samsung_tbmv,
320}; 321};
321 322
322static struct bcm3510_config air2pc_atsc_first_gen_config = { 323static struct bcm3510_config air2pc_atsc_first_gen_config = {
@@ -324,7 +325,7 @@ static struct bcm3510_config air2pc_atsc_first_gen_config = {
324 .request_firmware = flexcop_fe_request_firmware, 325 .request_firmware = flexcop_fe_request_firmware,
325}; 326};
326 327
327static int skystar23_samsung_tbdu18132_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 328static int skystar23_samsung_tbdu18132_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
328{ 329{
329 u8 buf[4]; 330 u8 buf[4];
330 u32 div; 331 u32 div;
@@ -341,6 +342,8 @@ static int skystar23_samsung_tbdu18132_pll_set(struct dvb_frontend* fe, struct d
341 if (params->frequency < 1550000) 342 if (params->frequency < 1550000)
342 buf[3] |= 0x02; 343 buf[3] |= 0x02;
343 344
345 if (fe->ops->i2c_gate_ctrl)
346 fe->ops->i2c_gate_ctrl(fe, 1);
344 if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) 347 if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1)
345 return -EIO; 348 return -EIO;
346 return 0; 349 return 0;
@@ -349,9 +352,51 @@ static int skystar23_samsung_tbdu18132_pll_set(struct dvb_frontend* fe, struct d
349static struct mt312_config skystar23_samsung_tbdu18132_config = { 352static struct mt312_config skystar23_samsung_tbdu18132_config = {
350 353
351 .demod_address = 0x0e, 354 .demod_address = 0x0e,
352 .pll_set = skystar23_samsung_tbdu18132_pll_set,
353}; 355};
354 356
357int alps_tdee4_stv0297_tuner_set_params (struct dvb_frontend* fe, struct dvb_frontend_parameters *fep)
358{
359 struct flexcop_device *fc = fe->dvb->priv;
360 u8 buf[4];
361 u16 div;
362 int ret;
363
364/* 62.5 kHz * 10 */
365#define REF_FREQ 625
366#define FREQ_OFFSET 36125
367
368 div = ((fep->frequency/1000 + FREQ_OFFSET ) * 10) / REF_FREQ; // 4 MHz = 4000 KHz
369
370 buf[0] = (u8)( div >> 8) & 0x7f;
371 buf[1] = (u8) div & 0xff;
372
373/* F(osc) = N * Reference Freq. (62.5 kHz)
374 * byte 2 : 0 N14 N13 N12 N11 N10 N9 N8
375 * byte 3 : N7 N6 N5 N4 N3 N2 N1 N0
376 * byte 4 : 1 * * AGD R3 R2 R1 R0
377 * byte 5 : C1 * RE RTS BS4 BS3 BS2 BS1
378 * AGD = 1, R3 R2 R1 R0 = 0 1 0 1 => byte 4 = 1**10101 = 0x95 */
379 buf[2] = 0x95;
380
381// Range(MHz) C1 * RE RTS BS4 BS3 BS2 BS1 Byte 5
382// 47 - 153 0 * 0 0 0 0 0 1 0x01
383// 153 - 430 0 * 0 0 0 0 1 0 0x02
384// 430 - 822 0 * 0 0 1 0 0 0 0x08
385// 822 - 862 1 * 0 0 1 0 0 0 0x88
386
387 if (fep->frequency <= 153000000) buf[3] = 0x01;
388 else if (fep->frequency <= 430000000) buf[3] = 0x02;
389 else if (fep->frequency <= 822000000) buf[3] = 0x08;
390 else buf[3] = 0x88;
391
392 if (fe->ops->i2c_gate_ctrl)
393 fe->ops->i2c_gate_ctrl(fe, 1);
394 deb_tuner("tuner buffer for %d Hz: %x %x %x %x\n",fep->frequency, buf[0],buf[1],buf[2],buf[3]);
395 ret = fc->i2c_request(fc,FC_WRITE,FC_I2C_PORT_TUNER,0x61,buf[0],&buf[1],3);
396 deb_tuner("tuner write returned: %d\n",ret);
397
398 return 0;
399}
355 400
356static u8 alps_tdee4_stv0297_inittab[] = { 401static u8 alps_tdee4_stv0297_inittab[] = {
357 0x80, 0x01, 402 0x80, 0x01,
@@ -462,6 +507,8 @@ int flexcop_frontend_init(struct flexcop_device *fc)
462 if ((fc->fe = stv0299_attach(&samsung_tbmu24112_config, &fc->i2c_adap)) != NULL) { 507 if ((fc->fe = stv0299_attach(&samsung_tbmu24112_config, &fc->i2c_adap)) != NULL) {
463 ops = fc->fe->ops; 508 ops = fc->fe->ops;
464 509
510 ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params;
511
465 ops->set_voltage = flexcop_set_voltage; 512 ops->set_voltage = flexcop_set_voltage;
466 513
467 fc->fe_sleep = ops->sleep; 514 fc->fe_sleep = ops->sleep;
@@ -473,16 +520,19 @@ int flexcop_frontend_init(struct flexcop_device *fc)
473 /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */ 520 /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */
474 if ((fc->fe = mt352_attach(&samsung_tdtc9251dh0_config, &fc->i2c_adap)) != NULL ) { 521 if ((fc->fe = mt352_attach(&samsung_tdtc9251dh0_config, &fc->i2c_adap)) != NULL ) {
475 fc->dev_type = FC_AIR_DVB; 522 fc->dev_type = FC_AIR_DVB;
523 fc->fe->ops->tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs;
476 info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address); 524 info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address);
477 } else 525 } else
478 /* try the air atsc 2nd generation (nxt2002) */ 526 /* try the air atsc 2nd generation (nxt2002) */
479 if ((fc->fe = nxt200x_attach(&samsung_tbmv_config, &fc->i2c_adap)) != NULL) { 527 if ((fc->fe = nxt200x_attach(&samsung_tbmv_config, &fc->i2c_adap)) != NULL) {
480 fc->dev_type = FC_AIR_ATSC2; 528 fc->dev_type = FC_AIR_ATSC2;
529 dvb_pll_attach(fc->fe, 0x61, &fc->i2c_adap, &dvb_pll_samsung_tbmv);
481 info("found the nxt2002 at i2c address: 0x%02x",samsung_tbmv_config.demod_address); 530 info("found the nxt2002 at i2c address: 0x%02x",samsung_tbmv_config.demod_address);
482 } else 531 } else
483 /* try the air atsc 3nd generation (lgdt3303) */ 532 /* try the air atsc 3nd generation (lgdt3303) */
484 if ((fc->fe = lgdt330x_attach(&air2pc_atsc_hd5000_config, &fc->i2c_adap)) != NULL) { 533 if ((fc->fe = lgdt330x_attach(&air2pc_atsc_hd5000_config, &fc->i2c_adap)) != NULL) {
485 fc->dev_type = FC_AIR_ATSC3; 534 fc->dev_type = FC_AIR_ATSC3;
535 fc->fe->ops->tuner_ops.set_params = lgdt3303_tuner_set_params;
486 info("found the lgdt3303 at i2c address: 0x%02x",air2pc_atsc_hd5000_config.demod_address); 536 info("found the lgdt3303 at i2c address: 0x%02x",air2pc_atsc_hd5000_config.demod_address);
487 } else 537 } else
488 /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */ 538 /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */
@@ -493,12 +543,15 @@ int flexcop_frontend_init(struct flexcop_device *fc)
493 /* try the cable dvb (stv0297) */ 543 /* try the cable dvb (stv0297) */
494 if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) { 544 if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) {
495 fc->dev_type = FC_CABLE; 545 fc->dev_type = FC_CABLE;
546 fc->fe->ops->tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params;
496 info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); 547 info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address);
497 } else 548 } else
498 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ 549 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
499 if ((fc->fe = vp310_mt312_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) { 550 if ((fc->fe = vp310_mt312_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {
500 ops = fc->fe->ops; 551 ops = fc->fe->ops;
501 552
553 ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params;
554
502 ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd; 555 ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd;
503 ops->diseqc_send_burst = flexcop_diseqc_send_burst; 556 ops->diseqc_send_burst = flexcop_diseqc_send_burst;
504 ops->set_tone = flexcop_set_tone; 557 ops->set_tone = flexcop_set_tone;