drm/rockchip: add rk3399 vop big csc support
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / rockchip / rockchip_drm_gem.h
1 /*
2  * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
3  * Author:Mark Yao <mark.yao@rock-chips.com>
4  *
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.
8  *
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.
13  */
14
15 #ifndef _ROCKCHIP_DRM_GEM_H
16 #define _ROCKCHIP_DRM_GEM_H
17
18 #define to_rockchip_obj(x) container_of(x, struct rockchip_gem_object, base)
19
20 struct rockchip_gem_object {
21         struct drm_gem_object base;
22         unsigned int flags;
23
24         struct sg_table *sgt;
25         void *kvaddr;
26         dma_addr_t dma_addr;
27         struct dma_attrs dma_attrs;
28
29 #ifdef CONFIG_DRM_DMA_SYNC
30         struct fence *acquire_fence;
31         atomic_t acquire_shared_count;
32         bool acquire_exclusive;
33 #endif
34 };
35
36 /*
37  * rockchip drm GEM object linked list structure.
38  *
39  * @list: list link.
40  * @rockchip_gem_obj: struct rockchhip_gem_object that this entry points to.
41  */
42 struct rockchip_gem_object_node {
43         struct list_head                list;
44         struct rockchip_gem_object      *rockchip_gem_obj;
45 };
46
47 struct sg_table *rockchip_gem_prime_get_sg_table(struct drm_gem_object *obj);
48 struct drm_gem_object *
49 rockchip_gem_prime_import_sg_table(struct drm_device *dev,
50                                    struct dma_buf_attachment *attach,
51                                    struct sg_table *sgt);
52 void *rockchip_gem_prime_vmap(struct drm_gem_object *obj);
53 void rockchip_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
54
55 /* drm driver mmap file operations */
56 int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma);
57
58 /* mmap a gem object to userspace. */
59 int rockchip_gem_mmap_buf(struct drm_gem_object *obj,
60                           struct vm_area_struct *vma);
61
62 struct rockchip_gem_object *
63         rockchip_gem_create_object(struct drm_device *drm, unsigned int size,
64                                    bool alloc_kmap);
65
66 void rockchip_gem_free_object(struct drm_gem_object *obj);
67
68 int rockchip_gem_dumb_create(struct drm_file *file_priv,
69                              struct drm_device *dev,
70                              struct drm_mode_create_dumb *args);
71 int rockchip_gem_dumb_map_offset(struct drm_file *file_priv,
72                                  struct drm_device *dev, uint32_t handle,
73                                  uint64_t *offset);
74 /*
75  * request gem object creation and buffer allocation as the size
76  * that it is calculated with framebuffer information such as width,
77  * height and bpp.
78  */
79 int rockchip_gem_create_ioctl(struct drm_device *dev, void *data,
80                               struct drm_file *file_priv);
81
82 /* get buffer offset to map to user space. */
83 int rockchip_gem_map_offset_ioctl(struct drm_device *dev, void *data,
84                                   struct drm_file *file_priv);
85
86 /*
87  * acquire gem object for CPU access.
88  */
89 int rockchip_gem_cpu_acquire_ioctl(struct drm_device *dev, void* data,
90                                    struct drm_file *file_priv);
91 /*
92  * release gem object after CPU access.
93  */
94 int rockchip_gem_cpu_release_ioctl(struct drm_device *dev, void* data,
95                                    struct drm_file *file_priv);
96
97 #endif /* _ROCKCHIP_DRM_GEM_H */