From patchwork Wed Jan 4 19:17:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gianluca Gennari X-Patchwork-Id: 9312 Return-path: Envelope-to: mchehab@canuck.infradead.org Delivery-date: Wed, 04 Jan 2012 19:20:42 +0000 Received: from canuck.infradead.org [134.117.69.58] by gaivota with IMAP (fetchmail-6.3.20) for (single-drop); Wed, 04 Jan 2012 17:20:48 -0200 (BRST) Received: from casper.infradead.org ([2001:770:15f::2]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1RiWO9-00073e-Ly for mchehab@canuck.infradead.org; Wed, 04 Jan 2012 19:20:42 +0000 Received: from vger.kernel.org ([209.132.180.67]) by casper.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RiWO2-0003Fs-59; Wed, 04 Jan 2012 19:20:34 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753900Ab2ADTUQ (ORCPT + 1 other); Wed, 4 Jan 2012 14:20:16 -0500 Received: from mail-ee0-f46.google.com ([74.125.83.46]:56458 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752303Ab2ADTUJ (ORCPT ); Wed, 4 Jan 2012 14:20:09 -0500 Received: by eekc4 with SMTP id c4so16921540eek.19 for ; Wed, 04 Jan 2012 11:20:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=sx6Mco5CTVxWQEgKQ1nYWS7rsgQWSMMoFwOo+E0m/Ak=; b=ZiFbTIit5in3C8p61cSEYXLaI+So46peuvlkIQ3nDcVMv9dwFUowoKolNKCezK0aV4 WDRyf0u8GdG+bVRzCO/A8NV1iAGdJiT4f5nnYUel5eBvF5MhTDDLMmXEonTAUWo9kwAh VaBhQISLcni0GPx3nm9BMGGMlDFSvh5w020Nk= Received: by 10.14.32.14 with SMTP id n14mr23185255eea.64.1325704807997; Wed, 04 Jan 2012 11:20:07 -0800 (PST) Received: from localhost.localdomain (93-50-34-119.ip150.fastwebnet.it. [93.50.34.119]) by mx.google.com with ESMTPS id 19sm47272833eew.7.2012.01.04.11.20.06 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Jan 2012 11:20:07 -0800 (PST) From: Gianluca Gennari To: linux-media@vger.kernel.org, mchehab@redhat.com Cc: Gianluca Gennari Subject: [PATCH v3] xc3028: fix center frequency calculation for DTV78 firmware Date: Wed, 4 Jan 2012 20:17:19 +0100 Message-Id: <1325704639-21010-1-git-send-email-gennarone@gmail.com> X-Mailer: git-send-email 1.7.5.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hi all, this v3 version has been sent through "git send-email" to avoid line-wrapping problems. 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(-) 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; /* * 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