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

[media] fc0012 ver. 0.6: introduction of get_rf_strength function

Changes compared to version 0.5 of driver (sent 6 May):
- Initial implementation of get_rf_strength function.

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
4a14db7e e889adc9

+71 -1
+71 -1
drivers/media/common/tuners/fc0012.c
··· 343 343 return 0; 344 344 } 345 345 346 + #define INPUT_ADC_LEVEL -8 347 + 348 + static int fc0012_get_rf_strength(struct dvb_frontend *fe, u16 *strength) 349 + { 350 + struct fc0012_priv *priv = fe->tuner_priv; 351 + int ret; 352 + unsigned char tmp; 353 + int int_temp, lna_gain, int_lna, tot_agc_gain, power; 354 + const int fc0012_lna_gain_table[] = { 355 + /* low gain */ 356 + -63, -58, -99, -73, 357 + -63, -65, -54, -60, 358 + /* middle gain */ 359 + 71, 70, 68, 67, 360 + 65, 63, 61, 58, 361 + /* high gain */ 362 + 197, 191, 188, 186, 363 + 184, 182, 181, 179, 364 + }; 365 + 366 + if (fe->ops.i2c_gate_ctrl) 367 + fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ 368 + 369 + ret = fc0012_writereg(priv, 0x12, 0x00); 370 + if (ret) 371 + goto err; 372 + 373 + ret = fc0012_readreg(priv, 0x12, &tmp); 374 + if (ret) 375 + goto err; 376 + int_temp = tmp; 377 + 378 + ret = fc0012_readreg(priv, 0x13, &tmp); 379 + if (ret) 380 + goto err; 381 + lna_gain = tmp & 0x1f; 382 + 383 + if (fe->ops.i2c_gate_ctrl) 384 + fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ 385 + 386 + if (lna_gain < ARRAY_SIZE(fc0012_lna_gain_table)) { 387 + int_lna = fc0012_lna_gain_table[lna_gain]; 388 + tot_agc_gain = (abs((int_temp >> 5) - 7) - 2 + 389 + (int_temp & 0x1f)) * 2; 390 + power = INPUT_ADC_LEVEL - tot_agc_gain - int_lna / 10; 391 + 392 + if (power >= 45) 393 + *strength = 255; /* 100% */ 394 + else if (power < -95) 395 + *strength = 0; 396 + else 397 + *strength = (power + 95) * 255 / 140; 398 + 399 + *strength |= *strength << 8; 400 + } else { 401 + ret = -1; 402 + } 403 + 404 + goto exit; 405 + 406 + err: 407 + if (fe->ops.i2c_gate_ctrl) 408 + fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ 409 + exit: 410 + if (ret) 411 + warn("%s: failed: %d", __func__, ret); 412 + return ret; 413 + } 346 414 347 415 static const struct dvb_tuner_ops fc0012_tuner_ops = { 348 416 .info = { ··· 431 363 .get_frequency = fc0012_get_frequency, 432 364 .get_if_frequency = fc0012_get_if_frequency, 433 365 .get_bandwidth = fc0012_get_bandwidth, 366 + 367 + .get_rf_strength = fc0012_get_rf_strength, 434 368 }; 435 369 436 370 struct dvb_frontend *fc0012_attach(struct dvb_frontend *fe, ··· 464 394 MODULE_DESCRIPTION("Fitipower FC0012 silicon tuner driver"); 465 395 MODULE_AUTHOR("Hans-Frieder Vogt <hfvogt@gmx.net>"); 466 396 MODULE_LICENSE("GPL"); 467 - MODULE_VERSION("0.5"); 397 + MODULE_VERSION("0.6");