aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2013-03-19 08:50:17 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-21 06:52:37 -0400
commit5ac14b60118071631bb0e2e50527c7528675648c (patch)
tree1a7fd9a4c7e1f608343e4fb9460626141f76ed3c
parent6a28bd94f4d068b6de65517e52f52b6840603d0a (diff)
[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: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/common/siano/smscoreapi.c91
1 files changed, 54 insertions, 37 deletions
diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c
index 8c576a6e3829..9b2f2b42bfbb 100644
--- a/drivers/media/common/siano/smscoreapi.c
+++ b/drivers/media/common/siano/smscoreapi.c
@@ -1063,9 +1063,11 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
1063 const struct firmware *fw; 1063 const struct firmware *fw;
1064 1064
1065 char *fw_filename = smscore_get_fw_filename(coredev, mode, lookup); 1065 char *fw_filename = smscore_get_fw_filename(coredev, mode, lookup);
1066 sms_debug("Firmware name: %s\n", fw_filename); 1066 if (!fw_filename) {
1067 if (!strcmp(fw_filename, "none")) 1067 sms_info("mode %d not supported on this device", mode);
1068 return -ENOENT; 1068 return -ENOENT;
1069 }
1070 sms_debug("Firmware name: %s", fw_filename);
1069 1071
1070 if (loadfirmware_handler == NULL && !(coredev->device_flags 1072 if (loadfirmware_handler == NULL && !(coredev->device_flags
1071 & SMS_DEVICE_FAMILY2)) 1073 & SMS_DEVICE_FAMILY2))
@@ -1198,32 +1200,53 @@ static int smscore_detect_mode(struct smscore_device_t *coredev)
1198 return rc; 1200 return rc;
1199} 1201}
1200 1202
1201static char *smscore_fw_lkup[][SMS_NUM_OF_DEVICE_TYPES] = { 1203static char *smscore_fw_lkup[][DEVICE_MODE_MAX] = {
1202 /*Stellar, NOVA A0, Nova B0, VEGA, VENICE, MING, PELE, RIO, DENVER_1530, DENVER_2160 */ 1204 [SMS_NOVA_A0] = {
1203 /*DVBT*/ 1205 [DEVICE_MODE_DVBT] = "dvb_nova_12mhz.inp",
1204 { "none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none", "none", "none", "none", "dvb_rio.inp", "none", "none" }, 1206 [DEVICE_MODE_DVBH] = "dvb_nova_12mhz.inp",
1205 /*DVBH*/ 1207 [DEVICE_MODE_DAB_TDMB] = "tdmb_nova_12mhz.inp",
1206 { "none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none", "none", "none", "none", "dvbh_rio.inp", "none", "none" }, 1208 [DEVICE_MODE_DVBT_BDA] = "dvb_nova_12mhz.inp",
1207 /*TDMB*/ 1209 [DEVICE_MODE_ISDBT] = "isdbt_nova_12mhz.inp",
1208 { "none", "tdmb_nova_12mhz.inp", "tdmb_nova_12mhz_b0.inp", "none", "none", "none", "none", "none", "none", "tdmb_denver.inp" }, 1210 [DEVICE_MODE_ISDBT_BDA] = "isdbt_nova_12mhz.inp",
1209 /*DABIP*/ 1211 },
1210 { "none", "none", "none", "none", "none", "none", "none", "none", "none", "none" }, 1212 [SMS_NOVA_B0] = {
1211 /*DVBT_BDA*/ 1213 [DEVICE_MODE_DVBT] = "dvb_nova_12mhz_b0.inp",
1212 { "none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none", "none", "none", "none", "dvb_rio.inp", "none", "none" }, 1214 [DEVICE_MODE_DVBH] = "dvb_nova_12mhz_b0.inp",
1213 /*ISDBT*/ 1215 [DEVICE_MODE_DAB_TDMB] = "tdmb_nova_12mhz_b0.inp",
1214 { "none", "isdbt_nova_12mhz.inp", "isdbt_nova_12mhz_b0.inp", "none", "none", "none", "isdbt_pele.inp", "isdbt_rio.inp", "none", "none" }, 1216 [DEVICE_MODE_DVBT_BDA] = "dvb_nova_12mhz_b0.inp",
1215 /*ISDBT_BDA*/ 1217 [DEVICE_MODE_ISDBT] = "isdbt_nova_12mhz_b0.inp",
1216 { "none", "isdbt_nova_12mhz.inp", "isdbt_nova_12mhz_b0.inp", "none", "none", "none", "isdbt_pele.inp", "isdbt_rio.inp", "none", "none" }, 1218 [DEVICE_MODE_ISDBT_BDA] = "isdbt_nova_12mhz_b0.inp",
1217 /*CMMB*/ 1219 [DEVICE_MODE_FM_RADIO] = "fm_radio.inp",
1218 { "none", "none", "none", "cmmb_vega_12mhz.inp", "cmmb_venice_12mhz.inp", "cmmb_ming_app.inp", "none", "none", "none", "none" }, 1220 [DEVICE_MODE_FM_RADIO_BDA] = "fm_radio.inp",
1219 /*RAW - not supported*/ 1221 },
1220 { "none", "none", "none", "none", "none", "none", "none", "none", "none", "none" }, 1222 [SMS_VEGA] = {
1221 /*FM*/ 1223 [DEVICE_MODE_CMMB] = "cmmb_vega_12mhz.inp",
1222 { "none", "none", "fm_radio.inp", "none", "none", "none", "none", "fm_radio_rio.inp", "none", "none" }, 1224 },
1223 /*FM_BDA*/ 1225 [SMS_VENICE] = {
1224 { "none", "none", "fm_radio.inp", "none", "none", "none", "none", "fm_radio_rio.inp", "none", "none" }, 1226 [DEVICE_MODE_CMMB] = "cmmb_venice_12mhz.inp",
1225 /*ATSC*/ 1227 },
1226 { "none", "none", "none", "none", "none", "none", "none", "none", "atsc_denver.inp", "none" } 1228 [SMS_MING] = {
1229 [DEVICE_MODE_CMMB] = "cmmb_ming_app.inp",
1230 },
1231 [SMS_PELE] = {
1232 [DEVICE_MODE_ISDBT] = "isdbt_pele.inp",
1233 [DEVICE_MODE_ISDBT_BDA] = "isdbt_pele.inp",
1234 },
1235 [SMS_RIO] = {
1236 [DEVICE_MODE_DVBT] = "dvb_rio.inp",
1237 [DEVICE_MODE_DVBH] = "dvbh_rio.inp",
1238 [DEVICE_MODE_DVBT_BDA] = "dvb_rio.inp",
1239 [DEVICE_MODE_ISDBT] = "isdbt_rio.inp",
1240 [DEVICE_MODE_ISDBT_BDA] = "isdbt_rio.inp",
1241 [DEVICE_MODE_FM_RADIO] = "fm_radio_rio.inp",
1242 [DEVICE_MODE_FM_RADIO_BDA] = "fm_radio_rio.inp",
1243 },
1244 [SMS_DENVER_1530] = {
1245 [DEVICE_MODE_ATSC] = "atsc_denver.inp",
1246 },
1247 [SMS_DENVER_2160] = {
1248 [DEVICE_MODE_DAB_TDMB] = "tdmb_denver.inp",
1249 },
1227}; 1250};
1228 1251
1229/** 1252/**
@@ -1249,22 +1272,16 @@ static char *smscore_get_fw_filename(struct smscore_device_t *coredev,
1249 if ((board_id == SMS_BOARD_UNKNOWN) || (lookup == 1)) { 1272 if ((board_id == SMS_BOARD_UNKNOWN) || (lookup == 1)) {
1250 sms_debug("trying to get fw name from lookup table mode %d type %d", 1273 sms_debug("trying to get fw name from lookup table mode %d type %d",
1251 mode, type); 1274 mode, type);
1252 return smscore_fw_lkup[mode][type]; 1275 return smscore_fw_lkup[type][mode];
1253 } 1276 }
1254 1277
1255 sms_debug("trying to get fw name from sms_boards board_id %d mode %d", 1278 sms_debug("trying to get fw name from sms_boards board_id %d mode %d",
1256 board_id, mode); 1279 board_id, mode);
1257 fw = sms_get_board(board_id)->fw; 1280 fw = sms_get_board(board_id)->fw;
1258 if (fw == NULL) { 1281 if (!fw || !fw[mode]) {
1259 sms_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d",
1260 mode, type);
1261 return smscore_fw_lkup[mode][type];
1262 }
1263
1264 if (fw[mode] == NULL) {
1265 sms_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d", 1282 sms_debug("cannot find fw name in sms_boards, getting from lookup table mode %d type %d",
1266 mode, type); 1283 mode, type);
1267 return smscore_fw_lkup[mode][type]; 1284 return smscore_fw_lkup[type][mode];
1268 } 1285 }
1269 1286
1270 return fw[mode]; 1287 return fw[mode];