From 03af723216afffaf57d9bb78d71a80a32adb7d9a Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 18 Sep 2014 10:35:42 +0200 Subject: [PATCH] linuxdvb: rotor - try to fix the grace calculation routine for USALS and negative longtitudes --- src/input/mpegts/linuxdvb/linuxdvb_rotor.c | 20 ++++++++++++++++---- src/tvheadend.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/input/mpegts/linuxdvb/linuxdvb_rotor.c b/src/input/mpegts/linuxdvb/linuxdvb_rotor.c index 68c2dd36..72374024 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_rotor.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_rotor.c @@ -134,16 +134,28 @@ linuxdvb_rotor_grace ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm ) { linuxdvb_rotor_t *lr = (linuxdvb_rotor_t*)ld; + linuxdvb_satconf_t *ls = ld->ld_satconf->lse_parent; + int newpos, curpos, delta; - if (!ld->ld_satconf->lse_parent->ls_orbital_dir || lr->lr_rate == 0) + if (!ls->ls_orbital_dir || lr->lr_rate == 0) return 120; - int curpos = ld->ld_satconf->lse_parent->ls_orbital_pos; + if (idnode_is_instance(&lr->ld_id, &linuxdvb_rotor_gotox_class)) + newpos = lr->lr_position; /* GotoX */ + else + newpos = (lr->lr_sat_lon + 0.005) * 100; /* USALS */ - if (ld->ld_satconf->lse_parent->ls_orbital_dir == 'W') + curpos = ls->ls_orbital_pos; + if (ls->ls_orbital_dir == 'W') curpos = -(curpos); + delta = abs(deltaI32(curpos, newpos)); - return (lr->lr_rate*(deltaU32(curpos, lr->lr_position))+999)/1000; + /* ignore very small movements like 0.8W and 1W */ + if (delta <= 2) + return 0; + + /* add one extra second, because of the rounding issue */ + return ((lr->lr_rate*delta+999)/1000) + 1; } static int diff --git a/src/tvheadend.h b/src/tvheadend.h index d32d8c16..87ca0114 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -708,6 +708,7 @@ int rmtree ( const char *path ); char *regexp_escape ( const char *str ); +static inline int32_t deltaI32(int32_t a, int32_t b) { return (a > b) ? (a - b) : (b - a); } static inline uint32_t deltaU32(uint32_t a, uint32_t b) { return (a > b) ? (a - b) : (b - a); } #define SKEL_DECLARE(name, type) type *name;