/* * This function does the display of color bars */ int st_v4l2_display_color_bar_userptr(int dev, int noframes, struct v4l2_format *st_fmt, struct v4l2_buffer *st_buf, int buffer_size, int pixelfmt) { int retVal = SUCCESS; int counter = 0; unsigned int cpu_load; struct timeval before, after, result; struct proc_stat cpuload; start_cpuload_measurement(&cpuload); gettimeofday(&before, NULL); for (counter = 0; counter < noframes; counter++) { retVal = ioctl(dev, VIDIOC_DQBUF, st_buf); if (SUCCESS > retVal) { perror("VIDIOC_DQBUF"); return retVal; } /* putting moving color bars */ colorbar_generate((void *)buffer_addr[st_buf->index], st_fmt->fmt.pix.width, st_fmt->fmt.pix.height, counter%(st_fmt->fmt.pix.height/2), pixelfmt); /* Now queue it back to display it */ st_buf->index = st_buf->index; st_buf->m.userptr = buffer_addr[st_buf->index]; st_buf->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; st_buf->memory = V4L2_MEMORY_USERPTR; st_buf->length = buffer_size; retVal = ioctl(dev, VIDIOC_QBUF, st_buf); if (SUCCESS > retVal) { perror("VIDIOC_QBUF"); return retVal; } } gettimeofday(&after, NULL); timeval_subtract(&result, &after, &before); TEST_PRINT_TRC("Calculated Frame Rate:\t%ld Fps", noframes/result.tv_sec); cpu_load = stop_cpuload_measurement(&cpuload); TEST_PRINT_TRC("The V4L2 Display : Percentage CPU Load = %u%%", cpu_load); return retVal; }
/* * Closes FBDEV device */ int st_fbdev_close_interface(char *name, int *fd) { int ret; ret = close(*fd); if (0 != ret) { TEST_PRINT_TRC("%s: ", name); perror("Close: "); return ret; } *fd = -1; TEST_PRINT_TRC("FBDEV %s device closed", name); return SUCCESS; }
/* * This function implements the enum fmt ioctl */ int st_v4l2_display_enum_fmt(int dev, struct v4l2_fmtdesc *fmtdesc) { int retVal = SUCCESS; int i = 0; while (1) { fmtdesc->index = i; retVal = ioctl(dev, VIDIOC_ENUM_FMT, fmtdesc); if (retVal < 0) { perror("VIDIOC_ENUM_FMT"); break; return retVal; } TEST_PRINT_TRC("description = %s\n", fmtdesc->description); if (fmtdesc->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) TEST_PRINT_TRC("Video Display type\n"); if (fmtdesc->pixelformat == V4L2_PIX_FMT_UYVY) TEST_PRINT_TRC("V4L2_PIX_FMT_UYVY\n"); i++; } return retVal; }
/* * This function get the control */ int st_v4l2_get_control(int dev, struct v4l2_control *st_control) { int retVal = SUCCESS; retVal = ioctl(dev, VIDIOC_G_CTRL, st_control); if (retVal < 0) { perror("VIDIOC_S_CTRL"); return retVal; } TEST_PRINT_TRC("The control value set to = %d", st_control->value); return retVal; }
/* * Help/Usage instructions * * Help is broken down into two layers, Standard and Custom (Platform specific). */ void st_display_fbdev_display_test_suite_help(struct fbdev_display_testparams *options) { printf("FbdevDisplayTestSuite V %s\n", VERSION_STRING); printf("Usage:\n" "./fbdev_display_tests <options>\n\n" "-device Device name on which display test is to be run\n" "\t\t\tPossible values-/dev/fb0,/dev/fb1\n" "-width Width of the image to be displayed\n" "-height Height of the image to be displayed\n" "-virtual_width Virtual Width of the image to be displayed\n" "-virtual_height Virtual Height of the image to be displayed\n" "-bits_per_pixel Pixel Format\n" "-grayscale Grey scale\n" "-left Left Margin\n" "-right Right Margin\n" "-lower Lower Margin\n" "-upper Upper Margin\n" "-hsynclen Hsync len\n" "-vsynclen Vsync len\n" "-rgba Color depth and offset [< r,g,b,a>]\n" "-colorkey Colorkeying testing\n" "-alphablend Alpha blending testcase\n" "-pan Double buffering [<xoffset,yoffset>]\n" "\t\t\t Syntax - rL/rO,gL/gO,bL/bO,tL/tO or rL,gL,bL,tL]\n" "-rotate Rotation angle [Note: Check support for rotation]\n" "\t\t\tPossible values- 0, 90, 180, 270\n" "-file Name of the BMP image file to display\n" "\t\t\t Make sure the file is as per -w(width),-h(height)" " configured with valid pixel format\n" "-loop Number of times to run loop for ioctl test\n" "-ioctl IOCTL number\n" "\t\t\tPossible values-0:getVscreenInfo , 1:putVscreenInfo " "2:getFscreenInfo 3: blank 4:getCmap 5:putCmap \n" "\t\t\t Note: Also check custom ioctl support below\n" "-id Test case id string for logging purpose\n" "-framerate Displays the frame rate in fps(frames per sec)\n" "-help Displays the help\n" "-version Displays the version of LFTB package\n" "-cpuload Displays the cpu load in percenatge\n"); TEST_PRINT_TRC("Custom (Platform Specific) Fbdev Configuration help\n"); /* Platform specific Help */ if (options->pfunc.help) options->pfunc.help(); exit(0); }
/* * This function implements the QUERYCAP ioctl */ int st_v4l2_display_querycap(int dev, struct v4l2_capability *capability) { int retVal = SUCCESS; retVal = ioctl(dev, VIDIOC_QUERYCAP, capability); if (retVal < 0) { perror("VIDIOC_QUERYCAP"); return retVal; } if (capability->capabilities & V4L2_CAP_VIDEO_OUTPUT) { TEST_PRINT_TRC("Display capability is supported"); } else { TEST_PRINT_TRC("Display capability is not supported"); } if (capability->capabilities & V4L2_CAP_STREAMING) { TEST_PRINT_TRC("Streaming is supported"); } else { TEST_PRINT_TRC("Streaming is not supported"); } return retVal; }
/* * This function implements scaling */ int st_v4l2_display_set_scaling(int dev, struct v4l2_format *st_fmt, struct v4l2_crop *st_crop) { int retVal = SUCCESS; retVal = ioctl(dev, VIDIOC_S_FMT, st_fmt); if (retVal < 0) { perror("VIDIOC_S_FMT"); return retVal; } retVal = ioctl(dev, VIDIOC_S_CROP, st_crop); if (retVal < 0) { perror("VIDIOC_S_CROP"); return retVal; } TEST_PRINT_TRC("The zoom height of the image | %d", st_crop->c.height); TEST_PRINT_TRC("The zoom width of the image | %d", st_crop->c.width); TEST_PRINT_TRC("The zoom top of the image | %d", st_crop->c.top); TEST_PRINT_TRC("The zoom left of the image | %d", st_crop->c.left); return retVal; }
/* * Opens FBDEV device */ int st_fbdev_open_interface(char *name, int *fd) { int ret; ret = open(name, O_RDWR); if (ret <= 0) { perror("Open: "); return ret; } *fd = ret; TEST_PRINT_TRC("FBDEV %s device opened", name); return SUCCESS; }
/* * Fill up buffer with vertical color bars. */ void fill_color_bar_vertical(unsigned char *addr, int width, int height, unsigned int bits_per_pixel) { int i, j, k; switch (bits_per_pixel) { case 16: { unsigned short *start = (unsigned short*) addr; for (j = 0; j < height / 2; j++) { for (i = 0; i < 8; i++) { for (k = 0; k < width / 8; k++) { *start = rgb565[0][i]; start++; } } } } break; case 24: case 32: { unsigned int *start = (unsigned int*) addr; for (j = 0; j < height / 2; j++) { for (i = 0; i < 8; i++) { for (k = 0; k < width / 8; k++) { *start = rgb888[0][i]; start++; } } } } break; default: TEST_PRINT_TRC("Invalid bpp"); break; } }
/* * Create color bar pattern and swap it after every 1 sec */ void fill_reverse_color_bar(unsigned char *addr, unsigned int line_length, unsigned int height, unsigned int bits_per_pixel) { int i, j, k; switch (bits_per_pixel) { case 16: { unsigned short *start = (unsigned short*) addr; for (i = 0; i < 8; i++) { for(j = 0 ; j < (height / 8) ; j++) { for (k = 0; k < (line_length/2); k++) start[k] = rgb565[1][i]; start += (line_length/2); } } } break; case 24: case 32: { unsigned int *start = (unsigned int*) addr; for(i = 0 ; i < 8 ; i++) { for(j = 0 ; j < (height / 8) ; j++) { for(k = 0 ; k < (line_length/4); k++) start[k] = rgb888[1][i]; start += (line_length/4); } } } break; default: TEST_PRINT_TRC("Invalid bpp"); break; } }
static int calc_result_time(struct timeval *result, struct timeval *after, struct timeval *before) { TEST_PRINT_TRC("After=$after Before=$before"); /* Perform the carry for the later subtraction by updating "before" */ if (after->tv_usec < before->tv_usec) { int nsec = (before->tv_usec - after->tv_usec) / 1000000 + 1; before->tv_usec -= 1000000 * nsec; before->tv_sec += nsec; } if (after->tv_usec - before->tv_usec > 1000000) { int nsec = (after->tv_usec - before->tv_usec) / 1000000; before->tv_usec += 1000000 * nsec; before->tv_sec -= nsec; } /* Compute the time remaining to wait, tv_usec is certainly positive. * */ result->tv_sec = after->tv_sec - before->tv_sec; result->tv_usec = after->tv_usec - before->tv_usec; /* Return 1 if result is negative. */ return after->tv_sec < before->tv_sec; }
/* * Function - st_filesystem_performance_read_test * Functionality - This function recieves the test params and read * from the file * Input Params - info,test_id * Return Value - 0: SUCCESS, -1: FAILURE * Note - None */ int st_filesystem_performance_read_test(struct st_filesystem_testparams *info, char *test_id) { int fdes = 0; int result = SUCCESS; int res_close = SUCCESS; char *buff_ptr = NULL; char *file_ptr = NULL; int i = 0; int read_ret = 0; int bsize = 0; int totalsize = 0; int loopcount = 0; int remainder = 0; int totbytread = 0; struct timeval start_time; unsigned long elapsed_usecs = 0; struct proc_stat cpu_status_id; float percentage_cpu_load = 0; float throughput = 0; file_ptr = info->filename; totalsize = info->file_size * 1024 * 1024; bsize = info->buffer_size; loopcount = totalsize / bsize; remainder = totalsize % bsize; /* Allocate memory for the buff_ptr, size = bsize */ buff_ptr = (char *)malloc(bsize * (sizeof(char))); if (NULL == buff_ptr) { perror("\n malloc"); result = FAILURE; goto end; } /* Perform the read operation */ fdes = open((const char *)file_ptr, O_RDONLY); if (-1 == fdes) { perror("\n open"); TEST_PRINT_ERR("file open failed "); result = FAILURE; goto free_mem; } if (info->cpuload_flag) { /* Start CPU Load calcaulation */ start_cpuload_measurement(&cpu_status_id); } if (info->throughput_flag) { /* Start Timer */ start_timer(&start_time); } for (i = 0; i < loopcount; i++) { read_ret = read(fdes, buff_ptr, bsize); totbytread = totbytread + read_ret; if (bsize != read_ret) { perror("\n read"); TEST_PRINT_ERR("file read failed "); result = FAILURE; goto close_file; } } if (remainder) { read_ret = read(fdes, buff_ptr, remainder); totbytread = totbytread + read_ret; if (remainder != read_ret) { perror("\n read"); TEST_PRINT_ERR("file read failed "); result = FAILURE; goto close_file; } } close_file: res_close = fsync(fdes); if (-1 == res_close) { perror("\n fsync"); TEST_PRINT_ERR("file fsync failed "); result = FAILURE; } if (info->throughput_flag && result == SUCCESS) { /* Stop the Timer and get the usecs elapsed */ elapsed_usecs = stop_timer(&start_time); throughput = (float)(((float)totalsize / (float)elapsed_usecs)); TEST_PRINT_TRC("fileread | Durartion in usecs | %ld", elapsed_usecs); TEST_PRINT_TRC("fileread | Mega Bytes/Sec | %lf",throughput); } if (info->cpuload_flag && result == SUCCESS) { /* Get CPU Load figures */ percentage_cpu_load = stop_cpuload_measurement(&cpu_status_id); if ((percentage_cpu_load >= 0) && (percentage_cpu_load <= 100)) TEST_PRINT_TRC ("fileread | percentage cpu load | %.2f%%", percentage_cpu_load); } res_close = close(fdes); if (-1 == res_close) { perror("\n close"); TEST_PRINT_ERR("file close failed "); result = FAILURE; } TEST_PRINT_TRC("|PERFDATA|bsize:%d|iomode:read|throughput:%.2lfMB/S|cpuload:%.2f%%|", bsize, throughput, percentage_cpu_load); free_mem: /* Free memory for the buff_ptr */ if (NULL != buff_ptr) { free(buff_ptr); } end: return result; }
/* * 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; }
/* 2 DMA Channels Chained, Mem-2-Mem Copy, A-SYNC Mode, INCR Mode */ int kSt_edma_memtomemcpytest_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue) { int result = 0; unsigned int dma_ch1 = 0; unsigned int dma_ch2 = 0; unsigned int tcc1 = ST_EDMA_TCC_ANY; unsigned int tcc2 = ST_EDMA_TCC_ANY; int i; int count = 0; unsigned int Istestpassed1 = 0u; unsigned int Istestpassed2 = 0u; unsigned int numenabled = 0; unsigned int BRCnt = 0; int srcbidx = 0; int desbidx = 0; int srccidx = 0; int descidx = 0; st_edma_param_set param_set; s32 trial =0; for (trial = 0; trial <= MAX_TRIALS; trial++) { /* Initalize source and destination buffers */ for (count = 0u; count < (acnt * bcnt * ccnt); count++) { dmabufsrc1[count] = 'A' + (count % 26); dmabufdest1[count] = 0; dmabufsrc2[count] = 'A' + (count % 26); dmabufdest2[count] = 0; } /* Set B count reload as B count. */ BRCnt = bcnt; /* Setting up the SRC/DES Index */ srcbidx = acnt; desbidx = acnt; if (sync_mode == ASYNC) { /* A Sync Transfer Mode */ srccidx = acnt; descidx = acnt; result = kSt_davinci_request_dma(ST_EDMA_CHANNEL_ANY, "A-SYNC_DMA0", kSt_callback1, NULL,&dma_ch1, &tcc1, event_queue); } else if (sync_mode == ABSYNC) { /* AB Sync Transfer Mode */ srccidx = acnt * bcnt; descidx = acnt * bcnt; result = kSt_davinci_request_dma(ST_EDMA_CHANNEL_ANY, "AB-SYNC_DMA0", kSt_callback1, NULL,&dma_ch1, &tcc1, event_queue); } else { TEST_PRINT_ERR(" Invalid Transfer mode \n"); } if (FAILURE == result) { TEST_PRINT_ERR("edma_test_chain::davinci_request_dma failed for dma_ch1, error:%d", result); return result; } kSt_davinci_set_dma_src_params(dma_ch1, (unsigned long)(dmaphyssrc1), INCR, W8BIT); kSt_davinci_set_dma_dest_params(dma_ch1, (unsigned long)(dmaphysdest1), INCR, W8BIT); kSt_davinci_set_dma_src_index(dma_ch1, srcbidx, srccidx); kSt_davinci_set_dma_dest_index(dma_ch1, desbidx, descidx); if (sync_mode == ASYNC) { /* A Sync Transfer Mode */ kSt_davinci_set_dma_transfer_params(dma_ch1, acnt, bcnt, ccnt, BRCnt, ASYNC); } else if (sync_mode == ABSYNC) { /* AB Sync Transfer Mode */ kSt_davinci_set_dma_transfer_params(dma_ch1, acnt, bcnt, ccnt, BRCnt, ABSYNC); } else { TEST_PRINT_ERR (" Invalid Transfer mode \n"); } if (sync_mode == ASYNC) { /* Request Another DMA Channel */ result = kSt_davinci_request_dma(ST_EDMA_CHANNEL_ANY, "AB-SYNC_DMA0", kSt_callback2, NULL,&dma_ch2, &tcc2, event_queue); } else if (sync_mode == ABSYNC) { /* Request Another DMA Channel */ result = kSt_davinci_request_dma(ST_EDMA_CHANNEL_ANY, "AB-SYNC_DMA0", kSt_callback2, NULL,&dma_ch2, &tcc2, event_queue); } else { TEST_PRINT_ERR(" Invalid Transfer mode \n"); } if (FAILURE == result) { TEST_PRINT_ERR("edma_test_chain::davinci_request_dma failed for dma_ch2, error:%d", result); kSt_davinci_free_dma(dma_ch1); return result; } kSt_davinci_set_dma_src_params(dma_ch2, (unsigned long)(dmaphyssrc2), INCR, W8BIT); kSt_davinci_set_dma_dest_params(dma_ch2, (unsigned long)(dmaphysdest2), INCR, W8BIT); kSt_davinci_set_dma_src_index(dma_ch2, srcbidx, srccidx); kSt_davinci_set_dma_dest_index(dma_ch2, desbidx, descidx); if (sync_mode == ASYNC) { /* A Sync Transfer Mode */ kSt_davinci_set_dma_transfer_params(dma_ch2, acnt, bcnt, ccnt, BRCnt, ASYNC); } else if (sync_mode == ABSYNC) { /* AB Sync Transfer Mode */ kSt_davinci_set_dma_transfer_params(dma_ch2, acnt, bcnt, ccnt, BRCnt, ABSYNC); } else { TEST_PRINT_ERR(" Invalid Transfer mode \n"); } /* Chain both the channels */ /* Chain both the channels */ kSt_davinci_get_dma_params(dma_ch1, ¶m_set); param_set.opt |= (1 << TCCHEN_SHIFT); param_set.opt |= EDMA_TCC(EDMA_CHAN_SLOT(dma_ch2)); kSt_davinci_set_dma_params(dma_ch1, ¶m_set); /* Enable the Intermediate and Final Interrupts on Channel 1. * Also, Enable the Intermediate Chaining. */ kSt_davinci_get_dma_params(dma_ch1, ¶m_set); param_set.opt |= (1 << ITCCHEN_SHIFT); param_set.opt |= (1 << TCINTEN_SHIFT); param_set.opt |= (1 << ITCINTEN_SHIFT); kSt_davinci_set_dma_params(dma_ch1, ¶m_set); /* Enable the Intermediate and Final Interrupts on Channel 2 */ kSt_davinci_get_dma_params(dma_ch2, ¶m_set); param_set.opt |= (1 << TCINTEN_SHIFT); param_set.opt |= (1 << ITCINTEN_SHIFT); kSt_davinci_set_dma_params(dma_ch2, ¶m_set); if (sync_mode == ASYNC) { numenabled = bcnt * ccnt; } else if (sync_mode == ABSYNC) { numenabled = ccnt; } else { TEST_PRINT_ERR (" Invalid Transfer mode \n"); } for (i = 0; i < numenabled; i++) { irqraised2 = 0; /* Now enable the transfer for Master channel as many times * as calculated above. */ result = kSt_davinci_start_dma(dma_ch1); if (result != 0) { TEST_PRINT_ERR("edma_test_chain: kSt_davinci_start_dma failed "); kSt_davinci_stop_dma(dma_ch1); kSt_davinci_free_dma(dma_ch1); kSt_davinci_free_dma(dma_ch2); return result; } /* Transfer on the master channel (ch1Id) will finish after some * time. * Now, because of the enabling of intermediate chaining on channel * 1, after the transfer gets over, a sync event will be sent * to channel 2, which will trigger the transfer on it. * Also, Final and Intermediate Transfer Complete * Interrupts are enabled on channel 2, so we should wait for the * completion ISR on channel 2 first, before proceeding * ahead. */ while (irqraised2 == 0u) ; /* Check the status of the completed transfer */ if (irqraised2 < 0) { /* Some error occured, break from the FOR loop. */ TEST_PRINT_ERR("edma3_test_with_chaining: " "Event Miss Occured!!!"); break; } } /* Match the Source and Destination Buffers. */ for (i = 0; i < (acnt * bcnt * ccnt); i++) { if (dmabufsrc1[i] != dmabufdest1[i]) { TEST_PRINT_ERR("edma_test_chain(1): " "Data write-read matching failed at = %u",i); Istestpassed1 = 0u; result = -1; break; } } if (i == (acnt * bcnt * ccnt)) { Istestpassed1 = 1u; } for (i = 0; i < (acnt * bcnt * ccnt); i++) { if (dmabufsrc2[i] != dmabufdest2[i]) { TEST_PRINT_ERR("edma_test_chain(2): " "Data write-read matching failed at = %u",i); Istestpassed2 = 0u; result = -1; break; } } if (i == (acnt * bcnt * ccnt)) { Istestpassed2 = 1u; } kSt_davinci_stop_dma(dma_ch1); kSt_davinci_free_dma(dma_ch1); kSt_davinci_stop_dma(dma_ch2); kSt_davinci_free_dma(dma_ch2); } if ((Istestpassed1 == 1u) && (Istestpassed2 == 1u)) { DEBUG_PRINT("edma_test_chain: " "Transfer controller/event_queue: %d", event_queue); DEBUG_PRINT("edma_test_chain: " "Mode: %d 0 -> ASYNC, 1 -> ABSYNC", sync_mode); TEST_PRINT_TRC("edma_test_chain: " "EDMA Data Transfer Successfull on TC %d",event_queue); } else { TEST_PRINT_ERR("edma_test_chain: EDMA Data Transfer Failed"); } return result; }
/* * Function - st_filesystem_performance_copy_test * Functionality - This function recieves the test params and copies * from src to dst * Input Params - info,test_id * Return Value - 0: SUCCESS, -1: FAILURE * Note - None */ int st_filesystem_performance_copy_test(struct st_filesystem_testparams *info, char *test_id) { int srcfdes = 0; int dstfdes = 0; int result = SUCCESS; int res_close = SUCCESS; char *buff_ptr = NULL; char *srcfile_ptr = NULL; char *dstfile_ptr = NULL; int i = 0; int read_ret = 0; int write_ret = 0; int bsize = 0; int totalsize = 0; int loopcount = 0; int remainder = 0; int dstfileopenflag = 0; int srcfileopenflag = 0; struct timeval duration_starttime; struct timeval throughput_starttime; unsigned long elapsed_usecs = 0; unsigned long elapsed_secs = 0; float throughput = 0; int throughputcnt = 0; int res_integrity = 0; int copycnt = 0; srcfile_ptr = info->src; dstfile_ptr = info->dst; totalsize = info->file_size * 1024 * 1024; bsize = info->buffer_size; loopcount = totalsize / bsize; remainder = totalsize % bsize; /* Allocate memory for the buff_ptr, size = bsize */ buff_ptr = (char *)malloc(bsize * (sizeof(char))); if (NULL == buff_ptr) { perror("\n malloc"); result = FAILURE; goto end; } /* Get the currnt time for the duration */ start_timer(&duration_starttime); while(elapsed_secs < info->duration) { /* Open the files for copy operation */ srcfdes = open((const char *)srcfile_ptr, O_RDONLY); if (-1 == srcfdes) { perror("\n open"); TEST_PRINT_ERR("src file open failed "); result = FAILURE; srcfileopenflag = 1; goto free_mem; } dstfdes = open((const char *)dstfile_ptr, (O_WRONLY | O_CREAT)); if (-1 == dstfdes) { perror("\n open"); TEST_PRINT_ERR("dst file open failed "); result = FAILURE; dstfileopenflag = 1; goto free_mem; } if (info->throughput_flag) { /* Get the currnt time for the throughput */ start_timer(&throughput_starttime); } for (i = 0; i < loopcount; i++) { read_ret = read(srcfdes, buff_ptr, bsize); if (bsize != read_ret) { perror("\n read"); TEST_PRINT_ERR("file read failed "); result = FAILURE; goto free_mem; } write_ret = write(dstfdes, buff_ptr, bsize); if (bsize != write_ret) { perror("\n write"); TEST_PRINT_ERR("file write failed "); result = FAILURE; goto free_mem; } } if(remainder) { read_ret = read(srcfdes, buff_ptr, remainder); if (remainder != read_ret) { perror("\n read"); TEST_PRINT_ERR("file read failed "); result = FAILURE; goto free_mem; } write_ret = write(dstfdes, buff_ptr, remainder); if (remainder != write_ret) { perror("\n write"); TEST_PRINT_ERR("file write failed "); result = FAILURE; goto free_mem; } } res_close = fsync(srcfdes); if (-1 == res_close) { perror("\n fsync"); TEST_PRINT_ERR("file fsync failed "); result = FAILURE; goto free_mem; } res_close = fsync(dstfdes); if (-1 == res_close) { perror("\n fsync"); TEST_PRINT_ERR("file fsync failed "); result = FAILURE; goto free_mem; } if (info->throughput_flag) { /* Stop the Timer and get the usecs elapsed */ elapsed_usecs = stop_timer(&throughput_starttime); throughput += (float)((float)totalsize /(float)elapsed_usecs); throughputcnt++; } res_close = close(srcfdes); if (-1 == res_close) { perror("\n close"); TEST_PRINT_ERR("file close failed "); result = FAILURE; goto free_mem; } srcfileopenflag = 0; res_close = close(dstfdes); if (-1 == res_close) { perror("\n close"); TEST_PRINT_ERR("file close failed "); result = FAILURE; goto free_mem; } copycnt++; TEST_PRINT_TRC("Copying of file succeeded for %d Time",copycnt); dstfileopenflag = 0; res_integrity = st_filesystem_dateintegrity_test(srcfile_ptr,dstfile_ptr); if( SUCCESS != res_integrity ) { TEST_PRINT_ERR("Data integrity test failed "); result = FAILURE; goto free_mem; } TEST_PRINT_TRC("Data integrity succeeded"); /* Stop the Timer and get the secs elapsed for duration */ elapsed_usecs = stop_timer(&duration_starttime); elapsed_secs = (elapsed_usecs/1000000); } TEST_PRINT_TRC("Time Out ... Elapsed %lu Secs",elapsed_secs); if (info->throughput_flag) { /* Calculate the average throughput */ TEST_PRINT_TRC("filecopy | Mega Bytes/Sec | %lf", (float)(throughput/(float)(throughputcnt))); } TEST_PRINT_TRC("|PERFDATA|bsize:%d|iomode:copy|throughput:%.2lfMB/S|", bsize, (float)(throughput/(float)(throughputcnt))); free_mem: if(dstfileopenflag) { res_close = close(dstfdes); if (-1 == res_close) { perror("\n close"); TEST_PRINT_ERR("file close failed "); result = FAILURE; } } if(srcfileopenflag) { res_close = close(srcfdes); if (-1 == res_close) { perror("\n close"); TEST_PRINT_ERR("file close failed "); result = FAILURE; } } if (NULL != buff_ptr) { free(buff_ptr); } end: return result; }
/* Set the requested display output */ int st_set_output_interface(struct v4l2_display_testparams *options) { /* * In case of OMAP35x we are supporting 3 outputs * 0 = Switch to LCD * 1 = Switch to DVI * 2 = Switch to TV */ switch (options->output) { case 0: TEST_PRINT_TRC("Switching output to LCD output\n"); /* Disable overlays and displays and break the link */ config_dss_sysfs("overlay0/enabled", "0"); config_dss_sysfs("overlay1/enabled", "0"); config_dss_sysfs("overlay2/enabled", "0"); config_dss_sysfs("overlay0/manager", "\n"); config_dss_sysfs("overlay1/manager", "\n"); config_dss_sysfs("overlay2/manager", "\n"); config_dss_sysfs("display0/enabled", "0"); config_dss_sysfs("display1/enabled", "0"); config_dss_sysfs("display2/enabled", "0"); /* Set the links and enable overlays: Currentl only GFX is * enabled */ config_dss_sysfs("overlay0/manager", "lcd"); config_dss_sysfs("overlay1/manager", "lcd"); config_dss_sysfs("overlay2/manager", "lcd"); config_dss_sysfs("manager0/display", "lcd"); config_dss_sysfs("overlay0/enabled", "1"); config_dss_sysfs("display0/enabled", "1"); break; case 1: TEST_PRINT_TRC("Switching output to DVI output\n"); /* Disable overlays and displays and break the link */ config_dss_sysfs("overlay0/enabled", "0"); config_dss_sysfs("overlay1/enabled", "0"); config_dss_sysfs("overlay2/enabled", "0"); config_dss_sysfs("overlay0/manager", "\n"); config_dss_sysfs("overlay1/manager", "\n"); config_dss_sysfs("overlay2/manager", "\n"); config_dss_sysfs("display0/enabled", "0"); config_dss_sysfs("display1/enabled", "0"); config_dss_sysfs("display2/enabled", "0"); /* Set the links and enable overlays: Currentl only GFX is * enabled */ config_dss_sysfs("manager0/display", "dvi"); config_dss_sysfs("overlay0/manager", "lcd"); config_dss_sysfs("overlay1/manager", "lcd"); config_dss_sysfs("overlay2/manager", "lcd"); config_dss_sysfs("overlay0/enabled", "1"); config_dss_sysfs("display2/enabled", "1"); break; case 2: TEST_PRINT_TRC("Switching output to TV output\n"); /* Disable overlays and displays and break the link */ config_dss_sysfs("overlay0/enabled", "0"); config_dss_sysfs("overlay1/enabled", "0"); config_dss_sysfs("overlay2/enabled", "0"); config_dss_sysfs("overlay0/manager", "\n"); config_dss_sysfs("overlay1/manager", "\n"); config_dss_sysfs("overlay2/manager", "\n"); config_dss_sysfs("display0/enabled", "0"); config_dss_sysfs("display1/enabled", "0"); config_dss_sysfs("display2/enabled", "0"); config_dss_sysfs("overlay0/manager", "tv"); config_dss_sysfs("overlay1/manager", "tv"); config_dss_sysfs("overlay2/manager", "tv"); config_dss_sysfs("overlay0/enabled", "1"); config_dss_sysfs("display1/enabled", "1"); break; default: TEST_PRINT_ERR("Wrong output device\n"); return -EINVAL; } return 0; }
/* * Prints the test option values being used for current test case * * Function is broken down into two layers, Standard and Custom (Platform specific). */ void st_print_fbdev_display_show_params(struct fbdev_display_testparams *options) { TEST_PRINT_TST_START(options->testcase_id); TEST_PRINT_TRC("The Test is going to start with following values"); TEST_PRINT_TRC("The device node |%s", options->device_name); TEST_PRINT_TRC("Height of the image |%d", options->var.xres); TEST_PRINT_TRC("Width of the image |%d", options->var.yres); TEST_PRINT_TRC("Virtual Height of the image |%d", options->var.xres_virtual); TEST_PRINT_TRC("Virtual Width of the image |%d", options->var.yres_virtual); TEST_PRINT_TRC("Pixel clock |%d", options->var.pixclock); TEST_PRINT_TRC("Bits per Pixel of the image |%d", options->var.bits_per_pixel); TEST_PRINT_TRC("Pan X-offset |%d", options->var.xoffset); TEST_PRINT_TRC("Pan Y-offset |%d", options->var.yoffset); TEST_PRINT_TRC("Rotation Angle |%d", options->var.rotate); TEST_PRINT_TRC("GrayScale |%d", options->var.grayscale); TEST_PRINT_TRC("Left Margin |%d", options->var.left_margin); TEST_PRINT_TRC("Right Margin |%d", options->var.right_margin); TEST_PRINT_TRC("Lower Margin |%d", options->var.lower_margin); TEST_PRINT_TRC("Upper Margin |%d", options->var.upper_margin); TEST_PRINT_TRC("Hsync Length |%d", options->var.hsync_len); TEST_PRINT_TRC("Vsync Length |%d", options->var.vsync_len); TEST_PRINT_TRC("Bit Fields [RGBA] |%d/%d, %d/%d, %d/%d, %d/%d", options->var.red.length, options->var.red.offset, options->var.green.length, options->var.green.offset, options->var.blue.length, options->var.blue.offset, options->var.transp.length, options->var.transp.offset); TEST_PRINT_TRC("Custom (Platform Specific) Fbdev Configuration\n"); /* Platform specific options */ if (options->pfunc.show_params) options->pfunc.show_params(options); }
/**************************************************************************** * Function - st_wdt_ioctl_test * Functionality - This function recieves the test params and calls * the appropariate ioctl and prints the status * accordingly * Input Params - info,test_id * Return Value - 0: SUCCESS, -1: FAILURE * Note - None ****************************************************************************/ int st_wdt_ioctl_test(struct st_wdt_testparams *info, char *test_id,int fileDesc) { int result = SUCCESS; int retVal = 0; int i = 0; int timeout_val = 0; int readtimeout_val = 0; int defaulttimeut_val = ST_WDT_TIMEOUT_VAL; do { if (FAILURE == fileDesc) { TEST_PRINT_ERR("file open failed "); result = FAILURE; break; } if (WDIOC_SETTIMEOUT == info->ioctl) { /* 1. Read the time out first 2. Set the time out to predefined value 3. Get the timeout and verify. 4. Put back the time out vale read earlier */ retVal = ioctl(fileDesc, WDIOC_GETTIMEOUT, &(timeout_val)); if (FAILURE == retVal) { st_perror("IOCTL FAILED"); result = FAILURE; break; } retVal = ioctl(fileDesc, WDIOC_SETTIMEOUT,&defaulttimeut_val); if (FAILURE == retVal) { st_perror("IOCTL FAILED"); result = FAILURE; break; } retVal = ioctl(fileDesc, WDIOC_GETTIMEOUT, &(readtimeout_val)); if (FAILURE == retVal) { st_perror("IOCTL FAILED"); result = FAILURE; break; } if (defaulttimeut_val != readtimeout_val) { TEST_PRINT_ERR ("SETTIMEOUT IOCTL: Time set" "and read did not match"); result = FAILURE; } } else { retVal = ioctl(fileDesc, info->ioctl, &(info->ioctl_arg)); if (FAILURE == retVal) { st_perror("IOCTL FAILED"); result = FAILURE; break; } else { switch(info->ioctl) { case WDIOC_GETSUPPORT: TEST_PRINT_TRC("Return Value : 0x%x", (unsigned int)info->ioctl_arg); TEST_PRINT_TRC("Following Features Are" " Supported By The Driver : "); while (NULL != supportinfo_table[i].descr) { if (supportinfo_table[i]. supportinfo == (info->ioctl_arg & supportinfo_table[i]. supportinfo)) { TEST_PRINT_TRC("%s", supportinfo_table[i]. descr); } i++; } break; case WDIOC_GETTIMELEFT: TEST_PRINT_TRC("TIME LEFT IS : %ld", info->ioctl_arg); break; case WDIOC_GETSTATUS : case WDIOC_GETBOOTSTATUS : TEST_PRINT_TRC ("STATUS VALUE : %ld \nStatus Is : ", info->ioctl_arg); while (NULL != supportinfo_table[i].descr) { if (supportinfo_table[i]. supportinfo == (info-> ioctl_arg & supportinfo_table[i]. supportinfo)) { TEST_PRINT_TRC("%s", supportinfo_table[i]. descr); } i++; } break; case WDIOC_GETTIMEOUT: TEST_PRINT_TRC("TIME OUT VALUE : %ld", info->ioctl_arg); break; case WDIOC_GETPRETIMEOUT: TEST_PRINT_TRC("PRETIMEOUT VALUE : %ld", info->ioctl_arg); break; case WDIOC_GETTEMP: TEST_PRINT_TRC("TEMP VALUE : %ld", info->ioctl_arg); break; } } } } while (0); return result; }
/* * Function - st_print_edma_test_params * Functionality - This function prints the test option values * Input Params - Test params structure * Return Value - None * Note - None */ void st_print_edma_test_params(struct st_edma_testparams *testoptions, char *test_id) { TEST_PRINT_TRC("******** edma Testcase parameters ******** "); TEST_PRINT_TRC("Device : %s", testoptions->device); TEST_PRINT_TRC("acnt : %d", testoptions->acnt); TEST_PRINT_TRC("bcnt : %d", testoptions->bcnt); TEST_PRINT_TRC("ccnt : %d", testoptions->ccnt); TEST_PRINT_TRC("numtcs : %d", testoptions->numtcs); switch (testoptions->ioctl) { case EDMA_ASYNC: TEST_PRINT_TRC("Transfer Mode : EDMA_ASYNC"); break; case EDMA_ABSYNC: TEST_PRINT_TRC("Transfer Mode : EDMA_ABSYNC"); break; case EDMA_LINK_ASYNC: TEST_PRINT_TRC("Transfer Mode : EDMA_LINK_ASYNC"); break; case EDMA_LINK_ABSYNC: TEST_PRINT_TRC("Transfer Mode : EDMA_LINK_ABSYNC"); break; case EDMA_CHAIN_ASYNC: TEST_PRINT_TRC("Transfer Mode : EDMA_CHAIN_ASYNC"); break; case EDMA_CHAIN_ABSYNC: TEST_PRINT_TRC("Transfer Mode : EDMA_CHAIN_ABSYNC"); break; } TEST_PRINT_TRC(" ************* End of Test params ************* "); }
/* * Function - st_alsa_print_test_params * Functionality - This function prints the test params * Input Params - test_opt * Return Value - None * Note - None */ void st_alsa_print_test_params(tc_dev_params * test_opt) { char *format = NULL; char *access = NULL; switch (test_opt->format) { case PCM_FORMAT_S8: format = "S8"; break; case PCM_FORMAT_S16_LE: format = "S16_LE"; break; case PCM_FORMAT_S16_BE: format = "S16_BE"; break; case PCM_FORMAT_U16_LE: format = "U16_LE"; break; case PCM_FORMAT_U16_BE: format = "U16_BE"; break; case PCM_FORMAT_S24_LE: format = "S24_LE"; break; case PCM_FORMAT_S24_BE: format = "S24_BE"; break; case PCM_FORMAT_U24_LE: format = "U24_LE"; break; case PCM_FORMAT_U24_BE: format = "U24_BE"; break; case PCM_FORMAT_S32_BE: format = "S32_BE"; break; case PCM_FORMAT_S32_LE: format = "S32_LE"; break; case PCM_FORMAT_U32_BE: format = "U32_BE"; break; case PCM_FORMAT_U32_LE: format = "U32_LE"; break; } switch (test_opt->access_type) { case PCM_ACCESS_MMAP_INTERLEAVED: access = "MMAP_INTERLEAVED"; break; case PCM_ACCESS_MMAP_NONINTERLEAVED: access = "MMAP_NONINTERLEAVED"; break; case PCM_ACCESS_MMAP_COMPLEX: access = "MMAP_COMPLEX"; break; case PCM_ACCESS_RW_INTERLEAVED: access = "RW_INTERLEAVED"; break; case PCM_ACCESS_RW_NONINTERLEAVED: access = "RW_NONINTERLEAVED"; break; } TEST_PRINT_TST_START(testcaseid); TEST_PRINT("******** ALSA Testcase parameters ******** "); if (play_or_record == OPTION_RECORD) { TEST_PRINT_TRC ("CAPTURE Test is going to start with following values "); } else if (play_or_record == OPTION_PLAYBACK) { TEST_PRINT_TRC ("PLAYBACK Test is going to start with following values "); } else { TEST_PRINT_TRC ("LOOPBACK Test is going to start with following values "); } TEST_PRINT_TRC("Card name |%s", test_opt->card_name); TEST_PRINT_TRC("Device Number |%d", test_opt->device); TEST_PRINT_TRC("Access Type |%s", access); TEST_PRINT_TRC("Period Size |%d", test_opt->period_size); TEST_PRINT_TRC("Sampling Rate |%d", test_opt->sampling_rate); TEST_PRINT_TRC("Channels |%d", test_opt->channel); TEST_PRINT_TRC("format |%s", format); if (test_opt->capture_to_file == TRUE || test_opt->play_from_file == TRUE) { TEST_PRINT_TRC("File name |%s", test_opt->file_name); } TEST_PRINT_TRC("Total Size |%d", test_opt->total_size); TEST_PRINT("************* End of Test params ***************** "); }