]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
* Add support for DiSEqC 1.1 / 2.1, configured on per-adapter basis.
authorAndreas Öman <andreas@lonelycoder.com>
Tue, 8 Sep 2009 19:42:40 +0000 (19:42 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Tue, 8 Sep 2009 19:42:40 +0000 (19:42 +0000)
  Ticket #99

debian/changelog
src/dvb/diseqc.c
src/dvb/diseqc.h
src/dvb/dvb.h
src/dvb/dvb_adapter.c
src/dvb/dvb_fe.c
src/webui/extjs.c
src/webui/static/app/dvb.js

index 6660ba1c462b9f1a9cf6a258570fa92cce6dcb55..fd7bfb426763a65421bda0da406f10f09e93aa4c 100644 (file)
@@ -17,6 +17,9 @@ hts-tvheadend (2.6) hts; urgency=low
 
   * Default character encoding in DVB is ISO6937, not Latin-1. Ticket #96
 
+  * Add support for DiSEqC 1.1 / 2.1, configured on per-adapter basis.
+    Ticket #99
+
 hts-tvheadend (2.5) hts; urgency=low
 
   * If a previosly detected DVB adapter was not present during startup,
index 769ca17666dcca4829af1ef82db137708fe56098..c3344d0ecd72bb36878a81b17a1afbcc5523f6d0 100644 (file)
@@ -6,7 +6,7 @@
 #include "diseqc.h"
 
 
-struct diseqc_cmd switch_cmds[] = {
+struct diseqc_cmd switch_commited_cmds[] = {
        { { { 0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00 }, 4 }, 0 },
        { { { 0xe0, 0x10, 0x38, 0xf2, 0x00, 0x00 }, 4 }, 0 },
        { { { 0xe0, 0x10, 0x38, 0xf1, 0x00, 0x00 }, 4 }, 0 },
@@ -25,6 +25,25 @@ struct diseqc_cmd switch_cmds[] = {
        { { { 0xe0, 0x10, 0x38, 0xff, 0x00, 0x00 }, 4 }, 0 }
 };
 
+struct diseqc_cmd switch_uncommited_cmds[] = {
+       { { { 0xe0, 0x10, 0x39, 0xf0, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xf1, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xf2, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xf3, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xf4, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xf5, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xf6, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xf7, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xf8, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xf9, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xfa, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xfb, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xfc, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xfd, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xfe, 0x00, 0x00 }, 4 }, 0 },
+       { { { 0xe0, 0x10, 0x39, 0xff, 0x00, 0x00 }, 4 }, 0 }
+};
+
 
 /*--------------------------------------------------------------------------*/
 
@@ -68,16 +87,22 @@ int diseqc_send_msg (int fd, fe_sec_voltage_t v, struct diseqc_cmd **cmd,
 }
 
 
-int diseqc_setup(int frontend_fd, int switch_pos, int voltage_18, int hiband)
+int 
+diseqc_setup(int frontend_fd, int switch_pos, int voltage_18, int hiband,
+            int diseqc_ver)
 {
        struct diseqc_cmd *cmd[2] = { NULL, NULL };
        int i = 4 * switch_pos + 2 * hiband + (voltage_18 ? 1 : 0);
-
-
-       if(i < 0 || i >= (int) (sizeof(switch_cmds)/sizeof(struct diseqc_cmd)))
-               return -1;
-
-       cmd[0] = &switch_cmds[i];
+       
+       if (diseqc_ver == 1) {
+               if(switch_pos < 0 || switch_pos >= (int) (sizeof(switch_uncommited_cmds)/sizeof(struct diseqc_cmd)))
+                       return -1;
+               cmd[0] = &switch_uncommited_cmds[switch_pos];
+       } else {
+               if(i < 0 || i >= (int) (sizeof(switch_commited_cmds)/sizeof(struct diseqc_cmd)))
+                       return -1;
+               cmd[0] = &switch_commited_cmds[i];
+       }
 
        return diseqc_send_msg (frontend_fd,
                                i % 2 ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13,
index 2038962af6f67adac6667ea4cfcc9f4d926b90b9..a1ad4509d8e4859bec3e1d4d2258210491f78c05 100644 (file)
@@ -18,7 +18,8 @@ extern int diseqc_send_msg(int fd, fe_sec_voltage_t v, struct diseqc_cmd **cmd,
 /**
  *   set up the switch to position/voltage/tone
  */
-int diseqc_setup(int frontend_fd, int switch_pos, int voltage_18, int hiband);
+int diseqc_setup(int frontend_fd, int switch_pos, int voltage_18, int hiband,
+                int diseqc_ver);
 
 #endif
 
index 3fd68118cd9a5814d93a79e7cbc44cd0cc82225f..77858593516c63f2aaa40b9fe6bf48f959c5722b 100644 (file)
@@ -165,7 +165,7 @@ typedef struct th_dvb_adapter {
   uint32_t tda_autodiscovery;
   uint32_t tda_idlescan;
   uint32_t tda_logging;
-
+  uint32_t tda_diseqc_version;
   char *tda_displayname;
 
   int tda_fe_fd;
@@ -215,6 +215,8 @@ void dvb_adapter_set_idlescan(th_dvb_adapter_t *tda, int on);
 
 void dvb_adapter_set_logging(th_dvb_adapter_t *tda, int on);
 
+void dvb_adapter_set_diseqc_version(th_dvb_adapter_t *tda, unsigned int v);
+
 void dvb_adapter_clone(th_dvb_adapter_t *dst, th_dvb_adapter_t *src);
 
 void dvb_adapter_clean(th_dvb_adapter_t *tda);
index 0482e8274306d0704d1fe7b148ca7deefd5dc806..0511c3d5dc301e62d8992127069fc7f9c1beb574 100644 (file)
@@ -79,6 +79,7 @@ tda_save(th_dvb_adapter_t *tda)
   htsmsg_add_u32(m, "autodiscovery", tda->tda_autodiscovery);
   htsmsg_add_u32(m, "idlescan", tda->tda_idlescan);
   htsmsg_add_u32(m, "logging", tda->tda_logging);
+  htsmsg_add_u32(m, "diseqc_version", tda->tda_diseqc_version);
   hts_settings_save(m, "dvbadapters/%s", tda->tda_identifier);
   htsmsg_destroy(m);
 }
@@ -164,6 +165,29 @@ dvb_adapter_set_logging(th_dvb_adapter_t *tda, int on)
 }
 
 
+/**
+ *
+ */
+void
+dvb_adapter_set_diseqc_version(th_dvb_adapter_t *tda, unsigned int v)
+{
+  if(v > 1)
+    v = 1;
+
+  if(tda->tda_diseqc_version == v)
+    return;
+
+  lock_assert(&global_lock);
+
+  tvhlog(LOG_NOTICE, "dvb", "Adapter \"%s\" DiSEqC version set to: %s",
+        tda->tda_displayname, v ? "1.1 / 2.1" : "1.0 / 2.0" );
+
+  tda->tda_diseqc_version = v;
+  tda_save(tda);
+}
+
+
+
 /**
  *
  */
@@ -294,6 +318,7 @@ dvb_adapter_init(void)
       htsmsg_get_u32(c, "autodiscovery", &tda->tda_autodiscovery);
       htsmsg_get_u32(c, "idlescan", &tda->tda_idlescan);
       htsmsg_get_u32(c, "logging", &tda->tda_logging);
+      htsmsg_get_u32(c, "diseqc_version", &tda->tda_diseqc_version);
     }
     htsmsg_destroy(l);
   }
index 134644099c505f101c2f8411099d7ade7b2acf1b..9c3d6f8144749e5547818f5da6a4dda19718bbe9 100644 (file)
@@ -340,7 +340,7 @@ dvb_fe_tune(th_dvb_mux_instance_t *tdmi, const char *reason)
                 port,
                 pol == POLARISATION_HORIZONTAL ||
                 pol == POLARISATION_CIRCULAR_LEFT,
-                hiband);
+                hiband, tda->tda_diseqc_version);
       
     usleep(50000);
       
index fc426a23759b3017adc8c19f1144eef082d26920..71058c42f9417bac68610ff8d7049ae9167990b0 100644 (file)
@@ -990,6 +990,10 @@ extjs_dvbadapter(http_connection_t *hc, const char *remain, void *opaque)
     htsmsg_add_u32(r, "automux", tda->tda_autodiscovery);
     htsmsg_add_u32(r, "idlescan", tda->tda_idlescan);
     htsmsg_add_u32(r, "logging", tda->tda_logging);
+    htsmsg_add_str(r, "diseqcversion", 
+                  ((const char *[]){"DiSEqC 1.0 / 2.0",
+                                      "DiSEqC 1.1 / 2.1"})
+                  [tda->tda_diseqc_version % 2]);
  
     out = json_single_record(r, "dvbadapters");
   } else if(!strcmp(op, "save")) {
@@ -1006,6 +1010,13 @@ extjs_dvbadapter(http_connection_t *hc, const char *remain, void *opaque)
     s = http_arg_get(&hc->hc_req_args, "logging");
     dvb_adapter_set_logging(tda, !!s);
 
+    if((s = http_arg_get(&hc->hc_req_args, "diseqcversion")) != NULL) {
+      if(!strcmp(s, "DiSEqC 1.0 / 2.0"))
+       dvb_adapter_set_diseqc_version(tda, 0);
+      else if(!strcmp(s, "DiSEqC 1.1 / 2.1"))
+       dvb_adapter_set_diseqc_version(tda, 1);
+    }
+
     out = htsmsg_create_map();
     htsmsg_add_u32(out, "success", 1);
   } else if(!strcmp(op, "addnetwork")) {
index fd4300a66ed790cdc4489be6c3e8d1f78a6bca55..e952e2864dbf594da6587626922abfa7ef26b4cb 100644 (file)
@@ -998,7 +998,7 @@ tvheadend.dvb_adapter_general = function(adapterData, satConfStore) {
 
     var confreader = new Ext.data.JsonReader({
        root: 'dvbadapters'
-    }, ['name', 'automux', 'idlescan', 'logging']);
+    }, ['name', 'automux', 'idlescan', 'logging', 'diseqcversion']);
 
     
     function saveConfForm () {
@@ -1008,6 +1008,39 @@ tvheadend.dvb_adapter_general = function(adapterData, satConfStore) {
            waitMsg:'Saving Data...'
        });
     }
