[closed]Slow copy: memcpy 26Mb = 190ms with MMAP. IO_METHOD_USERPTR now works.

V4L2_MEMORY_USERPTR works fast now.

I found v4l2 example (Webcam and maximal resolution using v4l2 - FriendlyARM), where is userptr buffer allocation using not malloc, but memalign from malloc.h. Otherwise: Invalid argument error 22.

Now i set IO_METHOD_USERPTR, and in the init_userp:

unsigned int page_size;

        page_size = getpagesize ();
        buffer_size = (buffer_size + page_size - 1) & ~(page_size - 1);

..................
..................

  for (n_buffers = 0; n_buffers < 4; ++n_buffers) {
                buffers[n_buffers].length = buffer_size;
                buffers[n_buffers].start = memalign (/* boundary */page_size,buffer_size);

                if (!buffers[n_buffers].start) {
          fprintf (stderr, "Out of memory\n");
                exit (EXIT_FAILURE);
    }
        }

Then i copy buf.m.userptr to pinned memory and then using in the cuda functions.

Thanks to all.

Best regards, Viktor.