]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
linuxdvb: satconf - make diseqc switch/rotor delays more configurable
authorJaroslav Kysela <perex@perex.cz>
Fri, 16 Oct 2015 16:43:14 +0000 (18:43 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 16 Oct 2015 16:46:49 +0000 (18:46 +0200)
src/input/mpegts/linuxdvb/linuxdvb_rotor.c
src/input/mpegts/linuxdvb/linuxdvb_satconf.c
src/input/mpegts/linuxdvb/linuxdvb_switch.c
src/tvheadend.h

index c1e0caa7fcef31825338732b0e7e0eea910948c2..a0317264d66512d54296f7e054cc3ee2187a6d4d 100644 (file)
@@ -65,6 +65,9 @@ typedef struct linuxdvb_rotor
   linuxdvb_diseqc_t;
 #endif
 
+  uint32_t  lr_powerup_time;
+  uint32_t  lr_cmd_time;
+
   double    lr_sat_lon;
   uint32_t  lr_position;
 
@@ -88,6 +91,23 @@ const idclass_t linuxdvb_rotor_class = {
   .ic_class       = "linuxdvb_rotor",
   .ic_caption     = N_("DiseqC Rotor"),
   .ic_get_title   = linuxdvb_rotor_class_get_title,
+  .ic_properties  = (const property_t[]) {
+    {
+      .type    = PT_U32,
+      .id      = "powerup_time",
+      .name    = N_("Powerup Time (ms) (10-200)"),
+      .off     = offsetof(linuxdvb_rotor_t, lr_powerup_time),
+      .def.u32 = 100,
+    },
+    {
+      .type    = PT_U32,
+      .id      = "cmd_time",
+      .name    = N_("Command Time (ms) (10-100)"),
+      .off     = offsetof(linuxdvb_rotor_t, lr_cmd_time),
+      .def.u32 = 25
+    },
+    {}
+  }
 };
 
 const idclass_t linuxdvb_rotor_gotox_class =
@@ -356,7 +376,7 @@ linuxdvb_rotor_gotox_tune
       tvherror("diseqc", "failed to set GOTOX pos %d", lr->lr_position);
       return -1;
     }
-    usleep(25000);
+    usleep(MINMAX(lr->lr_cmd_time, 10, 100));
   }
 
   tvhdebug("diseqc", "rotor GOTOX pos %d sent", lr->lr_position);
@@ -392,7 +412,7 @@ linuxdvb_rotor_usals_tune
       tvherror("diseqc", "failed to send USALS command");
       return -1;
     }
-    usleep(25000);
+    usleep(MINMAX(lr->lr_cmd_time, 10, 100));
   }
 
   return linuxdvb_rotor_grace((linuxdvb_diseqc_t*)lr,lm);
@@ -410,7 +430,7 @@ linuxdvb_rotor_tune
     return 0;
 
   /* Force to 18v (quicker movement) */
-  if (linuxdvb_satconf_start(lsp, 1, 1))
+  if (linuxdvb_satconf_start(lsp, MINMAX(lr->lr_powerup_time, 10, 200) * 1000, 1))
     return -1;
 
   /* GotoX */
@@ -467,6 +487,7 @@ linuxdvb_rotor_create0
 {
   int i;
   linuxdvb_diseqc_t *ld = NULL;
+  linuxdvb_rotor_t *lr;
 
   for (i = 0; i < ARRAY_SIZE(linuxdvb_rotor_all); i++) {
     if (!strcmp(name ?: "", linuxdvb_rotor_all[i].name)) {
@@ -478,6 +499,11 @@ linuxdvb_rotor_create0
         ld->ld_grace = linuxdvb_rotor_grace;
         ld->ld_post  = linuxdvb_rotor_post;
       }
+      lr = (linuxdvb_rotor_t *)ld;
+      if (lr->lr_powerup_time == 0)
+        lr->lr_powerup_time = 100;
+      if (lr->lr_cmd_time == 0)
+        lr->lr_cmd_time = 25;
     }
   }
                                  
index 7751d0460795f311a8f3e8c0817edb1816a6ca97..63a0e18b6e7b55282c2386131046ecff7f3ba1a3 100644 (file)
@@ -713,7 +713,7 @@ linuxdvb_satconf_start ( linuxdvb_satconf_t *ls, int delay, int vol )
     ls->ls_last_tone_off = 1;
   }
   if (delay)
-    usleep(10000);
+    usleep(delay);
   return 0;
 }
 
index 566c64e8558506527921b0755e4a828bdb7a6cb1..32931d1a65508d50fb058c06a55ad9231a5ca28c 100644 (file)
@@ -44,7 +44,8 @@ typedef struct linuxdvb_switch
   int ls_committed;
   int ls_uncommitted;
   int ls_uncommitted_first;
-  int ls_sleep_time; /* in ms */
+  uint32_t ls_powerup_time; /* in ms */
+  uint32_t ls_sleep_time;   /* in ms */
 
 } linuxdvb_switch_t;
 