+
+    var items = [
+       {
+           fieldLabel: 'Adapter name',
+           name: 'name',
+           width: 250
+       },
+       new Ext.form.Checkbox({
+           fieldLabel: 'Autodetect muxes',
+           name: 'automux'
+       }),
+       new Ext.form.Checkbox({
+           fieldLabel: 'Idle scanning',
+           name: 'idlescan'
+       }),
+       new Ext.form.Checkbox({
+           fieldLabel: 'Detailed logging',
+           name: 'logging'
+       })
+    ];
+
+    if(satConfStore) { 
+       v = new Ext.form.ComboBox({
+           name: 'diseqcversion',
+           fieldLabel: 'DiSEqC version',
+           editable: false,
+           allowBlank: false,
+           mode: 'remote',
+           triggerAction: 'all',
+           store: ['DiSEqC 1.0 / 2.0', 'DiSEqC 1.1 / 2.1']
+       });
+       items.push(v);
+    }
     
     var confform = new Ext.FormPanel({
        title:'Adapter configuration',
@@ -1022,25 +1055,7 @@ tvheadend.dvb_adapter_general = function(adapterData, satConfStore) {
        waitMsgTarget: true,
        reader: confreader,
        defaultType: 'textfield',
-       items: [
-           {
-               fieldLabel: 'Adapter name',
-               name: 'name',
-               width: 250
-           },
-           new Ext.form.Checkbox({
-               fieldLabel: 'Autodetect muxes',
-               name: 'automux'
-           }),
-           new Ext.form.Checkbox({
-               fieldLabel: 'Idle scanning',
-               name: 'idlescan'
-           }),
-           new Ext.form.Checkbox({
-               fieldLabel: 'Detailed logging',
-               name: 'logging'
-           })
-       ],
+       items: items,
        buttons: [{
            text: 'Save',
            handler: saveConfForm
@@ -1051,6 +1066,8 @@ tvheadend.dvb_adapter_general = function(adapterData, satConfStore) {
        url:'dvb/adapter/' + adapterId, 
        params:{'op':'load'},
        success:function(form, action) {
+           console.log(form);
+           console.log(action);
            confform.enable();
        }
     });