• Home
  • Raw
  • Download

Lines Matching refs:bo

225 struct bo *drv_bo_new(struct driver *drv, uint32_t width, uint32_t height, uint32_t format,  in drv_bo_new()
229 struct bo *bo; in drv_bo_new() local
230 bo = (struct bo *)calloc(1, sizeof(*bo)); in drv_bo_new()
232 if (!bo) in drv_bo_new()
235 bo->drv = drv; in drv_bo_new()
236 bo->width = width; in drv_bo_new()
237 bo->height = height; in drv_bo_new()
238 bo->format = format; in drv_bo_new()
239 bo->use_flags = use_flags; in drv_bo_new()
240 bo->num_planes = drv_num_planes_from_format(format); in drv_bo_new()
242 if (!bo->num_planes) { in drv_bo_new()
243 free(bo); in drv_bo_new()
247 return bo; in drv_bo_new()
250 struct bo *drv_bo_create(struct driver *drv, uint32_t width, uint32_t height, uint32_t format, in drv_bo_create()
255 struct bo *bo; in drv_bo_create() local
257 bo = drv_bo_new(drv, width, height, format, use_flags); in drv_bo_create()
259 if (!bo) in drv_bo_create()
262 ret = drv->backend->bo_create(bo, width, height, format, use_flags); in drv_bo_create()
265 free(bo); in drv_bo_create()
271 for (plane = 0; plane < bo->num_planes; plane++) { in drv_bo_create()
273 assert(bo->offsets[plane] >= bo->offsets[plane - 1]); in drv_bo_create()
275 drv_increment_reference_count(drv, bo, plane); in drv_bo_create()
280 return bo; in drv_bo_create()
283 struct bo *drv_bo_create_with_modifiers(struct driver *drv, uint32_t width, uint32_t height, in drv_bo_create_with_modifiers()
288 struct bo *bo; in drv_bo_create_with_modifiers() local
295 bo = drv_bo_new(drv, width, height, format, BO_USE_NONE); in drv_bo_create_with_modifiers()
297 if (!bo) in drv_bo_create_with_modifiers()
300 ret = drv->backend->bo_create_with_modifiers(bo, width, height, format, modifiers, count); in drv_bo_create_with_modifiers()
303 free(bo); in drv_bo_create_with_modifiers()
309 for (plane = 0; plane < bo->num_planes; plane++) { in drv_bo_create_with_modifiers()
311 assert(bo->offsets[plane] >= bo->offsets[plane - 1]); in drv_bo_create_with_modifiers()
313 drv_increment_reference_count(drv, bo, plane); in drv_bo_create_with_modifiers()
318 return bo; in drv_bo_create_with_modifiers()
321 void drv_bo_destroy(struct bo *bo) in drv_bo_destroy() argument
325 struct driver *drv = bo->drv; in drv_bo_destroy()
329 for (plane = 0; plane < bo->num_planes; plane++) in drv_bo_destroy()
330 drv_decrement_reference_count(drv, bo, plane); in drv_bo_destroy()
332 for (plane = 0; plane < bo->num_planes; plane++) in drv_bo_destroy()
333 total += drv_get_reference_count(drv, bo, plane); in drv_bo_destroy()
338 assert(drv_mapping_destroy(bo) == 0); in drv_bo_destroy()
339 bo->drv->backend->bo_destroy(bo); in drv_bo_destroy()
342 free(bo); in drv_bo_destroy()
345 struct bo *drv_bo_import(struct driver *drv, struct drv_import_fd_data *data) in drv_bo_import()
349 struct bo *bo; in drv_bo_import() local
352 bo = drv_bo_new(drv, data->width, data->height, data->format, data->use_flags); in drv_bo_import()
354 if (!bo) in drv_bo_import()
357 ret = drv->backend->bo_import(bo, data); in drv_bo_import()
359 free(bo); in drv_bo_import()
363 for (plane = 0; plane < bo->num_planes; plane++) { in drv_bo_import()
364 bo->strides[plane] = data->strides[plane]; in drv_bo_import()
365 bo->offsets[plane] = data->offsets[plane]; in drv_bo_import()
366 bo->format_modifiers[plane] = data->format_modifiers[plane]; in drv_bo_import()
375 if (plane == bo->num_planes - 1 || data->offsets[plane + 1] == 0) in drv_bo_import()
376 bo->sizes[plane] = seek_end - data->offsets[plane]; in drv_bo_import()
378 bo->sizes[plane] = data->offsets[plane + 1] - data->offsets[plane]; in drv_bo_import()
380 if ((int64_t)bo->offsets[plane] + bo->sizes[plane] > seek_end) { in drv_bo_import()
385 bo->total_size += bo->sizes[plane]; in drv_bo_import()
388 return bo; in drv_bo_import()
391 drv_bo_destroy(bo); in drv_bo_import()
395 void *drv_bo_map(struct bo *bo, const struct rectangle *rect, uint32_t map_flags, in drv_bo_map() argument
404 assert(rect->x + rect->width <= drv_bo_get_width(bo)); in drv_bo_map()
405 assert(rect->y + rect->height <= drv_bo_get_height(bo)); in drv_bo_map()
408 assert(!(bo->use_flags & BO_USE_PROTECTED)); in drv_bo_map()
414 pthread_mutex_lock(&bo->drv->driver_lock); in drv_bo_map()
416 for (i = 0; i < drv_array_size(bo->drv->mappings); i++) { in drv_bo_map()
417 struct mapping *prior = (struct mapping *)drv_array_at_idx(bo->drv->mappings, i); in drv_bo_map()
418 if (prior->vma->handle != bo->handles[plane].u32 || in drv_bo_map()
431 for (i = 0; i < drv_array_size(bo->drv->mappings); i++) { in drv_bo_map()
432 struct mapping *prior = (struct mapping *)drv_array_at_idx(bo->drv->mappings, i); in drv_bo_map()
433 if (prior->vma->handle != bo->handles[plane].u32 || in drv_bo_map()
443 memcpy(mapping.vma->map_strides, bo->strides, sizeof(mapping.vma->map_strides)); in drv_bo_map()
444 addr = bo->drv->backend->bo_map(bo, mapping.vma, plane, map_flags); in drv_bo_map()
448 pthread_mutex_unlock(&bo->drv->driver_lock); in drv_bo_map()
454 mapping.vma->handle = bo->handles[plane].u32; in drv_bo_map()
458 *map_data = drv_array_append(bo->drv->mappings, &mapping); in drv_bo_map()
460 drv_bo_invalidate(bo, *map_data); in drv_bo_map()
462 addr += drv_bo_get_plane_offset(bo, plane); in drv_bo_map()
463 pthread_mutex_unlock(&bo->drv->driver_lock); in drv_bo_map()
467 int drv_bo_unmap(struct bo *bo, struct mapping *mapping) in drv_bo_unmap() argument
472 pthread_mutex_lock(&bo->drv->driver_lock); in drv_bo_unmap()
478 ret = bo->drv->backend->bo_unmap(bo, mapping->vma); in drv_bo_unmap()
482 for (i = 0; i < drv_array_size(bo->drv->mappings); i++) { in drv_bo_unmap()
483 if (mapping == (struct mapping *)drv_array_at_idx(bo->drv->mappings, i)) { in drv_bo_unmap()
484 drv_array_remove(bo->drv->mappings, i); in drv_bo_unmap()
490 pthread_mutex_unlock(&bo->drv->driver_lock); in drv_bo_unmap()
494 int drv_bo_invalidate(struct bo *bo, struct mapping *mapping) in drv_bo_invalidate() argument
503 if (bo->drv->backend->bo_invalidate) in drv_bo_invalidate()
504 ret = bo->drv->backend->bo_invalidate(bo, mapping); in drv_bo_invalidate()
509 int drv_bo_flush_or_unmap(struct bo *bo, struct mapping *mapping) in drv_bo_flush_or_unmap() argument
517 assert(!(bo->use_flags & BO_USE_PROTECTED)); in drv_bo_flush_or_unmap()
519 if (bo->drv->backend->bo_flush) in drv_bo_flush_or_unmap()
520 ret = bo->drv->backend->bo_flush(bo, mapping); in drv_bo_flush_or_unmap()
522 ret = drv_bo_unmap(bo, mapping); in drv_bo_flush_or_unmap()
527 uint32_t drv_bo_get_width(struct bo *bo) in drv_bo_get_width() argument
529 return bo->width; in drv_bo_get_width()
532 uint32_t drv_bo_get_height(struct bo *bo) in drv_bo_get_height() argument
534 return bo->height; in drv_bo_get_height()
537 uint32_t drv_bo_get_stride_or_tiling(struct bo *bo) in drv_bo_get_stride_or_tiling() argument
539 return bo->tiling ? bo->tiling : drv_bo_get_plane_stride(bo, 0); in drv_bo_get_stride_or_tiling()
542 size_t drv_bo_get_num_planes(struct bo *bo) in drv_bo_get_num_planes() argument
544 return bo->num_planes; in drv_bo_get_num_planes()
547 union bo_handle drv_bo_get_plane_handle(struct bo *bo, size_t plane) in drv_bo_get_plane_handle() argument
549 return bo->handles[plane]; in drv_bo_get_plane_handle()
556 int drv_bo_get_plane_fd(struct bo *bo, size_t plane) in drv_bo_get_plane_fd() argument
560 assert(plane < bo->num_planes); in drv_bo_get_plane_fd()
562 ret = drmPrimeHandleToFD(bo->drv->fd, bo->handles[plane].u32, DRM_CLOEXEC | DRM_RDWR, &fd); in drv_bo_get_plane_fd()
566 ret = drmPrimeHandleToFD(bo->drv->fd, bo->handles[plane].u32, DRM_CLOEXEC, &fd); in drv_bo_get_plane_fd()
571 uint32_t drv_bo_get_plane_offset(struct bo *bo, size_t plane) in drv_bo_get_plane_offset() argument
573 assert(plane < bo->num_planes); in drv_bo_get_plane_offset()
574 return bo->offsets[plane]; in drv_bo_get_plane_offset()
577 uint32_t drv_bo_get_plane_size(struct bo *bo, size_t plane) in drv_bo_get_plane_size() argument
579 assert(plane < bo->num_planes); in drv_bo_get_plane_size()
580 return bo->sizes[plane]; in drv_bo_get_plane_size()
583 uint32_t drv_bo_get_plane_stride(struct bo *bo, size_t plane) in drv_bo_get_plane_stride() argument
585 assert(plane < bo->num_planes); in drv_bo_get_plane_stride()
586 return bo->strides[plane]; in drv_bo_get_plane_stride()
589 uint64_t drv_bo_get_plane_format_modifier(struct bo *bo, size_t plane) in drv_bo_get_plane_format_modifier() argument
591 assert(plane < bo->num_planes); in drv_bo_get_plane_format_modifier()
592 return bo->format_modifiers[plane]; in drv_bo_get_plane_format_modifier()
595 uint32_t drv_bo_get_format(struct bo *bo) in drv_bo_get_format() argument
597 return bo->format; in drv_bo_get_format()
608 uint32_t drv_num_buffers_per_bo(struct bo *bo) in drv_num_buffers_per_bo() argument
613 for (plane = 0; plane < bo->num_planes; plane++) { in drv_num_buffers_per_bo()
615 if (bo->handles[p].u32 == bo->handles[plane].u32) in drv_num_buffers_per_bo()