mirror of
https://github.com/DigitalDevices/dddvb.git
synced 2025-03-01 10:35:23 +00:00
Support several channel regions. They have to start with frequency now!
This commit is contained in:
@@ -24,12 +24,31 @@ struct mconf {
|
|||||||
int set_output;
|
int set_output;
|
||||||
int set_channels;
|
int set_channels;
|
||||||
int fd;
|
int fd;
|
||||||
|
int chanset;
|
||||||
|
|
||||||
struct mci_command channels;
|
struct mci_command channels;
|
||||||
struct mci_command stream;
|
struct mci_command stream;
|
||||||
struct mci_command output;
|
struct mci_command output;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void dump(uint8_t *b, int l)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for (j = 0; j < l; j += 16, b += 16) {
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
if (i + j < l)
|
||||||
|
printf("%02x ", b[i]);
|
||||||
|
else
|
||||||
|
printf(" ");
|
||||||
|
printf(" | ");
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
if (i + j < l)
|
||||||
|
putchar((b[i] > 31 && b[i] < 127) ? b[i] : '.');
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void strim(char *s)
|
void strim(char *s)
|
||||||
{
|
{
|
||||||
int l = strlen(s);
|
int l = strlen(s);
|
||||||
@@ -39,13 +58,15 @@ void strim(char *s)
|
|||||||
s[l] = 0;
|
s[l] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse(char *fname, char *sec, void *priv, void (*cb)(void *, char *, char *))
|
int parse(char *fname, char *sec, void *priv, void (*cb)(void *, char *, char *))
|
||||||
{
|
{
|
||||||
char line[256], csec[80], par[80], val[80], *p;
|
char line[256], csec[80], par[80], val[80], *p;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if ((f = fopen(fname, "r")) == NULL)
|
if ((f = fopen(fname, "r")) == NULL) {
|
||||||
return;
|
dprintf(2, "Could not open %s\n", fname);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
while ((p = fgets(line, sizeof(line), f))) {
|
while ((p = fgets(line, sizeof(line), f))) {
|
||||||
if (*p == '\r' || *p == '\n' || *p == '#')
|
if (*p == '\r' || *p == '\n' || *p == '#')
|
||||||
continue;
|
continue;
|
||||||
@@ -75,6 +96,7 @@ void parse(char *fname, char *sec, void *priv, void (*cb)(void *, char *, char *
|
|||||||
if (!strcmp(sec, csec) && cb)
|
if (!strcmp(sec, csec) && cb)
|
||||||
cb(priv, NULL, NULL);
|
cb(priv, NULL, NULL);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct param_table_entry {
|
struct param_table_entry {
|
||||||
@@ -249,24 +271,6 @@ int parse_param(char *val, struct param_table_entry *table, int *value) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump(const uint8_t *b, int l)
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
|
|
||||||
for (j = 0; j < l; j += 16, b += 16) {
|
|
||||||
for (i = 0; i < 16; i++)
|
|
||||||
if (i + j < l)
|
|
||||||
printf("%02x ", b[i]);
|
|
||||||
else
|
|
||||||
printf(" ");
|
|
||||||
printf(" | ");
|
|
||||||
for (i = 0; i < 16; i++)
|
|
||||||
if (i + j < l)
|
|
||||||
putchar((b[i] > 31 && b[i] < 127) ? b[i] : '.');
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int mci_cmd(int dev, struct mci_command *cmd)
|
int mci_cmd(int dev, struct mci_command *cmd)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@@ -276,7 +280,7 @@ int mci_cmd(int dev, struct mci_command *cmd)
|
|||||||
memset(&msg, 0, sizeof(msg));
|
memset(&msg, 0, sizeof(msg));
|
||||||
msg.link = 0;
|
msg.link = 0;
|
||||||
memcpy(&msg.cmd, cmd, sizeof(msg.cmd));
|
memcpy(&msg.cmd, cmd, sizeof(msg.cmd));
|
||||||
//dump((const uint8_t *) &msg.cmd, sizeof(msg.cmd));
|
dump((uint8_t *) &msg.cmd, sizeof(msg.cmd));
|
||||||
ret = ioctl(dev, IOCTL_DDB_MCI_CMD, &msg);
|
ret = ioctl(dev, IOCTL_DDB_MCI_CMD, &msg);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dprintf(2, "mci_cmd error %d (%s)\n", errno, strerror(errno));
|
dprintf(2, "mci_cmd error %d (%s)\n", errno, strerror(errno));
|
||||||
@@ -301,7 +305,7 @@ struct mci_command msg_channels = {
|
|||||||
.mod_channel = 0,
|
.mod_channel = 0,
|
||||||
.mod_stream = 0,
|
.mod_stream = 0,
|
||||||
.mod_setup_channels[0] = {
|
.mod_setup_channels[0] = {
|
||||||
.flags = MOD_SETUP_FLAG_FIRST|MOD_SETUP_FLAG_LAST|MOD_SETUP_FLAG_VALID,
|
.flags = 0,
|
||||||
.standard = MOD_STANDARD_DVBT_8,
|
.standard = MOD_STANDARD_DVBT_8,
|
||||||
.num_channels = 25,
|
.num_channels = 25,
|
||||||
.frequency = 474000000,
|
.frequency = 474000000,
|
||||||
@@ -371,23 +375,29 @@ void channels_cb(void *priv, char *par, char *val)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!strcasecmp(par, "frequency")) {
|
if (!strcasecmp(par, "frequency")) {
|
||||||
mc->channels.mod_setup_channels[0].frequency = (uint32_t) (strtod(val, NULL) * 1000000.0);
|
mc->chanset++;
|
||||||
printf("frequency = %u\n", mc->channels.mod_setup_channels[0].frequency);
|
if (mc->chanset > 3)
|
||||||
} else if (!strcasecmp(par, "channels")) {
|
return;
|
||||||
mc->channels.mod_setup_channels[0].num_channels = strtol(val, NULL, 10);
|
mc->channels.mod_setup_channels[mc->chanset].frequency = (uint32_t) (strtod(val, NULL) * 1000000.0);
|
||||||
printf("channels = %u\n", mc->channels.mod_setup_channels[0].num_channels);
|
printf("frequency %u = %u\n", mc->chanset + 1, mc->channels.mod_setup_channels[mc->chanset].frequency);
|
||||||
|
} else
|
||||||
|
if (mc->chanset>=0 && mc->chanset < 4) {
|
||||||
|
if (!strcasecmp(par, "channels")) {
|
||||||
|
mc->channels.mod_setup_channels[mc->chanset].num_channels = strtol(val, NULL, 10);
|
||||||
|
printf("channels = %u\n", mc->channels.mod_setup_channels[mc->chanset].num_channels);
|
||||||
} else if (!strcasecmp(par, "standard")) {
|
} else if (!strcasecmp(par, "standard")) {
|
||||||
if (!parse_param(val,mod_standard_table, &value))
|
if (!parse_param(val,mod_standard_table, &value))
|
||||||
mc->channels.mod_setup_channels[0].standard = value;
|
mc->channels.mod_setup_channels[mc->chanset].standard = value;
|
||||||
printf("standard = %u\n", value);
|
printf("standard = %u\n", value);
|
||||||
} else if (!strcasecmp(par, "offset")) {
|
} else if (!strcasecmp(par, "offset")) {
|
||||||
mc->channels.mod_setup_channels[0].offset = (uint32_t) (strtod(val, NULL) * 1000000.0);
|
mc->channels.mod_setup_channels[mc->chanset].offset = (uint32_t) (strtod(val, NULL) * 1000000.0);
|
||||||
} else if (!strcasecmp(par, "bandwidth")) {
|
} else if (!strcasecmp(par, "bandwidth")) {
|
||||||
mc->channels.mod_setup_channels[0].bandwidth = (uint32_t) (strtod(val, NULL) * 1000000.0);
|
mc->channels.mod_setup_channels[mc->chanset].bandwidth = (uint32_t) (strtod(val, NULL) * 1000000.0);
|
||||||
mc->channels.mod_setup_channels[0].offset =
|
mc->channels.mod_setup_channels[mc->chanset].offset =
|
||||||
mc->channels.mod_setup_channels[0].bandwidth / 2;
|
mc->channels.mod_setup_channels[mc->chanset].bandwidth / 2;
|
||||||
} else
|
} else
|
||||||
printf("invalid channels parameter: %s\n", par);
|
printf("invalid channels parameter: %s\n", par);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void streams_cb(void *priv, char *par, char *val)
|
void streams_cb(void *priv, char *par, char *val)
|
||||||
@@ -462,7 +472,7 @@ int mci_lic(int dev)
|
|||||||
printf("MATYPE1: %02x\n", res->bb_header.matype_1);
|
printf("MATYPE1: %02x\n", res->bb_header.matype_1);
|
||||||
printf("MATYPE2: %02x\n", res->bb_header.matype_2);
|
printf("MATYPE2: %02x\n", res->bb_header.matype_2);
|
||||||
}
|
}
|
||||||
dump((const uint8_t *)&res->license, sizeof(res->license));
|
//dump((const uint8_t *)&res->license, sizeof(res->license));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,7 +481,6 @@ int main(int argc, char*argv[])
|
|||||||
int fd = -1;
|
int fd = -1;
|
||||||
char fn[128];
|
char fn[128];
|
||||||
uint32_t device = 0;
|
uint32_t device = 0;
|
||||||
uint32_t frequency = 0;
|
|
||||||
char *configname = "modulator.conf";
|
char *configname = "modulator.conf";
|
||||||
struct mconf mc;
|
struct mconf mc;
|
||||||
|
|
||||||
@@ -479,7 +488,8 @@ int main(int argc, char*argv[])
|
|||||||
mc.channels = msg_channels;
|
mc.channels = msg_channels;
|
||||||
mc.stream = msg_stream;
|
mc.stream = msg_stream;
|
||||||
mc.output = msg_output;
|
mc.output = msg_output;
|
||||||
|
mc.chanset = -1;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int cur_optind = optind ? optind : 1;
|
int cur_optind = optind ? optind : 1;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
@@ -521,9 +531,14 @@ int main(int argc, char*argv[])
|
|||||||
}
|
}
|
||||||
//mci_lic(fd);
|
//mci_lic(fd);
|
||||||
mc.fd = fd;
|
mc.fd = fd;
|
||||||
parse(configname, "channels", (void *) &mc, channels_cb);
|
if (parse(configname, "channels", (void *) &mc, channels_cb))
|
||||||
|
exit(-1);
|
||||||
if (mc.set_channels) {
|
if (mc.set_channels) {
|
||||||
printf("setting channels.\n");
|
for (int i = 0; i <= mc.chanset; i++)
|
||||||
|
mc.channels.mod_setup_channels[i].flags = MOD_SETUP_FLAG_VALID;
|
||||||
|
mc.channels.mod_setup_channels[0].flags |= MOD_SETUP_FLAG_FIRST;
|
||||||
|
mc.channels.mod_setup_channels[mc.chanset].flags |= MOD_SETUP_FLAG_LAST;
|
||||||
|
printf("setting channels, %u groups.\n", mc.chanset + 1);
|
||||||
mci_cmd(fd, &mc.channels);
|
mci_cmd(fd, &mc.channels);
|
||||||
}
|
}
|
||||||
parse(configname, "streams", (void *) &mc, streams_cb);
|
parse(configname, "streams", (void *) &mc, streams_cb);
|
||||||
|
Reference in New Issue
Block a user