18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd 48c2ecf20Sopenharmony_ci * Author:Mark Yao <mark.yao@rock-chips.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef _ROCKCHIP_DRM_GEM_H 88c2ecf20Sopenharmony_ci#define _ROCKCHIP_DRM_GEM_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#define to_rockchip_obj(x) container_of(x, struct rockchip_gem_object, base) 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_cistruct rockchip_gem_object { 138c2ecf20Sopenharmony_ci struct drm_gem_object base; 148c2ecf20Sopenharmony_ci unsigned int flags; 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci void *kvaddr; 178c2ecf20Sopenharmony_ci dma_addr_t dma_addr; 188c2ecf20Sopenharmony_ci /* Used when IOMMU is disabled */ 198c2ecf20Sopenharmony_ci unsigned long dma_attrs; 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci /* Used when IOMMU is enabled */ 228c2ecf20Sopenharmony_ci struct drm_mm_node mm; 238c2ecf20Sopenharmony_ci unsigned long num_pages; 248c2ecf20Sopenharmony_ci struct page **pages; 258c2ecf20Sopenharmony_ci struct sg_table *sgt; 268c2ecf20Sopenharmony_ci size_t size; 278c2ecf20Sopenharmony_ci}; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistruct sg_table *rockchip_gem_prime_get_sg_table(struct drm_gem_object *obj); 308c2ecf20Sopenharmony_cistruct drm_gem_object * 318c2ecf20Sopenharmony_cirockchip_gem_prime_import_sg_table(struct drm_device *dev, 328c2ecf20Sopenharmony_ci struct dma_buf_attachment *attach, 338c2ecf20Sopenharmony_ci struct sg_table *sg); 348c2ecf20Sopenharmony_civoid *rockchip_gem_prime_vmap(struct drm_gem_object *obj); 358c2ecf20Sopenharmony_civoid rockchip_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* drm driver mmap file operations */ 388c2ecf20Sopenharmony_ciint rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma); 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/* mmap a gem object to userspace. */ 418c2ecf20Sopenharmony_ciint rockchip_gem_mmap_buf(struct drm_gem_object *obj, 428c2ecf20Sopenharmony_ci struct vm_area_struct *vma); 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistruct rockchip_gem_object * 458c2ecf20Sopenharmony_ci rockchip_gem_create_object(struct drm_device *drm, unsigned int size, 468c2ecf20Sopenharmony_ci bool alloc_kmap); 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_civoid rockchip_gem_free_object(struct drm_gem_object *obj); 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ciint rockchip_gem_dumb_create(struct drm_file *file_priv, 518c2ecf20Sopenharmony_ci struct drm_device *dev, 528c2ecf20Sopenharmony_ci struct drm_mode_create_dumb *args); 538c2ecf20Sopenharmony_ci#endif /* _ROCKCHIP_DRM_GEM_H */ 54