[vdr] [PATCH] Device power saving feature

2016-05-26 Thread glenvt18
Hi folks.

This patch introduces a feature which allows an idle device (a device
which is not currently recording or streaming) to enter a power-down
mode after some period of time. Given two timeout values,
PowerdownTimeoutM and PowerdownWakeupH, it works like this: when a
device becomes idle, it is kept powered up for PowerdownTimeoutM minutes
doing, for instance, an EPG scan before it is powered down. If the
device is still idle and has been powered down for PowerdownWakeupH
hours it is powered up for PowerdownTimeoutM minutes and so on. When
recording, streaming or a forced EPG scan starts, the device is powered
up and it's idle timer is disabled. This implies that PowerdownTimeoutM
should be enough for a full round of EPG scanning (20 seconds *
number_of_transponders). Another option is to run EPG scans from cron
(at night) and use SVDRP SCAN command.

Actual implementation of power saving facilities is left to a derived
device class. In the case of a DVB device it is implemented by closing
it's frontend device. For a DVB-S/S2 tuner this usually means powering
the LNB off. My measurements show 3-4W power consumption drops per tuner
for various DVB-S/S2 tuners. So, this feature (together with HDD
spin-down) is especially valuable while running a headless 24/7 VDR
server and/or using several tuners. A SATIP device can also implement
power saving if it is supported by a server.

I know about the dynamite plugin, but 1) it does much more then this, 2)
still requires a VDR patch, which is bigger, 3) doesn't work reliably
for me and 4) I think this functionality should be part of the VDR
core.

A copy of the patch is here:
http://pastebin.com/FRi0kTjf

Please review,
Sergey Chernyavskiy.

---
 config.c|  9 ++
 config.h|  3 ++
 device.c| 96 +++--
 device.h| 29 +++
 dvbdevice.c | 39 +
 dvbdevice.h |  7 +
 eitscan.c   |  7 -
 menu.c  |  9 +-
 vdr.c   |  6 
 9 files changed, 201 insertions(+), 4 deletions(-)

diff --git a/config.c b/config.c
index e5f5463..794c9f8 100644
--- a/config.c
+++ b/config.c
@@ -395,6 +395,9 @@ cSetup::cSetup(void)
   PositionerSpeed = 15;
   PositionerSwing = 650;
   PositionerLastLon = 0;
+  PowerdownEnabled = 0;
+  PowerdownTimeoutM = 15;
+  PowerdownWakeupH = 4;
   SetSystemTime = 0;
   TimeSource = 0;
   TimeTransponder = 0;
@@ -622,6 +625,9 @@ bool cSetup::Parse(const char *Name, const char *Value)
   else if (!strcasecmp(Name, "PositionerSpeed")) PositionerSpeed
  = atoi(Value);
   else if (!strcasecmp(Name, "PositionerSwing")) PositionerSwing
  = atoi(Value);
   else if (!strcasecmp(Name, "PositionerLastLon"))
PositionerLastLon  = atoi(Value);
+  else if (!strcasecmp(Name, "PowerdownEnabled"))PowerdownEnabled
  = atoi(Value);
+  else if (!strcasecmp(Name, "PowerdownTimeoutM"))
PowerdownTimeoutM  = atoi(Value);
+  else if (!strcasecmp(Name, "PowerdownWakeupH"))PowerdownWakeupH
  = atoi(Value);
   else if (!strcasecmp(Name, "SetSystemTime"))   SetSystemTime
  = atoi(Value);
   else if (!strcasecmp(Name, "TimeSource"))  TimeSource
  = cSource::FromString(Value);
   else if (!strcasecmp(Name, "TimeTransponder")) TimeTransponder
  = atoi(Value);
@@ -753,6 +759,9 @@ bool cSetup::Save(void)
   Store("PositionerSpeed",PositionerSpeed);
   Store("PositionerSwing",PositionerSwing);
   Store("PositionerLastLon",  PositionerLastLon);
+  Store("PowerdownEnabled",   PowerdownEnabled);
+  Store("PowerdownTimeoutM",  PowerdownTimeoutM);
+  Store("PowerdownWakeupH",   PowerdownWakeupH);
   Store("SetSystemTime",  SetSystemTime);
   Store("TimeSource", cSource::ToString(TimeSource));
   Store("TimeTransponder",TimeTransponder);
diff --git a/config.h b/config.h
index e5565da..7a73d9d 100644
--- a/config.h
+++ b/config.h
@@ -273,6 +273,9 @@ public:
   int PositionerSpeed;
   int PositionerSwing;
   int PositionerLastLon;
