]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
linuxdvb: rotor - add Max Rotor Movement field to the frontend config
authorJaroslav Kysela <perex@perex.cz>
Sun, 21 Sep 2014 07:12:35 +0000 (09:12 +0200)
committerJaroslav Kysela <perex@perex.cz>
Sun, 21 Sep 2014 07:12:35 +0000 (09:12 +0200)
src/input/mpegts/linuxdvb/linuxdvb_en50494.c
src/input/mpegts/linuxdvb/linuxdvb_frontend.c
src/input/mpegts/linuxdvb/linuxdvb_lnb.c
src/input/mpegts/linuxdvb/linuxdvb_private.h
src/input/mpegts/linuxdvb/linuxdvb_rotor.c
src/input/mpegts/linuxdvb/linuxdvb_satconf.c
src/input/mpegts/linuxdvb/linuxdvb_switch.c

index 3a888de634c83acb2c0181b078a5a46f8ba552c9..7119724b7f518043f3addeaa70b5406411c8cf12 100644 (file)
@@ -157,10 +157,11 @@ const idclass_t linuxdvb_en50494_class =
 
 static int
 linuxdvb_en50494_tune
-  ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *sc, int fd )
+  ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *sc,
+    linuxdvb_frontend_t *lfe )
 {
   int ret = 0;
-  int i;
+  int i, fd = lfe->lfe_fe_fd;
   linuxdvb_en50494_t *le = (linuxdvb_en50494_t*) ld;
   linuxdvb_lnb_t *lnb = sc->lse_lnb;
 
index be3cb32c02c2719104ea83cf29f9d6278772b5c5..19050c913aa9f8d171f76ce26839d567ce376285 100644 (file)
@@ -154,6 +154,14 @@ const idclass_t linuxdvb_frontend_dvbs_class =
       .list     = linuxdvb_satconf_type_list,
       .def.s    = "simple"
     },
+    {
+      .type     = PT_U32,
+      .id       = "max_rotor_move",
+      .name     = "Max Rotor Movement (seconds)",
+      .off      = offsetof(linuxdvb_frontend_t, lfe_max_rotor_move),
+      .opts     = PO_ADVANCED,
+      .def.u32  = 120
+    },
     {
       .id       = "networks",
       .type     = PT_NONE,
@@ -249,7 +257,7 @@ linuxdvb_frontend_get_grace ( mpegts_input_t *mi, mpegts_mux_t *mm )
   linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)mi;
   int r = 5;
   if (lfe->lfe_satconf)
-    r = linuxdvb_satconf_get_grace(lfe->lfe_satconf, mm);
+    r = linuxdvb_satconf_get_grace(lfe, mm);
   return r;
 }
 
@@ -1335,6 +1343,7 @@ linuxdvb_frontend_create
   lfe->lfe_type = type;
   strncpy(lfe->lfe_name, name, sizeof(lfe->lfe_name));
   lfe->lfe_name[sizeof(lfe->lfe_name)-1] = '\0';
+  lfe->lfe_max_rotor_move = 120;
   lfe = (linuxdvb_frontend_t*)mpegts_input_create0((mpegts_input_t*)lfe, idc, uuid, conf);
   if (!lfe) return NULL;
 
index f7607f4217ff7a04ed06f87e0c2691ff71553a43..71085740fa8b3c0f79a583187c846a18be192c93 100644 (file)
@@ -103,14 +103,15 @@ linuxdvb_lnb_standard_pol
 
 static int 
 linuxdvb_lnb_standard_tune
-  ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd )
+  ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls,
+    linuxdvb_frontend_t *lfe )
 {
   /* en50494 does not use the voltage tune. this is happend in the switch */
   if (ls->lse_en50494)
     return 0;
 
   int pol = linuxdvb_lnb_standard_pol((linuxdvb_lnb_t*)ld, lm);
-  return linuxdvb_diseqc_set_volt(fd, pol);
+  return linuxdvb_diseqc_set_volt(lfe->lfe_fe_fd, pol);
 }
 
 /*
@@ -152,10 +153,11 @@ linuxdvb_lnb_bandstack_pol
 
 static int
 linuxdvb_lnb_bandstack_tune
-  ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd )
+  ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls,
+    linuxdvb_frontend_t *lfe )
 {
   int pol = linuxdvb_lnb_bandstack_pol((linuxdvb_lnb_t*)ld, lm);
-  return linuxdvb_diseqc_set_volt(fd, pol);
+  return linuxdvb_diseqc_set_volt(lfe->lfe_fe_fd, pol);
 }
 
 /* **************************************************************************
index 38bb2b0c3f76fc4774b2293bcee6e905df5e4802..a0c1c6f8771f99dc430d68b8b7de75ca9ae55b26 100644 (file)
@@ -111,6 +111,7 @@ struct linuxdvb_frontend
    * Configuration
    */
   int                       lfe_powersave;
