aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/common/tuners/xc4000.c
diff options
context:
space:
mode:
authorIstvan Varga <istvan_v@mailbox.hu>2011-06-04 11:08:29 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-07-27 16:52:38 -0400
commitf4312e2fd4ca44e1defad1637d054bbe11a4ade6 (patch)
tree90fc125d67523c651f6551387a946365e635a596 /drivers/media/common/tuners/xc4000.c
parent027fd361860e40736c0ad093a8f4194d727afb63 (diff)
[media] xc4000: debug message improvements
The following patch makes a few minor changes to the printing of debug messages, and reporting the tuner status. The 'debug' module parameter can now be set from 0 to 2 to control the verbosity of debug messages. Signed-off-by: Istvan Varga <istvan_v@mailbox.hu> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/common/tuners/xc4000.c')
-rw-r--r--drivers/media/common/tuners/xc4000.c68
1 files changed, 45 insertions, 23 deletions
diff --git a/drivers/media/common/tuners/xc4000.c b/drivers/media/common/tuners/xc4000.c
index ec5f1f1b3f3c..24afebb93331 100644
--- a/drivers/media/common/tuners/xc4000.c
+++ b/drivers/media/common/tuners/xc4000.c
@@ -39,7 +39,7 @@
39 39
40static int debug; 40static int debug;
41module_param(debug, int, 0644); 41module_param(debug, int, 0644);
42MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); 42MODULE_PARM_DESC(debug, "\n\t\tDebugging level (0 to 2, default: 0 (off)).");
43 43
44static int no_poweroff; 44static int no_poweroff;
45module_param(no_poweroff, int, 0644); 45module_param(no_poweroff, int, 0644);
@@ -239,6 +239,7 @@ static struct XC_TV_STANDARD XC4000_Standard[MAX_TV_STANDARD] = {
239 239
240static int xc4000_readreg(struct xc4000_priv *priv, u16 reg, u16 *val); 240static int xc4000_readreg(struct xc4000_priv *priv, u16 reg, u16 *val);
241static int xc4000_TunerReset(struct dvb_frontend *fe); 241static int xc4000_TunerReset(struct dvb_frontend *fe);
242static void xc_debug_dump(struct xc4000_priv *priv);
242 243
243static int xc_send_i2c_data(struct xc4000_priv *priv, u8 *buf, int len) 244static int xc_send_i2c_data(struct xc4000_priv *priv, u8 *buf, int len)
244{ 245{
@@ -515,6 +516,15 @@ static int xc_tune_channel(struct xc4000_priv *priv, u32 freq_hz, int mode)
515 found = 1; 516 found = 1;
516 } 517 }
517 518
519 /* Wait for stats to stabilize.
520 * Frame Lines needs two frame times after initial lock
521 * before it is valid.
522 */
523 xc_wait(debug ? 100 : 10);
524
525 if (debug)
526 xc_debug_dump(priv);
527
518 return found; 528 return found;
519} 529}
520 530
@@ -1085,12 +1095,6 @@ static void xc_debug_dump(struct xc4000_priv *priv)
1085 u8 hw_majorversion = 0, hw_minorversion = 0; 1095 u8 hw_majorversion = 0, hw_minorversion = 0;
1086 u8 fw_majorversion = 0, fw_minorversion = 0; 1096 u8 fw_majorversion = 0, fw_minorversion = 0;
1087 1097
1088 /* Wait for stats to stabilize.
1089 * Frame Lines needs two frame times after initial lock
1090 * before it is valid.
1091 */
1092 xc_wait(100);
1093
1094 xc_get_ADC_Envelope(priv, &adc_envelope); 1098 xc_get_ADC_Envelope(priv, &adc_envelope);
1095 dprintk(1, "*** ADC envelope (0-1023) = %d\n", adc_envelope); 1099 dprintk(1, "*** ADC envelope (0-1023) = %d\n", adc_envelope);
1096 1100
@@ -1103,16 +1107,18 @@ static void xc_debug_dump(struct xc4000_priv *priv)
1103 1107
1104 xc_get_version(priv, &hw_majorversion, &hw_minorversion, 1108 xc_get_version(priv, &hw_majorversion, &hw_minorversion,
1105 &fw_majorversion, &fw_minorversion); 1109 &fw_majorversion, &fw_minorversion);
1106
1107 dprintk(1, "*** HW: V%02x.%02x, FW: V%02x.%02x\n", 1110 dprintk(1, "*** HW: V%02x.%02x, FW: V%02x.%02x\n",
1108 hw_majorversion, hw_minorversion, 1111 hw_majorversion, hw_minorversion,
1109 fw_majorversion, fw_minorversion); 1112 fw_majorversion, fw_minorversion);
1110 1113
1111 xc_get_hsync_freq(priv, &hsync_freq_hz); 1114 if (priv->video_standard < XC4000_DTV6) {
1112 dprintk(1, "*** Horizontal sync frequency = %d Hz\n", hsync_freq_hz); 1115 xc_get_hsync_freq(priv, &hsync_freq_hz);
1116 dprintk(1, "*** Horizontal sync frequency = %d Hz\n",
1117 hsync_freq_hz);
1113 1118
1114 xc_get_frame_lines(priv, &frame_lines); 1119 xc_get_frame_lines(priv, &frame_lines);
1115 dprintk(1, "*** Frame lines = %d\n", frame_lines); 1120 dprintk(1, "*** Frame lines = %d\n", frame_lines);
1121 }
1116 1122
1117 xc_get_quality(priv, &quality); 1123 xc_get_quality(priv, &quality);
1118 dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %d\n", quality); 1124 dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %d\n", quality);
@@ -1223,9 +1229,6 @@ static int xc4000_set_params(struct dvb_frontend *fe,
1223 } 1229 }
1224 xc_tune_channel(priv, priv->freq_hz, XC_TUNE_DIGITAL); 1230 xc_tune_channel(priv, priv->freq_hz, XC_TUNE_DIGITAL);
1225 1231
1226 if (debug)
1227 xc_debug_dump(priv);
1228
1229 ret = 0; 1232 ret = 0;
1230 1233
1231fail: 1234fail:
@@ -1320,9 +1323,6 @@ tune_channel:
1320 1323
1321 xc_tune_channel(priv, priv->freq_hz, XC_TUNE_ANALOG); 1324 xc_tune_channel(priv, priv->freq_hz, XC_TUNE_ANALOG);
1322 1325
1323 if (debug)
1324 xc_debug_dump(priv);
1325
1326 ret = 0; 1326 ret = 0;
1327 1327
1328fail: 1328fail:
@@ -1334,8 +1334,26 @@ fail:
1334static int xc4000_get_frequency(struct dvb_frontend *fe, u32 *freq) 1334static int xc4000_get_frequency(struct dvb_frontend *fe, u32 *freq)
1335{ 1335{
1336 struct xc4000_priv *priv = fe->tuner_priv; 1336 struct xc4000_priv *priv = fe->tuner_priv;
1337 dprintk(1, "%s()\n", __func__); 1337
1338 *freq = priv->freq_hz; 1338 *freq = priv->freq_hz;
1339
1340 if (debug) {
1341 mutex_lock(&priv->lock);
1342 if ((priv->cur_fw.type
1343 & (BASE | FM | DTV6 | DTV7 | DTV78 | DTV8)) == BASE) {
1344 u16 snr = 0;
1345 if (xc4000_readreg(priv, XREG_SNR, &snr) == 0) {
1346 mutex_unlock(&priv->lock);
1347 dprintk(1, "%s() freq = %u, SNR = %d\n",
1348 __func__, *freq, snr);
1349 return 0;
1350 }
1351 }
1352 mutex_unlock(&priv->lock);
1353 }
1354
1355 dprintk(1, "%s()\n", __func__);
1356
1339 return 0; 1357 return 0;
1340} 1358}
1341 1359
@@ -1355,13 +1373,17 @@ static int xc4000_get_status(struct dvb_frontend *fe, u32 *status)
1355 1373
1356 mutex_lock(&priv->lock); 1374 mutex_lock(&priv->lock);
1357 1375
1358 xc_get_lock_status(priv, &lock_status); 1376 if (priv->cur_fw.type & BASE)
1377 xc_get_lock_status(priv, &lock_status);
1359 1378
1360 mutex_unlock(&priv->lock); 1379 *status = (lock_status == 1 ?
1380 TUNER_STATUS_LOCKED | TUNER_STATUS_STEREO : 0);
1381 if (priv->cur_fw.type & (DTV6 | DTV7 | DTV78 | DTV8))
1382 *status &= (~TUNER_STATUS_STEREO);
1361 1383
1362 dprintk(1, "%s() lock_status = 0x%08x\n", __func__, lock_status); 1384 mutex_unlock(&priv->lock);
1363 1385
1364 *status = lock_status; 1386 dprintk(2, "%s() lock_status = %d\n", __func__, lock_status);
1365 1387
1366 return 0; 1388 return 0;
1367} 1389}