-PUBLIC void *gbm_bo_map(struct gbm_bo *bo, uint32_t x, uint32_t y, uint32_t width, uint32_t height,
- uint32_t transfer_flags, uint32_t *stride, void **map_data, size_t plane)
-{
- void *addr;
- off_t offset;
- uint32_t map_flags;
- struct rectangle rect = {.x = x, .y = y, .width = width, .height = height };
- if (!bo || width == 0 || height == 0 || !stride || !map_data)
- return NULL;
-
- map_flags = (transfer_flags & GBM_BO_TRANSFER_READ) ? BO_MAP_READ : BO_MAP_NONE;
- map_flags |= (transfer_flags & GBM_BO_TRANSFER_WRITE) ? BO_MAP_WRITE : BO_MAP_NONE;
-
- addr = drv_bo_map(bo->bo, &rect, map_flags, (struct mapping **)map_data, plane);
- if (addr == MAP_FAILED)
- return MAP_FAILED;
-
- *stride = ((struct mapping *)*map_data)->vma->map_strides[plane];
-
- offset = *stride * rect.y;
- offset += drv_stride_from_format(bo->gbm_format, rect.x, plane);
- return (void *)((uint8_t *)addr + offset);
-}
-