This commit is contained in:
刘可亮
2024-06-04 19:00:30 +08:00
parent 990c72f5be
commit 0a13af6a1d
1668 changed files with 342810 additions and 37726 deletions

View File

@@ -18,22 +18,22 @@
#include "./public/ge_fb.h"
#include "./public/ge_mem.h"
#define ALPHA_SRC_IMAGE "/sdcard/ge_test/image/alpha_src.bmp"
#define ALPHA_DST_IMAGE "/sdcard/ge_test/image/alpha_dst.bmp"
#define ALPHA_BACK_GROUND_IMAGE "/sdcard/ge_test/image/alpha_back_ground.bmp"
/* ge alpha bending test */
#define ALPHA_RULE_NUM 14
#define LOGE(fmt, ...) aic_log(AIC_LOG_ERR, "E", fmt, ##__VA_ARGS__)
#define LOGE(fmt, ...) aic_log(AIC_LOG_ERR, "E", fmt, ##__VA_ARGS__)
#define LOGW(fmt, ...) aic_log(AIC_LOG_WARN, "W", fmt, ##__VA_ARGS__)
#define LOGI(fmt, ...) aic_log(AIC_LOG_INFO, "I", fmt, ##__VA_ARGS__)
static char g_src_input[128] = {"/sdcard/ge_test/image/alpha_src.bmp"};
static char g_dst_input[128] = {"/sdcard/ge_test/image/alpha_dst.bmp"};
static char g_bg_input[128] = {"/sdcard/ge_test/image/alpha_back_ground.bmp"};
/* alpha blending */
static unsigned int src_alpha_mode = 0;
static unsigned int src_global_alpha = 0;
static unsigned int dst_alpha_mode = 0;
static unsigned int dst_global_alpha = 0;
static unsigned int g_src_alpha_mode = 0;
static unsigned int g_src_global_alpha = 0;
static unsigned int g_dst_alpha_mode = 0;
static unsigned int g_dst_global_alpha = 0;
static void usage_alpha(char *app)
{
@@ -51,7 +51,13 @@ static void usage_alpha(char *app)
"\t-p, --dst_global_alpha, Select dst_global_alpha value (default 0), "
"destination global alpha value (0~255)"
"\n"
"\t-i, --input_src\n"
"\t-o, --input_dst\n"
"\t-b, --bg_dst\n"
"\t-u, --usage\n");
printf("\tfor example:\n");
printf("\tge_alpha_blending -i alpha_src.bmp -o alpha_dst.bmp -b alpha_back_ground.bmp\n");
}
static long long int str2int(char *_str)
@@ -194,14 +200,14 @@ static void porter_duff_set(struct ge_bitblt *blt, struct ge_buf *src_buffer,
/* src layer settings */
memcpy(&blt->src_buf, &src_buffer->buf, sizeof(struct mpp_buf));
blt->src_buf.crop_en = 0;
blt->ctrl.src_alpha_mode = src_alpha_mode;
blt->ctrl.src_global_alpha = src_global_alpha;
blt->ctrl.src_alpha_mode = g_src_alpha_mode;
blt->ctrl.src_global_alpha = g_src_global_alpha;
/* dst layer settings */
memcpy(&blt->dst_buf, &dst_buffer->buf, sizeof(struct mpp_buf));
blt->dst_buf.crop_en = 0;
blt->ctrl.dst_alpha_mode = dst_alpha_mode;
blt->ctrl.dst_global_alpha = dst_global_alpha;
blt->ctrl.dst_alpha_mode = g_dst_alpha_mode;
blt->ctrl.dst_global_alpha = g_dst_global_alpha;
blt->ctrl.alpha_en = 1;
blt->ctrl.alpha_rules = alpha_rule;
@@ -230,9 +236,12 @@ static int ge_alpha_blending_test(int argc, char **argv)
struct ge_bitblt blt = {0};
struct ge_fb_info *fb_info = NULL;
const char sopts[] = "us:d:g:p:";
const char sopts[] = "us:d:g:p:i:o:b:";
const struct option lopts[] = {
{"usage", no_argument, NULL, 'u'},
{"src_input" , required_argument, NULL, 'i'},
{"dst_input" , required_argument, NULL, 'o'},
{"bg_input" , required_argument, NULL, 'b'},
{"src_alpha_mode" , required_argument, NULL, 's'},
{"dst_alpha_mode", required_argument, NULL, 'd'},
{"src_global_alpha", required_argument, NULL, 'g'},
@@ -241,30 +250,39 @@ static int ge_alpha_blending_test(int argc, char **argv)
optind = 0;
while ((ret = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
switch (ret) {
case 'i':
strncpy(g_src_input, optarg, sizeof(g_src_input) - 1);
break;
case 'o':
strncpy(g_dst_input, optarg, sizeof(g_dst_input) - 1);
break;
case 'b':
strncpy(g_bg_input, optarg, sizeof(g_bg_input) - 1);
break;
case 's':
src_alpha_mode = str2int(optarg);
if ((src_alpha_mode > 3) || (src_alpha_mode < 0)) {
g_src_alpha_mode = str2int(optarg);
if ((g_src_alpha_mode > 3) || (g_src_alpha_mode < 0)) {
printf("src_alpha_mode invalid, please input against\n");
return 0;
}
break;
case 'd':
dst_alpha_mode = str2int(optarg);
if ((dst_alpha_mode > 3) || (dst_alpha_mode < 0)) {
g_dst_alpha_mode = str2int(optarg);
if ((g_dst_alpha_mode > 3) || (g_dst_alpha_mode < 0)) {
printf("dst_alpha_mode invalid, please input against\n");
return 0;
}
break;
case 'g':
src_global_alpha = str2int(optarg);
if ((src_global_alpha > 255) || (src_global_alpha < 0)) {
g_src_global_alpha = str2int(optarg);
if ((g_src_global_alpha > 255) || (g_src_global_alpha < 0)) {
printf("src_global_alpha invalid, please input against\n");
return 0;
}
break;
case 'p':
dst_global_alpha = str2int(optarg);
if ((dst_global_alpha > 255) || (dst_global_alpha < 0)) {
g_dst_global_alpha = str2int(optarg);
if ((g_dst_global_alpha > 255) || (g_dst_global_alpha < 0)) {
printf("dst_global_alpha invalid, please input against\n");
return 0;
}
@@ -286,21 +304,21 @@ static int ge_alpha_blending_test(int argc, char **argv)
fb_info = fb_open();
bg_fd = bmp_open(ALPHA_BACK_GROUND_IMAGE, &bg_head);
bg_fd = bmp_open(g_bg_input, &bg_head);
if (bg_fd < 0) {
LOGE("open bmp error, path = %s\n", ALPHA_BACK_GROUND_IMAGE);
LOGE("open bmp error, path = %s\n", g_bg_input);
goto EXIT;
}
src_fd = bmp_open(ALPHA_SRC_IMAGE, &src_head);
src_fd = bmp_open(g_src_input, &src_head);
if (src_fd < 0) {
LOGE("open bmp error, path = %s\n", ALPHA_SRC_IMAGE);
LOGE("open bmp error, path = %s\n", g_src_input);
goto EXIT;
}
dst_fd = bmp_open(ALPHA_DST_IMAGE, &dst_head);
dst_fd = bmp_open(g_dst_input, &dst_head);
if (dst_fd < 0) {
LOGE("open bmp error, path = %s\n", ALPHA_DST_IMAGE);
LOGE("open bmp error, path = %s\n", g_dst_input);
goto EXIT;
}
@@ -377,6 +395,8 @@ static int ge_alpha_blending_test(int argc, char **argv)
goto EXIT;
}
}
printf("ge alpha blend test success\n");
EXIT:
if (bg_fd > 0)
bmp_close(bg_fd);

View File

@@ -17,6 +17,11 @@
#include "mpp_ge.h"
#include "mpp_fb.h"
#include "artinchip_fb.h"
#include "aic_hal_clk.h"
#include "./public/bmp.h"
#include "./public/ge_fb.h"
#include "./public/ge_mem.h"
#include <getopt.h>
@@ -27,19 +32,13 @@
#define LOGE(fmt, ...) aic_log(AIC_LOG_ERR, "E", fmt, ##__VA_ARGS__)
#define LOGW(fmt, ...) aic_log(AIC_LOG_WARN, "W", fmt, ##__VA_ARGS__)
#define LOGI(fmt, ...) aic_log(AIC_LOG_INFO, "I", fmt, ##__VA_ARGS__)
#define CLOCK_IMAGE_WIDTH 590
#define CLOCK_IMAGE_HEIGHT 600
#define SECOND_IMAGE_WIDTH 48
#define SECOND_IMAGE_HEIGHT 220
#define LOGD(fmt, ...) aic_log(AIC_LOG_DEBUG, "D", fmt, ##__VA_ARGS__)
#define ROT_SRC_CENTER_X 24
#define ROT_SRC_CENTER_Y 194
#define CLOCK_IMAGE "/sdcard/ge_test/image/clock.bmp"
#define SECOND_IMAGE "/sdcard/ge_test/image/second.bmp"
#define BLT_BMP "/sdcard/ge_test/image/clock.bmp"
static char g_src_input[128] = {"/sdcard/ge_test/image/base/clock.bmp"};
static char g_bg_input[128] = {"/sdcard/ge_test/image/base/clock.bmp"};
#define ROT_DST_CENTER_X 294
#define ROT_DST_CENTER_Y 297
@@ -49,10 +48,6 @@
#define PARA_NUM 0
#define PARA_CIR 1
static unsigned int g_src_phy = 0;
static unsigned int g_bg_phy = 0;
static unsigned int g_dst_phy = 0;
static struct aicfb_screeninfo g_info = {0};
static int degree_list[] = {
@@ -123,9 +118,16 @@ static void usage(char *app)
{
printf("Usage: %s [Options]: \n", app);
printf("\t-c, --circle test\n");
printf("\t-i, --input src\n");
printf("\t-o, --input bg_src\n");
printf("\t-n, --number of run, default run once\n");
printf("\t-d, --delay, unit: ms");
printf("\t-u, --usage\n\n");
printf("\t-u, --usage\n");
printf("\tfor example:\n");
printf("\tge_fill -n 10 -d 0\n");
printf("\tge_bitblt -i /data/clock.bmp -c\n");
printf("\tge_rotate -i /data/second.bmp -o /data/clock.bmp\n");
}
static long long int str2int(char *_str)
@@ -141,81 +143,64 @@ static long long int str2int(char *_str)
return strtoll(_str, NULL, 16);
}
static void draw_clock(struct ge_bitblt *blt, int src_buf, int index)
static void show_ge_freq(void)
{
int ret = hal_clk_get_freq(CLK_GE);
printf("GE current freq: %d MHz\n", ret / 1000000);
}
static void draw_clock(struct ge_bitblt *blt, struct ge_fb_info *info,
struct ge_buf *buffer, struct bmp_header *head)
{
unsigned int fb_phy = 0;
memset(blt, 0, sizeof(struct ge_bitblt));
/* source buffer */
blt->src_buf.buf_type = MPP_PHY_ADDR;
blt->src_buf.phy_addr[0] = src_buf;
blt->src_buf.stride[0] = CLOCK_IMAGE_WIDTH * 4;
blt->src_buf.size.width = CLOCK_IMAGE_WIDTH;
blt->src_buf.size.height = CLOCK_IMAGE_HEIGHT;
blt->src_buf.format = MPP_FMT_ARGB_8888;
memcpy(&blt->src_buf, &buffer->buf, sizeof(struct mpp_buf));
blt->src_buf.crop_en = 1;
blt->src_buf.crop.x = 0;
blt->src_buf.crop.y = 0;
blt->src_buf.crop.width = CLOCK_IMAGE_WIDTH;
blt->src_buf.crop.height = CLOCK_IMAGE_HEIGHT;
blt->src_buf.crop.width = head->width;
blt->src_buf.crop.height = abs(head->height);
/* dstination buffer */
fb_phy = fb_get_cur_frame(info);
blt->dst_buf.buf_type = MPP_PHY_ADDR;
if (!index) {
blt->dst_buf.phy_addr[0] = g_dst_phy;
} else {
if (APP_FB_NUM > 1) {
blt->dst_buf.phy_addr[0] = g_dst_phy + g_info.smem_len;
} else {
blt->dst_buf.phy_addr[0] = g_dst_phy;
}
}
blt->dst_buf.stride[0] = g_info.stride;
blt->dst_buf.size.width = g_info.width;
blt->dst_buf.size.height = g_info.height;
blt->dst_buf.format = g_info.format;
blt->dst_buf.phy_addr[0] = fb_phy;
blt->dst_buf.stride[0] = info->fb_data.stride;
blt->dst_buf.size.width = info->fb_data.width;
blt->dst_buf.size.height = info->fb_data.height;
blt->dst_buf.format = info->fb_data.format;
blt->ctrl.flags = 0;
blt->dst_buf.crop_en = 1;
blt->dst_buf.crop.x = 0;
blt->dst_buf.crop.y = 0;
blt->dst_buf.crop.width = CLOCK_IMAGE_WIDTH;
blt->dst_buf.crop.height = CLOCK_IMAGE_HEIGHT;
blt->dst_buf.crop.width = head->width;
blt->dst_buf.crop.height = abs(head->height);
}
static void move_second_hand(struct mpp_ge *ge, struct ge_rotation *rot,
int sin, int cos,
int src_buf, int index)
static void move_second_hand(struct ge_rotation *rot, struct ge_fb_info *info,
struct ge_buf *buffer, int sin, int cos)
{
/* source buffer */
rot->src_buf.buf_type = MPP_PHY_ADDR;
rot->src_buf.phy_addr[0] = src_buf;
rot->src_buf.stride[0] = SECOND_IMAGE_WIDTH * 4;
rot->src_buf.size.width = SECOND_IMAGE_WIDTH;
rot->src_buf.size.height = SECOND_IMAGE_HEIGHT;
rot->src_buf.format = MPP_FMT_ARGB_8888;
rot->src_buf.crop_en = 0;
unsigned int fb_phy = 0;
memset(rot, 0, sizeof(struct ge_rotation));
/* source buffer */
memcpy(&rot->src_buf, &buffer->buf, sizeof(struct mpp_buf));
rot->src_rot_center.x = ROT_SRC_CENTER_X;
rot->src_rot_center.y = ROT_SRC_CENTER_Y;
/* destination buffer */
fb_phy = fb_get_cur_frame(info);
rot->dst_buf.buf_type = MPP_PHY_ADDR;
if (!index) {
rot->dst_buf.phy_addr[0] = g_dst_phy;
} else {
if (APP_FB_NUM > 1) {
rot->dst_buf.phy_addr[0] = g_dst_phy + g_info.smem_len;
} else {
rot->dst_buf.phy_addr[0] = g_dst_phy;
}
}
rot->dst_buf.stride[0] = g_info.stride;
rot->dst_buf.size.width = g_info.width;
rot->dst_buf.size.height = g_info.height;
rot->dst_buf.format = g_info.format;
rot->dst_buf.crop_en = 0;
rot->dst_buf.phy_addr[0] = fb_phy;
rot->dst_buf.stride[0] = info->fb_data.stride;
rot->dst_buf.size.width = info->fb_data.width;
rot->dst_buf.size.height = info->fb_data.height;
rot->dst_buf.format = info->fb_data.format;
rot->dst_rot_center.x = ROT_DST_CENTER_X;
rot->dst_rot_center.y = ROT_DST_CENTER_Y;
@@ -229,89 +214,81 @@ static void ge_rotate_thread(void *arg)
{
int ret = 0;
int i = 0, num = 0, loops = 1;
int src_fd = -1, bg_fd = -1;
int fsize = 0;
int index = 0;
struct stat st;
struct mpp_ge *ge = NULL;
struct mpp_fb *fb = NULL;
void *src_buf = NULL;
void *bg_buf = NULL;
struct ge_bitblt blt = {0};
struct ge_rotation rot = {0};
int *para = NULL;
int circle = 0;
int bg_fd = -1;
int src_fd = -1;
enum mpp_pixel_format bg_fmt = 0;
enum mpp_pixel_format src_fmt = 0;
struct ge_buf *bg_buffer = NULL;
struct ge_buf *src_buffer = NULL;
struct bmp_header bg_head = {0};
struct bmp_header src_head = {0};
struct mpp_ge *ge = NULL;
struct ge_bitblt blt = {0};
struct ge_rotation rot = {0};
struct ge_fb_info *fb_info = NULL;
para = arg;
circle = para[PARA_CIR];
if (para[PARA_NUM] >= 0)
loops = para[PARA_NUM];
src_fd = open(SECOND_IMAGE, O_RDONLY);
if (src_fd < 0) {
LOGE("open second_bmp fail, path = %s\n", SECOND_IMAGE);
goto out;
}
lseek(src_fd, 54, SEEK_SET);
stat(SECOND_IMAGE, &st);
fsize = st.st_size;
src_buf = aicos_malloc(MEM_CMA, fsize);
if (!src_buf) {
LOGE("malloc src_buf fail\n");
return;
}
memset(src_buf, 0, fsize);
ret = read(src_fd, src_buf, fsize - 54);
aicos_dcache_clean_range((unsigned long *)src_buf, (unsigned long)fsize);
close(src_fd);
g_src_phy = (uintptr_t)src_buf;
bg_fd = open(CLOCK_IMAGE, O_RDONLY);
if (bg_fd < 0) {
LOGE("open second_bmp fail, path = %s\n", CLOCK_IMAGE);
goto out;
}
lseek(bg_fd, 54, SEEK_SET);
stat(CLOCK_IMAGE, &st);
fsize = st.st_size;
bg_buf = aicos_malloc(MEM_CMA, fsize);
if (!bg_buf) {
LOGE("malloc bg_buf fail\n");
goto out;
}
memset(bg_buf, 0, fsize);
ret = read(bg_fd, bg_buf, fsize - 54);
aicos_dcache_clean_range((unsigned long *)bg_buf, (unsigned long)fsize);
close(bg_fd);
g_bg_phy = (uintptr_t)bg_buf;
fb = mpp_fb_open();
if (!fb) {
LOGE("mpp fb open failed\n");
goto out;
}
ret = mpp_fb_ioctl(fb, AICFB_GET_SCREENINFO , &g_info);
if (ret) {
LOGE("get screen info failed\n");
goto out;
}
g_dst_phy = (unsigned long)g_info.framebuffer;
ge = mpp_ge_open();
if (!ge) {
LOGE("ge open fail\n");
goto out;
LOGE("open ge device error\n");
goto ROTATION_OUT;
}
fb_info = fb_open();
bg_fd = bmp_open(g_bg_input, &bg_head);
if (bg_fd < 0) {
LOGE("open bmp error, path = %s\n", g_bg_input);
goto ROTATION_OUT;
}
src_fd = bmp_open(g_src_input, &src_head);
if (src_fd < 0) {
LOGE("open bmp error, path = %s\n", g_src_input);
goto ROTATION_OUT;
}
bg_fmt = bmp_get_fmt(&bg_head);
bg_buffer = ge_buf_malloc(bg_head.width, abs(bg_head.height), bg_fmt);
if (bg_buffer == NULL) {
LOGE("malloc bg buffer error\n");
goto ROTATION_OUT;
}
src_fmt = bmp_get_fmt(&src_head);
src_buffer = ge_buf_malloc(src_head.width, abs(src_head.height), src_fmt);
if (src_buffer == NULL) {
LOGE("malloc src buffer error\n");
goto ROTATION_OUT;
}
ret = bmp_read(bg_fd, (void *)((uintptr_t)bg_buffer->buf.phy_addr[0]), &bg_head);
if (ret < 0) {
LOGE("bg bmp_read error\n");
goto ROTATION_OUT;
}
ge_buf_clean_dcache(bg_buffer);
ret = bmp_read(src_fd, (void *)((uintptr_t)src_buffer->buf.phy_addr[0]), &src_head);
if (ret < 0) {
LOGE("src bmp_read error\n");
goto ROTATION_OUT;
}
ge_buf_clean_dcache(src_buffer);
while (1) {
// LOGI("num : %d\n", num);
draw_clock(&blt, g_bg_phy, index);
draw_clock(&blt, fb_info, bg_buffer, &bg_head);
ret = mpp_ge_bitblt(ge, &blt);
if (ret < 0) {
@@ -329,10 +306,9 @@ static void ge_rotate_thread(void *arg)
break;
}
move_second_hand(ge, &rot,
move_second_hand(&rot, fb_info, src_buffer,
degree_list[i * 2],
degree_list[i * 2 + 1],
g_src_phy, index);
degree_list[i * 2 + 1]);
ret = mpp_ge_rotate(ge, &rot);
if (ret < 0) {
@@ -350,17 +326,9 @@ static void ge_rotate_thread(void *arg)
break;
}
fb_start_and_wait(fb_info);
fb_swap_frame(fb_info);
//LOGI("index : %d\n", index);
if (APP_FB_NUM > 1) {
ret = mpp_fb_ioctl(fb, AICFB_PAN_DISPLAY, &index);
if (ret == 0) {
ret = mpp_fb_ioctl(fb, AICFB_WAIT_FOR_VSYNC, &index);
if (ret < 0)
LOGE("wait for sync error\n");
} else {
LOGE("pan display fail\n");
}
}
i++;
if (i == 61) {
@@ -376,15 +344,23 @@ static void ge_rotate_thread(void *arg)
aicos_msleep(1000);
}
out:
mpp_ge_close(ge);
mpp_fb_close(fb);
printf("ge rotate test success\n");
ROTATION_OUT:
if (bg_fd > 0)
bmp_close(bg_fd);
if (src_fd > 0)
bmp_close(src_fd);
if (bg_buf)
aicos_free(MEM_CMA, bg_buf);
if (ge)
mpp_ge_close(ge);
if (src_buf)
aicos_free(MEM_CMA, src_buf);
if (fb_info)
fb_close(fb_info);
if (bg_buffer)
ge_buf_free(bg_buffer);
if (src_buffer)
ge_buf_free(src_buffer);
}
static void ge_rotate(int argc, char **argv)
@@ -393,20 +369,30 @@ static void ge_rotate(int argc, char **argv)
int ret = 0;
int para[2] = {0};
const char sopts[] = "ucn:";
const char sopts[] = "ucn:i:o:";
const struct option lopts[] = {
{"usage", no_argument, NULL, 'u'},
{"circle", no_argument, NULL, 'c'},
{"number", required_argument, NULL, 'n'},
{"usage", no_argument, NULL, 'u'},
{"circle", no_argument, NULL, 'c'},
{"src_input", required_argument, NULL, 'i'},
{"out_input", required_argument, NULL, 'o'},
{"number", required_argument, NULL, 'n'},
{0, 0, 0, 0}
};
strncpy(g_src_input, "/sdcard/ge_test/image/base/second.bmp", sizeof(g_src_input) - 1);
strncpy(g_bg_input, "/sdcard/ge_test/image/base/clock.bmp", sizeof(g_bg_input) - 1);
optind = 0;
while ((ret = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
switch (ret) {
case 'c':
para[PARA_CIR] = 1;
break;
case 'i':
strncpy(g_src_input, optarg, sizeof(g_src_input) - 1);
break;
case 'o':
strncpy(g_bg_input, optarg, sizeof(g_bg_input) - 1);
break;
case 'n':
if (str2int(optarg) <= 0) {
LOGE("Invalid parameter: %#x\n", ret);
@@ -433,28 +419,28 @@ MSH_CMD_EXPORT_ALIAS(ge_rotate, ge_rotate, ge rotate test);
static void ge_bitblt(int argc, char **argv)
{
LOGI("ge bitblt test app start........\n");
int ret = -1, num = 0, loops = 1;
int ret = -1, num = 0, loops = 1, delay = 1000;
struct mpp_ge *ge = NULL;
int width = CLOCK_IMAGE_WIDTH;
int height = CLOCK_IMAGE_HEIGHT;
int src_fd = -1;
int fsize = 0;
void *src_buf = NULL;
struct stat st;
struct ge_bitblt blt = {0};
struct mpp_fb *fb = NULL;
struct ge_fb_info *fb_info = NULL;
struct timespec begin, now;
struct bmp_header bmp_head = {0};
enum mpp_pixel_format bmp_fmt = 0;
struct ge_buf *bmp_buffer = NULL;
int bmp_fd = -1;
int circle = 0;
const char sopts[] = "ucn:";
const char sopts[] = "ucn:d:i:";
const struct option lopts[] = {
{"usage", no_argument, NULL, 'u'},
{"circle", no_argument, NULL, 'c'},
{"number", required_argument, NULL, 'n'},
{"usage", no_argument, NULL, 'u'},
{"circle", no_argument, NULL, 'c'},
{"src_input", required_argument, NULL, 'i'},
{"number", required_argument, NULL, 'n'},
{"delay", required_argument, NULL, 'd'},
{0, 0, 0, 0}
};
strncpy(g_src_input, "/sdcard/ge_test/image/base/clock.bmp", sizeof(g_src_input) - 1);
optind = 0;
while ((ret = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
switch (ret) {
@@ -468,6 +454,12 @@ static void ge_bitblt(int argc, char **argv)
}
loops = str2int(optarg);
break;
case 'd':
delay = str2int(optarg);
continue;
case 'i':
strncpy(g_src_input, optarg, sizeof(g_src_input) - 1);
break;
case 'u':
usage(argv[0]);
return;
@@ -477,42 +469,7 @@ static void ge_bitblt(int argc, char **argv)
}
}
src_fd = open(BLT_BMP, O_RDONLY);
if (src_fd < 0) {
LOGE("open blt_bmp fail, path = %s\n", BLT_BMP);
return;
}
lseek(src_fd, 54, SEEK_SET);
stat(BLT_BMP, &st);
fsize = st.st_size;
src_buf = aicos_malloc(MEM_CMA, fsize);
if (!src_buf) {
LOGE("malloc src fail, size: %d\n", fsize);
return;
}
memset(src_buf, 0, fsize);
ret = read(src_fd, src_buf, fsize - 54);
LOGI("fsize: %d, ret: %d", fsize, ret);
aicos_dcache_clean_range((unsigned long *)src_buf, (unsigned long)fsize);
close(src_fd);
g_src_phy = (uintptr_t)src_buf;
fb = mpp_fb_open();
if (!fb) {
LOGE("mpp fb open failed\n");
goto out;
}
ret = mpp_fb_ioctl(fb, AICFB_GET_SCREENINFO , &g_info);
if (ret) {
LOGE("get screen info failed\n");
goto out;
}
g_dst_phy = (unsigned long)g_info.framebuffer;
show_ge_freq();
ge = mpp_ge_open();
if (!ge) {
@@ -520,32 +477,55 @@ static void ge_bitblt(int argc, char **argv)
return;
}
fb_info = fb_open();
if (!fb_info) {
LOGE("fb_open fail\n");
goto BITBLT_OUT;
}
bmp_fd = bmp_open(g_src_input, &bmp_head);
if (bmp_fd < 0) {
LOGE("open bmp error, path = %s\n", g_src_input);
goto BITBLT_OUT;
}
bmp_fmt = bmp_get_fmt(&bmp_head);
bmp_buffer = ge_buf_malloc(bmp_head.width, abs(bmp_head.height), bmp_fmt);
if (bmp_buffer == NULL) {
LOGE("malloc bmp_buffer error\n");
goto BITBLT_OUT;
}
ret = bmp_read(bmp_fd, (void *)((uintptr_t)bmp_buffer->buf.phy_addr[0]), &bmp_head);
if (ret < 0) {
LOGE("bmp_read error\n");
ge_buf_free(bmp_buffer);
goto BITBLT_OUT;
}
ge_buf_clean_dcache(bmp_buffer);
gettimespec(&begin);
while (1) {
LOGI("num: %d\n", num);
LOGD("num: %d\n", num);
memset(&blt, 0, sizeof(struct ge_bitblt));
/* source buffer */
blt.src_buf.buf_type = MPP_PHY_ADDR;
blt.src_buf.phy_addr[0] = g_src_phy;
blt.src_buf.stride[0] = width * 4;
blt.src_buf.size.width = width;
blt.src_buf.size.height = height;
blt.src_buf.format = MPP_FMT_ARGB_8888;
blt.src_buf.crop_en = 0;
memcpy(&blt.src_buf, &bmp_buffer->buf, sizeof(struct mpp_buf));
/* dstination buffer */
blt.dst_buf.buf_type = MPP_PHY_ADDR;
blt.dst_buf.phy_addr[0] = g_dst_phy;
blt.dst_buf.stride[0] = g_info.stride;
blt.dst_buf.size.width = g_info.width;
blt.dst_buf.size.height = g_info.height;
blt.dst_buf.format = g_info.format;
blt.dst_buf.phy_addr[0] = (unsigned long)fb_info->fb_data.framebuffer;
blt.dst_buf.stride[0] = fb_info->fb_data.stride;
blt.dst_buf.size.width = fb_info->fb_data.width;
blt.dst_buf.size.height = fb_info->fb_data.height;
blt.dst_buf.format = fb_info->fb_data.format;
blt.dst_buf.crop_en = 1;
blt.dst_buf.crop.x = 0;
blt.dst_buf.crop.y = 0;
blt.dst_buf.crop.width = width;
blt.dst_buf.crop.height = height;
blt.dst_buf.crop.width = bmp_head.width;
blt.dst_buf.crop.height = abs(bmp_head.height);
printf("width = %d, height = %d\n", blt.dst_buf.crop.width, blt.dst_buf.crop.height);
ret = mpp_ge_bitblt(ge, &blt);
if (ret < 0) {
@@ -563,7 +543,14 @@ static void ge_bitblt(int argc, char **argv)
break;
}
num++;
aicos_msleep(1000);
if (delay)
aicos_msleep(delay);
if (num && (num % 2000 == 0)) {
gettimespec(&now);
show_fps("GE bitblt", &begin, &now, 2000);
gettimespec(&begin);
}
if (circle == 0) {
if(num == loops)
@@ -571,49 +558,63 @@ static void ge_bitblt(int argc, char **argv)
}
}
out:
mpp_ge_close(ge);
mpp_fb_close(fb);
aicos_free(MEM_CMA, src_buf);
printf("ge bitblt test success\n");
BITBLT_OUT:
if (ge)
mpp_ge_close(ge);
if (fb_info)
fb_close(fb_info);
if (bmp_buffer)
ge_buf_free(bmp_buffer);
if (bmp_fd > 0)
bmp_close(bmp_fd);
return;
}
MSH_CMD_EXPORT_ALIAS(ge_bitblt, ge_bitblt, ge bitblit test);
static void ge_fillrect(int argc, char **argv)
{
LOGI("ge fillrect app test start........\n");
int ret = -1, num = 0, loops = 1;
int ret = -1, num = 0, loops = 1, delay = 200;
int index = 0;
struct mpp_ge *ge = NULL;
struct mpp_fb *fb = NULL;
struct ge_fillrect fill;
int width;
int height;
struct timespec begin, now;
unsigned int g_dst_phy = 0;
int circle = 0;
const char sopts[] = "ucn:";
const char sopts[] = "ucn:d:";
const struct option lopts[] = {
{"usage", no_argument, NULL, 'u'},
{"circle", no_argument, NULL, 'c'},
{"number", required_argument, NULL, 'n'},
{"delay", required_argument, NULL, 'd'},
{0, 0, 0, 0}
};
#ifndef AIC_PAN_DISPLAY
LOGE("Must enable DE double-FrameBuffer in menuconfig first.\n");
return;
#endif
optind = 0;
while ((ret = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
switch (ret) {
case 'c':
circle = 1;
break;
continue;
case 'n':
if (str2int(optarg) <= 0) {
LOGE("Invalid parameter: %#x\n", ret);
return;
}
loops = str2int(optarg);
break;
continue;
case 'd':
delay = str2int(optarg);
continue;
case 'u':
usage(argv[0]);
return;
@@ -623,6 +624,8 @@ static void ge_fillrect(int argc, char **argv)
}
}
show_ge_freq();
fb = mpp_fb_open();
if (!fb) {
LOGE("open mpp fb failed\n");
@@ -638,7 +641,7 @@ static void ge_fillrect(int argc, char **argv)
g_dst_phy = (unsigned long)g_info.framebuffer;
width = g_info.width;
height = g_info.height;
LOGI("g_dst_phy: 0x%08x, width: %d, height: %d\n", g_dst_phy, width, height);
LOGI("FB: 0x%08x, width: %d, height: %d\n", g_dst_phy, width, height);
ge = mpp_ge_open();
if (!ge) {
@@ -646,8 +649,9 @@ static void ge_fillrect(int argc, char **argv)
goto out;
}
gettimespec(&begin);
while (1) {
LOGI("fill: %d\n", num);
LOGD("fill: %d\n", num);
memset(&fill, 0, sizeof(struct ge_fillrect));
fill.type = GE_NO_GRADIENT;
@@ -673,6 +677,7 @@ static void ge_fillrect(int argc, char **argv)
fill.dst_buf.size.height = g_info.height;
fill.dst_buf.format = g_info.format;
fill.ctrl.flags = 0;
fill.ctrl.alpha_en = 0;
fill.dst_buf.crop_en = 0;
fill.dst_buf.crop.x = 0;
@@ -696,7 +701,8 @@ static void ge_fillrect(int argc, char **argv)
break;
}
num++;
aicos_msleep(200);
if (delay)
aicos_msleep(delay);
if (APP_FB_NUM > 1) {
ret = mpp_fb_ioctl(fb, AICFB_PAN_DISPLAY, &index);
@@ -709,6 +715,12 @@ static void ge_fillrect(int argc, char **argv)
}
}
if (num && (num % 2000 == 0)) {
gettimespec(&now);
show_fps("GE fillrect", &begin, &now, 2000);
gettimespec(&begin);
}
if (circle == 0) {
if(num == loops)
break;
@@ -717,6 +729,7 @@ static void ge_fillrect(int argc, char **argv)
index = !index;
}
printf("ge fill test success\n");
out:
mpp_ge_close(ge);
mpp_fb_close(fb);

View File

@@ -22,8 +22,6 @@
#define SRC_DISP_REGION 0
#define DST_DISP_REGION 1
#define DITHER_IMAGE "/sdcard/ge_test/image/singer_alpha.bmp"
#define LOGE(fmt, ...) aic_log(AIC_LOG_ERR, "E", fmt, ##__VA_ARGS__)
#define LOGW(fmt, ...) aic_log(AIC_LOG_WARN, "W", fmt, ##__VA_ARGS__)
#define LOGI(fmt, ...) aic_log(AIC_LOG_INFO, "I", fmt, ##__VA_ARGS__)
@@ -38,15 +36,22 @@ struct StrToFormat {
static int table_size = 0;
static struct StrToFormat *format_table = NULL;
static char g_src_input[128] = {"/sdcard/ge_test/image/singer_alpha.bmp"};
static void usage(char *app)
{
printf("Usage: %s [Options]: \n", app);
printf("\t-o, --dither_on, Select open dither (default 0), 0 :close 1 :open\n");
printf("\t-s, --src_format, Select src format (default argb8888)\n");
printf("\t-d, --dst_format, Select dst format (default argb4444)\n");
printf("\t-i --input_src, input src\n");
printf("\t-u, --usage\n");
printf("\t-h, --help, list the supported format and the test instructions\n\n");
printf("\tfor example:\n");
printf("\tge_dither -i /data/singer_alpha.bmp -o 1\n");
}
static void help(void)
{
printf("\r--This is ge bitblt operation using dither function.\n");
@@ -232,10 +237,11 @@ static void ge_dither_test(int argc, char **argv)
struct ge_buf *dst_buffer = NULL;
struct bmp_header bmp_head = {0};
const char sopts[] = "uhs:d:o:";
const char sopts[] = "uhs:d:o:i:";
const struct option lopts[] = {
{"usage", no_argument, NULL, 'u'},
{"help", no_argument, NULL, 'h'},
{"src_input" , required_argument, NULL, 'i'},
{"src_format", required_argument, NULL, 's'},
{"dst_format", required_argument, NULL, 'd'},
{"dither_on", required_argument, NULL, 'o'},
@@ -246,6 +252,9 @@ static void ge_dither_test(int argc, char **argv)
optind = 0;
while ((ret = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
switch (ret) {
case 'i':
strncpy(g_src_input, optarg, sizeof(g_src_input) - 1);
break;
case 's':
src_format = str_to_format(optarg);
if (src_format < 0) {
@@ -287,9 +296,9 @@ static void ge_dither_test(int argc, char **argv)
fb_info = fb_open();
bmp_fd = bmp_open(DITHER_IMAGE, &bmp_head);
bmp_fd = bmp_open(g_src_input, &bmp_head);
if (bmp_fd < 0) {
LOGE("open bmp error, path = %s\n", DITHER_IMAGE);
LOGE("open bmp error, path = %s\n", g_src_input);
goto EXIT;
}
@@ -346,6 +355,7 @@ static void ge_dither_test(int argc, char **argv)
fb_start_and_wait(fb_info);
fb_swap_frame(fb_info);
printf("ge dither test success\n");
EXIT:
if (bmp_fd > 0)
bmp_close(bmp_fd);

View File

@@ -18,8 +18,6 @@
#include "./public/ge_fb.h"
#include "./public/ge_mem.h"
#define DITHER_IMAGE "/sdcard/ge_test/image/singer_alpha.bmp"
/* format conversion type */
#define RGB_TO_RGB 0
#define RGB_TO_YUV 1
@@ -42,13 +40,19 @@ struct StrToFormat {
static int table_size = 0;
static struct StrToFormat *format_table = NULL;
static char g_src_input[128] = {"/sdcard/ge_test/image/singer_alpha.bmp"};
static void usage(char *app)
{
printf("Usage: %s [Options]: \n", app);
printf("\t-m, --mode, select format conversion type (default rgbtorgb), \n"
"\tFormat conversion supports rgbtorgb, yuvtoyuv, yuvtorgb and rgbtoyuv.\n");
printf("\t-i --input_src, input src\n");
printf("\t-u, --usage\n");
printf("\t-h, --help to see more\n\n");
printf("\tfor example:\n");
printf("\tge_format -i singer_alpha.bmp\n");
}
static void help(void)
@@ -374,16 +378,20 @@ int ge_format_test(int argc, char **argv)
struct ge_fb_info *fb_info = NULL;
/* parameter supports settings */
const char sopts[] = "uhm:";
const char sopts[] = "uhm:i:";
const struct option lopts[] = {
{"usage", no_argument, NULL, 'u'},
{"help", no_argument, NULL, 'h'},
{"mode", required_argument, NULL, 'm'},
{"src_input" , required_argument, NULL, 'i'},
{0, 0, 0, 0}
};
optind = 0;
while ((ret = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
switch (ret) {
case 'i':
strncpy(g_src_input, optarg, sizeof(g_src_input) - 1);
break;
case 'm':
mode = str_to_mode(optarg);
if (mode < 0) {
@@ -411,9 +419,9 @@ int ge_format_test(int argc, char **argv)
fb_info = fb_open();
bmp_fd = bmp_open(DITHER_IMAGE, &bmp_head);
bmp_fd = bmp_open(g_src_input, &bmp_head);
if (bmp_fd < 0) {
LOGE("open bmp error, path = %s\n", DITHER_IMAGE);
LOGE("open bmp error, path = %s\n", g_src_input);
goto EXIT;
}
@@ -437,6 +445,8 @@ int ge_format_test(int argc, char **argv)
LOGE("format_conver_run task failed\n");
goto EXIT;
}
printf("ge fmt converse test success\n");
EXIT:
if (bmp_fd > 0)
bmp_close(bmp_fd);

View File

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -18,8 +18,6 @@
#include "./public/ge_fb.h"
#include "./public/ge_mem.h"
#define SCALE_IMAGE "/sdcard/ge_test/image/scale.bmp"
#define LOGE(fmt, ...) aic_log(AIC_LOG_ERR, "E", fmt, ##__VA_ARGS__)
#define LOGW(fmt, ...) aic_log(AIC_LOG_WARN, "W", fmt, ##__VA_ARGS__)
#define LOGI(fmt, ...) aic_log(AIC_LOG_INFO, "I", fmt, ##__VA_ARGS__)
@@ -31,14 +29,20 @@
#define ONE_PIXEL 1.0
static char g_src_input[128] = {"/sdcard/ge_test/image/scale.bmp"};
static void usage(char *app)
{
printf("Usage: %s [Options]: \n", app);
printf("\t --Framebuffer uses double buffer in this test, ensure that fb0 is properly configure\n\n");
printf("\t-i --input_src, input src\n");
printf("\t-t, --type, Select scale type (default 2)\n");
printf("\t --type, 0: wide stretch, 1: height stretch, 2: width and height stretch\n\n");
printf("\t-u, --usage\n");
printf("\tfor example:\n");
printf("\tge_scale -i scale.bmp\n");
}
static long long int str2int(char *_str)
@@ -332,15 +336,19 @@ static void scale_test(int argc, char **argv)
struct ge_buf *dst_buffer = NULL;
struct bmp_header bmp_head = {0};
const char sopts[] = "ut:";
const char sopts[] = "ut:i:";
const struct option lopts[] = {
{"usage", no_argument, NULL, 'u'},
{"type", required_argument, NULL, 't'},
{"src_input" , required_argument, NULL, 'i'},
{0, 0, 0, 0}
};
optind = 0;
while ((ret = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
switch (ret) {
case 'i':
strncpy(g_src_input, optarg, sizeof(g_src_input) - 1);
break;
case 't':
scale_type = str2int(optarg);
if ((scale_type > 2) || (scale_type < 0)) {
@@ -365,9 +373,9 @@ static void scale_test(int argc, char **argv)
fb_info = fb_open();
bmp_fd = bmp_open(SCALE_IMAGE, &bmp_head);
bmp_fd = bmp_open(g_src_input, &bmp_head);
if (bmp_fd < 0) {
LOGE("open bmp error, path = %s\n", SCALE_IMAGE);
LOGE("open bmp error, path = %s\n", g_src_input);
goto EXIT;
}
@@ -399,6 +407,7 @@ static void scale_test(int argc, char **argv)
goto EXIT;
}
printf("ge scale test success\n");
EXIT:
if (bmp_fd > 0)
bmp_close(bmp_fd);

View File

@@ -28,12 +28,12 @@
#define STRAIGHT_RIGHT 6
#define DIRECTLY_BELOW 7
#define SCAN_IMAGE "/sdcard/ge_test/image/scan_order.bmp"
#define LOGE(fmt, ...) aic_log(AIC_LOG_ERR, "E", fmt, ##__VA_ARGS__)
#define LOGW(fmt, ...) aic_log(AIC_LOG_WARN, "W", fmt, ##__VA_ARGS__)
#define LOGI(fmt, ...) aic_log(AIC_LOG_INFO, "I", fmt, ##__VA_ARGS__)
static char g_src_input[128] = {"/sdcard/ge_test/image/scan_order.bmp"};
static void usage(char *app)
{
printf("Usage: %s [Options]: \n", app);
@@ -43,9 +43,13 @@ static void usage(char *app)
printf("\t --mode=1 scan order flags = MPP_RL_TB\n");
printf("\t --mode=2 scan order flags = MPP_LR_BT\n");
printf("\t --mode=3 scan order flags = MPP_RL_BT\n");
printf("\t-i --input_src, input src\n");
printf("\t-u, --usage\n");
printf("\t-h, --help\n\n");
printf("\tfor example:\n");
printf("\tge_scan_order -i scan_order.bmp\n");
}
static void help(void)
@@ -261,10 +265,11 @@ static void ge_scan_test(int argc, char **argv)
struct ge_buf *buffer = NULL;
struct bmp_header bmp_head = {0};
const char sopts[] = "uhr:m:";
const char sopts[] = "uhr:m:i:";
const struct option lopts[] = {
{"usage", no_argument, NULL, 'u'},
{"help", no_argument, NULL, 'h'},
{"src_input" , required_argument, NULL, 'i'},
{"region", required_argument, NULL, 'r'},
{"mode", required_argument, NULL, 'm'},
{0, 0, 0, 0}
@@ -273,6 +278,9 @@ static void ge_scan_test(int argc, char **argv)
optind = 0;
while ((ret = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
switch (ret) {
case 'i':
strncpy(g_src_input, optarg, sizeof(g_src_input) - 1);
break;
case 'r':
region = str2int(optarg);
if (region < 0 || region > 7) region=0;
@@ -301,9 +309,9 @@ static void ge_scan_test(int argc, char **argv)
fb_info = fb_open();
bmp_fd = bmp_open(SCAN_IMAGE, &bmp_head);
bmp_fd = bmp_open(g_src_input, &bmp_head);
if (bmp_fd < 0) {
LOGE("open bmp error, path = %s\n", SCAN_IMAGE);
LOGE("open bmp error, path = %s\n", g_src_input);
goto EXIT;
}
@@ -337,6 +345,7 @@ static void ge_scan_test(int argc, char **argv)
goto EXIT;
}
printf("ge scan order test success\n");
EXIT:
if (bmp_fd > 0)
bmp_close(bmp_fd);