Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] fc0013 ver. 0.2: introduction of get_rf_strength function

Changes compared to version 0.1 of driver (sent 6 May):
- Initial implementation of get_rf_strength function.
- Introduction of a warning message

Signed-off-by: Hans-Frieder Vogt <hfvogt@gmx.net>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Hans-Frieder Vogt and committed by
Mauro Carvalho Chehab
b144c98c 4a14db7e

+73 -1
+73 -1
drivers/media/common/tuners/fc0013.c
··· 484 484 exit: 485 485 if (fe->ops.i2c_gate_ctrl) 486 486 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ 487 + if (ret) 488 + warn("%s: failed: %d", __func__, ret); 487 489 return ret; 488 490 } 489 491 ··· 510 508 return 0; 511 509 } 512 510 511 + #define INPUT_ADC_LEVEL -8 512 + 513 + static int fc0013_get_rf_strength(struct dvb_frontend *fe, u16 *strength) 514 + { 515 + struct fc0013_priv *priv = fe->tuner_priv; 516 + int ret; 517 + unsigned char tmp; 518 + int int_temp, lna_gain, int_lna, tot_agc_gain, power; 519 + const int fc0013_lna_gain_table[] = { 520 + /* low gain */ 521 + -63, -58, -99, -73, 522 + -63, -65, -54, -60, 523 + /* middle gain */ 524 + 71, 70, 68, 67, 525 + 65, 63, 61, 58, 526 + /* high gain */ 527 + 197, 191, 188, 186, 528 + 184, 182, 181, 179, 529 + }; 530 + 531 + if (fe->ops.i2c_gate_ctrl) 532 + fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ 533 + 534 + ret = fc0013_writereg(priv, 0x13, 0x00); 535 + if (ret) 536 + goto err; 537 + 538 + ret = fc0013_readreg(priv, 0x13, &tmp); 539 + if (ret) 540 + goto err; 541 + int_temp = tmp; 542 + 543 + ret = fc0013_readreg(priv, 0x14, &tmp); 544 + if (ret) 545 + goto err; 546 + lna_gain = tmp & 0x1f; 547 + 548 + if (fe->ops.i2c_gate_ctrl) 549 + fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ 550 + 551 + if (lna_gain < ARRAY_SIZE(fc0013_lna_gain_table)) { 552 + int_lna = fc0013_lna_gain_table[lna_gain]; 553 + tot_agc_gain = (abs((int_temp >> 5) - 7) - 2 + 554 + (int_temp & 0x1f)) * 2; 555 + power = INPUT_ADC_LEVEL - tot_agc_gain - int_lna / 10; 556 + 557 + if (power >= 45) 558 + *strength = 255; /* 100% */ 559 + else if (power < -95) 560 + *strength = 0; 561 + else 562 + *strength = (power + 95) * 255 / 140; 563 + 564 + *strength |= *strength << 8; 565 + } else { 566 + ret = -1; 567 + } 568 + 569 + goto exit; 570 + 571 + err: 572 + if (fe->ops.i2c_gate_ctrl) 573 + fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ 574 + exit: 575 + if (ret) 576 + warn("%s: failed: %d", __func__, ret); 577 + return ret; 578 + } 513 579 514 580 static const struct dvb_tuner_ops fc0013_tuner_ops = { 515 581 .info = { ··· 598 528 .get_frequency = fc0013_get_frequency, 599 529 .get_if_frequency = fc0013_get_if_frequency, 600 530 .get_bandwidth = fc0013_get_bandwidth, 531 + 532 + .get_rf_strength = fc0013_get_rf_strength, 601 533 }; 602 534 603 535 struct dvb_frontend *fc0013_attach(struct dvb_frontend *fe, ··· 631 559 MODULE_DESCRIPTION("Fitipower FC0013 silicon tuner driver"); 632 560 MODULE_AUTHOR("Hans-Frieder Vogt <hfvogt@gmx.net>"); 633 561 MODULE_LICENSE("GPL"); 634 - MODULE_VERSION("0.1"); 562 + MODULE_VERSION("0.2");