49426eb0034cafdac5b36e0d74e898f89c5b6ff0
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / rockchip / rockchip_drm_rga.h
1 #ifndef __ROCKCHIP_DRM_RGA__
2 #define __ROCKCHIP_DRM_RGA__
3
4 #define RGA_CMDBUF_SIZE                 14
5 #define RGA_CMDLIST_SIZE                0x20
6 #define RGA_CMDLIST_NUM                 64
7
8 /* cmdlist data structure */
9 struct rga_cmdlist {
10         u32             head;
11         u32             data[(RGA_CMDLIST_SIZE + RGA_CMDBUF_SIZE) * 2];
12         u32             last;   /* last data offset */
13         void            *src_mmu_pages;
14         void            *dst_mmu_pages;
15         void            *src1_mmu_pages;
16         struct dma_buf_attachment *src_attach;
17         struct dma_buf_attachment *dst_attach;
18 };
19
20 struct rga_cmdlist_node {
21         struct list_head        list;
22         struct rga_cmdlist      cmdlist;
23 };
24
25 struct rga_runqueue_node {
26         struct list_head        list;
27
28         struct device           *dev;
29         pid_t                   pid;
30         struct drm_file         *file;
31         struct completion       complete;
32
33         struct list_head        run_cmdlist;
34
35         int                     cmdlist_cnt;
36         void                    *cmdlist_pool_virt;
37         dma_addr_t              cmdlist_pool;
38         struct dma_attrs        cmdlist_dma_attrs;
39 };
40
41 struct rockchip_rga_version {
42         u32                     major;
43         u32                     minor;
44 };
45
46 struct rockchip_rga {
47         struct drm_device       *drm_dev;
48         struct device           *dev;
49         struct regmap           *grf;
50         void __iomem            *regs;
51         struct clk              *sclk;
52         struct clk              *aclk;
53         struct clk              *hclk;
54
55         bool                            suspended;
56         struct rockchip_rga_version     version;
57         struct drm_rockchip_subdrv      subdrv;
58         struct workqueue_struct         *rga_workq;
59         struct work_struct              runqueue_work;
60
61         /* rga command list pool */
62         struct rga_cmdlist_node         cmdlist_node[RGA_CMDLIST_NUM];
63         struct mutex                    cmdlist_mutex;
64
65         struct list_head                free_cmdlist;
66
67         /* rga runqueue */
68         struct rga_runqueue_node        *runqueue_node;
69         struct list_head                runqueue_list;
70         struct mutex                    runqueue_mutex;
71         struct kmem_cache               *runqueue_slab;
72 };
73
74 struct rockchip_drm_rga_private {
75         struct device           *dev;
76         struct list_head        inuse_cmdlist;
77         struct list_head        userptr_list;
78 };
79
80 #ifdef CONFIG_ROCKCHIP_DRM_RGA
81 int rockchip_rga_get_ver_ioctl(struct drm_device *dev, void *data,
82                                struct drm_file *file_priv);
83 int rockchip_rga_set_cmdlist_ioctl(struct drm_device *dev, void *data,
84                                    struct drm_file *file_priv);
85 int rockchip_rga_exec_ioctl(struct drm_device *dev, void *data,
86                             struct drm_file *file_priv);
87 #else
88 static inline int rockchip_rga_get_ver_ioctl(struct drm_device *dev, void *data,
89                                              struct drm_file *file_priv)
90 {
91         return -ENODEV;
92 }
93
94 static inline int rockchip_rga_set_cmdlist_ioctl(struct drm_device *dev,
95                                                  void *data,
96                                                  struct drm_file *file_priv)
97 {
98         return -ENODEV;
99 }
100
101 static inline int rockchip_rga_exec_ioctl(struct drm_device *dev, void *data,
102                                           struct drm_file *file_priv)
103 {
104         return -ENODEV;
105 }
106 #endif
107
108 #endif /* __ROCKCHIP_DRM_RGA__ */