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 the SDSoC 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. The zc702_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 the motion_demo_processing example, the following code snippet from m2m_sw_pipeline.c demonstrates 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 in motion_detect.c, where motion_demo_procesing is defined and called by the img_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 the SDSoC Downloads Page with the name ZC702[ZC706] + HDMI IO FMC. To access the project in the SDSoC environment, create a new project, name the project, and select Add Custom Platform. From the Target Platform menu, select the downloaded platform named zc702[zc706]_trd, click Next, and use the template named Motion Detect.