Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
linuxdvb diseqc: fix and improve command caching, fixes #2547
  • Loading branch information
perexg committed Dec 14, 2014
1 parent 450c2be commit 70a17df
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 39 deletions.
8 changes: 7 additions & 1 deletion src/input/mpegts/linuxdvb/linuxdvb_lnb.c
Expand Up @@ -118,7 +118,13 @@ linuxdvb_lnb_standard_tune

/* note: differentiate between linuxdvb_lnb_standard_pol / linuxdvb_lnb_inverted_pol */
int pol = ((linuxdvb_lnb_t*)ld)->lnb_pol((linuxdvb_lnb_t*)ld, lm);
return linuxdvb_diseqc_set_volt(fd, pol);

if (ls->lse_parent->ls_diseqc_full || ls->lse_parent->ls_last_pol != pol + 1) {
ls->lse_parent->ls_last_pol = pol + 1;
return linuxdvb_diseqc_set_volt(fd, pol);
}

return 0;
}

/*
Expand Down
2 changes: 2 additions & 0 deletions src/input/mpegts/linuxdvb/linuxdvb_private.h
Expand Up @@ -159,6 +159,8 @@ struct linuxdvb_satconf
*/
linuxdvb_satconf_ele_list_t ls_elements;
linuxdvb_satconf_ele_t *ls_last_switch;
int ls_last_pol;
int ls_last_toneburst;
};

/*
Expand Down
91 changes: 53 additions & 38 deletions src/input/mpegts/linuxdvb/linuxdvb_switch.c
Expand Up @@ -149,65 +149,80 @@ linuxdvb_switch_tune
int i, com, r1 = 0, r2 = 0;
int pol, band;
linuxdvb_switch_t *ls = (linuxdvb_switch_t*)ld;

if (!sc->lse_parent->ls_diseqc_full && sc->lse_parent->ls_last_switch == sc)
return 0;

sc->lse_parent->ls_last_switch = NULL;
linuxdvb_satconf_t *lsp = sc->lse_parent;

/* LNB settings */
pol = (sc->lse_lnb) ? sc->lse_lnb->lnb_pol (sc->lse_lnb, lm) & 0x1 : 0;
band = (sc->lse_lnb) ? sc->lse_lnb->lnb_band(sc->lse_lnb, lm) & 0x1 : 0;
com = 0xF0 | (ls->ls_committed << 2) | (pol << 1) | band;

/* Set the voltage */
if (linuxdvb_diseqc_set_volt(fd, pol))
return -1;

/* Single committed (before repeats) */
if (ls->ls_committed >= 0) {
if (sc->lse_parent->ls_diseqc_repeats > 0) {
r2 = 1;
if (linuxdvb_diseqc_send(fd, 0xE0, 0x10, 0x38, 1, com))
return -1;
usleep(25000); // 25ms
}

if (lsp->ls_diseqc_full || lsp->ls_last_pol != pol + 1) {

lsp->ls_last_pol = 0;

/* Set the voltage */
if (linuxdvb_diseqc_set_volt(fd, pol))
return -1;

lsp->ls_last_pol = pol + 1;
}

/* Repeats */
for (i = 0; i <= sc->lse_parent->ls_diseqc_repeats; i++) {
if (lsp->ls_diseqc_full || lsp->ls_last_switch != sc) {

/* Uncommitted */
if (ls->ls_uncommitted >= 0) {
if (linuxdvb_diseqc_send(fd, 0xE0 | r1, 0x10, 0x39, 1,
0xF0 | ls->ls_uncommitted))
return -1;
usleep(25000);
}
lsp->ls_last_switch = NULL;

band = (sc->lse_lnb) ? sc->lse_lnb->lnb_band(sc->lse_lnb, lm) & 0x1 : 0;
com = 0xF0 | (ls->ls_committed << 2) | (pol << 1) | band;

/* Committed */
/* Single committed (before repeats) */
if (ls->ls_committed >= 0) {
if (linuxdvb_diseqc_send(fd, 0xE0 | r2, 0x10, 0x38, 1, com))
return -1;
usleep(25000);
if (lsp->ls_diseqc_repeats > 0) {
r2 = 1;
if (linuxdvb_diseqc_send(fd, 0xE0, 0x10, 0x38, 1, com))
return -1;
usleep(25000); // 25ms
}
}

/* Repeats */
for (i = 0; i <= lsp->ls_diseqc_repeats; i++) {

/* Uncommitted */
if (ls->ls_uncommitted >= 0) {
if (linuxdvb_diseqc_send(fd, 0xE0 | r1, 0x10, 0x39, 1,
0xF0 | ls->ls_uncommitted))
return -1;
usleep(25000);
}

/* Committed */
if (ls->ls_committed >= 0) {
if (linuxdvb_diseqc_send(fd, 0xE0 | r2, 0x10, 0x38, 1, com))
return -1;
usleep(25000);
}

/* repeat flag */
r1 = r2 = 1;
}

/* repeat flag */
r1 = r2 = 1;
lsp->ls_last_switch = sc;

/* port was changed, new LNB has not received toneburst yet */
lsp->ls_last_toneburst = 0;
}

/* Tone burst */
if (ls->ls_toneburst >= 0) {
if (ls->ls_toneburst >= 0 &&
(lsp->ls_diseqc_full || lsp->ls_last_toneburst != ls->ls_toneburst + 1)) {
lsp->ls_last_toneburst = 0;
tvhtrace("diseqc", "toneburst %s", ls->ls_toneburst ? "B" : "A");
if (ioctl(fd, FE_DISEQC_SEND_BURST,
ls->ls_toneburst ? SEC_MINI_B : SEC_MINI_A)) {
tvherror("diseqc", "failed to set toneburst (e=%s)", strerror(errno));
return -1;
}
lsp->ls_last_toneburst = ls->ls_toneburst + 1;
}

sc->lse_parent->ls_last_switch = sc;

return 0;
}

Expand Down

0 comments on commit 70a17df

Please sign in to comment.