+  int PowerdownEnabled;
+  int PowerdownTimeoutM;
+  int PowerdownWakeupH;
   int SetSystemTime;
   int TimeSource;
   int TimeTransponder;
diff --git a/device.c b/device.c
index 542d120..9306adb 100644
--- a/device.c
+++ b/device.c
@@ -104,6 +104,9 @@ cDevice::cDevice(void)
   dvbSubtitleConverter = NULL;
   autoSelectPreferredSubtitleLanguage = true;

+  idleTimerExpires = time(NULL) + Setup.PowerdownTimeoutM * 60;
+  wakeupTimerExpires = 0;
+
   for (int i = 0; i < MAXRECEIVERS; i++)
   receiver[i] = NULL;

@@ -745,6 +748,11 @@ bool cDevice::SwitchChannel(int Direction)
   return result;
 }

+// While switching to a channel, the device will be kept powered up
+// for at least this number of seconds before a receiver is attached.
+// Must be less than cEITScanner::ScanTimeout.
+#define CHANNEL_SWITCH_POWERUP_TIMEOUT  10
+
 eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
 {
   cStatus::MsgChannelSwitch(this, 0, LiveView);
@@ -778,6 +786,8 @@ eSetChannel

[vdr] [PATCH] cDevice::GetDeviceForTransponder(): fix a typo

2016-05-26 Thread glenvt18
d->MaySwitchTransponder(Channel) is always false here

Please review,
Sergey Chernyavskiy.

---
 device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/device.c b/device.c
index 18867cd..542d120 100644
--- a/device.c
+++ b/device.c
@@ -342,7 +342,7 @@ cDevice *cDevice::GetDeviceForTransponder(const cChannel 
*Channel, int Priority)
  if (d->ProvidesTransponder(Channel)) {
 if (d->MaySwitchTransponder(Channel))
Device = d; // this device may switch to the transponder 
without disturbing any receiver or live view
-else if (!d->Occupied() && d->MaySwitchTransponder(Channel)) { // 
MaySwitchTransponder() implicitly calls Occupied()
+else if (!d->Occupied()) { // MaySwitchTransponder() implicitly 
calls Occupied()
if (d->Priority() < Priority && (!Device || d->Priority() < 
Device->Priority()))
   Device = d; // use this one only if no other with less 
impact can be found
}
-- 
1.9.1


___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


[vdr] [PATCH] cSkinXXXXDisplayMenu::SetEvent(): fix date buffer size

2016-05-26 Thread glenvt18
32 bytes is not enough for multi-byte utf8 strings

Date string is truncated.

Please review,
Sergey Chernyavskiy.
---
 PLUGINS/src/skincurses/skincurses.c | 2 +-
 skinclassic.c   | 2 +-
 skinlcars.c | 2 +-
 skinsttng.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/PLUGINS/src/skincurses/skincurses.c 
b/PLUGINS/src/skincurses/skincurses.c
index 358035e..fcf183d 100644
--- a/PLUGINS/src/skincurses/skincurses.c
+++ b/PLUGINS/src/skincurses/skincurses.c
@@ -407,7 +407,7 @@ void cSkinCursesDisplayMenu::SetEvent(const cEvent *Event)
  return;
   int y = 2;
   cTextScroller ts;
-  char t[32];
+  char t[64];
   snprintf(t, sizeof(t), "%s  %s - %s", *Event->GetDateString(), 
*Event->GetTimeString(), *Event->GetEndTimeString());
   ts.Set(osd, 0, y, ScOsdWidth, ScOsdHeight - y - 2, t, &Font, clrYellow, 
clrBackground);
   if (Event->Vps() && Event->Vps() != Event->StartTime()) {
diff --git a/skinclassic.c b/skinclassic.c
index b6d183b..410230d 100644
--- a/skinclassic.c
+++ b/skinclassic.c
@@ -352,7 +352,7 @@ void cSkinClassicDisplayMenu::SetEvent(const cEvent *Event)
   const cFont *font = cFont::GetFont(fontOsd);
   int y = y2;
   cTextScroller ts;
-  char t[32];
+  char t[64];
   snprintf(t, sizeof(t), "%s  %s - %s", *Event->GetDateString(), 
*Event->GetTimeString(), *Event->GetEndTimeString());
   ts.Set(osd, x1, y, x2 - x1, y3 - y, t, font, Theme.Color(clrMenuEventTime), 
Theme.Color(clrBackground));
   if (Event->Vps() && Event->Vps() != Event->StartTime()) {
diff --git a/skinlcars.c b/skinlcars.c
index d84a753..7c5561c 100644
--- a/skinlcars.c
+++ b/skinlcars.c
@@ -1636,7 +1636,7 @@ void cSkinLCARSDisplayMenu::SetEvent(const cEvent *Event)
   int xl = xi00;
   int y = yi00;
   cTextScroller ts;
-  char t[32];
+  char t[64];
   snprintf(t, sizeof(t), "%s  %s - %s", *Event->GetDateString(), 
*Event->GetTimeString(), *Event->GetEndTimeString());
   ts.Set(osd, xl, y, xi01 - xl, yi01 - y, t, font, Theme.Color(clrEventTime), 
Theme.Color(clrBackground));
   if (Event->Vps() && Event->Vps() != Event->StartTime()) {
diff --git a/skinsttng.c b/skinsttng.c
index f10f120..f81b13e 100644
--- a/skinsttng.c
+++ b/skinsttng.c
@@ -655,7 +655,7 @@ void cSkinSTTNGDisplayMenu::SetEvent(const cEvent *Event)
   int xl = x3 + TextSpacing;
   int y = y3;
   cTextScroller ts;
-  char t[32];
+  char t[64];
   snprintf(t, sizeof(t), "%s  %s - %s", *Event->GetDateString(), 
*Event->GetTimeString(), *Event->GetEndTimeString());
   ts.Set(osd, xl, y, x4 - xl, y4 - y, t, font, Theme.Color(clrMenuEventTime), 
Theme.Color(clrBackground));
   if (Event->Vps() && Event->Vps() != Event->StartTime()) {
-- 
1.9.1


___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] [PATCH] Device power saving feature

2016-05-26 Thread Richard F
Interesting.
How long have you been running it / testing it?
Have you tested with VPS timers enabled ?

Thanks
Richard

On 26/05/2016 16:36, glenvt18 wrote:
> Hi folks.
>
> This patch introduces a feature which allows an idle device (a device
> which is not currently recording or streaming) to enter a power-down
> mode after some period of time. Given two timeout values,
> PowerdownTimeoutM and PowerdownWakeupH, it works like this: when a
> device becomes idle, it is kept powered up for PowerdownTimeoutM minutes
> doing, for instance, an EPG scan before it is powered down. If the
> device is still idle and has been powered down for PowerdownWakeupH
> hours it is powered up for PowerdownTimeoutM minutes and so on. When
> recording, streaming or a forced EPG scan starts, the device is powered
> up and it's idle timer is disabled. This implies that PowerdownTimeoutM
> should be enough for a full round of EPG scanning (20 seconds *
> number_of_transponders). Another option is to run EPG scans from cron
> (at night) and use SVDRP SCAN command.

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] [PATCH] Device power saving feature

2016-05-26 Thread glenvt18
For about a month now. Tested with 3 different DVB-S/S2 tuners with
VDR 2.3.1 and VDR 2.2.0 (requires minor changes to the patch) - rock
solid.
I don't have VPS, so I can't test it. The same is about DVB-T/C
tuners. After all, if something doesn't work this feature can be
disabled (and it is disabled by default),

Best,
Sergey Chernyavskiy.

2016-05-26 20:15 GMT+03:00 Richard F :
> Interesting.
> How long have you been running it / testing it?
> Have you tested with VPS timers enabled ?
>
> Thanks
> Richard
>
> On 26/05/2016 16:36, glenvt18 wrote:
>> Hi folks.
>>
>> This patch introduces a feature which allows an idle device (a device
>> which is not currently recording or streaming) to enter a power-down
>> mode after some period of time. Given two timeout values,
>> PowerdownTimeoutM and PowerdownWakeupH, it works like this: when a
>> device becomes idle, it is kept powered up for PowerdownTimeoutM minutes
>> doing, for instance, an EPG scan before it is powered down. If the
>> device is still idle and has been powered down for PowerdownWakeupH
>> hours it is powered up for PowerdownTimeoutM minutes and so on. When
>> recording, streaming or a forced EPG scan starts, the device is powered
>> up and it's idle timer is disabled. This implies that PowerdownTimeoutM
>> should be enough for a full round of EPG scanning (20 seconds *
>> number_of_transponders). Another option is to run EPG scans from cron
>> (at night) and use SVDRP SCAN command.
>
> ___
> vdr mailing list
> vdr@linuxtv.org
> http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] TBS driver breaks lirc_serial

2016-05-26 Thread Karim
Hi Andreas,

You do not need journalctl, because your system is no systemd-system obviously.
On my system there is no syslog or other logfile in directory /var/log :)
ok... 

> This failed start should be visible in syslog...
>
> You've right. But curiously, I didnt find error :
>
> grep lirc /var/log/syslog
> May 24 23:01:00 pctest lircd-0.9.0-pre1[4396]: lircd(default) ready, 
> using /var/run/lirc/lircd May 24 23:02:00 pctest 
> lircd-0.9.0-pre1[4396]: caught signal May 24 23:09:01 pctest 
> lircd-0.9.0-pre1[4414]: lircd(default) ready, using 
> /var/run/lirc/lircd May 24 23:09:09 pctest lircd-0.9.0-pre1[4414]: 
> caught signal May 24 23:35:51 pctest kernel: [ 4171.326315] 
> lirc_serial: Manually using active low receiver May 24 23:35:51 pctest 
> kernel: [ 4171.326409] lirc_serial lirc_serial.0: lirc_dev: driver 
> lirc_serial registered at minor = 2
>
> grep lirc /var/log/user.log
> nothing.
Strange...
Really !

Maybe it is a good idea to reinstall your Debian system to be sure, that all 
modules are clean.
Than create a backup of the entire modules tree (/lib/modules/*) and install 
TBS stuff without deleting any directories.
After that you are able to compare the mixed modules to the backup (diff -Nqr 
/lib/modules /your.backup) and find out, what you should delete before 
installing TBS.
No mixed as I can see. Anyway I did many first install with clonezilla (I have 
an image of Debian fresh install without lirc, tbs, etc...).
Same problem everytime => TBS problem. 
 
> In case I can't find/fix this, do you think it could be interesting to try 
> with a fresh install of  Debian Jessie **8.4.0** which kernel 3.16 ?
Debian and OpenSUSE are different. Logging is different, configuration is 
different, ... but both are linux :) Do you have an old system with running DVB 
and LIRC? If so, try to find the LIRC configuration...
Unfortunately not !

I do not know Debian and which version is stable or not.
But why not - "latest is greatest" :)
I tried today with Jessie 8.4.0 x64, exactly same problem :-(

I think we tried all the ways. I opened a case at TBS support a few days ago. 
They asked me to send them "lirc_serial.ko working" to check, it seems they 
could integrate it in their driver. If so, it should be great ! 

Best regards
Andreas Böttger

Many thanks for your help !
Of course, if I have somme good (news) from TBS, I will post here.

Best regards.
Karim


___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] TBS driver breaks lirc_serial

2016-05-26 Thread Birgit & Andreas Böttger

Hi Karim,

Karim schrieb am 26.05.2016 um 22:39:

I tried today with Jessie 8.4.0 x64, exactly same problem :-(
I think we tried all the ways. I opened a case at TBS support a few days ago.
They asked me to send them "lirc_serial.ko working" to check, it seems they 
could integrate it in their driver.
If so, it should be great !

Many thanks for your help !
Of course, if I have some good news from TBS, I will post here.


You mean that the (current) TBS driver is incompatible to Debian?
Maybe .. OK, let's check the TBS support :)

Best regards
Andreas Böttger

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] TBS driver breaks lirc_serial

2016-05-26 Thread Karim
It's clear that TBS breaks lirc on Debian. It's a sort of incompatibility...

Karim

Le 26 mai 2016 23:08:37 GMT+02:00, "Birgit & Andreas Böttger" 
 a écrit :
>Hi Karim,
>
>Karim schrieb am 26.05.2016 um 22:39:
>> I tried today with Jessie 8.4.0 x64, exactly same problem :-(
>> I think we tried all the ways. I opened a case at TBS support a few
>days ago.
>> They asked me to send them "lirc_serial.ko working" to check, it
>seems they could integrate it in their driver.
>> If so, it should be great !
>>
>> Many thanks for your help !
>> Of course, if I have some good news from TBS, I will post here.
>
>You mean that the (current) TBS driver is incompatible to Debian?
>Maybe .. OK, let's check the TBS support :)
>
>Best regards
>Andreas Böttger
>
>___
>vdr mailing list
>vdr@linuxtv.org
>http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

-- 
Envoyé de mon téléphone Android avec K-9 Mail. Excusez la brièveté.___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr