summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Hanisch <dvb@flensrocker.de>2012-05-23 21:22:59 +0200
committerLars Hanisch <dvb@flensrocker.de>2012-05-23 21:22:59 +0200
commit914af2494259e1cac350e4379da3f1639797a871 (patch)
treef65e0bed50eec23acf09805f1cdda245cf4f91e6
parent10d78a85a5e85170979b7695704203de86f17ad3 (diff)
downloadvdr-plugin-dynamite-914af2494259e1cac350e4379da3f1639797a871.tar.gz
vdr-plugin-dynamite-914af2494259e1cac350e4379da3f1639797a871.tar.bz2
add udev attribute dynamite_attach_delay_preopenv0.0.9f
-rw-r--r--HISTORY4
-rw-r--r--README7
-rw-r--r--dynamicdevice.c21
-rw-r--r--dynamicdevice.h2
-rw-r--r--dynamite.c2
5 files changed, 32 insertions, 4 deletions
diff --git a/HISTORY b/HISTORY
index 0ed6238..48af73e 100644
--- a/HISTORY
+++ b/HISTORY
@@ -260,3 +260,7 @@ VDR Plugin 'dynamite' Revision History
2012-03-29: Version 0.0.9e
- re-new the device bonding if a device is attached
+
+2012-05-23: Version 0.0.9f
+
+- add udev attribute "dynamite_attach_delay_preopen"
diff --git a/README b/README
index 930d7c7..2d6b674 100644
--- a/README
+++ b/README
@@ -296,6 +296,7 @@ example for udev rule:
ACTION=="add", SUBSYSTEM=="dvb", ENV{DVB_DEVICE_TYPE}=="frontend" \
, ENV{dynamite_attach}="yes" \
, ENV{dynamite_attach_delay}="10" \
+ , ENV{dynamite_attach_delay_preopen}="yes" \
, ENV{dynamite_instanceid}="0" \
, ENV{dynamite_cardindex}="5" \
, ENV{dynamite_sources}="C,T" \
@@ -318,6 +319,12 @@ dynamite_attach
dynamite_attach_delay
n: wait with attaching this device at least n seconds
+dynamite_attach_delay_preopen
+ "yes", "y", "1": If an attach_delay is specified, dynamite will open the given path
+ before the delay (O_RDWR | O_NONBLOCK) to trigger the load of the firmware.
+ It will be closed immediately and reopened when it's attached.
+ Useful for "bad" usb-box-drivers.
+
dynamite_instanceid
n: attach only at vdr with matching instance id
diff --git a/dynamicdevice.c b/dynamicdevice.c
index 28e6236..3035b72 100644
--- a/dynamicdevice.c
+++ b/dynamicdevice.c
@@ -118,10 +118,11 @@ bool cDynamicDevice::ProcessQueuedCommands(void)
return true;
}
-int cDynamicDevice::GetUdevAttributesForAttach(const char *DevPath, int &CardIndex, int &AttachDelay)
+int cDynamicDevice::GetUdevAttributesForAttach(const char *DevPath, int &CardIndex, int &AttachDelay, bool &AttachDelayPreopen)
{
CardIndex = -1;
AttachDelay = 0;
+ AttachDelayPreopen = false;
if (DevPath == NULL)
return -1;
cUdevDevice *dev = cUdev::GetDeviceFromDevName(DevPath);
@@ -142,6 +143,12 @@ int cDynamicDevice::GetUdevAttributesForAttach(const char *DevPath, int &CardInd
if (val && (sscanf(val, "%d", &intVal) == 1) && (intVal > 0))
AttachDelay = intVal;
}
+ val = dev->GetPropertyValue("dynamite_attach_delay_preopen");
+ if (val) {
+ isyslog("dynamite: udev attach_delay_preopen is %s", val);
+ if ((strcmp(val, "1") == 0) || (strcasecmp(val, "y") == 0) || (strcasecmp(val, "yes") == 0))
+ AttachDelayPreopen = true;
+ }
delete dev;
return 0;
}
@@ -214,7 +221,8 @@ eDynamicDeviceReturnCode cDynamicDevice::AttachDevice(const char *DevPath, int D
int frontend = -1;
int wishIndex = -1;
int attachDelay = 0;
- GetUdevAttributesForAttach(DevPath, wishIndex, attachDelay);
+ bool attachDelayPreopen = false;
+ GetUdevAttributesForAttach(DevPath, wishIndex, attachDelay, attachDelayPreopen);
if (wishIndex >= 0)
isyslog("dynamite: %s wants card index %d", DevPath, wishIndex);
else if (sscanf(DevPath, "/dev/dvb/adapter%d/frontend%d", &adapter, &frontend) == 2) {
@@ -235,6 +243,15 @@ eDynamicDeviceReturnCode cDynamicDevice::AttachDevice(const char *DevPath, int D
}
if ((attachDelay > 0) && (Delayed > 1)) {
+ if (attachDelayPreopen) {
+ // trigger firmware load
+ isyslog("dynamite: open %s before attach", DevPath);
+ int fd = open(DevPath, O_RDWR | O_NONBLOCK);
+ if (fd > 0) {
+ close(fd);
+ isyslog("dynamite: close %s", DevPath);
+ }
+ }
commandRequeue.Add(new cDynamicDeviceProbe::cDynamicDeviceProbeItem(ddpcAttach, new cString(DevPath)));
new cDelayedDeviceItems(DevPath, attachDelay);
return ddrcAttachDelayed;
diff --git a/dynamicdevice.h b/dynamicdevice.h
index a8a88fd..274ba69 100644
--- a/dynamicdevice.h
+++ b/dynamicdevice.h
@@ -53,7 +53,7 @@ public:
///< Returns the total number of dynamic devices.
static cDynamicDevice *GetDynamicDevice(int Index);
static bool ProcessQueuedCommands(void);
- static int GetUdevAttributesForAttach(const char *DevPath, int &CardIndex, int &AttachDelay);
+ static int GetUdevAttributesForAttach(const char *DevPath, int &CardIndex, int &AttachDelay, bool &AttachDelayPreopen);
static void DetachAllDevices(bool Force);
static cString ListAllDevices(int &ReplyCode); // for SVDRP command LSTD
static cString AttachDevicePattern(const char *Pattern);
diff --git a/dynamite.c b/dynamite.c
index f87ac60..98ff9ed 100644
--- a/dynamite.c
+++ b/dynamite.c
@@ -11,7 +11,7 @@
#include "monitor.h"
#include "status.h"
-static const char *VERSION = "0.0.9e";
+static const char *VERSION = "0.0.9f";
static const char *DESCRIPTION = tr("attach/detach devices on the fly");
static const char *MAINMENUENTRY = NULL;