diff --git a/src/dvb/dvb.c b/src/dvb/dvb.c index 9e3775b..1e097f2 100644 --- a/src/dvb/dvb.c +++ b/src/dvb/dvb.c @@ -23,8 +23,8 @@ #include "dvb_charset.h" void -dvb_init(uint32_t adapter_mask, const char *rawfile) +dvb_init(uint32_t adapter_mask, uint32_t *adapter_frontends, const char *rawfile) { dvb_charset_init(); - dvb_adapter_init(adapter_mask, rawfile); + dvb_adapter_init(adapter_mask, adapter_frontends, rawfile); } diff --git a/src/dvb/dvb.h b/src/dvb/dvb.h index 80d8c66..6da8471 100644 --- a/src/dvb/dvb.h +++ b/src/dvb/dvb.h @@ -327,12 +327,12 @@ typedef struct th_dvb_table { extern struct th_dvb_adapter_queue dvb_adapters; extern struct th_dvb_mux_instance_tree dvb_muxes; -void dvb_init(uint32_t adapter_mask, const char *rawfile); +void dvb_init(uint32_t adapter_mask, uint32_t *adapter_frontends, const char *rawfile); /** * DVB Adapter */ -void dvb_adapter_init(uint32_t adapter_mask, const char *rawfile); +void dvb_adapter_init(uint32_t adapter_mask, uint32_t *adapter_frontends, const char *rawfile); void dvb_adapter_mux_scanner(void *aux); diff --git a/src/dvb/dvb_adapter.c b/src/dvb/dvb_adapter.c index 75681b5..1b1908d 100644 --- a/src/dvb/dvb_adapter.c +++ b/src/dvb/dvb_adapter.c @@ -445,7 +445,7 @@ check_full_stream(th_dvb_adapter_t *tda) * */ static void -tda_add(int adapter_num) +tda_add(int adapter_num, int frontend_num, int demux_num) { char path[200], fname[256]; int fe, i, r; @@ -453,7 +453,7 @@ tda_add(int adapter_num) char buf[400]; snprintf(path, sizeof(path), "/dev/dvb/adapter%d", adapter_num); - snprintf(fname, sizeof(fname), "%s/frontend0", path); + snprintf(fname, sizeof(fname), "%s/frontend%d", path, frontend_num); fe = tvh_open(fname, O_RDWR | O_NONBLOCK, 0); if(fe == -1) { @@ -468,7 +468,7 @@ tda_add(int adapter_num) tda->tda_adapter_num = adapter_num; tda->tda_rootpath = strdup(path); tda->tda_demux_path = malloc(256); - snprintf(tda->tda_demux_path, 256, "%s/demux0", path); + snprintf(tda->tda_demux_path, 256, "%s/demux%d", path, demux_num); tda->tda_fe_path = strdup(fname); tda->tda_fe_fd = -1; tda->tda_dvr_pipe.rd = -1; @@ -637,7 +637,7 @@ dvb_adapter_stop ( th_dvb_adapter_t *tda ) * */ void -dvb_adapter_init(uint32_t adapter_mask, const char *rawfile) +dvb_adapter_init(uint32_t adapter_mask, uint32_t *adapter_frontends, const char *rawfile) { htsmsg_t *l, *c; htsmsg_field_t *f; @@ -650,8 +650,8 @@ dvb_adapter_init(uint32_t adapter_mask, const char *rawfile) /* Initialise hardware */ for(i = 0; i < 32; i++) - if ((1 << i) & adapter_mask) - tda_add(i); + if ((1 << i) & adapter_mask) + tda_add(i, adapter_frontends[i], 0); /* Initialise rawts test file */ if(rawfile) diff --git a/src/main.c b/src/main.c index 704f6e4..aef77ac 100644 --- a/src/main.c +++ b/src/main.c @@ -190,6 +190,7 @@ usage(const char *argv0) printf("usage: %s [options]\n", argv0); printf("\n"); printf(" -a Use only DVB adapters specified (csv)\n"); + printf(" -b : Specify which frontend frN to use for adapter adpN\n"); printf(" -c Alternate configuration path.\n" " Defaults to [$HOME/.hts/tvheadend]\n"); printf(" -m Alternate mux configuration directory\n"); @@ -288,12 +289,15 @@ main(int argc, char **argv) const char *confpath = NULL; char *p, *endp; uint32_t adapter_mask = 0xffffffff; + uint32_t *adapter_frontends = (uint32_t*)malloc(sizeof(uint32_t)*32); int crash = 0; webui_port = 9981; htsp_port = 9982; gid_t gid; uid_t uid; + memset(adapter_frontends, 0, sizeof(uint32_t)*32); + /* Get current directory */ tvheadend_cwd = dirname(dirname(tvh_strdupa(argv[0]))); @@ -303,7 +307,7 @@ main(int argc, char **argv) // make sure the timezone is set tzset(); - while((c = getopt(argc, argv, "Aa:fp:u:g:c:Chdr:j:sw:e:E:R:W:")) != -1) { + while((c = getopt(argc, argv, "Aa:b:fp:u:g:c:Chdr:j:sw:e:E:R:W:")) != -1) { switch(c) { case 'a': adapter_mask = 0x0; @@ -325,6 +329,18 @@ main(int argc, char **argv) usage(argv[0]); } break; + case 'b': + p = strtok(optarg, ":"); + if (p != NULL) { + int tmp_frontend = strtol(p, &endp, 10); + p = strtok(NULL, ":"); + if(p == NULL || *endp != 0 || tmp_frontend < 0 || tmp_frontend > 31) + usage(argv[0]); + adapter_frontends[tmp_frontend] = strtol(p, &endp, 10); + } else { + usage(argv[0]); + } + break; case 'A': crash = 1; break; @@ -480,9 +496,11 @@ main(int argc, char **argv) #if ENABLE_LINUXDVB muxes_init(); - dvb_init(adapter_mask, dvb_rawts_input); + dvb_init(adapter_mask, adapter_frontends, dvb_rawts_input); #endif + free(adapter_frontends); + iptv_input_init(); #if ENABLE_V4L