aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/common
diff options
context:
space:
mode:
authorDevin Heitmueller <dheitmueller@kernellabs.com>2012-08-06 21:47:01 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-09 19:36:43 -0400
commitfc7a74bad1ae1d68a1a9999634baeb4bae277a92 (patch)
treeb5e48a23ebb88d45fc14eada881e1100bf89d518 /drivers/media/common
parentd6b8267800c59872bf2daf48c3399e83bee3a5ba (diff)
[media] xc5000: don't invoke auto calibration unless we really did reset tuner
The current code invokes the auto calibration of the tuner whenever the init routine is called (whenever the DVB frontend opens the device). However we should really only be invoking the calibration if we actually did reset the device and reload the firmware. Rework the routine to only do calibration if reset and firmware load was performed. Also because the called function is now a no-op if the firmware is already loaded, the caller no longer needs to invoke is_firmware_loaded(). Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/common')
-rw-r--r--drivers/media/common/tuners/xc5000.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c
index 7189e06fb35f..06f66fedfff3 100644
--- a/drivers/media/common/tuners/xc5000.c
+++ b/drivers/media/common/tuners/xc5000.c
@@ -717,11 +717,9 @@ static int xc5000_set_params(struct dvb_frontend *fe)
717 u32 freq = fe->dtv_property_cache.frequency; 717 u32 freq = fe->dtv_property_cache.frequency;
718 u32 delsys = fe->dtv_property_cache.delivery_system; 718 u32 delsys = fe->dtv_property_cache.delivery_system;
719 719
720 if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) { 720 if (xc_load_fw_and_init_tuner(fe) != XC_RESULT_SUCCESS) {
721 if (xc_load_fw_and_init_tuner(fe) != XC_RESULT_SUCCESS) { 721 dprintk(1, "Unable to load firmware and init tuner\n");
722 dprintk(1, "Unable to load firmware and init tuner\n"); 722 return -EINVAL;
723 return -EINVAL;
724 }
725 } 723 }
726 724
727 dprintk(1, "%s() frequency=%d (Hz)\n", __func__, freq); 725 dprintk(1, "%s() frequency=%d (Hz)\n", __func__, freq);
@@ -1002,11 +1000,9 @@ static int xc5000_set_analog_params(struct dvb_frontend *fe,
1002 if (priv->i2c_props.adap == NULL) 1000 if (priv->i2c_props.adap == NULL)
1003 return -EINVAL; 1001 return -EINVAL;
1004 1002
1005 if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) { 1003 if (xc_load_fw_and_init_tuner(fe) != XC_RESULT_SUCCESS) {
1006 if (xc_load_fw_and_init_tuner(fe) != XC_RESULT_SUCCESS) { 1004 dprintk(1, "Unable to load firmware and init tuner\n");
1007 dprintk(1, "Unable to load firmware and init tuner\n"); 1005 return -EINVAL;
1008 return -EINVAL;
1009 }
1010 } 1006 }
1011 1007
1012 switch (params->mode) { 1008 switch (params->mode) {
@@ -1065,26 +1061,26 @@ static int xc5000_get_status(struct dvb_frontend *fe, u32 *status)
1065static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe) 1061static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe)
1066{ 1062{
1067 struct xc5000_priv *priv = fe->tuner_priv; 1063 struct xc5000_priv *priv = fe->tuner_priv;
1068 int ret = 0; 1064 int ret = XC_RESULT_SUCCESS;
1069 1065
1070 if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) { 1066 if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) {
1071 ret = xc5000_fwupload(fe); 1067 ret = xc5000_fwupload(fe);
1072 if (ret != XC_RESULT_SUCCESS) 1068 if (ret != XC_RESULT_SUCCESS)
1073 return ret; 1069 return ret;
1074 }
1075 1070
1076 /* Start the tuner self-calibration process */ 1071 /* Start the tuner self-calibration process */
1077 ret |= xc_initialize(priv); 1072 ret |= xc_initialize(priv);
1078 1073
1079 /* Wait for calibration to complete. 1074 /* Wait for calibration to complete.
1080 * We could continue but XC5000 will clock stretch subsequent 1075 * We could continue but XC5000 will clock stretch subsequent
1081 * I2C transactions until calibration is complete. This way we 1076 * I2C transactions until calibration is complete. This way we
1082 * don't have to rely on clock stretching working. 1077 * don't have to rely on clock stretching working.
1083 */ 1078 */
1084 xc_wait(100); 1079 xc_wait(100);
1085 1080
1086 /* Default to "CABLE" mode */ 1081 /* Default to "CABLE" mode */
1087 ret |= xc_write_reg(priv, XREG_SIGNALSOURCE, XC_RF_MODE_CABLE); 1082 ret |= xc_write_reg(priv, XREG_SIGNALSOURCE, XC_RF_MODE_CABLE);
1083 }
1088 1084
1089 return ret; 1085 return ret;
1090} 1086}