Re: [vdr] Making VDR run under Systemd

2021-10-12 Thread glenvt18
Hi.

Here you can find an updated version of the patch:
https://github.com/glenvt18/vdr/commits/vdr-2.4.6

On Mon, Oct 11, 2021 at 04:02:43PM +0100, Richard F wrote:
> Mon, Sep 13, 2021 at 08:51:05PM +0200, Martin Wache wrote:
> > So, back to the plan with the Raspberry Pi 2B. One problem that I wanted
> > to solve is the power consumption of the DVB-T dongle when it is not in
> > use. I found https://github.com/mvp/uhubctl which can switch off power
> > on individual USB ports. I wrote a VDR shutdown script that does the
> > following:
> > 
> > sudo service lircd stop
> > uhubctl -p ... -a off
> > sudo service vdr stop
> > 
> > I did not refine the uhubctl invocation yet. The physical port could
> > vary.
> > 
> > An easy way to start up VDR could be a udev rule that would start up the
> > lircd and vdr services when the USB DVB stick is plugged in. Obviously,
> > if we power off the port during VDR shutdown, the adapter would have to
> > be plugged into a different port.
> > 
> > A simpler option for the occasional use of VDR might be to simply write
> > udev rules that will start up lircd and vdr when the DVB adapter is
> > plugged in, and shut down the services when the adapter is removed. 
> > That would be too risky if recording timers are being used.
> > 
> > I am not yet sure whether powering off the USB port makes any
> > difference, because the plastic case of the DVB stick feels slightly
> > warm to the touch even when the port is supposedly powered off. It might
> > be that some internal heat produced by the Rasberry is being dissipated
> > via the USB port. The metal frame of the USB jacks feels a bit warm too.
> > 
> > I think that I must measure the input power of the Raspberry Pi as well
> > as the voltage on the USB port when it is supposedly powered off.
> > 
> > Marko
> 
> Powersaving for DVB receivers - try the attached patch from glenvt18
> 
> 
> This has worked for me for a few years without noticeable problems on both
> USB and PCI cards.  I'm still on V2.20 by the way.  There's a little bit of
> log chatter as it powers up/down receivers when VDR scans the EPG etc, but
> you can filter that   I reckoned it saved around 3W at the mains for a
> 2-receiver server setup when I tested it back in 2016 - which adds up over
> time.
> 
> usbhubctl is a bit of a sledgehammer !
> 
> HTH
> 
> Richard
> 

> From 656cce97750882fd945d9ba76c47cb93a74c3059 Mon Sep 17 00:00:00 2001
> From: glenvt18 
> Date: Tue, 24 May 2016 00:39:01 +0300
> Subject: [PATCH] Device power saving feature
> 
> ---
>  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 9c6b71e..e196353 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;
> @@ -617,6 +620,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);
> @@ -743,6 +749,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 d1bae04..dbe84bb 100644
> --- a/config.h
> +++ b/config.h
> @@ -273,6 +273,9 @@ public:
>int PositionerSpeed;
>int PositionerSwing;
>int PositionerLastLon;
> +  int PowerdownEnabl

Re: [vdr] Making VDR run under Systemd

2021-10-12 Thread Marko Mäkelä

Mon, Oct 11, 2021 at 04:02:43PM +0100, Richard F wrote:

Powersaving for DVB receivers - try the attached patch from glenvt18


Thank you. I will test it later once I have hooked up the Raspberry Pi 
to my laboratory power supply so that I can observe the total power 
consumption.


While "uhubctl -a off" would cause an optimal mouse to power off its 
LED, it will not completely cut the power. I tested this by plugging in 
a mobile phone to the USB port. It indicated that charging is available.


One impact of "uhubctl -a off" is that any plug/unplug events for the 
affected ports will be disabled, and "lsusb" will reflect the state as 
it was before the invocation.


I just confirmed with a laboratory power supply that my USB DVB-T/T2/C 
stick is consuming 61 mA at 5 volts. If I remember correctly, USB 
devices are allowed to drain up to 100 mA without any negotiation, so it 
should not be out-of-spec. Those additional 0.35 watts should be a 
significant portion of the total power consumption. I did not measure 
yet, but I hope it to be in the range of 2 to 3 watts.


For my use case, I think that I will only configure udev events for 
inserting or removing the stick. No shutdown command would be configured 
in VDR. I would abruptly shut down VDR and lircd by unplugging the 
adapter. They would observe the abrupt loss of DVB hardware, followed by 
a terminating signal sent by systemd or udevd.


Best regards,

Marko

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