From patchwork Thu Sep 10 05:25:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitri Belimov X-Patchwork-Id: 1570 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Thu, 10 Sep 2009 05:30:00 +0000 Received: from bombadil.infradead.org [18.85.46.34] by caramujo.chehab.org with IMAP (fetchmail-6.3.6) for (single-drop); Thu, 10 Sep 2009 02:34:49 -0300 (BRT) Received: from vger.kernel.org ([209.132.176.167]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MlcEK-0007n5-6f; Thu, 10 Sep 2009 05:30:00 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752372AbZIJF3y (ORCPT + 1 other); Thu, 10 Sep 2009 01:29:54 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752247AbZIJF3y (ORCPT ); Thu, 10 Sep 2009 01:29:54 -0400 Received: from mail-ew0-f217.google.com ([209.85.219.217]:58992 "EHLO mail-ew0-f217.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751850AbZIJF3x (ORCPT ); Thu, 10 Sep 2009 01:29:53 -0400 X-Greylist: delayed 307 seconds by postgrey-1.27 at vger.kernel.org; Thu, 10 Sep 2009 01:29:52 EDT Received: by ewy17 with SMTP id 17so1601544ewy.39 for ; Wed, 09 Sep 2009 22:29: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:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type; bh=IZKnNFezPpEJzZxNaAncALV3cEcuuANlyGPsrliCP4U=; b=D6OZv0vw6pWEG+AcsCyk3HeJIFPhzoa5TPyuU6kZjPRzMaSWkaLdTXRm4rQcTWSo4Y wO3Z9qizK1I3zSmykDZtIsfEMFsR1GX/y3CHxXOahvYP+72UnbXpAiygH1ndcVmCknX5 Xhkxip8gIpJaPwmWAtYDqsw2DAjAz2DznkKHk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; b=LxLsalZK4/zptOb1qM1QfwSunoH8F8rDEZnzkopbZVCYZTJD88xP2id7mMSna8/8aU IuApnQY/DVW3KTmlUawQQbL8gWJvn3J5nI4MtgAHNuGh2opLEYASsRMZ01a/qBPPsohU YK7/bIQDpXNOFMmVjf2J22GPXkIU44fwc+YWs= Received: by 10.211.143.9 with SMTP id v9mr1161209ebn.53.1252560288069; Wed, 09 Sep 2009 22:24:48 -0700 (PDT) Received: from glory.loctelecom.ru (ns2.openhardware.ru [84.19.183.172]) by mx.google.com with ESMTPS id 10sm4525578eyz.30.2009.09.09.22.24.42 (version=SSLv3 cipher=RC4-MD5); Wed, 09 Sep 2009 22:24:45 -0700 (PDT) Date: Thu, 10 Sep 2009 15:25:10 +1000 From: Dmitri Belimov To: Michael Krufky Cc: hermann pitton , Mauro Carvalho Chehab , video4linux-list@redhat.com, linux-media Subject: Re: tuner, code for discuss Message-ID: <20090910152510.6970f8ab@glory.loctelecom.ru> In-Reply-To: <37219a840908250940m3393f73ftbaa28639ca0f93cd@mail.gmail.com> References: <20090819160700.049985b5@glory.loctelecom.ru> <37219a840908250940m3393f73ftbaa28639ca0f93cd@mail.gmail.com> 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 This is my next patch. Changes: 1. By default charge pump is ON 2. For radio mode charge pump set to OFF 3. Set correct AGC value in radio mode 4. Add control gain of AGC. 5. New function simple_get_tv_gain and simple_set_tv_gain for read/write gain of AGC. 6. Add some code for control gain from saa7134 part. By default this control is OFF 7. When TV card can manipulate this control, enable it. Main changes is control value of AGC TOP in .initdata = tua603x_agc112 array. Use this value for set AGC TOP after set freq of TV. I don't understand how to correct call new function for read/write value of AGC TOP. What you think about it?? With my best regards, Dmitry. diff -r 3f7e382dfae5 linux/drivers/media/common/tuners/tuner-simple.c --- a/linux/drivers/media/common/tuners/tuner-simple.c Sun Aug 16 21:53:17 2009 -0300 +++ b/linux/drivers/media/common/tuners/tuner-simple.c Thu Sep 10 06:05:49 2009 +1000 @@ -144,6 +144,7 @@ case TUNER_PHILIPS_FM1256_IH3: case TUNER_LG_NTSC_TAPE: case TUNER_TCL_MF02GIP_5N: + case TUNER_TCL_MFPE05_2: return ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3); default: return status & TUNER_STEREO; @@ -491,6 +492,18 @@ "(should be 4)\n", rc); break; } + case TUNER_TCL_MFPE05_2: + { + + printk("posttune TCL_MFPE05_2\r\n"); + + if (priv->tun->initdata) { + printk("write AUX byte = 0x%X",priv->tun->initdata[2]); + simple_set_aux_byte(fe, config, priv->tun->initdata[2]); + } + + break; + } } return 0; @@ -499,6 +512,7 @@ static int simple_radio_bandswitch(struct dvb_frontend *fe, u8 *buffer) { struct tuner_simple_priv *priv = fe->tuner_priv; + u8 rc; switch (priv->type) { case TUNER_TENA_9533_DI: @@ -513,6 +527,11 @@ case TUNER_LG_NTSC_TAPE: case TUNER_PHILIPS_FM1256_IH3: case TUNER_TCL_MF02GIP_5N: + buffer[3] = 0x19; + break; + case TUNER_TCL_MFPE05_2: + rc = buffer[2]&0xbf; + buffer[2] = rc; /* Switch OFF Charge Pump */ buffer[3] = 0x19; break; case TUNER_TNF_5335MF: @@ -754,7 +773,53 @@ if (4 != rc) tuner_warn("i2c i/o error: rc == %d (should be 4)\n", rc); + /* Write AUX byte */ + switch (priv->type) { + case TUNER_TCL_MFPE05_2: + printk("write AUX byte\n"); + simple_set_aux_byte(fe, 0x98, 0x20); + break; + } + return 0; +} + +static int simple_set_tv_gain(struct dvb_frontend *fe, + u8 tvgain) +{ + struct tuner_simple_priv *priv = fe->tuner_priv; + int ret = -EINVAL; + + switch (priv->type) { + case TUNER_TCL_MFPE05_2: + if (priv->tun->initdata) { + priv->tun->initdata[2] = tvgain; + printk("set AUX byte = 0x%X",priv->tun->initdata[2]); + ret = 0; + } + break; + } /* switch (priv->type) */ + + return ret; +} + +static int simple_get_tv_gain(struct dvb_frontend *fe, + u8 *tvgain) +{ + struct tuner_simple_priv *priv = fe->tuner_priv; + int ret = -EINVAL; + + switch (priv->type) { + case TUNER_TCL_MFPE05_2: + if (priv->tun->initdata) { + *tvgain = priv->tun->initdata[2]; + printk("read AUX byte = 0x%X",priv->tun->initdata[2]); + ret = 0; + } + break; + } /* switch (priv->type) */ + + return ret; } static int simple_set_params(struct dvb_frontend *fe, diff -r 3f7e382dfae5 linux/drivers/media/common/tuners/tuner-types.c --- a/linux/drivers/media/common/tuners/tuner-types.c Sun Aug 16 21:53:17 2009 -0300 +++ b/linux/drivers/media/common/tuners/tuner-types.c Thu Sep 10 06:05:49 2009 +1000 @@ -1321,6 +1321,31 @@ }, }; +/* ------------ TUNER_TCL_MFPE05_2 - TCL MFPE05-2 ALL ------------ */ + +static struct tuner_range tuner_tcl_mfpe05_2_all_ranges[] = { + { 16 * 158.00 /*MHz*/, 0xc6, 0x01, }, + { 16 * 441.00 /*MHz*/, 0xc6, 0x02, }, + { 16 * 864.00 , 0xc6, 0x04, }, +}; + +static struct tuner_params tuner_tcl_mfpe05_2_all_params[] = { + { + .type = TUNER_PARAM_TYPE_PAL, + .ranges = tuner_tcl_mfpe05_2_all_ranges, + .count = ARRAY_SIZE(tuner_tcl_mfpe05_2_all_ranges), + .cb_first_if_lower_freq = 1, + .has_tda9887 = 1, + .port1_active = 1, + .port2_active = 1, + .port2_invert_for_secam_lc = 1, + .port1_fm_high_sensitivity = 1, + .default_top_mid = -2, + .default_top_secam_mid = -2, + .default_top_secam_high = -2, + }, +}; + /* --------------------------------------------------------------------- */ struct tunertype tuners[] = { @@ -1779,6 +1804,14 @@ .params = tuner_partsnic_pti_5nf05_params, .count = ARRAY_SIZE(tuner_partsnic_pti_5nf05_params), }, + + [TUNER_TCL_MFPE05_2] = { /* TCL ALL */ + .name = "TCL MFPE05-2 MK3 PAL/SECAM multi (Beholder Lab)", + .params = tuner_tcl_mfpe05_2_all_params, + .count = ARRAY_SIZE(tuner_tcl_mfpe05_2_all_params), + .initdata = tua603x_agc112, + .sleepdata = (u8[]){ 4, 0x9c, 0x60, 0x85, 0x54 }, + }, }; EXPORT_SYMBOL(tuners); diff -r 3f7e382dfae5 linux/drivers/media/video/saa7134/saa7134-cards.c --- a/linux/drivers/media/video/saa7134/saa7134-cards.c Sun Aug 16 21:53:17 2009 -0300 +++ b/linux/drivers/media/video/saa7134/saa7134-cards.c Thu Sep 10 06:05:49 2009 +1000 @@ -4500,7 +4500,7 @@ /* Alexey Osipov */ .name = "Beholder BeholdTV M6", .audio_clock = 0x00187de7, - .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, + .tuner_type = TUNER_TCL_MFPE05_2, .radio_type = UNSET, .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, @@ -4537,7 +4537,7 @@ /* Beholder Intl. Ltd. Dmitry Belimov */ .name = "Beholder BeholdTV M63", .audio_clock = 0x00187de7, - .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, + .tuner_type = TUNER_TCL_MFPE05_2, .radio_type = UNSET, .tuner_addr = ADDR_UNSET, .radio_addr = ADDR_UNSET, @@ -7099,6 +7099,18 @@ } break; } + case SAA7134_BOARD_BEHOLD_M6: + case SAA7134_BOARD_BEHOLD_M63: + { + struct v4l2_queryctrl* ctl; + struct saa7134_fh *fh; + struct file *fl; + + ctl->id = V4L2_CID_GAIN; + if (saa7134_queryctrl(fl,fh,ctl)==0){ + ctl->flags &= ~(V4L2_CTRL_FLAG_DISABLED); /* enable this control */ + } + } } /* switch() */ /* initialize tuner */ diff -r 3f7e382dfae5 linux/drivers/media/video/saa7134/saa7134-video.c --- a/linux/drivers/media/video/saa7134/saa7134-video.c Sun Aug 16 21:53:17 2009 -0300 +++ b/linux/drivers/media/video/saa7134/saa7134-video.c Thu Sep 10 06:05:49 2009 +1000 @@ -413,6 +413,15 @@ .step = 1, .default_value = 0, .type = V4L2_CTRL_TYPE_INTEGER, + },{ + .id = V4L2_CID_GAIN, + .name = "Gain", + .minimum = 0, + .maximum = 6, + .step = 1, + .default_value = 3, + .type = V4L2_CTRL_TYPE_INTEGER, + .flags = V4L2_CTRL_FLAG_DISABLED, },{ .id = V4L2_CID_HFLIP, .name = "Mirror", @@ -1128,6 +1137,9 @@ case V4L2_CID_HUE: c->value = dev->ctl_hue; break; + case V4L2_CID_GAIN: + c->value = dev->ctl_gain; + break; case V4L2_CID_CONTRAST: c->value = dev->ctl_contrast; break; @@ -1175,6 +1187,7 @@ unsigned long flags; int restart_overlay = 0; int err; + unsigned char tgain; /* When called from the empress code fh == NULL. That needs to be fixed somehow, but for now this is @@ -1214,6 +1227,38 @@ dev->ctl_hue = c->value; saa_writeb(SAA7134_DEC_CHROMA_HUE, dev->ctl_hue); break; + case V4L2_CID_GAIN: + dev->ctl_gain = c->value; + + switch (c->value) { + case 0: + tgain = 0x80|0x50; /* TOP = 103dB, ATC = OFF */ + break; + case 1: + tgain = 0x80|0x40; /* TOP = 106dB, ATC = OFF */ + break; + case 2: + tgain = 0x80|0x30; /* TOP = 109dB, ATC = OFF */ + break; + case 3: + tgain = 0x80|0x20; /* TOP = 112dB, ATC = OFF */ + break; + case 4: + tgain = 0x80|0x10; /* TOP = 115dB, ATC = OFF */ + break; + case 5: + tgain = 0x80|0x00; /* TOP = 118dB, ATC = OFF */ + break; + case 6: + tgain = 0x80|0x60; /* TOP = External AGC, ATC = OFF */ + break; + default: + tgain = 0x80|0x20; + break; + } + /* call simple set AUX byte here */ + /* simple_set_v_gain(); */ + break; case V4L2_CID_CONTRAST: dev->ctl_contrast = c->value; saa_writeb(SAA7134_DEC_LUMA_CONTRAST, @@ -2534,6 +2579,7 @@ dev->ctl_bright = ctrl_by_id(V4L2_CID_BRIGHTNESS)->default_value; dev->ctl_contrast = ctrl_by_id(V4L2_CID_CONTRAST)->default_value; dev->ctl_hue = ctrl_by_id(V4L2_CID_HUE)->default_value; + dev->ctl_gain = ctrl_by_id(V4L2_CID_GAIN)->default_value; dev->ctl_saturation = ctrl_by_id(V4L2_CID_SATURATION)->default_value; dev->ctl_volume = ctrl_by_id(V4L2_CID_AUDIO_VOLUME)->default_value; dev->ctl_mute = 1; // ctrl_by_id(V4L2_CID_AUDIO_MUTE)->default_value; diff -r 3f7e382dfae5 linux/drivers/media/video/saa7134/saa7134.h --- a/linux/drivers/media/video/saa7134/saa7134.h Sun Aug 16 21:53:17 2009 -0300 +++ b/linux/drivers/media/video/saa7134/saa7134.h Thu Sep 10 06:05:49 2009 +1000 @@ -565,6 +565,7 @@ int ctl_bright; int ctl_contrast; int ctl_hue; + int ctl_gain; /* gain */ int ctl_saturation; int ctl_freq; int ctl_mute; /* audio */ diff -r 3f7e382dfae5 linux/include/media/tuner.h --- a/linux/include/media/tuner.h Sun Aug 16 21:53:17 2009 -0300 +++ b/linux/include/media/tuner.h Thu Sep 10 06:05:49 2009 +1000 @@ -127,6 +127,7 @@ #define TUNER_PHILIPS_FM1216MK5 79 #define TUNER_PHILIPS_FQ1216LME_MK3 80 /* Active loopthrough, no FM */ #define TUNER_PARTSNIC_PTI_5NF05 81 +#define TUNER_TCL_MFPE05_2 82 /* TCL clone of the Philips FM1216ME_MK3 */ /* tv card specific */ #define TDA9887_PRESENT (1<<0)