From 4fadb70767e727088bea6cc64b53b37d43da8855 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sun, 14 Dec 2014 15:57:13 +0100 Subject: [PATCH] linuxdvb diseqc: handle 22khz tone better for unicable --- src/input/mpegts/linuxdvb/linuxdvb_private.h | 1 + src/input/mpegts/linuxdvb/linuxdvb_satconf.c | 30 ++++++++++++++------ src/input/mpegts/linuxdvb/linuxdvb_switch.c | 11 ++++--- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/input/mpegts/linuxdvb/linuxdvb_private.h b/src/input/mpegts/linuxdvb/linuxdvb_private.h index acb3b435..ffc2c9bf 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_private.h +++ b/src/input/mpegts/linuxdvb/linuxdvb_private.h @@ -161,6 +161,7 @@ struct linuxdvb_satconf linuxdvb_satconf_ele_t *ls_last_switch; int ls_last_pol; int ls_last_toneburst; + int ls_last_tone_off; }; /* diff --git a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c index 38cb8704..249053d2 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c @@ -680,14 +680,21 @@ linuxdvb_satconf_ele_tune ( linuxdvb_satconf_ele_t *lse ) (linuxdvb_diseqc_t*)lse->lse_en50494, (linuxdvb_diseqc_t*)lse->lse_lnb }; - // TODO: really need to understand whether or not we need to pre configure - // and/or re-affirm the switch - /* Disable tone (en50494 don't use tone) */ - if (!lse->lse_en50494) { - if (ioctl(lfe->lfe_fe_fd, FE_SET_TONE, SEC_TONE_OFF)) { - tvherror("diseqc", "failed to disable tone"); - return -1; + /* + * Disable tone (en50494 don't use tone) + * The 22khz tone is used for signalling band (universal LNB) + * and also for the DiseqC commands. It's necessary to turn + * tone off before communication with DiseqC devices. + */ + + if (!lse->lse_en50494 || lse->lse_switch || lse->lse_rotor) { + if (ls->ls_diseqc_full || ls->ls_last_tone_off != 1) { + if (ioctl(lfe->lfe_fe_fd, FE_SET_TONE, SEC_TONE_OFF)) { + tvherror("diseqc", "failed to disable tone"); + return -1; + } + ls->ls_last_tone_off = 1; } } @@ -718,13 +725,17 @@ linuxdvb_satconf_ele_tune ( linuxdvb_satconf_ele_t *lse ) /* Set the tone (en50494 don't use tone) */ if (!lse->lse_en50494) { + ls->ls_last_tone_off = 0; b = lse->lse_lnb->lnb_band(lse->lse_lnb, lm); tvhtrace("diseqc", "set diseqc tone %s", b ? "on" : "off"); - if (ioctl(lfe->lfe_fe_fd, FE_SET_TONE, b ? SEC_TONE_ON : SEC_TONE_OFF)) { + if (b && ioctl(lfe->lfe_fe_fd, FE_SET_TONE, b ? SEC_TONE_ON : SEC_TONE_OFF)) { tvherror("diseqc", "failed to set diseqc tone (e=%s)", strerror(errno)); return -1; } - usleep(20000); // Allow LNB to settle before tuning + if (b) { + ls->ls_last_tone_off = 2; + usleep(20000); // Allow LNB to settle before tuning + } } /* Frontend */ @@ -786,6 +797,7 @@ linuxdvb_satconf_reset ls->ls_last_switch = NULL; ls->ls_last_pol = 0; ls->ls_last_toneburst = 0; + ls->ls_last_tone_off = 0; } /* ************************************************************************** diff --git a/src/input/mpegts/linuxdvb/linuxdvb_switch.c b/src/input/mpegts/linuxdvb/linuxdvb_switch.c index 6f8324ec..35d6ff16 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_switch.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_switch.c @@ -158,11 +158,14 @@ linuxdvb_switch_tune lsp->ls_last_pol = 0; - /* Set the voltage */ - if (linuxdvb_diseqc_set_volt(fd, pol)) - return -1; + /* EN50494 devices have another mechanism to select polarization */ + if (!sc->lse_en50494) { + /* Set the voltage */ + if (linuxdvb_diseqc_set_volt(fd, pol)) + return -1; - lsp->ls_last_pol = pol + 1; + lsp->ls_last_pol = pol + 1; + } } if (lsp->ls_diseqc_full || lsp->ls_last_switch != sc) {