diff --git a/src/capmt.c b/src/capmt.c index 9e42a8ab..6c5869e5 100644 --- a/src/capmt.c +++ b/src/capmt.c @@ -36,6 +36,7 @@ #include #include "tvhead.h" +#include "dvb/dvb.h" #include "tcp.h" #include "psi.h" #include "tsdemux.h" @@ -410,6 +411,7 @@ capmt_table_input(struct th_descrambler *td, struct th_transport *t, { capmt_transport_t *ct = (capmt_transport_t *)td; capmt_t *capmt = ct->ct_capmt; + int adapter_num = t->tht_dvb_mux_instance->tdmi_adapter->tda_adapter_num; if(len > 4096) return; @@ -486,7 +488,8 @@ capmt_table_input(struct th_descrambler *td, struct th_transport *t, capmt_descriptor_t dmd = { .cad_type = CAPMT_DESC_DEMUX, .cad_length = 0x02, - .cad_data = { 0x01, 0x00 }}; + .cad_data = { + 1 << adapter_num, adapter_num }}; memcpy(&buf[pos], &dmd, dmd.cad_length + 2); pos += dmd.cad_length + 2; @@ -611,7 +614,9 @@ capmt_transport_start(th_transport_t *t) TAILQ_FOREACH(capmt, &capmts, capmt_link) { tvhlog(LOG_INFO, "capmt", - "Starting capmt server for service \"%s\"", t->tht_svcname); + "Starting capmt server for service \"%s\" on tuner %d", + t->tht_svcname, + t->tht_dvb_mux_instance->tdmi_adapter->tda_adapter_num); ct = calloc(1, sizeof(capmt_transport_t)); ct->ct_cluster_size = get_suggested_cluster_size(); diff --git a/src/dvb/dvb.h b/src/dvb/dvb.h index bd5a46cf..d08fde2e 100644 --- a/src/dvb/dvb.h +++ b/src/dvb/dvb.h @@ -170,6 +170,8 @@ typedef struct th_dvb_adapter { int tda_type; struct dvb_frontend_info *tda_fe_info; + int tda_adapter_num; + char *tda_demux_path; char *tda_dvr_path; diff --git a/src/dvb/dvb_adapter.c b/src/dvb/dvb_adapter.c index 7a0d1e0e..7e0a684a 100644 --- a/src/dvb/dvb_adapter.c +++ b/src/dvb/dvb_adapter.c @@ -172,14 +172,16 @@ dvb_adapter_set_diseqc_version(th_dvb_adapter_t *tda, unsigned int v) * */ static void -tda_add(const char *path) +tda_add(int adapter_num) { + char path[200]; char fname[256]; int fe, i, r; th_dvb_adapter_t *tda; char buf[400]; pthread_t ptid; + snprintf(path, sizeof(path), "/dev/dvb/adapter%d", adapter_num); snprintf(fname, sizeof(fname), "%s/frontend0", path); fe = tvh_open(fname, O_RDWR | O_NONBLOCK, 0); @@ -192,6 +194,7 @@ tda_add(const char *path) tda = tda_alloc(); + 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); @@ -254,7 +257,6 @@ tda_add(const char *path) void dvb_adapter_init(uint32_t adapter_mask) { - char path[200]; htsmsg_t *l, *c; htsmsg_field_t *f; const char *name, *s; @@ -263,12 +265,9 @@ dvb_adapter_init(uint32_t adapter_mask) TAILQ_INIT(&dvb_adapters); - for(i = 0; i < 32; i++) { - if ((1 << i) & adapter_mask) { - snprintf(path, sizeof(path), "/dev/dvb/adapter%d", i); - tda_add(path); - } - } + for(i = 0; i < 32; i++) + if ((1 << i) & adapter_mask) + tda_add(i); l = hts_settings_load("dvbadapters"); if(l != NULL) {