From patchwork Sun Oct 13 09:00:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "guido.cordaro@tiscali.it" X-Patchwork-Id: 20377 Received: from localhost ([127.0.0.1] helo=www.linuxtv.org) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1VVHX8-0004IC-Us; Sun, 13 Oct 2013 11:00:19 +0200 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1VVHX6-0004I7-Ed for vdr@linuxtv.org; Sun, 13 Oct 2013 11:00:16 +0200 X-tubIT-Incoming-IP: 213.205.33.245 Received: from santino.mail.tiscali.it ([213.205.33.245]) by mail.tu-berlin.de (exim-4.72/mailfrontend-5) with esmtp for id 1VVHX0-0006X9-9F; Sun, 13 Oct 2013 11:00:16 +0200 Received: from [192.168.1.3] ([84.222.164.78]) by santino.mail.tiscali.it with id cZ091m00P1hoTh801Z09JY; Sun, 13 Oct 2013 11:00:10 +0200 x-auth-user: guido.cordaro@tiscali.it Message-ID: <525A6119.8060807@tiscali.it> Date: Sun, 13 Oct 2013 11:00:09 +0200 From: "guido.cordaro@tiscali.it" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: VDR Mailing List References: <525A5F08.9070709@tiscali.it> In-Reply-To: <525A5F08.9070709@tiscali.it> X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2013.10.13.60014 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, MIME_TEXT_ONLY_MP_MIXED 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_6000_6999 0, BODY_SIZE_7000_LESS 0, __ANY_URI 0, __BAT_BOUNDARY 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CP_URI_IN_BODY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_MIXED 0, __FORWARDED_MSG 0, __HAS_FROM 0, __HAS_MSGID 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __MOZILLA_USER_AGENT 0, __SANE_MSGID 0, __SUBJ_ALPHA_NEGATE 0, __SXL_URI_TIMEOUT , __TO_MALFORMED_2 0, __URI_NS , __USER_AGENT 0' X-LSpam-Score: -1.1 (-) X-LSpam-Report: No, score=-1.1 required=5.0 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RDNS_NONE=0.793, URIBL_BLOCKED=0.001 autolearn=no Subject: Re: [vdr] Fix SIGNALSTRENGTH in vdr 2.0.3 TechniSat SkyStar 2 DVB-S rev 2.3P - dvbdevice.c X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: vdr-bounces@linuxtv.org Errors-To: vdr-bounces@linuxtv.org Il 13/10/2013 10:51, guido.cordaro@tiscali.it ha scritto: > Thanks Klaus Schmidinger > > For having responded to my e-mail > > This' modified code that you send as an attachment ... > > Files created with " diff -urN > new.diff " > > Guido Cordaro > > > > > Il 12/10/2013 23:08, Klaus Schmidinger ha scritto: >> On 12.10.2013 21:21, knap.home wrote: >>> With this change to the source I was able to run properly "SIGNAL >>> STRENGTH." >>> >>> Using the device Netsystem TechniSat SkyStar 2 DVB-S rev 2.3P. >>> >>> Great as a solution ... >>> >>> Modified Source -> /usr/local/src/vdr-2.0.3/dvbdevice.c >> >> Please send just the differences (diff -u) between the original and the >> modified code. I'm afraid even though I tried I can't seem to generate >> a proper diff from what you've posted. And please send it as an >> attachment, >> not inline (lines get wrapped). >> >> Klaus >> >> _______________________________________________ >> vdr mailing list >> vdr@linuxtv.org >> http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr > --- /home/knap/Patch/vdr-2.0.3/dvbdevice.c 2013-09-01 23:04:05.000000000 +0200 +++ /home/knap/Patch/dvbdevice.c 2013-10-13 10:34:27.489228803 +0200 @@ -532,33 +532,110 @@ //#define DEBUG_SIGNALSTRENGTH //#define DEBUG_SIGNALQUALITY +// Inizio Modifica + +#define LOCK_THRESHOLD 5 // indicates that all 5 FE_HAS_* flags are set + int cDvbTuner::GetSignalStrength(void) const { - ClearEventQueue(); - uint16_t Signal; - while (1) { - if (ioctl(fd_frontend, FE_READ_SIGNAL_STRENGTH, &Signal) != -1) - break; - if (errno != EINTR) - return -1; + fe_status_t Status; + if (GetFrontendStatus(Status)) { + // Actually one would expect these checks to be done from FE_HAS_SIGNAL to FE_HAS_LOCK, but some drivers (like the stb0899) are broken, so FE_HAS_LOCK is the only one that (hopefully) is generally reliable... + if ((Status & FE_HAS_LOCK) == 0) { + if ((Status & FE_HAS_SIGNAL) == 0) + return 0; + if ((Status & FE_HAS_CARRIER) == 0) + return 1; + if ((Status & FE_HAS_VITERBI) == 0) + return 2; + if ((Status & FE_HAS_SYNC) == 0) + return 3; + return 4; } - uint16_t MaxSignal = 0xFFFF; // Let's assume the default is using the entire range. - // Use the subsystemId to identify individual devices in case they need - // special treatment to map their Signal value into the range 0...0xFFFF. - switch (subsystemId) { - case 0x13C21019: // TT-budget S2-3200 (DVB-S/DVB-S2) - case 0x1AE40001: // TechniSat SkyStar HD2 (DVB-S/DVB-S2) - MaxSignal = 670; break; - } - int s = int(Signal) * 100 / MaxSignal; - if (s > 100) - s = 100; #ifdef DEBUG_SIGNALSTRENGTH - fprintf(stderr, "FE %d/%d: %08X S = %04X %04X %3d%%\n", adapter, frontend, subsystemId, MaxSignal, Signal, s); + bool HasSignal = true; +#endif + uint16_t Signal; + while (1) { + if (ioctl(fd_frontend, FE_READ_SIGNAL_STRENGTH, &Signal) != -1) + break; + if (errno != EINTR) { + Signal = 0xFFFF; +#ifdef DEBUG_SIGNALSTRENGTH + HasSignal = false; +#endif + break; + } + } +#ifdef DEBUG_SIGNALSTRENGTH + bool HasBer = true; +#endif + uint32_t Ber; + while (1) { + if (ioctl(fd_frontend, FE_READ_BER, &Ber) != -1) + break; + if (errno != EINTR) { + Ber = 0; +#ifdef DEBUG_SIGNALSTRENGTH + HasBer = false; #endif - return s; + break; + } + } +#ifdef DEBUG_SIGNALSTRENGTH + bool HasUnc = true; +#endif + uint32_t Unc; + while (1) { + if (ioctl(fd_frontend, FE_READ_UNCORRECTED_BLOCKS, &Unc) != -1) + break; + if (errno != EINTR) { + Unc = 0; +#ifdef DEBUG_SIGNALSTRENGTH + HasUnc = false; +#endif + break; + } + } + uint16_t MinSignal = 0x0000; + uint16_t MaxSignal = 0xFFFF; // Let's assume the default is using the entire range. + // Use the subsystemId to identify individual devices in case they need + // special treatment to map their Snr value into the range 0...0xFFFF. + switch (subsystemId) { + case 0x13C21019: // TT-budget S2-3200 (DVB-S/DVB-S2) + case 0x1AE40001: // TechniSat SkyStar HD2 (DVB-S/DVB-S2) + if (frontendType == SYS_DVBS2) { + MinSignal = 10; + MaxSignal = 70; + } + else +// MaxSignal = 200; + MaxSignal = 670; + + break; + case 0x20130245: // PCTV Systems PCTV 73ESE + case 0x2013024F: // PCTV Systems nanoStick T2 290e +// MaxSignal = 255; break; + MaxSignal = 670; + + } + int a = int(constrain(Signal, MinSignal, MaxSignal)) * 350 / (MaxSignal - MinSignal); + int b = 100 - (Unc * 10 + (Ber / 256) * 5); + if (b < 0) + b = 0; + int s = LOCK_THRESHOLD + a * b * (100 - LOCK_THRESHOLD) / 100 / 100; + if (s > 100) + s = 100; + #ifdef DEBUG_SIGNALSTRENGTH + fprintf(stderr, "FE %d/%d: %08X S = %04X %04X %d %5d %5d %3d%%\n", adapter, frontend, subsystemId, MaxSignal, Signal, HasSignal, HasBer ? int(Ber) : -1, HasUnc ? int(Unc) : -1, s); +#endif + return s; + } + return -1; } +// Fine Modifica + #define LOCK_THRESHOLD 5 // indicates that all 5 FE_HAS_* flags are set int cDvbTuner::GetSignalQuality(void) const