From patchwork Tue Jan 3 18:30:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gianluca Gennari X-Patchwork-Id: 9305 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1Ri97t-0006L7-KV; Tue, 03 Jan 2012 19:30:22 +0100 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-4) with esmtp id 1Ri97s-0002d9-Bh; Tue, 03 Jan 2012 19:30:21 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754571Ab2ACSaS (ORCPT + 4 others); Tue, 3 Jan 2012 13:30:18 -0500 Received: from mail-ee0-f46.google.com ([74.125.83.46]:34509 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754490Ab2ACSaR (ORCPT ); Tue, 3 Jan 2012 13:30:17 -0500 Received: by eekc4 with SMTP id c4so16105782eek.19 for ; Tue, 03 Jan 2012 10:30:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:user-agent:mime-version:to:cc:subject :x-enigmail-version:content-type:content-transfer-encoding; bh=E9yga6+5U1lJjegqw9BhaeQVTEIDvwpun9ioF+t7SlQ=; b=tKrhY9+cNwYc/qDeTqnG0dDQgz8k8p2J8BPEmNK5ybGUtON86ziBszzwcOxq0OZcXm SdwVbr0RWIEaPTOorLTc4gM1xkNbG0YW35IWcGsXqx0sWnoIHh6W2fIyeaTw7LIBhRyX vf+4i0TZfgiL7ocukrwkpv9fYUC3aB1I7w5iU= Received: by 10.14.49.133 with SMTP id x5mr22447824eeb.35.1325615416195; Tue, 03 Jan 2012 10:30:16 -0800 (PST) Received: from [192.168.2.3] (93-50-34-119.ip150.fastwebnet.it. [93.50.34.119]) by mx.google.com with ESMTPS id 13sm208896126eeu.1.2012.01.03.10.30.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 Jan 2012 10:30:15 -0800 (PST) Message-ID: <4F034934.4010407@gmail.com> Date: Tue, 03 Jan 2012 19:30:12 +0100 From: Gianluca Gennari Reply-To: gennarone@gmail.com User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111124 Thunderbird/8.0 MIME-Version: 1.0 To: linux-media@vger.kernel.org CC: Mauro Carvalho Chehab Subject: [PATCH v2] xc3028: fix center frequency calculation for DTV78 firmware X-Enigmail-Version: 1.3.4 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.1.3.181815 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' FORGED_FROM_GMAIL 0.1, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FRAUD_WEBMAIL_REPLYTO 0, __FROM_GMAIL 0, __HAS_MSGID 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0' X-LSpam-Score: -1.9 (-) X-LSpam-Report: No, score=-1.9 required=5.0 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, T_DKIM_INVALID=0.01 autolearn=ham Hi all, this patch replaces the previous one proposed in the thread "xc3028: force reload of DTV7 firmware in VHF band with Zarlink demodulator". The problem is that the firmware DTV78 works fine in UHF band (8 MHz bandwidth) but is not working at all in VHF band (7 MHz bandwidth). Reading the comments inside the code, I figured out that the real problem could be connected to the formula used to calculate the center frequency offset in VHF band. In fact, removing this adjustment fixes the problem: if ((priv->cur_fw.type & DTV78) && freq < 470000000) offset -= 500000; This is coherent to what was implemented for the DTV7 firmware by an Australian user: if (priv->cur_fw.type & DTV7) offset += 500000; In the end, now the center frequency is the same for all firmwares (DTV7, DTV8, DTV78) and doesn't depend on channel bandwidth. The final code looks clean and simple, and there is no need for any "magic" adjustment: if (priv->cur_fw.type & DTV6) offset = 1750000; else /* DTV7 or DTV8 or DTV78 */ offset = 2750000; Signed-off-by: Gianluca Gennari --- drivers/media/common/tuners/tuner-xc2028.c | 26 ++++++++++++++++---------- 1 files changed, 16 insertions(+), 10 deletions(-) * xc3028 additional "magic" @@ -979,17 +989,13 @@ static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */, * newer firmwares */ -#if 1 /* * The proper adjustment would be to do it at s-code table. * However, this didn't work, as reported by * Robert Lowery */ - if (priv->cur_fw.type & DTV7) - offset += 500000; - -#else +#if 0 /* * Still need tests for XC3028L (firmware 3.2 or upper) * So, for now, let's just comment the per-firmware diff --git a/drivers/media/common/tuners/tuner-xc2028.c b/drivers/media/common/tuners/tuner-xc2028.c index bdcbfd7..2755599 100644 --- a/drivers/media/common/tuners/tuner-xc2028.c +++ b/drivers/media/common/tuners/tuner-xc2028.c @@ -962,14 +962,24 @@ static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */, * For DTV 7/8, the firmware uses BW = 8000, so it needs a * further adjustment to get the frequency center on VHF */ + + /* + * The firmware DTV78 used to work fine in UHF band (8 MHz + * bandwidth) but not at all in VHF band (7 MHz bandwidth). + * The real problem was connected to the formula used to + * calculate the center frequency offset in VHF band. + * In fact, removing the 500KHz adjustment fixed the problem. + * This is coherent to what was implemented for the DTV7 + * firmware. + * In the end, now the center frequency is the same for all 3 + * firmwares (DTV7, DTV8, DTV78) and doesn't depend on channel + * bandwidth. + */ + if (priv->cur_fw.type & DTV6) offset = 1750000; - else if (priv->cur_fw.type & DTV7) - offset = 2250000; - else /* DTV8 or DTV78 */ + else /* DTV7 or DTV8 or DTV78 */ offset = 2750000; - if ((priv->cur_fw.type & DTV78) && freq < 470000000) - offset -= 500000; /*