Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
linuxdvb: rotor - remember the last orbital position to skip movement...
  • Loading branch information
perexg committed Jul 27, 2014
1 parent 9b41652 commit 9892716
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/input/mpegts/linuxdvb/linuxdvb_private.h
Expand Up @@ -136,6 +136,12 @@ struct linuxdvb_satconf
* LNB settings
*/
int ls_lnb_poweroff;

/*
* Position
*/
int ls_orbital_pos;
char ls_orbital_dir;

/*
* Satconf elements
Expand Down
29 changes: 29 additions & 0 deletions src/input/mpegts/linuxdvb/linuxdvb_rotor.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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-" : "");
Expand Down
5 changes: 5 additions & 0 deletions src/input/mpegts/linuxdvb/linuxdvb_satconf.c
Expand Up @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions src/input/mpegts/mpegts_dvb.h
Expand Up @@ -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 );

/*
*
*/
Expand Down
21 changes: 21 additions & 0 deletions src/input/mpegts/mpegts_network_dvb.c
Expand Up @@ -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
*
Expand Down

0 comments on commit 9892716

Please sign in to comment.