This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

User-Allocated Buffers

Newbie question...

Can someone help me to understand the different ways buffers are handled in Linux?  I see DVSDK 3.10 promoting that it supports "user-allocated buffers".   What exactly does this mean?  In the past I've seen that we've used CMEM (or maybe DMAI on top of CMEM) for doing memory allocation.  I still see calls into DMAI in DVSDK 3.10.  So how is it different?  I'd like to understand the advantages/disadvantages (performance, ease of use, portability, etc.) for the various approaches.

  • Hi Brad,

    User-allocated buffers means that the user allocates the contiguous video buffer in their app using e.g. CMEM (any contiguous memory mapped to user space will do). Driver-allocated buffers means that the driver itself allocates the buffers, typically when the driver is initialized. Depending on your application, one may be preferred to the other. The performance is the same, and both types of buffers need to be page aligned (4096 bytes on ARM Linux).

    However, this is the usage difference: When Linux initializes it takes over all memory given to it (can be limited using the mem= kernel command line option). If the driver is asked to allocate memory for the device driver buffers, the driver will carve off contiguous memory from the memory controlled by Linux. As for ease of use, the number of buffers to allocate as well as resolution can typically be configured using kernel module or boot command line parameters.

    If user-allocated buffers using CMEM is used the memory is not taken from the memory Linux controls, it is taken from the memory CMEM controls instead. The upside is that you can configure all your video buffers, for codecs and device drivers, in one central pool based location. The down side to user allocated buffers is that the FBDev interface doesn't support user allocated buffers, only the v4l2 interface does. Most community software uses FBDev for display, hence driver allocated buffers remains necessary if FBDev is to be supported.

    You can see more information on CMEM vs. Linux memory and how to partition this for your application on this wiki page:

    http://tiexpressdsp.com/index.php/Changing_the_DVEVM_memory_map#The_procedure

    Regards, Niclas