19f464c52Smaya/* 29f464c52Smaya * Copyright (C) 2018-2019 Lima Project 39f464c52Smaya * 49f464c52Smaya * Permission is hereby granted, free of charge, to any person obtaining a 59f464c52Smaya * copy of this software and associated documentation files (the "Software"), 69f464c52Smaya * to deal in the Software without restriction, including without limitation 79f464c52Smaya * the rights to use, copy, modify, merge, publish, distribute, sublicense, 89f464c52Smaya * and/or sell copies of the Software, and to permit persons to whom the 99f464c52Smaya * Software is furnished to do so, subject to the following conditions: 109f464c52Smaya * 119f464c52Smaya * The above copyright notice and this permission notice shall be included in 129f464c52Smaya * all copies or substantial portions of the Software. 139f464c52Smaya * 149f464c52Smaya * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 159f464c52Smaya * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 169f464c52Smaya * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 179f464c52Smaya * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 189f464c52Smaya * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 199f464c52Smaya * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 209f464c52Smaya * OTHER DEALINGS IN THE SOFTWARE. 219f464c52Smaya * 229f464c52Smaya */ 239f464c52Smaya 249f464c52Smaya#ifndef H_LIMA_BO 259f464c52Smaya#define H_LIMA_BO 269f464c52Smaya 279f464c52Smaya#include <stdbool.h> 289f464c52Smaya#include <stdint.h> 299f464c52Smaya 309f464c52Smaya#include "util/u_atomic.h" 317ec681f3Smrg#include "util/list.h" 329f464c52Smaya 339f464c52Smayastruct lima_bo { 349f464c52Smaya struct lima_screen *screen; 357ec681f3Smrg struct list_head time_list; 367ec681f3Smrg struct list_head size_list; 379f464c52Smaya int refcnt; 387ec681f3Smrg bool cacheable; 397ec681f3Smrg time_t free_time; 409f464c52Smaya 419f464c52Smaya uint32_t size; 427ec681f3Smrg uint32_t flags; 439f464c52Smaya uint32_t handle; 449f464c52Smaya uint64_t offset; 459f464c52Smaya uint32_t flink_name; 469f464c52Smaya 479f464c52Smaya void *map; 489f464c52Smaya uint32_t va; 499f464c52Smaya}; 509f464c52Smaya 519f464c52Smayabool lima_bo_table_init(struct lima_screen *screen); 529f464c52Smayavoid lima_bo_table_fini(struct lima_screen *screen); 537ec681f3Smrgbool lima_bo_cache_init(struct lima_screen *screen); 547ec681f3Smrgvoid lima_bo_cache_fini(struct lima_screen *screen); 559f464c52Smaya 569f464c52Smayastruct lima_bo *lima_bo_create(struct lima_screen *screen, uint32_t size, 579f464c52Smaya uint32_t flags); 587ec681f3Smrgvoid lima_bo_unreference(struct lima_bo *bo); 599f464c52Smaya 609f464c52Smayastatic inline void lima_bo_reference(struct lima_bo *bo) 619f464c52Smaya{ 629f464c52Smaya p_atomic_inc(&bo->refcnt); 639f464c52Smaya} 649f464c52Smaya 659f464c52Smayavoid *lima_bo_map(struct lima_bo *bo); 669f464c52Smayavoid lima_bo_unmap(struct lima_bo *bo); 679f464c52Smaya 689f464c52Smayabool lima_bo_export(struct lima_bo *bo, struct winsys_handle *handle); 699f464c52Smayastruct lima_bo *lima_bo_import(struct lima_screen *screen, 709f464c52Smaya struct winsys_handle *handle); 719f464c52Smaya 729f464c52Smayabool lima_bo_wait(struct lima_bo *bo, uint32_t op, uint64_t timeout_ns); 739f464c52Smaya 749f464c52Smaya#endif 75