Showing results for 
Search instead for 
Did you mean: 
Registered: ‎05-15-2018

Read from i/p Frame Buffer into the PS - Process - Write to o/p frame Buffer

I am working on the Reference design

I am looking at options to read write the Frame Buffers into and out of the PS. Currently, the video_cmd which is included in the reference design is based on the DRM API, where the data transfer between the I/P and O/P Frame buffer is through a DMA. But I want to read the V_frmbuf_wr_o (i/p frame buffer) and do certain processing on the data thus read and write it out to the Video Frame Buffer Read (o/p frame buffer), this I want to do in a loop for a video processing.



Now I have tried the below steps.

cat of /proc/iomem

root@zcu102:~# cat /proc/iomem
00000000-7fefffff : System RAM
  00080000-00d5ffff : Kernel code
  00de0000-010a6fff : Kernel data
80000000-8000ffff : hdmi-rxss
80010000-8001ffff : /amba_pl@0/v_frmbuf_rd@80010000
80040000-8004ffff : /amba_pl@0/v_frmbuf_wr@80040000

and figured out the mapping for the frame buffer and further I did a memory mapping for these memory regions into virtual memory into PS and then do a memcpy from the i/p to the o/p, below is a brief code

#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", \
  __LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)

#define MAP_SIZE_8K 8192UL

void *lookup_slave_by_phy_addr(const int fd, const off_t target, const size_t mapsize)
  void *map_base, *virt_addr;

  /* Map one page */
  map_base = mmap(0, mapsize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target & ~(mapsize-1));
  if (map_base == (void *) -1) { FATAL; }
  printf("Memory mapped at address %p.\n", map_base);

  virt_addr = map_base + (target & (mapsize-1));
  return virt_addr;

       int fd;
       if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) { FATAL; }
       printf("/dev/mem opened.\n");
       void *ReadPixels, *WritePixels;
       ReadPixels       = lookup_slave_by_phy_addr(fd,strtoul("0x0000000800400000",0,0),MAP_SIZE_8K);
       WritePixels       = lookup_slave_by_phy_addr(fd,strtoul("0x0000000800100000",0,0),MAP_SIZE_8K);

       memcpy(ReadPixels, WritePixels, 8192);

But this doesn't yield any video stream on the o/p, I then edited the existing video_cmd with the above code added and disabling the s2m_pipeline, but that too fails to work and ends up with a blank screen only.

Now I am looking at ways to do this, without DRM/ DMA but with PS control over the read Write with below questions.

1. Is the physical memory I am mapping correctly? Is this actually the memory space where the video data is read and written from and to or is it just a control register space?
2. Are there two separate physical memory space (for reading and Write)?
3. How do you I access the data safely and write it back post processing?
4. Is there any HW IP I am required incorporate to do this?
5. Need any possible help in achieving the schematic shown above.



Tags (1)
0 Kudos