linuxdvb: rotor - add Max Rotor Movement field to the frontend config

This commit is contained in:
Jaroslav Kysela 2014-09-21 09:12:35 +02:00
parent fa1ce0aa2f
commit aaedddc7e0
7 changed files with 46 additions and 27 deletions

View file

@ -157,10 +157,11 @@ const idclass_t linuxdvb_en50494_class =
static int static int
linuxdvb_en50494_tune linuxdvb_en50494_tune
( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *sc, int fd ) ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *sc,
linuxdvb_frontend_t *lfe )
{ {
int ret = 0; int ret = 0;
int i; int i, fd = lfe->lfe_fe_fd;
linuxdvb_en50494_t *le = (linuxdvb_en50494_t*) ld; linuxdvb_en50494_t *le = (linuxdvb_en50494_t*) ld;
linuxdvb_lnb_t *lnb = sc->lse_lnb; linuxdvb_lnb_t *lnb = sc->lse_lnb;

View file

@ -154,6 +154,14 @@ const idclass_t linuxdvb_frontend_dvbs_class =
.list = linuxdvb_satconf_type_list, .list = linuxdvb_satconf_type_list,
.def.s = "simple" .def.s = "simple"
}, },
{
.type = PT_U32,
.id = "max_rotor_move",
.name = "Max Rotor Movement (seconds)",
.off = offsetof(linuxdvb_frontend_t, lfe_max_rotor_move),
.opts = PO_ADVANCED,
.def.u32 = 120
},
{ {
.id = "networks", .id = "networks",
.type = PT_NONE, .type = PT_NONE,
@ -249,7 +257,7 @@ linuxdvb_frontend_get_grace ( mpegts_input_t *mi, mpegts_mux_t *mm )
linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)mi; linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)mi;
int r = 5; int r = 5;
if (lfe->lfe_satconf) if (lfe->lfe_satconf)
r = linuxdvb_satconf_get_grace(lfe->lfe_satconf, mm); r = linuxdvb_satconf_get_grace(lfe, mm);
return r; return r;
} }
@ -1335,6 +1343,7 @@ linuxdvb_frontend_create
lfe->lfe_type = type; lfe->lfe_type = type;
strncpy(lfe->lfe_name, name, sizeof(lfe->lfe_name)); strncpy(lfe->lfe_name, name, sizeof(lfe->lfe_name));
lfe->lfe_name[sizeof(lfe->lfe_name)-1] = '\0'; lfe->lfe_name[sizeof(lfe->lfe_name)-1] = '\0';
lfe->lfe_max_rotor_move = 120;
lfe = (linuxdvb_frontend_t*)mpegts_input_create0((mpegts_input_t*)lfe, idc, uuid, conf); lfe = (linuxdvb_frontend_t*)mpegts_input_create0((mpegts_input_t*)lfe, idc, uuid, conf);
if (!lfe) return NULL; if (!lfe) return NULL;

View file

