From patchwork Sun Oct 10 15:08:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tuxoholic X-Patchwork-Id: 244201 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 o9AFBtT7013093 for ; Sun, 10 Oct 2010 15:14:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752139Ab0JJPO6 (ORCPT ); Sun, 10 Oct 2010 11:14:58 -0400 Received: from blu0-omc1-s10.blu0.hotmail.com ([65.55.116.21]:57876 "EHLO blu0-omc1-s10.blu0.hotmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751974Ab0JJPO6 (ORCPT ); Sun, 10 Oct 2010 11:14:58 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sun, 10 Oct 2010 15:14:59 +0000 (UTC) X-Greylist: delayed 370 seconds by postgrey-1.27 at vger.kernel.org; Sun, 10 Oct 2010 11:14:57 EDT Received: from BLU0-SMTP58 ([65.55.116.7]) by blu0-omc1-s10.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 10 Oct 2010 08:08:47 -0700 X-Originating-IP: [89.236.138.144] X-Originating-Email: [tuxoholic@hotmail.de] Message-ID: Received: from ubull.localnet ([89.236.138.144]) by BLU0-SMTP58.phx.gbl over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Sun, 10 Oct 2010 08:08:43 -0700 Subject: [PATCH v2] V4L/DVB: faster DVB-S lock for mantis cards using stb0899 demod To: linux-media@vger.kernel.org CC: manu@linuxtv.org From: SE Date: Sun, 10 Oct 2010 17:08:27 +0200 MIME-Version: 1.0 X-OriginalArrivalTime: 10 Oct 2010 15:08:46.0667 (UTC) FILETIME=[095899B0:01CB688D] Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org diff --git a/drivers/media/dvb/frontends/stb0899_algo.c b/drivers/media/dvb/frontends/stb0899_algo.c index 2da55ec..3efde1e 100644 --- a/drivers/media/dvb/frontends/stb0899_algo.c +++ b/drivers/media/dvb/frontends/stb0899_algo.c @@ -206,7 +206,6 @@ static enum stb0899_status stb0899_check_tmg(struct stb0899_state *state) static enum stb0899_status stb0899_search_tmg(struct stb0899_state *state) { struct stb0899_internal *internal = &state->internal; - struct stb0899_params *params = &state->params; short int derot_step, derot_freq = 0, derot_limit, next_loop = 3; int index = 0; @@ -216,10 +215,9 @@ static enum stb0899_status stb0899_search_tmg(struct stb0899_state *state) /* timing loop computation & symbol rate optimisation */ derot_limit = (internal->sub_range / 2L) / internal->mclk; - derot_step = (params->srate / 2L) / internal->mclk; + derot_step = internal->derot_step * 4; /* dertot_step = decreasing delta */ while ((stb0899_check_tmg(state) != TIMINGOK) && next_loop) { - index++; derot_freq += index * internal->direction * derot_step; /* next derot zig zag position */ if (abs(derot_freq) > derot_limit) @@ -230,6 +228,7 @@ static enum stb0899_status stb0899_search_tmg(struct stb0899_state *state) STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(state->config->inversion * derot_freq)); stb0899_write_regs(state, STB0899_CFRM, cfr, 2); /* derotator frequency */ } + index++; internal->direction = -internal->direction; /* Change zigzag direction */ } @@ -278,14 +277,18 @@ static enum stb0899_status stb0899_search_carrier(struct stb0899_state *state) { struct stb0899_internal *internal = &state->internal; - short int derot_freq = 0, last_derot_freq = 0, derot_limit, next_loop = 3; + short int derot_freq = 0, last_derot_freq = 0, derot_limit, derot_step, next_loop = 3; int index = 0; + int base_freq; u8 cfr[2]; u8 reg; internal->status = NOCARRIER; derot_limit = (internal->sub_range / 2L) / internal->mclk; derot_freq = internal->derot_freq; + derot_step = internal->derot_step * 2; + last_derot_freq = internal->derot_freq; + base_freq = internal->derot_freq; reg = stb0899_read_reg(state, STB0899_CFD); STB0899_SETFIELD_VAL(CFD_ON, reg, 1); @@ -294,11 +297,10 @@ static enum stb0899_status stb0899_search_carrier(struct stb0899_state *state) do { dprintk(state->verbose, FE_DEBUG, 1, "Derot Freq=%d, mclk=%d", derot_freq, internal->mclk); if (stb0899_check_carrier(state) == NOCARRIER) { - index++; last_derot_freq = derot_freq; - derot_freq += index * internal->direction * internal->derot_step; /* next zig zag derotator position */ + derot_freq += index * internal->direction * derot_step; /* next zig zag derotator position */ - if(abs(derot_freq) > derot_limit) + if (derot_freq > base_freq + derot_limit || derot_freq < base_freq - derot_limit) next_loop--; if (next_loop) { @@ -310,9 +312,10 @@ static enum stb0899_status stb0899_search_carrier(struct stb0899_state *state) STB0899_SETFIELD_VAL(CFRL, cfr[1], LSB(state->config->inversion * derot_freq)); stb0899_write_regs(state, STB0899_CFRM, cfr, 2); /* derotator frequency */ } + index++; + internal->direction = -internal->direction; /* Change zigzag direction */ } - internal->direction = -internal->direction; /* Change zigzag direction */ } while ((internal->status != CARRIEROK) && next_loop); if (internal->status == CARRIEROK) { @@ -338,6 +341,7 @@ static enum stb0899_status stb0899_check_data(struct stb0899_state *state) int lock = 0, index = 0, dataTime = 500, loop; u8 reg; + msleep(1); internal->status = NODATA; /* RESET FEC */ @@ -348,6 +352,7 @@ static enum stb0899_status stb0899_check_data(struct stb0899_state *state) reg = stb0899_read_reg(state, STB0899_TSTRES); STB0899_SETFIELD_VAL(FRESACS, reg, 0); stb0899_write_reg(state, STB0899_TSTRES, reg); + msleep(1); if (params->srate <= 2000000) dataTime = 2000; @@ -360,6 +365,7 @@ static enum stb0899_status stb0899_check_data(struct stb0899_state *state) stb0899_write_reg(state, STB0899_DSTATUS2, 0x00); /* force search loop */ while (1) { + msleep(1); // Alex: added 1 mSec /* WARNING! VIT LOCKED has to be tested before VIT_END_LOOOP */ reg = stb0899_read_reg(state, STB0899_VSTATUS); lock = STB0899_GETFIELD(VSTATUS_LOCKEDVIT, reg); @@ -387,20 +393,21 @@ static enum stb0899_status stb0899_search_data(struct stb0899_state *state) short int derot_freq, derot_step, derot_limit, next_loop = 3; u8 cfr[2]; u8 reg; - int index = 1; + int index = 0; + int base_freq; struct stb0899_internal *internal = &state->internal; - struct stb0899_params *params = &state->params; - derot_step = (params->srate / 4L) / internal->mclk; + derot_step = internal->derot_step; derot_limit = (internal->sub_range / 2L) / internal->mclk; derot_freq = internal->derot_freq; + base_freq = internal->derot_freq; do { if ((internal->status != CARRIEROK) || (stb0899_check_data(state) != DATAOK)) { derot_freq += index * internal->direction * derot_step; /* next zig zag derotator position */ - if (abs(derot_freq) > derot_limit) + if (derot_freq > base_freq + derot_limit || derot_freq < base_freq - derot_limit) next_loop--; if (next_loop) { @@ -414,9 +421,9 @@ static enum stb0899_status stb0899_search_data(struct stb0899_state *state) stb0899_write_regs(state, STB0899_CFRM, cfr, 2); /* derotator frequency */ stb0899_check_carrier(state); - index++; } } + index++; internal->direction = -internal->direction; /* change zig zag direction */ } while ((internal->status != DATAOK) && next_loop); -- 1.7.1