]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
linuxdvb: add complete (ish) v3 and S2 tuning calls
authorAdam Sutton <dev@adamsutton.me.uk>
Sat, 1 Jun 2013 20:43:18 +0000 (21:43 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Sat, 1 Jun 2013 20:43:18 +0000 (21:43 +0100)
This still doesn't include any code to handle DVB-S, that needs further
thought on how best to configure.

src/input/mpegts/dvb.h
src/input/mpegts/dvb_support.c
src/input/mpegts/linuxdvb/linuxdvb_frontend.c

index c72acf39de3c3b74e567df6787b17466d5c0091b..bfaf8f02dd6ef0d033dad4cd64ddf0fc9b113a66 100644 (file)
@@ -226,6 +226,8 @@ int dvb_str2hier    ( const char *str );
 int dvb_str2pol     ( const char *str );
 int dvb_str2type    ( const char *str );
 
+int dvb_bandwidth   ( enum fe_bandwidth bw );
+
 #endif /* ENABLE_DVBAPI */
 
 #endif /* DVB_SUPPORT_H */
index e319b0ad5ee0de25c9df21e3b75dc7732975c8ff..431e19345c12ebad84a1f600feafbf9df6055a44 100644 (file)
@@ -738,4 +738,25 @@ dvb_mux_conf_save ( fe_type_t type, dvb_mux_conf_t *dmc, htsmsg_t *m )
   else if (type == FE_ATSC) dvb_mux_conf_save_atsc(dmc, m);
 }
 
+int
+dvb_bandwidth ( fe_bandwidth_t bw )
+{
+  switch (bw) {
+    case BANDWIDTH_10_MHZ:
+      return 10000000;
+    case BANDWIDTH_8_MHZ:
+      return 8000000;
+    case BANDWIDTH_7_MHZ:
+      return 7000000;
+    case BANDWIDTH_6_MHZ:
+      return 6000000;
+    case BANDWIDTH_5_MHZ:
+      return 5000000;
+    case BANDWIDTH_1_712_MHZ:
+      return 1712000;
+    default:
+      return 0;
+  }
+}
+
 #endif /* ENABLE_DVBAPI */
index ae2dce7a79900a6852fea0048fc29d81d042eb56..f57f39dd91b4f04b723ecfb5d6d8b59f461455da 100644 (file)
@@ -373,16 +373,20 @@ linuxdvb_frontend_monitor ( void *aux )
   }
 }
 
