slow memcpy

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

slow memcpy

Jump to solution
658 Views
OlivierG
Contributor III

HI

i tried this code

https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/imx-processors/173737/1/v4lcap.c

unfortunately the call to memcpy from
buffers[buf.index].start[0]
is very slow about 10 ms with an image size 640*480

i thing it is due to the VB2_MEMORY_MMAP mode

i tried with V4L2_MEMORY_DMABUF but ioctl failed

Is the slow memcpy due to the memory mode ?
Is there a working exemple with V4L2_MEMORY_DMABUF and V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ?

 

Greeting

 

Olivier

0 Kudos
Reply
1 Solution
635 Views
OlivierG
Contributor III

Hi 

i use this code to use DMA instead of MMAP

https://github.com/emfend/dmabuf-v4l2-demo

I also verified that this patch is applied

https://github.com/torvalds/linux/commit/de27891f675ed1e46e8821d2e05e036e5f97586b

It works, memcpy time is less than 1 ms

Olivier

 

 

View solution in original post

0 Kudos
Reply
1 Reply
636 Views
OlivierG
Contributor III

Hi 

i use this code to use DMA instead of MMAP

https://github.com/emfend/dmabuf-v4l2-demo

I also verified that this patch is applied

https://github.com/torvalds/linux/commit/de27891f675ed1e46e8821d2e05e036e5f97586b

It works, memcpy time is less than 1 ms

Olivier

 

 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2059409%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Eslow%20memcpy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2059409%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHI%3C%2FP%3E%3CP%3Ei%20tried%20this%20code%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Fpwmxy87654%2Fattachments%2Fpwmxy87654%2Fimx-processors%2F173737%2F1%2Fv4lcap.c%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Fpwmxy87654%2Fattachments%2Fpwmxy87654%2Fimx-processors%2F173737%2F1%2Fv4lcap.c%3C%2FA%3E%3C%2FP%3E%3CP%3Eunfortunately%20the%20call%20to%20memcpy%20from%3CBR%20%2F%3Ebuffers%5Bbuf.index%5D.start%5B0%5D%3CBR%20%2F%3Eis%20very%20slow%20about%2010%20ms%20with%20an%20image%20size%20640*480%3C%2FP%3E%3CP%3Ei%20thing%20it%20is%20due%20to%20the%20VB2_MEMORY_MMAP%20mode%3C%2FP%3E%3CP%3Ei%20tried%20with%20V4L2_MEMORY_DMABUF%20but%20ioctl%20failed%3C%2FP%3E%3CP%3EIs%20the%20slow%20memcpy%20due%20to%20the%20memory%20mode%20%3F%3CBR%20%2F%3EIs%20there%20a%20working%20exemple%20with%20V4L2_MEMORY_DMABUF%20and%20V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE%20%3F%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EGreeting%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EOlivier%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2061369%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20slow%20memcpy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2061369%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3C%2FP%3E%3CP%3Ei%20use%20this%20code%20to%20use%20DMA%20instead%20of%20MMAP%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Femfend%2Fdmabuf-v4l2-demo%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Femfend%2Fdmabuf-v4l2-demo%3C%2FA%3E%3C%2FP%3E%3CP%3EI%20also%20verified%20that%20this%20patch%20is%20applied%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Ftorvalds%2Flinux%2Fcommit%2Fde27891f675ed1e46e8821d2e05e036e5f97586b%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Ftorvalds%2Flinux%2Fcommit%2Fde27891f675ed1e46e8821d2e05e036e5f97586b%3C%2FA%3E%3C%2FP%3E%3CP%3EIt%20works%2C%20memcpy%20time%20is%20less%20than%201%20ms%3C%2FP%3E%3CP%3EOlivier%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E