Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
linuxdvb rotor: do not rely on NIT, use site position value only
  • Loading branch information
perexg committed Dec 14, 2014
1 parent 920cb35 commit d9bb16e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
9 changes: 3 additions & 6 deletions src/input/mpegts/linuxdvb/linuxdvb_private.h
Expand Up @@ -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
Expand All @@ -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;
};

/*
Expand Down Expand Up @@ -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
Expand Down
42 changes: 25 additions & 17 deletions src/input/mpegts/linuxdvb/linuxdvb_rotor.c
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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) */
Expand All @@ -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
* *************************************************************************/
Expand Down Expand Up @@ -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;
}
}
}
Expand Down
10 changes: 3 additions & 7 deletions src/input/mpegts/linuxdvb/linuxdvb_satconf.c
Expand Up @@ -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;
Expand Down

0 comments on commit d9bb16e

Please sign in to comment.