diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/debug_menu.c | 132 |
1 files changed, 130 insertions, 2 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index cb6ad07c4a..663ea7bdf4 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -54,6 +54,9 @@ | |||
54 | #ifdef CONFIG_TUNER | 54 | #ifdef CONFIG_TUNER |
55 | #include "radio.h" | 55 | #include "radio.h" |
56 | #endif | 56 | #endif |
57 | #ifdef HAVE_MMC | ||
58 | #include "ata_mmc.h" | ||
59 | #endif | ||
57 | 60 | ||
58 | /*---------------------------------------------------*/ | 61 | /*---------------------------------------------------*/ |
59 | /* SPECIAL DEBUG STUFF */ | 62 | /* SPECIAL DEBUG STUFF */ |
@@ -1260,9 +1263,134 @@ static bool view_runtime(void) | |||
1260 | } | 1263 | } |
1261 | 1264 | ||
1262 | #ifdef HAVE_MMC | 1265 | #ifdef HAVE_MMC |
1263 | static bool dbg_mmc_info(void) | 1266 | /* value is 10 * real value */ |
1267 | static unsigned char prep_value_unit(unsigned int *value, | ||
1268 | const unsigned char *units) | ||
1269 | { | ||
1270 | int unit_no = 0; | ||
1271 | |||
1272 | while (*value >= 10000) | ||
1273 | { | ||
1274 | *value /= 1000; | ||
1275 | unit_no++; | ||
1276 | } | ||
1277 | return units[unit_no]; | ||
1278 | } | ||
1279 | |||
1280 | bool dbg_mmc_info(void) | ||
1264 | { | 1281 | { |
1265 | splash(HZ, true, "To be implemented."); | 1282 | bool done = false; |
1283 | int currval = 0; | ||
1284 | unsigned int value; | ||
1285 | tCardInfo *card; | ||
1286 | unsigned char pbuf[32]; | ||
1287 | unsigned char card_name[7]; | ||
1288 | unsigned char unit; | ||
1289 | |||
1290 | static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 }; | ||
1291 | static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 }; | ||
1292 | |||
1293 | card_name[6] = '\0'; | ||
1294 | |||
1295 | lcd_setmargins(0, 0); | ||
1296 | lcd_setfont(FONT_SYSFIXED); | ||
1297 | |||
1298 | while (!done) | ||
1299 | { | ||
1300 | card = mmc_card_info(currval / 2); | ||
1301 | |||
1302 | lcd_clear_display(); | ||
1303 | snprintf(pbuf, sizeof(pbuf), "[MMC%d p%d]", currval / 2, | ||
1304 | (currval % 2) + 1); | ||
1305 | lcd_puts(0, 0, pbuf); | ||
1306 | |||
1307 | if (card->initialized) | ||
1308 | { | ||
1309 | if (!(currval % 2)) /* General info */ | ||
1310 | { | ||
1311 | strncpy(card_name, ((unsigned char*)card->cid) + 3, 6); | ||
1312 | snprintf(pbuf, sizeof(pbuf), "%s Rev %d.%d", card_name, | ||
1313 | mmc_extract_bits(card->cid, 72, 4), | ||
1314 | mmc_extract_bits(card->cid, 76, 4)); | ||
1315 | lcd_puts(0, 1, pbuf); | ||
1316 | snprintf(pbuf, sizeof(pbuf), "Prod: %d/%d", | ||
1317 | mmc_extract_bits(card->cid, 112, 4), | ||
1318 | mmc_extract_bits(card->cid, 116, 4) + 1997); | ||
1319 | lcd_puts(0, 2, pbuf); | ||
1320 | snprintf(pbuf, sizeof(pbuf), "Ser#: 0x%08x", | ||
1321 | mmc_extract_bits(card->cid, 80, 32)); | ||
1322 | lcd_puts(0, 3, pbuf); | ||
1323 | snprintf(pbuf, sizeof(pbuf), "M=%02x, O=%04x", | ||
1324 | mmc_extract_bits(card->cid, 0, 8), | ||
1325 | mmc_extract_bits(card->cid, 8, 16)); | ||
1326 | lcd_puts(0, 4, pbuf); | ||
1327 | value = mmc_extract_bits(card->csd, 54, 12) | ||
1328 | * (SECTOR_SIZE << (mmc_extract_bits(card->csd, 78, 3)+2)); | ||
1329 | snprintf(pbuf, sizeof(pbuf), "Size: %d MB", | ||
1330 | value / (1024*1024)); | ||
1331 | lcd_puts(0, 5, pbuf); | ||
1332 | } | ||
1333 | else /* Technical details */ | ||
1334 | { | ||
1335 | value = card->speed / 100; | ||
1336 | unit = prep_value_unit(&value, "kMG"); | ||
1337 | if (value < 100) | ||
1338 | snprintf(pbuf, sizeof(pbuf), "Speed: %d.%01d %cBit/s", | ||
1339 | value / 10, value % 10, unit); | ||
1340 | else | ||
1341 | snprintf(pbuf, sizeof(pbuf), "Tsac: %d %cBit/s", | ||
1342 | value / 10, unit); | ||
1343 | lcd_puts(0, 1, pbuf); | ||
1344 | |||
1345 | value = card->tsac; | ||
1346 | unit = prep_value_unit(&value, "nµm"); | ||
1347 | if (value < 100) | ||
1348 | snprintf(pbuf, sizeof(pbuf), "Tsac: %d.%01d %cs", | ||
1349 | value / 10, value % 10, unit); | ||
1350 | else | ||
1351 | snprintf(pbuf, sizeof(pbuf), "Tsac: %d %cs", | ||
1352 | value / 10, unit); | ||
1353 | lcd_puts(0, 1, pbuf); | ||
1354 | |||
1355 | snprintf(pbuf, sizeof(pbuf), "Nsac: %d clk", card->nsac); | ||
1356 | lcd_puts(0, 2, pbuf); | ||
1357 | snprintf(pbuf, sizeof(pbuf), "R2W: *%d", card->r2w_factor); | ||
1358 | lcd_puts(0, 3, pbuf); | ||
1359 | snprintf(pbuf, sizeof(pbuf), "IRmax: %d..%d mA", | ||
1360 | i_vmin[mmc_extract_bits(card->csd, 66, 3)], | ||
1361 | i_vmax[mmc_extract_bits(card->csd, 69, 3)]); | ||
1362 | lcd_puts(0, 4, pbuf); | ||
1363 | snprintf(pbuf, sizeof(pbuf), "IWmax: %d..%d mA", | ||
1364 | i_vmin[mmc_extract_bits(card->csd, 72, 3)], | ||
1365 | i_vmax[mmc_extract_bits(card->csd, 75, 3)]); | ||
1366 | lcd_puts(0, 5, pbuf); | ||
1367 | } | ||
1368 | } | ||
1369 | else | ||
1370 | lcd_puts(0, 1, "Not found!"); | ||
1371 | |||
1372 | lcd_update(); | ||
1373 | |||
1374 | switch (button_get(true)) | ||
1375 | { | ||
1376 | case SETTINGS_OK: | ||
1377 | case SETTINGS_CANCEL: | ||
1378 | done = true; | ||
1379 | break; | ||
1380 | |||
1381 | case SETTINGS_DEC: | ||
1382 | currval--; | ||
1383 | if (currval < 0) | ||
1384 | currval = 3; | ||
1385 | break; | ||
1386 | |||
1387 | case SETTINGS_INC: | ||
1388 | currval++; | ||
1389 | if (currval > 3) | ||
1390 | currval = 0; | ||
1391 | break; | ||
1392 | } | ||
1393 | } | ||
1266 | 1394 | ||
1267 | return false; | 1395 | return false; |
1268 | } | 1396 | } |