From: Jaroslav Kysela Date: Fri, 16 Oct 2015 16:43:14 +0000 (+0200) Subject: linuxdvb: satconf - make diseqc switch/rotor delays more configurable X-Git-Tag: v4.2.1~1893 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a21371dcf2d4e3f21330dd76a11c2bd16cba5af7;p=thirdparty%2Ftvheadend.git linuxdvb: satconf - make diseqc switch/rotor delays more configurable --- diff --git a/src/input/mpegts/linuxdvb/linuxdvb_rotor.c b/src/input/mpegts/linuxdvb/linuxdvb_rotor.c index c1e0caa7f..a0317264d 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_rotor.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_rotor.c @@ -65,6 +65,9 @@ typedef struct linuxdvb_rotor linuxdvb_diseqc_t; #endif + uint32_t lr_powerup_time; + uint32_t lr_cmd_time; + double lr_sat_lon; uint32_t lr_position; @@ -88,6 +91,23 @@ const idclass_t linuxdvb_rotor_class = { .ic_class = "linuxdvb_rotor", .ic_caption = N_("DiseqC Rotor"), .ic_get_title = linuxdvb_rotor_class_get_title, + .ic_properties = (const property_t[]) { + { + .type = PT_U32, + .id = "powerup_time", + .name = N_("Powerup Time (ms) (10-200)"), + .off = offsetof(linuxdvb_rotor_t, lr_powerup_time), + .def.u32 = 100, + }, + { + .type = PT_U32, + .id = "cmd_time", + .name = N_("Command Time (ms) (10-100)"), + .off = offsetof(linuxdvb_rotor_t, lr_cmd_time), + .def.u32 = 25 + }, + {} + } }; const idclass_t linuxdvb_rotor_gotox_class = @@ -356,7 +376,7 @@ linuxdvb_rotor_gotox_tune tvherror("diseqc", "failed to set GOTOX pos %d", lr->lr_position); return -1; } - usleep(25000); + usleep(MINMAX(lr->lr_cmd_time, 10, 100)); } tvhdebug("diseqc", "rotor GOTOX pos %d sent", lr->lr_position); @@ -392,7 +412,7 @@ linuxdvb_rotor_usals_tune tvherror("diseqc", "failed to send USALS command"); return -1; } - usleep(25000); + usleep(MINMAX(lr->lr_cmd_time, 10, 100)); } return linuxdvb_rotor_grace((linuxdvb_diseqc_t*)lr,lm); @@ -410,7 +430,7 @@ linuxdvb_rotor_tune return 0; /* Force to 18v (quicker movement) */ - if (linuxdvb_satconf_start(lsp, 1, 1)) + if (linuxdvb_satconf_start(lsp, MINMAX(lr->lr_powerup_time, 10, 200) * 1000, 1)) return -1; /* GotoX */ @@ -467,6 +487,7 @@ linuxdvb_rotor_create0 { int i; linuxdvb_diseqc_t *ld = NULL; + linuxdvb_rotor_t *lr; for (i = 0; i < ARRAY_SIZE(linuxdvb_rotor_all); i++) { if (!strcmp(name ?: "", linuxdvb_rotor_all[i].name)) { @@ -478,6 +499,11 @@ linuxdvb_rotor_create0 ld->ld_grace = linuxdvb_rotor_grace; ld->ld_post = linuxdvb_rotor_post; } + lr = (linuxdvb_rotor_t *)ld; + if (lr->lr_powerup_time == 0) + lr->lr_powerup_time = 100; + if (lr->lr_cmd_time == 0) + lr->lr_cmd_time = 25; } } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c index 7751d0460..63a0e18b6 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c @@ -713,7 +713,7 @@ linuxdvb_satconf_start ( linuxdvb_satconf_t *ls, int delay, int vol ) ls->ls_last_tone_off = 1; } if (delay) - usleep(10000); + usleep(delay); return 0; } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_switch.c b/src/input/mpegts/linuxdvb/linuxdvb_switch.c index 566c64e85..32931d1a6 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_switch.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_switch.c @@ -44,7 +44,8 @@ typedef struct linuxdvb_switch int ls_committed; int ls_uncommitted; int ls_uncommitted_first; - int ls_sleep_time; /* in ms */ + uint32_t ls_powerup_time; /* in ms */ + uint32_t ls_sleep_time; /* in ms */ } linuxdvb_switch_t; @@ -116,37 +117,45 @@ const idclass_t linuxdvb_switch_class = .ic_get_title = linuxdvb_switch_class_get_title, .ic_properties = (const property_t[]) { { - .type = PT_INT, - .id = "committed", - .name = N_("Committed"), - .off = offsetof(linuxdvb_switch_t, ls_committed), - .list = linuxdvb_switch_class_committed_list + .type = PT_INT, + .id = "committed", + .name = N_("Committed"), + .off = offsetof(linuxdvb_switch_t, ls_committed), + .list = linuxdvb_switch_class_committed_list }, { - .type = PT_INT, - .id = "uncommitted", - .name = N_("Uncommitted"), - .off = offsetof(linuxdvb_switch_t, ls_uncommitted), - .list = linuxdvb_switch_class_uncommitted_list + .type = PT_INT, + .id = "uncommitted", + .name = N_("Uncommitted"), + .off = offsetof(linuxdvb_switch_t, ls_uncommitted), + .list = linuxdvb_switch_class_uncommitted_list }, { - .type = PT_INT, - .id = "toneburst", - .name = N_("Tone Burst"), - .off = offsetof(linuxdvb_switch_t, ls_toneburst), - .list = linuxdvb_switch_class_toneburst_list + .type = PT_INT, + .id = "toneburst", + .name = N_("Tone Burst"), + .off = offsetof(linuxdvb_switch_t, ls_toneburst), + .list = linuxdvb_switch_class_toneburst_list }, { - .type = PT_BOOL, - .id = "preferun", - .name = N_("Uncommited First"), - .off = offsetof(linuxdvb_switch_t, ls_uncommitted_first), + .type = PT_BOOL, + .id = "preferun", + .name = N_("Uncommited First"), + .off = offsetof(linuxdvb_switch_t, ls_uncommitted_first), }, { - .type = PT_INT, - .id = "sleeptime", - .name = N_("Cmd Delay Time (ms) (10-500)"), - .off = offsetof(linuxdvb_switch_t, ls_sleep_time) + .type = PT_U32, + .id = "poweruptime", + .name = N_("Powerup Time (ms) (10-200)"), + .off = offsetof(linuxdvb_switch_t, ls_powerup_time), + .def.u32 = 100, + }, + { + .type = PT_U32, + .id = "sleeptime", + .name = N_("Cmd Delay Time (ms) (10-200)"), + .off = offsetof(linuxdvb_switch_t, ls_sleep_time), + .def.u32 = 25 }, {} } @@ -172,13 +181,11 @@ linuxdvb_switch_tune lsp->ls_last_switch = NULL; - if (linuxdvb_satconf_start(lsp, 1, pol)) + if (linuxdvb_satconf_start(lsp, MINMAX(ls->ls_powerup_time, 10, 200), pol)) return -1; com = 0xF0 | (ls->ls_committed << 2) | (pol << 1) | band; - slp = ls->ls_sleep_time > 10 ? - MAX(500, MIN(25, ls->ls_sleep_time)) * 1000 : - 25000; + slp = MINMAX(ls->ls_sleep_time, 25, 200) * 1000; /* Repeats */ for (i = 0; i <= lsp->ls_diseqc_repeats; i++) { @@ -225,7 +232,7 @@ linuxdvb_switch_tune if (ls->ls_toneburst >= 0 && (lsp->ls_diseqc_full || lsp->ls_last_toneburst != ls->ls_toneburst + 1)) { - if (linuxdvb_satconf_start(lsp, 1, vol)) + if (linuxdvb_satconf_start(lsp, MINMAX(ls->ls_powerup_time, 10, 200), vol)) return -1; lsp->ls_last_toneburst = 0; @@ -274,6 +281,10 @@ linuxdvb_switch_create0 if (u >= 0) ld->ls_uncommitted = u; } + if (ld->ls_powerup_time == 0) + ld->ls_powerup_time = 100; + if (ld->ls_sleep_time == 0) + ld->ls_sleep_time = 25; } } diff --git a/src/tvheadend.h b/src/tvheadend.h index 81947fa59..aa6decac8 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -558,6 +558,7 @@ static inline unsigned int tvh_strhash(const char *s, unsigned int mod) #define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b)) +#define MINMAX(a,mi,ma) MAX(mi, MIN(ma, a)) #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) void tvh_str_set(char **strp, const char *src);