1 /* 2 * Copyright (C) ROCKCHIP, Inc. 3 * Author:yzq<yzq@rock-chips.com> 4 * 5 * based on exynos_drmif.h 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a 8 * copy of this software and associated documentation files (the "Software"), 9 * to deal in the Software without restriction, including without limitation 10 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 * and/or sell copies of the Software, and to permit persons to whom the 12 * Software is furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the next 15 * paragraph) shall be included in all copies or substantial portions of the 16 * Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 * SOFTWARE. 25 * 26 */ 27 28 #ifndef ROCKCHIP_DRMIF_H_ 29 #define ROCKCHIP_DRMIF_H_ 30 31 #include <xf86drm.h> 32 #include <stdint.h> 33 #include "rockchip_drm.h" 34 35 struct rockchip_device { 36 int fd; 37 }; 38 39 /* 40 * Rockchip Buffer Object structure. 41 * 42 * @dev: rockchip device object allocated. 43 * @handle: a gem handle to gem object created. 44 * @flags: indicate memory allocation and cache attribute types. 45 * @size: size to the buffer created. 46 * @vaddr: user space address to a gem buffer mmaped. 47 * @name: a gem global handle from flink request. 48 */ 49 struct rockchip_bo { 50 struct rockchip_device *dev; 51 uint32_t handle; 52 uint32_t flags; 53 size_t size; 54 void *vaddr; 55 uint32_t name; 56 }; 57 58 /* 59 * device related functions: 60 */ 61 struct rockchip_device *rockchip_device_create(int fd); 62 void rockchip_device_destroy(struct rockchip_device *dev); 63 64 /* 65 * buffer-object related functions: 66 */ 67 struct rockchip_bo *rockchip_bo_create(struct rockchip_device *dev, 68 size_t size, uint32_t flags); 69 int rockchip_bo_get_info(struct rockchip_device *dev, uint32_t handle, 70 size_t *size, uint32_t *flags); 71 void rockchip_bo_destroy(struct rockchip_bo *bo); 72 struct rockchip_bo *rockchip_bo_from_name(struct rockchip_device *dev, 73 uint32_t name); 74 int rockchip_bo_get_name(struct rockchip_bo *bo, uint32_t *name); 75 uint32_t rockchip_bo_handle(struct rockchip_bo *bo); 76 struct rockchip_bo *rockchip_bo_from_handle(struct rockchip_device *dev, 77 uint32_t handle, uint32_t flags, uint32_t size); 78 void *rockchip_bo_map(struct rockchip_bo *bo); 79 #endif /* ROCKCHIP_DRMIF_H_ */ 80