From 4bf1f489266de256bb0eb814bcd631a1b1354140 Mon Sep 17 00:00:00 2001 From: drmocm Date: Sat, 4 Feb 2023 15:19:11 +0100 Subject: [PATCH 01/10] limit the number of modulators used with -m option --- apps/modtest.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/apps/modtest.c b/apps/modtest.c index 71784c5..3c69c15 100644 --- a/apps/modtest.c +++ b/apps/modtest.c @@ -1029,8 +1029,8 @@ void set_dvbt_mods(int adapt, int chans, uint32_t start_freq, write_data *wd) wd->tp[i].code_rate = 4; wd->tp[i].trans_mode = MOD_STANDARD_DVBT_8; - device = malloc(sizeof(char)*25); - snprintf(device,24,"/dev/dvb/adapter%d/mod%d",adapt,i); + device = malloc(sizeof(char)*40); + snprintf(device,35,"/dev/dvb/adapter%d/mod%d",adapt,i); fd = open(device, O_RDWR); if( fd < 0 ) { @@ -1109,8 +1109,8 @@ void set_dvbc_mods(int adapt, int chans, uint32_t start_freq, write_data *wd) wd->tp[i].code_rate = 0; wd->tp[i].trans_mode = 0; - device = malloc(sizeof(char)*25); - snprintf(device,24,"/dev/dvb/adapter%d/mod%d",adapt,i); + device = malloc(sizeof(char)*40); + snprintf(device,35,"/dev/dvb/adapter%d/mod%d",adapt,i); fd = open(device, O_RDWR); if( fd < 0 ) { @@ -1156,19 +1156,20 @@ static void usage(char *progname) { printf ("usage: %s [options] \n\n",progname); printf ("options:\n"); - printf (" --adapter, -a : adapter number of modulator card\n"); - printf (" --file, -i : input filename(default test.ts)\n"); - printf (" --frequency, -f : start frequency in MHz( default DVB_C 114MHz, DVB-T 474MHz)\n"); - printf (" --dvbt, -t : modulator is DVB-T\n"); - printf (" --NIT, -n : write a minimal NIT for fatser scan\n"); - printf (" --help, -h : print help message\n"); + printf (" --adapter , -a : adapter number of modulator card\n"); + printf (" --mods , -m : number of modulators to use\n"); + printf (" --file, -i : input filename(default test.ts)\n"); + printf (" --frequency, -f : start frequency in MHz( default DVB_C 114MHz, DVB-T 474MHz)\n"); + printf (" --dvbt, -t : modulator is DVB-T\n"); + printf (" --NIT, -n : write a minimal NIT for fatser scan\n"); + printf (" --help, -h : print help message\n"); printf ("\n"); printf ("\n"); exit(1); } -static int parse_cl(int argc, char * const argv[], char **filename) +static int parse_cl(int argc, char * const argv[], char **filename, int *chans) { int c; int fset = 0; @@ -1184,12 +1185,13 @@ static int parse_cl(int argc, char * const argv[], char **filename) {"dvbt", no_argument , NULL, 't'}, {"NIT", no_argument , NULL, 'n'}, {"adapter", required_argument , NULL, 'a'}, + {"mods", required_argument , NULL, 'm'}, {"file", required_argument , NULL, 'i'}, {"frequency", required_argument , NULL, 'f'}, {NULL, 0, NULL, 0} }; - c = getopt_long (argc, argv, "ha:i:f:nt",long_options, + c = getopt_long (argc, argv, "ha:i:f:ntm:",long_options, &option_index); if (c == -1) @@ -1200,6 +1202,10 @@ static int parse_cl(int argc, char * const argv[], char **filename) adapt = (int)strtol(optarg,(char **)NULL, 0); break; + case 'm': + *chans = (int)strtol(optarg,(char **)NULL, 0); + break; + case 'f': fset = 1; start_freq = strtoul(optarg, NULL, 0)*1000000; @@ -1248,9 +1254,10 @@ int main(int argc, char **argv) write_data wd; int fd_out; int fd_in; + int chans = 0; printf("%s \n\n", progn); - adapt = parse_cl(argc, argv, &filename); + adapt = parse_cl(argc, argv, &filename, &chans); if (check_dvb(&ddevices)<0){ fprintf(stderr,"No DVB devices found\n"); exit(1); @@ -1290,7 +1297,8 @@ int main(int argc, char **argv) exit(1); } - int chans = ddevices.ndevs[adapt]; + if (chans<1 || chans >ddevices.ndevs[adapt] ) + chans = ddevices.ndevs[adapt]; if (dvbt){ set_dvbt_mods(adapt, chans, start_freq, &wd); @@ -1299,9 +1307,9 @@ int main(int argc, char **argv) } fprintf(stderr,"Reading from %s\n", filename); - device = malloc(sizeof(char)*25); + device = malloc(sizeof(char)*40); for (int m= 0; m < chans; m++){ - snprintf(device,24,"/dev/dvb/adapter%d/mod%d",adapt,m); + snprintf(device,35,"/dev/dvb/adapter%d/mod%d",adapt,m); fd_out = open(device, O_WRONLY); wd.fd_out[m] = fd_out; wd.fd_in = fd_in; From 0c3c1f5753ea433e3b4aa866075994f38336d343 Mon Sep 17 00:00:00 2001 From: drmocm Date: Sat, 4 Feb 2023 16:13:10 +0100 Subject: [PATCH 02/10] edited help info --- apps/modtest.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/modtest.c b/apps/modtest.c index 3c69c15..4b1e806 100644 --- a/apps/modtest.c +++ b/apps/modtest.c @@ -1156,12 +1156,12 @@ static void usage(char *progname) { printf ("usage: %s [options] \n\n",progname); printf ("options:\n"); - printf (" --adapter , -a : adapter number of modulator card\n"); - printf (" --mods , -m : number of modulators to use\n"); - printf (" --file, -i : input filename(default test.ts)\n"); - printf (" --frequency, -f : start frequency in MHz( default DVB_C 114MHz, DVB-T 474MHz)\n"); - printf (" --dvbt, -t : modulator is DVB-T\n"); - printf (" --NIT, -n : write a minimal NIT for fatser scan\n"); + printf (" --adapter , -a : adapter number of modulator card (defaults to first found)\n"); + printf (" --mods , -m : number of modulators to use (default all)\n"); + printf (" --file, -i : input filename (default test.ts)\n"); + printf (" --frequency, -f : start frequency in MHz (default DVB_C 114MHz, DVB-T 474MHz)\n"); + printf (" --dvbt, -t : modulator is DVB-T\n"); + printf (" --NIT, -n : write a minimal NIT for faster scan\n"); printf (" --help, -h : print help message\n"); printf ("\n"); printf ("\n"); From efbf312d9802637bd9e9774c94ecefdafee9c4d8 Mon Sep 17 00:00:00 2001 From: internal Date: Tue, 13 Dec 2022 13:31:02 +0100 Subject: [PATCH 03/10] include link and port number in debug message --- ddbridge/ddbridge-core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ddbridge/ddbridge-core.c b/ddbridge/ddbridge-core.c index a8c70c3..b7fa02d 100644 --- a/ddbridge/ddbridge-core.c +++ b/ddbridge/ddbridge-core.c @@ -626,12 +626,14 @@ static void ddb_input_stop_unlocked(struct ddb_input *input) input->dma->running = 0; if (input->dma->stall_count) dev_warn(input->port->dev->dev, - "DMA stalled %u times!\n", + "l%ui%u: DMA stalled %u times!\n", + input->port->lnr, input->nr, input->dma->stall_count); update_loss(input->dma); if (input->dma->packet_loss > 1) dev_warn(input->port->dev->dev, - "%u packets lost due to low DMA performance!\n", + "l%ui%u: %u packets lost due to low DMA performance!\n", + input->port->lnr, input->nr, input->dma->packet_loss); } } From e64ceb90fbf8252e53dd33f8fbe689cba7293dab Mon Sep 17 00:00:00 2001 From: internal Date: Tue, 13 Dec 2022 13:32:03 +0100 Subject: [PATCH 04/10] simplify dummy frontend config --- ddbridge/ddbridge-core.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ddbridge/ddbridge-core.c b/ddbridge/ddbridge-core.c index b7fa02d..3c97f27 100644 --- a/ddbridge/ddbridge-core.c +++ b/ddbridge/ddbridge-core.c @@ -1124,13 +1124,19 @@ static void dummy_release(struct dvb_frontend *fe) kfree(fe); } +static enum dvbfe_algo dummy_algo(struct dvb_frontend *fe) +{ + return DVBFE_ALGO_HW; +} + static struct dvb_frontend_ops dummy_ops = { - .delsys = { SYS_DVBC_ANNEX_A, SYS_DVBS, SYS_DVBS2 }, + .delsys = { SYS_DVBC_ANNEX_A }, .info = { - .name = "DUMMY DVB-C/C2 DVB-T/T2", - .frequency_stepsize_hz = 166667, /* DVB-T only */ - .frequency_min_hz = 47000000, /* DVB-T: 47125000 */ - .frequency_max_hz = 865000000, /* DVB-C: 862000000 */ + .name = "DUMMY DVB-C", + .frequency_stepsize_hz = 0, + .frequency_tolerance_hz = 0, + .frequency_min_hz = 47000000, + .frequency_max_hz = 865000000, .symbol_rate_min = 870000, .symbol_rate_max = 11700000, .caps = FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_32 | @@ -1143,6 +1149,7 @@ static struct dvb_frontend_ops dummy_ops = { FE_CAN_GUARD_INTERVAL_AUTO | FE_CAN_HIERARCHY_AUTO | FE_CAN_RECOVER | FE_CAN_MUTE_TS | FE_CAN_2G_MODULATION }, + .get_frontend_algo = dummy_algo, .release = dummy_release, .read_status = dummy_read_status, }; From 0b36a69c448088ed50b503c9d09ef2d0f8e9295a Mon Sep 17 00:00:00 2001 From: internal Date: Tue, 13 Dec 2022 13:33:09 +0100 Subject: [PATCH 05/10] check if MCI interface present --- ddbridge/ddbridge-mci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ddbridge/ddbridge-mci.c b/ddbridge/ddbridge-mci.c index a37edc5..d2f143c 100644 --- a/ddbridge/ddbridge-mci.c +++ b/ddbridge/ddbridge-mci.c @@ -134,6 +134,8 @@ int ddb_mci_cmd_link(struct ddb_link *link, struct mci_result res; int stat; + if (!link->mci_ok) + return -EFAULT; if (!result) result = &res; mutex_lock(&link->mci_lock); From 6ce49ed99012967fa279c96e9401c8d569f57446 Mon Sep 17 00:00:00 2001 From: internal Date: Tue, 13 Dec 2022 13:33:57 +0100 Subject: [PATCH 06/10] return actual symbol rate for all delivery systems --- ddbridge/ddbridge-mci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddbridge/ddbridge-mci.c b/ddbridge/ddbridge-mci.c index d2f143c..4e96c45 100644 --- a/ddbridge/ddbridge-mci.c +++ b/ddbridge/ddbridge-mci.c @@ -296,6 +296,8 @@ void ddb_mci_proc_info(struct mci *mci, struct dtv_frontend_properties *p) p->frequency = mci->signal_info.dvbs2_signal_info.frequency; + p->symbol_rate = + mci->signal_info.dvbs2_signal_info.symbol_rate; switch (p->delivery_system) { default: case SYS_DVBS: @@ -305,8 +307,6 @@ void ddb_mci_proc_info(struct mci *mci, struct dtv_frontend_properties *p) mci->signal_info.dvbs2_signal_info.pls_code; p->frequency = mci->signal_info.dvbs2_signal_info.frequency / 1000; - p->symbol_rate = - mci->signal_info.dvbs2_signal_info.symbol_rate; p->delivery_system = (mci->signal_info.dvbs2_signal_info.standard == 2) ? SYS_DVBS2 : SYS_DVBS; From ee7c48e6ff5340f2caddadcbe1627ff29d9731bb Mon Sep 17 00:00:00 2001 From: internal Date: Tue, 13 Dec 2022 13:34:22 +0100 Subject: [PATCH 07/10] return actual modulation for DVB-C --- ddbridge/ddbridge-mci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ddbridge/ddbridge-mci.c b/ddbridge/ddbridge-mci.c index 4e96c45..0d093aa 100644 --- a/ddbridge/ddbridge-mci.c +++ b/ddbridge/ddbridge-mci.c @@ -342,6 +342,8 @@ void ddb_mci_proc_info(struct mci *mci, struct dtv_frontend_properties *p) break; } case SYS_DVBC_ANNEX_A: + p->modulation = + mci->signal_info.dvbc_signal_info.constellation + 1; break; case SYS_DVBT: break; From a6565abde31465d8685a708cdded601d4523cac6 Mon Sep 17 00:00:00 2001 From: internal Date: Tue, 13 Dec 2022 13:44:34 +0100 Subject: [PATCH 08/10] emulate old API for latest FSM firmware --- ddbridge/ddbridge-modulator.c | 67 ++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/ddbridge/ddbridge-modulator.c b/ddbridge/ddbridge-modulator.c index 8b6cb1b..d2cabfe 100644 --- a/ddbridge/ddbridge-modulator.c +++ b/ddbridge/ddbridge-modulator.c @@ -195,6 +195,48 @@ static int mod_calc_obitrate(struct ddb_mod *mod) return 0; } +static int mod_set_stream(struct ddb_output *output) +{ + struct ddb *dev = output->port->dev; + u32 stream = output->nr; + struct ddb_mod *mod = &dev->mod[output->nr]; + struct ddb_link *link = &dev->link[0]; + struct mci_result res; + u32 channel; + struct mci_command cmd = { + .mod_command = MOD_SETUP_STREAM, + .mod_channel = stream, + .mod_stream = stream, + .mod_setup_stream = { + .standard = MOD_STANDARD_DVBC_8, + .symbol_rate = mod->symbolrate, + .qam = { + .modulation = mod->modulation - 1, + .rolloff = 13, + } + }, + }; + if (dev->link[0].info->version != 2) + return 0; + if (dev->link[0].ids.revision != 1) + return 0; + if ((dev->link[0].ids.hwid & 0xffffff) < 9065) + return 0; + if (!mod->frequency && !mod->symbolrate && !mod->modulation) + return 0; + + if (mod->frequency) + channel = (mod->frequency - 114000000) / 8000000; + if (!mod->symbolrate) + mod->symbolrate = 6900000; + if (!mod->modulation) + mod->modulation = 5; + cmd.mod_channel = channel; + cmd.mod_setup_stream.symbol_rate = mod->symbolrate; + cmd.mod_setup_stream.qam.modulation = mod->modulation - 1; + return ddb_mci_cmd_link(link, &cmd, &res); +} + static int mod_set_symbolrate(struct ddb_mod *mod, u32 srate) { struct ddb *dev = mod->port->dev; @@ -210,6 +252,7 @@ static int mod_set_symbolrate(struct ddb_mod *mod, u32 srate) } mod->symbolrate = srate; mod_calc_obitrate(mod); + mod_set_stream(mod->port->output); return 0; } @@ -227,6 +270,7 @@ static int mod_set_modulation(struct ddb_mod *mod, ddbwritel(dev, qamtab[modulation], CHANNEL_SETTINGS(mod->port->nr)); mod_calc_obitrate(mod); + mod_set_stream(mod->port->output); return 0; } @@ -241,6 +285,7 @@ static int mod_set_frequency(struct ddb_mod *mod, u32 frequency) if ((freq < 114) || (freq > 874)) return -EINVAL; mod->frequency = frequency; + mod_set_stream(mod->port->output); return 0; } @@ -330,13 +375,19 @@ int ddbridge_mod_output_start(struct ddb_output *output) u32 LF = 9000000UL; u32 d = gcd(KF, LF); u32 checkLF; -#if 0 - if (dev->link[0].ids.revision == 1) { - mod->Control |= CHANNEL_CONTROL_ENABLE_DVB; - return -EINVAL; - break; + + if ((dev->link[0].ids.revision == 1)) { + if ((dev->link[0].info->version == 2)) { + if ((dev->link[0].ids.hwid & 0xffffff) >= 9065) { + mod->Control |= CHANNEL_CONTROL_ENABLE_DVB; + break; + } + } else { + mod->Control |= CHANNEL_CONTROL_ENABLE_DVB; + break; + } } -#endif + ddbwritel(dev, mod->modulation - 1, CHANNEL_SETTINGS(Channel)); ddbwritel(dev, Output, CHANNEL_SETTINGS2(Channel)); @@ -1909,7 +1960,6 @@ int ddbridge_mod_do_ioctl(struct file *file, unsigned int cmd, void *parg) return ret; } -#if 0 static int mod_init_2_1(struct ddb *dev, u32 Frequency) { int i, streams = dev->link[0].info->port_num; @@ -1921,7 +1971,6 @@ static int mod_init_2_1(struct ddb *dev, u32 Frequency) } return 0; } -#endif static int mod_init_2(struct ddb *dev, u32 Frequency) { @@ -2127,6 +2176,8 @@ int ddbridge_mod_init(struct ddb *dev) case 1: return mod_init_1(dev, 722000000); case 2: /* FSM */ + if ((dev->link[0].ids.hwid & 0xffffff) >= 9065) + return mod_init_2_1(dev, 114000000); return mod_init_2(dev, 114000000); case 16: /* PAL */ return mod_init_3(dev, 503250000); From 7e9650c8419d61eea3310902a5c405ccea8009dc Mon Sep 17 00:00:00 2001 From: internal Date: Tue, 13 Dec 2022 13:45:33 +0100 Subject: [PATCH 09/10] add actual frequency and symbol rate to debug output --- lib/src/dvb_quality.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/dvb_quality.c b/lib/src/dvb_quality.c index 5922ca3..53d8a17 100644 --- a/lib/src/dvb_quality.c +++ b/lib/src/dvb_quality.c @@ -329,7 +329,7 @@ static void calc_lq(struct dddvb_fe *fe) { struct dtv_fe_stats st; int64_t str, snr; - uint32_t mod, fec, ber_num, ber_den, trans, pilot = 0, quality = 0, freq; + uint32_t mod, fec, ber_num, ber_den, trans, pilot = 0, quality = 0, freq, rate; get_property(fe->fd, DTV_TRANSMISSION_MODE, &fe->pls_code); dbgprintf(DEBUG_DVB, "fe%d: pls=0x%02x\n", fe->nr, fe->pls_code); @@ -362,15 +362,15 @@ static void calc_lq(struct dddvb_fe *fe) dbgprintf(DEBUG_DVB, "fe%d: snr=%lld ber=%llu/%llu\n", fe->nr, snr, ber_num, ber_den); dbgprintf(DEBUG_DVB, "fe%d: fec=%u mod=%u\n", fe->nr, fec, mod); + get_property(fe->fd, DTV_FREQUENCY, &freq); + dbgprintf(DEBUG_DVB, "fe%d: actual frequency=%u\n", fe->nr, freq); + get_property(fe->fd, DTV_SYMBOL_RATE, &rate); + dbgprintf(DEBUG_DVB, "fe%d: actual symbol rate=%u\n", fe->nr, rate); switch (fe->n_param.param[PARAM_MSYS]) { case SYS_DVBS: - get_property(fe->fd, DTV_FREQUENCY, &freq); - dbgprintf(DEBUG_DVB, "fe%d: actual frequency=%u\n", fe->nr, freq); quality = dvbsq(snr, fec, ber_num, ber_den); break; case SYS_DVBS2: - get_property(fe->fd, DTV_FREQUENCY, &freq); - dbgprintf(DEBUG_DVB, "fe%d: actual frequency=%u\n", fe->nr, freq); quality = dvbs2q(snr, fec, mod, ber_num, ber_den); break; case SYS_DVBC_ANNEX_A: From c008e44bf69bfc7ab633a20a35a94d64e7d0361a Mon Sep 17 00:00:00 2001 From: rjkm Date: Fri, 3 Mar 2023 13:42:12 +0100 Subject: [PATCH 10/10] hardware DVB-T can only do 14 channels --- ddbridge/ddbridge-hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddbridge/ddbridge-hw.c b/ddbridge/ddbridge-hw.c index 37a75a3..eeb95bc 100644 --- a/ddbridge/ddbridge-hw.c +++ b/ddbridge/ddbridge-hw.c @@ -616,7 +616,7 @@ static const struct ddb_info ddb_sdr_dvbt = { .name = "Digital Devices DVBT", .version = 18, .regmap = &octopus_sdr_map, - .port_num = 16, + .port_num = 14, .temp_num = 1, .tempmon_irq = 8, };