UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Participant gomo
Participant
4,007 Views
Registered: ‎07-18-2016

in Zynq UltraScale MPSoC Base TRD 2016.2 reference designs, how to get the first image from sensor in trigger mode of sensor.

 

in Zynq UltraScale MPSoC Base TRD 2016.2 reference designs, we use to capture image ,in the following codes:

 

process_m2m_sw_event_loop(void *ptr)
{
int ret=0,i=0;
struct video_pipeline *v_pipe = (struct video_pipeline *) ptr;


/* push cleanup handler */
pthread_cleanup_push(uninit_m2m_sw_pipeline, ptr);
if (v_pipe->enable_log_event) {
ret = pthread_create(&v_pipe->event_thread, NULL, capture_pipeline_events, v_pipe);
ASSERT( ret < 0 , "thread creation failed \n");
}

 

for (i = 0; i < BUFFER_CNT; ++i)
{
struct v4l2_buffer buffer;
memset(&buffer, 0, sizeof(buffer));
buffer.type =V4L2_BUF_TYPE_VIDEO_CAPTURE;
buffer.memory = V4L2_MEMORY_MMAP;
buffer.index = i;
if (-1 == ioctl (m2m_sw_stream_handle.video_in.fd, VIDIOC_QUERYBUF, &buffer))
{
perror("VIDIOC_QUERYBUF");
exit(EXIT_FAILURE);
}

m2m_sw_stream_handle.video_in.vid_buf[i].v4l2_buff_length=buffer.length;

/* remember for munmap() */
m2m_sw_stream_handle.video_in.vid_buf[i].v4l2_buff = mmap(NULL,
buffer.length, PROT_READ|PROT_WRITE, MAP_SHARED,
m2m_sw_stream_handle.video_in.fd, buffer.m.offset);

printf("process_m2m_sw_event_loop s2m_stream_handle.video_in.vid_buf[i] =%p i=%d ------\n ",m2m_sw_stream_handle.video_in.vid_buf[i].v4l2_buff ,i );

/* If you do not exit here you should unmap() and free()
the buffers mapped so far. */

ASSERT(MAP_FAILED == m2m_sw_stream_handle.video_in.vid_buf[i].v4l2_buff , "mmap failed ");
m2m_sw_stream_handle.video_in.vid_buf[i].index = i;

#ifdef WITH_SDSOC
if (m2m_sw_stream_handle.fs->mode == FILTER_MODE_HW) {
/* export buffer for sharing buffer between two v4l2 devices*/
struct v4l2_exportbuffer eb;
memset(&eb, 0, sizeof(eb));
eb.type = m2m_sw_stream_handle.video_in.buf_type;
eb.index = i;
ret = ioctl(m2m_sw_stream_handle.video_in.fd, VIDIOC_EXPBUF, &eb);
ASSERT(ret< 0, "VIDIOC_EXPBUF failed: %s\n", ERRSTR);

m2m_sw_stream_handle.video_in.vid_buf[i].dbuf_fd = eb.fd;
vlib_dbg("sds_register_dmabuf :: %s :: %p %d \n",__func__,
m2m_sw_stream_handle.video_in.vid_buf[i].v4l2_buff,
m2m_sw_stream_handle.video_in.vid_buf[i].dbuf_fd);

if (sds_register_dmabuf((void *)m2m_sw_stream_handle.video_in.vid_buf[i].v4l2_buff,
m2m_sw_stream_handle.video_in.vid_buf[i].dbuf_fd)) {
perror( "ERROR: dmabuf registration failed" );
}

}
#endif
}


/* Assigning buffer index and set exported buff handle */
for(i=0;i<BUFFER_CNT;i++) {
//Queue buffer to TPG
v4l2_queue_buffer(&m2m_sw_stream_handle.video_in,
& (m2m_sw_stream_handle.video_in.vid_buf[i]));
}

/* Start streaming */
ret = v4l2_device_on(& m2m_sw_stream_handle.video_in);
ASSERT (ret < 0, "v4l2_device_on [video_in] failed %d \n",ret);
vlib_dbg("vlib :: Video Capture Pipeline started\n");


/* Set current buffer index */
m2m_sw_stream_handle.vout_index = -1;
m2m_sw_stream_handle.vin_index = -1;

struct pollfd fds[] = {
{.fd = m2m_sw_stream_handle.video_in.fd, .events = POLLIN},
{.fd = v_pipe->drm.fd, .events = POLLIN},
};

/* Register drm event context */
drmEventContext evctx;
memset(&evctx, 0, sizeof evctx);
evctx.version = DRM_EVENT_CONTEXT_VERSION;
evctx.vblank_handler = drm_event_handler;


struct buffer *b;
/* NOTE : VDMA doesn't issue EOF interrupt , as a result even on the first frame done,
interrupt , it still updating it , current solution is to skip the first frame
done notification */


/* poll and pass buffers */
while ((ret = poll(fds, ARRAY_SIZE(fds), POLL_TIMEOUT_MSEC)) > 0 )
{
if (fds[0].revents & POLLIN)
{
printf("poll fds[0].revents 222 ----- \n ");

v_pipe->events[CAPTURE].counter_val++;
b = v4l2_dequeue_buffer(&m2m_sw_stream_handle.video_in,
m2m_sw_stream_handle.video_in.vid_buf);


int index = b->index;
if (m2m_sw_stream_handle.vin_index == -1){
m2m_sw_stream_handle.vin_index = index;
continue;
}

b = &m2m_sw_stream_handle.video_in.vid_buf[m2m_sw_stream_handle.vin_index];
m2m_sw_stream_handle.vin_index = index;

unsigned short *out_ptr = (unsigned short *) v_pipe->drm.d_buff[b->index].drm_buff;
unsigned short *in_ptr = (unsigned short *) b->v4l2_buff;
v_pipe->events[PROCESS_IN].counter_val++;


we find Code comments "/* NOTE : VDMA doesn't issue EOF interrupt , as a result even on the first frame done,
interrupt , it still updating it , current solution is to skip the first frame
done notification */"

 

what does this means ? and how to solve it ? because we want to get the first image from sensor in trigger mode of sensor.

0 Kudos