Buffer Read/Write from CPU

You can use this API function to write data directly into a GBM buffer:

gbm_bo_write(bo, user_buffer, sizeof user_buffer);

You can also memory map a GBM buffer and get a CPU-accessible address to the data written to or read from it:

uint32_t dst_stride = 0;
void *gbo_mapping = NULL;
// Map bo to CPU accessible address.
char *dst_ptr = gbm_bo_map(bo,
                           0, 0,
                           width,
                           height,
                           GBM_BO_TRANSFER_READ_WRITE,
                           &dst_stride,
                           &gbo_mapping);
// Write data to or read data from dst_ptr.
. . .
// Unmap bo.
gbm_bo_unmap(bo, gbo_mapping);