1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd 4 * Author:Mark Yao <mark.yao@rock-chips.com> 5 */ 6 7 #ifndef _ROCKCHIP_DRM_GEM_H 8 #define _ROCKCHIP_DRM_GEM_H 9 10 #define to_rockchip_obj(x) container_of(x, struct rockchip_gem_object, base) 11 12 struct rockchip_gem_object { 13 struct drm_gem_object base; 14 unsigned int flags; 15 16 void *kvaddr; 17 dma_addr_t dma_addr; 18 /* Used when IOMMU is disabled */ 19 unsigned long dma_attrs; 20 21 /* Used when IOMMU is enabled */ 22 struct drm_mm_node mm; 23 unsigned long num_pages; 24 struct page **pages; 25 struct sg_table *sgt; 26 size_t size; 27 }; 28 29 struct sg_table *rockchip_gem_prime_get_sg_table(struct drm_gem_object *obj); 30 struct drm_gem_object * 31 rockchip_gem_prime_import_sg_table(struct drm_device *dev, 32 struct dma_buf_attachment *attach, 33 struct sg_table *sg); 34 int rockchip_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map); 35 void rockchip_gem_prime_vunmap(struct drm_gem_object *obj, 36 struct iosys_map *map); 37 38 struct rockchip_gem_object * 39 rockchip_gem_create_object(struct drm_device *drm, unsigned int size, 40 bool alloc_kmap); 41 42 void rockchip_gem_free_object(struct drm_gem_object *obj); 43 44 int rockchip_gem_dumb_create(struct drm_file *file_priv, 45 struct drm_device *dev, 46 struct drm_mode_create_dumb *args); 47 #endif /* _ROCKCHIP_DRM_GEM_H */ 48