-#if DVB_API_VERSION >= 5
 
 static int
 linuxdvb_frontend_tune
   ( linuxdvb_frontend_t *lfe, linuxdvb_mux_t *lm )
 {
+  int r;
   struct dvb_frontend_event ev;
   dvb_mux_conf_t *dmc = &lm->lm_tuning;
   struct dvb_frontend_parameters *p = &dmc->dmc_fe_params;
-  int r;
+
+  /* S2 tuning */
+#if DVB_API_VERSION >= 5
+  struct dtv_property cmds[20];
+  struct dtv_properties cmdseq = { .num = 0, .props = cmds };
   
   /* Clear Q */
   static struct dtv_property clear_p[] = {
@@ -396,46 +400,64 @@ linuxdvb_frontend_tune
     return -1;
   
   /* Tune */
-  struct dtv_property _dvbs_cmdargs[] = {
-    { .cmd = DTV_DELIVERY_SYSTEM,   .u.data = SYS_DVBT /*TODO: fix this*/ },
-    { .cmd = DTV_FREQUENCY,         .u.data = p->frequency },
-    { .cmd = DTV_INVERSION,         .u.data = p->inversion },
-    { .cmd = DTV_BANDWIDTH_HZ,      .u.data = 8000000 },// TODO: fix this
-    { .cmd = DTV_CODE_RATE_HP,      .u.data = p->u.ofdm.code_rate_HP },
-    { .cmd = DTV_CODE_RATE_LP,      .u.data = p->u.ofdm.code_rate_LP },
-    { .cmd = DTV_MODULATION,        .u.data = p->u.ofdm.constellation },
-    { .cmd = DTV_TRANSMISSION_MODE, .u.data = p->u.ofdm.transmission_mode },
-    { .cmd = DTV_GUARD_INTERVAL,    .u.data = p->u.ofdm.guard_interval },
-    { .cmd = DTV_HIERARCHY,         .u.data = p->u.ofdm.hierarchy_information },
-    { .cmd = DTV_TUNE },
-  };
+#define S2CMD(c, d)\
+  cmds[cmdseq.num].cmd      = c;\
+  cmds[cmdseq.num++].u.data = d
+  S2CMD(DTV_DELIVERY_SYSTEM, lm->lm_tuning.dmc_fe_delsys);
+  S2CMD(DTV_FREQUENCY,       p->frequency);
+  S2CMD(DTV_INVERSION,       p->inversion);
+
+  /* DVB-T */
+  if (lfe->lfe_info.type == FE_OFDM) {
+    S2CMD(DTV_BANDWIDTH_HZ,      dvb_bandwidth(p->u.ofdm.bandwidth));
+    S2CMD(DTV_CODE_RATE_HP,      p->u.ofdm.code_rate_HP);
+    S2CMD(DTV_CODE_RATE_LP,      p->u.ofdm.code_rate_LP);
+    S2CMD(DTV_MODULATION,        p->u.ofdm.constellation);
+    S2CMD(DTV_TRANSMISSION_MODE, p->u.ofdm.transmission_mode);
+    S2CMD(DTV_GUARD_INTERVAL,    p->u.ofdm.guard_interval);
+    S2CMD(DTV_HIERARCHY,         p->u.ofdm.hierarchy_information);
+
+  /* DVB-C */
+  } else if (lfe->lfe_info.type == FE_QAM) {
+    S2CMD(DTV_SYMBOL_RATE,       p->u.qam.symbol_rate);
+    S2CMD(DTV_MODULATION,        p->u.qam.modulation);
+    S2CMD(DTV_INNER_FEC,         p->u.qam.fec_inner);
+
+  /* DVB-S */
+  } else if (lfe->lfe_info.type == FE_QPSK) {
+    S2CMD(DTV_SYMBOL_RATE,       p->u.qpsk.symbol_rate);
+    S2CMD(DTV_INNER_FEC,         p->u.qpsk.fec_inner);
+    S2CMD(DTV_MODULATION,        dmc->dmc_fe_modulation);
+    S2CMD(DTV_ROLLOFF,           dmc->dmc_fe_rolloff);
+
+  /* ATSC */
+  } else {
+    S2CMD(DTV_MODULATION,        p->u.vsb.modulation);
+  }
 
-  struct dtv_properties _dvbs_cmdseq = {
-    .num   = 11,
-    .props = _dvbs_cmdargs
-  };
+  /* Tune */
+  S2CMD(DTV_TUNE, 0);
+#undef S2CMD
+#endif
 
-  /* discard stale QPSK events */
+  /* discard stale events */
   while (1) {
     if (ioctl(lfe->lfe_fe_fd, FE_GET_EVENT, &ev) == -1)
       break;
   }
 
-  /* do tuning now */
-  r = ioctl(lfe->lfe_fe_fd, FE_SET_PROPERTY, &_dvbs_cmdseq);
-
-  return r;
-}
+  /* S2 tuning */
+#if DVB_API_VERSION >= 5
+  r = ioctl(lfe->lfe_fe_fd, FE_SET_PROPERTY, &cmdseq);
 
+  /* v3 tuning */
 #else
-static int
-linuxdvb_frontend_tune
-  ( linuxdvb_frontend_t *lfe, mpegts_mux_instance_t *mmi )
+  r = ioctl(lfe->lfe_fe_fd, FE_SET_FRONTEND, p);
+#endif
 
+  return r;
 }
 
-#endif
-
 /* **************************************************************************
  * Creation/Config
  * *************************************************************************/