17ec681f3Smrg/* 27ec681f3Smrg * Copyright © 2019 Raspberry Pi 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 207ec681f3Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 217ec681f3Smrg * IN THE SOFTWARE. 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg#ifndef V3DV_BO_H 257ec681f3Smrg#define V3DV_BO_H 267ec681f3Smrg 277ec681f3Smrgstruct v3dv_device; 287ec681f3Smrg 297ec681f3Smrgstruct v3dv_bo { 307ec681f3Smrg struct list_head list_link; 317ec681f3Smrg 327ec681f3Smrg uint32_t handle; 337ec681f3Smrg uint64_t handle_bit; 347ec681f3Smrg uint32_t size; 357ec681f3Smrg uint32_t offset; 367ec681f3Smrg 377ec681f3Smrg uint32_t map_size; 387ec681f3Smrg void *map; 397ec681f3Smrg 407ec681f3Smrg const char *name; 417ec681f3Smrg 427ec681f3Smrg /** Entry in the linked list of buffers freed, by age. */ 437ec681f3Smrg struct list_head time_list; 447ec681f3Smrg /** Entry in the per-page-count linked list of buffers freed (by age). */ 457ec681f3Smrg struct list_head size_list; 467ec681f3Smrg /** Approximate second when the bo was freed. */ 477ec681f3Smrg time_t free_time; 487ec681f3Smrg 497ec681f3Smrg /** 507ec681f3Smrg * Whether only our process has a reference to the BO (meaning that 517ec681f3Smrg * it's safe to reuse it in the BO cache). 527ec681f3Smrg */ 537ec681f3Smrg bool private; 547ec681f3Smrg 557ec681f3Smrg /** 567ec681f3Smrg * If this BO was allocated for a swapchain on the display device, the 577ec681f3Smrg * handle of the dumb BO on that device. 587ec681f3Smrg */ 597ec681f3Smrg int32_t dumb_handle; 607ec681f3Smrg}; 617ec681f3Smrg 627ec681f3Smrgvoid v3dv_bo_init(struct v3dv_bo *bo, uint32_t handle, uint32_t size, uint32_t offset, const char *name, bool private); 637ec681f3Smrg 647ec681f3Smrgstruct v3dv_bo *v3dv_bo_alloc(struct v3dv_device *device, uint32_t size, const char *name, bool private); 657ec681f3Smrg 667ec681f3Smrgbool v3dv_bo_free(struct v3dv_device *device, struct v3dv_bo *bo); 677ec681f3Smrg 687ec681f3Smrgbool v3dv_bo_wait(struct v3dv_device *device, struct v3dv_bo *bo, uint64_t timeout_ns); 697ec681f3Smrg 707ec681f3Smrgbool v3dv_bo_map_unsynchronized(struct v3dv_device *device, struct v3dv_bo *bo, uint32_t size); 717ec681f3Smrg 727ec681f3Smrgbool v3dv_bo_map(struct v3dv_device *device, struct v3dv_bo *bo, uint32_t size); 737ec681f3Smrg 747ec681f3Smrgvoid v3dv_bo_unmap(struct v3dv_device *device, struct v3dv_bo *bo); 757ec681f3Smrg 767ec681f3Smrgvoid v3dv_bo_cache_init(struct v3dv_device *device); 777ec681f3Smrgvoid v3dv_bo_cache_destroy(struct v3dv_device *device); 787ec681f3Smrg 797ec681f3Smrg#endif /* V3DV_BO_H */ 80