From patchwork Sun Dec 4 22:22:21 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinhard Nissl X-Patchwork-Id: 12109 Received: from mail.gmx.de ([213.165.64.20] helo=mail.gmx.net) by www.linuxtv.org with smtp (Exim 4.50) id 1Ej2Fy-0005pg-K8 for vdr@linuxtv.org; Sun, 04 Dec 2005 23:22:54 +0100 Received: (qmail invoked by alias); 04 Dec 2005 22:22:23 -0000 Received: from ambg-c3471384.pool.mediaWays.net (EHLO [192.168.101.15]) [195.71.19.132] by mail.gmx.net (mp010) with SMTP; 04 Dec 2005 23:22:23 +0100 X-Authenticated: #527675 Message-ID: <43936C1D.2070904@gmx.de> Date: Sun, 04 Dec 2005 23:22:21 +0100 From: Reinhard Nissl User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: VDR Mailing List X-Y-GMX-Trusted: 0 Subject: [vdr] VDR-1.3.37: retuning -- possibly a fix for VDSB X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Dec 2005 22:22:54 -0000 Status: O X-Status: X-Keywords: X-UID: 6497 Hi, the attached patch introduces some timeouts while the device is tuning and when it looses the lock: DISEQC_REPEAT_TIMEOUT (500 ms) is used to repeat the DiSEqC signalling in case the where a multiswitch receives at first a malformed message and therefore doesn't switch. TUNE_TO_RETUNE_TIMEOUT (3000 ms) is used to instruct the device to start the tuning operation once again in case the above DiSEqC signalling doesn't work. LOST_LOCK_TO_RETUNE_TIMEOUT (500 ms) lets the device retune after a LOCKED to NOT LOCKED transition, probably under bad reception conditions. Please give the patch a try and report success or failure. Tests of special interest: - bad reception conditions (DVB-T) - steering dishes Bye. --- ../vdr-1.3.37-orig/dvbdevice.c 2005-11-26 14:23:11.000000000 +0100 +++ dvbdevice.c 2005-12-04 22:43:41.000000000 +0100 @@ -277,15 +277,24 @@ bool cDvbTuner::SetFrontend(void) esyslog("ERROR: attempt to set channel with unknown DVB frontend type"); return false; } - if (ioctl(fd_frontend, FE_SET_FRONTEND, &Frontend) < 0) { - esyslog("ERROR: frontend %d: %m", cardIndex); - return false; + if (tunerStatus == tsSet) { + if (ioctl(fd_frontend, FE_SET_FRONTEND, &Frontend) < 0) { + esyslog("ERROR: frontend %d: %m", cardIndex); + return false; + } } return true; } +#define DISEQC_REPEAT_TIMEOUT 500 //ms +#define TUNE_TO_RETUNE_TIMEOUT 3000 //ms +#define LOST_LOCK_TO_RETUNE_TIMEOUT 500 //ms + void cDvbTuner::Action(void) { + enum { tssIdle, tssLostLock } TunerSubStatus = tssIdle; + cTimeMs Timer, DiseqcRepeatTimer; + dvb_frontend_event event; while (Running()) { bool hasEvent = GetFrontendEvent(event, 1); @@ -298,8 +307,24 @@ void cDvbTuner::Action(void) if (hasEvent) continue; tunerStatus = SetFrontend() ? tsTuned : tsIdle; + TunerSubStatus = tssIdle; + Timer.Set(TUNE_TO_RETUNE_TIMEOUT); + DiseqcRepeatTimer.Set(DISEQC_REPEAT_TIMEOUT); continue; case tsTuned: + if (Timer.TimedOut()) { + tunerStatus = tsSet; + diseqcCommands = NULL; // deep re-tuning (= resend DiSEqC commands) + esyslog("ERROR: frontend %d timed out while tuning - re-tuning", cardIndex); + continue; + } + if (diseqcCommands && DiseqcRepeatTimer.TimedOut()) { + diseqcCommands = NULL; // deep re-tuning (= resend DiSEqC commands) + dsyslog("cDvbTuner: frontend %d: resending DiSEqC commands", cardIndex); + SetFrontend(); // repeat DiSEqC commands + DiseqcRepeatTimer.Set(DISEQC_REPEAT_TIMEOUT); + continue; + } case tsLocked: if (hasEvent) { if (event.status & FE_REINIT) { @@ -308,16 +333,26 @@ void cDvbTuner::Action(void) } if (event.status & FE_HAS_LOCK) { tunerStatus = tsLocked; + TunerSubStatus = tssIdle; locked.Broadcast(); } + else if (tunerStatus >= tsLocked) { + TunerSubStatus = tssLostLock; + Timer.Set(LOST_LOCK_TO_RETUNE_TIMEOUT); + } + continue; + } + else if (tunerStatus >= tsLocked && TunerSubStatus == tssLostLock && Timer.TimedOut()) { + tunerStatus = tsSet; + esyslog("ERROR: frontend %d lost lock - re-tuning", cardIndex); continue; } } if (ciHandler) ciHandler->Process(); - if (tunerStatus != tsTuned) - newSet.TimedWait(mutex, 1000); + if (tunerStatus != tsTuned) // the tuners sub status may require faster reaction + newSet.TimedWait(mutex, (TunerSubStatus != tssIdle) ? 100 : 1000); } }