From patchwork Fri Jun 3 15:27:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "istvan_v@mailbox.hu" X-Patchwork-Id: 847612 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p53FRZm1028493 for ; Fri, 3 Jun 2011 15:27:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756008Ab1FCP1e (ORCPT ); Fri, 3 Jun 2011 11:27:34 -0400 Received: from mail.juropnet.hu ([212.24.188.131]:55484 "EHLO mail.juropnet.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751988Ab1FCP1d (ORCPT ); Fri, 3 Jun 2011 11:27:33 -0400 Received: from [94.248.227.103] by mail.juropnet.hu with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1QSWHa-0003KO-Q6 for linux-media@vger.kernel.org; Fri, 03 Jun 2011 17:27:32 +0200 Message-ID: <4DE8FD62.406@mailbox.hu> Date: Fri, 03 Jun 2011 17:27:30 +0200 From: "istvan_v@mailbox.hu" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20090915 SUSE/3.0b4-3.6 Thunderbird/3.0b4 MIME-Version: 1.0 To: linux-media@vger.kernel.org Subject: XC4000: fixed frequency error References: <4D764337.6050109@email.cz> <20110531124843.377a2a80@glory.local> <20110531174323.0f0c45c0@glory.local> In-Reply-To: X-Host-Lookup-Failed: Reverse DNS lookup failed for 94.248.227.103 (failed) X-Spam-Score: -4.2 (----) X-Scan-Signature: a4f14732b2cca6a29ae1a1c6a2a9d330 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 03 Jun 2011 15:27:36 +0000 (UTC) The xc_get_frequency_error() function reported the frequency error incorrectly. The data read from the hardware is a signed integer, in 15625 Hz units. The attached patch fixes the bug. Signed-off-by: Istvan Varga diff -uNr xc4000_orig/drivers/media/common/tuners/xc4000.c xc4000/drivers/media/common/tuners/xc4000.c --- xc4000_orig/drivers/media/common/tuners/xc4000.c 2011-06-03 17:09:54.000000000 +0200 +++ xc4000/drivers/media/common/tuners/xc4000.c 2011-06-03 17:14:12.000000000 +0200 @@ -418,8 +418,9 @@ if (result != XC_RESULT_SUCCESS) return result; - tmp = (u32)regData; - (*freq_error_hz) = (tmp * 15625) / 1000; + tmp = (u32)regData & 0xFFFFU; + tmp = (tmp < 0x8000U ? tmp : 0x10000U - tmp); + (*freq_error_hz) = tmp * 15625; return result; }