Interfacing with the Video Framebuffer Driver from DMA Clients

Linux Drivers

Release Date
2023-07-22
xilinx_frmbuf.h
  1. Using the Video Framebuffer API, configure the DMA device with the expected memory format for write
  2. Prepare an interleaved template describing the buffer location (note: see section DMA Interleaved Template Requirements below for more details)
  3. Pass the interleaved template to the DMA device using the Linux DMA Engine interface
  4. With the DMA descriptor which is returned from step 3, add a callback and then submit to the DMA device via the DMA Engine interface
  5. Start the DMA write operation
  6. Terminate DMA write operation when frame processing deemed complete by client
/* Abstract V4L2 Client Code Example */
 
struct dma_chan *frmbuf_dma = to_frmbuf_dma_chan(xdev);
struct dma_interleaved_template dma_tmplt;
dma_addr_t addr = vb2_dma_contig_plane_dma_addr(vb2_buffer_ptr, 0);
u32 flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK;
 
/* Step 1 - Configure the dma channel to write out packed RGB */
xilinx_xdma_v4l2_config(frmbuf_dma, V4L2_PIX_FMT_RGB24);
 
/* Step 2 - Describe the buffer attributes for a 1080p frame */
dma_tmplt.dir = DMA_DEV_TO_MEM; /* DMA_MEM_TO_DEV */
dma_tmplt.src_sgl = false;
dma_tmplt.dst_sgl = true;
dma_tmplt.dst_start = addr;
dma_tmplt.frame_size = 1; /* single plane pixel format */
dma_tmplt.numf = 1080; /* 1920x1080 frame */
 
dma_tmplt.sgl[0].size = 5760; /* 3 bytes/pixel x 1920 pixels */
dma_tmplt.sgl[0].icg = 0;
 
 
/* Step 3 - Submit the buffer description to the dma channel */
desc = dmaengine_prep_interleaved_dma(frmbuf_dma, &&dma_tmplt, flags);
desc->callback = dma_complete;
desc->callback_param = buf;
 
/* Step 4 - Submit the returned and updated descriptor to the dma channel */
dmaengine_submit(desc);
 
/* Step 5 - Start dma to memory operation */
dma_async_issue_pending(frmbuf_dma);
 
/* Step 6 - Halt DMA when required frame processing completed */
dmaengine_terminate_all(frmbuf_dma);