]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
linuxdvb diseqc: handle 22khz tone better for unicable
authorJaroslav Kysela <perex@perex.cz>
Sun, 14 Dec 2014 14:57:13 +0000 (15:57 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sun, 14 Dec 2014 14:57:13 +0000 (15:57 +0100)
src/input/mpegts/linuxdvb/linuxdvb_private.h
src/input/mpegts/linuxdvb/linuxdvb_satconf.c
src/input/mpegts/linuxdvb/linuxdvb_switch.c

index acb3b4358a0e70b7f9ed8e9532af6c33f9531e77..ffc2c9bf22bb35a405faf9da7b5178006f0e15e9 100644 (file)
@@ -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;
 };
 
 /*
index 38cb8704cb3878aa3e07407c89695e2f8d3601df..249053d22999ec4dc3c1fc9bbaa530d07bf433a5 100644 (file)
@@ -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;
 }
 
 /* **************************************************************************
index 6f8324ec86c62286a0915326cf0f7b1f4e0b131f..35d6ff1652be577810104f523d275880c1701146 100644 (file)
@@ -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) {