@ -103,14 +103,15 @@ linuxdvb_lnb_standard_pol
static int static int
linuxdvb_lnb_standard_tune linuxdvb_lnb_standard_tune
( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls,
linuxdvb_frontend_t *lfe )
{ {
/* en50494 does not use the voltage tune. this is happend in the switch */ /* en50494 does not use the voltage tune. this is happend in the switch */
if (ls->lse_en50494) if (ls->lse_en50494)
return 0; return 0;
int pol = linuxdvb_lnb_standard_pol((linuxdvb_lnb_t*)ld, lm); int pol = linuxdvb_lnb_standard_pol((linuxdvb_lnb_t*)ld, lm);
return linuxdvb_diseqc_set_volt(fd, pol); return linuxdvb_diseqc_set_volt(lfe->lfe_fe_fd, pol);
} }
/* /*
@ -152,10 +153,11 @@ linuxdvb_lnb_bandstack_pol
static int static int
linuxdvb_lnb_bandstack_tune linuxdvb_lnb_bandstack_tune
( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls,
linuxdvb_frontend_t *lfe )
{ {
int pol = linuxdvb_lnb_bandstack_pol((linuxdvb_lnb_t*)ld, lm); int pol = linuxdvb_lnb_bandstack_pol((linuxdvb_lnb_t*)ld, lm);
return linuxdvb_diseqc_set_volt(fd, pol); return linuxdvb_diseqc_set_volt(lfe->lfe_fe_fd, pol);
} }
/* ************************************************************************** /* **************************************************************************

View file

@ -111,6 +111,7 @@ struct linuxdvb_frontend
* Configuration * Configuration
*/ */
int lfe_powersave; int lfe_powersave;
uint32_t lfe_max_rotor_move;
/* /*
* Satconf (DVB-S only) * Satconf (DVB-S only)
@ -191,9 +192,10 @@ struct linuxdvb_diseqc
idnode_t ld_id; idnode_t ld_id;
const char *ld_type; const char *ld_type;
linuxdvb_satconf_ele_t *ld_satconf; linuxdvb_satconf_ele_t *ld_satconf;
int (*ld_grace) (linuxdvb_diseqc_t *ld, dvb_mux_t *lm); int (*ld_grace) (linuxdvb_diseqc_t *ld, dvb_mux_t *lm,
linuxdvb_frontend_t *lfe);
int (*ld_tune) (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); linuxdvb_satconf_ele_t *ls, linuxdvb_frontend_t *lfe);
}; };
struct linuxdvb_lnb struct linuxdvb_lnb
@ -318,7 +320,7 @@ int linuxdvb_satconf_get_priority
( linuxdvb_satconf_t *ls, mpegts_mux_t *mm ); ( linuxdvb_satconf_t *ls, mpegts_mux_t *mm );
int linuxdvb_satconf_get_grace int linuxdvb_satconf_get_grace
( linuxdvb_satconf_t *ls, mpegts_mux_t *mm ); ( linuxdvb_frontend_t *lfe, mpegts_mux_t *mm );
void linuxdvb_satconf_post_stop_mux( linuxdvb_satconf_t *ls ); void linuxdvb_satconf_post_stop_mux( linuxdvb_satconf_t *ls );

View file

@ -131,14 +131,14 @@ const idclass_t linuxdvb_rotor_usals_class =
static int static int
linuxdvb_rotor_grace linuxdvb_rotor_grace
( linuxdvb_diseqc_t *ld, dvb_mux_t *lm ) ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_frontend_t *lfe )
{ {
linuxdvb_rotor_t *lr = (linuxdvb_rotor_t*)ld; linuxdvb_rotor_t *lr = (linuxdvb_rotor_t*)ld;
linuxdvb_satconf_t *ls = ld->ld_satconf->lse_parent; linuxdvb_satconf_t *ls = ld->ld_satconf->lse_parent;
int newpos, curpos, delta; int newpos, curpos, delta;
if (!ls->ls_orbital_dir || lr->lr_rate == 0) if (!ls->ls_orbital_dir || lr->lr_rate == 0)
return 120; return lfe->lfe_max_rotor_move;
if (idnode_is_instance(&lr->ld_id, &linuxdvb_rotor_gotox_class)) if (idnode_is_instance(&lr->ld_id, &linuxdvb_rotor_gotox_class))
newpos = lr->lr_position; /* GotoX */ newpos = lr->lr_position; /* GotoX */
@ -183,7 +183,8 @@ linuxdvb_rotor_check_orbital_pos
/* GotoX */ /* GotoX */
static int static int
linuxdvb_rotor_gotox_tune linuxdvb_rotor_gotox_tune
( linuxdvb_rotor_t *lr, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) ( linuxdvb_rotor_t *lr, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls,
linuxdvb_frontend_t *lfe )
{ {
int i; int i;
@ -191,7 +192,7 @@ linuxdvb_rotor_gotox_tune
return 0; return 0;
for (i = 0; i <= ls->lse_parent->ls_diseqc_repeats; i++) { for (i = 0; i <= ls->lse_parent->ls_diseqc_repeats; i++) {
if (linuxdvb_diseqc_send(fd, 0xE0, 0x31, 0x6B, 1, (int)lr->lr_position)) { if (linuxdvb_diseqc_send(lfe->lfe_fe_fd, 0xE0, 0x31, 0x6B, 1, (int)lr->lr_position)) {
tvherror("diseqc", "failed to set GOTOX pos %d", lr->lr_position); tvherror("diseqc", "failed to set GOTOX pos %d", lr->lr_position);
return -1; return -1;
} }
@ -200,13 +201,14 @@ linuxdvb_rotor_gotox_tune
tvhdebug("diseqc", "rotor GOTOX pos %d sent", lr->lr_position); tvhdebug("diseqc", "rotor GOTOX pos %d sent", lr->lr_position);
return linuxdvb_rotor_grace((linuxdvb_diseqc_t*)lr,lm); return linuxdvb_rotor_grace((linuxdvb_diseqc_t*)lr, lm, lfe);
} }
/* USALS */ /* USALS */
static int static int
linuxdvb_rotor_usals_tune linuxdvb_rotor_usals_tune
( linuxdvb_rotor_t *lr, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) ( linuxdvb_rotor_t *lr, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls,
linuxdvb_frontend_t *lfe )
{ {
/* /*
* Code originally written in PR #238 by Jason Millard jsm174 * Code originally written in PR #238 by Jason Millard jsm174
@ -263,14 +265,14 @@ linuxdvb_rotor_usals_tune
motor_angle, (motor_angle > 0.0) ? "counter-" : ""); motor_angle, (motor_angle > 0.0) ? "counter-" : "");
for (i = 0; i <= ls->lse_parent->ls_diseqc_repeats; i++) { for (i = 0; i <= ls->lse_parent->ls_diseqc_repeats; i++) {
if (linuxdvb_diseqc_send(fd, 0xE0, 0x31, 0x6E, 2, angle_1, angle_2)) { if (linuxdvb_diseqc_send(lfe->lfe_fe_fd, 0xE0, 0x31, 0x6E, 2, angle_1, angle_2)) {
tvherror("diseqc", "failed to send USALS command"); tvherror("diseqc", "failed to send USALS command");
return -1; return -1;
} }
usleep(25000); usleep(25000);
} }
return linuxdvb_rotor_grace((linuxdvb_diseqc_t*)lr,lm); return linuxdvb_rotor_grace((linuxdvb_diseqc_t*)lr, lm, lfe);
#undef TO_RAD #undef TO_RAD
#undef TO_DEG #undef TO_DEG
@ -278,12 +280,13 @@ linuxdvb_rotor_usals_tune
static int static int
linuxdvb_rotor_tune linuxdvb_rotor_tune
( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls,
linuxdvb_frontend_t *lfe )
{ {
linuxdvb_rotor_t *lr = (linuxdvb_rotor_t*)ld; linuxdvb_rotor_t *lr = (linuxdvb_rotor_t*)ld;
/* Force to 18v (quicker movement) */ /* Force to 18v (quicker movement) */
if (ioctl(fd, FE_SET_VOLTAGE, SEC_VOLTAGE_18)) { if (ioctl(lfe->lfe_fe_fd, FE_SET_VOLTAGE, SEC_VOLTAGE_18)) {
tvherror("diseqc", "failed to set 18v for rotor movement"); tvherror("diseqc", "failed to set 18v for rotor movement");
return -1; return -1;
} }
@ -291,10 +294,10 @@ linuxdvb_rotor_tune
/* GotoX */ /* GotoX */
if (idnode_is_instance(&lr->ld_id, &linuxdvb_rotor_gotox_class)) if (idnode_is_instance(&lr->ld_id, &linuxdvb_rotor_gotox_class))
return linuxdvb_rotor_gotox_tune(lr, lm, ls, fd); return linuxdvb_rotor_gotox_tune(lr, lm, ls, lfe);
/* USALS */ /* USALS */
return linuxdvb_rotor_usals_tune(lr, lm, ls, fd); return linuxdvb_rotor_usals_tune(lr, lm, ls, lfe);
} }
/* ************************************************************************** /* **************************************************************************

View file

@ -590,8 +590,9 @@ linuxdvb_satconf_post_stop_mux
int int
linuxdvb_satconf_get_grace linuxdvb_satconf_get_grace
( linuxdvb_satconf_t *ls, mpegts_mux_t *mm ) ( linuxdvb_frontend_t *lfe, mpegts_mux_t *mm )
{ {
linuxdvb_satconf_t *ls = lfe->lfe_satconf;
linuxdvb_satconf_ele_t *lse = linuxdvb_satconf_find_ele(ls, mm); linuxdvb_satconf_ele_t *lse = linuxdvb_satconf_find_ele(ls, mm);
int i, r = 10; int i, r = 10;
linuxdvb_diseqc_t *lds[] = { linuxdvb_diseqc_t *lds[] = {
@ -604,7 +605,7 @@ linuxdvb_satconf_get_grace
/* Add diseqc delay */ /* Add diseqc delay */
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
if (lds[i] && lds[i]->ld_grace) if (lds[i] && lds[i]->ld_grace)
r += lds[i]->ld_grace(lds[i], (dvb_mux_t*)mm); r += lds[i]->ld_grace(lds[i], (dvb_mux_t*)mm, lfe);
} }
return r; return r;
@ -644,7 +645,7 @@ linuxdvb_satconf_ele_tune ( linuxdvb_satconf_ele_t *lse )
/* Diseqc */ /* Diseqc */
for (i = ls->ls_diseqc_idx; i < ARRAY_SIZE(lds); i++) { for (i = ls->ls_diseqc_idx; i < ARRAY_SIZE(lds); i++) {
if (!lds[i]) continue; if (!lds[i]) continue;
r = lds[i]->ld_tune(lds[i], lm, lse, lfe->lfe_fe_fd); r = lds[i]->ld_tune(lds[i], lm, lse, lfe);
/* Error */ /* Error */
if (r < 0) return r; if (r < 0) return r;

View file

@ -144,9 +144,10 @@ const idclass_t linuxdvb_switch_class =
static int static int
linuxdvb_switch_tune linuxdvb_switch_tune
( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *sc, int fd ) ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *sc,
linuxdvb_frontend_t *lfe )
{ {
int i, com, r1 = 0, r2 = 0; int i, com, r1 = 0, r2 = 0, fd = lfe->lfe_fe_fd;
int pol, band; int pol, band;
linuxdvb_switch_t *ls = (linuxdvb_switch_t*)ld; linuxdvb_switch_t *ls = (linuxdvb_switch_t*)ld;