1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdint.h>
4 #include <string.h>
5 #include <rtthread.h>
6 #include <hal_mem.h>
7 #include <log.h>
8 #include <video/sunxi_display2.h>
9 #include "disp_layer_cfg.h"
10 #include "disp_mem.h"
11 
12 int msleep(unsigned int msecs);
13 
14 static u32 g_screen_index;
15 
show_layer(struct test_layer_cfg * cfg,u32 width,u32 height,u32 channel,u32 format,char * filename)16 static int show_layer(struct test_layer_cfg *cfg, u32 width, u32 height,
17               u32 channel, u32 format, char *filename)
18 {
19     if (!cfg || !filename)
20         return -1;
21 
22     printf("show %s format:0x%x\n", filename, format);
23     disp_mem(0, width, height, 0, filename);
24 
25     cfg->mem_id = 0;
26     cfg->screen_id = g_screen_index;
27     cfg->layer_cfg.channel = channel;
28     cfg->layer_id = 0;
29     cfg->layer_cfg.layer_id = 0;
30 
31     cfg->layer_cfg.info.fb.format = format;
32     cfg->layer_cfg.info.fb.size[0].width = width;
33     cfg->layer_cfg.info.fb.size[0].height = height;
34     cfg->layer_cfg.info.fb.crop.x = 0;
35     cfg->layer_cfg.info.fb.crop.y = 0;
36     cfg->layer_cfg.info.fb.crop.width = width;
37     cfg->layer_cfg.info.fb.crop.height = height;
38     cfg->layer_cfg.info.fb.align[0] = 4;
39     cfg->layer_cfg.info.mode = 0;
40     cfg->layer_cfg.info.alpha_mode = 1;
41     cfg->layer_cfg.info.alpha_value = 255;
42     cfg->layer_cfg.info.zorder = 0;
43     cfg->layer_cfg.info.screen_win.x = 0;
44     cfg->layer_cfg.info.screen_win.y = 0;
45 
46     disp_layer_cfg(cfg);
47     msleep(1000);
48     disp_layer_clear(g_screen_index, channel, 0);
49     disp_mem_clear(0);
50     return 0;
51 }
52 
disp_layer_format_test(int argc,char ** argv)53 int disp_layer_format_test(int argc, char **argv)
54 {
55     struct test_layer_cfg test_cfg;
56     int i, sw, sh;
57     /*main test start*/
58 
59     if (argc == 2) {
60         g_screen_index = atoi(argv[1]);
61     } else
62         g_screen_index = 0;
63 
64     disp_layer_clear_all(g_screen_index);
65 
66     printf("request mem_id 0\n");
67 
68     printf("Start show layer\n");
69 
70     memset(&test_cfg, 0, sizeof(struct test_layer_cfg));
71     show_layer(&test_cfg, 480, 320, 0, 3, "./pic/bike_480x320_150.bin");
72     show_layer(&test_cfg, 640, 480, 0, 3, "./pic/bike_640x480_150.bin");
73     show_layer(&test_cfg, 720, 480, 0, 3,"./pic/bike_720x480_150.bin");
74     show_layer(&test_cfg, 720, 576, 0, 3, "./pic/bike_720x576_150.bin");
75     show_layer(&test_cfg, 960, 640, 0, 3, "./pic/bike_960x640_150.bin");
76     show_layer(&test_cfg, 1024, 600, 0, 3, "./pic/bike_1024x600_150.bin");
77     show_layer(&test_cfg, 1024, 720, 0, 3, "./pic/bike_1024x720_150.bin");
78     show_layer(&test_cfg, 1024, 768, 0, 3, "./pic/bike_1024x768_150.bin");
79     show_layer(&test_cfg, 1280, 720, 0, 3, "./pic/bike_1280x720_150.bin");
80     show_layer(&test_cfg, 500, 312, 0, 0, "./pic/argb8888.bin");
81     show_layer(&test_cfg, 500, 312, 0, 1, "./pic/abgr8888.bin");
82     show_layer(&test_cfg, 500, 312, 0, 2, "./pic/rgba8888.bin");
83     show_layer(&test_cfg, 500, 312, 0, 3, "./pic/bgra8888.bin");
84 
85     show_layer(&test_cfg, 480, 320, 1, 3, "./pic/bike_480x320_150.bin");
86     show_layer(&test_cfg, 640, 480, 1, 3, "./pic/bike_640x480_150.bin");
87     show_layer(&test_cfg, 720, 480, 1, 3, "./pic/bike_720x480_150.bin");
88     show_layer(&test_cfg, 720, 576, 1, 3,"./pic/bike_720x576_150.bin");
89     show_layer(&test_cfg, 960, 640, 1, 3, "./pic/bike_960x640_150.bin");
90     show_layer(&test_cfg, 1024, 600, 1, 3, "./pic/bike_1024x600_150.bin");
91     show_layer(&test_cfg, 1024, 720, 1, 3, "./pic/bike_1024x720_150.bin");
92     show_layer(&test_cfg, 1024, 768, 1, 3, "./pic/bike_1024x768_150.bin");
93     show_layer(&test_cfg, 1280, 720, 1, 3, "./pic/bike_1280x720_150.bin");
94 
95     show_layer(&test_cfg, 500, 312, 1, 0, "./pic/argb8888.bin");
96     show_layer(&test_cfg, 500, 312, 1, 1, "./pic/abgr8888.bin");
97     show_layer(&test_cfg, 500, 312, 1, 2, "./pic/rgba8888.bin");
98     show_layer(&test_cfg, 500, 312, 1, 3, "./pic/bgra8888.bin");
99 
100     show_layer(&test_cfg, 320, 240, 1, 72, "./pic/bike_320x240_020.bin");
101     show_layer(&test_cfg, 640, 480, 0, 72, "./pic/bike_640x480_020.bin");
102     show_layer(&test_cfg, 1280, 720, 0, 72, "./pic/bike_1280x720_020.bin");
103     show_layer(&test_cfg, 1920, 1080, 0, 72, "./pic/bike_1920x1080_020.bin");
104 
105     show_layer(&test_cfg, 480, 320, 0, 76, "./pic/bike_480x320_220.bin");
106     show_layer(&test_cfg, 640, 480, 0, 76, "./pic/bike_640x480_220.bin");
107     show_layer(&test_cfg, 720, 480, 0, 76, "./pic/bike_720x480_220.bin");
108     show_layer(&test_cfg, 720, 576, 0, 76, "./pic/bike_720x576_220.bin");
109     show_layer(&test_cfg, 960, 640, 0, 76, "./pic/bike_960x640_220.bin");
110     show_layer(&test_cfg, 1024, 600, 0, 76, "./pic/bike_1024x600_220.bin");
111     show_layer(&test_cfg, 1024, 720, 0, 76, "./pic/bike_1024x720_220.bin");
112     show_layer(&test_cfg, 1024, 768, 0, 76, "./pic/bike_1024x768_220.bin");
113     show_layer(&test_cfg, 1920, 1080, 0, 76, "./pic/bike_1920x1080_220.bin");
114     show_layer(&test_cfg, 1920, 1200, 0, 76, "./pic/bike_1920x1200_220.bin");
115 
116     show_layer(&test_cfg, 500, 312, 0, 16, "./pic/argb1555_500x312_ps0_ARGB.bin");
117 
118     show_layer(&test_cfg, 500, 312, 0, 16, "./pic/argb1555.bin");
119 
120     show_layer(&test_cfg, 500, 312, 0, 17, "./pic/abgr1555.bin");
121     show_layer(&test_cfg, 500, 312, 0, 18, "./pic/rgba5551.bin");
122     show_layer(&test_cfg, 500, 312, 0, 19, "./pic/bgra5551.bin");
123     show_layer(&test_cfg, 500, 312, 0, 12, "./pic/argb4444_ps0_500x312_ARGB.bin");
124     show_layer(&test_cfg, 500, 312, 0, 12, "./pic/argb4444.bin");
125     show_layer(&test_cfg, 500, 312, 0, 13, "./pic/abgr4444.bin");
126     show_layer(&test_cfg, 500, 312, 0, 14, "./pic/rgba4444.bin");
127     show_layer(&test_cfg, 500, 312, 0, 15, "./pic/bgra4444.bin");
128     show_layer(&test_cfg, 500, 312, 0, 10, "./pic/rgb565_ps0_500x312_ARGB.bin");
129     show_layer(&test_cfg, 500, 312, 0, 10, "./pic/rgb565.bin");
130     show_layer(&test_cfg, 500, 312, 0, 11, "./pic/bgr565.bin");
131 
132     disp_layer_clear_all(g_screen_index);
133     msleep(100);
134 
135     return 0;
136 }
137 
138 FINSH_FUNCTION_EXPORT_ALIAS(disp_layer_format_test, __cmd_disp_layer_format_test, disp_layer_format_test);
139