2 * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
3 * Author:Mark Yao <mark.yao@rock-chips.com>
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #ifndef _ROCKCHIP_DRM_GEM_H
16 #define _ROCKCHIP_DRM_GEM_H
18 #define to_rockchip_obj(x) container_of(x, struct rockchip_gem_object, base)
20 struct rockchip_gem_object {
21 struct drm_gem_object base;
26 struct dma_attrs dma_attrs;
28 #ifdef CONFIG_DRM_DMA_SYNC
29 struct fence *acquire_fence;
30 atomic_t acquire_shared_count;
31 bool acquire_exclusive;
36 * rockchip drm GEM object linked list structure.
39 * @rockchip_gem_obj: struct rockchhip_gem_object that this entry points to.
41 struct rockchip_gem_object_node {
42 struct list_head list;
43 struct rockchip_gem_object *rockchip_gem_obj;
46 struct sg_table *rockchip_gem_prime_get_sg_table(struct drm_gem_object *obj);
47 struct drm_gem_object *
48 rockchip_gem_prime_import_sg_table(struct drm_device *dev, size_t size,
49 struct sg_table *sgt);
50 void *rockchip_gem_prime_vmap(struct drm_gem_object *obj);
51 void rockchip_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
53 /* drm driver mmap file operations */
54 int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma);
56 /* mmap a gem object to userspace. */
57 int rockchip_gem_mmap_buf(struct drm_gem_object *obj,
58 struct vm_area_struct *vma);
60 struct rockchip_gem_object *
61 rockchip_gem_create_object(struct drm_device *drm, unsigned int size,
64 void rockchip_gem_free_object(struct drm_gem_object *obj);
66 int rockchip_gem_dumb_create(struct drm_file *file_priv,
67 struct drm_device *dev,
68 struct drm_mode_create_dumb *args);
69 int rockchip_gem_dumb_map_offset(struct drm_file *file_priv,
70 struct drm_device *dev, uint32_t handle,
73 * request gem object creation and buffer allocation as the size
74 * that it is calculated with framebuffer information such as width,
77 int rockchip_gem_create_ioctl(struct drm_device *dev, void *data,
78 struct drm_file *file_priv);
80 /* get buffer offset to map to user space. */
81 int rockchip_gem_map_offset_ioctl(struct drm_device *dev, void *data,
82 struct drm_file *file_priv);
85 * acquire gem object for CPU access.
87 int rockchip_gem_cpu_acquire_ioctl(struct drm_device *dev, void* data,
88 struct drm_file *file_priv);
90 * release gem object after CPU access.
92 int rockchip_gem_cpu_release_ioctl(struct drm_device *dev, void* data,
93 struct drm_file *file_priv);
95 #endif /* _ROCKCHIP_DRM_GEM_H */