]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
linuxdvb rotor: cleanups, move site config to frontend, fixes
authorJaroslav Kysela <perex@perex.cz>
Mon, 15 Dec 2014 13:57:42 +0000 (14:57 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 15 Dec 2014 13:57:42 +0000 (14:57 +0100)
src/input/mpegts/linuxdvb/linuxdvb_private.h
src/input/mpegts/linuxdvb/linuxdvb_rotor.c
src/input/mpegts/linuxdvb/linuxdvb_satconf.c

index 1428519466dce64348c68acc5aad47b8493eae95..77624fac77ed7759879ada168575f50d99b433f8 100644 (file)
@@ -145,6 +145,9 @@ struct linuxdvb_satconf
    */
   int                    ls_lnb_poweroff;
   uint32_t               ls_max_rotor_move;
+  double                 ls_site_lat;
+  double                 ls_site_lon;
+  uint32_t               ls_motor_rate;
   int                    ls_site_lat_south;
   int                    ls_site_lon_west;
   int                    ls_site_altitude;
index 2fda6ee1ffcce59777cad87f330a670490686288..17e9fcac0b3b5e88053f33fb47b8a2c8f9debe15 100644 (file)
@@ -38,15 +38,8 @@ typedef struct linuxdvb_rotor
 {
   linuxdvb_diseqc_t;
 
-  /* USALS */
-  double    lr_site_lat;
-  double    lr_site_lon;
   double    lr_sat_lon;
-  double    lr_zero_lon;
-  
-  /* GOTOX */
   uint32_t  lr_position;
-  uint32_t  lr_rate;
 
 } linuxdvb_rotor_t;
 
@@ -86,12 +79,6 @@ const idclass_t linuxdvb_rotor_gotox_class =
       .name   = "Satellite Longitude",
       .off    = offsetof(linuxdvb_rotor_t, lr_sat_lon),
     },
-    {
-      .type   = PT_U16,
-      .id     = "rate",
-      .name   = "Rate (millis/click)",
-      .off    = offsetof(linuxdvb_rotor_t, lr_rate),
-    },
     {}
   }
 };
@@ -102,30 +89,12 @@ const idclass_t linuxdvb_rotor_usals_class =
   .ic_class       = "linuxdvb_rotor_usals",
   .ic_caption     = "USALS Rotor",
   .ic_properties  = (const property_t[]) {
-    {
-      .type   = PT_DBL,
-      .id     = "site_lat",
-      .name   = "Site Latitude",
-      .off    = offsetof(linuxdvb_rotor_t, lr_site_lat),
-    },
-    {
-      .type   = PT_DBL,
-      .id     = "site_lon",
-      .name   = "Site Longitude",
-      .off    = offsetof(linuxdvb_rotor_t, lr_site_lon),
-    },
     {
       .type   = PT_DBL,
       .id     = "sat_lon",
       .name   = "Satellite Longitude",
       .off    = offsetof(linuxdvb_rotor_t, lr_sat_lon),
     },
-    {
-      .type   = PT_U16,
-      .id     = "rate",
-      .name   = "Rate (millis/deg)",
-      .off    = offsetof(linuxdvb_rotor_t, lr_rate),
-    },
  
     {}
   }
@@ -174,15 +143,11 @@ linuxdvb_rotor_grace
   linuxdvb_satconf_t *ls = ld->ld_satconf->lse_parent;
   int newpos, delta, tunit;
 
-  if (!ls->ls_last_orbital_pos || lr->lr_rate == 0)
+  if (!ls->ls_last_orbital_pos || ls->ls_motor_rate == 0)
     return ls->ls_max_rotor_move;
 
   newpos = pos_to_integer(lr->lr_sat_lon);
-  if (idnode_is_instance(&lr->ld_id, &linuxdvb_rotor_gotox_class)) {
-    tunit  = 1000;  /* GOTOX */
-  } else {
-    tunit  = 10000; /* USALS */
-  }
+  tunit  = 10000; /* 1/1000 sec per one degree */
 
   delta = abs(deltaI32(ls->ls_last_orbital_pos, newpos));
 
@@ -191,7 +156,7 @@ linuxdvb_rotor_grace
     return 0;
 
   /* add one extra second, because of the rounding issue */
