lin
2025-01-10 9ec4e21f2f615ef95b70a249569906799e36bace
longan/brandy/brandy-2.0/u-boot-2018/drivers/video/sunxi/disp2/disp/dev_disp.c
....@@ -11,7 +11,7 @@
1111 */
1212
1313 #include "dev_disp.h"
14
-
14
+#include "de/disp_display.h"
1515 disp_drv_info g_disp_drv;
1616
1717 #define MY_BYTE_ALIGN(x) ( ( (x + (4*1024-1)) >> 12) << 12) /* alloc based on 4K byte */
....@@ -1312,6 +1312,175 @@
13121312 return ret;
13131313 }
13141314
1315
+s32 bsp_disp_get_fps(u32 disp)
1316
+{
1317
+ u32 pre_time_index, cur_time_index;
1318
+ u32 pre_time, cur_time;
1319
+ u32 fps = 0xff;
1320
+
1321
+ pre_time_index = gdisp.screen[disp].health_info.sync_time_index;
1322
+ cur_time_index = (pre_time_index == 0) ? (DEBUG_TIME_SIZE - 1) : (pre_time_index - 1);
1323
+
1324
+ pre_time = gdisp.screen[disp].health_info.sync_time[pre_time_index];
1325
+ cur_time = gdisp.screen[disp].health_info.sync_time[cur_time_index];
1326
+
1327
+ if (pre_time != cur_time) {
1328
+ fps = 10000 * DEBUG_TIME_SIZE / (cur_time - pre_time);
1329
+ }
1330
+
1331
+ return fps;
1332
+}
1333
+
1334
+
1335
+s32 bsp_disp_get_health_info(u32 disp, disp_health_info *info)
1336
+{
1337
+ if (info)
1338
+ memcpy(info, &gdisp.screen[disp].health_info, sizeof(disp_health_info));
1339
+ return 0;
1340
+}
1341
+
1342
+int do_sunxi_disp_sys(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
1343
+{
1344
+#define SYS_BUF_SIZE 5120
1345
+ struct disp_manager *mgr = NULL;
1346
+ struct disp_device *dispdev = NULL;
1347
+ ssize_t count = 0;
1348
+ int num_screens, screen_id;
1349
+ int num_layers, layer_id;
1350
+ int num_chans, chan_id;
1351
+ char *buf = NULL;
1352
+#if defined(CONFIG_DISP2_LCD_ESD_DETECT)
1353
+ struct disp_lcd_esd_info esd_inf;
1354
+
1355
+ memset(&esd_inf, 0, sizeof(struct disp_lcd_esd_info));
1356
+#endif
1357
+ /* int hpd; */
1358
+
1359
+ buf = kmalloc(SYS_BUF_SIZE, GFP_KERNEL | __GFP_ZERO);
1360
+ num_screens = bsp_disp_feat_get_num_screens();
1361
+ for (screen_id = 0; screen_id < num_screens; screen_id++) {
1362
+ u32 width = 0, height = 0;
1363
+ int fps = 0;
1364
+ disp_health_info info;
1365
+
1366
+ mgr = disp_get_layer_manager(screen_id);
1367
+ if (mgr == NULL)
1368
+ continue;
1369
+ dispdev = mgr->device;
1370
+ if (dispdev == NULL)
1371
+ continue;
1372
+ dispdev->get_resolution(dispdev, &width, &height);
1373
+ fps = bsp_disp_get_fps(screen_id);
1374
+ bsp_disp_get_health_info(screen_id, &info);
1375
+
1376
+ if (!dispdev->is_enabled(dispdev))
1377
+ continue;
1378
+ count += sprintf(buf + count, "screen %d:\n", screen_id);
1379
+ count += sprintf(buf + count, "de_rate %d hz, ref_fps:%d\n",
1380
+ mgr->get_clk_rate(mgr),
1381
+ dispdev->get_fps(dispdev));
1382
+ count += mgr->dump(mgr, buf + count);
1383
+ /* output */
1384
+ if (dispdev->type == DISP_OUTPUT_TYPE_LCD) {
1385
+ count += sprintf(buf + count,
1386
+ "\tlcd output\tbacklight(%3d)\tfps:%d.%d",
1387
+ dispdev->get_bright(dispdev), fps / 10,
1388
+ fps % 10);
1389
+#if defined(CONFIG_DISP2_LCD_ESD_DETECT)
1390
+ if (dispdev->get_esd_info) {
1391
+ dispdev->get_esd_info(dispdev, &esd_inf);
1392
+ count += sprintf(buf + count,
1393
+ "\tesd level(%u)\tfreq(%u)\tpos(%u)\treset(%u)",
1394
+ esd_inf.level, esd_inf.freq,
1395
+ esd_inf.esd_check_func_pos, esd_inf.rst_cnt);
1396
+ }
1397
+#endif
1398
+ } else if (dispdev->type == DISP_OUTPUT_TYPE_HDMI) {
1399
+ int mode = dispdev->get_mode(dispdev);
1400
+
1401
+ count += sprintf(buf + count,
1402
+ "\thdmi output mode(%d)\tfps:%d.%d",
1403
+ mode, fps / 10, fps % 10);
1404
+ } else if (dispdev->type == DISP_OUTPUT_TYPE_TV) {
1405
+ int mode = dispdev->get_mode(dispdev);
1406
+
1407
+ count += sprintf(buf + count,
1408
+ "\ttv output mode(%d)\tfps:%d.%d",
1409
+ mode, fps / 10, fps % 10);
1410
+ }
1411
+/* else if (dispdev->type == DISP_OUTPUT_TYPE_VGA) {
1412
+ int mode = dispdev->get_mode(dispdev);
1413
+
1414
+ count += sprintf(buf + count,
1415
+ "\tvga output mode(%d)\tfps:%d.%d",
1416
+ mode, fps / 10, fps % 10);
1417
+ } else if (dispdev->type == DISP_OUTPUT_TYPE_VDPO) {
1418
+ int mode = dispdev->get_mode(dispdev);
1419
+
1420
+ count += sprintf(buf + count,
1421
+ "\tvdpo output mode(%d)\tfps:%d.%d",
1422
+ mode, fps / 10, fps % 10);
1423
+ } else if (dispdev->type == DISP_OUTPUT_TYPE_RTWB) {
1424
+ int mode = dispdev->get_mode(dispdev);
1425
+
1426
+ count += sprintf(buf + count,
1427
+ "\trtwb output mode(%d)\tfps:%d.%d",
1428
+ mode, fps / 10, fps % 10);
1429
+ } else if (dispdev->type == DISP_OUTPUT_TYPE_EDP) {
1430
+ count += sprintf(
1431
+ buf + count, "\tEDP output(%s) \tfps:%d.%d",
1432
+ (dispdev->is_enabled(dispdev) == 1) ? "enable"
1433
+ : "disable",
1434
+ fps / 10, fps % 10);
1435
+ }
1436
+*/
1437
+ if (dispdev->type != DISP_OUTPUT_TYPE_NONE) {
1438
+ count += sprintf(buf + count, "\t%4ux%4u\n",
1439
+ width, height);
1440
+ count += sprintf(buf + count,
1441
+ "\terr:%u\tskip:%u\tirq:%u\tvsync:%u\tvsync_skip:%u\t\n",
1442
+ info.error_cnt, info.skip_cnt,
1443
+ info.irq_cnt, info.vsync_cnt,
1444
+ info.vsync_skip_cnt);
1445
+ }
1446
+
1447
+ printf("%s\n", buf);
1448
+ memset(buf, 0, SYS_BUF_SIZE);
1449
+ count = 0;
1450
+ num_chans = bsp_disp_feat_get_num_channels(screen_id);
1451
+
1452
+ /* layer info */
1453
+ for (chan_id = 0; chan_id < num_chans; chan_id++) {
1454
+ num_layers =
1455
+ bsp_disp_feat_get_num_layers_by_chn(screen_id,
1456
+ chan_id);
1457
+ for (layer_id = 0; layer_id < num_layers; layer_id++) {
1458
+ struct disp_layer *lyr = NULL;
1459
+ struct disp_layer_config config;
1460
+
1461
+ lyr = disp_get_layer(screen_id, chan_id,
1462
+ layer_id);
1463
+ config.channel = chan_id;
1464
+ config.layer_id = layer_id;
1465
+ mgr->get_layer_config(mgr, &config, 1);
1466
+ if (lyr && (true == config.enable) && lyr->dump) {
1467
+ count += lyr->dump(lyr, buf + count);
1468
+ printf("%s\n", buf);
1469
+ memset(buf, 0, SYS_BUF_SIZE);
1470
+ count = 0;
1471
+ }
1472
+ }
1473
+ }
1474
+ }
1475
+ kfree(buf);
1476
+ return 0;
1477
+}
1478
+
1479
+U_BOOT_CMD(
1480
+ disp, 3, 0, do_sunxi_disp_sys,
1481
+ "show display status",
1482
+ "\nparameters : NULL\n"
1483
+);
13151484 /*TODO:drv_disp_standby is useful??*/
13161485
13171486 int do_sunxi_disp_colorbar(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])