From patchwork Wed Sep 2 01:37:05 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitri Belimov X-Patchwork-Id: 45122 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n821awru007635 for ; Wed, 2 Sep 2009 01:36:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932098AbZIBBgy (ORCPT ); Tue, 1 Sep 2009 21:36:54 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755518AbZIBBgy (ORCPT ); Tue, 1 Sep 2009 21:36:54 -0400 Received: from mail-ew0-f206.google.com ([209.85.219.206]:47797 "EHLO mail-ew0-f206.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755370AbZIBBgx (ORCPT ); Tue, 1 Sep 2009 21:36:53 -0400 Received: by ewy2 with SMTP id 2so369606ewy.17 for ; Tue, 01 Sep 2009 18:36:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:x-mailer:mime-version:content-type; bh=OL10It+dhHWjs72uuUn9cUFuO8Y3zy9pdyD2HeOQuiw=; b=cl5TQ96I/Kxq0cD9yEcIWMQchup3iZL+WBi8kKJBAMAcGxg+HuxflKWX9DO9kpHKum j5KQqORfm3ltuVxQ1dHdUz9z7jIaYytVuHg4iT/GAUlMchrOhPSG1hYxNDYu+w9m/Oqa 1W1eH9EXWN4wKRxxbc5V1DWKpeJgfqFNG8z1o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:x-mailer:mime-version:content-type; b=Ix24viej12MPZvdMmyIQi0SQVycxPC8jC59XedhJc6odT3g4O+RRtHWl5WWMVX6aeH Hd4ccGh2Wf6wPTCav608l/9w0Y951b2RlFru0lPrje67t2/Gs0AwCcVHmInOw7KKuPBK qHZADVhjD9XBRNI5uJLCwZGO8zvaXyVRuHdGg= Received: by 10.211.180.16 with SMTP id h16mr1017863ebp.10.1251855413792; Tue, 01 Sep 2009 18:36:53 -0700 (PDT) Received: from glory.loctelecom.ru (ns2.openhardware.ru [84.19.183.172]) by mx.google.com with ESMTPS id 10sm510426eyd.2.2009.09.01.18.36.51 (version=SSLv3 cipher=RC4-MD5); Tue, 01 Sep 2009 18:36:52 -0700 (PDT) Date: Wed, 2 Sep 2009 11:37:05 +1000 From: Dmitri Belimov To: linux-media@vger.kernel.org, video4linux-list@redhat.com Subject: [PATCH] Add FM radio for the XC5000 Message-ID: <20090902113705.168af9f0@glory.loctelecom.ru> X-Mailer: Claws Mail 3.5.0 (GTK+ 2.16.1; i486-pc-linux-gnu) Mime-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hi All Add FM radio for the xc5000 silicon tuner chip. Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov With my best regards, Dmitry. diff -r 28f8b0ebd224 linux/drivers/media/common/tuners/xc5000.c --- a/linux/drivers/media/common/tuners/xc5000.c Sun Aug 23 13:55:25 2009 -0300 +++ b/linux/drivers/media/common/tuners/xc5000.c Wed Sep 02 06:32:12 2009 +1000 @@ -747,14 +747,11 @@ return ret; } -static int xc5000_set_analog_params(struct dvb_frontend *fe, +static int xc5000_set_tv_freq(struct dvb_frontend *fe, struct analog_parameters *params) { struct xc5000_priv *priv = fe->tuner_priv; int ret; - - if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) - xc_load_fw_and_init_tuner(fe); dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n", __func__, params->frequency); @@ -834,6 +831,67 @@ return 0; } + +static int xc5000_set_radio_freq(struct dvb_frontend *fe, + struct analog_parameters *params) +{ + struct xc5000_priv *priv = fe->tuner_priv; + int ret = -EINVAL; + + dprintk(1, "%s() frequency=%d (in units of khz)\n", + __func__, params->frequency); + + priv->freq_hz = params->frequency * 125 / 2; + + priv->rf_mode = XC_RF_MODE_AIR; + + ret = xc_SetTVStandard(priv, + XC5000_Standard[FM_Radio_INPUT1].VideoMode, + XC5000_Standard[FM_Radio_INPUT1].AudioMode); + + if (ret != XC_RESULT_SUCCESS) { + printk(KERN_ERR "xc5000: xc_SetTVStandard failed\n"); + return -EREMOTEIO; + } + + ret = xc_SetSignalSource(priv, priv->rf_mode); + if (ret != XC_RESULT_SUCCESS) { + printk(KERN_ERR + "xc5000: xc_SetSignalSource(%d) failed\n", + priv->rf_mode); + return -EREMOTEIO; + } + + xc_tune_channel(priv, priv->freq_hz, XC_TUNE_ANALOG); + + return 0; +} + +static int xc5000_set_analog_params(struct dvb_frontend *fe, + struct analog_parameters *params) +{ + struct xc5000_priv *priv = fe->tuner_priv; + int ret = -EINVAL; + + if (priv->i2c_props.adap == NULL) + return -EINVAL; + + if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) + xc_load_fw_and_init_tuner(fe); + + switch (params->mode) { + case V4L2_TUNER_RADIO: + ret = xc5000_set_radio_freq(fe, params); + break; + case V4L2_TUNER_ANALOG_TV: + case V4L2_TUNER_DIGITAL_TV: + ret = xc5000_set_tv_freq(fe, params); + break; + } + + return ret; +} + static int xc5000_get_frequency(struct dvb_frontend *fe, u32 *freq) { Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov