void IL_ClientFbDevAppTask (void *threadsArg) { struct fb_fix_screeninfo fixinfo; struct fb_var_screeninfo varinfo, org_varinfo; struct ti81xxfb_region_params regp, oldregp; int32_t display_fd; //struct timeval before, after, result; int32_t ret = 0; int32_t buffersize; int32_t i; uint8_t *buffer_addr[MAX_BUFFER]; int32_t dummy; IL_CLIENT_GFX_PRIVATE *pGfxData = NULL; pGfxData = (IL_CLIENT_GFX_PRIVATE *) threadsArg; alpha = 80; if (0 == pGfxData->gfxId) { /*As Gfx node is 0 is chosen FB0 is to be opened*/ display_fd = open (display_dev_name_fb0, O_RDWR); } else { /*As Gfx node is 1 is chosen FB1 is to be opened*/ display_fd = open (display_dev_name_fb1, O_RDWR); } if (display_fd <= 0) { perror ("Could not open device\n"); return; } /* Get fix screen information. Fix screen information gives * fix information like panning step for horizontal and vertical * direction, line length, memory mapped start address and length etc. */ if (get_fixinfo (display_fd, &fixinfo)) { goto exit1; } /* Get variable screen information. Variable screen information * gives informtion like size of the image, bites per pixel, * virtual size of the image etc. */ if (get_varinfo (display_fd, &varinfo)) { goto exit1; } memcpy (&org_varinfo, &varinfo, sizeof (varinfo)); if (get_regparams (display_fd, ®p)) { goto exit1; } if (0 == pGfxData->gfxId) { /*Setting the Colorbar window size to smaller than the 1080P size*/ varinfo.xres = 1280; varinfo.yres = 720; } else { /*Setting the Colorbar window size to smaller than the LCD screen size*/ varinfo.xres = 530; varinfo.yres = 320; } varinfo.xres_virtual = varinfo.xres; varinfo.yres_virtual = varinfo.yres * 2; /* set the ARGB8888 format */ varinfo.red.length = varinfo.green.length = varinfo.blue.length = varinfo.transp.length = 8; varinfo.red.msb_right = varinfo.blue.msb_right = varinfo.green.msb_right = varinfo.transp.msb_right = 0; varinfo.red.offset = 16; varinfo.green.offset = 8; varinfo.blue.offset = 0; varinfo.transp.offset = 24; varinfo.bits_per_pixel = 32; ret = ioctl (display_fd, FBIOPUT_VSCREENINFO, &varinfo); if (ret < 0) { perror ("Error setting variable information.\n"); goto exit1; } if (get_varinfo (display_fd, &varinfo)) { goto exit2; } if (get_fixinfo (display_fd, &fixinfo)) { goto exit2; } if (get_regparams (display_fd, ®p)) { goto exit2; } oldregp = regp; /* Mmap the driver buffers in application space so that application can write on to them. Driver allocates contiguous memory for three buffers. These buffers can be displayed one by one. */ buffersize = fixinfo.line_length * varinfo.yres; buffer_addr[0] = (unsigned char *) mmap (0, buffersize * MAX_BUFFER, (PROT_READ | PROT_WRITE), MAP_SHARED, display_fd, 0); if ((int32_t) buffer_addr[0] == -1) { printf ("MMap Failed.\n"); goto exit3; } /* Store each buffer addresses in the local variable. These buffer addresses can be used to fill the image. */ for (i = 1; i < MAX_BUFFER; i++) { buffer_addr[i] = buffer_addr[i - 1] + buffersize; } /* fill buffer with color bar pattern */ for (i = 0; i < MAX_BUFFER; i++) { fill_color_bar (buffer_addr[i], fixinfo.line_length, varinfo.yres); } i = 0; while (1) { ret = ioctl (display_fd, FBIOGET_VSCREENINFO, &varinfo); if (ret < 0) { perror ("ger varinfo failed.\n"); break; } if (i % 128 == 0) { if (regp.blendtype == TI81XXFB_BLENDING_NO) { regp.blendtype = TI81XXFB_BLENDING_PIXEL; } else { regp.blendtype = TI81XXFB_BLENDING_NO; } ret = ioctl (display_fd, TIFB_SET_PARAMS, ®p); if (ret < 0) { perror ("can not set params.\n"); break; } } ret = ioctl (display_fd, FBIO_WAITFORVSYNC, &dummy); if (ret < 0) { perror ("wait vsync failed.\n"); break; } i++; if (pGfxData->terminateGfx) { break; } } munmap (buffer_addr[0], buffersize * MAX_BUFFER); exit3: ret = ioctl (display_fd, TIFB_SET_PARAMS, &oldregp); if (ret < 0) { perror ("Error set reg params.\n"); } exit2: ret = ioctl (display_fd, FBIOPUT_VSCREENINFO, &org_varinfo); if (ret < 0) { perror ("Error reading variable information.\n"); } exit1: close (display_fd); pGfxData->terminateDone = 1; pthread_exit (threadsArg); } /* IL_ClientFbDevAppTask */
/* * Displays color bar to Fbdev buffer */ void st_fbdev_create_color_bar(unsigned int line_length, unsigned int height, unsigned int bits_per_pixel, unsigned char* buf_addr) { /* Fill the buffers with the color bars */ fill_color_bar(buf_addr, line_length, height, bits_per_pixel); }
/* * Function to display image (either from raw file or color bar[default]) * of given width*height on the selected output */ int st_fbdev_display_test(struct fbdev_display_testparams *params) { int i, ret, status = SUCCESS; unsigned char* buf_addr; unsigned int cpu_load; struct proc_stat cpuload; struct timeval before, after, result; /* Open the device */ ret = st_fbdev_open_interface(params->device_name, ¶ms->fd); if (ret != SUCCESS) return ret; /* Enable window */ ret = st_fbdev_blank_interface(params->fd, VESA_NO_BLANKING); if (ret) { status = FAILURE; goto exit; } TEST_PRINT_TRC("FBIO_BLANK Ioctl passed"); /* put variable screen info */ ret = st_fbdev_put_vscreeninfo_interface(params->fd, ¶ms->var); if (ret) { status = FAILURE; goto exit; } TEST_PRINT_TRC("FBIOPUT_VSCREENINFO Ioctl passed"); /* get fix screen info */ ret = st_fbdev_get_fscreeninfo_interface(params->fd, ¶ms->fix); if (ret) { status = FAILURE; goto exit; } TEST_PRINT_TRC("FBIOGET_FSCREENINFO Ioctl Passed"); /* map vid0 buffers to user space */ ret = st_fbdev_mmap_interface(params->fd, params->fix.line_length, params->var.yres_virtual, &buf_addr); if (ret) { status = FAILURE; goto exit; } TEST_PRINT_TRC("mmap Ioctl passed"); /* If CPU load requested */ if (params->cpuload == TRUE) start_cpuload_measurement(&cpuload); if (params->framerate == TRUE) gettimeofday(&before, NULL); /* Create color bar pattern */ for (i = 0; i < params->loopcount; i++) { fill_color_bar(buf_addr, params->fix.line_length, params->var.yres, params->var.bits_per_pixel); sleep(1); fill_reverse_color_bar(buf_addr, params->fix.line_length, params->var.yres, params->var.bits_per_pixel); sleep(1); } /* unmap buffers */ ret |= st_fbdev_unmap_interface(params->fd, params->fix.line_length, params->var.yres_virtual, buf_addr); if (params->framerate == TRUE) { gettimeofday(&after, NULL); calc_result_time(&result, &after, &before); TEST_PRINT_TRC("The Fbdev Display : Frame rate = %lu", params->loopcount/result.tv_sec); } /* If CPU load requested */ if(params->cpuload == TRUE) { cpu_load = stop_cpuload_measurement(&cpuload); TEST_PRINT_TRC("The Fbdev Display : Percentage CPU Load = %u%%", cpu_load); } exit: /* close FBDEV device */ ret |= st_fbdev_close_interface(params->device_name, ¶ms->fd); if (ret) status = FAILURE; /* print status of the test case */ st_fbdev_display_test_status(status, params->testcase_id); /* end test case */ TEST_PRINT_TST_END(params->testcase_id); return ret; }