@@ -116,37 +117,45 @@ const idclass_t linuxdvb_switch_class =
   .ic_get_title   = linuxdvb_switch_class_get_title,
   .ic_properties  = (const property_t[]) {
     {
-      .type   = PT_INT,
-      .id     = "committed",
-      .name   = N_("Committed"),
-      .off    = offsetof(linuxdvb_switch_t, ls_committed),
-      .list   = linuxdvb_switch_class_committed_list
+      .type    = PT_INT,
+      .id      = "committed",
+      .name    = N_("Committed"),
+      .off     = offsetof(linuxdvb_switch_t, ls_committed),
+      .list    = linuxdvb_switch_class_committed_list
     },
     {
-      .type   = PT_INT,
-      .id     = "uncommitted",
-      .name   = N_("Uncommitted"),
-      .off    = offsetof(linuxdvb_switch_t, ls_uncommitted),
-      .list   = linuxdvb_switch_class_uncommitted_list
+      .type    = PT_INT,
+      .id      = "uncommitted",
+      .name    = N_("Uncommitted"),
+      .off     = offsetof(linuxdvb_switch_t, ls_uncommitted),
+      .list    = linuxdvb_switch_class_uncommitted_list
     },
     {
-      .type   = PT_INT,
-      .id     = "toneburst",
-      .name   = N_("Tone Burst"),
-      .off    = offsetof(linuxdvb_switch_t, ls_toneburst),
-      .list   = linuxdvb_switch_class_toneburst_list
+      .type    = PT_INT,
+      .id      = "toneburst",
+      .name    = N_("Tone Burst"),
+      .off     = offsetof(linuxdvb_switch_t, ls_toneburst),
+      .list    = linuxdvb_switch_class_toneburst_list
     },
     {
-      .type   = PT_BOOL,
-      .id     = "preferun",
-      .name   = N_("Uncommited First"),
-      .off    = offsetof(linuxdvb_switch_t, ls_uncommitted_first),
+      .type    = PT_BOOL,
+      .id      = "preferun",
+      .name    = N_("Uncommited First"),
+      .off     = offsetof(linuxdvb_switch_t, ls_uncommitted_first),
     },
     {
-      .type   = PT_INT,
-      .id     = "sleeptime",
-      .name   = N_("Cmd Delay Time (ms) (10-500)"),
-      .off    = offsetof(linuxdvb_switch_t, ls_sleep_time)
+      .type    = PT_U32,
+      .id      = "poweruptime",
+      .name    = N_("Powerup Time (ms) (10-200)"),
+      .off     = offsetof(linuxdvb_switch_t, ls_powerup_time),
+      .def.u32 = 100,
+    },
+    {
+      .type    = PT_U32,
+      .id      = "sleeptime",
+      .name    = N_("Cmd Delay Time (ms) (10-200)"),
+      .off     = offsetof(linuxdvb_switch_t, ls_sleep_time),
+      .def.u32 = 25
     },
     {}
   }
@@ -172,13 +181,11 @@ linuxdvb_switch_tune
 
     lsp->ls_last_switch = NULL;
 
-    if (linuxdvb_satconf_start(lsp, 1, pol))
+    if (linuxdvb_satconf_start(lsp, MINMAX(ls->ls_powerup_time, 10, 200), pol))
       return -1;
 
     com = 0xF0 | (ls->ls_committed << 2) | (pol << 1) | band;
-    slp = ls->ls_sleep_time > 10 ?
-            MAX(500, MIN(25, ls->ls_sleep_time)) * 1000 :
-            25000;
+    slp = MINMAX(ls->ls_sleep_time, 25, 200) * 1000;
 
     /* Repeats */
     for (i = 0; i <= lsp->ls_diseqc_repeats; i++) {
@@ -225,7 +232,7 @@ linuxdvb_switch_tune
   if (ls->ls_toneburst >= 0 &&
       (lsp->ls_diseqc_full || lsp->ls_last_toneburst != ls->ls_toneburst + 1)) {
 
-    if (linuxdvb_satconf_start(lsp, 1, vol))
+    if (linuxdvb_satconf_start(lsp, MINMAX(ls->ls_powerup_time, 10, 200), vol))
       return -1;
 
     lsp->ls_last_toneburst = 0;
@@ -274,6 +281,10 @@ linuxdvb_switch_create0
         if (u >= 0)
           ld->ls_uncommitted = u;
       }
+      if (ld->ls_powerup_time == 0)
+        ld->ls_powerup_time = 100;
+      if (ld->ls_sleep_time == 0)
+        ld->ls_sleep_time = 25;
     }
   }
 
index 81947fa599f7eb91c5e9ea078aa96151474c5f7a..aa6decac820b5728822439274912c3ef6999ce13 100644 (file)
@@ -558,6 +558,7 @@ static inline unsigned int tvh_strhash(const char *s, unsigned int mod)
 
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
+#define MINMAX(a,mi,ma) MAX(mi, MIN(ma, a))
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
 
 void tvh_str_set(char **strp, const char *src);