From patchwork Tue Aug 7 02:47:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 13641 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1SyZq0-00072P-H1 for patchwork@linuxtv.org; Tue, 07 Aug 2012 04:48:04 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-2) with esmtp for id 1SyZpz-0005Me-J9; Tue, 07 Aug 2012 04:48:04 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932543Ab2HGCr7 (ORCPT ); Mon, 6 Aug 2012 22:47:59 -0400 Received: from mail-vc0-f174.google.com ([209.85.220.174]:52727 "EHLO mail-vc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932526Ab2HGCr5 (ORCPT ); Mon, 6 Aug 2012 22:47:57 -0400 Received: by mail-vc0-f174.google.com with SMTP id fk26so3432709vcb.19 for ; Mon, 06 Aug 2012 19:47:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=/oDBfgyJdKf+HSzdyeWyxIVxSphJ0YBnPlYHtipJX5s=; b=DBqpTOvTJzGOfChw4+1UCxKTvtTeSyO9xU8bBVDDSZgAJ+UPu+qF01vtZCqtmcEpeG ha4ioTmPZiG8OCqNnEe66vUlavYxmYWHngeghS3J5u1kmIL83uYMOfe/IRaa2CsQc+hM enTVbqN6FSSVyL8nqwPQl+CWfrUjbyGp38tnBWKn/arbm/Ep5gCmqDB4iXTpJq3ORMoS K9UPSCj3sMrjJhdBlRKnJm7eXBPiX0vsrAXmxYegte7mYUmpo0PsYlvrgYPMXEqo0P3v UyBSmmEB0lizJrs17LSiEAm2577K+fNx76fqfv4Vf82brIsqoaeZ99kLS7U2KgM1L434 K6YQ== Received: by 10.52.89.83 with SMTP id bm19mr8385270vdb.116.1344307677185; Mon, 06 Aug 2012 19:47:57 -0700 (PDT) Received: from localhost.localdomain (pool-108-54-72-165.nycmny.fios.verizon.net. [108.54.72.165]) by mx.google.com with ESMTPS id e9sm17555638vdf.21.2012.08.06.19.47.56 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 06 Aug 2012 19:47:56 -0700 (PDT) From: Devin Heitmueller To: linux-media@vger.kernel.org Cc: Devin Heitmueller Subject: [PATCH 11/24] xc5000: don't invoke auto calibration unless we really did reset tuner Date: Mon, 6 Aug 2012 22:47:01 -0400 Message-Id: <1344307634-11673-12-git-send-email-dheitmueller@kernellabs.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1344307634-11673-1-git-send-email-dheitmueller@kernellabs.com> References: <1344307634-11673-1-git-send-email-dheitmueller@kernellabs.com> X-Gm-Message-State: ALoCoQlbBzXej33dSV5klkJqaZpDhcLIIEzlCzm/AmSSdroLBmpJ6dbLe3cmlvVwck53vA3m6T+X Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.8.7.23921 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' 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 --- drivers/media/common/tuners/xc5000.c | 40 +++++++++++++++------------------ 1 files changed, 18 insertions(+), 22 deletions(-) diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c index a7fa17e..1cfaa7c 100644 --- a/drivers/media/common/tuners/xc5000.c +++ b/drivers/media/common/tuners/xc5000.c @@ -715,11 +715,9 @@ static int xc5000_set_params(struct dvb_frontend *fe) u32 freq = fe->dtv_property_cache.frequency; u32 delsys = fe->dtv_property_cache.delivery_system; - if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) { - if (xc_load_fw_and_init_tuner(fe) != XC_RESULT_SUCCESS) { - dprintk(1, "Unable to load firmware and init tuner\n"); - return -EINVAL; - } + if (xc_load_fw_and_init_tuner(fe) != XC_RESULT_SUCCESS) { + dprintk(1, "Unable to load firmware and init tuner\n"); + return -EINVAL; } dprintk(1, "%s() frequency=%d (Hz)\n", __func__, freq); @@ -994,11 +992,9 @@ static int xc5000_set_analog_params(struct dvb_frontend *fe, if (priv->i2c_props.adap == NULL) return -EINVAL; - if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) { - if (xc_load_fw_and_init_tuner(fe) != XC_RESULT_SUCCESS) { - dprintk(1, "Unable to load firmware and init tuner\n"); - return -EINVAL; - } + if (xc_load_fw_and_init_tuner(fe) != XC_RESULT_SUCCESS) { + dprintk(1, "Unable to load firmware and init tuner\n"); + return -EINVAL; } switch (params->mode) { @@ -1057,26 +1053,26 @@ static int xc5000_get_status(struct dvb_frontend *fe, u32 *status) static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe) { struct xc5000_priv *priv = fe->tuner_priv; - int ret = 0; + int ret = XC_RESULT_SUCCESS; if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) { ret = xc5000_fwupload(fe); if (ret != XC_RESULT_SUCCESS) return ret; - } - /* Start the tuner self-calibration process */ - ret |= xc_initialize(priv); + /* Start the tuner self-calibration process */ + ret |= xc_initialize(priv); - /* Wait for calibration to complete. - * We could continue but XC5000 will clock stretch subsequent - * I2C transactions until calibration is complete. This way we - * don't have to rely on clock stretching working. - */ - xc_wait(100); + /* Wait for calibration to complete. + * We could continue but XC5000 will clock stretch subsequent + * I2C transactions until calibration is complete. This way we + * don't have to rely on clock stretching working. + */ + xc_wait(100); - /* Default to "CABLE" mode */ - ret |= xc_write_reg(priv, XREG_SIGNALSOURCE, XC_RF_MODE_CABLE); + /* Default to "CABLE" mode */ + ret |= xc_write_reg(priv, XREG_SIGNALSOURCE, XC_RF_MODE_CABLE); + } return ret; }