diff options
author | Yang Wei <yangweix.shui@intel.com> | 2015-03-17 09:19:01 +0800 |
---|---|---|
committer | Yi Sun <yi.sun@intel.com> | 2015-03-17 09:19:01 +0800 |
commit | 9807660ec6cda254b748cce000a871fb54376f76 (patch) | |
tree | ba8abc60e92c154def3de78f85a16d5723b83ddd | |
parent | 0f23d3ae6450c819de8f9b05fb271a43f11c1233 (diff) |
update judgement for vtview -l, -n image could use absolute
Signed-off-by: Yi Sun <yi.sun@intel.com>
-rw-r--r-- | tools/vtview.c | 71 |
1 files changed, 56 insertions, 15 deletions
diff --git a/tools/vtview.c b/tools/vtview.c index 929b0ea..c46b767 100644 --- a/tools/vtview.c +++ b/tools/vtview.c @@ -76,7 +76,7 @@ struct termios saved_tio; drmModeRes *resources; int drm_fd, modes; -int test_all_modes = 0, test_preferred_mode = 0; +int test_all_modes = 0, test_preferred_mode = 0, test_set_image = 0; char *image_name; unsigned int tiling = I915_TILING_X; //tiling = I915_TILING_NONE; @@ -191,10 +191,26 @@ static void paint_output_info(struct connector *c, struct igt_fb *fb, char *imag double max_width; int i; char * img_addr=NULL; - char * separator="/"; + //char * separator="/"; + char _cwd[100]; + if(getcwd(_cwd,sizeof(_cwd)) == NULL) + perror("getcwd error"); if(!image) image="pass.png"; - img_addr=str_contact(IGT_DATADIR,separator,image); + + if(!access(image,0)) { + img_addr = (char*)malloc(strlen(image) + 1); + strcpy(img_addr, image); + } + else if(strchr(image,'/') != 0) { + img_addr = (char*)malloc(strlen(image) + strlen(_cwd) + 1); + strcpy(img_addr, _cwd); + strcat(img_addr, strchr(image,'/')); + } + //else + // img_addr=str_contact(IGT_DATADIR,separator,image); + + //printf("img_addr: %s \n ",img_addr); paint_image(cr, img_addr, &isl); free(img_addr); @@ -214,14 +230,14 @@ set_mode(struct connector *c) if (test_all_modes) test_mode_num = c->connector->count_modes; - - width = c->mode.hdisplay; height = c->mode.vdisplay; - if(!isl.img_y) isl.img_y = height * (0.1 ); - if(!isl.img_h) isl.img_h = height * 0.08 * 4; - if(!isl.img_w) isl.img_w = isl.img_h; - if(!isl.img_x) isl.img_x = (width / 2) - (isl.img_w / 2); + if(!test_set_image) { + isl.img_y = height * (0.1); + isl.img_h = height * 0.08 * 4; + isl.img_w = isl.img_h; + isl.img_x = (width / 2) - (isl.img_w / 2); + } fb_id = igt_create_fb(drm_fd, width, height, igt_bpp_depth_to_drm_format(bpp, depth), @@ -321,8 +337,8 @@ static void __attribute__((noreturn)) usage(char *name, char opt) igt_info("\t-r\tprint a QR code on the screen whose content is \"pass\" for the automatic test\n"); igt_info("\t-o\t<id of the display>,<number of the mode>\tonly test specified mode on the specified display\n"); igt_info("\t-f\t<clock MHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n"); - igt_info("\t-l\t<num,num,num,num>, set image size and location\n"); - igt_info("\t-n\timage name located at tools/\n"); + igt_info("\t-l\t<x-axis,y-axis,width,height>, set image size and location, width and height can not be 0\n"); + igt_info("\t-n\timage name located at tools/, e.g. %s -n pass.png\n", name); igt_info("\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n"); igt_info("\t\ttest force mode\n"); igt_info("\tDefault is to test all modes.\n"); @@ -407,6 +423,8 @@ int main(int argc, char **argv) }; char delims[] = ","; char *result = NULL; + char *data[10]; + int i=0; // igt_skip_on_simulation(); @@ -436,11 +454,34 @@ int main(int argc, char **argv) test_preferred_mode = 1; break; case 'l': + test_set_image = 1; result=strtok(optarg,delims); - isl.img_y = atoi(result); - isl.img_h = atoi(strtok(NULL,delims)); - isl.img_w = atoi(strtok(NULL,delims)); - isl.img_x = atoi(strtok(NULL,delims)); + strcpy(&data[i],result); + while(result) + { + if(i >= 4) { + printf("More than four values, %s -l x-axis,y-axis,width,height\n",argv[0]); + exit(EXIT_FAILURE); + } + ++i; + result=strtok(NULL,delims); + if(!result && i < 4) { + printf("Less than four values, %s -l x-axis,y-axis,width,height\n",argv[0]); + exit(EXIT_FAILURE); + } + if(result) { + if (strcmp(result,"0") == 0 && i >= 2) { + printf("%s -l x-axis,y-axis,weight,height, width and height can not be 0!\n", argv[0]); + exit(EXIT_FAILURE); + } + + strcpy(&data[i],result); + } + } + isl.img_x = atoi(&data[0]); + isl.img_y = atoi(&data[1]); + isl.img_w = atoi(&data[2]); + isl.img_h = atoi(&data[3]); break; case 'n': |