Accessing External I/O via Memory Buffers
This section uses the motion-detect ZC702 + HDMI IO FMC or ZC706 + HDMI IO FMC platform found on theSDSoC Downloads Page. The figure below shows how the design example is configured. The preconfigured SDSoC platform is responsible for the HDMI data transfer to external memory. The application must call the platform interfaces to process the data from the frame buffer in DDR memory.
Figure:Motion Detect Design Configuration
The SDSoC environment accesses the external frame buffer through an accelerator interface to the platform. Thezc702_hdmi
platform provides a software interface to access the video frame buffer through the Video4Linux2 (V4L2) API. The V4L2 framework provides an API accessing a collection of device drivers supporting real-time video capture in Linux. For the application developer, this API is the platform I/O entry point. In themotion_demo_processing
example, the following code snippet fromm2m_sw_pipeline.cdemonstrates the function call interface.
extern void motion_demo_processing(unsigned short int *prev_buffer, unsigned short int *in_buffer, unsigned short int *out_buffer, int fps_enable, int height, int width, int stride); . . . unsigned short *out_ptr = v_pipe->drm.d_buff[buf_next->index].drm_buff; unsigned short *in_ptr1 = buf_prev->v412_buff; unsigned short *in_ptr2 = buf_next->v412_buff; v_pipe->events[PROCESS_IN].counter_val++; motion_demo_processing(in_ptr1, in_ptr2, out_ptr, v_pipe->fps_enable, (int)m2m_sw_stream_handle.video_in.format.height, (int)m2m_sw_stream_handle.video_in.format.width, (int)m2m_sw_stream_handle.video_in.format.bytesperline/2);
The application accesses this API inmotion_detect.c, wheremotion_demo_procesing
is defined and called by theimg_process
function.
void motion_demo_processing(unsigned short int *prev_buffer, unsigned short int *in_buffer, unsigned short int *out_buffer, int fps_enable, int height, int width, int stride) { int param0=0, param1=1, param2=2; TIME_STAMP_INIT img_process(prev_buffer, in_buffer, out_buffer, height, width, stride); TIME_STAMP }
Finally,img_process
calls the various filters and transforms to process the data.
void img_process(unsigned short int *frame_prev, unsigned short int *frame_curr, unsigned short int *frame_out, int param0, int param1, int param2) { ... }
By using a platform API to access the frame buffers, the application developer does not program at the driver level to process the video frames. You can find the platform used for the code snippets on theSDSoC Downloads Pagewith the name ZC702[ZC706] + HDMI IO FMC. To access the project in the SDSoC environment, create a new project, name the project, and selectAdd Custom Platform. From theTarget Platformmenu, select the downloaded platform namedzc702[zc706]_trd, clickNext, and use the template named Motion Detect.