Commit 5ac14b60 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] siano: simplify firmware lookup logic

There are two ways to specify firmware for siano devices: a
per-device ID and a per-device type.
The per-device type logic is currently made by a 11x9 string
table, sparsely filled. It is very hard to read the table at
the source code, as there are too much "none" filling there
("none" there is a way to tell NULL).
Instead of using such problematic table, convert it into an
easy to read table, where the unused values will be defaulted
to NULL.
While here, also simplifies a little bit the logic and print
a message if an user-selected mode doesn't exist.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 6a28bd94
...@@ -1063,9 +1063,11 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, ...@@ -1063,9 +1063,11 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
const struct firmware *fw; const struct firmware *fw;
char *fw_filename = smscore_get_fw_filename(coredev, mode, lookup); char *fw_filename = smscore_get_fw_filename(coredev, mode, lookup);
sms_debug("Firmware name: %s\n", fw_filename); if (!fw_filename) {
if (!strcmp(fw_filename, "none")) sms_info("mode %d not supported on this device", mode);
return -ENOENT; return -ENOENT;
}
sms_debug("Firmware name: %s", fw_filename);
if (loadfirmware_handler == NULL && !(coredev->device_flags if (loadfirmware_handler == NULL && !(coredev->device_flags
& SMS_DEVICE_FAMILY2)) & SMS_DEVICE_FAMILY2))
...@@ -1198,32 +1200,53 @@ static int smscore_detect_mode(struct smscore_device_t *coredev) ...@@ -1198,32 +1200,53 @@ static int smscore_detect_mode(struct smscore_device_t *coredev)
return rc; return rc;
} }
static char *smscore_fw_lkup[][SMS_NUM_OF_DEVICE_TYPES] = { static char *smscore_fw_lkup[][DEVICE_MODE_MAX] = {
/*Stellar, NOVA A0, Nova B0, VEGA, VENICE, MING, PELE, RIO, DENVER_1530, DENVER_2160 */ [SMS_NOVA_A0] = {
/*DVBT*/ [DEVICE_MODE_DVBT] = "dvb_nova_12mhz.inp",
{ "none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none", "none", "none", "none", "dvb_rio.inp", "none", "none" }, [DEVICE_MODE_DVBH] = "dvb_nova_12mhz.inp",
/*DVBH*/ [DEVICE_MODE_DAB_TDMB] = "tdmb_nova_12mhz.inp",
{ "none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none", "none", "none", "none", "dvbh_rio.inp", "none", "none" }, [DEVICE_MODE_DVBT_BDA] = "dvb_nova_12mhz.inp",
/*TDMB*/ [DEVICE_MODE_ISDBT] = "isdbt_nova_12mhz.inp",
{ "none", "tdmb_nova_12mhz.inp", "tdmb_nova_12mhz_b0.inp", "none", "none", "none", "none", "none", "none", "tdmb_denver.inp" }, [DEVICE_MODE_ISDBT_BDA] = "isdbt_nova_12mhz.inp",
/*DABIP*/ },
{ "none", "none", "none", "none", "none", "none", "none", "none", "none", "none" }, [SMS_NOVA_B0] = {
/*DVBT_BDA*/ [DEVICE_MODE_DVBT] = "dvb_nova_12mhz_b0.inp",
{ "none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none", "none", "none", "none", "dvb_rio.inp", "none", "none" }, [DEVICE_MODE_DVBH] = "dvb_nova_12mhz_b0.inp",
/*ISDBT*/ [DEVICE_MODE_DAB_TDMB] = "tdmb_nova_12mhz_b0.inp",
{ "none", "isdbt_nova_12mhz.inp", "isdbt_nova_12mhz_b0.inp", "none", "none", "none", "isdbt_pele.inp", "isdbt_rio.inp", "none", "none" }, [DEVICE_MODE_DVBT_BDA] = "dvb_nova_12mhz_b0.inp",
/*ISDBT_BDA*/ [DEVICE_MODE_ISDBT] = "isdbt_nova_12mhz_b0.inp",
{ "none", "isdbt_nova_12mhz.inp", "isdbt_nova_12mhz_b0.inp", "none", "none", "none", "isdbt_pele.inp", "isdbt_rio.inp", "none", "none" }, [DEVICE_MODE_ISDBT_BDA] = "isdbt_nova_12mhz_b0.inp",
/*CMMB*/ [DEVICE_MODE_FM_RADIO] = "fm_radio.inp",
{ "none", "none", "none", "cmmb_vega_12mhz.inp", "cmmb_venice_12mhz.inp", "cmmb_ming_app.inp", "none", "none", "none", "none" }, [DEVICE_MODE_FM_RADIO_BDA] = "fm_radio.inp",
/*RAW - not supported*/ },
{ "none", "none", "none", "none", "none", "none", "none", "none", "none", "none" }, [SMS_VEGA] = {
/*FM*/ [DEVICE_MODE_CMMB] = "cmmb_vega_12mhz.inp",
{ "none", "none", "fm_radio.inp", "none", "none", "none", "none", "fm_radio_rio.inp", "none", "none" }, },
/*FM_BDA*/ [SMS_VENICE] = {
{ "none", "none", "fm_radio.inp", "none", "none", "none", "none", "fm_radio_rio.inp", "none", "none" }, [DEVICE_MODE_CMMB] = "cmmb_venice_12mhz.inp",
/*ATSC*/ },
{ "none", "none", "none", "none", "none", "none", "none", "none", "atsc_denver.inp", "none" } [SMS_MING] = {
[DEVICE_MODE_CMMB] = "cmmb_ming_app.inp",
},
[SMS_PELE] = {
[DEVICE_MODE_ISDBT] = "isdbt_pele.inp",
[DEVICE_MODE_ISDBT_BDA] = "isdbt_pele.inp",
},
[SMS_RIO] = {
[DEVICE_MODE_DVBT] = "dvb_rio.inp",
[DEVICE_MODE_DVBH] = "dvbh_rio.inp",
[DEVICE_MODE_DVBT_BDA] = "dvb_rio.inp",
[DEVICE_MODE_ISDBT] = "isdbt_rio.inp",
[DEVICE_MODE_ISDBT_BDA] = "isdbt_rio.inp",
[DEVICE_MODE_FM_RADIO] = "fm_radio_rio.inp",
[DEVICE_MODE_FM_RADIO_BDA] = "fm_radio_rio.inp",
},
[SMS_DENVER_1530] = {
[DEVICE_MODE_ATSC] = "atsc_denver.inp",
},
[SMS_DENVER_2160] = {
[DEVICE_MODE_DAB_TDMB] = "tdmb_denver.inp",
},
}; };
/** /**
...@@ -1249,22 +1272,16 @@ static char *smscore_get_fw_filename(struct smscore_device_t *coredev, ...@@ -1249,22 +1272,16 @@ static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
if ((board_id == SMS_BOARD_UNKNOWN) || (lookup == 1)) { if ((board_id == SMS_BOARD_UNKNOWN) || (lookup == 1)) {
sms_debug("trying to get fw name from lookup table mode %d type %d", sms_debug("trying to get fw name from lookup table mode %d type %d",
mode, type); mode, type);
return smscore_fw_lkup[mode][type]; return smscore_fw_lkup[type][mode];
} }
sms_debug("trying to get fw name from sms_boards board_id %d mode %d", sms_debug("trying to get fw name from sms_boards board_id %d mode %d",
board_id, mode); board_id, mode);
fw = sms_get_board(board_id)->fw; fw = sms_get_board(board_id)->fw;
if (fw == NULL) { if (!fw || !fw[mode]) {
sms_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d",
mode, type);
return smscore_fw_lkup[mode][type];
}
if (fw[mode] == NULL) {
sms_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d", sms_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d",
mode, type); mode, type);
return smscore_fw_lkup[mode][type]; return smscore_fw_lkup[type][mode];
} }
return fw[mode]; return fw[mode];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment