1
0
mirror of https://github.com/DigitalDevices/dddvb.git synced 2023-10-10 13:37:43 +02:00

- initialize modulators before registering devices to prevent races

- check for number of FSM modulator channels before allocating ports
This commit is contained in:
Ralph Metzler 2017-09-09 00:21:11 +02:00
parent fe5f6b737c
commit 983949f4dd
3 changed files with 24 additions and 11 deletions

View File

@ -4358,10 +4358,20 @@ int ddb_init(struct ddb *dev)
ddb_gtl_init(dev); ddb_gtl_init(dev);
ddb_init_boards(dev); ddb_init_boards(dev);
if (dev->link[0].info->type == DDB_MOD &&
dev->link[0].info->version == 2) {
int ret = ddb_mod_fsm_setup(dev, 0);
if (ret < 0) {
dev_err(dev->dev, "FSM setup failed!\n");
return ret;
}
}
if (ddb_i2c_init(dev) < 0) if (ddb_i2c_init(dev) < 0)
goto fail; goto fail;
ddb_ports_init(dev); ddb_ports_init(dev);
if (dev->link[0].info->type == DDB_MOD)
ddbridge_mod_init(dev);
if (ddb_buffers_alloc(dev) < 0) { if (ddb_buffers_alloc(dev) < 0) {
dev_info(dev->dev, dev_info(dev->dev,
"Could not allocate buffer memory\n"); "Could not allocate buffer memory\n");
@ -4377,8 +4387,6 @@ int ddb_init(struct ddb *dev)
ddbwritel(dev, 1, GPIO_DIRECTION); ddbwritel(dev, 1, GPIO_DIRECTION);
ddbwritel(dev, 1, GPIO_OUTPUT); ddbwritel(dev, 1, GPIO_OUTPUT);
} }
if (dev->link[0].info->type == DDB_MOD)
ddbridge_mod_init(dev);
return 0; return 0;
fail3: fail3:

View File

@ -468,8 +468,7 @@ static int mod_setup_max2871(struct ddb *dev, u32 *reg)
return status; return status;
} }
static int mod_fsm_setup(struct ddb *dev, u32 FrequencyPlan, int ddb_mod_fsm_setup(struct ddb *dev, u32 MaxUsedChannels)
u32 MaxUsedChannels)
{ {
int status = 0; int status = 0;
u32 Capacity; u32 Capacity;
@ -1630,16 +1629,17 @@ out:
static int mod_init_2(struct ddb *dev, u32 Frequency) static int mod_init_2(struct ddb *dev, u32 Frequency)
{ {
int status, i; int i, streams = dev->link[0].info->port_num;
int streams = dev->link[0].info->port_num;
dev->mod_base.frequency = Frequency; dev->mod_base.frequency = Frequency;
status = mod_fsm_setup(dev, 0, 0);
#if 0
status = mod_fsm_setup(dev, 0);
if (status) { if (status) {
dev_err(dev->dev, "FSM setup failed!\n"); dev_err(dev->dev, "FSM setup failed!\n");
return -1; return -1;
} }
#endif
for (i = 0; i < streams; i++) { for (i = 0; i < streams; i++) {
struct ddb_mod *mod = &dev->mod[i]; struct ddb_mod *mod = &dev->mod[i];
@ -1790,11 +1790,15 @@ static int mod_init_3(struct ddb *dev, u32 Frequency)
int ddbridge_mod_init(struct ddb *dev) int ddbridge_mod_init(struct ddb *dev)
{ {
if (dev->link[0].info->version <= 1) switch (dev->link[0].info->version) {
case 0:
case 1:
return mod_init_1(dev, 722000000); return mod_init_1(dev, 722000000);
if (dev->link[0].info->version == 2) case 2:
return mod_init_2(dev, 114000000); return mod_init_2(dev, 114000000);
if (dev->link[0].info->version == 3) case 3:
return mod_init_3(dev, 503250000); return mod_init_3(dev, 503250000);
return -1; default:
return -1;
}
} }

View File

@ -545,6 +545,7 @@ int ddbridge_mod_init(struct ddb *dev);
void ddbridge_mod_output_stop(struct ddb_output *output); void ddbridge_mod_output_stop(struct ddb_output *output);
int ddbridge_mod_output_start(struct ddb_output *output); int ddbridge_mod_output_start(struct ddb_output *output);
void ddbridge_mod_rate_handler(unsigned long data); void ddbridge_mod_rate_handler(unsigned long data);
int ddb_mod_fsm_setup(struct ddb *dev, u32 MaxUsedChannels);
void ddb_device_destroy(struct ddb *dev); void ddb_device_destroy(struct ddb *dev);
void ddb_nsd_detach(struct ddb *dev); void ddb_nsd_detach(struct ddb *dev);