From d9bb16eea67da16ffd1e02b032b3243d903a245f Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sun, 14 Dec 2014 22:21:33 +0100 Subject: [PATCH] linuxdvb rotor: do not rely on NIT, use site position value only --- src/input/mpegts/linuxdvb/linuxdvb_private.h | 9 ++--- src/input/mpegts/linuxdvb/linuxdvb_rotor.c | 42 ++++++++++++-------- src/input/mpegts/linuxdvb/linuxdvb_satconf.c | 10 ++--- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/input/mpegts/linuxdvb/linuxdvb_private.h b/src/input/mpegts/linuxdvb/linuxdvb_private.h index ffc2c9bf..8a6f4673 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_private.h +++ b/src/input/mpegts/linuxdvb/linuxdvb_private.h @@ -147,12 +147,6 @@ struct linuxdvb_satconf int ls_site_lat_south; int ls_site_lon_west; int ls_site_altitude; - - /* - * Position - */ - int ls_orbital_pos; - char ls_orbital_dir; /* * Satconf elements @@ -162,6 +156,7 @@ struct linuxdvb_satconf int ls_last_pol; int ls_last_toneburst; int ls_last_tone_off; + int ls_last_orbital_pos; }; /* @@ -205,6 +200,8 @@ struct linuxdvb_diseqc int (*ld_grace) (linuxdvb_diseqc_t *ld, dvb_mux_t *lm); int (*ld_tune) (linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd); + int (*ld_post) (linuxdvb_diseqc_t *ld, dvb_mux_t *lm, + linuxdvb_satconf_ele_t *ls, int fd); }; struct linuxdvb_lnb diff --git a/src/input/mpegts/linuxdvb/linuxdvb_rotor.c b/src/input/mpegts/linuxdvb/linuxdvb_rotor.c index dcecb376..15f1a639 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_rotor.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_rotor.c @@ -141,9 +141,9 @@ linuxdvb_rotor_grace { linuxdvb_rotor_t *lr = (linuxdvb_rotor_t*)ld; linuxdvb_satconf_t *ls = ld->ld_satconf->lse_parent; - int newpos, curpos, delta, tunit; + int newpos, delta, tunit; - if (!ls->ls_orbital_dir || lr->lr_rate == 0) + if (!ls->ls_last_orbital_pos || lr->lr_rate == 0) return ls->ls_max_rotor_move; newpos = (lr->lr_sat_lon + 0.05) * 10; @@ -153,10 +153,7 @@ linuxdvb_rotor_grace tunit = 10000; /* USALS */ } - curpos = ls->ls_orbital_pos; - if (ls->ls_orbital_dir == 'W') - curpos = -(curpos); - delta = abs(deltaI32(curpos, newpos)); + delta = abs(deltaI32(ls->ls_last_orbital_pos, newpos)); /* ignore very small movements like 0.8W and 1W */ if (delta <= 2) @@ -168,23 +165,23 @@ linuxdvb_rotor_grace static int linuxdvb_rotor_check_orbital_pos - ( dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls ) + ( linuxdvb_rotor_t *lr, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls ) { - linuxdvb_satconf_t *lsp; - int pos; + linuxdvb_satconf_t *lsp = ls->lse_parent; + int pos = lsp->ls_last_orbital_pos; char dir; - if (dvb_network_get_orbital_pos(lm->mm_network, &pos, &dir) < 0) + if (!pos) return 0; - lsp = ls->lse_parent; - - if (dir != lsp->ls_orbital_dir) - return 0; - - if (abs(pos - lsp->ls_orbital_pos) > 2) + if (abs((int)((lr->lr_sat_lon + 0.05) / 10) - pos) > 2) return 0; + dir = 'E'; + if (pos < 0) { + pos = -(pos); + dir = 'W'; + } tvhdebug("diseqc", "rotor already positioned to %i.%i%c", pos / 10, pos % 10, dir); return 1; @@ -377,7 +374,7 @@ linuxdvb_rotor_tune { linuxdvb_rotor_t *lr = (linuxdvb_rotor_t*)ld; - if (linuxdvb_rotor_check_orbital_pos(lm, ls)) + if (linuxdvb_rotor_check_orbital_pos(lr, lm, ls)) return 0; /* Force to 18v (quicker movement) */ @@ -396,6 +393,16 @@ linuxdvb_rotor_tune return linuxdvb_rotor_usals_tune(lr, lm, ls, fd); } +static int +linuxdvb_rotor_post + ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) +{ + linuxdvb_rotor_t *lr = (linuxdvb_rotor_t*)ld; + + ls->lse_parent->ls_last_orbital_pos = lr->lr_sat_lon; + return 0; +} + /* ************************************************************************** * Create / Config * *************************************************************************/ @@ -440,6 +447,7 @@ linuxdvb_rotor_create0 if (ld) { ld->ld_tune = linuxdvb_rotor_tune; ld->ld_grace = linuxdvb_rotor_grace; + ld->ld_post = linuxdvb_rotor_post; } } } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c index 8da87028..562c37bc 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c @@ -716,13 +716,9 @@ linuxdvb_satconf_ele_tune ( linuxdvb_satconf_ele_t *lse ) } } - /* Remember the last network position for rotor */ - if (dvb_network_get_orbital_pos(lm->mm_network, - &ls->ls_orbital_pos, - &ls->ls_orbital_dir) < 0) { - ls->ls_orbital_pos = 0; - ls->ls_orbital_dir = 0; - } + /* Do post things (store position for rotor) */ + if (lse->lse_rotor) + lse->lse_rotor->ld_post(lse->lse_rotor, lm, lse, lfe->lfe_fe_fd); /* LNB settings */ pol = (lse->lse_lnb) ? lse->lse_lnb->lnb_pol (lse->lse_lnb, lm) & 0x1 : 0;