Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
linuxdvb: satconf - make diseqc switch/rotor delays more configurable
  • Loading branch information
perexg committed Oct 16, 2015
1 parent 3b851fb commit a21371d
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 33 deletions.
32 changes: 29 additions & 3 deletions src/input/mpegts/linuxdvb/linuxdvb_rotor.c
Expand Up @@ -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;

Expand All @@ -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 =
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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 */
Expand Down Expand Up @@ -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)) {
Expand All @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/linuxdvb/linuxdvb_satconf.c
Expand Up @@ -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;
}

Expand Down
69 changes: 40 additions & 29 deletions src/input/mpegts/linuxdvb/linuxdvb_switch.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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
},
{}
}
Expand All @@ -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++) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/tvheadend.h
Expand Up @@ -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);
Expand Down

0 comments on commit a21371d

Please sign in to comment.