-  return ((lr->lr_rate*delta+(tunit-1))/tunit) + 1;
+  return ((ls->ls_motor_rate*delta+(tunit-1))/tunit) + 1;
 }
 
 static int
@@ -332,23 +297,25 @@ linuxdvb_rotor_usals_tune
   static const uint8_t xtable[10] =
          { 0x00, 0x02, 0x03, 0x05, 0x06, 0x08, 0x0A, 0x0B, 0x0D, 0x0E };
 
-  double site_lat = lr->lr_site_lat;
-  double site_lon = lr->lr_site_lon;
+  linuxdvb_satconf_t *lsp = ls->lse_parent;
+
+  double site_lat = lsp->ls_site_lat;
+  double site_lon = lsp->ls_site_lon;
   double sat_lon  = lr->lr_sat_lon;
   double motor_angle;
   uint32_t tmp, cmd;
   int i;
 
-  if (ls->lse_parent->ls_site_lat_south)
+  if (lsp->ls_site_lat_south)
     site_lat = -site_lat;
-  if (ls->lse_parent->ls_site_lon_west)
+  if (lsp->ls_site_lon_west)
     site_lon = 360 - site_lon;
   if (sat_lon < 0)
     sat_lon = 360 - sat_lon;
 
-  motor_angle = usals_sat_angle(lr->lr_site_lat, lr->lr_site_lon,
-                                ls->lse_parent->ls_site_altitude,
-                                lr->lr_sat_lon);
+  motor_angle = usals_sat_angle(site_lat, site_lon,
+                                lsp->ls_site_altitude,
+                                sat_lon);
 
   if (site_lat >= 0) {
     tmp = round(fabs(180 - motor_angle) * 10.0);
@@ -362,11 +329,11 @@ linuxdvb_rotor_usals_tune
     cmd = ((tmp / 10) * 0x10 + xtable[tmp % 10]) | 0xE000;
   }
 
-  tvhtrace("diseqc", "rotor USALS goto %0.1f%c (motor %0.1f %sclockwise)",
+  tvhdebug("diseqc", "rotor USALS goto %0.1f%c (motor %0.1f %sclockwise)",
            fabs(lr->lr_sat_lon), (lr->lr_sat_lon > 0.0) ? 'E' : 'W',
            ((double)tmp / 10.0), (cmd & 0xF000) == 0xD000 ? "counter-" : "");
 
-  for (i = 0; i <= ls->lse_parent->ls_diseqc_repeats; i++) {
+  for (i = 0; i <= lsp->ls_diseqc_repeats; i++) {
     if (linuxdvb_diseqc_send(fd, 0xE0, 0x31, 0x6E, 2,
                              (cmd >> 8) & 0xff, cmd & 0xff)) {
       tvherror("diseqc", "failed to send USALS command");
index 4ebbe8c8109cf3f1f9f7dd103c0d52855cb14875..d2087f531656542cae923dbb24f8f41751ff8fde 100644 (file)
@@ -253,6 +253,20 @@ const idclass_t linuxdvb_satconf_class =
       .opts     = PO_ADVANCED,
       .def.u32  = 120
     },
+    {
+      .type     = PT_DBL,
+      .id       = "site_lat",
+      .name     = "Site Latitude",
+      .off      = offsetof(linuxdvb_satconf_t, ls_site_lat),
+      .opts     = PO_ADVANCED,
+    },
+    {
+      .type     = PT_DBL,
+      .id       = "site_lon",
+      .name     = "Site Longitude",
+      .off      = offsetof(linuxdvb_satconf_t, ls_site_lon),
+      .opts     = PO_ADVANCED,
+    },
     {
       .type     = PT_BOOL,
       .id       = "site_lat_south",
@@ -277,6 +291,12 @@ const idclass_t linuxdvb_satconf_class =
       .opts     = PO_ADVANCED,
       .def.i    = 0
     },
+    {
+      .type     = PT_U32,
+      .id       = "motor_rate",
+      .name     = "Motor Rate (millis/deg)",
+      .off      = offsetof(linuxdvb_satconf_t, ls_motor_rate),
+    },
     {}
   }
 };