This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM365 capture pipeline

Other Parts Discussed in Thread: TVP7002

I have been trying for a frustratingly long time to get simple H.264 encoding of a D1 composite capture working on the DM365EVM.  I was expecting this to essentially work out of the box, but I'm clearly doing something wrong.

I'm using the Arago 2.6.37 git kernel, linux-davinci branch, updated just a few days ago, with the default configuration for the DM365EVM.  It compiles and boots fine.

I'm using TI's H.264 2.30.00.04 production codec.  That part works fine; I can encode the sample file.

Originally, I tried to reuse my VPFE capture code that I had for DM6446... which didn't work because that code was compiled against a 2.6.28 kernel that didn't use the Media Controller API.  I updated the code to use the MC API, only to find out the encoder only accepts YUV420SP frames, not the UYVY frames from the CCDC capture node that I had been using.

After searching around, it seemed I needed to use the DaVinci Resizer hardware to convert the UYVY frames to the NV12 that the encoder expects.  So, I change my device chain to look like this:

tvp514x ---> DAVINCI CCDC ---> DAVINCI PREVIEWER ---> DAVINCI RESIZER ---> DAVINCI VIDEO RSZ output

All of the pads are formatted as 720x480, V4L2_MBUS_FMT_YUYV8_2x8, although I attempted to set the pixel format to V4L2_MBUS_FMT_NV12_1x10 only to have the
driver return V4L2_MBUS_FMT_YUYV8_2x8, anyways.  VIDIOC_S_FMT on the resizer output successfully set the format to NV12, though, so I thought it might still work.

Firing up the application, however, saw my capture thread going into the VIDIOC_DQBUF ioctl for the resizer output and never returning...

Digging around, I found the mt9p031_ccdc_prv_rsz_loopback_mmap.c example app in the PSP.  Not exactly the same chain, but I was mostly concerned about the "prv, rsz, and mmap" elements, since those were the parts I couldn't get working.  This example program set up a few more IOCTLs (for which the only documentation I could find was related to the 2.6.10 kernel version of the drivers... a bit out of date), so I figured I was missing yet more configuration.  I attempted to adapt the code to configure my situation, but still my capture thread hangs in DQBUF.

Here is the code to set the whole thing up (note: it's a C++ app, the mediaDevice_ object has an overloaded [] operator to give me its entities by name and the >> operator handles linking magic... trying to help out readability for whoever inherits this code after I jump off a cliff from frustration :) ):

mediaDevice_["DAVINCI VIDEO CCDC output"];
	mediaDevice_["tvp514x"] >>mediaDevice_["DAVINCI CCDC"] >> mediaDevice_["DAVINCI PREVIEWER"] >> mediaDevice_["DAVINCI RESIZER"] >> mediaDevice_["DAVINCI VIDEO RSZ output"]; 
	char subdevice0Name[] = "/dev/v4l-subdev0";
	AO_MESSAGE << "Attempting to open " << subdevice0Name << "..." << endl;
	mediaDevice_["tvp514x"].SetSubDevice(subdevice0Name);
	v4l2_mbus_framefmt frameFormat;
	memset(&frameFormat, 0, sizeof(frameFormat));
	frameFormat.width = 720;
	frameFormat.height = 480;
	frameFormat.code = V4L2_MBUS_FMT_YUYV8_2X8;
	frameFormat.field = V4L2_FIELD_INTERLACED;
	frameFormat.colorspace = V4L2_COLORSPACE_SMPTE170M;
	mediaDevice_["tvp514x"].SetMediaBusFormat(frameFormat);
	
	char subdevice1Name[] = "/dev/v4l-subdev2";
	AO_MESSAGE << "Attempting to open " << subdevice1Name << "..." << endl;
	mediaDevice_["DAVINCI CCDC"].SetSubDevice(subdevice1Name);
	mediaDevice_["DAVINCI CCDC"].SetMediaBusFormat(frameFormat);
	
	char subdevice2Name[] = "/dev/v4l-subdev3";
	AO_MESSAGE << "Attempting to open " << subdevice2Name << "..." << endl;
	mediaDevice_["DAVINCI PREVIEWER"].SetSubDevice(subdevice2Name);
	
	//set default previewer config... I think this might only be neccessary to get the default continuous configs in the next step
	prev_channel_config previewerChannelConfig;
	previewerChannelConfig.len = 0;
	previewerChannelConfig.config = 0;
	AO_MESSAGE << "Attempting to set previewer default configuration..." << endl;
	if(0 > mediaDevice_["DAVINCI PREVIEWER"].SubDeviceIOControl(PREV_S_CONFIG, &previewerChannelConfig))
	{
		AO_ERROR << "Can't set previewer default configuration:" << strerror(errno);
		//throw std::runtime_error("Can't set previewer default configuration");
		abort();
	}
	//get default continuous config
	prev_continuous_config previewerContinuousConfig;
	bzero(&previewerContinuousConfig, sizeof(prev_continuous_config));
	previewerChannelConfig.len = sizeof(prev_continuous_config);
	previewerChannelConfig.config = &previewerContinuousConfig;
	AO_MESSAGE << "Attempting to get previewer default configuration for continuous mode..." << endl;
	if(0 > mediaDevice_["DAVINCI PREVIEWER"].SubDeviceIOControl(PREV_G_CONFIG, &previewerChannelConfig))
	{
		AO_ERROR << "Can't get previewer default configuration for continuous mode:" << strerror(errno);
		//throw std::runtime_error("Can't set previewer default configuration");
		abort();
	}
	//now set the continuous mode parameters we need...
	//for some reason we need to configure these fields again?!
	previewerChannelConfig.len = sizeof(prev_continuous_config);
	previewerContinuousConfig.bypass = IPIPE_BYPASS_ON;
	previewerChannelConfig.config = &previewerContinuousConfig;
	AO_MESSAGE << "Attempting to set previewer final configuration..." << endl;
	if(0 > mediaDevice_["DAVINCI PREVIEWER"].SubDeviceIOControl(PREV_S_CONFIG, &previewerChannelConfig))
	{
		AO_ERROR << "Can't set previewer final configuration:" << strerror(errno);
		//throw std::runtime_error("Can't set previewer default configuration");
		abort();
	}
	//FIXME I have no idea what the hell the point of this next section is
	prev_cap previewerCapabilities;
	previewerCapabilities.index = 0;
	prev_module_param previewerModuleParameters;
	while(1)
	{
		if( 0 > mediaDevice_["DAVINCI PREVIEWER"].SubDeviceIOControl(PREV_ENUM_CAP, &previewerCapabilities) )
		{
			break;
		}
		strcpy(previewerModuleParameters.version, previewerCapabilities.version);
		previewerModuleParameters.module_id = previewerCapabilities.module_id;
		AO_MESSAGE << "Setting default for previewer module " << previewerCapabilities.module_name << endl;
		previewerModuleParameters.param = 0;
		if( 0 > mediaDevice_["DAVINCI PREVIEWER"].SubDeviceIOControl(PREV_S_PARAM, &previewerModuleParameters) )
		{
			AO_ERROR << "Can't set default parameters for module " << previewerCapabilities.module_name << endl;
			abort();
		}
		++previewerCapabilities.index;
	}	
	mediaDevice_["DAVINCI PREVIEWER"].SetMediaBusFormat(frameFormat);
	
	char subdevice3Name[] = "/dev/v4l-subdev4";
	AO_MESSAGE << "Attempting to open " << subdevice3Name << "..." << endl;
	mediaDevice_["DAVINCI RESIZER"].SetSubDevice(subdevice3Name);

	//set default resizer config... I think this might only be neccessary to get the default continuous configs in the next step
	rsz_channel_config resizerChannelConfig;
	resizerChannelConfig.chain = 1;	//take input from previewer
	resizerChannelConfig.len = 0;
	resizerChannelConfig.config = 0;
	AO_MESSAGE << "Attempting to set resizer default configuration..." << endl;
	if(0 > mediaDevice_["DAVINCI RESIZER"].SubDeviceIOControl(RSZ_S_CONFIG, &resizerChannelConfig))
	{
		AO_ERROR << "Can't set resizer default configuration:" << strerror(errno);
		//throw std::runtime_error("Can't set resizer default configuration");
		abort();
	}
	//get default continuous config
	rsz_continuous_config resizerContinuousConfig;
	bzero(&resizerContinuousConfig, sizeof(rsz_continuous_config));
	resizerChannelConfig.chain = 1;	//take input from previewer
	resizerChannelConfig.len = sizeof(rsz_continuous_config);
	resizerChannelConfig.config = &resizerContinuousConfig;
	AO_MESSAGE << "Attempting to get resizer default configuration for continuous mode..." << endl;
	if(0 > mediaDevice_["DAVINCI RESIZER"].SubDeviceIOControl(RSZ_G_CONFIG, &resizerChannelConfig))
	{
		AO_ERROR << "Can't get resizer default configuration for continuous mode:" << strerror(errno);
		//throw std::runtime_error("Can't set resizer default configuration");
		abort();
	}
	//now set the continuous mode parameters we need...
	resizerContinuousConfig.output1.enable = 1;	//output1 doesn't support changing the pixel format... WTF
	resizerContinuousConfig.output2.enable = 1;
	resizerContinuousConfig.output2.width = captureWidth_;
	resizerContinuousConfig.output2.height = captureHeight_;
	resizerContinuousConfig.output2.pix_fmt = IPIPE_YUV420SP;
	//resizerContinuousConfig.output1.pix_fmt = IPIPE_YUV420SP;
	
	//for some reason we need to configure these fields again?!
	resizerChannelConfig.chain = 1;	//take input from previewer
	resizerChannelConfig.len = sizeof(rsz_continuous_config);
	resizerChannelConfig.config = &resizerContinuousConfig;
	AO_MESSAGE << "Attempting to set resizer final configuration..." << endl;
	if(0 > mediaDevice_["DAVINCI RESIZER"].SubDeviceIOControl(RSZ_S_CONFIG, &resizerChannelConfig))
	{
		AO_ERROR << "Can't set resizer final configuration:" << strerror(errno);
		//throw std::runtime_error("Can't set resizer default configuration");
		abort();
	}
		
	frameFormat.code = V4L2_MBUS_FMT_NV12_1X20;
	//N.B. this is only setting the output pad format... trying to set the input pad format results in "Operation Not Permitted" and general badness...
	mediaDevice_["DAVINCI RESIZER"].SetMediaBusOutputFormat(frameFormat);

//deviceName is set outside this function to /dev/video4, the resizer output
	if(-1 == (fd_ = open(deviceName, O_RDWR, 0)))
	{
		AO_ERROR << "cannot open " << deviceName << ": " << strerror(errno) << endl;
		return;
	}
	
//input is 0
	if(-1 == ioctl(fd_, VIDIOC_S_INPUT, &input_))
	{
		AO_ERROR << "VIDIOC_S_INPUT failed for input " << input_ << ": " << strerror(errno) << endl;
		return;
	}
//sanity checks on device
	if(-1 == ioctl(fd_, VIDIOC_QUERYCAP, &v4l2Capability_))
	{
		AO_ERROR << "VIDIOC_QUERYCAP failed: " << strerror(errno) << endl;
		return;
	}

	if(!(v4l2Capability_.capabilities & V4L2_CAP_VIDEO_CAPTURE))
	{
		AO_ERROR << "doesn't support capture" << endl;
		return;
	}

	if(!(v4l2Capability_.capabilities & V4L2_CAP_STREAMING))
	{
		AO_ERROR << "doesn't support streaming" << endl;
		return;
	}
	
	v4l2VideoStandard_ = V4L2_STD_NTSC;
	if(-1 == ioctl(fd_, VIDIOC_S_STD, &v4l2VideoStandard_))
	{
		AO_ERROR << "VIDIOC_S_STD to " << v4l2VideoStandard_ << " failed: " << strerror(errno) << endl;
		return;
	}

	Zero(v4l2Format_);	
	v4l2Format_.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	v4l2Format_.fmt.pix.width = captureWidth_;
	v4l2Format_.fmt.pix.height = captureHeight_;
	v4l2Format_.fmt.pix.pixelformat = V4L2_PIX_FMT_NV12;
	v4l2Format_.fmt.pix.field = V4L2_FIELD_INTERLACED; //should this be NONE?

	char fourcc[5] = {0, 0, 0, 0, 0};

	AO_MESSAGE << "Attempting to set capture format:" << endl;	
	AO_MESSAGE << "\ttype:" << v4l2Format_.type << endl;	
	AO_MESSAGE << "\twidth:" << v4l2Format_.fmt.pix.width << endl;	
	AO_MESSAGE << "\theight:" << v4l2Format_.fmt.pix.height << endl;	
	memcpy(fourcc, &v4l2Format_.fmt.pix.pixelformat, 4);
	AO_MESSAGE << "\tpixel format:" << fourcc << endl;	
	AO_MESSAGE << "\tfield:" << v4l2Format_.fmt.pix.field << endl;	
	
	if(-1 == ioctl(fd_, VIDIOC_S_FMT, &v4l2Format_))
	{
		AO_ERROR << "VIDIOC_S_FMT failed: " << strerror(errno) << endl;
		return;
	}

	AO_MESSAGE << "Reading back capture format:" << endl;	
	
	AO_MESSAGE << "\ttype:" << v4l2Format_.type << endl;	
	AO_MESSAGE << "\twidth:" << v4l2Format_.fmt.pix.width << endl;	
	AO_MESSAGE << "\theight:" << v4l2Format_.fmt.pix.height << endl;	
	AO_MESSAGE << "\tbytesperline:" << v4l2Format_.fmt.pix.bytesperline << endl;	
	memcpy(fourcc, &v4l2Format_.fmt.pix.pixelformat, 4);
	AO_MESSAGE << "\tpixel format:" << fourcc << endl;	
	AO_MESSAGE << "\tfield:" << v4l2Format_.fmt.pix.field << endl;	
//numBuffersRequested is 3
	AO_MESSAGE << "Requesting " << numBuffersRequested_ << " capture buffers..." << endl;
	Zero(v4l2RequestBuffers_);
	v4l2RequestBuffers_.count = numBuffersRequested_;
	v4l2RequestBuffers_.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	v4l2RequestBuffers_.memory = V4L2_MEMORY_MMAP;
	if(-1 == ioctl(fd_, VIDIOC_REQBUFS, &v4l2RequestBuffers_))
	{
		AO_ERROR << "VIDIOC_REQBUFS failed: " << strerror(errno) << endl;
		return;
	}

	AO_MESSAGE << "Number of buffers granted:" << v4l2RequestBuffers_.count << endl;
	
	if(v4l2RequestBuffers_.count < numBuffersRequested_)
	{
		AO_ERROR << "too few buffers available: " << v4l2RequestBuffers_.count << "<" << numBuffersRequested_ << endl;
		return;
	}

	videoBuffers_.resize(v4l2RequestBuffers_.count);
	v4l2_buffer* v4l2BuffersTemp = new v4l2_buffer[v4l2RequestBuffers_.count];

	for(unsigned int bufferIndex = 0; bufferIndex < v4l2RequestBuffers_.count; bufferIndex++)
	{
		v4l2_buffer& buffer = v4l2BuffersTemp[bufferIndex];
		Zero(buffer);

		buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
		buffer.memory = V4L2_MEMORY_MMAP;
		buffer.index = bufferIndex;
		if(-1 == ioctl(fd_, VIDIOC_QUERYBUF, &buffer))
		{
			AO_ERROR << "VIDIOC_QUERYBUF failed: " << strerror(errno) << endl;
			return;
		}
		AO_MESSAGE << "VIDIOC_QUERYBUF for buffer " << buffer.index << endl;
		AO_MESSAGE << "\ttype:" << buffer.type << endl;
		AO_MESSAGE << "\tbytesused:" << buffer.bytesused << endl;
		AO_MESSAGE << "\tflags:" << buffer.flags << endl;
		AO_MESSAGE << "\tfield:" << buffer.field << endl;
		AO_MESSAGE << "\tmemory:" << buffer.memory << endl;
		AO_MESSAGE << "\tlength:" << buffer.length << endl;
		AO_MESSAGE << "\toffset:" << buffer.m.offset << endl;
		videoBuffers_[bufferIndex].SetSize(buffer.length);
		videoBuffers_[bufferIndex].SetStart(	(int)mmap((void *)0,
								buffer.length,
								PROT_READ | PROT_WRITE,
								MAP_SHARED,
								fd_, 
								buffer.m.offset)	);
		if((int)MAP_FAILED == videoBuffers_[bufferIndex].GetStart())
		{
			AO_ERROR << "memory map failed for buffer " << bufferIndex << ": " << strerror(errno) << endl;
			return;
		}
		
		if(-1 == ioctl(fd_, VIDIOC_QBUF, &buffer))
		{
			AO_ERROR << "VIDIOC_QBUF failed for buffer: " << bufferIndex << ":" << strerror(errno) << endl;
			return;
		}
		videoBuffers_[bufferIndex].SetRelease(boost::bind(&VPFECapture::ReleaseCaptureBuffer,this,buffer));
	}


Another function calls the STREAMON ioctl, but when I go to DQBUF, that call never returns. I don't have this problem with the "DAVINCI VIDEO CCDC output", but that doesn't give me the right format for the encoder.

What am I doing wrong?  Is this generally the correct method to do D1 composite capture and H.264 encode using TI's encoder on the DM365, or am I off the mark?

If the resizer has two outputs associated with the RSZ_S_CONFIG, which one ends up at /dev/video4?  And, if it's output1, how do I configure it to be YUV420SP (there's no pix_fmt field for output1...)?

