]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
en50494: optimization for previous patch, move code to linuxdvb_en50494.c, fixes...
authorJaroslav Kysela <perex@perex.cz>
Fri, 18 Sep 2015 18:32:25 +0000 (20:32 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 18 Sep 2015 18:33:16 +0000 (20:33 +0200)
src/input/mpegts/linuxdvb/linuxdvb_en50494.c
src/input/mpegts/linuxdvb/linuxdvb_private.h
src/input/mpegts/linuxdvb/linuxdvb_satconf.c

index 8fc90b742709b55b43da82dfbeed7fec6d3933cd..804268b6c7b876ddb4f714c0a35ebb5131deaf60 100644 (file)
@@ -155,24 +155,49 @@ const idclass_t linuxdvb_en50494_class =
  * Class methods
  * *************************************************************************/
 
+static int
+linuxdvb_en50494_freq0
+  ( linuxdvb_en50494_t *le, int freq, int *rfreq, uint16_t *t )
+{
+  /* transponder value - t */
+  *t = round((((freq / 1000) + 2 + le->le_frequency) / 4) - 350);
+  if (*t > 1024) {
+    tvherror("en50494", "transponder value bigger then 1024");
+    return -1;
+  }
+
+  /* tune frequency for the frontend */
+  *rfreq = (*t + 350) * 4000 - freq;
+  return 0;
+}
+
+static int
+linuxdvb_en50494_freq
+  ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, int freq )
+{
+  linuxdvb_en50494_t *le = (linuxdvb_en50494_t*) ld;
+  int rfreq;
+  uint16_t t;
+
+  if (linuxdvb_en50494_freq0(le, freq, &rfreq, &t))
+    return -1;
+  return freq;
+}
+
 static int
 linuxdvb_en50494_tune
   ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm,
     linuxdvb_satconf_t *lsp, linuxdvb_satconf_ele_t *sc,
     int vol, int pol, int band, int freq )
 {
-  int ret = 0, i, fd = linuxdvb_satconf_fe_fd(lsp);
+  int ret = 0, i, fd = linuxdvb_satconf_fe_fd(lsp), rfreq;
   linuxdvb_en50494_t *le = (linuxdvb_en50494_t*) ld;
-
-  /* transponder value - t*/
-  uint16_t t = round((( (freq / 1000) + 2 + le->le_frequency) / 4) - 350);
-  if ( t > 1024) {
-    tvherror("en50494", "transponder value bigger then 1024");
-    return -1;
-  }
+  uint16_t t;
 
   /* tune frequency for the frontend */
-  le->le_tune_freq = (t + 350) * 4000 - freq;
+  if (linuxdvb_en50494_freq0(le, freq, &rfreq, &t))
+    return -1;
+  le->le_tune_freq = rfreq;
 
   /* 2 data fields (16bit) */
   uint8_t data1, data2;
@@ -295,6 +320,7 @@ linuxdvb_en50494_create0
   le->le_id        = 0;
   le->le_frequency = 0;
   le->le_pin       = LINUXDVB_EN50494_NOPIN;
+  le->ld_freq      = linuxdvb_en50494_freq;
 
   ld = linuxdvb_diseqc_create0((linuxdvb_diseqc_t *)le,
                                NULL, &linuxdvb_en50494_class, conf,
index ffe85877e98efd716fd965fde13bb2be51345e19..07935360662ddf06271cd0c674a4deb1fc389642 100644 (file)
@@ -309,6 +309,7 @@ struct linuxdvb_diseqc
   const char           *ld_type;
   linuxdvb_satconf_ele_t   *ld_satconf;
   int (*ld_grace) (linuxdvb_diseqc_t *ld, dvb_mux_t *lm);
+  int (*ld_freq)  (linuxdvb_diseqc_t *ld, dvb_mux_t *lm, int freq);
   int (*ld_tune)  (linuxdvb_diseqc_t *ld, dvb_mux_t *lm,
                    linuxdvb_satconf_t *lsp, linuxdvb_satconf_ele_t *ls,
                    int vol, int pol, int band, int freq);
@@ -328,7 +329,7 @@ struct linuxdvb_en50494
 {
   linuxdvb_diseqc_t;
 
-  /* en50494 configuration*/
+  /* en50494 configuration */
   uint16_t  le_position;  /* satelitte A(0) or B(1) */
   uint16_t  le_frequency; /* user band frequency in MHz */
   uint16_t  le_id;        /* user band id 0-7 */
index cd73f2a68f1f085a80e3a3ded6b1c372b070f01f..157be159d2f9e7987abb8c36109429a81697a482 100644 (file)
@@ -853,15 +853,15 @@ linuxdvb_satconf_start_mux
 
     /* calculate tuning frequency for en50494 */
     if (lse->lse_en50494) {
-      /* transponder value - t*/
-      uint16_t t = round((( (f / 1000) + 2 + (((linuxdvb_en50494_t*)lse->lse_en50494)->le_frequency)) / 4) - 350);
-      if ( t > 1024) {
-        tvherror("en50494", "transponder value bigger then 1024");
+      r = lse->lse_en50494->ld_freq(lse->lse_en50494, lm, f);
+      if (r < 0) {
+        tvherror("en50494", "invalid tuning freq");
         return -1;
       }
       /* tune frequency for the frontend */
-      f = (t + 350) * 4000 - f;
+      f = r;
     }
+
     r = linuxdvb_frontend_tune0(lfe, mmi, f);
     if (r) return r;
   } else {