+  uint32_t                  lfe_max_rotor_move;
 
   /*
    * Satconf (DVB-S only)
@@ -191,9 +192,10 @@ struct linuxdvb_diseqc
   idnode_t              ld_id;
   const char           *ld_type;
   linuxdvb_satconf_ele_t   *ld_satconf;
-  int (*ld_grace) (linuxdvb_diseqc_t *ld, dvb_mux_t *lm);
+  int (*ld_grace) (linuxdvb_diseqc_t *ld, dvb_mux_t *lm,
+                   linuxdvb_frontend_t *lfe);
   int (*ld_tune)  (linuxdvb_diseqc_t *ld, dvb_mux_t *lm,
-                   linuxdvb_satconf_ele_t *ls, int fd);
+                   linuxdvb_satconf_ele_t *ls, linuxdvb_frontend_t *lfe);
 };
 
 struct linuxdvb_lnb
@@ -318,7 +320,7 @@ int linuxdvb_satconf_get_priority
   ( linuxdvb_satconf_t *ls, mpegts_mux_t *mm );
 
 int linuxdvb_satconf_get_grace
-  ( linuxdvb_satconf_t *ls, mpegts_mux_t *mm );
+  ( linuxdvb_frontend_t *lfe, mpegts_mux_t *mm );
   
 void linuxdvb_satconf_post_stop_mux( linuxdvb_satconf_t *ls );
 
index e83ad681f49d51d88f3fc31b0359b7a94aef22bb..e920bd4c82d15ebe3bb48632effbf000d011d39c 100644 (file)
@@ -131,14 +131,14 @@ const idclass_t linuxdvb_rotor_usals_class =
 
 static int
 linuxdvb_rotor_grace
-  ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm )
+  ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_frontend_t *lfe )
 {
   linuxdvb_rotor_t *lr = (linuxdvb_rotor_t*)ld;
   linuxdvb_satconf_t *ls = ld->ld_satconf->lse_parent;
   int newpos, curpos, delta;
 
   if (!ls->ls_orbital_dir || lr->lr_rate == 0)
-    return 120;
+    return lfe->lfe_max_rotor_move;
 
   if (idnode_is_instance(&lr->ld_id, &linuxdvb_rotor_gotox_class))
     newpos = lr->lr_position;                /* GotoX */
@@ -183,7 +183,8 @@ linuxdvb_rotor_check_orbital_pos
 /* GotoX */
 static int
 linuxdvb_rotor_gotox_tune