Thanks in advance for any help...

  • Hi,

    Not sure which branch you are using as linux source use this branch

    http://arago-project.org/git/projects/?p=linux-davinci.git;a=shortlog;h=refs/heads/dvsdk 

    in which NV12 support has been added. and for the examples refer this branch

    http://arago-project.org/git/projects/?p=examples-davinci.git;a=shortlog;h=refs/heads/422-420SP

    and refer resizer_ss.c which has support for NV12 support.

    Thx,

    --Prabhakar Lad

  • Hi Prabhakar,

    Thanks for your response.  I am using the dvsdk branch of the linux-davinci repository.

    I've seen the resizer_ss.c example, but that has the resizer working off of single shot mode using user supplied buffers.  If I were to capture from the CCDC directly, then pass that buffer into the resizer in single shot mode and then pass the result from that into the encoder, I'd be incurring at least an extra buffer of memory overhead.  It's not quite what I want.  I'm wondering how to set up the capture pipeline so that I can stream NV12 frames directly from the video output node, with the resizer being chained off of the previewer and CCDC in continuous mode.  Is this simply not possible with the DM365?  I'd be a little baffled if TI wrote an encoder that doesn't work off of their own capture hardware without having to jump through hoops...


    Thanks again; I'd appreciate any more insight.

    Ryan

  • Hi Frank,

     

    /* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * Redistributions of source code must retain the above copyright
     * notice, this list of conditions and the following disclaimer.
     *
     * Redistributions in binary form must reproduce the above copyright
     * notice, this list of conditions and the following disclaimer in the
     * documentation and/or other materials provided with the
     * distribution.
     *
     * Neither the name of Texas Instruments Incorporated nor the names of
     * its contributors may be used to endorse or promote products derived
     * from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *NOTE : This aplication needs CMEM.
     *       [TVP7002]--->[CCDC]--->[PREVIEWER]--->[Video node] media pipeline will be set
     *       and frames captured.
     */
    
    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/ioctl.h>
    #include <fcntl.h>
    #include <unistd.h>
    #include <stdlib.h>
    #include <errno.h>
    #include <string.h>
    #include <sys/mman.h>
    #include <getopt.h>
    #include <sys/mman.h>
    #include <sys/time.h>
    #include <linux/videodev.h>
    #include <linux/videodev2.h>
    #include <media/davinci/imp_previewer.h>
    #include <media/davinci/imp_resizer.h>
    #include <media/davinci/dm365_ipipe.h>
    #include <media/davinci/vpfe_capture.h>
    #include <linux/media.h>
    #include <linux/v4l2-subdev.h>
    #include "cmem.h"
    #include "common.h"
    /*******************************************************************************/
    #define ALIGN(x, y)	(((x + (y-1))/y)*y)
    #define CLEAR(x) memset (&(x), 0, sizeof (x))
    
    /* structure to hold address */
    struct buf_info {
    	void *user_addr;
    	unsigned long phy_addr;
    };
    
    #define APP_NUM_BUFS	3
    /* capture buffer addresses stored here */
    struct buf_info			capture_buffers[APP_NUM_BUFS];
    struct buf_info 		*output1_buffers[APP_NUM_BUFS];
    
    struct media_entity_desc	entity[10];
    struct media_links_enum		links;
    int				entities_count;
    
    #define CODE		V4L2_MBUS_FMT_YUYV10_1X20
    #define CODE1		V4L2_MBUS_FMT_YUYV8_2X8
    #define CODE2		V4L2_MBUS_FMT_NV12_1X20
    
    int width = 1280, height = 720;
    int buf_size = ALIGN((1280*720*2), 4096);
    
    static unsigned long long prev_ts;
    static unsigned long long curr_ts;
    static unsigned long fp_period_average;
    static unsigned long fp_period_max;
    static unsigned long fp_period_min;
    static unsigned long fp_period;
    
    /*******************************************************************************
     * allocate_user_buffers() allocate buffer using CMEM
     ******************************************************************************/
    int allocate_user_buffers(int in_buf_size)
    {
    	void *pool;
    	int i;
    
    	CMEM_AllocParams  alloc_params;
    	printf("calling cmem utilities for allocating frame buffers\n");
    	CMEM_init();
    
    	alloc_params.type = CMEM_POOL;
    	alloc_params.flags = CMEM_NONCACHED;
    	alloc_params.alignment = 32;
    	pool = CMEM_allocPool(0, &alloc_params);
    
    	if (NULL == pool) {
    		printf("Failed to allocate cmem pool\n");
    		return -1;
    	}
    	printf("Allocating capture buffers :buf size = %d \n", in_buf_size);
    
    	for (i=0; i < APP_NUM_BUFS; i++) {
    		capture_buffers[i].user_addr = CMEM_alloc(in_buf_size, &alloc_params);
    		if (capture_buffers[i].user_addr) {
    			capture_buffers[i].phy_addr = CMEM_getPhys(capture_buffers[i].user_addr);
    			if (0 == capture_buffers[i].phy_addr) {
    				printf("Failed to get phy cmem buffer address\n");
    				return -1;
    			}
    		} else {
    			printf("Failed to allocate cmem buffer\n");
    			return -1;
    		}
    		printf("Got %p from CMEM, phy = %p\n", capture_buffers[i].user_addr,
    			(void *)capture_buffers[i].phy_addr);
    	}
    
    	printf("**********************************************\n");
    /*
    	for (i=0; i < APP_NUM_BUFS; i++) {
    		output1_buffers[i]->user_addr = CMEM_alloc(out_buf_size, &alloc_params);
    		if (output1_buffers[i]->user_addr) {
    			output1_buffers[i]->phy_addr = CMEM_getPhys(output1_buffers[i]->user_addr);
    			if (0 == output1_buffers[i]->phy_addr) {
    				printf("Failed to get phy cmem buffer address\n");
    				return -1;
    			}
    		} else {
    			printf("Failed to allocate cmem buffer\n");
    			return -1;
    		}
    		printf("Got %p from CMEM, phy = %p\n", output1_buffers[i]->user_addr,
    			(void *)output1_buffers[i]->phy_addr);
    	}
    	printf("**********************************************\n");*/
    
    	return 0;
    }
    
    int main(int argc, char *argp[])
    {
    	int i, index, media_fd = 0, tvp_fd = 0, ccdc_fd = 0, prv_fd = 0;
    	int rsz_fd = 0, capt_fd = 0, ret, capture_pitch, frame_count;
    	int disp_second_output = 0, second_out_width, second_out_height;
    	int output_format;
    	int h = 0;
    	int num_bytes = 0;
    	struct media_link_desc link;
    	struct v4l2_subdev_format fmt;
    	struct v4l2_input input;
    	struct v4l2_dv_preset preset;
    	struct v4l2_format v4l2_fmt;
    	struct v4l2_requestbuffers req;
    	enum v4l2_buf_type type;
    	char *source;
    	struct v4l2_buffer cap_buf;
    	unsigned long temp;
    	void * dmptr;
    	struct prev_channel_config prev_chan_config;
    	struct prev_continuous_config prev_cont_config;
    	struct prev_cap cap;
    	struct prev_module_param mod_param;
    	struct rsz_channel_config rsz_chan_config;
    	struct rsz_continuous_config rsz_cont_config;
    	int E_VIDEO;
    	int E_TVP7002;
    	int E_CCDC;
    	int E_PRV;
    	int E_RSZ;
    
    	FILE* file = (FILE*) malloc(sizeof(FILE*));
    
    	/* 2.allocate buffers using cmem */
    	if (allocate_user_buffers(ALIGN((width * height * 2), 4096)) < 0) {
    		printf("Unable to Allocate user buffers\n");
    		goto cleanup;
    	}
    
    	/* 3.open media device */
    	media_fd = open("/dev/media0", O_RDWR);
    	if (media_fd < 0) {
    		printf("%s: Can't open media device %s\n", __func__, "/dev/media0");
    		goto cleanup;
    	}
    
    	/* 4.enumerate media-entities */
    	printf("4.enumerating media entities\n");
    	index = 0;
    	do {
    		memset(&entity[index], 0, sizeof(entity));
    		entity[index].id = index | MEDIA_ENT_ID_FLAG_NEXT;
    
    		ret = ioctl(media_fd, MEDIA_IOC_ENUM_ENTITIES, &entity[index]);
    		if (ret < 0) {
    			if (errno == EINVAL)
    				break;
    		}else {
    			if (!strcmp(entity[index].name, E_VIDEO_RSZ_OUT_NAME)) {
    				E_VIDEO =  entity[index].id;
    			}
    			else if (!strcmp(entity[index].name, E_TVP7002_NAME)) {
    				E_TVP7002 =  entity[index].id;
    			}
    			else if (!strcmp(entity[index].name, E_CCDC_NAME)) {
    				E_CCDC =  entity[index].id;
    			}
    			else if (!strcmp(entity[index].name, E_PRV_NAME)) {
    				E_PRV =  entity[index].id;
    			}
    			else if (!strcmp(entity[index].name, E_RSZ_NAME)) {
    				E_RSZ =  entity[index].id;
    			}
    			printf("[%x]:%s\n", entity[index].id, entity[index].name);
    		}
    
    		index++;
    	} while (ret == 0);
    
    	entities_count = index;
    	printf("total number of entities: %x\n", entities_count);
    	printf("**********************************************\n");
    
    	/* 5.enumerate links for each entity */
    	printf("5.enumerating links/pads for entities\n");
    	for(index = 0; index < entities_count; index++) {
    
    		links.entity = entity[index].id;
    		links.pads = malloc(sizeof( struct media_pad_desc) * entity[index].pads);
    		links.links = malloc(sizeof(struct media_link_desc) * entity[index].links);
    
    		ret = ioctl(media_fd, MEDIA_IOC_ENUM_LINKS, &links);
    		if (ret < 0) {
    			if (errno == EINVAL)
    				break;
    		} else {
    			/* display pads info first */
    			if(entity[index].pads)
    				printf("pads for entity %x=", entity[index].id);
    
    			for(i = 0;i< entity[index].pads; i++)
    			{
    				printf("(%x, %s) ", links.pads->index,(links.pads->flags & MEDIA_PAD_FL_INPUT)?"INPUT":"OUTPUT");
    				links.pads++;
    			}
    			printf("\n");
    			/* display links now */
    			for(i = 0;i< entity[index].links; i++)
    			{
    				printf("[%x:%x]-------------->[%x:%x]",links.links->source.entity,
    				       links.links->source.index,links.links->sink.entity,links.links->sink.index);
    				       if(links.links->flags & MEDIA_LNK_FL_ENABLED)
    						printf("\tACTIVE\n");
    				       else
    						printf("\tINACTIVE \n");
    
    				links.links++;
    			}
    
    			printf("\n");
    		}
    	}
    
    	printf("**********************************************\n");
    
    	
    
    	/* 6. enable 'tvp7002-->ccdc' link */
    	printf("6. ENABLEing link [tvp7002]----------->[ccdc]\n");
    	memset(&link, 0, sizeof(link));
    	link.flags |=  MEDIA_LNK_FL_ENABLED;
    	link.source.entity = E_TVP7002;
    	link.source.index = P_TVP7002;
    	link.source.flags = MEDIA_PAD_FL_OUTPUT;
    	link.sink.entity = E_CCDC;
    	link.sink.index = P_CCDC_SINK;
    	link.sink.flags = MEDIA_PAD_FL_INPUT;
    
    	ret = ioctl(media_fd, MEDIA_IOC_SETUP_LINK, &link);
    	if(ret) {
    		printf("failed to enable link between tvp7002 and ccdc\n");
    		goto cleanup;
    	} else
    		printf("[tvp7002]----------->[ccdc]\tENABLED\n");
    
    	/* 7.enable 'ccdc-->prv' link */
    	printf("7. ENABLEing link [CCDC]----------->[PRV]\n");
    	memset(&link, 0, sizeof(link));
    	link.flags |=  MEDIA_LNK_FL_ENABLED;
    	link.source.entity = E_CCDC;
    	link.source.index = P_CCDC_SOURCE;
    	link.source.flags = MEDIA_PAD_FL_OUTPUT;
    	link.sink.entity = E_PRV;
    	link.sink.index = P_PRV_SINK;
    	link.sink.flags = MEDIA_PAD_FL_INPUT;
    
    	ret = ioctl(media_fd, MEDIA_IOC_SETUP_LINK, &link);
    	if(ret) {
    		printf("failed to enable link between ccdc and previewer\n");
    		goto cleanup;
    	} else
    		printf("[ccdc]----------->[prv]\tENABLED\n");
    
    	/* 8.enable 'prv-->rsz' link */
    	printf("7. ENABLEing link [prv]----------->[rsz]\n");
    	memset(&link, 0, sizeof(link));
    
    	link.flags |=  MEDIA_LNK_FL_ENABLED;
    	link.source.entity = E_PRV;
    	link.source.index = P_PRV_SOURCE;
    	link.source.flags = MEDIA_PAD_FL_OUTPUT;
    	link.sink.entity = E_RSZ;
    	link.sink.index = P_RSZ_SINK;
    	link.sink.flags = MEDIA_PAD_FL_INPUT;
    
    	ret = ioctl(media_fd, MEDIA_IOC_SETUP_LINK, &link);
    	if(ret) {
    		printf("failed to enable link between prv and rsz\n");
    		goto cleanup;
    	} else
    		printf("[prv]----------->[rsz]\tENABLED\n");
    
    	/* 9. enable 'rsz->memory' link */
    	printf("8. ENABLEing link [rsz]----------->[video_node]\n");
    	memset(&link, 0, sizeof(link));
    	link.flags |=  MEDIA_LNK_FL_ENABLED;
    	link.source.entity = E_RSZ;
    	link.source.index = P_RSZ_SOURCE;
    	link.source.flags = MEDIA_PAD_FL_OUTPUT;
    	link.sink.entity = E_VIDEO;
    	link.sink.index = P_VIDEO;
    	link.sink.flags = MEDIA_PAD_FL_INPUT;
    
    	ret = ioctl(media_fd, MEDIA_IOC_SETUP_LINK, &link);
    	if(ret) {
    		printf("failed to enable link between rsz and video node\n");
    		goto cleanup;
    	} else
    		printf("[rsz]----------->[video_node]\t ENABLED\n");
    
    	printf("**********************************************\n");
    
    	/* 13.open rsz device */
    	rsz_fd = open("/dev/v4l-subdev4", O_RDWR);
    	if(prv_fd == -1) {
    		printf("failed to open %s\n", "/dev/v4l-subdev4");
    		goto cleanup;
    	}
    
    	/* 14. set default configuration in rsz */
    	//rsz_chan_config.oper_mode = IMP_MODE_CONTINUOUS;
    	rsz_chan_config.chain  = 1;
    	rsz_chan_config.len = 0;
    	rsz_chan_config.config = NULL;
    	if (ioctl(rsz_fd, RSZ_S_CONFIG, &rsz_chan_config) < 0) {
    		perror("failed to set default configuration in resizer\n");
    		goto cleanup;
    	} else
    		printf("default configuration setting in resizer successfull\n");
    
    	/* 15. get configuration from rsz */
    	bzero(&rsz_cont_config, sizeof(struct rsz_continuous_config));
    	//rsz_chan_config.oper_mode = IMP_MODE_CONTINUOUS;
    	rsz_chan_config.chain = 1;
    	rsz_chan_config.len = sizeof(struct rsz_continuous_config);
    	rsz_chan_config.config = &rsz_cont_config;
    
    	if (ioctl(rsz_fd, RSZ_G_CONFIG, &rsz_chan_config) < 0) {
    		perror("failed to get resizer channel configuration\n");
    		goto cleanup;
    	} else
    		printf("congiration got from resizer successfully\n");
    
    	/* 16. set configuration in rsz */
    	rsz_cont_config.output1.enable = 1;
    	if (disp_second_output) {
    		rsz_cont_config.output2.enable = 1;
    		rsz_cont_config.output2.width = second_out_width;
    		rsz_cont_config.output2.height = second_out_height;
    		if (output_format)
    			rsz_cont_config.output2.pix_fmt = IPIPE_YUV420SP;
    		else
    			rsz_cont_config.output2.pix_fmt = IPIPE_UYVY;
    	} else
    		rsz_cont_config.output2.enable = 0;
    
    	//rsz_chan_config.oper_mode = IMP_MODE_CONTINUOUS;
    	rsz_chan_config.chain = 1;
    	rsz_chan_config.len = sizeof(struct rsz_continuous_config);
    	rsz_chan_config.config = &rsz_cont_config;
    	if (ioctl(rsz_fd, RSZ_S_CONFIG, &rsz_chan_config) < 0) {
    		perror("failed to set configuration in resizer\n");
    		goto cleanup;
    	} else
    		printf("successfully set configuration in rsz \n");
    
    
    
    	/* 20.open prv device */
    	prv_fd = open("/dev/v4l-subdev3", O_RDWR);
    	if(prv_fd == -1) {
    		printf("failed to open %s\n", "/dev/v4l-subdev3");
    		goto cleanup;
    	}
    
    	/* 21. set default configuration in PRV */
    	//prev_chan_config.oper_mode = IMP_MODE_CONTINUOUS;
    	prev_chan_config.len = 0;
    	prev_chan_config.config = NULL; /* to set defaults in driver */
    	if (ioctl(prv_fd, PREV_S_CONFIG, &prev_chan_config) < 0) {
    		perror("failed to set default configuration on prv\n");
    		goto cleanup;
    	} else
    		printf("default configuration is set successfully on prv\n");
    
    	/* 22. get configuration from prv */
    	//prev_chan_config.oper_mode = IMP_MODE_CONTINUOUS;
    	prev_chan_config.len = sizeof(struct prev_continuous_config);
    	prev_chan_config.config = &prev_cont_config;
    
    	if (ioctl(prv_fd, PREV_G_CONFIG, &prev_chan_config) < 0) {
    		perror("failed to get default configuration from prv\n");
    		goto cleanup;
    	} else
    		printf("got configuration from prv successfully\n");
    
    	/* 23. set configuration in prv */
    	//prev_chan_config.oper_mode = IMP_MODE_CONTINUOUS;
    	prev_chan_config.len = sizeof(struct prev_continuous_config);
    	prev_chan_config.config = &prev_cont_config;
    
    	if (ioctl(prv_fd, PREV_S_CONFIG, &prev_chan_config) < 0) {
    		perror("failed to set configuration on prv\n");
    		goto cleanup;
    	} else
    		printf("configuration is set successfully on prv\n");
    
    	/* 24. setting default prv-params */
    	cap.index=0;
    	while (1) {
    		ret = ioctl(prv_fd , PREV_ENUM_CAP, &cap);
    		if (ret < 0) {
    			break;
    		}
    
    		strcpy(mod_param.version,cap.version);
    		mod_param.module_id = cap.module_id;
    
    		printf("setting default for prv-module %s\n", cap.module_name);
    			mod_param.param = NULL;
    
    		if (ioctl(prv_fd, PREV_S_PARAM, &mod_param) < 0) {
    			printf("error in Setting %s prv-params from driver\n", cap.module_name);
    			goto cleanup;
    		}
    		cap.index++;
    	}
    	printf("**********************************************\n");
    
    	/* 27.open capture device */
    	{
    	if ((capt_fd = open("/dev/video4", O_RDWR | O_NONBLOCK, 0)) <= -1) {
    		printf("failed to open %s \n", "/dev/video4");
    		goto cleanup;
    	}
    
    	/* 28.enumerate inputs supported by capture via tvp514x[wh s active through mc] */
    	printf("12.enumerating INPUTS\n");
    	bzero(&input, sizeof(struct v4l2_input));
    	input.type = V4L2_INPUT_TYPE_CAMERA;
    	input.index = 0;
    	index = 0;
      	while (1) {
    
    		ret = ioctl(capt_fd, VIDIOC_ENUMINPUT, &input);
    		if(ret != 0)
    			break;
    
    		printf("[%x].%s\n", index, input.name);
    
    		bzero(&input, sizeof(struct v4l2_input));
    		index++;
    		input.index = index;
      	}
      	printf("**********************************************\n");
    
    	/* 29.setting COMPONENT input */
    	printf("13.setting COMPONENT input. . .\n");
    	bzero(&input, sizeof(struct v4l2_input));
    	input.type = V4L2_INPUT_TYPE_CAMERA;
    	input.index = 0;
    	if (-1 == ioctl (capt_fd, VIDIOC_S_INPUT, &input.index)) {
    		printf("failed to set COMPONENT with capture device\n");
    		goto cleanup;
    	} else
    		printf("successfully set COMPONENT input\n");
    
    	printf("**********************************************\n");
    
    	/* 30.setting V4L2_DV_720P60 preset */
     	printf("14.setting V4L2_DV_720P60 preset. . .\n");
     	bzero(&preset, sizeof(preset));
     	preset.preset = V4L2_DV_720P60;
     	if (-1 == ioctl(capt_fd, VIDIOC_S_DV_PRESET, &preset)) {
     		printf("failed to set preset on capture device\n");
     		goto cleanup;
     	} else {
     		printf("successfully set V4L2_DV_720P60 preset\n");
     	}
    
    
    	printf("**********************************************\n");
    	/* 10. set format on pad of tvp7002 */
    	tvp_fd = open("/dev/v4l-subdev1", O_RDWR);
    	if(tvp_fd == -1) {
    		printf("failed to open %s\n", "/dev/v4l-subdev1");
    		goto cleanup;
    	}
    
    	printf("8. setting format on pad of tvp7002 entity. . .\n");
    	memset(&fmt, 0, sizeof(fmt));
    
    	fmt.pad = P_TVP7002;
    	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    	fmt.format.code = CODE;
    	fmt.format.width = width;
    	fmt.format.height = height;
    	fmt.format.field = V4L2_FIELD_NONE;
    
    	ret = ioctl(tvp_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    	if(ret) {
    		printf("failed to set format on pad %x\n", fmt.pad);
    		goto cleanup;
    	}
    	else
    		printf("successfully format is set on pad %x\n", fmt.pad);
    	}
    
    	/* 11. set format on sink-pad of ccdc */
    	{
    	ccdc_fd = open("/dev/v4l-subdev2", O_RDWR);
    	if(ccdc_fd == -1) {
    		printf("failed to open %s\n", "/dev/v4l-subdev2");
    		goto cleanup;
    	}
    
    	printf("9. setting format on sink-pad of ccdc entity. . .\n");
    	memset(&fmt, 0, sizeof(fmt));
    
    	fmt.pad = P_CCDC_SINK;
    	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    	fmt.format.code = CODE;
    	fmt.format.width = width;
    	fmt.format.height = height;
    	fmt.format.field = V4L2_FIELD_NONE;
    
    	ret = ioctl(ccdc_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    	if(ret) {
    		printf("failed to set format on pad %x\n", fmt.pad);
    		goto cleanup;
    	}
    	else
    		printf("successfully format is set on pad %x\n", fmt.pad);
    
    	/* 12. set format on OF-pad of ccdc */
    	printf("10. setting format on OF-pad of ccdc entity. . . \n");
    	memset(&fmt, 0, sizeof(fmt));
    
    	fmt.pad = P_CCDC_SOURCE;
    	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    	fmt.format.code = CODE;
    	fmt.format.width = width;
    	fmt.format.height = height;
    	fmt.format.field = V4L2_FIELD_NONE;
    
    	ret = ioctl(ccdc_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    	if(ret) {
    		printf("failed to set format on pad %x\n", fmt.pad);
    		goto cleanup;
    	}
    	else
    		printf("successfully format is set on pad %x\n", fmt.pad);
    
    	/* 25. set format on sink-pad of prv */
    	printf("10. setting format on sink-pad of prv entity. . . \n");
    	memset(&fmt, 0, sizeof(fmt));
    
    	fmt.pad = P_PRV_SINK;
    	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    	fmt.format.code = CODE;
    	fmt.format.width = width;
    	fmt.format.height = height;
    	fmt.format.field = V4L2_FIELD_NONE;
    
    	ret = ioctl(prv_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    	if(ret) {
    		printf("failed to set format on pad %x\n", fmt.pad);
    		goto cleanup;
    	}
    	else
    		printf("successfully format is set on pad %x\n", fmt.pad);
    
    	/* 26. set format on source-pad of prv */
    	printf("10. setting format on source-pad of prv entity. . . \n");
    	memset(&fmt, 0, sizeof(fmt));
    
    	fmt.pad = P_PRV_SOURCE;
    	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    	fmt.format.code = CODE1;
    	fmt.format.width = width;
    	fmt.format.height = height;
    	fmt.format.field = V4L2_FIELD_NONE;
    
    	ret = ioctl(prv_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    	if(ret) {
    		printf("failed to set format on pad %x\n", fmt.pad);
    		goto cleanup;
    	}
    	else
    		printf("successfully format is set on pad %x\n", fmt.pad);
    
    	printf("**********************************************\n");
    	}
    
    	/* 18. set format on sink-pad of rsz */
    	printf("10. setting format on sink-pad of rsz entity. . . \n");
    	memset(&fmt, 0, sizeof(fmt));
    
    	fmt.pad = P_RSZ_SINK;
    	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    	fmt.format.code = CODE1;
    	fmt.format.width = width;
    	fmt.format.height = height;
    	fmt.format.field = V4L2_FIELD_NONE;
    
    	ret = ioctl(rsz_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    	if(ret) {
    		printf("failed to set format on pad %x\n", fmt.pad);
    		goto cleanup;
    	}
    	else
    		printf("successfully format is set on pad %x\n", fmt.pad);
    
    	/* 19. set format on source-pad of rsz */
    	printf("10. setting format on source-pad of rsz entity. . . \n");
    	memset(&fmt, 0, sizeof(fmt));
    
    	fmt.pad = P_RSZ_SOURCE;
    	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    	fmt.format.code = CODE2;
    	fmt.format.width = width;
    	fmt.format.height = height;
    	fmt.format.field = V4L2_FIELD_NONE;
    
    	ret = ioctl(rsz_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    	if(ret) {
    		printf("failed to set format on pad %x\n", fmt.pad);
    		goto cleanup;
    	}
    	else
    		printf("successfully format is set on pad %x\n", fmt.pad);
    
    	/* 31.setting format */
    	printf("15.setting format V4L2_PIX_FMT_UYVY\n");
    	CLEAR(v4l2_fmt);
    	v4l2_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    	v4l2_fmt.fmt.pix.width = width;
    	v4l2_fmt.fmt.pix.height = height;
    	v4l2_fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_NV12;;
    	v4l2_fmt.fmt.pix.field = V4L2_FIELD_NONE;
    	printf ("Image width: %d Height: %d\n", width, height);
    	if (-1 == ioctl(capt_fd, VIDIOC_S_FMT, &v4l2_fmt)) {
    		printf("failed to set format on captute device \n");
    		goto cleanup;
    	} else
    		printf("successfully set the format\n");
    
    	/* 32.call G_FMT for knowing picth */
    	if (-1 == ioctl(capt_fd, VIDIOC_G_FMT, &v4l2_fmt)) {
    		printf("failed to get format from captute device \n");
    		goto cleanup;
    	} else {
    		printf("capture_pitch: %x\n", v4l2_fmt.fmt.pix.bytesperline);
    		printf ("Image width: %d Height: %d\n", v4l2_fmt.fmt.pix.width, v4l2_fmt.fmt.pix.height);
    		capture_pitch = v4l2_fmt.fmt.pix.bytesperline;
    		
    	}
    	printf("**********************************************\n");
    
    	/* 33.make sure 3 buffers are supported for streaming */
    
    	CLEAR(req);
    	req.count = 3;
    	req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    	req.memory = V4L2_MEMORY_USERPTR;
    
    	if (-1 == ioctl(capt_fd, VIDIOC_REQBUFS, &req)) {
    		printf("call to VIDIOC_REQBUFS failed\n");
    		goto cleanup;
    	}
    
    	if (req.count != 3) {
    		printf("3 buffers not supported by capture device");
    		goto cleanup;
    	} else
    		printf("3 buffers are supported for streaming\n");
    
    	printf("**********************************************\n");
    
    	/* 34.queue the buffers */
    	for (i = 0; i < 3; i++) {
    		struct v4l2_buffer buf;
    		CLEAR(buf);
    		buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    		buf.memory = V4L2_MEMORY_USERPTR;
    		buf.index = i;
    		buf.length = buf_size;
    		buf.m.userptr = (unsigned long)capture_buffers[i].user_addr;
    
    		if (-1 == ioctl(capt_fd, VIDIOC_QBUF, &buf)) {
    			printf("call to VIDIOC_QBUF failed\n");
    			goto cleanup;
    		}
    	}
    
    	/* 35.start streaming */
    	CLEAR(type);
    	type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    	if (-1 == ioctl(capt_fd, VIDIOC_STREAMON, &type)) {
    		printf("failed to start streaming on capture device");
    		goto cleanup;
    	} else
    		printf("streaming started successfully\n");
    
    	/* 35.open file in which frames should be saved */
    	
    	file = fopen("tvp7002_ccdc_prv_rsz.yuv", "wa+");
            if (file == NULL) {
    		perror("could not open the file to write");
    		goto cleanup;
    	}
    
    	/* 36.get 20 frames from capture device and store in a file */
    	frame_count = 0;
    	while(frame_count != 200) {
    
    		CLEAR(cap_buf);
    
    		cap_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    		cap_buf.memory = V4L2_MEMORY_USERPTR;
    try_again:
    		ret = ioctl(capt_fd, VIDIOC_DQBUF, &cap_buf);
    		if (ret < 0) {
    			if (errno == EAGAIN) {
    				goto try_again;
    			}
    			printf("failed to DQ buffer from capture device\n");
    			goto cleanup;
    		}
    
    		temp = cap_buf.m.userptr;
    		source = (char *)temp;
    
    		h = height + height/2;
    		num_bytes = width;
    		for(i=0 ; i < h; i++) {
    			fwrite(source, 1 , num_bytes, file);
    			source += capture_pitch;
    		}
    
    		/* Q the buffer for capture, again */
    		ret = ioctl(capt_fd, VIDIOC_QBUF, &cap_buf);
    		if (ret < 0) {
    			printf("failed to Q buffer onto capture device\n");
    			goto cleanup;
    		}
    
    		if (frame_count == 0)
    			prev_ts = (cap_buf.timestamp.tv_sec*1000000) + cap_buf.timestamp.tv_usec;
    		else {
    			curr_ts = (cap_buf.timestamp.tv_sec*1000000) + cap_buf.timestamp.tv_usec;
    			fp_period = curr_ts - prev_ts;
    			if (frame_count == 1) {
    				fp_period_max = fp_period_min = fp_period_average = fp_period;
    			}
    			else {
    				/* calculate jitters and average */
    				if (fp_period > fp_period_max)
    					fp_period_max = fp_period;
    				if (fp_period < fp_period_min)
    					fp_period_min = fp_period;
    
    				fp_period_average =
    					((fp_period_average * frame_count) +
    					fp_period)/(frame_count + 1);
    			}
    			prev_ts = curr_ts;
    		}
    
    		frame_count++;
    
    		printf("frame:%5u, ", frame_count);
    		printf("buf.timestamp:%lu:%lu\n",
    			cap_buf.timestamp.tv_sec, cap_buf.timestamp.tv_usec);
    	}
    
    	printf("**********************************************\n");
    
    	/* 37. do stream off */
    	CLEAR(type);
    	type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    	if (-1 == ioctl(capt_fd, VIDIOC_STREAMOFF, &type)) {
    		printf("failed to stop streaming on capture device");
    		goto cleanup;
    	} else
    		printf("streaming stopped successfully\n");
    
    cleanup:
    
    	 /* 24. de-enable all the links which are active right now */
    	for(index = 0; index < entities_count; index++) {
    
    		links.entity = entity[index].id;
    
    		links.pads = malloc(sizeof( struct media_pad_desc) * entity[index].pads);
    		links.links = malloc(sizeof(struct media_link_desc) * entity[index].links);
    
    		ret = ioctl(media_fd, MEDIA_IOC_ENUM_LINKS, &links);
    		if (ret < 0) {
    			if (errno == EINVAL)
    				break;
    		}else{
    
    			for(i = 0;i< entity[index].links; i++)
    			{
    				       if(links.links->flags & MEDIA_LNK_FL_ENABLED) {
    					        /* de-enable the link */
    					        memset(&link, 0, sizeof(link));
    
    						link.flags |=  ~MEDIA_LNK_FL_ENABLED;
    						link.source.entity = links.links->source.entity;
    						link.source.index = links.links->source.index;
    						link.source.flags = MEDIA_PAD_FL_OUTPUT;
    
    						link.sink.entity = links.links->sink.entity;
    						link.sink.index = links.links->sink.index;
    						link.sink.flags = MEDIA_PAD_FL_INPUT;
    
    						ret = ioctl(media_fd, MEDIA_IOC_SETUP_LINK, &link);
    						if(ret) {
    							printf("failed to de-enable link \n");
    						}
    
    				       }
    
    				links.links++;
    			}
    		}
    	}
    
    	/* 42.close all the file descriptors */
    	printf("closing all the file descriptors. . .\n");
    	if(rsz_fd) {
    		close(rsz_fd);
    		printf("closed reszier sub-device\n");
    	}
    	if(prv_fd) {
    		close(prv_fd);
    		printf("closed previewer sub-device\n");
    	}
    	if(ccdc_fd) {
    		close(ccdc_fd);
    		printf("closed ccdc sub-device\n");
    	}
    	if(tvp_fd) {
    		close(tvp_fd);
    		printf("closed tvp7002 sub-device\n");
    	}
    	if(capt_fd) {
    		close(capt_fd);
    		printf("closed capture device\n");
    	}
    	if(media_fd) {
    		close(media_fd);
    		printf("closed  media device\n");
    	}
    	if(file) {
    		fclose(file);
    		printf("closed the file \n");
    	}
    	return ret;
    }
    ,

    The attached application depicts NV12 output in continuous mode 

    ([TVP7002]--->[CCDC]--->[PRV]--->[RSZ]--->[Video node] media pipeline)

    You can use this application as reference and change accordingly as per requirement.

    Thx,

    --Prabhakar Lad 

  • Frank,

    as you have mentioned in DQBuf your application is not coming out, i doubt your interrupts are generating.

    can you check wether you are gettinginterrupts or not inside your ISR by just putting some printk's.

  • Hi Prabhakar,

    Thanks again for your help.  I have adapted the file you sent; the only step I was previously omitting was setting the DV preset on the resizer output, which I set to V4L2_DV_480P59_94.

    Unfortunately, it is still hanging in the DQBUF call.  However, I did notice something in the kernel output that I hadn't before... there is an error message saying, "invalid mbus code"  As far as I can tell, this comes from vpfe_capture.c in the mbus_to_pix function in the kernel.  I modified the printk on line 153 to tell me which code is being specified, expecting to see 8211 for V4L2_MBUS_FMT_NV12_1x20, but instead it says the code is, "0".  I have set the media bus format on every pin in the chain except for the resizer output sink (because it gives me an error if I try)... so I'm not sure where that 0 is coming from, but I would bet it's integral to the problem.

    Any ideas?  Thanks again for your continued help.

  • Hi Frank,

    I have created a application as you need,  [tvp514x]--->[CCDC]--->[PRV]--->[RSZ]--->[Video node]

    This application is tested for PAL, If you need NTSC appropriately change it.

    Attached is the application.

    /* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
     *
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * Redistributions of source code must retain the above copyright
     * notice, this list of conditions and the following disclaimer.
     *
     * Redistributions in binary form must reproduce the above copyright
     * notice, this list of conditions and the following disclaimer in the
     * documentation and/or other materials provided with the
     * distribution.
     *
     * Neither the name of Texas Instruments Incorporated nor the names of
     * its contributors may be used to endorse or promote products derived
     * from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *NOTE : This aplication needs CMEM.
     *       [tvp514x]--->[CCDC]--->[PRV]--->[RSZ]--->[Video node] media pipeline
     *       will be set and frames captured.
     */
    
    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/ioctl.h>
    #include <fcntl.h>
    #include <unistd.h>
    #include <stdlib.h>
    #include <errno.h>
    #include <string.h>
    #include <sys/mman.h>
    #include <getopt.h>
    #include <sys/mman.h>
    #include <sys/time.h>
    #include <linux/videodev.h>
    #include <linux/videodev2.h>
    #include <linux/media.h>
    #include <linux/v4l2-subdev.h>
    #include <media/davinci/vpfe_capture.h>
    #include <media/davinci/imp_previewer.h>
    #include <media/davinci/imp_resizer.h>
    #include <media/davinci/dm365_ipipe.h>
    #include <media/davinci/dm365_ccdc.h>
    #include <linux/davinci_user.h>
    #include "cmem.h"
    #include "common.h"
    /*******************************************************************************/
    #define ALIGN(x, y)	(((x + (y-1))/y)*y)
    #define CLEAR(x) memset (&(x), 0, sizeof (x))
    
    /* structure to hold address */
    struct buf_info {
    	void *user_addr;
    	unsigned long phy_addr;
    };
    
    #define APP_NUM_BUFS	3
    /* capture buffer addresses stored here */
    struct buf_info			capture_buffers[APP_NUM_BUFS];
    
    struct media_entity_desc	entity[15];
    struct media_links_enum		links;
    int				entities_count;
    
    #define CODE1		V4L2_MBUS_FMT_YUYV8_2X8
    #define CODE2		V4L2_MBUS_FMT_NV12_1X20
    
    int width = 720, height = 576;
    
    static unsigned long long prev_ts;
    static unsigned long long curr_ts;
    static unsigned long fp_period_average;
    static unsigned long fp_period_max;
    static unsigned long fp_period_min;
    static unsigned long fp_period;
    
    /* ccdc enable tags */
    static int linearization_en;
    static int csc_en;
    static int vldfc_en;
    static int en_culling;
    
    /* prv enable tags */
    static int regular_col_pat;
    /*******************************************************************************
     * allocate_user_buffers() allocate buffer using CMEM
     ******************************************************************************/
    int allocate_user_buffers(int buf_size)
    {
    	void *pool;
    	int i;
    
    	CMEM_AllocParams  alloc_params;
    	printf("calling cmem utilities for allocating frame buffers\n");
    	CMEM_init();
    
    	alloc_params.type = CMEM_POOL;
    	alloc_params.flags = CMEM_NONCACHED;
    	alloc_params.alignment = 32;
    	pool = CMEM_allocPool(0, &alloc_params);
    
    	if (NULL == pool) {
    		printf("Failed to allocate cmem pool\n");
    		return -1;
    	}
    	printf("Allocating capture buffers :buf size = %d \n", buf_size);
    
    	for (i=0; i < APP_NUM_BUFS; i++) {
    		capture_buffers[i].user_addr = CMEM_alloc(buf_size, &alloc_params);
    		if (capture_buffers[i].user_addr) {
    			capture_buffers[i].phy_addr = CMEM_getPhys(capture_buffers[i].user_addr);
    			if (0 == capture_buffers[i].phy_addr) {
    				printf("Failed to get phy cmem buffer address\n");
    				return -1;
    			}
    		} else {
    			printf("Failed to allocate cmem buffer\n");
    			return -1;
    		}
    		printf("Got %p from CMEM, phy = %p\n", capture_buffers[i].user_addr,
    			(void *)capture_buffers[i].phy_addr);
    	}
    
    	printf("**********************************************\n");
    
    	return 0;
    }
    
    int main(int argc, char *argp[])
    {
    
    	int i, index, media_fd = 0, tvp_fd = 0, rsz_fd = 0, prv_fd = 0;
    	int ccdc_fd = 0, capt_fd = 0, ret, capture_pitch, frame_count;
    	int disp_second_output = 1, second_out_width, second_out_height, output_format=1;
    	int bufsize;
    	struct media_link_desc link;
    	struct v4l2_subdev_format fmt;
    	struct v4l2_input input;
    	struct v4l2_dv_preset preset;
    	struct v4l2_format v4l2_fmt;
    	struct v4l2_requestbuffers req;
    	enum v4l2_buf_type type;
    	char *source;
    	v4l2_std_id cur_std;
    	struct v4l2_buffer cap_buf;
    	struct ccdc_config_params_raw raw_params;
    	struct ccdc_float_16 r = {0, 511};
    	struct ccdc_float_16 gr = {0, 511};
    	struct ccdc_float_16 gb = {0, 511};
    	struct ccdc_float_16 b = {0, 511};
    	struct ccdc_float_8 csc_coef_val = { 1, 0 };
    	struct prev_channel_config prev_chan_config;
    	struct prev_continuous_config prev_cont_config;
    	struct prev_cap cap;
    	struct prev_module_param mod_param;
    	struct rsz_channel_config rsz_chan_config;
    	struct rsz_continuous_config rsz_cont_config;
    	int E_VIDEO;
    	int E_TVP514X;
    	int E_CCDC;
    	int E_PRV;
    	int E_RSZ;
    	int bytesperline;
    
    	FILE* file = (FILE*) malloc(sizeof(FILE*));
    	if (output_format){
    		bytesperline = ALIGN(width,32);
    		bufsize = height * bytesperline * 1.5;
    		printf("out format is 420sp and buf size is %d!!!\n",bufsize);
    	} else {
    		bytesperline = ALIGN(width,32);
    		bufsize = height * bytesperline * 2;
    		printf("out format is 420sp and buf size is %d!!!\n",bufsize);
    	}
    	
    	
    	/* 2.allocate buffers using cmem */
    	if (allocate_user_buffers(bufsize) < 0) {
    		printf("Unable to Allocate user buffers\n");
    		goto cleanup;
    	}
    
    	/* 3.open media device */
    	media_fd = open("/dev/media0", O_RDWR);
    	if (media_fd < 0) {
    		printf("%s: Can't open media device %s\n", __func__, "/dev/media0");
    		goto cleanup;
    	}
    
    	/* 4.enumerate media-entities */
    	printf("4.enumerating media entities\n");
    	index = 0;
    	do {
    		memset(&entity[index], 0, sizeof(entity));
    		entity[index].id = index | MEDIA_ENT_ID_FLAG_NEXT;
    
    		ret = ioctl(media_fd, MEDIA_IOC_ENUM_ENTITIES, &entity[index]);
    		if (ret < 0) {
    			if (errno == EINVAL)
    				break;
    		}else {
    			if (!strcmp(entity[index].name, E_VIDEO_RSZ_OUT_NAME)) {
    				E_VIDEO =  entity[index].id;
    			}
    			else if (!strcmp(entity[index].name, E_TVP514X_NAME)) {
    				E_TVP514X =  entity[index].id;
    				printf("1 major minor are : %d %d\n",entity[index].v4l.major,entity[index].v4l.minor);
    			}
    			else if (!strcmp(entity[index].name, E_CCDC_NAME)) {
    				E_CCDC =  entity[index].id;
    				printf("2 major minor are : %d %d\n",entity[index].v4l.major,entity[index].v4l.minor);
    			}
    			else if (!strcmp(entity[index].name, E_PRV_NAME)) {
    				E_PRV =  entity[index].id;
    				printf("3 major minor are : %d %d\n",entity[index].v4l.major,entity[index].v4l.minor);
    			}
    			else if (!strcmp(entity[index].name, E_RSZ_NAME)) {
    				E_RSZ =  entity[index].id;
    				printf("4 major minor are : %d %d\n",entity[index].v4l.major,entity[index].v4l.minor);
    			}
    			printf("[%x]:%s\n", entity[index].id, entity[index].name);
    		}
    
    		index++;
    	}while (ret == 0);
    	entities_count = index;
    	printf("total number of entities: %d\n", entities_count);
    	printf("**********************************************\n");
    
    	/* 5.enumerate links for each entity */
    	printf("5.enumerating links/pads for entities\n");
    	for(index = 0; index < entities_count; index++) {
    
    		links.entity = entity[index].id;
    
    		links.pads = malloc(sizeof( struct media_pad_desc) * entity[index].pads);
    		links.links = malloc(sizeof(struct media_link_desc) * entity[index].links);
    
    		ret = ioctl(media_fd, MEDIA_IOC_ENUM_LINKS, &links);
    		if (ret < 0) {
    			if (errno == EINVAL)
    				break;
    		}else{
    			/* display pads info first */
    			if(entity[index].pads)
    				printf("pads for entity %x=", entity[index].id);
    
    			for(i = 0;i< entity[index].pads; i++)
    			{
    				printf("(%x, %s) ", links.pads->index,(links.pads->flags & MEDIA_PAD_FL_INPUT)?"INPUT":"OUTPUT");
    				links.pads++;
    			}
    
    			printf("\n");
    
    			/* display links now */
    			for(i = 0;i< entity[index].links; i++)
    			{
    				printf("[%x:%x]-------------->[%x:%x]",links.links->source.entity,
    				       links.links->source.index,links.links->sink.entity,links.links->sink.index);
    				       if(links.links->flags & MEDIA_LNK_FL_ENABLED)
    						printf("\tACTIVE\n");
    				       else
    						printf("\tINACTIVE \n");
    
    				links.links++;
    			}
    
    			printf("\n");
    		}
    	}
    
    	printf("**********************************************\n");
    
    	/* 6. enable 'tvp514x-->ccdc' link */
    	printf("6. ENABLEing link [tvp7002]----------->[ccdc]\n");
    	memset(&link, 0, sizeof(link));
    
    	link.flags |=  MEDIA_LNK_FL_ENABLED;
    	link.source.entity = E_TVP514X;
    	link.source.index = P_TVP514X;
    	link.source.flags = MEDIA_PAD_FL_OUTPUT;
    
    	link.sink.entity = E_CCDC;
    	link.sink.index = P_CCDC_SINK;
    	link.sink.flags = MEDIA_PAD_FL_INPUT;
    
    	ret = ioctl(media_fd, MEDIA_IOC_SETUP_LINK, &link);
    	if(ret) {
    		printf("failed to enable link between tvp541x and ccdc\n");
    		goto cleanup;
    	} else
    		printf("[tvp514x]----------->[ccdc]\tENABLED\n");
    
    	/* 7.enable 'ccdc-->prv' link */
    	printf("7. ENABLEing link [CCDC]----------->[PRV]\n");
    	memset(&link, 0, sizeof(link));
    
    	link.flags |=  MEDIA_LNK_FL_ENABLED;
    	link.source.entity = E_CCDC;
    	link.source.index = P_CCDC_SOURCE;
    	link.source.flags = MEDIA_PAD_FL_OUTPUT;
    
    	link.sink.entity = E_PRV;
    	link.sink.index = P_PRV_SINK;
    	link.sink.flags = MEDIA_PAD_FL_INPUT;
    
    	ret = ioctl(media_fd, MEDIA_IOC_SETUP_LINK, &link);
    	if(ret) {
    		printf("failed to enable link between ccdc and previewer\n");
    		goto cleanup;
    	} else
    		printf("[ccdc]----------->[prv]\tENABLED\n");
    
    	/* 8.enable 'prv-->rsz' link */
    	printf("7. ENABLEing link [prv]----------->[rsz]\n");
    	memset(&link, 0, sizeof(link));
    
    	link.flags |=  MEDIA_LNK_FL_ENABLED;
    	link.source.entity = E_PRV;
    	link.source.index = P_PRV_SOURCE;
    	link.source.flags = MEDIA_PAD_FL_OUTPUT;
    
    	link.sink.entity = E_RSZ;
    	link.sink.index = P_RSZ_SINK;
    	link.sink.flags = MEDIA_PAD_FL_INPUT;
    
    	ret = ioctl(media_fd, MEDIA_IOC_SETUP_LINK, &link);
    	if(ret) {
    		printf("failed to enable link between prv and rsz\n");
    		goto cleanup;
    	} else
    		printf("[prv]----------->[rsz]\tENABLED\n");
    
    	/* 9. enable 'rsz->memory' link */
    	printf("8. ENABLEing link [rsz]----------->[video_node]\n");
    	memset(&link, 0, sizeof(link));
    
    	link.flags |=  MEDIA_LNK_FL_ENABLED;
    	link.source.entity = E_RSZ;
    	link.source.index = P_RSZ_SOURCE;
    	link.source.flags = MEDIA_PAD_FL_OUTPUT;
    
    	link.sink.entity = E_VIDEO;
    	link.sink.index = P_VIDEO;
    	link.sink.flags = MEDIA_PAD_FL_INPUT;
    
    	ret = ioctl(media_fd, MEDIA_IOC_SETUP_LINK, &link);
    	if(ret) {
    		printf("failed to enable link between rsz and video node\n");
    		goto cleanup;
    	} else
    		printf("[rsz]----------->[video_node]\t ENABLED\n");
    
    	printf("**********************************************\n");
    
    	/* 13.open rsz device */
    	rsz_fd = open("/dev/v4l-subdev4", O_RDWR);
    	if(prv_fd == -1) {
    		printf("failed to open %s\n", "/dev/v4l-subdev3");
    		goto cleanup;
    	}
    
    	/* 14. set default configuration in rsz */
    	//rsz_chan_config.oper_mode = IMP_MODE_CONTINUOUS;
    	rsz_chan_config.chain  = 1;
    	rsz_chan_config.len = 0;
    	rsz_chan_config.config = NULL;
    	if (ioctl(rsz_fd, RSZ_S_CONFIG, &rsz_chan_config) < 0) {
    		perror("failed to set default configuration in resizer\n");
    		goto cleanup;
    	} else
    		printf("default configuration setting in resizer successfull\n");
    
    	/* 15. get configuration from rsz */
    	bzero(&rsz_cont_config, sizeof(struct rsz_continuous_config));
    	//rsz_chan_config.oper_mode = IMP_MODE_CONTINUOUS;
    	rsz_chan_config.chain = 1;
    	rsz_chan_config.len = sizeof(struct rsz_continuous_config);
    	rsz_chan_config.config = &rsz_cont_config;
    
    	if (ioctl(rsz_fd, RSZ_G_CONFIG, &rsz_chan_config) < 0) {
    		perror("failed to get resizer channel configuration\n");
    		goto cleanup;
    	} else
    		printf("congiration got from resizer successfully\n");
    
    	/* 16. set configuration in rsz */
    	//rsz_cont_config.output1.enable = 1;
    	if (disp_second_output) {
    		printf("second output enabled!!!\n");		
    		rsz_cont_config.output2.enable = 1;
    		rsz_cont_config.output2.width = 720; //second_out_width;
    		rsz_cont_config.output2.height = 480; //second_out_height;
    		if (output_format)
    		{
    			printf("out format is 420sp\n");
    			rsz_cont_config.output2.pix_fmt = IPIPE_YUV420SP;
    		}
    		else
    			rsz_cont_config.output2.pix_fmt = IPIPE_UYVY;
    	} else
    		rsz_cont_config.output2.enable = 0;
    
    	//rsz_chan_config.oper_mode = IMP_MODE_CONTINUOUS;
    	rsz_chan_config.chain = 1;
    	rsz_chan_config.len = sizeof(struct rsz_continuous_config);
    	rsz_chan_config.config = &rsz_cont_config;
    	if (ioctl(rsz_fd, RSZ_S_CONFIG, &rsz_chan_config) < 0) {
    		perror("failed to set configuration in resizer\n");
    		goto cleanup;
    	} else
    		printf("successfully set configuration in rsz \n");
    
    	/* 20.open prv device */
    	prv_fd = open("/dev/v4l-subdev3", O_RDWR);
    	if(prv_fd == -1) {
    		printf("failed to open %s\n", "/dev/v4l-subdev2");
    		goto cleanup;
    	}
    
    	/* 21. set default configuration in PRV */
    	//prev_chan_config.oper_mode = IMP_MODE_CONTINUOUS;
    	prev_chan_config.len = 0;
    	prev_chan_config.config = NULL; /* to set defaults in driver */
    	if (ioctl(prv_fd, PREV_S_CONFIG, &prev_chan_config) < 0) {
    		perror("failed to set default configuration on prv\n");
    		goto cleanup;
    	} else
    		printf("default configuration is set successfully on prv\n");
    
    	/* 22. get configuration from prv */
    	//prev_chan_config.oper_mode = IMP_MODE_CONTINUOUS;
    	prev_chan_config.len = sizeof(struct prev_continuous_config);
    	prev_chan_config.config = &prev_cont_config;
    
    	if (ioctl(prv_fd, PREV_G_CONFIG, &prev_chan_config) < 0) {
    		perror("failed to get default configuration from prv\n");
    		goto cleanup;
    	} else
    		printf("got configuration from prv successfully\n");
    
    	/* 23. set configuration in prv */
    	//prev_chan_config.oper_mode = IMP_MODE_CONTINUOUS;
    	prev_chan_config.len = sizeof(struct prev_continuous_config);
    	prev_chan_config.config = &prev_cont_config;
    #if 0
    	if (regular_col_pat) {
    			prev_cont_config.input.colp_elep= IPIPE_BLUE;
    			prev_cont_config.input.colp_elop= IPIPE_GREEN_BLUE;
    			prev_cont_config.input.colp_olep= IPIPE_GREEN_RED;
    			prev_cont_config.input.colp_olop= IPIPE_RED;
    	} else {
    			prev_cont_config.input.colp_elep= IPIPE_GREEN_BLUE;
    			prev_cont_config.input.colp_elop= IPIPE_BLUE;
    			prev_cont_config.input.colp_olep= IPIPE_RED;
    			prev_cont_config.input.colp_olop= IPIPE_GREEN_RED;
    	}
    #endif
    
    	if (ioctl(prv_fd, PREV_S_CONFIG, &prev_chan_config) < 0) {
    		perror("failed to set configuration on prv\n");
    		goto cleanup;
    	} else
    		printf("configuration is set successfully on prv\n");
    
    	/* 24. setting default prv-params */
    	cap.index=0;
    	while (1) {
    		ret = ioctl(prv_fd , PREV_ENUM_CAP, &cap);
    		if (ret < 0) {
    			break;
    		}
    
    		strcpy(mod_param.version,cap.version);
    		mod_param.module_id = cap.module_id;
    
    		printf("setting default for prv-module %s\n", cap.module_name);
    			mod_param.param = NULL;
    
    		if (ioctl(prv_fd, PREV_S_PARAM, &mod_param) < 0) {
    			printf("error in Setting %s prv-params from driver\n", cap.module_name);
    			goto cleanup;
    		}
    		cap.index++;
    	}
    	printf("**********************************************\n");
    
    	/* 14.open capture device */
    	if ((capt_fd = open("/dev/video4", O_RDWR | O_NONBLOCK, 0)) <= -1) {
    		printf("failed to open %s \n", "/dev/video4");
    		goto cleanup;
    	}
    
    	/* 15.enumerate inputs supported by capture via tvp514x[wh s active through mc] */
    	printf("15.enumerating INPUTS\n");
    	bzero(&input, sizeof(struct v4l2_input));
    	input.type = V4L2_INPUT_TYPE_CAMERA;
    	input.index = 0;
    	index = 0;
      	while (1) {
    
    		ret = ioctl(capt_fd, VIDIOC_ENUMINPUT, &input);
    		if(ret != 0)
    			break;
    
    		printf("[%x].%s\n", index, input.name);
    
    		bzero(&input, sizeof(struct v4l2_input));
    		index++;
    		input.index = index;
      	}
      	printf("**********************************************\n");
    
    	/* 16.setting CAMERA as input */
    	printf("16. setting CAMERA as input. . .\n");
    	bzero(&input, sizeof(struct v4l2_input));
    	input.type = V4L2_INPUT_TYPE_CAMERA;
    	input.index = 0;
    	if (-1 == ioctl (capt_fd, VIDIOC_S_INPUT, &input.index)) {
    		printf("failed to set CAMERA with capture device\n");
    		goto cleanup;
    	} else
    		printf("successfully set CAMERA input\n");
    
    	printf("**********************************************\n");
    
    	/* 14.setting PAL std */
    	printf("setting PAL std. . .\n");
    	bzero(&cur_std, sizeof(cur_std));
    	cur_std = V4L2_STD_PAL;
    	if (-1 == ioctl(capt_fd, VIDIOC_S_STD, &cur_std)) {
    		printf("failed to set PAL std on capture device\n");
    		goto cleanup;
    	} else {
    		printf("successfully set PAL std\n");
    	}
    
    
    	/* 8. set format on pad of tvp514x */
    	tvp_fd = open("/dev/v4l-subdev0", O_RDWR);
    	if(tvp_fd == -1) {
    		printf("failed to open %s\n", "/dev/v4l-subdev0");
    		goto cleanup;
    	}
    
    	printf("8. setting format on pad of tvp514x entity. . .\n");
    	memset(&fmt, 0, sizeof(fmt));
    	printf("width and height are: %d %d\n",width,height);
    	fmt.pad = P_TVP514X;
    	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    	fmt.format.code = CODE1;
    	fmt.format.width = width;
    	fmt.format.height = height;
    	fmt.format.colorspace = V4L2_COLORSPACE_SMPTE170M;
    	fmt.format.field = V4L2_FIELD_INTERLACED;
    
    	ret = ioctl(tvp_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    	if(ret) {
    		printf("failed to set format on tvp pad %x\n", fmt.pad);
    		goto cleanup;
    	}
    	else
    		printf("successfully format is set on pad %x\n", fmt.pad);
    
    	/* 9. set format on sink-pad of ccdc */
    	ccdc_fd = open("/dev/v4l-subdev2", O_RDWR);
    	if(ccdc_fd == -1) {
    		printf("failed to open %s\n", "/dev/v4l-subdev1");
    		goto cleanup;
    	}
    
    	/* set format on sink pad of ccdc */
    	printf("12. setting format on sink-pad of ccdc entity. . .\n");
    	memset(&fmt, 0, sizeof(fmt));
    
    	fmt.pad = P_CCDC_SINK;
    	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    	fmt.format.code = CODE1;
    	fmt.format.width = width;
    	fmt.format.height = height;
    	fmt.format.colorspace = V4L2_COLORSPACE_SMPTE170M;
    	fmt.format.field = V4L2_FIELD_INTERLACED;
    
    	ret = ioctl(ccdc_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    	if(ret) {
    		printf("failed to set format on pad %x\n", fmt.pad);
    		goto cleanup;
    	}
    	else
    		printf("successfully format is set on pad %x\n", fmt.pad);
    
    	/* 13. set format on source-pad of ccdc */
    	printf("13. setting format on OF-pad of ccdc entity. . . \n");
    	memset(&fmt, 0, sizeof(fmt));
    
    	fmt.pad = P_CCDC_SOURCE;
    	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    	fmt.format.code = CODE1;
    	fmt.format.width = width;
    	fmt.format.height = height;
    	fmt.format.colorspace = V4L2_COLORSPACE_SMPTE170M;
    	fmt.format.field = V4L2_FIELD_INTERLACED; //V4L2_FIELD_NONE;
    
    	ret = ioctl(ccdc_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    	if(ret) {
    		printf("failed to set format on pad %x\n", fmt.pad);
    		goto cleanup;
    	}
    	else
    		printf("successfully format is set on pad %x\n", fmt.pad);
    #if 0
    
    	/* 10. get ccdc raw params from ccdc*/
    	printf("10. getting RAW params from ccdc\n");
    
    	bzero(&raw_params, sizeof(raw_params));
    
    	if (-1 == ioctl(ccdc_fd, VPFE_CMD_G_CCDC_RAW_PARAMS, &raw_params)) {
    		printf("failed to get raw params, %p", &raw_params);
    		goto cleanup;
    	}
    
    	/* 11. set raw params in ccdc */
    	printf("11. setting raw params in ccdc\n");
    	raw_params.compress.alg = CCDC_NO_COMPRESSION;
    	raw_params.gain_offset.gain.r_ye = r;
    	raw_params.gain_offset.gain.gr_cy = gr;
    	raw_params.gain_offset.gain.gb_g = gb;
    	raw_params.gain_offset.gain.b_mg = b;
    	raw_params.gain_offset.gain_sdram_en = 1;
    	raw_params.gain_offset.gain_ipipe_en = 1;
    	raw_params.gain_offset.offset = 0;
    	raw_params.gain_offset.offset_sdram_en = 1;
    
    	/* To test linearization, set this to 1, and update the
    	 * linearization table with correct data
    	 */
    	if (linearization_en) {
    		raw_params.linearize.en = 1;
    		raw_params.linearize.corr_shft = CCDC_1BIT_SHIFT;
    		raw_params.linearize.scale_fact.integer = 0;
    		raw_params.linearize.scale_fact.decimal = 10;
    
    		for (i = 0; i < CCDC_LINEAR_TAB_SIZE; i++)
    			raw_params.linearize.table[i] = i;
    	} else {
    		raw_params.linearize.en = 0;
    	}
    
    	/* csc */
    	if (csc_en) {
    		raw_params.df_csc.df_or_csc = 0;
    		raw_params.df_csc.csc.en = 1;
    		/* I am hardcoding this here. But this should
    		 * really match with that of the capture standard
    		 */
    		raw_params.df_csc.start_pix = 1;
    		raw_params.df_csc.num_pixels = 720;
    		raw_params.df_csc.start_line = 1;
    		raw_params.df_csc.num_lines = 480;
    		/* These are unit test values. For real case, use
    		 * correct values in this table
    		 */
    		raw_params.df_csc.csc.coeff[0] = csc_coef_val;
    		raw_params.df_csc.csc.coeff[1].decimal = 1;
    		raw_params.df_csc.csc.coeff[2].decimal = 2;
    		raw_params.df_csc.csc.coeff[3].decimal = 3;
    		raw_params.df_csc.csc.coeff[4].decimal = 4;
    		raw_params.df_csc.csc.coeff[5].decimal = 5;
    		raw_params.df_csc.csc.coeff[6].decimal = 6;
    		raw_params.df_csc.csc.coeff[7].decimal = 7;
    		raw_params.df_csc.csc.coeff[8].decimal = 8;
    		raw_params.df_csc.csc.coeff[9].decimal = 9;
    		raw_params.df_csc.csc.coeff[10].decimal = 10;
    		raw_params.df_csc.csc.coeff[11].decimal = 11;
    		raw_params.df_csc.csc.coeff[12].decimal = 12;
    		raw_params.df_csc.csc.coeff[13].decimal = 13;
    		raw_params.df_csc.csc.coeff[14].decimal = 14;
    		raw_params.df_csc.csc.coeff[15].decimal = 15;
    
    	} else {
    		raw_params.df_csc.df_or_csc = 0;
    		raw_params.df_csc.csc.en = 0;
    	}
    
    	/* vertical line defect correction */
    	if (vldfc_en) {
    		raw_params.dfc.en = 1;
    		// correction method
    		raw_params.dfc.corr_mode = CCDC_VDFC_HORZ_INTERPOL_IF_SAT;
    
    		// not pixels upper than the defect corrected
    		raw_params.dfc.corr_whole_line = 1;
    		raw_params.dfc.def_level_shift = CCDC_VDFC_SHIFT_2;
    		raw_params.dfc.def_sat_level = 20;
    		raw_params.dfc.num_vdefects = 7;
    		for (i = 0; i < raw_params.dfc.num_vdefects; i++) {
    			raw_params.dfc.table[i].pos_vert = i;
    			raw_params.dfc.table[i].pos_horz = i + 1;
    			raw_params.dfc.table[i].level_at_pos = i + 5;
    			raw_params.dfc.table[i].level_up_pixels = i + 6;
    			raw_params.dfc.table[i].level_low_pixels = i + 7;
    		}
    		printf("DFC enabled\n");
    	} else {
    		raw_params.dfc.en = 0;
    	}
    
    	if (en_culling) {
    
    		printf("Culling enabled\n");
    		raw_params.culling.hcpat_odd  = 0xaa;
    		raw_params.culling.hcpat_even = 0xaa;
    		raw_params.culling.vcpat = 0x55;
    		raw_params.culling.en_lpf = 1;
    	} else {
    		raw_params.culling.hcpat_odd  = 0xFF;
    		raw_params.culling.hcpat_even = 0xFF;
    		raw_params.culling.vcpat = 0xFF;
    	}
    
    	raw_params.col_pat_field0.olop = CCDC_GREEN_BLUE;
    	raw_params.col_pat_field0.olep = CCDC_BLUE;
    	raw_params.col_pat_field0.elop = CCDC_RED;
    	raw_params.col_pat_field0.elep = CCDC_GREEN_RED;
    	raw_params.col_pat_field1.olop = CCDC_GREEN_BLUE;
    	raw_params.col_pat_field1.olep = CCDC_BLUE;
    	raw_params.col_pat_field1.elop = CCDC_RED;
    	raw_params.col_pat_field1.elep = CCDC_GREEN_RED;
    	raw_params.data_size = CCDC_12_BITS;
    	raw_params.data_shift = CCDC_NO_SHIFT;
    
    
    	if (-1 == ioctl(ccdc_fd, VPFE_CMD_S_CCDC_RAW_PARAMS, &raw_params)) {
    		printf("failed to set raw params, %p", &raw_params);
    		return -1;
    	} else
    		printf("successfully set raw params in ccdc\n");
    
    
    	printf("**********************************************\n");
    
    
    #endif
    #if 1
    
    	/* 17. set format on sink-pad of prv */
    	printf("10. setting format on sink-pad of prv entity. . . \n");
    	memset(&fmt, 0, sizeof(fmt));
    
    	fmt.pad = P_PRV_SINK;
    	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    	fmt.format.code = CODE1;
    	fmt.format.width = width;
    	fmt.format.height = height;
    	fmt.format.colorspace = V4L2_COLORSPACE_SMPTE170M;
    	fmt.format.field = V4L2_FIELD_INTERLACED;
    
    	ret = ioctl(prv_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    	if(ret) {
    		printf("failed to set format on pad %x\n", fmt.pad);
    		goto cleanup;
    	}
    	else
    		printf("successfully format is set on pad %x\n", fmt.pad);
    #endif
    	/* 18. set format on source-pad of ccdc */
    	printf("10. setting format on source-pad of prv entity. . . \n");
    	memset(&fmt, 0, sizeof(fmt));
    
    	fmt.pad = P_PRV_SOURCE;
    	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    	fmt.format.code = CODE1;
    	fmt.format.width = width;
    	fmt.format.height = height;
    	fmt.format.colorspace = V4L2_COLORSPACE_SMPTE170M;
    	fmt.format.field = V4L2_FIELD_INTERLACED;
    
    	ret = ioctl(prv_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    	if(ret) {
    		printf("failed to set format on pad %x\n", fmt.pad);
    		goto cleanup;
    	}
    	else
    		printf("successfully format is set on pad %x\n", fmt.pad);
    #if 1
    	/* 18. set format on sink-pad of rsz */
    	printf("10. setting format on sink-pad of rsz entity. . . \n");
    	memset(&fmt, 0, sizeof(fmt));
    
    	fmt.pad = P_RSZ_SINK;
    	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    	fmt.format.code = CODE1;
    	fmt.format.width = width;
    	fmt.format.height = height;
    	fmt.format.colorspace = V4L2_COLORSPACE_SMPTE170M;
    	fmt.format.field = V4L2_FIELD_INTERLACED;
    	ret = ioctl(rsz_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    	if(ret) {
    		printf("failed to set format on pad %x\n", fmt.pad);
    		goto cleanup;
    	}
    	else
    		printf("successfully format is set on pad %x\n", fmt.pad);
    
    #endif
    	/* 19. set format on source-pad of rsz */
    	printf("10. setting format on source-pad of rsz entity. . . \n");
    	memset(&fmt, 0, sizeof(fmt));
    
    	fmt.pad = P_RSZ_SOURCE;
    	fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
    	fmt.format.code = CODE2;
    	fmt.format.width = width;
    	fmt.format.height = height;
    	fmt.format.colorspace = V4L2_COLORSPACE_SMPTE170M;
    	fmt.format.field = V4L2_FIELD_NONE;
    
    	ret = ioctl(rsz_fd, VIDIOC_SUBDEV_S_FMT, &fmt);
    	if(ret) {
    		printf("failed to set format on pad %x\n", fmt.pad);
    		goto cleanup;
    	}
    	else
    		printf("successfully format is set on pad %x\n", fmt.pad);
    	
    	printf("**********************************************\n");
    
    
    	/* 17.setting format */
    	printf("17. setting format V4L2_PIX_FMT_UYVY\n");
    	CLEAR(v4l2_fmt);
    	v4l2_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    	v4l2_fmt.fmt.pix.width = width;
    	v4l2_fmt.fmt.pix.height = height;
    	v4l2_fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_NV12;
    	v4l2_fmt.fmt.pix.field = V4L2_FIELD_NONE;
    
    	if (-1 == ioctl(capt_fd, VIDIOC_S_FMT, &v4l2_fmt)) {
    		printf("failed to set format on captute device \n");
    		goto cleanup;
    	} else
    		printf("successfully set the format\n");
    
    	/* 15.call G_FMT for knowing picth */
    	if (-1 == ioctl(capt_fd, VIDIOC_G_FMT, &v4l2_fmt)) {
    		printf("failed to get format from captute device \n");
    		goto cleanup;
    	} else {
    		printf("capture_pitch: %x\n", v4l2_fmt.fmt.pix.bytesperline);
    		capture_pitch = v4l2_fmt.fmt.pix.bytesperline;
    	}
    
    	printf("**********************************************\n");
    
    	/* 18.make sure 3 buffers are supported for streaming */
    	printf("18. Requesting for 3 buffers\n");
    	CLEAR(req);
    	req.count = 3;
    	req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    	req.memory = V4L2_MEMORY_USERPTR;
    
    	if (-1 == ioctl(capt_fd, VIDIOC_REQBUFS, &req)) {
    		printf("call to VIDIOC_REQBUFS failed\n");
    		goto cleanup;
    	}
    
    	if (req.count != 3) {
    		printf("3 buffers not supported by capture device");
    		goto cleanup;
    	} else
    		printf("3 buffers are supported for streaming\n");
    
    	printf("**********************************************\n");
    
    	/* 19.queue the buffers */
    	printf("19. queing buffers\n");
    	for (i = 0; i < 3; i++) {
    		struct v4l2_buffer buf;
    		CLEAR(buf);
    		buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    		buf.memory = V4L2_MEMORY_USERPTR;
    		buf.index = i;
    		buf.length = bufsize;
    		buf.m.userptr = (unsigned long)capture_buffers[i].user_addr;
    
    		if (-1 == ioctl(capt_fd, VIDIOC_QBUF, &buf)) {
    			printf("call to VIDIOC_QBUF failed\n");
    			goto cleanup;
    		}
    	}
    
    	/* 20.start streaming */
    	CLEAR(type);
    	type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    	if (-1 == ioctl(capt_fd, VIDIOC_STREAMON, &type)) {
    		printf("failed to start streaming on capture device");
    		goto cleanup;
    	} else
    		printf("streaming started successfully\n");
    
    	/* 21.get frames from capture device and store in a file */
    	frame_count = 0;
    	unsigned long temp;
    	void * dmptr;
    
    	/* 22.open file in which frames should be saved */
    	file = fopen("tvp514x_ccdc_prv_rsz_420.yuv","wa");
            if (file == NULL) {
    		printf("could not open the file to write... \n");
    		goto cleanup;
    	}
    	int h,numbytes;
    	if(output_format) {
    		h = height + height/2;
    		numbytes = width;
    	} else {
    		h = (height * 2);
    		numbytes = width;
    	}
    		
    	printf("numbytes : %d h : %d width : %d height : %d capture_pich : %d\n",numbytes,h,width,height,capture_pitch);
    	while(frame_count != 10) {
    
    		CLEAR(cap_buf);
    
    		cap_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    		cap_buf.memory = V4L2_MEMORY_USERPTR;
    try_again:
    		ret = ioctl(capt_fd, VIDIOC_DQBUF, &cap_buf);
    		if (ret < 0) {
    			if (errno == EAGAIN) {
    				goto try_again;
    				//exit(0);
    			}
    			printf("failed to DQ buffer from capture device\n");
    			goto cleanup;
    		}
    
    		temp = cap_buf.m.userptr;
    		source = (char *)temp;
    		/* copy frame to a file */
    		for(i=0 ; i < h; i++) {
    			fwrite(source, 1 , numbytes, file);
    			source += capture_pitch;
    		}
    
    		/* Q the buffer for capture, again */
    		ret = ioctl(capt_fd, VIDIOC_QBUF, &cap_buf);
    		if (ret < 0) {
    			printf("failed to Q buffer onto capture device\n");
    			goto cleanup;
    		}
    
    		if (frame_count == 0)
    			prev_ts = (cap_buf.timestamp.tv_sec*1000000) + cap_buf.timestamp.tv_usec;
    		else {
    			curr_ts = (cap_buf.timestamp.tv_sec*1000000) + cap_buf.timestamp.tv_usec;
    			fp_period = curr_ts - prev_ts;
    			if (frame_count == 1) {
    				fp_period_max = fp_period_min = fp_period_average = fp_period;
    			}
    			else {
    				/* calculate jitters and average */
    				if (fp_period > fp_period_max)
    					fp_period_max = fp_period;
    				if (fp_period < fp_period_min)
    					fp_period_min = fp_period;
    
    				fp_period_average =
    					((fp_period_average * frame_count) +
    					fp_period)/(frame_count + 1);
    			}
    			prev_ts = curr_ts;
    		}
    
    		frame_count++;
    
    		printf("frame:%5u, ", frame_count);
    		printf("buf.timestamp:%lu:%lu\n",
    			cap_buf.timestamp.tv_sec, cap_buf.timestamp.tv_usec);
    	}
    
    	printf("**********************************************\n");
    
    	/* 21. do stream off */
    	CLEAR(type);
    	type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    	if (-1 == ioctl(capt_fd, VIDIOC_STREAMOFF, &type)) {
    		printf("failed to stop streaming on capture device");
    		goto cleanup;
    	} else
    		printf("streaming stopped successfully\n");
    
    cleanup:
    	 /* 24. de-enable all the links which are active right now */
    	for(index = 0; index < entities_count; index++) {
    
    		links.entity = entity[index].id;
    
    		links.pads = malloc(sizeof( struct media_pad_desc) * entity[index].pads);
    		links.links = malloc(sizeof(struct media_link_desc) * entity[index].links);
    
    		ret = ioctl(media_fd, MEDIA_IOC_ENUM_LINKS, &links);
    		if (ret < 0) {
    			if (errno == EINVAL)
    				break;
    		}else{
    
    			for(i = 0;i< entity[index].links; i++)
    			{
    				       if(links.links->flags & MEDIA_LNK_FL_ENABLED) {
    					        /* de-enable the link */
    					        memset(&link, 0, sizeof(link));
    
    						link.flags |=  ~MEDIA_LNK_FL_ENABLED;
    						link.source.entity = links.links->source.entity;
    						link.source.index = links.links->source.index;
    						link.source.flags = MEDIA_PAD_FL_OUTPUT;
    
    						link.sink.entity = links.links->sink.entity;
    						link.sink.index = links.links->sink.index;
    						link.sink.flags = MEDIA_PAD_FL_INPUT;
    
    						ret = ioctl(media_fd, MEDIA_IOC_SETUP_LINK, &link);
    						if(ret) {
    							printf("failed to de-enable link \n");
    						}
    
    				       }
    
    				links.links++;
    			}
    		}
    	}
    
    
    	/* 25.close all the file descriptors */
    	printf("closing all the file descriptors. . .\n");
    	if(capt_fd) {
    		close(capt_fd);
    		printf("closed capture device\n");
    	}
    	if(rsz_fd) {
    		close(rsz_fd);
    		printf("closed reszier sub-device\n");
    	}
    	if(prv_fd) {
    		close(prv_fd);
    		printf("closed previewer sub-device\n");
    	}
    	if(ccdc_fd) {
    		close(ccdc_fd);
    		printf("closed ccdc sub-device\n");
    	}
    	if(tvp_fd) {
    		close(tvp_fd);
    		printf("closed tvp514x sub-device\n");
    	}
    	if(media_fd) {
    		close(media_fd);
    		printf("closed  media device\n");
    	}
    	if(file) {
    		fclose(file);
    		printf("closed the file \n");
    	}
    	return ret;
    }
    

    Thx,

    --Prabhakar Lad

  • Hi Sujit,

    I added the printks to vpfe_isr and vpfe_vdint1_isr in vpfe_capture.c, and I see that vpfe_isr is indeed being called (the one that is triggered off of VINT0), but my DQBUF still hangs indefinitely.

    Any idea what might be the problem, in this case?

    Thanks.

  • Prabhakar,

    Wow, thank you for taking the trouble to do that.  This application does indeed do what I want, and it works.  I modified it to use memory mapped I/O and it still works.  I am adapting the code into our existing framework, but still running into the DQBUF hang, even though VINT0 is firing as it should be.  Our code is configuring things with the same parameters as yours, although in a slightly different order... I will try modifying the order to match yours if that is critical.

    Thanks again, I will post my eventual success here.  At least now I know that what I want to do is indeed possible!

  • Hi Frank,

    Thanks Good to hear that it works.

    May be in your case you are missing, the queuing of right size buffers,

    because of which it keeps on waiting for DQBUF IOCTL.

    Thx,

    --Prabhakar Lad

  • Hi Prabhakar,

    Well, I have some interesting, and confusing, news: I changed the order of the configuration calls in our code to match the application that you wrote, and it worked!  Except, it only worked for one run... the next time I ran the application, it again hung inside of DQBUF.  Frustrated, I ran the application you generously provided just to check my sanity, and it *also* hung inside of DQBUF...

    I rebooted the EVM, and at first our application failed to MMAP one of the capture buffers, then your application (which I modified to use MMAP instead of USERPTR) also failed to MMAP the last capture buffer.  The next run, however, was successful, for both applications.

    So, I tentatively have a working application, but it bothers me still that even your application sometimes hangs in DQBUF, and also these random MMAP failures that can be resolved by simply trying to run the application again...

    I would appreciate any thoughts you might have on this, and once again thanks for your help.

    Oh, and as for the buffer size, as you mentioned in your comment above, I use the size returned by MMAP from the driver, so it should be correct...

  • Hi Frank,

    I tested the application which I provided to you, but I see no  issues as you mentioned.

    root@dm365-evm:/usr/PP# ./tvp514x_ccdc_prv_rsz_file_suma 
    out format is 420sp and buf size is 635904!!!
    calling cmem utilities for allocating frame buffers
    Allocating capture buffers :buf size = 635904 
    Got 0x4078f000 from CMEM, phy = 0x87718000
    vpfe-capture vpfe-capture: RSZ_G_CONFIG:1:124
    Got 0x40c4c000 from CMEM, phy = 0x872a4000
    Got 0x41108000 from vpfe-capture vpfe-capture: ipipe_set_preview_config
    CMEM, phy = 0x86e30000
    ****************************************vpfe-capture vpfe-capture: ipipe_set_preview_config
    ******
    4.enumerating media entities
    1 major minor are : 81 0
    [1]:tvp514x
    [2]EVM: switch to tvp5146 SD video input
    :tvp7002
    [3]:ths7353
    2 major minor are : 81 2
    [4]:DAVINCI CCDC
    [5]:DAVINCI VIDEO CCDC output
    3 major minor are : 81 4
    [6]:DAVINCI PREVIEWER
    [7]:DAVINCI VIDEO PRV input
    [8]:DAVINCI VIDEO PRV output
    4 major minor are : 81 7
    [9]:DAVINCI RESIZER
    [a]:DAVINCI VIDEO RSZ input
    [b]:DAVINCI VIDEO RSZ output
    [c]:DAVINCI AEW
    [d]:DAVINCI AF
    total number of entities: 13
    **********************************************
    5.enumerating links/pads for entities
    pads for entity 1=(0, OUTPUT) 
    [1:0]-------------->[4:0]       ACTIVE
    
    pads for entity 2=(0, OUTPUT) 
    [2:0]-------------->[4:0]       INACTIVE 
    
    
    
    pads for entity 4=(0, INPUT) (1, OUTPUT) 
    [4:1]-------------->[5:0]       INACTIVE 
    [4:1]-------------->[c:0]       INACTIVE 
    [4:1]-------------->[d:0]       INACTIVE 
    [4:1]-------------->[6:0]       ACTIVE
    
    pads for entity 5=(0, INPUT) 
    
    pads for entity 6=(0, INPUT) (1, OUTPUT) 
    [6:1]-------------->[8:0]       INACTIVE 
    [6:1]-------------->[9:0]       ACTIVE
    
    pads for entity 7=(0, OUTPUT) 
    [7:0]-------------->[6:0]       INACTIVE 
    
    pads for entity 8=(0, INPUT) 
    
    pads for entity 9=(0, INPUT) (1, OUTPUT) 
    [9:1]-------------->[b:0]       ACTIVE
    
    pads for entity a=(0, OUTPUT) 
    [a:0]-------------->[9:0]       INACTIVE 
    
    pads for entity b=(0, INPUT) 
    
    pads for entity c=(0, INPUT) 
    
    pads for entity d=(0, INPUT) 
    
    **********************************************
    6. ENABLEing link [tvp7002]----------->[ccdc]
    [mt9p031]----------->[ccdc]     ENABLED
    7. ENABLEing link [CCDC]----------->[PRV]
    [ccdc]----------->[prv] ENABLED
    7. ENABLEing link [prv]----------->[rsz]
    [prv]----------->[rsz]  ENABLED
    8. ENABLEing link [rsz]----------->[video_node]
    [rsz]----------->[video_node]    ENABLED
    **********************************************
    default configuration setting in resizer successfull
    congiration got from resizer successfully
    second output enabled!!!
    out format is 420sp
    successfully set configuration in rsz 
    default configuration is set successfully on prv
    got configuration from prv successfully
    configuration is set successfully on prv
    setting default for prv-module LUT Defect Correction
    setting default for prv-module OTF Defect Pixel Correction
    setting default for prv-module 2-D Noise filter - 1
    setting default for prv-module 2-D Noise filter - 2
    setting default for prv-module Green Imbalance Correction
    setting default for prv-module White balance
    setting default for prv-module CFA Interpolation
    setting default for prv-module RGB-RGB Conversion - 1
    setting default for prv-module Gamma Correction
    setting default for prv-module RGB-RGB Conversion - 2
    setting default for prv-module 3D LUT
    setting default for prv-module RGB-YCbCr conversion
    setting default for prv-module Global Brightness,Contrast Control
    setting default for prv-module YUV 422 conversion
    setting default for prv-module Luminance Adjustment
    setting default for prv-module Edge Enhancer
    setting default for prv-module Chromatic Artifact Reduction
    setting default for prv-module Chromatic Gain Suppression
    **********************************************
    15.enumerating INPUTS
    [0].Composite
    [1].S-Video
    **********************************************
    16. setting CAMERA as input. . .
    successfully set CAMERA input
    **********************************************
    8. setting format on pad of mt9p031 entity. . .
    width and height are: 720 576
    successfully format is set on pad 0
    12. setting format on sink-pad of ccdc entity. . .
    successfully format is set on pad 0
    13. setting format on OF-pad of ccdc entity. . . 
    successfully format is set on pad 1
    10. setting format on sink-pad of prv entity. . . 
    successfully format is set on pad 0
    10. setting format on source-pad of prv entity. . . 
    successfully format is set on pad 1
    10. setting format on sink-pad of rsz entity. . . 
    successfully format is set on pad 0
    10. setting format on source-pad of rsz entity. . . 
    successfully format is set on pad 1
    **********************************************
    17. setting format V4L2_PIX_FMT_UYVY
    successfully set the format
    capture_pitch: 2e0
    **********************************************
    18. Requesting for 3 buffers
    3 buffers are supported for streaming
    **********************************************
    19. queing buffers
    streaming started successfully
    numbytes : 720 h : 864 width : 720 height : 576 capture_pich : 736
    frame:    1, buf.timestamp:1277136649:183493
    frame:    2, buf.timestamp:1277136649:203447
    frame:    3, buf.timestamp:1277136649:283445
    frame:    4, buf.timestamp:1277136649:323435
    frame:    5, buf.timestamp:1277136649:343474
    frame:    6, buf.timestamp:1277136649:383473
    frame:    7, buf.timestamp:1277136649:423470
    frame:    8, buf.timestamp:1277136649:463471
    frame:    9, buf.timestamp:1277136649:503461
    frame:   10, buf.timestamp:1277136649:523437
    **********************************************
    streaming stopped successfully
    closing all the file descriptors. . .
    closed capture device
    closed reszier sub-device
    closed previewer sub-device
    closed ccdc sub-device
    closed mt9p031 sub-device
    closed  media device
    closed the file 
    root@dm365-evm:/usr/PP# ./tvp514x_ccdc_prv_rsz_file_suma 
    out format is 420sp and buf size is 635904!!!
    calling cmem utilities for allocating frame buffers
    Allocating capture buffers :buf size = 635904 
    Got 0x4079c000 from CMEM, phy = 0x87718000
    vpfe-capture vpfe-capture: RSZ_G_CONFIG:1:124
    Got 0x40cd6000 from CMEM, phy = 0x872a4000
    Got vpfe-capture vpfe-capture: ipipe_set_preview_config
    0x41196000 from vpfe-capture vpfe-capture: ipipe_set_preview_config
    CMEM, phy = 0x86e30000
    **********************************************
    4.enumerating media entities
    1 major minor are : 81 0
    [1]:tvp514x
    [2]EVM: switch to tvp5146 SD video input
    :tvp7002
    [3]:ths7353
    2 major minor are : 81 2
    [4]:DAVINCI CCDtvp514x: tvp5146 (Version - 0x03) found at 0xba (DaVinci I2C adapter)
    C
    [5]:DAVINCI VIDEO CCDC output
    3 major minor are : 81 4
    [6]:DAVINCI PREVIEWER
    [7]:DAVINCI VIDEO PRV input
    [8]:DAVINCI VIDEO PRV output
    4 major minor are : 81 7
    [9]:DAVINCI RESIZER
    [a]:DAVINCI VIDEO RSZ input
    [b]:DAVINCI VIDEO RSZ output
    [c]:DAVINCI AEW
    [d]:DAVINCI AF
    total number of entities: 13
    **********************************************
    5.enumerating links/pads for entities
    pads for entity 1=(0, OUTPUT) 
    [1:0]-------------->[4:0]       INACTIVE 
    
    pads for entity 2=(0, OUTPUT) 
    [2:0]-------------->[4:0]       INACTIVE 
    
    
    
    pads for entity 4=(0, INPUT) (1, OUTPUT) 
    [4:1]-------------->[5:0]       INACTIVE 
    [4:1]-------------->[c:0]       INACTIVE 
    [4:1]-------------->[d:0]       INACTIVE 
    [4:1]-------------->[6:0]       INACTIVE 
    
    pads for entity 5=(0, INPUT) 
    
    pads for entity 6=(0, INPUT) (1, OUTPUT) 
    [6:1]-------------->[8:0]       INACTIVE 
    [6:1]-------------->[9:0]       INACTIVE 
    
    pads for entity 7=(0, OUTPUT) 
    [7:0]-------------->[6:0]       INACTIVE 
    
    pads for entity 8=(0, INPUT) 
    
    pads for entity 9=(0, INPUT) (1, OUTPUT) 
    [9:1]-------------->[b:0]       INACTIVE 
    
    pads for entity a=(0, OUTPUT) 
    [a:0]-------------->[9:0]       INACTIVE 
    
    pads for entity b=(0, INPUT) 
    
    pads for entity c=(0, INPUT) 
    
    pads for entity d=(0, INPUT) 
    
    **********************************************
    6. ENABLEing link [tvp7002]----------->[ccdc]
    [mt9p031]----------->[ccdc]     ENABLED
    7. ENABLEing link [CCDC]----------->[PRV]
    [ccdc]----------->[prv] ENABLED
    7. ENABLEing link [prv]----------->[rsz]
    [prv]----------->[rsz]  ENABLED
    8. ENABLEing link [rsz]----------->[video_node]
    [rsz]----------->[video_node]    ENABLED
    **********************************************
    default configuration setting in resizer successfull
    congiration got from resizer successfully
    second output enabled!!!
    out format is 420sp
    successfully set configuration in rsz 
    default configuration is set successfully on prv
    got configuration from prv successfully
    configuration is set successfully on prv
    setting default for prv-module LUT Defect Correction
    setting default for prv-module OTF Defect Pixel Correction
    setting default for prv-module 2-D Noise filter - 1
    setting default for prv-module 2-D Noise filter - 2
    setting default for prv-module Green Imbalance Correction
    setting default for prv-module White balance
    setting default for prv-module CFA Interpolation
    setting default for prv-module RGB-RGB Conversion - 1
    setting default for prv-module Gamma Correction
    setting default for prv-module RGB-RGB Conversion - 2
    setting default for prv-module 3D LUT
    setting default for prv-module RGB-YCbCr conversion
    setting default for prv-module Global Brightness,Contrast Control
    setting default for prv-module YUV 422 conversion
    setting default for prv-module Luminance Adjustment
    setting default for prv-module Edge Enhancer
    setting default for prv-module Chromatic Artifact Reduction
    setting default for prv-module Chromatic Gain Suppression
    **********************************************
    15.enumerating INPUTS
    [0].Composite
    [1].S-Video
    **********************************************
    16. setting CAMERA as input. . .
    successfully set CAMERA input
    **********************************************
    8. setting format on pad of mt9p031 entity. . .
    width and height are: 720 576
    successfully format is set on pad 0
    12. setting format on sink-pad of ccdc entity. . .
    successfully format is set on pad 0
    13. setting format on OF-pad of ccdc entity. . . 
    successfully format is set on pad 1
    10. setting format on sink-pad of prv entity. . . 
    successfully format is set on pad 0
    10. setting format on source-pad of prv entity. . . 
    successfully format is set on pad 1
    10. setting format on sink-pad of rsz entity. . . 
    successfully format is set on pad 0
    10. setting format on source-pad of rsz entity. . . 
    successfully format is set on pad 1
    **********************************************
    17. setting format V4L2_PIX_FMT_UYVY
    successfully set the format
    capture_pitch: 2e0
    **********************************************
    18. Requesting for 3 buffers
    3 buffers are supported for streaming
    **********************************************
    19. queing buffers
    streaming started successfully
    numbytes : 720 h : 864 width : 720 height : 576 capture_pich : 736
    frame:    1, buf.timestamp:1277136652:863383
    frame:    2, buf.timestamp:1277136652:883343
    frame:    3, buf.timestamp:1277136652:983371
    frame:    4, buf.timestamp:1277136653:3344
    frame:    5, buf.timestamp:1277136653:43345
    frame:    6, buf.timestamp:1277136653:83337
    frame:    7, buf.timestamp:1277136653:103375
    frame:    8, buf.timestamp:1277136653:163338
    frame:    9, buf.timestamp:1277136653:203333
    frame:   10, buf.timestamp:1277136653:223367
    **********************************************
    streaming stopped successfully
    closing all the file descriptors. . .
    closed capture device
    closed reszier sub-device
    closed previewer sub-device
    closed ccdc sub-device
    closed mt9p031 sub-device
    closed  media device
    closed the file 
    root@dm365-evm:/usr/PP# ./tvp514x_ccdc_prv_rsz_file_suma 
    out format is 420sp and buf size is 635904!!!
    calling cmem utilities for allocating frame buffers
    Allocating capture buffers :buf size = 635904 
    Got 0x40816000 from CMEM, phy = 0x87718000
    vpfe-capture vpfe-capture: RSZ_G_CONFIG:1:124
    Got 0x40d1c000 fvpfe-capture vpfe-capture: ipipe_set_preview_config
    rom CMEM, phy = 0x872a4000
    Got 0x4121c000 from vpfe-capture vpfe-capture: ipipe_set_preview_config
    CMEM, phy = 0x86e30000
    **********************************************
    4.enumerating media entiEVM: switch to tvp5146 SD video input
    ties
    1 major minor are : 81 0
    tvp514x: tvp5146 (Version - 0x03) found at 0xba (DaVinci I2C adapter)
    [1]:tvp514x
    [2]:tvp7002
    [3]:ths7353
    2 major minor are : 81 2
    [4]:DAVINCI CCDC
    [5]:DAVINCI VIDEO CCDC output
    3 major minor are : 81 4
    [6]:DAVINCI PREVIEWER
    [7]:DAVINCI VIDEO PRV input
    [8]:DAVINCI VIDEO PRV output
    4 major minor are : 81 7
    [9]:DAVINCI RESIZER
    [a]:DAVINCI VIDEO RSZ input
    [b]:DAVINCI VIDEO RSZ output
    [c]:DAVINCI AEW
    [d]:DAVINCI AF
    total number of entities: 13
    **********************************************
    5.enumerating links/pads for entities
    pads for entity 1=(0, OUTPUT) 
    [1:0]-------------->[4:0]       INACTIVE 
    
    pads for entity 2=(0, OUTPUT) 
    [2:0]-------------->[4:0]       INACTIVE 
    
    
    
    pads for entity 4=(0, INPUT) (1, OUTPUT) 
    [4:1]-------------->[5:0]       INACTIVE 
    [4:1]-------------->[c:0]       INACTIVE 
    [4:1]-------------->[d:0]       INACTIVE 
    [4:1]-------------->[6:0]       INACTIVE 
    
    pads for entity 5=(0, INPUT) 
    
    pads for entity 6=(0, INPUT) (1, OUTPUT) 
    [6:1]-------------->[8:0]       INACTIVE 
    [6:1]-------------->[9:0]       INACTIVE 
    
    pads for entity 7=(0, OUTPUT) 
    [7:0]-------------->[6:0]       INACTIVE 
    
    pads for entity 8=(0, INPUT) 
    
    pads for entity 9=(0, INPUT) (1, OUTPUT) 
    [9:1]-------------->[b:0]       INACTIVE 
    
    pads for entity a=(0, OUTPUT) 
    [a:0]-------------->[9:0]       INACTIVE 
    
    pads for entity b=(0, INPUT) 
    
    pads for entity c=(0, INPUT) 
    
    pads for entity d=(0, INPUT) 
    
    **********************************************
    6. ENABLEing link [tvp7002]----------->[ccdc]
    [mt9p031]----------->[ccdc]     ENABLED
    7. ENABLEing link [CCDC]----------->[PRV]
    [ccdc]----------->[prv] ENABLED
    7. ENABLEing link [prv]----------->[rsz]
    [prv]----------->[rsz]  ENABLED
    8. ENABLEing link [rsz]----------->[video_node]
    [rsz]----------->[video_node]    ENABLED
    **********************************************
    default configuration setting in resizer successfull
    congiration got from resizer successfully
    second output enabled!!!
    out format is 420sp
    successfully set configuration in rsz 
    default configuration is set successfully on prv
    got configuration from prv successfully
    configuration is set successfully on prv
    setting default for prv-module LUT Defect Correction
    setting default for prv-module OTF Defect Pixel Correction
    setting default for prv-module 2-D Noise filter - 1
    setting default for prv-module 2-D Noise filter - 2
    setting default for prv-module Green Imbalance Correction
    setting default for prv-module White balance
    setting default for prv-module CFA Interpolation
    setting default for prv-module RGB-RGB Conversion - 1
    setting default for prv-module Gamma Correction
    setting default for prv-module RGB-RGB Conversion - 2
    setting default for prv-module 3D LUT
    setting default for prv-module RGB-YCbCr conversion
    setting default for prv-module Global Brightness,Contrast Control
    setting default for prv-module YUV 422 conversion
    setting default for prv-module Luminance Adjustment
    setting default for prv-module Edge Enhancer
    setting default for prv-module Chromatic Artifact Reduction
    setting default for prv-module Chromatic Gain Suppression
    **********************************************
    15.enumerating INPUTS
    [0].Composite
    [1].S-Video
    **********************************************
    16. setting CAMERA as input. . .
    successfully set CAMERA input
    **********************************************
    8. setting format on pad of mt9p031 entity. . .
    width and height are: 720 576
    successfully format is set on pad 0
    12. setting format on sink-pad of ccdc entity. . .
    successfully format is set on pad 0
    13. setting format on OF-pad of ccdc entity. . . 
    successfully format is set on pad 1
    10. setting format on sink-pad of prv entity. . . 
    successfully format is set on pad 0
    10. setting format on source-pad of prv entity. . . 
    successfully format is set on pad 1
    10. setting format on sink-pad of rsz entity. . . 
    successfully format is set on pad 0
    10. setting format on source-pad of rsz entity. . . 
    successfully format is set on pad 1
    **********************************************
    17. setting format V4L2_PIX_FMT_UYVY
    successfully set the format
    capture_pitch: 2e0
    **********************************************
    18. Requesting for 3 buffers
    3 buffers are supported for streaming
    **********************************************
    19. queing buffers
    streaming started successfully
    numbytes : 720 h : 864 width : 720 height : 576 capture_pich : 736
    frame:    1, buf.timestamp:1277136656:443252
    frame:    2, buf.timestamp:1277136656:463283
    frame:    3, buf.timestamp:1277136656:543284
    frame:    4, buf.timestamp:1277136656:563250
    frame:    5, buf.timestamp:1277136656:603248
    frame:    6, buf.timestamp:1277136656:643248
    frame:    7, buf.timestamp:1277136656:683245
    frame:    8, buf.timestamp:1277136656:723244
    frame:    9, buf.timestamp:1277136656:763242
    frame:   10, buf.timestamp:1277136656:823270
    **********************************************
    streaming stopped successfully
    closing all the file descriptors. . .
    closed capture device
    closed reszier sub-device
    closed previewer sub-device
    closed ccdc sub-device
    closed mt9p031 sub-device
    closed  media device
    closed the file 
    root@dm365-evm:/usr/PP# ./tvp514x_ccdc_prv_rsz_file_suma 
    out format is 420sp and buf size is 635904!!!
    calling cmem utilities for allocating frame buffers
    Allocating capture buffers :buf size = 635904 
    Got 0x40765000 from CMEM, phy = 0x87718000
    vpfe-capture vpfe-capture: RSZ_G_CONFIG:1:124
    Got 0x40cba000 fvpfe-capture vpfe-capture: ipipe_set_preview_config
    rom CMEM, phy = 0x872a4000
    Got 0x4120d000 from vpfe-capture vpfe-capture: ipipe_set_preview_config
    CMEM, phy = 0x86e30000
    **********************************************
    4.enumerEVM: switch to tvp5146 SD video input
    ating media entities
    1 major minor are : 81 0
    [1]:tvp514x
    [2]tvp514x: tvp5146 (Version - 0x03) found at 0xba (DaVinci I2C adapter)
    :tvp7002
    [3]:ths7353
    2 major minor are : 81 2
    [4]:DAVINCI CCDC
    [5]:DAVINCI VIDEO CCDC output
    3 major minor are : 81 4
    [6]:DAVINCI PREVIEWER
    [7]:DAVINCI VIDEO PRV input
    [8]:DAVINCI VIDEO PRV output
    4 major minor are : 81 7
    [9]:DAVINCI RESIZER
    [a]:DAVINCI VIDEO RSZ input
    [b]:DAVINCI VIDEO RSZ output
    [c]:DAVINCI AEW
    [d]:DAVINCI AF
    total number of entities: 13
    **********************************************
    5.enumerating links/pads for entities
    pads for entity 1=(0, OUTPUT) 
    [1:0]-------------->[4:0]       INACTIVE 
    
    pads for entity 2=(0, OUTPUT) 
    [2:0]-------------->[4:0]       INACTIVE 
    
    
    
    pads for entity 4=(0, INPUT) (1, OUTPUT) 
    [4:1]-------------->[5:0]       INACTIVE 
    [4:1]-------------->[c:0]       INACTIVE 
    [4:1]-------------->[d:0]       INACTIVE 
    [4:1]-------------->[6:0]       INACTIVE 
    
    pads for entity 5=(0, INPUT) 
    
    pads for entity 6=(0, INPUT) (1, OUTPUT) 
    [6:1]-------------->[8:0]       INACTIVE 
    [6:1]-------------->[9:0]       INACTIVE 
    
    pads for entity 7=(0, OUTPUT) 
    [7:0]-------------->[6:0]       INACTIVE 
    
    pads for entity 8=(0, INPUT) 
    
    pads for entity 9=(0, INPUT) (1, OUTPUT) 
    [9:1]-------------->[b:0]       INACTIVE 
    
    pads for entity a=(0, OUTPUT) 
    [a:0]-------------->[9:0]       INACTIVE 
    
    pads for entity b=(0, INPUT) 
    
    pads for entity c=(0, INPUT) 
    
    pads for entity d=(0, INPUT) 
    
    **********************************************
    6. ENABLEing link [tvp7002]----------->[ccdc]
    [mt9p031]----------->[ccdc]     ENABLED
    7. ENABLEing link [CCDC]----------->[PRV]
    [ccdc]----------->[prv] ENABLED
    7. ENABLEing link [prv]----------->[rsz]
    [prv]----------->[rsz]  ENABLED
    8. ENABLEing link [rsz]----------->[video_node]
    [rsz]----------->[video_node]    ENABLED
    **********************************************
    default configuration setting in resizer successfull
    congiration got from resizer successfully
    second output enabled!!!
    out format is 420sp
    successfully set configuration in rsz 
    default configuration is set successfully on prv
    got configuration from prv successfully
    configuration is set successfully on prv
    setting default for prv-module LUT Defect Correction
    setting default for prv-module OTF Defect Pixel Correction
    setting default for prv-module 2-D Noise filter - 1
    setting default for prv-module 2-D Noise filter - 2
    setting default for prv-module Green Imbalance Correction
    setting default for prv-module White balance
    setting default for prv-module CFA Interpolation
    setting default for prv-module RGB-RGB Conversion - 1
    setting default for prv-module Gamma Correction
    setting default for prv-module RGB-RGB Conversion - 2
    setting default for prv-module 3D LUT
    setting default for prv-module RGB-YCbCr conversion
    setting default for prv-module Global Brightness,Contrast Control
    setting default for prv-module YUV 422 conversion
    setting default for prv-module Luminance Adjustment
    setting default for prv-module Edge Enhancer
    setting default for prv-module Chromatic Artifact Reduction
    setting default for prv-module Chromatic Gain Suppression
    **********************************************
    15.enumerating INPUTS
    [0].Composite
    [1].S-Video
    **********************************************
    16. setting CAMERA as input. . .
    successfully set CAMERA input
    **********************************************
    8. setting format on pad of mt9p031 entity. . .
    width and height are: 720 576
    successfully format is set on pad 0
    12. setting format on sink-pad of ccdc entity. . .
    successfully format is set on pad 0
    13. setting format on OF-pad of ccdc entity. . . 
    successfully format is set on pad 1
    10. setting format on sink-pad of prv entity. . . 
    successfully format is set on pad 0
    10. setting format on source-pad of prv entity. . . 
    successfully format is set on pad 1
    10. setting format on sink-pad of rsz entity. . . 
    successfully format is set on pad 0
    10. setting format on source-pad of rsz entity. . . 
    successfully format is set on pad 1
    **********************************************
    17. setting format V4L2_PIX_FMT_UYVY
    successfully set the format
    capture_pitch: 2e0
    **********************************************
    18. Requesting for 3 buffers
    3 buffers are supported for streaming
    **********************************************
    19. queing buffers
    streaming started successfully
    numbytes : 720 h : 864 width : 720 height : 576 capture_pich : 736
    frame:    1, buf.timestamp:1277136659:983181
    frame:    2, buf.timestamp:1277136660:3148
    frame:    3, buf.timestamp:1277136660:83144
    frame:    4, buf.timestamp:1277136660:103180
    frame:    5, buf.timestamp:1277136660:143181
    frame:    6, buf.timestamp:1277136660:183173
    frame:    7, buf.timestamp:1277136660:203150
    frame:    8, buf.timestamp:1277136660:263183
    frame:    9, buf.timestamp:1277136660:303170
    frame:   10, buf.timestamp:1277136660:323141
    **********************************************
    streaming stopped successfully
    closing all the file descriptors. . .
    closed capture device
    closed reszier sub-device
    closed previewer sub-device
    closed ccdc sub-device
    closed mt9p031 sub-device
    closed  media device
    closed the file 
    root@dm365-evm:/usr/PP# ./tvp514x_ccdc_prv_rsz_file_suma 
    out format is 420sp and buf size is 635904!!!
    calling cmem utilities for allocating frame buffers
    Allocating capture buffers :buf size = 635904 
    Got 0x40754000 from CMEM, phy = 0x87718000
    vpfe-capture vpfe-capture: RSZ_G_CONFIG:1:124
    Got 0x40c5b000 from CMEM, phy = vpfe-capture vpfe-capture: ipipe_set_preview_config
    0x872a4000
    Got vpfe-capture vpfe-capture: ipipe_set_preview_config
    0x41195000 from CMEM, phy = 0x86e30000
    **********************************************
    4.enumerating media entiEVM: switch to tvp5146 SD video input
    ties
    1 major minor are : 81 0
    tvp514x: tvp5146 (Version - 0x03) found at 0xba (DaVinci I2C adapter)
    [1]:tvp514x
    [2]:tvp7002
    [3]:ths7353
    2 major minor are : 81 2
    [4]:DAVINCI CCDC
    [5]:DAVINCI VIDEO CCDC output
    3 major minor are : 81 4
    [6]:DAVINCI PREVIEWER
    [7]:DAVINCI VIDEO PRV input
    [8]:DAVINCI VIDEO PRV output
    4 major minor are : 81 7
    [9]:DAVINCI RESIZER
    [a]:DAVINCI VIDEO RSZ input
    [b]:DAVINCI VIDEO RSZ output
    [c]:DAVINCI AEW
    [d]:DAVINCI AF
    total number of entities: 13
    **********************************************
    5.enumerating links/pads for entities
    pads for entity 1=(0, OUTPUT) 
    [1:0]-------------->[4:0]       INACTIVE 
    
    pads for entity 2=(0, OUTPUT) 
    [2:0]-------------->[4:0]       INACTIVE 
    
    
    
    pads for entity 4=(0, INPUT) (1, OUTPUT) 
    [4:1]-------------->[5:0]       INACTIVE 
    [4:1]-------------->[c:0]       INACTIVE 
    [4:1]-------------->[d:0]       INACTIVE 
    [4:1]-------------->[6:0]       INACTIVE 
    
    pads for entity 5=(0, INPUT) 
    
    pads for entity 6=(0, INPUT) (1, OUTPUT) 
    [6:1]-------------->[8:0]       INACTIVE 
    [6:1]-------------->[9:0]       INACTIVE 
    
    pads for entity 7=(0, OUTPUT) 
    [7:0]-------------->[6:0]       INACTIVE 
    
    pads for entity 8=(0, INPUT) 
    
    pads for entity 9=(0, INPUT) (1, OUTPUT) 
    [9:1]-------------->[b:0]       INACTIVE 
    
    pads for entity a=(0, OUTPUT) 
    [a:0]-------------->[9:0]       INACTIVE 
    
    pads for entity b=(0, INPUT) 
    
    pads for entity c=(0, INPUT) 
    
    pads for entity d=(0, INPUT) 
    
    **********************************************
    6. ENABLEing link [tvp7002]----------->[ccdc]
    [mt9p031]----------->[ccdc]     ENABLED
    7. ENABLEing link [CCDC]----------->[PRV]
    [ccdc]----------->[prv] ENABLED
    7. ENABLEing link [prv]----------->[rsz]
    [prv]----------->[rsz]  ENABLED
    8. ENABLEing link [rsz]----------->[video_node]
    [rsz]----------->[video_node]    ENABLED
    **********************************************
    default configuration setting in resizer successfull
    congiration got from resizer successfully
    second output enabled!!!
    out format is 420sp
    successfully set configuration in rsz 
    default configuration is set successfully on prv
    got configuration from prv successfully
    configuration is set successfully on prv
    setting default for prv-module LUT Defect Correction
    setting default for prv-module OTF Defect Pixel Correction
    setting default for prv-module 2-D Noise filter - 1
    setting default for prv-module 2-D Noise filter - 2
    setting default for prv-module Green Imbalance Correction
    setting default for prv-module White balance
    setting default for prv-module CFA Interpolation
    setting default for prv-module RGB-RGB Conversion - 1
    setting default for prv-module Gamma Correction
    setting default for prv-module RGB-RGB Conversion - 2
    setting default for prv-module 3D LUT
    setting default for prv-module RGB-YCbCr conversion
    setting default for prv-module Global Brightness,Contrast Control
    setting default for prv-module YUV 422 conversion
    setting default for prv-module Luminance Adjustment
    setting default for prv-module Edge Enhancer
    setting default for prv-module Chromatic Artifact Reduction
    setting default for prv-module Chromatic Gain Suppression
    **********************************************
    15.enumerating INPUTS
    [0].Composite
    [1].S-Video
    **********************************************
    16. setting CAMERA as input. . .
    successfully set CAMERA input
    **********************************************
    8. setting format on pad of mt9p031 entity. . .
    width and height are: 720 576
    successfully format is set on pad 0
    12. setting format on sink-pad of ccdc entity. . .
    successfully format is set on pad 0
    13. setting format on OF-pad of ccdc entity. . . 
    successfully format is set on pad 1
    10. setting format on sink-pad of prv entity. . . 
    successfully format is set on pad 0
    10. setting format on source-pad of prv entity. . . 
    successfully format is set on pad 1
    10. setting format on sink-pad of rsz entity. . . 
    successfully format is set on pad 0
    10. setting format on source-pad of rsz entity. . . 
    successfully format is set on pad 1
    **********************************************
    17. setting format V4L2_PIX_FMT_UYVY
    successfully set the format
    capture_pitch: 2e0
    **********************************************
    18. Requesting for 3 buffers
    3 buffers are supported for streaming
    **********************************************
    19. queing buffers
    streaming started successfully
    numbytes : 720 h : 864 width : 720 height : 576 capture_pich : 736
    frame:    1, buf.timestamp:1277136663:603057
    frame:    2, buf.timestamp:1277136663:623101
    frame:    3, buf.timestamp:1277136663:723045
    frame:    4, buf.timestamp:1277136663:743082
    frame:    5, buf.timestamp:1277136663:783081
    frame:    6, buf.timestamp:1277136663:823075
    frame:    7, buf.timestamp:1277136663:843046
    frame:    8, buf.timestamp:1277136663:903080
    frame:    9, buf.timestamp:1277136663:943071
    frame:   10, buf.timestamp:1277136663:963044
    **********************************************
    streaming stopped successfully
    closing all the file descriptors. . .
    closed capture device
    closed reszier sub-device
    closed previewer sub-device
    closed ccdc sub-device
    closed mt9p031 sub-device
    closed  media device
    closed the file 
    root@dm365-evm:/usr/PP# ./tvp514x_ccdc_prv_rsz_file_suma 
    out format is 420sp and buf size is 635904!!!
    calling cmem utilities for allocating frame buffers
    Allocating capture buffers :buf size = 635904 
    Got 0x40819000 from CMEM, phy = 0x87718000
    vpfe-capture vpfe-capture: RSZ_G_CONFIG:1:124
    Got 0x40d1f000 fvpfe-capture vpfe-capture: ipipe_set_preview_config
    rom CMEM, phy = 0x872a4000
    Got 0x411e2000 from vpfe-capture vpfe-capture: ipipe_set_preview_config
    CMEM, phy = 0x86e30000
    **********************************************
    4.enumerating media entiEVM: switch to tvp5146 SD video input
    ties
    1 major minor are : 81 0
    tvp514x: tvp5146 (Version - 0x03) found at 0xba (DaVinci I2C adapter)
    [1]:tvp514x
    [2]:tvp7002
    [3]:ths7353
    2 major minor are : 81 2
    [4]:DAVINCI CCDC
    [5]:DAVINCI VIDEO CCDC output
    3 major minor are : 81 4
    [6]:DAVINCI PREVIEWER
    [7]:DAVINCI VIDEO PRV input
    [8]:DAVINCI VIDEO PRV output
    4 major minor are : 81 7
    [9]:DAVINCI RESIZER
    [a]:DAVINCI VIDEO RSZ input
    [b]:DAVINCI VIDEO RSZ output
    [c]:DAVINCI AEW
    [d]:DAVINCI AF
    total number of entities: 13
    **********************************************
    5.enumerating links/pads for entities
    pads for entity 1=(0, OUTPUT) 
    [1:0]-------------->[4:0]       INACTIVE 
    
    pads for entity 2=(0, OUTPUT) 
    [2:0]-------------->[4:0]       INACTIVE 
    
    
    
    pads for entity 4=(0, INPUT) (1, OUTPUT) 
    [4:1]-------------->[5:0]       INACTIVE 
    [4:1]-------------->[c:0]       INACTIVE 
    [4:1]-------------->[d:0]       INACTIVE 
    [4:1]-------------->[6:0]       INACTIVE 
    
    pads for entity 5=(0, INPUT) 
    
    pads for entity 6=(0, INPUT) (1, OUTPUT) 
    [6:1]-------------->[8:0]       INACTIVE 
    [6:1]-------------->[9:0]       INACTIVE 
    
    pads for entity 7=(0, OUTPUT) 
    [7:0]-------------->[6:0]       INACTIVE 
    
    pads for entity 8=(0, INPUT) 
    
    pads for entity 9=(0, INPUT) (1, OUTPUT) 
    [9:1]-------------->[b:0]       INACTIVE 
    
    pads for entity a=(0, OUTPUT) 
    [a:0]-------------->[9:0]       INACTIVE 
    
    pads for entity b=(0, INPUT) 
    
    pads for entity c=(0, INPUT) 
    
    pads for entity d=(0, INPUT) 
    
    **********************************************
    6. ENABLEing link [tvp7002]----------->[ccdc]
    [mt9p031]----------->[ccdc]     ENABLED
    7. ENABLEing link [CCDC]----------->[PRV]
    [ccdc]----------->[prv] ENABLED
    7. ENABLEing link [prv]----------->[rsz]
    [prv]----------->[rsz]  ENABLED
    8. ENABLEing link [rsz]----------->[video_node]
    [rsz]----------->[video_node]    ENABLED
    **********************************************
    default configuration setting in resizer successfull
    congiration got from resizer successfully
    second output enabled!!!
    out format is 420sp
    successfully set configuration in rsz 
    default configuration is set successfully on prv
    got configuration from prv successfully
    configuration is set successfully on prv
    setting default for prv-module LUT Defect Correction
    setting default for prv-module OTF Defect Pixel Correction
    setting default for prv-module 2-D Noise filter - 1
    setting default for prv-module 2-D Noise filter - 2
    setting default for prv-module Green Imbalance Correction
    setting default for prv-module White balance
    setting default for prv-module CFA Interpolation
    setting default for prv-module RGB-RGB Conversion - 1
    setting default for prv-module Gamma Correction
    setting default for prv-module RGB-RGB Conversion - 2
    setting default for prv-module 3D LUT
    setting default for prv-module RGB-YCbCr conversion
    setting default for prv-module Global Brightness,Contrast Control
    setting default for prv-module YUV 422 conversion
    setting default for prv-module Luminance Adjustment
    setting default for prv-module Edge Enhancer
    setting default for prv-module Chromatic Artifact Reduction
    setting default for prv-module Chromatic Gain Suppression
    **********************************************
    15.enumerating INPUTS
    [0].Composite
    [1].S-Video
    **********************************************
    16. setting CAMERA as input. . .
    successfully set CAMERA input
    **********************************************
    8. setting format on pad of mt9p031 entity. . .
    width and height are: 720 576
    successfully format is set on pad 0
    12. setting format on sink-pad of ccdc entity. . .
    successfully format is set on pad 0
    13. setting format on OF-pad of ccdc entity. . . 
    successfully format is set on pad 1
    10. setting format on sink-pad of prv entity. . . 
    successfully format is set on pad 0
    10. setting format on source-pad of prv entity. . . 
    successfully format is set on pad 1
    10. setting format on sink-pad of rsz entity. . . 
    successfully format is set on pad 0
    10. setting format on source-pad of rsz entity. . . 
    successfully format is set on pad 1
    **********************************************
    17. setting format V4L2_PIX_FMT_UYVY
    successfully set the format
    capture_pitch: 2e0
    **********************************************
    18. Requesting for 3 buffers
    3 buffers are supported for streaming
    **********************************************
    19. queing buffers
    streaming started successfully
    numbytes : 720 h : 864 width : 720 height : 576 capture_pich : 736
    frame:    1, buf.timestamp:1277136669:282916
    frame:    2, buf.timestamp:1277136669:302933
    frame:    3, buf.timestamp:1277136669:402900
    frame:    4, buf.timestamp:1277136669:442893
    frame:    5, buf.timestamp:1277136669:462931
    frame:    6, buf.timestamp:1277136669:502929
    frame:    7, buf.timestamp:1277136669:542930
    frame:    8, buf.timestamp:1277136669:582929
    frame:    9, buf.timestamp:1277136669:622921
    frame:   10, buf.timestamp:1277136669:642893
    **********************************************
    streaming stopped successfully
    closing all the file descriptors. . .
    closed capture device
    closed reszier sub-device
    closed previewer sub-device
    closed ccdc sub-device
    closed mt9p031 sub-device
    closed  media device
    closed the file 

    I have attached the log which depicts the same.

    Thx,

    --Prabhakar Lad

  • Hi Prabhakar,

    Yes, it was pretty strange to have the application you provided hang; it hadn't done that before.  I'm not certain what went wrong.  It has not happened since.

    Aside from the occasional video buffer allocation failure by the video capture driver, my application now seems to be working well.

    Thanks again for all of your help!

    Frank

  • Hi Prabhakar,

    OK, one more problem:  while testing performance of our application, I noticed that frames were being dropped fairly regularly (nominal framerate is 30fps).  I went back to your test application, and ran it for 10 seconds, and noticed that it also dropped frames.  In fact, in the log you attached above, you can see some of the frames have 40ms and one even 80ms in between them.

    We can't really afford to drop frames for our application; do you have any insight as to why this is happening?

    Best regards,

    Frank

  • Hi Frank,

    Not sure about your application, But the app which i had attached was performing

    file operation(frames are written to file), If you can remove this file operation,

    and check the exact frame rate achived.

    Thx,

    --Prabhakar Lad

  • Hi Prabhakar,

    Our application sends the captured frames to the H264 encoder, which then performs file I/O, but the capture portion runs in its own thread at the highest priority in the system.  Even without the encoder or file I/O threads running, though, the capture rate was not keeping up.

    I removed the 'fwrite' call from your application, and added the frame timestamp deltas to the output.  The result is attached; there are several frame periods well into the 80ms range and beyond.  Can you confirm this is the case for you, as well?

    out format is 420sp and buf size is 635904!!!
    calling cmem utilities for allocating frame buffers
    Allocating capture buffers :buf size = 635904 
    Got 0x403d9000 from CMEM, phy = 0x87125000
    Got 0x40563000 from CMEM, phy = 0x86e28000
    Got 0x408fb000 from CMEM, phy = 0x87206000
    **********************************************
    4.enumerating media entities
    1 major minor are : 81 0
    [1]:tvp514x
    [2]:tvp7002
    [3]:ths7353
    2 major minor are : 81 2
    [4]:DAVINCI CCDC
    [5]:DAVINCI VIDEO CCDC output
    3 major minor are : 81 4
    [6]:DAVINCI PREVIEWER
    [7]:DAVINCI VIDEO PRV input
    [8]:DAVINCI VIDEO PRV output
    4 major minor are : 81 7
    [9]:DAVINCI RESIZER
    [a]:DAVINCI VIDEO RSZ input
    [b]:DAVINCI VIDEO RSZ output
    [c]:DAVINCI AEW
    [d]:DAVINCI AF
    total number of entities: 13
    **********************************************
    5.enumerating links/pads for entities
    pads for entity 1=(0, OUTPUT) 
    [1:0]-------------->[4:0]	INACTIVE 
    
    pads for entity 2=(0, OUTPUT) 
    [2:0]-------------->[4:0]	INACTIVE 
    
    
    
    pads for entity 4=(0, INPUT) (1, OUTPUT) 
    [4:1]-------------->[5:0]	INACTIVE 
    [4:1]-------------->[c:0]	INACTIVE 
    [4:1]-------------->[d:0]	INACTIVE 
    [4:1]-------------->[6:0]	INACTIVE 
    
    pads for entity 5=(0, INPUT) 
    
    pads for entity 6=(0, INPUT) (1, OUTPUT) 
    [6:1]-------------->[8:0]	INACTIVE 
    [6:1]-------------->[9:0]	INACTIVE 
    
    pads for entity 7=(0, OUTPUT) 
    [7:0]-------------->[6:0]	INACTIVE 
    
    pads for entity 8=(0, INPUT) 
    
    pads for entity 9=(0, INPUT) (1, OUTPUT) 
    [9:1]-------------->[b:0]	INACTIVE 
    
    pads for entity a=(0, OUTPUT) 
    [a:0]-------------->[9:0]	INACTIVE 
    
    pads for entity b=(0, INPUT) 
    
    pads for entity c=(0, INPUT) 
    
    pads for entity d=(0, INPUT) 
    
    **********************************************
    6. ENABLEing link [tvp7002]----------->[ccdc]
    [tvp514x]----------->[ccdc]	ENABLED
    7. ENABLEing link [CCDC]----------->[PRV]
    [ccdc]----------->[prv]	ENABLED
    7. ENABLEing link [prv]----------->[rsz]
    [prv]----------->[rsz]	ENABLED
    8. ENABLEing link [rsz]----------->[video_node]
    [rsz]----------->[video_node]	 ENABLED
    **********************************************
    default configuration setting in resizer successfull
    congiration got from resizer successfully
    second output enabled!!!
    out format is 420sp
    successfully set configuration in rsz 
    default configuration is set successfully on prv
    got configuration from prv successfully
    configuration is set successfully on prv
    setting default for prv-module LUT Defect Correction
    setting default for prv-module OTF Defect Pixel Correction
    setting default for prv-module 2-D Noise filter - 1
    setting default for prv-module 2-D Noise filter - 2
    setting default for prv-module Green Imbalance Correction
    setting default for prv-module White balance
    setting default for prv-module CFA Interpolation
    setting default for prv-module RGB-RGB Conversion - 1
    setting default for prv-module Gamma Correction
    setting default for prv-module RGB-RGB Conversion - 2
    setting default for prv-module 3D LUT
    setting default for prv-module RGB-YCbCr conversion
    setting default for prv-module Global Brightness,Contrast Control
    setting default for prv-module YUV 422 conversion
    setting default for prv-module Luminance Adjustment
    setting default for prv-module Edge Enhancer
    setting default for prv-module Chromatic Artifact Reduction
    setting default for prv-module Chromatic Gain Suppression
    **********************************************
    15.enumerating INPUTS
    [0].Composite
    [1].S-Video
    **********************************************
    16. setting CAMERA as input. . .
    successfully set CAMERA input
    **********************************************
    setting PAL std. . .
    successfully set PAL std
    8. setting format on pad of tvp514x entity. . .
    width and height are: 720 576
    successfully format is set on pad 0
    12. setting format on sink-pad of ccdc entity. . .
    successfully format is set on pad 0
    13. setting format on OF-pad of ccdc entity. . . 
    successfully format is set on pad 1
    10. setting format on sink-pad of prv entity. . . 
    successfully format is set on pad 0
    10. setting format on source-pad of prv entity. . . 
    successfully format is set on pad 1
    10. setting format on sink-pad of rsz entity. . . 
    successfully format is set on pad 0
    10. setting format on source-pad of rsz entity. . . 
    successfully format is set on pad 1
    **********************************************
    17. setting format V4L2_PIX_FMT_UYVY
    successfully set the format
    capture_pitch: 2e0
    **********************************************
    18. Requesting for 3 buffers
    3 buffers are supported for streaming
    **********************************************
    19. queing buffers
    streaming started successfully
    numbytes : 720 h : 864 width : 720 height : 576 capture_pich : 736
    frame:    1, buf.timestamp:1303343530:394741 (delta:0)
    frame:    2, buf.timestamp:1303343530:428135 (delta:33394)
    frame:    3, buf.timestamp:1303343530:452133 (delta:23998)
    frame:    4, buf.timestamp:1303343530:498038 (delta:45905)
    frame:    5, buf.timestamp:1303343530:634477 (delta:136439)
    frame:    6, buf.timestamp:1303343530:670802 (delta:36325)
    frame:    7, buf.timestamp:1303343530:704064 (delta:33262)
    frame:    8, buf.timestamp:1303343530:834472 (delta:130408)
    frame:    9, buf.timestamp:1303343530:870793 (delta:36321)
    frame:   10, buf.timestamp:1303343530:904065 (delta:33272)
    frame:   11, buf.timestamp:1303343531:34470 (delta:130405)
    frame:   12, buf.timestamp:1303343531:70790 (delta:36320)
    frame:   13, buf.timestamp:1303343531:104057 (delta:33267)
    frame:   14, buf.timestamp:1303343531:184879 (delta:80822)
    frame:   15, buf.timestamp:1303343531:211676 (delta:26797)
    frame:   16, buf.timestamp:1303343531:234467 (delta:22791)
    frame:   17, buf.timestamp:1303343531:270787 (delta:36320)
    frame:   18, buf.timestamp:1303343531:304051 (delta:33264)
    frame:   19, buf.timestamp:1303343531:384877 (delta:80826)
    frame:   20, buf.timestamp:1303343531:411673 (delta:26796)
    frame:   21, buf.timestamp:1303343531:434463 (delta:22790)
    frame:   22, buf.timestamp:1303343531:470784 (delta:36321)
    frame:   23, buf.timestamp:1303343531:504049 (delta:33265)
    frame:   24, buf.timestamp:1303343531:584873 (delta:80824)
    frame:   25, buf.timestamp:1303343531:611669 (delta:26796)
    frame:   26, buf.timestamp:1303343531:634457 (delta:22788)
    frame:   27, buf.timestamp:1303343531:670780 (delta:36323)
    frame:   28, buf.timestamp:1303343531:704047 (delta:33267)
    frame:   29, buf.timestamp:1303343531:784868 (delta:80821)
    frame:   30, buf.timestamp:1303343531:811664 (delta:26796)
    frame:   31, buf.timestamp:1303343531:834455 (delta:22791)
    frame:   32, buf.timestamp:1303343531:870776 (delta:36321)
    frame:   33, buf.timestamp:1303343531:904038 (delta:33262)
    frame:   34, buf.timestamp:1303343531:984865 (delta:80827)
    frame:   35, buf.timestamp:1303343532:11662 (delta:26797)
    frame:   36, buf.timestamp:1303343532:34454 (delta:22792)
    frame:   37, buf.timestamp:1303343532:70773 (delta:36319)
    frame:   38, buf.timestamp:1303343532:104042 (delta:33269)
    frame:   39, buf.timestamp:1303343532:184861 (delta:80819)
    frame:   40, buf.timestamp:1303343532:211657 (delta:26796)
    frame:   41, buf.timestamp:1303343532:234445 (delta:22788)
    frame:   42, buf.timestamp:1303343532:270770 (delta:36325)
    frame:   43, buf.timestamp:1303343532:304032 (delta:33262)
    frame:   44, buf.timestamp:1303343532:384855 (delta:80823)
    frame:   45, buf.timestamp:1303343532:411652 (delta:26797)
    frame:   46, buf.timestamp:1303343532:434443 (delta:22791)
    frame:   47, buf.timestamp:1303343532:470763 (delta:36320)
    frame:   48, buf.timestamp:1303343532:504031 (delta:33268)
    frame:   49, buf.timestamp:1303343532:584853 (delta:80822)
    frame:   50, buf.timestamp:1303343532:611648 (delta:26795)
    frame:   51, buf.timestamp:1303343532:634437 (delta:22789)
    frame:   52, buf.timestamp:1303343532:670760 (delta:36323)
    frame:   53, buf.timestamp:1303343532:704024 (delta:33264)
    frame:   54, buf.timestamp:1303343532:784847 (delta:80823)
    frame:   55, buf.timestamp:1303343532:811644 (delta:26797)
    frame:   56, buf.timestamp:1303343532:834433 (delta:22789)
    frame:   57, buf.timestamp:1303343532:870755 (delta:36322)
    frame:   58, buf.timestamp:1303343532:904022 (delta:33267)
    frame:   59, buf.timestamp:1303343532:984843 (delta:80821)
    frame:   60, buf.timestamp:1303343533:11642 (delta:26799)
    frame:   61, buf.timestamp:1303343533:34431 (delta:22789)
    frame:   62, buf.timestamp:1303343533:70751 (delta:36320)
    frame:   63, buf.timestamp:1303343533:104017 (delta:33266)
    frame:   64, buf.timestamp:1303343533:184843 (delta:80826)
    frame:   65, buf.timestamp:1303343533:211639 (delta:26796)
    frame:   66, buf.timestamp:1303343533:234427 (delta:22788)
    frame:   67, buf.timestamp:1303343533:270748 (delta:36321)
    frame:   68, buf.timestamp:1303343533:304013 (delta:33265)
    frame:   69, buf.timestamp:1303343533:384836 (delta:80823)
    frame:   70, buf.timestamp:1303343533:411635 (delta:26799)
    frame:   71, buf.timestamp:1303343533:434422 (delta:22787)
    frame:   72, buf.timestamp:1303343533:470745 (delta:36323)
    frame:   73, buf.timestamp:1303343533:504009 (delta:33264)
    frame:   74, buf.timestamp:1303343533:584833 (delta:80824)
    frame:   75, buf.timestamp:1303343533:611632 (delta:26799)
    frame:   76, buf.timestamp:1303343533:634420 (delta:22788)
    frame:   77, buf.timestamp:1303343533:670737 (delta:36317)
    frame:   78, buf.timestamp:1303343533:704005 (delta:33268)
    frame:   79, buf.timestamp:1303343533:784830 (delta:80825)
    frame:   80, buf.timestamp:1303343533:811625 (delta:26795)
    frame:   81, buf.timestamp:1303343533:834416 (delta:22791)
    frame:   82, buf.timestamp:1303343533:870733 (delta:36317)
    frame:   83, buf.timestamp:1303343533:903999 (delta:33266)
    frame:   84, buf.timestamp:1303343533:984826 (delta:80827)
    frame:   85, buf.timestamp:1303343534:11620 (delta:26794)
    frame:   86, buf.timestamp:1303343534:34412 (delta:22792)
    frame:   87, buf.timestamp:1303343534:70730 (delta:36318)
    frame:   88, buf.timestamp:1303343534:103998 (delta:33268)
    frame:   89, buf.timestamp:1303343534:184819 (delta:80821)
    frame:   90, buf.timestamp:1303343534:211618 (delta:26799)
    frame:   91, buf.timestamp:1303343534:234408 (delta:22790)
    frame:   92, buf.timestamp:1303343534:270726 (delta:36318)
    frame:   93, buf.timestamp:1303343534:303998 (delta:33272)
    frame:   94, buf.timestamp:1303343534:384817 (delta:80819)
    frame:   95, buf.timestamp:1303343534:411615 (delta:26798)
    frame:   96, buf.timestamp:1303343534:434404 (delta:22789)
    frame:   97, buf.timestamp:1303343534:470720 (delta:36316)
    frame:   98, buf.timestamp:1303343534:503988 (delta:33268)
    frame:   99, buf.timestamp:1303343534:584812 (delta:80824)
    frame:  100, buf.timestamp:1303343534:611611 (delta:26799)
    frame:  101, buf.timestamp:1303343534:634398 (delta:22787)
    frame:  102, buf.timestamp:1303343534:670717 (delta:36319)
    frame:  103, buf.timestamp:1303343534:703986 (delta:33269)
    frame:  104, buf.timestamp:1303343534:784808 (delta:80822)
    frame:  105, buf.timestamp:1303343534:811605 (delta:26797)
    frame:  106, buf.timestamp:1303343534:834397 (delta:22792)
    frame:  107, buf.timestamp:1303343534:870712 (delta:36315)
    frame:  108, buf.timestamp:1303343534:903982 (delta:33270)
    frame:  109, buf.timestamp:1303343534:984806 (delta:80824)
    frame:  110, buf.timestamp:1303343535:11603 (delta:26797)
    frame:  111, buf.timestamp:1303343535:34409 (delta:22806)
    frame:  112, buf.timestamp:1303343535:70709 (delta:36300)
    frame:  113, buf.timestamp:1303343535:103977 (delta:33268)
    frame:  114, buf.timestamp:1303343535:184801 (delta:80824)
    frame:  115, buf.timestamp:1303343535:211598 (delta:26797)
    frame:  116, buf.timestamp:1303343535:234392 (delta:22794)
    frame:  117, buf.timestamp:1303343535:270704 (delta:36312)
    frame:  118, buf.timestamp:1303343535:303975 (delta:33271)
    frame:  119, buf.timestamp:1303343535:384798 (delta:80823)
    frame:  120, buf.timestamp:1303343535:411595 (delta:26797)
    frame:  121, buf.timestamp:1303343535:434388 (delta:22793)
    frame:  122, buf.timestamp:1303343535:470699 (delta:36311)
    frame:  123, buf.timestamp:1303343535:503970 (delta:33271)
    frame:  124, buf.timestamp:1303343535:584798 (delta:80828)
    frame:  125, buf.timestamp:1303343535:611590 (delta:26792)
    frame:  126, buf.timestamp:1303343535:634385 (delta:22795)
    frame:  127, buf.timestamp:1303343535:670697 (delta:36312)
    frame:  128, buf.timestamp:1303343535:703965 (delta:33268)
    frame:  129, buf.timestamp:1303343535:784792 (delta:80827)
    frame:  130, buf.timestamp:1303343535:811586 (delta:26794)
    frame:  131, buf.timestamp:1303343535:834380 (delta:22794)
    frame:  132, buf.timestamp:1303343535:870693 (delta:36313)
    frame:  133, buf.timestamp:1303343535:903963 (delta:33270)
    frame:  134, buf.timestamp:1303343535:984789 (delta:80826)
    frame:  135, buf.timestamp:1303343536:11584 (delta:26795)
    frame:  136, buf.timestamp:1303343536:34377 (delta:22793)
    frame:  137, buf.timestamp:1303343536:70688 (delta:36311)
    frame:  138, buf.timestamp:1303343536:103958 (delta:33270)
    frame:  139, buf.timestamp:1303343536:184785 (delta:80827)
    frame:  140, buf.timestamp:1303343536:211580 (delta:26795)
    frame:  141, buf.timestamp:1303343536:234373 (delta:22793)
    frame:  142, buf.timestamp:1303343536:270685 (delta:36312)
    frame:  143, buf.timestamp:1303343536:303956 (delta:33271)
    frame:  144, buf.timestamp:1303343536:384783 (delta:80827)
    frame:  145, buf.timestamp:1303343536:411575 (delta:26792)
    frame:  146, buf.timestamp:1303343536:434370 (delta:22795)
    frame:  147, buf.timestamp:1303343536:470685 (delta:36315)
    frame:  148, buf.timestamp:1303343536:503955 (delta:33270)
    frame:  149, buf.timestamp:1303343536:584779 (delta:80824)
    frame:  150, buf.timestamp:1303343536:611572 (delta:26793)
    frame:  151, buf.timestamp:1303343536:634364 (delta:22792)
    frame:  152, buf.timestamp:1303343536:670677 (delta:36313)
    frame:  153, buf.timestamp:1303343536:703947 (delta:33270)
    frame:  154, buf.timestamp:1303343536:784775 (delta:80828)
    frame:  155, buf.timestamp:1303343536:811569 (delta:26794)
    frame:  156, buf.timestamp:1303343536:834360 (delta:22791)
    frame:  157, buf.timestamp:1303343536:870672 (delta:36312)
    frame:  158, buf.timestamp:1303343536:903942 (delta:33270)
    frame:  159, buf.timestamp:1303343536:984770 (delta:80828)
    frame:  160, buf.timestamp:1303343537:11564 (delta:26794)
    frame:  161, buf.timestamp:1303343537:34355 (delta:22791)
    frame:  162, buf.timestamp:1303343537:70671 (delta:36316)
    frame:  163, buf.timestamp:1303343537:103939 (delta:33268)
    frame:  164, buf.timestamp:1303343537:184767 (delta:80828)
    frame:  165, buf.timestamp:1303343537:211558 (delta:26791)
    frame:  166, buf.timestamp:1303343537:234353 (delta:22795)
    frame:  167, buf.timestamp:1303343537:270664 (delta:36311)
    frame:  168, buf.timestamp:1303343537:303936 (delta:33272)
    frame:  169, buf.timestamp:1303343537:384763 (delta:80827)
    frame:  170, buf.timestamp:1303343537:411556 (delta:26793)
    frame:  171, buf.timestamp:1303343537:434350 (delta:22794)
    frame:  172, buf.timestamp:1303343537:470662 (delta:36312)
    frame:  173, buf.timestamp:1303343537:503935 (delta:33273)
    frame:  174, buf.timestamp:1303343537:584757 (delta:80822)
    frame:  175, buf.timestamp:1303343537:611553 (delta:26796)
    frame:  176, buf.timestamp:1303343537:634346 (delta:22793)
    frame:  177, buf.timestamp:1303343537:670657 (delta:36311)
    frame:  178, buf.timestamp:1303343537:703928 (delta:33271)
    frame:  179, buf.timestamp:1303343537:784756 (delta:80828)
    frame:  180, buf.timestamp:1303343537:811547 (delta:26791)
    frame:  181, buf.timestamp:1303343537:834340 (delta:22793)
    frame:  182, buf.timestamp:1303343537:870654 (delta:36314)
    frame:  183, buf.timestamp:1303343537:903929 (delta:33275)
    frame:  184, buf.timestamp:1303343537:984750 (delta:80821)
    frame:  185, buf.timestamp:1303343538:11544 (delta:26794)
    frame:  186, buf.timestamp:1303343538:34336 (delta:22792)
    frame:  187, buf.timestamp:1303343538:70654 (delta:36318)
    frame:  188, buf.timestamp:1303343538:103922 (delta:33268)
    frame:  189, buf.timestamp:1303343538:184746 (delta:80824)
    frame:  190, buf.timestamp:1303343538:211540 (delta:26794)
    frame:  191, buf.timestamp:1303343538:234334 (delta:22794)
    frame:  192, buf.timestamp:1303343538:270650 (delta:36316)
    frame:  193, buf.timestamp:1303343538:303922 (delta:33272)
    frame:  194, buf.timestamp:1303343538:384743 (delta:80821)
    frame:  195, buf.timestamp:1303343538:411535 (delta:26792)
    frame:  196, buf.timestamp:1303343538:434330 (delta:22795)
    frame:  197, buf.timestamp:1303343538:470645 (delta:36315)
    frame:  198, buf.timestamp:1303343538:503914 (delta:33269)
    frame:  199, buf.timestamp:1303343538:584740 (delta:80826)
    frame:  200, buf.timestamp:1303343538:611534 (delta:26794)
    frame:  201, buf.timestamp:1303343538:634328 (delta:22794)
    frame:  202, buf.timestamp:1303343538:670643 (delta:36315)
    frame:  203, buf.timestamp:1303343538:703913 (delta:33270)
    frame:  204, buf.timestamp:1303343538:784735 (delta:80822)
    frame:  205, buf.timestamp:1303343538:811528 (delta:26793)
    frame:  206, buf.timestamp:1303343538:834321 (delta:22793)
    frame:  207, buf.timestamp:1303343538:870639 (delta:36318)
    frame:  208, buf.timestamp:1303343538:903908 (delta:33269)
    frame:  209, buf.timestamp:1303343538:984731 (delta:80823)
    frame:  210, buf.timestamp:1303343539:11523 (delta:26792)
    frame:  211, buf.timestamp:1303343539:34318 (delta:22795)
    frame:  212, buf.timestamp:1303343539:70634 (delta:36316)
    frame:  213, buf.timestamp:1303343539:103904 (delta:33270)
    frame:  214, buf.timestamp:1303343539:184727 (delta:80823)
    frame:  215, buf.timestamp:1303343539:211521 (delta:26794)
    frame:  216, buf.timestamp:1303343539:234314 (delta:22793)
    frame:  217, buf.timestamp:1303343539:270631 (delta:36317)
    frame:  218, buf.timestamp:1303343539:303899 (delta:33268)
    frame:  219, buf.timestamp:1303343539:384724 (delta:80825)
    frame:  220, buf.timestamp:1303343539:411518 (delta:26794)
    frame:  221, buf.timestamp:1303343539:434308 (delta:22790)
    frame:  222, buf.timestamp:1303343539:470627 (delta:36319)
    frame:  223, buf.timestamp:1303343539:503896 (delta:33269)
    frame:  224, buf.timestamp:1303343539:584722 (delta:80826)
    frame:  225, buf.timestamp:1303343539:611513 (delta:26791)
    frame:  226, buf.timestamp:1303343539:634308 (delta:22795)
    frame:  227, buf.timestamp:1303343539:670623 (delta:36315)
    frame:  228, buf.timestamp:1303343539:703895 (delta:33272)
    frame:  229, buf.timestamp:1303343539:784716 (delta:80821)
    frame:  230, buf.timestamp:1303343539:811512 (delta:26796)
    frame:  231, buf.timestamp:1303343539:834303 (delta:22791)
    frame:  232, buf.timestamp:1303343539:870619 (delta:36316)
    frame:  233, buf.timestamp:1303343539:903887 (delta:33268)
    frame:  234, buf.timestamp:1303343539:984711 (delta:80824)
    frame:  235, buf.timestamp:1303343540:11505 (delta:26794)
    frame:  236, buf.timestamp:1303343540:34300 (delta:22795)
    frame:  237, buf.timestamp:1303343540:70614 (delta:36314)
    frame:  238, buf.timestamp:1303343540:103885 (delta:33271)
    frame:  239, buf.timestamp:1303343540:184708 (delta:80823)
    frame:  240, buf.timestamp:1303343540:211500 (delta:26792)
    frame:  241, buf.timestamp:1303343540:234293 (delta:22793)
    frame:  242, buf.timestamp:1303343540:270612 (delta:36319)
    frame:  243, buf.timestamp:1303343540:303880 (delta:33268)
    frame:  244, buf.timestamp:1303343540:384704 (delta:80824)
    frame:  245, buf.timestamp:1303343540:411494 (delta:26790)
    frame:  246, buf.timestamp:1303343540:434289 (delta:22795)
    frame:  247, buf.timestamp:1303343540:470607 (delta:36318)
    frame:  248, buf.timestamp:1303343540:503877 (delta:33270)
    frame:  249, buf.timestamp:1303343540:584701 (delta:80824)
    frame:  250, buf.timestamp:1303343540:611491 (delta:26790)
    frame:  251, buf.timestamp:1303343540:634287 (delta:22796)
    frame:  252, buf.timestamp:1303343540:670602 (delta:36315)
    frame:  253, buf.timestamp:1303343540:703872 (delta:33270)
    frame:  254, buf.timestamp:1303343540:784697 (delta:80825)
    frame:  255, buf.timestamp:1303343540:811488 (delta:26791)
    frame:  256, buf.timestamp:1303343540:834282 (delta:22794)
    frame:  257, buf.timestamp:1303343540:870600 (delta:36318)
    frame:  258, buf.timestamp:1303343540:903870 (delta:33270)
    frame:  259, buf.timestamp:1303343540:984691 (delta:80821)
    frame:  260, buf.timestamp:1303343541:11481 (delta:26790)
    frame:  261, buf.timestamp:1303343541:34279 (delta:22798)
    frame:  262, buf.timestamp:1303343541:70596 (delta:36317)
    frame:  263, buf.timestamp:1303343541:103866 (delta:33270)
    frame:  264, buf.timestamp:1303343541:184688 (delta:80822)
    frame:  265, buf.timestamp:1303343541:211478 (delta:26790)
    frame:  266, buf.timestamp:1303343541:234275 (delta:22797)
    frame:  267, buf.timestamp:1303343541:270590 (delta:36315)
    frame:  268, buf.timestamp:1303343541:303860 (delta:33270)
    frame:  269, buf.timestamp:1303343541:384684 (delta:80824)
    frame:  270, buf.timestamp:1303343541:411474 (delta:26790)
    frame:  271, buf.timestamp:1303343541:434272 (delta:22798)
    frame:  272, buf.timestamp:1303343541:470588 (delta:36316)
    frame:  273, buf.timestamp:1303343541:503857 (delta:33269)
    frame:  274, buf.timestamp:1303343541:584683 (delta:80826)
    frame:  275, buf.timestamp:1303343541:611469 (delta:26786)
    frame:  276, buf.timestamp:1303343541:634266 (delta:22797)
    frame:  277, buf.timestamp:1303343541:670585 (delta:36319)
    frame:  278, buf.timestamp:1303343541:703852 (delta:33267)
    frame:  279, buf.timestamp:1303343541:784676 (delta:80824)
    frame:  280, buf.timestamp:1303343541:811467 (delta:26791)
    frame:  281, buf.timestamp:1303343541:834263 (delta:22796)
    frame:  282, buf.timestamp:1303343541:870579 (delta:36316)
    frame:  283, buf.timestamp:1303343541:903850 (delta:33271)
    frame:  284, buf.timestamp:1303343541:984673 (delta:80823)
    frame:  285, buf.timestamp:1303343542:11462 (delta:26789)
    frame:  286, buf.timestamp:1303343542:34259 (delta:22797)
    frame:  287, buf.timestamp:1303343542:70576 (delta:36317)
    frame:  288, buf.timestamp:1303343542:103845 (delta:33269)
    frame:  289, buf.timestamp:1303343542:184670 (delta:80825)
    frame:  290, buf.timestamp:1303343542:211456 (delta:26786)
    frame:  291, buf.timestamp:1303343542:234255 (delta:22799)
    frame:  292, buf.timestamp:1303343542:270573 (delta:36318)
    frame:  293, buf.timestamp:1303343542:303842 (delta:33269)
    frame:  294, buf.timestamp:1303343542:384665 (delta:80823)
    frame:  295, buf.timestamp:1303343542:411455 (delta:26790)
    frame:  296, buf.timestamp:1303343542:434250 (delta:22795)
    frame:  297, buf.timestamp:1303343542:470568 (delta:36318)
    frame:  298, buf.timestamp:1303343542:503836 (delta:33268)
    frame:  299, buf.timestamp:1303343542:584661 (delta:80825)
    frame:  300, buf.timestamp:1303343542:611451 (delta:26790)
    **********************************************
    streaming stopped successfully
    closing all the file descriptors. . .
    closed capture device
    closed reszier sub-device
    closed previewer sub-device
    closed ccdc sub-device
    closed tvp514x sub-device
    closed  media device
    closed the file 
    

    Thanks,

    Frank

  • Just as an update, we found the reason we were still having frame drops: the camera connections at the camera side were loose!  This was causing intermittent signal issues and thus dropped frames.

    Thanks again for all the help.


    Frank

  • Hi Frank,

    Sorry I dnt I had the setup to test it :(. I'ts good that you solved it and problem was not in the driver :)

    Thx,

    --Prabhakar Lad

  • Hi,

    This thread seems to indicate, that the "dvsdk" branch is better to use than the "official" latest PSP-release supporting dm365 (using tag "v2.6.37_DAVINCIPSP_03.21.00.04")

    Is that correct?

    Thank you!

    /Søren

  • I'm not sure that the "dvsdk" branch is better, but I remember reading something about it being necessary for DM368.  Maybe somebody from TI can shed some light on the subject.  You might want to start a separate thread, though.