]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
linuxdvb: add linuxdvb_frontend_clear(), fixes #2547
authorJaroslav Kysela <perex@perex.cz>
Mon, 15 Dec 2014 12:12:44 +0000 (13:12 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 15 Dec 2014 12:13:53 +0000 (13:13 +0100)
src/input/mpegts/linuxdvb/linuxdvb_frontend.c
src/input/mpegts/linuxdvb/linuxdvb_private.h
src/input/mpegts/linuxdvb/linuxdvb_satconf.c

index e7f5c2603474bc385cbefe3d41e7bd8b58dae06f..641af7db76357b2b3425e0a4f33ea0accddc2673 100644 (file)
@@ -979,6 +979,41 @@ int linuxdvb2tvh_delsys ( int delsys )
 }
 #endif
 
+int
+linuxdvb_frontend_clear
+  ( linuxdvb_frontend_t *lfe )
+{
+  char buf1[256];
+
+  /* Open FE */
+  lfe->mi_display_name((mpegts_input_t*)lfe, buf1, sizeof(buf1));
+
+  if (lfe->lfe_fe_fd <= 0) {
+    lfe->lfe_fe_fd = tvh_open(lfe->lfe_fe_path, O_RDWR | O_NONBLOCK, 0);
+    tvhtrace("linuxdvb", "%s - opening FE %s (%d)", buf1, lfe->lfe_fe_path, lfe->lfe_fe_fd);
+    if (lfe->lfe_fe_fd <= 0) {
+      return SM_CODE_TUNING_FAILED;
+    }
+  }
+  lfe->lfe_locked = 0;
+  lfe->lfe_status = 0;
+
+#if DVB_API_VERSION >= 5
+  static struct dtv_property clear_p[] = {
+    { .cmd = DTV_CLEAR },
+  };
+  static struct dtv_properties clear_cmdseq = {
+    .num = 1,
+    .props = clear_p
+  };
+  if ((ioctl(lfe->lfe_fe_fd, FE_SET_PROPERTY, &clear_cmdseq)) != 0) {
+    tvherror("linuxdvb", "%s - DTV_CLEAR failed [e=%s]", buf1, strerror(errno));
+    return -1;
+  }
+#endif
+
+  return 0;
+}
 
 int
 linuxdvb_frontend_tune0
@@ -1113,18 +1148,10 @@ linuxdvb_frontend_tune0
   dvb_mux_conf_t *dmc;
   struct dvb_frontend_parameters p;
 
-  /* Open FE */
-  lfe->mi_display_name((mpegts_input_t*)lfe, buf1, sizeof(buf1));
+  r = linuxdvb_frontend_clear(lfe);
+  if (r) return r;
 
-  if (lfe->lfe_fe_fd <= 0) {
-    lfe->lfe_fe_fd = tvh_open(lfe->lfe_fe_path, O_RDWR | O_NONBLOCK, 0);
-    tvhtrace("linuxdvb", "%s - opening FE %s (%d)", buf1, lfe->lfe_fe_path, lfe->lfe_fe_fd);
-    if (lfe->lfe_fe_fd <= 0) {
-      return SM_CODE_TUNING_FAILED;
-    }
-  }
-  lfe->lfe_locked = 0;
-  lfe->lfe_status = 0;
+  lfe->mi_display_name((mpegts_input_t*)lfe, buf1, sizeof(buf1));
 
   /*
    * copy the universal parameters to the Linux kernel structure
@@ -1184,18 +1211,6 @@ linuxdvb_frontend_tune0
   struct dtv_property cmds[20];
   struct dtv_properties cmdseq;
   
-  /* Clear Q */
-  static struct dtv_property clear_p[] = {
-    { .cmd = DTV_CLEAR },
-  };
-  static struct dtv_properties clear_cmdseq = {
-    .num = 1,
-    .props = clear_p
-  };
-  if ((ioctl(lfe->lfe_fe_fd, FE_SET_PROPERTY, &clear_cmdseq)) != 0) {
-    tvherror("linuxdvb", "%s - DTV_CLEAR failed [e=%s]", buf1, strerror(errno));
-    return -1;
-  }
 
   if (freq == (uint32_t)-1)
     freq = p.frequency;
index 165eaf359f9b0b98925284ac045550a6c3cb8edf..1428519466dce64348c68acc5aad47b8493eae95 100644 (file)
@@ -256,6 +256,8 @@ void linuxdvb_frontend_delete ( linuxdvb_frontend_t *lfe );
 void linuxdvb_frontend_add_network
   ( linuxdvb_frontend_t *lfe, linuxdvb_network_t *net );
 
+int linuxdvb_frontend_clear
+  ( linuxdvb_frontend_t *lfe );
 int linuxdvb_frontend_tune0
   ( linuxdvb_frontend_t *lfe, mpegts_mux_instance_t *mmi, uint32_t freq );
 int linuxdvb_frontend_tune1
index 562c37bc97486ba4daf59ed08611a56dd4c13600..4ebbe8c8109cf3f1f9f7dd103c0d52855cb14875 100644 (file)
@@ -790,10 +790,23 @@ linuxdvb_satconf_start_mux
   f = lse->lse_lnb->lnb_freq(lse->lse_lnb, lm);
   if (f == (uint32_t)-1)
     return SM_CODE_TUNING_FAILED;
+#if 0
+  // Note: unfortunately, this test also "delays" the valid
+  //       tune request, so it's disabled now until we create
+  //       own parameter validator
   if (!lse->lse_en50494) {
     r = linuxdvb_frontend_tune0(lfe, mmi, f);
     if (r) return r;
+  } else {
+    /* Clear the frontend settings, open frontend fd */
+    r = linuxdvb_frontend_clear(lfe);
+    if (r) return r;
   }
+#else
+  /* Clear the frontend settings, open frontend fd */
+  r = linuxdvb_frontend_clear(lfe);
+  if (r) return r;
+#endif
 
   /* Diseqc */
   ls->ls_mmi        = mmi;