-  ( linuxdvb_rotor_t *lr, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd )
+  ( linuxdvb_rotor_t *lr, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls,
+    linuxdvb_frontend_t *lfe )
 {
   int i;
 
@@ -191,7 +192,7 @@ linuxdvb_rotor_gotox_tune
     return 0;
 
   for (i = 0; i <= ls->lse_parent->ls_diseqc_repeats; i++) {
-    if (linuxdvb_diseqc_send(fd, 0xE0, 0x31, 0x6B, 1, (int)lr->lr_position)) {
+    if (linuxdvb_diseqc_send(lfe->lfe_fe_fd, 0xE0, 0x31, 0x6B, 1, (int)lr->lr_position)) {
       tvherror("diseqc", "failed to set GOTOX pos %d", lr->lr_position);
       return -1;
     }
@@ -200,13 +201,14 @@ linuxdvb_rotor_gotox_tune
 
   tvhdebug("diseqc", "rotor GOTOX pos %d sent", lr->lr_position);
 
-  return linuxdvb_rotor_grace((linuxdvb_diseqc_t*)lr,lm);
+  return linuxdvb_rotor_grace((linuxdvb_diseqc_t*)lr, lm, lfe);
 }
 
 /* USALS */
 static int
 linuxdvb_rotor_usals_tune
-  ( linuxdvb_rotor_t *lr, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd )
+  ( linuxdvb_rotor_t *lr, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls,
+    linuxdvb_frontend_t *lfe )
 {
   /*
    * Code originally written in PR #238 by Jason Millard jsm174
@@ -263,14 +265,14 @@ linuxdvb_rotor_usals_tune
            motor_angle, (motor_angle > 0.0) ? "counter-" : "");
 
   for (i = 0; i <= ls->lse_parent->ls_diseqc_repeats; i++) {
-    if (linuxdvb_diseqc_send(fd, 0xE0, 0x31, 0x6E, 2, angle_1, angle_2)) {
+    if (linuxdvb_diseqc_send(lfe->lfe_fe_fd, 0xE0, 0x31, 0x6E, 2, angle_1, angle_2)) {
       tvherror("diseqc", "failed to send USALS command");
       return -1;
     }
     usleep(25000);
   }
 
-  return linuxdvb_rotor_grace((linuxdvb_diseqc_t*)lr,lm);
+  return linuxdvb_rotor_grace((linuxdvb_diseqc_t*)lr, lm, lfe);
 
 #undef TO_RAD
 #undef TO_DEG
@@ -278,12 +280,13 @@ linuxdvb_rotor_usals_tune
 
 static int
 linuxdvb_rotor_tune
-  ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd )
+  ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls,
+    linuxdvb_frontend_t *lfe )
 {
   linuxdvb_rotor_t *lr = (linuxdvb_rotor_t*)ld;
 
   /* Force to 18v (quicker movement) */
-  if (ioctl(fd, FE_SET_VOLTAGE, SEC_VOLTAGE_18)) {
+  if (ioctl(lfe->lfe_fe_fd, FE_SET_VOLTAGE, SEC_VOLTAGE_18)) {
     tvherror("diseqc", "failed to set 18v for rotor movement");
     return -1;
   }
@@ -291,10 +294,10 @@ linuxdvb_rotor_tune
 
   /* GotoX */
   if (idnode_is_instance(&lr->ld_id, &linuxdvb_rotor_gotox_class))
-    return linuxdvb_rotor_gotox_tune(lr, lm, ls, fd);
+    return linuxdvb_rotor_gotox_tune(lr, lm, ls, lfe);
 
   /* USALS */
-  return linuxdvb_rotor_usals_tune(lr, lm, ls, fd);
+  return linuxdvb_rotor_usals_tune(lr, lm, ls, lfe);
 }
 
 /* **************************************************************************
index 41ad0de84700137dfead0005ba81d30d155d9886..bdfefdbf784fc37e570223621b74b7b839e261c9 100644 (file)
@@ -590,8 +590,9 @@ linuxdvb_satconf_post_stop_mux
 
 int
 linuxdvb_satconf_get_grace
-  ( linuxdvb_satconf_t *ls, mpegts_mux_t *mm )
+  ( linuxdvb_frontend_t *lfe, mpegts_mux_t *mm )
 {
+  linuxdvb_satconf_t *ls = lfe->lfe_satconf;
   linuxdvb_satconf_ele_t *lse = linuxdvb_satconf_find_ele(ls, mm);
   int i, r = 10;
   linuxdvb_diseqc_t      *lds[] = {
@@ -604,7 +605,7 @@ linuxdvb_satconf_get_grace
   /* Add diseqc delay */
   for (i = 0; i < 3; i++) {
     if (lds[i] && lds[i]->ld_grace)
-      r += lds[i]->ld_grace(lds[i], (dvb_mux_t*)mm);
+      r += lds[i]->ld_grace(lds[i], (dvb_mux_t*)mm, lfe);
   }
 
   return r;
@@ -644,7 +645,7 @@ linuxdvb_satconf_ele_tune ( linuxdvb_satconf_ele_t *lse )
   /* Diseqc */  
   for (i = ls->ls_diseqc_idx; i < ARRAY_SIZE(lds); i++) {
     if (!lds[i]) continue;
-    r = lds[i]->ld_tune(lds[i], lm, lse, lfe->lfe_fe_fd);
+    r = lds[i]->ld_tune(lds[i], lm, lse, lfe);
 
     /* Error */
     if (r < 0) return r;
index 2044c74d74286dc65d44daec743cbb040d58cbbd..9c430faf57d1294414f2affb564d849fb5e393dc 100644 (file)
@@ -144,9 +144,10 @@ const idclass_t linuxdvb_switch_class =
 
 static int
 linuxdvb_switch_tune
-  ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *sc, int fd )
+  ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *sc,
+    linuxdvb_frontend_t *lfe )
 {
-  int i, com, r1 = 0, r2 = 0;
+  int i, com, r1 = 0, r2 = 0, fd = lfe->lfe_fe_fd;
   int pol, band;
   linuxdvb_switch_t *ls = (linuxdvb_switch_t*)ld;