/* * V4L2 - Handles VIDIOC_S_FMT Ioctl * * @param vout structure vout_data * * * @param v4l2_format structure v4l2_format * * * @return status 0 success, EINVAL failed */ static int mxc_v4l2out_s_fmt(vout_data * vout, struct v4l2_format *f) { int retval = 0; u32 size = 0; u32 bytesperline; if (f->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) { retval = -EINVAL; goto err0; } if (!valid_mode(f->fmt.pix.pixelformat)) { DPRINTK("pixel format not supported\n"); retval = -EINVAL; goto err0; } bytesperline = (f->fmt.pix.width * fmt_to_bpp(f->fmt.pix.pixelformat)) / 8; if (f->fmt.pix.bytesperline < bytesperline) { f->fmt.pix.bytesperline = bytesperline; } else { bytesperline = f->fmt.pix.bytesperline; } switch (f->fmt.pix.pixelformat) { case V4L2_PIX_FMT_YUV422P: /* byteperline for YUV planar formats is for Y plane only */ size = bytesperline * f->fmt.pix.height * 2; break; case V4L2_PIX_FMT_YUV420: size = (bytesperline * f->fmt.pix.height * 3) / 2; break; default: size = bytesperline * f->fmt.pix.height; break; } /* Return the actual size of the image to the app */ f->fmt.pix.sizeimage = size; vout->v2f.fmt.pix.sizeimage = size; vout->v2f.fmt.pix.width = f->fmt.pix.width; vout->v2f.fmt.pix.height = f->fmt.pix.height; vout->v2f.fmt.pix.pixelformat = f->fmt.pix.pixelformat; vout->v2f.fmt.pix.bytesperline = f->fmt.pix.bytesperline; retval = 0; err0: return retval; }
ImgBlk* X86Ipu::allocHwBuf(u32 width,u32 height,u32 format) { if(width < 0 || height < 0) { log_print(_ERROR,"X86Ipu::allocHwBuf fail\n"); return NULL; } ImgBlk* tmp = (ImgBlk *)malloc(sizeof(ImgBlk)); int ret = 0; // if (IPU_PIX_FMT_TILED_NV12F == format) { // tmp->size = PAGE_ALIGN(width * height/2) + // PAGE_ALIGN(width * height/4); // tmp->size = tmp->size * 2; // } else switch(format){ case PIX_FMT_NV12: //< Packed YUV 4:2:0 (separate Y plane, interleaved Cb & Cr planes) case PIX_FMT_NV21: //< Packed YUV 4:2:0 (separate Y plane, interleaved Cb & Cr planes) case PIX_FMT_YUV420P: //< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples) (I420) case PIX_FMT_YVU420P: //< Planar YUV 4:2:0 (1 Cb & Cr sample per 2x2 Y samples) (YV12) case PIX_FMT_YUV411P: //< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples) case PIX_FMT_YUVJ420P: //< Planar YUV 4:2:0 full scale (jpeg) case PIX_FMT_UYVY411: //< Packed pixel, Cb Y0 Y1 Cr Y2 Y3 // tmp->size = PAGE_ALIGN(width * height/2) + PAGE_ALIGN(width * height/4); // tmp->size = tmp->size * 2; //break; default: tmp->size = width * height* fmt_to_bpp(format)/8; break; } //log_print(_DEBUG,"bbp=%d",fmt_to_bpp(format)); tmp->paddr = tmp->size; tmp->vaddr = malloc(tmp->size); if (!tmp->vaddr) { log_print(_ERROR,"X86Ipu::allocHwBuf fail\n"); return NULL; } //log_print(_DEBUG,"CIpu::allocHwBuf paddr %x\n vaddr %x, bbp=%d\n",tmp->paddr,tmp->vaddr,fmt_to_bpp(format)); tmp->fourcc= format; tmp->height = height; tmp->width = width; return tmp; }
/*! * V4L2 interface - ioctl function * * @param inode struct inode * * * @param file struct file * * * @param ioctlnr unsigned int * * @param arg void * * * @return 0 success, ENODEV for invalid device instance, * -1 for other errors. */ static int mxc_v4l2out_do_ioctl(struct inode *inode, struct file *file, unsigned int ioctlnr, void *arg) { struct video_device *dev = file->private_data; vout_data *vout = video_get_drvdata(dev); int retval = 0; int i = 0; if (!vout) return -ENODEV; /* make this _really_ smp-safe */ if (down_interruptible(&vout->busy_lock)) return -EINTR; switch (ioctlnr) { case VIDIOC_QUERYCAP: { struct v4l2_capability *cap = arg; strcpy(cap->driver, "mxc_v4l2_output"); cap->version = 0; cap->capabilities = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; retval = 0; break; } case VIDIOC_G_FMT: { struct v4l2_format *gf = arg; retval = mxc_v4l2out_g_fmt(vout, gf); break; } case VIDIOC_S_FMT: { struct v4l2_format *sf = arg; if (vout->state != STATE_STREAM_OFF) { retval = -EBUSY; break; } retval = mxc_v4l2out_s_fmt(vout, sf); break; } case VIDIOC_REQBUFS: { struct v4l2_requestbuffers *req = arg; if ((req->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) || (req->memory != V4L2_MEMORY_MMAP)) { DPRINTK ("VIDIOC_REQBUFS: incorrect buffer type\n"); retval = -EINVAL; break; } if (req->count == 0) { mxc_v4l2out_streamoff(vout); if (vout->queue_buf_paddr[0] != 0) { mxc_free_buffers(vout->queue_buf_paddr, vout->buffer_cnt); DPRINTK ("VIDIOC_REQBUFS: freed buffers\n"); } vout->buffer_cnt = 0; break; } if (vout->queue_buf_paddr[0] != 0) { DPRINTK ("VIDIOC_REQBUFS: Cannot allocate buffers\n"); retval = -EBUSY; break; } if (req->count < MIN_FRAME_NUM) { req->count = MIN_FRAME_NUM; } else if (req->count > MAX_FRAME_NUM) { req->count = MAX_FRAME_NUM; } vout->buffer_cnt = req->count; retval = mxc_allocate_buffers(vout->queue_buf_paddr, vout->buffer_cnt, PAGE_ALIGN(vout->v2f.fmt. pix. sizeimage)); if (retval < 0) break; /* Init buffer queues */ vout->done_q.head = 0; vout->done_q.tail = 0; vout->ready_q.head = 0; vout->ready_q.tail = 0; for (i = 0; i < vout->buffer_cnt; i++) { memset(&(vout->v4l2_bufs[i]), 0, sizeof(vout->v4l2_bufs[i])); vout->v4l2_bufs[i].flags = 0; vout->v4l2_bufs[i].memory = V4L2_MEMORY_MMAP; vout->v4l2_bufs[i].index = i; vout->v4l2_bufs[i].type = V4L2_BUF_TYPE_VIDEO_OUTPUT; vout->v4l2_bufs[i].length = PAGE_ALIGN(vout->v2f.fmt.pix.sizeimage); vout->v4l2_bufs[i].m.offset = (unsigned long)vout->queue_buf_paddr[i]; vout->v4l2_bufs[i].timestamp.tv_sec = 0; vout->v4l2_bufs[i].timestamp.tv_usec = 0; } break; } case VIDIOC_QUERYBUF: { struct v4l2_buffer *buf = arg; u32 type = buf->type; int index = buf->index; if ((type != V4L2_BUF_TYPE_VIDEO_OUTPUT) || (index >= vout->buffer_cnt)) { DPRINTK ("VIDIOC_QUERYBUFS: incorrect buffer type\n"); retval = -EINVAL; break; } down(&vout->param_lock); memcpy(buf, &(vout->v4l2_bufs[index]), sizeof(*buf)); up(&vout->param_lock); break; } case VIDIOC_QBUF: { struct v4l2_buffer *buf = arg; int index = buf->index; u32 lock_flags; if ((buf->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) || (index >= vout->buffer_cnt) || (buf->flags != 0)) { retval = -EINVAL; break; } DPRINTK("VIDIOC_QBUF: %d\n", buf->index); spin_lock_irqsave(&g_lock, lock_flags); memcpy(&(vout->v4l2_bufs[index]), buf, sizeof(*buf)); vout->v4l2_bufs[index].flags |= V4L2_BUF_FLAG_QUEUED; g_buf_q_cnt++; queue_buf(&vout->ready_q, index); if (vout->state == STATE_STREAM_PAUSED) { unsigned long timeout = timeval_to_jiffies(&vout->v4l2_bufs[index]. timestamp); if (!timeout) { /* if timestamp is 0, then default to 30fps */ timeout = vout->start_jiffies + msecs_to_jiffies(vout->frame_count * 33); } else { /* Adjust time from time of day to jiffies */ timeout -= vout->start_tod_jiffies; } vout->output_timer.expires = timeout; DPRINTK("QBUF: frame #%u timeout @ %u jiffies, " "current = %u\n", vout->frame_count, timeout, jiffies); add_timer(&vout->output_timer); vout->state = STATE_STREAM_ON; vout->frame_count++; } spin_unlock_irqrestore(&g_lock, lock_flags); break; } case VIDIOC_DQBUF: { struct v4l2_buffer *buf = arg; int idx; /* DPRINTK("VIDIOC_DQBUF: q size = %d\n", queue_size(&vout->done_q)); */ if ((queue_size(&vout->done_q) == 0) && (file->f_flags & O_NONBLOCK)) { retval = -EAGAIN; break; } if (!wait_event_interruptible_timeout(vout->v4l_bufq, queue_size(&vout-> done_q) != 0, 2 * HZ)) { printk("VIDIOC_DQBUF: timeout\n"); retval = -ETIME; break; } else if (signal_pending(current)) { printk("VIDIOC_DQBUF: interrupt received\n"); vout->state = STATE_STREAM_STOPPING; retval = -ERESTARTSYS; break; } idx = dequeue_buf(&vout->done_q); if (idx == -1) { /* No frame free */ printk ("VIDIOC_DQBUF: no free buffers, returning\n"); retval = -EAGAIN; break; } if ((vout->v4l2_bufs[idx].flags & V4L2_BUF_FLAG_DONE) == 0) printk ("VIDIOC_DQBUF: buffer in done q, but not " "flagged as done\n"); vout->v4l2_bufs[idx].flags = 0; memcpy(buf, &(vout->v4l2_bufs[idx]), sizeof(*buf)); DPRINTK("VIDIOC_DQBUF: %d\n", buf->index); break; } case VIDIOC_STREAMON: { struct timeval t; do_gettimeofday(&t); vout->start_tod_jiffies = timeval_to_jiffies(&t) - jiffies; vout->frame_count = 2; vout->start_jiffies = jiffies; DPRINTK("VIDIOC_STREAMON: start time = %u jiffies, " "tod adjustment = %u\n", vout->start_jiffies, vout->start_tod_jiffies); retval = mxc_v4l2out_streamon(vout); break; } case VIDIOC_STREAMOFF: { retval = mxc_v4l2out_streamoff(vout); break; } case VIDIOC_G_CTRL: { retval = mxc_get_v42lout_control(vout, arg); break; } case VIDIOC_S_CTRL: { retval = mxc_set_v42lout_control(vout, arg); break; } case VIDIOC_CROPCAP: { struct v4l2_cropcap *cap = arg; if (cap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) { retval = -EINVAL; break; } cap->bounds = vout->crop_bounds[vout->cur_disp_output]; cap->defrect = vout->crop_bounds[vout->cur_disp_output]; retval = 0; break; } case VIDIOC_G_CROP: { struct v4l2_crop *crop = arg; if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) { retval = -EINVAL; break; } crop->c = vout->crop_current; break; } case VIDIOC_S_CROP: { struct v4l2_crop *crop = arg; struct v4l2_rect *b = &(vout->crop_bounds[vout->cur_disp_output]); if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) { retval = -EINVAL; break; } if (crop->c.height < 0) { retval = -EINVAL; break; } if (crop->c.width < 0) { retval = -EINVAL; break; } if (crop->c.top < b->top) crop->c.top = b->top; if (crop->c.top > b->top + b->height) crop->c.top = b->top + b->height; if (crop->c.height > b->top - crop->c.top + b->height) crop->c.height = b->top - crop->c.top + b->height; if (crop->c.left < b->left) crop->c.top = b->left; if (crop->c.left > b->left + b->width) crop->c.top = b->left + b->width; if (crop->c.width > b->left - crop->c.left + b->width) crop->c.width = b->left - crop->c.left + b->width; /* stride line limitation */ crop->c.height -= crop->c.height % 8; crop->c.width -= crop->c.width % 8; vout->crop_current = crop->c; vout->sdc_fg_buf_size = vout->crop_current.width * vout->crop_current.height; vout->sdc_fg_buf_size *= fmt_to_bpp(SDC_FG_FB_FORMAT) / 8; /* Free previously allocated buffer */ if (vout->display_bufs[0] != NULL) { mxc_free_buffers(vout->display_bufs, 2); } if ((retval = mxc_allocate_buffers(vout->display_bufs, 2, vout-> sdc_fg_buf_size)) < 0) { DPRINTK("unable to allocate SDC FG buffers\n"); retval = -ENOMEM; break; } break; } case VIDIOC_ENUMOUTPUT: { struct v4l2_output *output = arg; if ((output->index >= 4) || (vout->output_enabled[output->index] == false)) { retval = -EINVAL; break; } if (output->index < 3) { *output = mxc_outputs[MXC_V4L2_OUT_2_ADC]; output->name[4] = '0' + output->index; } else { *output = mxc_outputs[MXC_V4L2_OUT_2_SDC]; } break; } case VIDIOC_G_OUTPUT: { int *p_output_num = arg; *p_output_num = vout->cur_disp_output; break; } case VIDIOC_S_OUTPUT: { int *p_output_num = arg; if ((*p_output_num >= 4) || (vout->output_enabled[*p_output_num] == false)) { retval = -EINVAL; break; } if (vout->state != STATE_STREAM_OFF) { retval = -EBUSY; break; } vout->cur_disp_output = *p_output_num; break; } case VIDIOC_ENUM_FMT: case VIDIOC_TRY_FMT: case VIDIOC_QUERYCTRL: case VIDIOC_G_PARM: case VIDIOC_ENUMSTD: case VIDIOC_G_STD: case VIDIOC_S_STD: case VIDIOC_G_TUNER: case VIDIOC_S_TUNER: case VIDIOC_G_FREQUENCY: case VIDIOC_S_FREQUENCY: default: retval = -EINVAL; break; } up(&vout->busy_lock); return retval; }
int main (int argc, char *argv[]) { int file_in; size_t filesize; void * raw_image; struct ipu_task task; struct timeval begin, end; struct fb_var_screeninfo fb_var; struct fb_fix_screeninfo fb_fix; dma_addr_t outpaddr; int sec, usec, run_time; int fd_ipu, fd_fb, isize, osize; int ret, i; void *inbuf = NULL; void *outbuf = NULL; // Clear &task memset(&task, 0, sizeof(task)); // Input image size and format task.input.width = 320; task.input.height = 240; // Output image size and format task.output.width = 1024; task.output.height = 768; task.output.format = v4l2_fourcc('R', 'G', 'B', 'P'); task.output.rotate = 1; // Open IPU device fd_ipu = open("/dev/mxc_ipu", O_RDWR, 0); if (fd_ipu < 0) { printf("open ipu dev fail\n"); ret = -1; goto done; } // Open Framebuffer and gets its address if ((fd_fb = open("/dev/fb0", O_RDWR, 0)) < 0) { printf("Unable to open /dev/fb0\n"); ret = -1; goto done; } // Unblank the display ioctl(fd_fb, FBIOBLANK, FB_BLANK_UNBLANK); if ( ioctl(fd_fb, FBIOGET_FSCREENINFO, &fb_fix) < 0) { printf("Get FB fix info failed!\n"); ret = -1; goto done; } ioctl(fd_fb, FBIOGET_FSCREENINFO, &fb_fix); // Set IPU output address as framebuffer address outpaddr = fb_fix.smem_start; task.output.paddr = outpaddr; // Create memory map for output image outbuf = mmap(0, osize, PROT_READ | PROT_WRITE, MAP_SHARED, fd_ipu, task.output.paddr); if (!outbuf) { printf("mmap fail\n"); ret = -1; goto done; } // Open the raw image if ((file_in = open("../../../images/stefan_interlaced_320x240_1frame.yv12", O_RDWR, 0)) < 0) { printf("Unable to open file\n"); ret = -1; goto done; } printf("\nOpening image file\n"); filesize = lseek(file_in, 0, SEEK_END); raw_image = mmap(0, filesize, PROT_READ, MAP_SHARED, file_in, 0); // Setting the input image format task.input.format = v4l2_fourcc('N', 'V', '1', '2'); // Calculate input size from image dimensions and bits-per-pixel // according to format isize = task.input.paddr = task.input.width * task.input.height * fmt_to_bpp(task.input.format)/8; // Allocate contingous physical memory for input image // input.paddr contains the amount needed // this value will be replaced with physical address on success ret = ioctl(fd_ipu, IPU_ALLOC, &task.input.paddr); if (ret < 0) { printf("ioctl IPU_ALLOC fail: (errno = %d)\n", errno); goto done; } // Create memory map and obtain the allocated memory virtual address inbuf = mmap(0, isize, PROT_READ | PROT_WRITE, MAP_SHARED, fd_ipu, task.input.paddr); if (!inbuf) { printf("mmap fail\n"); ret = -1; goto done; } //Copy the raw image to the IPU buffer memcpy(inbuf, raw_image, isize); for (i=0; i < 10 ; i++) { task.input.deinterlace.enable = i & 0x1; gettimeofday(&begin, NULL); // Perform deinterlace ret = ioctl(fd_ipu, IPU_QUEUE_TASK, &task); gettimeofday(&end, NULL); if (ret < 0) { printf("ioct IPU_QUEUE_TASK fail %x\n", ret); goto done; } sec = end.tv_sec - begin.tv_sec; usec = end.tv_usec - begin.tv_usec; if (usec < 0) { sec--; usec = usec + 1000000; } run_time = (sec * 1000000) + usec; printf("Color Space Conversion time: %d usecs\n", run_time); sleep(2); } done: if (file_in) close(file_in); if (outbuf) munmap(outbuf, osize); if (task.output.paddr) ioctl(fd_ipu, IPU_FREE, &task.output.paddr); if (inbuf) munmap(inbuf, isize); if (task.input.paddr) ioctl(fd_ipu, IPU_FREE, &task.input.paddr); if (fd_ipu) close(fd_ipu); if (fd_fb) close(fd_fb); return ret; }
int Iputool::prepare_ipu(int argc, char *argv[]) { t = &test_handle.task; ret = 0; file_out = NULL; fd_ipu = 0, fd_fb = 0; isize = 0, ovsize = 0; alpsize = 0, osize = 0; inbuf = NULL, vdibuf = NULL; ovbuf = NULL, alpbuf = NULL; memset(&test_handle, 0, sizeof(ipu_test_handle_t)); if (process_cmdline(argc, argv, &test_handle) < 0) { printf("\nMXC IPU device Test\n\n" \ "Usage: %s -C <config file> <input raw file>\n", argv[0]); return -1; } //file_in = fopen(argv[argc-1], "rb"); // if (file_in == NULL){ // printf("there is no such file for reading %s\n", argv[argc-1]); // ret = -1; // goto err0; // } fd_ipu = open("/dev/mxc_ipu", O_RDWR, 0); if (fd_ipu < 0) { printf("open ipu dev fail\n"); ret = -1; ipuErr=Err1; goto err1; } if (IPU_PIX_FMT_TILED_NV12F == t->input.format) { isize = PAGE_ALIGN(t->input.width * t->input.height/2) + PAGE_ALIGN(t->input.width * t->input.height/4); isize = t->input.paddr = isize * 2; } else isize = t->input.paddr = t->input.width * t->input.height * fmt_to_bpp(t->input.format)/8; ret = ioctl(fd_ipu, IPU_ALLOC, &t->input.paddr); if (ret < 0) { printf("ioctl IPU_ALLOC fail\n"); ipuErr=Err2; goto err2; } // printf("mmap isize %d:\n",isize); inbuf = mmap(0, isize, PROT_READ | PROT_WRITE, MAP_SHARED, fd_ipu, t->input.paddr); if (!inbuf) { printf("mmap fail\n"); ret = -1; ipuErr=Err3; goto err3; } if (t->input.deinterlace.enable && (t->input.deinterlace.motion != HIGH_MOTION)) { t->input.paddr_n = isize; ret = ioctl(fd_ipu, IPU_ALLOC, &t->input.paddr_n); if (ret < 0) { printf("ioctl IPU_ALLOC fail\n"); ipuErr=Err4; goto err4; } vdibuf = mmap(0, isize, PROT_READ | PROT_WRITE, MAP_SHARED, fd_ipu, t->input.paddr_n); if (!vdibuf) { printf("mmap fail\n"); ret = -1; ipuErr=Err5; goto err5; } } if (t->overlay_en) { ovsize = t->overlay.paddr = t->overlay.width * t->overlay.height * fmt_to_bpp(t->overlay.format)/8; ret = ioctl(fd_ipu, IPU_ALLOC, &t->overlay.paddr); if (ret < 0) { printf("ioctl IPU_ALLOC fail\n"); ipuErr=Err6; goto err6; } ovbuf = mmap(0, ovsize, PROT_READ | PROT_WRITE, MAP_SHARED, fd_ipu, t->overlay.paddr); if (!ovbuf) { printf("mmap fail\n"); ret = -1; ipuErr=Err7; goto err7; } /*fill overlay buffer with dedicated data*/ memset(ovbuf, 0x00, ovsize/4); memset(ovbuf+ovsize/4, 0x55, ovsize/4); memset(ovbuf+ovsize/2, 0xaa, ovsize/4); memset(ovbuf+ovsize*3/4, 0xff, ovsize/4); if (t->overlay.alpha.mode == IPU_ALPHA_MODE_LOCAL) { alpsize = t->overlay.alpha.loc_alp_paddr = t->overlay.width * t->overlay.height; ret = ioctl(fd_ipu, IPU_ALLOC, &t->overlay.alpha.loc_alp_paddr); if (ret < 0) { printf("ioctl IPU_ALLOC fail\n"); ipuErr=Err8; goto err8; } alpbuf = mmap(0, alpsize, PROT_READ | PROT_WRITE, MAP_SHARED, fd_ipu, t->overlay.alpha.loc_alp_paddr); if (!alpbuf) { printf("mmap fail\n"); ret = -1; ipuErr=Err9; goto err9; } /*fill loc alpha buffer with dedicated data*/ memset(alpbuf, 0x00, alpsize/4); memset(alpbuf+alpsize/4, 0x55, alpsize/4); memset(alpbuf+alpsize/2, 0xaa, alpsize/4); memset(alpbuf+alpsize*3/4, 0xff, alpsize/4); } } if (test_handle.show_to_fb) { int found = 0, i; char fb_dev[] = "/dev/fb0"; char fb_name[16]; if (!strcmp(test_handle.outfile, "ipu0-1st-ovfb")) memcpy(fb_name, "DISP3 FG", 9); if (!strcmp(test_handle.outfile, "ipu0-2nd-fb")) memcpy(fb_name, "DISP3 BG - DI1", 15); if (!strcmp(test_handle.outfile, "ipu1-1st-ovfb")) memcpy(fb_name, "DISP4 FG", 9); if (!strcmp(test_handle.outfile, "ipu1-2nd-fb")) memcpy(fb_name, "DISP4 BG - DI1", 15); for (i=0; i<5; i++) { fb_dev[7] = '0'; fb_dev[7] += i; fd_fb = open(fb_dev, O_RDWR, 0); if (fd_fb > 0) { ioctl(fd_fb, FBIOGET_FSCREENINFO, &fb_fix); if (!strcmp(fb_fix.id, fb_name)) { printf("found fb dev %s\n", fb_dev); found = 1; break; } else close(fd_fb); } } if (!found) { printf("can not find fb dev %s\n", fb_name); ret = -1; ipuErr=Err10; goto err10; } ioctl(fd_fb, FBIOGET_VSCREENINFO, &fb_var); fb_var.xres = t->output.width; fb_var.xres_virtual = fb_var.xres; fb_var.yres = t->output.height; fb_var.yres_virtual = fb_var.yres; fb_var.activate |= FB_ACTIVATE_FORCE; fb_var.vmode |= FB_VMODE_YWRAP; fb_var.nonstd = t->output.format; fb_var.bits_per_pixel = fmt_to_bpp(t->output.format); ret = ioctl(fd_fb, FBIOPUT_VSCREENINFO, &fb_var); if (ret < 0) { printf("fb ioctl FBIOPUT_VSCREENINFO fail\n"); ipuErr=Err11; goto err11; } ioctl(fd_fb, FBIOGET_VSCREENINFO, &fb_var); ioctl(fd_fb, FBIOGET_FSCREENINFO, &fb_fix); outpaddr = fb_fix.smem_start; blank = FB_BLANK_UNBLANK; ioctl(fd_fb, FBIOBLANK, blank); } else { osize = t->output.paddr = t->output.width * t->output.height * fmt_to_bpp(t->output.format)/8; ret = ioctl(fd_ipu, IPU_ALLOC, &t->output.paddr); if (ret < 0) { printf("ioctl IPU_ALLOC fail\n"); ipuErr=Err10; goto err10; } rgbData = (unsigned char *)mmap(0, osize, PROT_READ | PROT_WRITE, MAP_SHARED, fd_ipu, t->output.paddr); if (!rgbData) { printf("mmap fail\n"); ret = -1; ipuErr=Err11; goto err11; } file_out = fopen(test_handle.outfile, "wb"); if (file_out == NULL) { printf("can not open output file %s\n", test_handle.outfile); ret = -1; ipuErr=Err12; goto err12; } } again: ret = ioctl(fd_ipu, IPU_CHECK_TASK, t); if (ret != IPU_CHECK_OK) { if (ret > IPU_CHECK_ERR_MIN) { if (ret == IPU_CHECK_ERR_SPLIT_INPUTW_OVER) { t->input.crop.w -= 8; goto again; } if (ret == IPU_CHECK_ERR_SPLIT_INPUTH_OVER) { t->input.crop.h -= 8; goto again; } if (ret == IPU_CHECK_ERR_SPLIT_OUTPUTW_OVER) { t->output.crop.w -= 8; goto again; } if (ret == IPU_CHECK_ERR_SPLIT_OUTPUTH_OVER) { t->output.crop.h -= 8; goto again; } ret = 0; printf("ipu task check fail\n"); ipuErr=Err13; goto err13; } } dump_ipu_task(t); err13: if(ipuErr==Err13){ printf("err13 !!!!\n"); if (fd_fb) { blank = FB_BLANK_POWERDOWN; ioctl(fd_fb, FBIOBLANK, blank); } } // if (file_out) // fclose(file_out); err12: if(ipuErr==Err12){ printf("err12 !!!!\n"); if (rgbData) munmap(rgbData, osize); } err11: if(ipuErr==Err11){ printf("err11 !!!!\n"); if (fd_fb) close(fd_fb); if (t->output.paddr) ioctl(fd_ipu, IPU_FREE, &t->output.paddr); } err10: if(ipuErr==Err10){ printf("err10 !!!!\n"); if (alpbuf) munmap(alpbuf, alpsize); } err9: if(ipuErr==Err9){ printf("err9 !!!!\n"); if (t->overlay.alpha.loc_alp_paddr) ioctl(fd_ipu, IPU_FREE, &t->overlay.alpha.loc_alp_paddr); } err8: if(ipuErr==Err8){ printf("err8 !!!!\n"); if (ovbuf) munmap(ovbuf, ovsize); } err7: if(ipuErr==Err7){ printf("err7 !!!!\n"); if (t->overlay.paddr) ioctl(fd_ipu, IPU_FREE, &t->overlay.paddr); } err6: if(ipuErr==Err6){ printf("err6 !!!!\n"); if (vdibuf) munmap(vdibuf, isize); } err5: if(ipuErr==Err5){ printf("err5 !!!!\n"); if (t->input.paddr_n) ioctl(fd_ipu, IPU_FREE, &t->input.paddr_n); } err4: if(ipuErr==Err4){ printf("err4 !!!!\n"); if (inbuf) munmap(inbuf, isize); } err3: if(ipuErr==Err3){ printf("err3 !!!!\n"); if (t->input.paddr) ioctl(fd_ipu, IPU_FREE, &t->input.paddr); } err2: if(ipuErr==Err2){ printf("err2 !!!!\n"); if (fd_ipu) close(fd_ipu); } err1: if(ipuErr==Err1){ // if (file_in) // fclose(file_in); } return 0; }