]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
linuxdvb: rotor - remember the last orbital position to skip movement...
authorJaroslav Kysela <perex@perex.cz>
Sun, 27 Jul 2014 15:45:34 +0000 (17:45 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 4 Aug 2014 15:19:04 +0000 (17:19 +0200)
src/input/mpegts/linuxdvb/linuxdvb_private.h
src/input/mpegts/linuxdvb/linuxdvb_rotor.c
src/input/mpegts/linuxdvb/linuxdvb_satconf.c
src/input/mpegts/mpegts_dvb.h
src/input/mpegts/mpegts_network_dvb.c

index a5e89da6d996ea82aedbdca1e7cd860d3716c5eb..4089ca14d4c690e1af3cb1160a94d9080aeb1bb0 100644 (file)
@@ -137,6 +137,12 @@ struct linuxdvb_satconf
    * LNB settings
    */
   int                    ls_lnb_poweroff;
+
+  /*
+   * Position
+   */
+  int                    ls_orbital_pos;
+  char                   ls_orbital_dir;
   
   /*
    * Satconf elements
index 4ded7004fd97fefe2b638caaf74662aa9d4d0c83..0b6a64101d165e2a610bca5e5a8768df50f2bb23 100644 (file)
@@ -129,12 +129,38 @@ const idclass_t linuxdvb_rotor_usals_class =
  * Class methods
  * *************************************************************************/
 
+static int
+linuxdvb_rotor_check_orbital_pos
+  ( dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls )
+{
+  int  pos;
+  char dir;
+
+
+  if (dvb_network_get_orbital_pos(lm->mm_network, &pos, &dir) < 0)
+    return 0;
+
+  if (dir != ls->lse_parent->ls_orbital_dir)
+    return 0;
+
+  if (abs(pos - ls->lse_parent->ls_orbital_pos) > 2)
+    return 0;
+
+  tvhdebug("diseqc", "rotor already positioned to %i.%i%c",
+                     pos / 10, pos % 10, dir);
+  return 1;
+}
+
 /* GotoX */
 static int
 linuxdvb_rotor_gotox_tune
   ( linuxdvb_rotor_t *lr, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd )
 {
   int i;
+
+  if (linuxdvb_rotor_check_orbital_pos(lm, ls))
+    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)) {
       tvherror("diseqc", "failed to set GOTOX pos %d", lr->lr_position);
@@ -199,6 +225,9 @@ linuxdvb_rotor_usals_tune
   int angle_1 = (((motor_angle > 0.0) ? 0xd0 : 0xe0) | (sixteenths >> 8));
   int angle_2 = (sixteenths & 0xff);
  
+  if (linuxdvb_rotor_check_orbital_pos(lm, ls))
+    return 0;
+
   tvhtrace("diseqc", "rotor USALS goto %0.1f%c (motor %0.2f %sclockwise)",
            fabs(pos), (pos > 0.0) ? 'E' : 'W',
            motor_angle, (motor_angle > 0.0) ? "counter-" : "");
index d4351e0f3b1b55c4a0e20b8cd0a49ecac1d20f30..b8fa0e38f1dc158a2b8940696071f24f58a46cde 100644 (file)
@@ -649,6 +649,11 @@ linuxdvb_satconf_ele_tune ( linuxdvb_satconf_ele_t *lse )
     }
   }
 
+  /* Remember the last network position for rotor */
+  dvb_network_get_orbital_pos(lm->mm_network,
+                              &lse->lse_parent->ls_orbital_pos,
+                              &lse->lse_parent->ls_orbital_dir);
+
   /* Set the tone */
   b = lse->lse_lnb->lnb_band(lse->lse_lnb, lm);
   tvhtrace("disqec", "set diseqc tone %s", b ? "on" : "off");
index 5c3ed2bd8315e36e404fc625766b3a6aac2cf840..b426040de8de00b2fa4a32981379423492a6aeff 100644 (file)
@@ -46,6 +46,9 @@ dvb_network_t *dvb_network_find_by_uuid(const char *uuid);
 dvb_network_t *dvb_network_create0
   ( const char *uuid, const idclass_t *idc, htsmsg_t *conf );
 
+int dvb_network_get_orbital_pos
+  ( mpegts_network_t *mn, int *pos, char *dir );
+
 /*
  *
  */
index 7680c1fdeb4eb358e38e51798289f40e9fb97c75..0eefbe0d14585db8bc38b7db938fd524bc146c56 100644 (file)
@@ -632,6 +632,27 @@ dvb_network_find_by_uuid(const char *uuid)
   return (dvb_network_t*)in;
 }
 
+int dvb_network_get_orbital_pos
+  ( mpegts_network_t *mn, int *pos, char *dir )
+{
+  dvb_network_t *ln = (dvb_network_t *)mn;
+  mpegts_mux_t  *mm;
+  dvb_mux_t     *lm = NULL;
+
+  LIST_FOREACH(mm, &ln->mn_muxes, mm_network_link) {
+    lm = (dvb_mux_t *)mm;
+    if (lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir)
+      break;
+  }
+  if (lm) {
+    *pos = lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos;
+    *dir = lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir;
+    return 0;
+  } else {
+    return -1;
+  }
+}
+
 /******************************************************************************
  * Editor Configuration
  *